@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.
Files changed (50) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +180 -0
  3. package/cordis.patch.yml +13 -0
  4. package/lib/client.js +3924 -0
  5. package/lib/client.js.map +1 -0
  6. package/lib/index.js +3120 -0
  7. package/lib/index.js.map +1 -0
  8. package/lib/types/assets.d.ts +35 -0
  9. package/lib/types/assistant.d.ts +43 -0
  10. package/lib/types/bookshelf.d.ts +35 -0
  11. package/lib/types/client/api.d.ts +68 -0
  12. package/lib/types/client/docx.d.ts +15 -0
  13. package/lib/types/client/index.d.ts +14 -0
  14. package/lib/types/client/locales.d.ts +139 -0
  15. package/lib/types/client/mount.d.ts +9 -0
  16. package/lib/types/client/panel/AssetsTab.d.ts +7 -0
  17. package/lib/types/client/panel/AssistantTab.d.ts +7 -0
  18. package/lib/types/client/panel/BookshelfBar.d.ts +11 -0
  19. package/lib/types/client/panel/NovelPanel.d.ts +13 -0
  20. package/lib/types/client/panel/controller.d.ts +19 -0
  21. package/lib/types/client/panel/helpers.d.ts +8 -0
  22. package/lib/types/client/sidebar-entry.d.ts +13 -0
  23. package/lib/types/docx.d.ts +19 -0
  24. package/lib/types/engine.d.ts +95 -0
  25. package/lib/types/index.d.ts +55 -0
  26. package/lib/types/protocol.d.ts +521 -0
  27. package/lib/types/routes.d.ts +29 -0
  28. package/package.json +105 -0
  29. package/src/assets.ts +518 -0
  30. package/src/assistant.ts +547 -0
  31. package/src/bookshelf.ts +137 -0
  32. package/src/client/api.ts +254 -0
  33. package/src/client/css-modules.d.ts +8 -0
  34. package/src/client/docx.ts +69 -0
  35. package/src/client/index.ts +34 -0
  36. package/src/client/locales.ts +271 -0
  37. package/src/client/mount.tsx +97 -0
  38. package/src/client/panel/AssetsTab.tsx +341 -0
  39. package/src/client/panel/AssistantTab.tsx +188 -0
  40. package/src/client/panel/BookshelfBar.tsx +116 -0
  41. package/src/client/panel/NovelPanel.tsx +990 -0
  42. package/src/client/panel/controller.ts +45 -0
  43. package/src/client/panel/helpers.ts +17 -0
  44. package/src/client/panel/panel.module.css +894 -0
  45. package/src/client/sidebar-entry.ts +122 -0
  46. package/src/docx.ts +83 -0
  47. package/src/engine.ts +1019 -0
  48. package/src/index.ts +184 -0
  49. package/src/protocol.ts +539 -0
  50. 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
+ }