dsh-tiddlywiki 0.7.4 → 0.8.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/README.md +24 -1
- package/lib/client.bundle.js +264 -2
- package/lib/client.js +264 -2
- package/lib/index.js +18 -5
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client/editor-popup.ts +127 -121
- package/src/client/panel.ts +12 -1
- package/src/client/settings-page.ts +2 -0
- package/src/client/styles.ts +4 -2
- package/src/client/theme-sync.ts +312 -0
- package/src/host/config.ts +14 -0
- package/src/host/routes.ts +5 -1
- package/src/index.ts +15 -9
package/src/host/config.ts
CHANGED
|
@@ -16,6 +16,12 @@ import type { TiddlyWebClient } from './tw-api.ts'
|
|
|
16
16
|
/** Config tiddler (JSON string) where the settings page stores overrides. */
|
|
17
17
|
export const CONFIG_TIDDLER = '$:/plugins/dsh-tiddlywiki/config'
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Default dark palette the embedded TW switches to when DSH is dark
|
|
21
|
+
* (mirrored in src/client/theme-sync.ts — the two bundles cannot share code).
|
|
22
|
+
*/
|
|
23
|
+
export const DARK_PALETTE_DEFAULT = '$:/palettes/CupertinoDark'
|
|
24
|
+
|
|
19
25
|
/** Extensible, loose plugin config shape (future fields just appear here). */
|
|
20
26
|
export interface PluginConfigShape {
|
|
21
27
|
note?: { tag?: string }
|
|
@@ -27,6 +33,14 @@ export interface PluginConfigShape {
|
|
|
27
33
|
showPanelStatus?: boolean
|
|
28
34
|
/** 是否在界面右下角显示「同步」悬浮按钮(默认 true)。 */
|
|
29
35
|
showSyncButton?: boolean
|
|
36
|
+
/**
|
|
37
|
+
* 嵌入式 TW 是否跟随 DSH 深浅主题(默认 true):DSH 暗色时把 TW 活动
|
|
38
|
+
* palette 临时切到 `darkPalette`,浅色时恢复用户原 palette;仅内存生效,
|
|
39
|
+
* 不会写回 wiki。
|
|
40
|
+
*/
|
|
41
|
+
followDshTheme?: boolean
|
|
42
|
+
/** DSH 暗色时 TW 使用的 palette tiddler 标题(默认 CupertinoDark)。 */
|
|
43
|
+
darkPalette?: string
|
|
30
44
|
/**
|
|
31
45
|
* 一键发送给 Agent(TW 笔记 → DSH 会话注入)。
|
|
32
46
|
* `enabled: false` 时路由 403、TW 端按钮点击提示未启用;`token` 非空时
|
package/src/host/routes.ts
CHANGED
|
@@ -83,11 +83,15 @@ export interface WorkspaceRegistryFace {
|
|
|
83
83
|
create(path: string, title?: string): Promise<{ id: string; path: string }>
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
/** Effective UI
|
|
86
|
+
/** Effective UI flags returned by /status (mirror index.ts). */
|
|
87
87
|
export interface UiDefaultsPublic {
|
|
88
88
|
showQuickNote: boolean
|
|
89
89
|
showPanelStatus: boolean
|
|
90
90
|
showSyncButton: boolean
|
|
91
|
+
/** 嵌入式 TW 是否跟随 DSH 深浅主题(false 时客户端停止 palette 同步)。 */
|
|
92
|
+
followDshTheme: boolean
|
|
93
|
+
/** DSH 暗色时 TW 使用的 palette tiddler 标题。 */
|
|
94
|
+
darkPalette: string
|
|
91
95
|
}
|
|
92
96
|
|
|
93
97
|
export interface RouteDeps {
|
package/src/index.ts
CHANGED
|
@@ -23,7 +23,7 @@ import { writeFile } from 'node:fs/promises'
|
|
|
23
23
|
import { join } from 'node:path'
|
|
24
24
|
import { AutoCommitter, GitFace } from './host/git.ts'
|
|
25
25
|
import { registerRoutes, type SessionControllerFace, type WebServerFace, type WorkspaceRegistryFace } from './host/routes.ts'
|
|
26
|
-
import { ConfigStore, deepMerge, type PluginConfigShape } from './host/config.ts'
|
|
26
|
+
import { ConfigStore, deepMerge, DARK_PALETTE_DEFAULT, type PluginConfigShape } from './host/config.ts'
|
|
27
27
|
import { registerAdminRoutes, ensureLanguage, resolveTwRoot, type AdminDeps } from './host/admin.ts'
|
|
28
28
|
import { seedDocNote, DOC_NOTE_TITLE } from './host/seed-notes.ts'
|
|
29
29
|
import { TiddlyWebClient } from './host/tw-api.ts'
|
|
@@ -56,7 +56,7 @@ export interface TiddlywikiConfig {
|
|
|
56
56
|
port?: number
|
|
57
57
|
git?: { autoCommit?: boolean; debounceMs?: number; remote?: string; branch?: string }
|
|
58
58
|
note?: { tag?: string }
|
|
59
|
-
ui?: { showQuickNote?: boolean; showPanelStatus?: boolean; showSyncButton?: boolean }
|
|
59
|
+
ui?: { showQuickNote?: boolean; showPanelStatus?: boolean; showSyncButton?: boolean; followDshTheme?: boolean; darkPalette?: string }
|
|
60
60
|
auth?: { username?: string; password?: string }
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -77,7 +77,7 @@ interface ResolvedConfig {
|
|
|
77
77
|
port: number
|
|
78
78
|
git: { autoCommit: boolean; debounceMs: number; remote: string; branch: string }
|
|
79
79
|
note: { tag: string }
|
|
80
|
-
ui: { showQuickNote: boolean; showPanelStatus: boolean; showSyncButton: boolean; sendToAgent: { enabled: boolean } }
|
|
80
|
+
ui: { showQuickNote: boolean; showPanelStatus: boolean; showSyncButton: boolean; followDshTheme: boolean; darkPalette: string; sendToAgent: { enabled: boolean } }
|
|
81
81
|
auth: { username?: string; password?: string }
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -87,7 +87,7 @@ const DEFAULTS: ResolvedConfig = {
|
|
|
87
87
|
port: 0,
|
|
88
88
|
git: { autoCommit: true, debounceMs: 60_000, remote: '', branch: 'main' },
|
|
89
89
|
note: { tag: 'inbox' },
|
|
90
|
-
ui: { showQuickNote: true, showPanelStatus: true, showSyncButton: true, sendToAgent: { enabled: true } },
|
|
90
|
+
ui: { showQuickNote: true, showPanelStatus: true, showSyncButton: true, followDshTheme: true, darkPalette: DARK_PALETTE_DEFAULT, sendToAgent: { enabled: true } },
|
|
91
91
|
auth: { username: '', password: '' },
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -214,11 +214,17 @@ export function apply(ctx: HostCtx, rawConfig: TiddlywikiConfig = {}): void {
|
|
|
214
214
|
const tag = eff().note?.tag
|
|
215
215
|
return typeof tag === 'string' && tag.trim().length > 0 ? tag : config.note.tag
|
|
216
216
|
}
|
|
217
|
-
const effectiveUi = (): { showQuickNote: boolean; showPanelStatus: boolean; showSyncButton: boolean } =>
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
217
|
+
const effectiveUi = (): { showQuickNote: boolean; showPanelStatus: boolean; showSyncButton: boolean; followDshTheme: boolean; darkPalette: string } => {
|
|
218
|
+
const ui = eff().ui ?? {}
|
|
219
|
+
const palette = typeof ui.darkPalette === 'string' && ui.darkPalette.trim().length > 0 ? ui.darkPalette.trim() : DARK_PALETTE_DEFAULT
|
|
220
|
+
return {
|
|
221
|
+
showQuickNote: ui.showQuickNote !== false,
|
|
222
|
+
showPanelStatus: ui.showPanelStatus !== false,
|
|
223
|
+
showSyncButton: ui.showSyncButton !== false,
|
|
224
|
+
followDshTheme: ui.followDshTheme !== false,
|
|
225
|
+
darkPalette: palette,
|
|
226
|
+
}
|
|
227
|
+
}
|
|
222
228
|
|
|
223
229
|
const disposers: Array<() => void> = []
|
|
224
230
|
const disposeAll = (): void => {
|