diff --git a/ui/build b/ui/build index 49977bc275..62fe626caf 100755 --- a/ui/build +++ b/ui/build @@ -15,7 +15,7 @@ mkdir -p public/compiled apps1="common" apps2="chess ceval game tree chat nvui puz" -apps3="site swiss msg chat cli challenge notify learn insight editor puzzle round analyse lobby tournament tournamentSchedule tournamentCalendar simul dasher speech palantir serviceWorker dgt storm racer" +apps3="site swiss msg chat cli challenge notify learn insight editor puzzle round analyse lobby tournament tournamentSchedule tournamentCalendar simul dasher speech palantir serviceWorker dgt storm" site_plugins="tvEmbed puzzleEmbed analyseEmbed user modUser clas coordinate captcha expandText team forum account coachShow coachForm challengePage checkout login passwordComplexity tourForm teamBattleForm gameSearch userComplete infiniteScroll flatpickr teamAdmin appeal modGames" round_plugins="nvui keyboardMove" analyse_plugins="nvui studyTopicForm" diff --git a/ui/puz/package.json b/ui/puz/package.json index bb81592259..e11f05b9a6 100644 --- a/ui/puz/package.json +++ b/ui/puz/package.json @@ -8,7 +8,7 @@ "author": "Thibault Duplessis", "license": "AGPL-3.0-or-later", "scripts": { - "compile": "../../node_modules/typescript/bin/tsc --incremental --outDir ./dist --declaration --inlineSourceMap", + "compile": "../../node_modules/typescript/bin/tsc", "dev": "yarn run compile", "prod": "yarn run compile" }, diff --git a/ui/puz/src/interfaces.ts b/ui/puz/src/interfaces.ts index 9a8a4988ed..6bc9deebaa 100644 --- a/ui/puz/src/interfaces.ts +++ b/ui/puz/src/interfaces.ts @@ -1,3 +1,16 @@ +import { Role } from 'chessground/types'; +import { VNode } from 'snabbdom/vnode'; + +export type MaybeVNode = VNode | string | null | undefined; +export type MaybeVNodes = MaybeVNode[]; +export type Redraw = () => void; + +export interface Promotion { + start(orig: Key, dest: Key, callback: (orig: Key, dest: Key, prom: Role) => void): boolean; + cancel(): void; + view(): MaybeVNode; +} + export interface Prefs { coords: 0 | 1 | 2; is3d: boolean; diff --git a/ui/storm/src/promotion.ts b/ui/puz/src/promotion.ts similarity index 100% rename from ui/storm/src/promotion.ts rename to ui/puz/src/promotion.ts diff --git a/ui/storm/src/util.ts b/ui/puz/src/util.ts similarity index 100% rename from ui/storm/src/util.ts rename to ui/puz/src/util.ts diff --git a/ui/puz/src/view/chessground.ts b/ui/puz/src/view/chessground.ts index f7ed032ffa..cb3379d871 100644 --- a/ui/puz/src/view/chessground.ts +++ b/ui/puz/src/view/chessground.ts @@ -1,8 +1,6 @@ import changeColorHandle from 'common/coordsColor'; import resizeHandle from 'common/resize'; import { Config as CgConfig } from 'chessground/config'; -import { h } from 'snabbdom'; -import { VNode } from 'snabbdom/vnode'; import { Prefs, UserMove } from '../interfaces'; export function makeConfig(opts: CgConfig, pref: Prefs, userMove: UserMove): CgConfig { diff --git a/ui/puz/tsconfig.json b/ui/puz/tsconfig.json index 4bd6962d40..c667f3ae6f 100644 --- a/ui/puz/tsconfig.json +++ b/ui/puz/tsconfig.json @@ -1,4 +1,8 @@ { - "extends": "../tsconfig.base.json", - "include": ["src"] + "extends": "../tsconfig_module.base.json", + "include": ["src"], + "exclude": [], + "compilerOptions": { + "outDir": "." + } } diff --git a/ui/storm/package.json b/ui/storm/package.json index 318d8a7099..cb8d6b53b2 100644 --- a/ui/storm/package.json +++ b/ui/storm/package.json @@ -17,8 +17,9 @@ }, "dependencies": { "chessground": "^7.11.0", + "snabbdom": "^0.7.4", "common": "2.0.0", - "snabbdom": "^0.7.4" + "puz": "2.0.0" }, "scripts": { "dev": "rollup --config", diff --git a/ui/storm/src/ctrl.ts b/ui/storm/src/ctrl.ts index 05fc429c20..00ee44f7d9 100644 --- a/ui/storm/src/ctrl.ts +++ b/ui/storm/src/ctrl.ts @@ -1,17 +1,18 @@ import * as xhr from './xhr'; import config from './config'; -import makePromotion from './promotion'; +import makePromotion from 'puz/promotion'; import sign from './sign'; import { Api as CgApi } from 'chessground/api'; import { Chess } from 'chessops/chess'; import { chessgroundDests } from 'chessops/compat'; import { Config as CgConfig } from 'chessground/config'; -import { getNow } from './util'; +import { getNow } from 'puz/util'; import { parseFen, makeFen } from 'chessops/fen'; import { parseUci, opposite } from 'chessops/util'; import { prop, Prop } from 'common'; import { Role } from 'chessground/types'; -import { StormOpts, StormData, StormPuzzle, StormVm, Promotion, TimeMod, StormRun, StormPrefs } from './interfaces'; +import { StormOpts, StormData, StormPuzzle, StormVm, TimeMod, StormRun, StormPrefs } from './interfaces'; +import { Promotion } from 'puz/interfaces'; export default class StormCtrl { private data: StormData; @@ -206,9 +207,6 @@ export default class StormCtrl { dests: chessgroundDests(pos), } : undefined, - premovable: { - enabled: false, - }, check: !!pos.isCheck(), lastMove: this.uciToLastMove(this.line()[this.vm.moveIndex]), }; diff --git a/ui/storm/src/interfaces.ts b/ui/storm/src/interfaces.ts index de50fa3845..411ab48276 100644 --- a/ui/storm/src/interfaces.ts +++ b/ui/storm/src/interfaces.ts @@ -1,10 +1,4 @@ -import { Role } from 'chessground/types'; import { Prop } from 'common'; -import { VNode } from 'snabbdom/vnode'; - -export type MaybeVNode = VNode | string | null | undefined; -export type MaybeVNodes = MaybeVNode[]; -export type Redraw = () => void; export interface StormOpts { data: StormData; @@ -74,12 +68,6 @@ export interface StormPuzzle { rating: number; } -export interface Promotion { - start(orig: Key, dest: Key, callback: (orig: Key, dest: Key, prom: Role) => void): boolean; - cancel(): void; - view(): MaybeVNode; -} - export interface DailyBest { score: number; prev?: number; diff --git a/ui/storm/src/view/clock.ts b/ui/storm/src/view/clock.ts index ae410b604e..6bbc092739 100644 --- a/ui/storm/src/view/clock.ts +++ b/ui/storm/src/view/clock.ts @@ -1,6 +1,6 @@ import StormCtrl from '../ctrl'; import { defined } from 'common'; -import { getNow } from '../util'; +import { getNow } from 'puz/util'; import { h } from 'snabbdom'; import { VNode } from 'snabbdom/vnode'; import { TimeMod } from '../interfaces'; diff --git a/ui/storm/src/view/end.ts b/ui/storm/src/view/end.ts index d467d10bb4..075c97cdf0 100644 --- a/ui/storm/src/view/end.ts +++ b/ui/storm/src/view/end.ts @@ -1,7 +1,7 @@ import * as miniBoard from 'common/mini-board'; import StormCtrl from '../ctrl'; import { Chess } from 'chessops/chess'; -import { getNow, onInsert } from '../util'; +import { getNow, onInsert } from 'puz/util'; import { h } from 'snabbdom'; import { numberSpread } from 'common/number'; import { parseFen, makeFen } from 'chessops/fen'; diff --git a/ui/storm/src/view/main.ts b/ui/storm/src/view/main.ts index e93646d06c..2a61adc489 100644 --- a/ui/storm/src/view/main.ts +++ b/ui/storm/src/view/main.ts @@ -4,7 +4,7 @@ import config from '../config'; import renderClock from './clock'; import renderEnd from './end'; import StormCtrl from '../ctrl'; -import { getNow, onInsert } from '../util'; +import { getNow, onInsert } from 'puz/util'; import { h } from 'snabbdom'; import { VNode } from 'snabbdom/vnode'; @@ -37,7 +37,8 @@ const playModifiers = (ctrl: StormCtrl) => { const chessground = (ctrl: StormCtrl): VNode => h('div.cg-wrap', { hook: { - insert: vnode => ctrl.ground(Chessground(vnode.elm as HTMLElement, makeCgConfig(ctrl))), + insert: vnode => + ctrl.ground(Chessground(vnode.elm as HTMLElement, makeCgConfig(ctrl.makeCgOpts(), ctrl.pref, ctrl.userMove))), destroy: _ => ctrl.withGround(g => g.destroy()), }, });