@waterwx/dsh-novel-forge 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +180 -0
- package/cordis.patch.yml +13 -0
- package/lib/client.js +3924 -0
- package/lib/client.js.map +1 -0
- package/lib/index.js +3120 -0
- package/lib/index.js.map +1 -0
- package/lib/types/assets.d.ts +35 -0
- package/lib/types/assistant.d.ts +43 -0
- package/lib/types/bookshelf.d.ts +35 -0
- package/lib/types/client/api.d.ts +68 -0
- package/lib/types/client/docx.d.ts +15 -0
- package/lib/types/client/index.d.ts +14 -0
- package/lib/types/client/locales.d.ts +139 -0
- package/lib/types/client/mount.d.ts +9 -0
- package/lib/types/client/panel/AssetsTab.d.ts +7 -0
- package/lib/types/client/panel/AssistantTab.d.ts +7 -0
- package/lib/types/client/panel/BookshelfBar.d.ts +11 -0
- package/lib/types/client/panel/NovelPanel.d.ts +13 -0
- package/lib/types/client/panel/controller.d.ts +19 -0
- package/lib/types/client/panel/helpers.d.ts +8 -0
- package/lib/types/client/sidebar-entry.d.ts +13 -0
- package/lib/types/docx.d.ts +19 -0
- package/lib/types/engine.d.ts +95 -0
- package/lib/types/index.d.ts +55 -0
- package/lib/types/protocol.d.ts +521 -0
- package/lib/types/routes.d.ts +29 -0
- package/package.json +105 -0
- package/src/assets.ts +518 -0
- package/src/assistant.ts +547 -0
- package/src/bookshelf.ts +137 -0
- package/src/client/api.ts +254 -0
- package/src/client/css-modules.d.ts +8 -0
- package/src/client/docx.ts +69 -0
- package/src/client/index.ts +34 -0
- package/src/client/locales.ts +271 -0
- package/src/client/mount.tsx +97 -0
- package/src/client/panel/AssetsTab.tsx +341 -0
- package/src/client/panel/AssistantTab.tsx +188 -0
- package/src/client/panel/BookshelfBar.tsx +116 -0
- package/src/client/panel/NovelPanel.tsx +990 -0
- package/src/client/panel/controller.ts +45 -0
- package/src/client/panel/helpers.ts +17 -0
- package/src/client/panel/panel.module.css +894 -0
- package/src/client/sidebar-entry.ts +122 -0
- package/src/docx.ts +83 -0
- package/src/engine.ts +1019 -0
- package/src/index.ts +184 -0
- package/src/protocol.ts +539 -0
- package/src/routes.ts +955 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Novel-forge panel controller: the single owner of the panel's open/closed
|
|
3
|
+
* state (framework-free, mirroring the family plugins' controllers).
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** Immutable controller snapshot for UI subscriptions. */
|
|
7
|
+
export interface PanelControllerSnapshot {
|
|
8
|
+
panelOpen: boolean
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** The panel state owner the sidebar entry toggles and the view renders from. */
|
|
12
|
+
export class PanelController {
|
|
13
|
+
private panelOpen = false
|
|
14
|
+
private listeners = new Set<() => void>()
|
|
15
|
+
|
|
16
|
+
getSnapshot(): PanelControllerSnapshot {
|
|
17
|
+
return { panelOpen: this.panelOpen }
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
subscribe(fn: () => void): () => void {
|
|
21
|
+
this.listeners.add(fn)
|
|
22
|
+
return () => { this.listeners.delete(fn) }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
open(): void {
|
|
26
|
+
if (this.panelOpen) return
|
|
27
|
+
this.panelOpen = true
|
|
28
|
+
this.notify()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
close(): void {
|
|
32
|
+
if (!this.panelOpen) return
|
|
33
|
+
this.panelOpen = false
|
|
34
|
+
this.notify()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
toggle(): void {
|
|
38
|
+
if (this.panelOpen) this.close()
|
|
39
|
+
else this.open()
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private notify(): void {
|
|
43
|
+
for (const fn of [...this.listeners]) fn()
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tiny translation helper for the panel: reads the zh dict with the en dict
|
|
3
|
+
* as fallback (the family plugins use a full locale registry; the panel keeps
|
|
4
|
+
* a dependency-free helper so the client bundle stays self-contained).
|
|
5
|
+
*/
|
|
6
|
+
import { zh, en, type NovelKey } from '../locales.ts'
|
|
7
|
+
|
|
8
|
+
/** Translate one key with optional {placeholder} substitution. */
|
|
9
|
+
export function tt(key: NovelKey, params?: Record<string, string | number>): string {
|
|
10
|
+
let text: string = zh[key] ?? en[key] ?? key
|
|
11
|
+
if (params !== undefined) {
|
|
12
|
+
for (const [name, value] of Object.entries(params)) {
|
|
13
|
+
text = text.replaceAll(`{${name}}`, String(value))
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return text
|
|
17
|
+
}
|