dsh-image-video 0.3.1 → 1.0.1

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 (52) hide show
  1. package/README.md +102 -28
  2. package/cordis.patch.yml +7 -7
  3. package/lib/client/client.Workbench.js +29373 -0
  4. package/lib/client/client.Workbench.js.map +1 -0
  5. package/lib/client/plugin.js +527 -0
  6. package/lib/client/plugin.js.map +1 -0
  7. package/lib/index.d.ts +501 -85
  8. package/lib/index.js +14136 -1153
  9. package/lib/types/client/PaneBoundary.d.ts +39 -0
  10. package/lib/types/client/PipelineCard.d.ts +33 -0
  11. package/lib/types/client/RelocatedNotice.d.ts +26 -0
  12. package/lib/types/client/VirtualList.d.ts +66 -0
  13. package/lib/types/client/VoiceCard.d.ts +15 -0
  14. package/lib/types/client/Workbench.d.ts +67 -0
  15. package/lib/types/client/WorkbenchPanelIcon.d.ts +18 -0
  16. package/lib/types/client/WorkbenchSeat.d.ts +7 -0
  17. package/lib/types/client/WorkflowCanvas.d.ts +41 -0
  18. package/lib/types/client/api.d.ts +837 -0
  19. package/lib/types/client/auth/ConnectDialog.d.ts +29 -0
  20. package/lib/types/client/auth/locales.d.ts +26 -0
  21. package/lib/types/client/auth-style.d.ts +10 -0
  22. package/lib/types/client/canvas-style.d.ts +9 -0
  23. package/lib/types/client/chrome-locales.d.ts +28 -0
  24. package/lib/types/client/icons.d.ts +40 -0
  25. package/lib/types/client/locale-ns.d.ts +9 -0
  26. package/lib/types/client/locales.d.ts +9 -0
  27. package/lib/types/client/overlay-position.d.ts +65 -0
  28. package/lib/types/client/panels/AssetHealthPanel.d.ts +9 -0
  29. package/lib/types/client/panels/EpisodeWorkspace.d.ts +25 -0
  30. package/lib/types/client/panels/ExportHistoryPanel.d.ts +22 -0
  31. package/lib/types/client/panels/ModelCardsPanel.d.ts +8 -0
  32. package/lib/types/client/panels/ModelPicker.d.ts +14 -0
  33. package/lib/types/client/panels/PanelState.d.ts +43 -0
  34. package/lib/types/client/panels/PromptStudioPanel.d.ts +18 -0
  35. package/lib/types/client/panels/RatioSlicesPanel.d.ts +11 -0
  36. package/lib/types/client/panels/ResourceFoldersPanel.d.ts +11 -0
  37. package/lib/types/client/panels/SkillLibraryPanel.d.ts +10 -0
  38. package/lib/types/client/panels/TaskCard.d.ts +27 -0
  39. package/lib/types/client/panels/TimelineSegmentPreview.d.ts +8 -0
  40. package/lib/types/client/plugin.d.ts +49 -0
  41. package/lib/types/client/screens/GuideOverlay.d.ts +60 -0
  42. package/lib/types/client/screens/guide-locales.d.ts +20 -0
  43. package/lib/types/client/screens/guide-style.d.ts +31 -0
  44. package/lib/types/client/timeline-math.d.ts +82 -0
  45. package/lib/types/client/use-dialog-focus.d.ts +25 -0
  46. package/lib/types/client/use-elapsed.d.ts +12 -0
  47. package/lib/types/client/use-history-stack.d.ts +33 -0
  48. package/lib/types/client/use-unified-poll.d.ts +40 -0
  49. package/lib/types/client/window-fullscreen.d.ts +23 -0
  50. package/lib/types/client/workbench-store.d.ts +90 -0
  51. package/lib/types/client/workbench-style.d.ts +32 -0
  52. package/package.json +95 -14
@@ -0,0 +1,527 @@
1
+ window.__ModuleLoader__.load({
2
+ id: "dsh-image-video",
3
+ factory: (require) => {
4
+ var module = { exports: {} };
5
+ var exports = module.exports;
6
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
7
+ let react = require("react");
8
+ let react_jsx_runtime = require("react/jsx-runtime");
9
+ //#region src/workbench-contract.ts
10
+ /**
11
+ * The channel contract shared by the host and browser halves of the workbench.
12
+ *
13
+ * It holds no runtime dependency of either side, so the browser bundle can carry
14
+ * the channel name and the health shape without pulling in host code. The host
15
+ * handler (`src/host/rpc.ts`) and the client plugin (`src/client/plugin.ts`) both
16
+ * read it, which is what keeps "the two halves agree on the channel" from being
17
+ * a comment nobody checks.
18
+ */
19
+ /**
20
+ * Channel of the workbench RPC, as `connection.rpc.handle`/`call` name it.
21
+ *
22
+ * **One path segment only**: the connection transport validates channels against
23
+ * `/^\/[A-Za-z0-9._~-]+$/` and rejects `/api` (see `rpc-host.ts` `assertChannel`),
24
+ * on the host and in the browser caller alike. A channel like
25
+ * `/image-video/workbench` throws at registration and every call is refused.
26
+ */
27
+ const WORKBENCH_RPC_CHANNEL = "/image-video";
28
+ //#endregion
29
+ //#region src/client/api.ts
30
+ /**
31
+ * Build the API over a client connection.
32
+ * @param connection - the client connection handle (`ctx.get('connection')`).
33
+ * @returns the typed API.
34
+ */
35
+ function createWorkbenchApi(connection) {
36
+ /** Call one endpoint and unwrap the connection result envelope. */
37
+ async function call(endpoint, payload = {}) {
38
+ const result = await connection.rpc.call(WORKBENCH_RPC_CHANNEL, endpoint, payload);
39
+ if (!result.ok) throw new Error(result.error?.message ?? `workbench ${endpoint} failed`);
40
+ return result.value;
41
+ }
42
+ return {
43
+ health: () => call("health"),
44
+ authHealth: () => call("auth/health"),
45
+ authLogin: (input) => call("auth/login", input),
46
+ authLogout: () => call("auth/logout"),
47
+ authProfile: () => call("auth/profile"),
48
+ authSetKey: (input) => call("auth/set-key", input),
49
+ authTestKey: (input) => call("auth/test-key", input),
50
+ authKeyState: (provider) => call("auth/key-state", provider === void 0 ? {} : { provider }),
51
+ listProjects: async () => (await call("projects/list")).projects,
52
+ createProject: async (name) => (await call("projects/create", { name })).project,
53
+ removeProject: async (id) => (await call("projects/remove", { id })).removed,
54
+ listAssets: async (projectId) => (await call("assets/list", projectId === void 0 ? {} : { projectId })).assets,
55
+ attachAsset: (input) => call("assets/attach", input),
56
+ removeAsset: async (id, force) => (await call("assets/remove", force === true ? {
57
+ id,
58
+ force: true
59
+ } : { id })).removed,
60
+ removeAssets: (input) => call("assets/remove-many", input),
61
+ renameProject: async (id, name) => (await call("projects/rename", {
62
+ id,
63
+ name
64
+ })).project,
65
+ listResources: async (projectId, kind) => (await call("resources/list", {
66
+ projectId,
67
+ kind
68
+ })).resources,
69
+ listResourcesWithFolders: async (projectId, kind, folder) => call("resources/list", {
70
+ projectId,
71
+ ...kind === void 0 ? {} : { kind },
72
+ ...folder === void 0 || folder === "" ? {} : { folder }
73
+ }),
74
+ planResourceRedraw: (resourceId) => call("resources/plan-redraw", { resourceId }),
75
+ modelsCatalog: async (options) => call("models/catalog", options?.refresh === true ? { refresh: true } : {}),
76
+ defaultsOptions: async () => (await call("defaults/options")).options,
77
+ checkPrompt: async (text) => (await call("prompts/check", { text })).report,
78
+ renderRatioSlices: (input) => call("timelines/render-ratios", input),
79
+ createResource: async (input) => (await call("resources/create", input)).resource,
80
+ removeResource: async (id, force) => (await call("resources/remove", force === true ? {
81
+ id,
82
+ force: true
83
+ } : { id })).removed,
84
+ listTasks: async (limit, projectId, episodeId) => (await call("tasks/list", {
85
+ ...limit === void 0 ? {} : { limit },
86
+ ...projectId === void 0 ? {} : { projectId },
87
+ ...episodeId === void 0 ? {} : { episodeId }
88
+ })).tasks,
89
+ listEpisodes: async (projectId) => (await call("episodes/list", { projectId })).episodes,
90
+ createEpisode: async (projectId, input) => (await call("episodes/create", {
91
+ projectId,
92
+ ...input ?? {}
93
+ })).episode,
94
+ getEpisode: async (id) => (await call("episodes/get", { id })).episode,
95
+ updateEpisode: async (id, patch) => (await call("episodes/update", {
96
+ id,
97
+ ...patch
98
+ })).episode,
99
+ removeEpisode: async (id, force) => (await call("episodes/remove", force === true ? {
100
+ id,
101
+ force: true
102
+ } : { id })).removed,
103
+ reorderEpisodes: async (projectId, order) => (await call("episodes/reorder", {
104
+ projectId,
105
+ order
106
+ })).episodes,
107
+ episodeResources: async (id, action, input) => (await call("episodes/resources", {
108
+ id,
109
+ action,
110
+ ...input ?? {}
111
+ })).refs,
112
+ episodeAssets: async (id, action, input) => (await call("episodes/assets", {
113
+ id,
114
+ action,
115
+ ...input ?? {}
116
+ })).refs,
117
+ listSegments: async (episodeId) => (await call("segments/list", { episodeId })).segments,
118
+ createSegment: async (episodeId, input) => (await call("segments/create", {
119
+ episodeId,
120
+ ...input ?? {}
121
+ })).segment,
122
+ updateSegment: async (id, patch) => (await call("segments/update", {
123
+ id,
124
+ ...patch
125
+ })).segment,
126
+ removeSegment: async (id) => (await call("segments/remove", { id })).removed,
127
+ reorderSegments: async (episodeId, order) => (await call("segments/reorder", {
128
+ episodeId,
129
+ order
130
+ })).segments,
131
+ listStoryboards: async (episodeId) => (await call("storyboards/list", { episodeId })).storyboards,
132
+ getStoryboard: async (id) => (await call("storyboards/get", { id })).storyboard,
133
+ saveStoryboard: async (input) => (await call("storyboards/save", input)).storyboard,
134
+ removeStoryboard: async (id) => (await call("storyboards/remove", { id })).removed,
135
+ listSkills: async (kind, enabledOnly) => (await call("skills/list", {
136
+ ...kind === void 0 ? {} : { kind },
137
+ ...enabledOnly === true ? { enabled: true } : {}
138
+ })).skills,
139
+ getSkill: async (id) => (await call("skills/get", { id })).skill,
140
+ saveSkill: async (input) => (await call("skills/save", input)).skill,
141
+ importSkill: async (input) => (await call("skills/import", input)).skill,
142
+ toggleSkill: async (id, enabled) => (await call("skills/toggle", {
143
+ id,
144
+ enabled
145
+ })).skill,
146
+ removeSkill: async (id) => (await call("skills/remove", { id })).removed,
147
+ revealSkill: async (id) => (await call("skills/reveal", { id })).reveal,
148
+ exportEpisode: async (episodeId) => (await call("episodes/export", { episodeId })).export,
149
+ syncEpisodeWorkflow: async (episodeId) => (await call("workflows/sync-episode", { episodeId })).workflow,
150
+ listRunningTasks: async () => (await call("tasks/running")).running,
151
+ probeFfmpeg: async (path) => (await call("media/ffmpeg", path === void 0 ? {} : { path })).ffmpeg,
152
+ saveDefaults: async (patch) => {
153
+ const response = await fetch("/image-video/defaults", {
154
+ method: "POST",
155
+ headers: { "content-type": "application/json" },
156
+ body: JSON.stringify(patch)
157
+ });
158
+ if (!response.ok) {
159
+ const text = await response.text().catch(() => "");
160
+ throw new Error(`默认值没写进去(HTTP ${response.status}):${text.slice(0, 200)}`);
161
+ }
162
+ },
163
+ listResourceUsage: async (options) => (await call("resources/usage", options ?? {})).usage,
164
+ renderTimeline: async (timelineId, projectId, options) => (await call("timelines/render", {
165
+ timelineId,
166
+ ...projectId !== void 0 ? { projectId } : {},
167
+ ...options !== void 0 ? {
168
+ resolution: options.resolution,
169
+ fps: options.fps,
170
+ aspect: options.aspect
171
+ } : {}
172
+ })).render,
173
+ listRenders: async (projectId) => (await call("timelines/renders", projectId === void 0 ? {} : { projectId })).renders,
174
+ cancelRender: async (renderId) => (await call("timelines/render-cancel", { renderId })).cancelled,
175
+ listTimelines: async (projectId) => (await call("timelines/list", { projectId })).timelines,
176
+ saveTimeline: async (input) => (await call("timelines/save", input)).timeline,
177
+ removeTimeline: async (id) => (await call("timelines/remove", { id })).removed,
178
+ listWorkflows: async (projectId) => (await call("workflows/list", { projectId })).workflows,
179
+ saveWorkflow: async (input) => (await call("workflows/save", input)).workflow,
180
+ removeWorkflow: async (id) => (await call("workflows/remove", { id })).removed,
181
+ compactAssets: async () => (await call("maintenance/compact", {})).removed,
182
+ runWorkflow: async (workflowId, only) => (await call("workflows/run", {
183
+ workflowId,
184
+ ...only === void 0 ? {} : { only }
185
+ })).run,
186
+ composePipeline: (input) => call("pipelines/compose", input).then((result) => result.pipeline),
187
+ runPipeline: (input) => call("pipelines/run", input),
188
+ voiceStatus: async () => (await call("voice/status", {})).voice,
189
+ voicePlan: (input) => call("voice/plan", { timelineId: input }),
190
+ voiceSynthesize: (input) => call("voice/synthesize", input),
191
+ listRuns: async (projectId, workflowId) => (await call("workflows/runs", {
192
+ projectId,
193
+ workflowId
194
+ })).runs,
195
+ cancelRun: async (runId) => (await call("workflows/run-cancel", { runId })).cancelled,
196
+ retryRun: async (runId) => (await call("workflows/run-retry", { runId })).run,
197
+ cancelTask: async (id) => (await call("tasks/cancel", { id })).cancelled,
198
+ attachAssets: (input) => call("assets/attach-many", input),
199
+ updateResource: (input) => call("resources/update", input).then((result) => result.resource),
200
+ importMedia: (input) => call("media/import", input),
201
+ generateMedia: (input) => call("media/generate", input),
202
+ composeMedia: (input) => call("media/compose", input),
203
+ extractPrompt: (input) => call("prompts/extract", input),
204
+ planStoryboard: (input) => call("storyboard/plan", input),
205
+ listPrompts: async (filter) => (await call("prompts/list", {
206
+ ...filter?.projectId === void 0 ? {} : { projectId: filter.projectId },
207
+ ...filter?.episodeId === void 0 ? {} : { episodeId: filter.episodeId }
208
+ })).prompts,
209
+ savePrompt: async (input) => (await call("prompts/save", input)).prompt,
210
+ removePrompt: async (id) => (await call("prompts/remove", { id })).removed,
211
+ listExports: async (input) => {
212
+ return (await call("exports/list", {
213
+ ...input?.projectId === void 0 ? {} : { projectId: input.projectId },
214
+ ...input?.limit === void 0 ? {} : { limit: input.limit }
215
+ })).exports;
216
+ },
217
+ recordExport: async (input) => (await call("exports/record", input)).export,
218
+ updateExport: async (input) => (await call("exports/update", input)).export,
219
+ assignTask: async (id, projectId) => (await call("tasks/assign", {
220
+ id,
221
+ projectId
222
+ })).task,
223
+ revealOutputs: async () => (await call("outputs/reveal", {})).reveal,
224
+ assetSizeReport: async (topN) => (await call("assets/size-report", topN === void 0 ? {} : { topN })).size,
225
+ assetDuplicates: async (maxHashFiles) => (await call("assets/duplicates", maxHashFiles === void 0 ? {} : { maxHashFiles })).duplicates,
226
+ assetProjectStats: async () => (await call("assets/project-stats")).stats,
227
+ listOutputs: async (limit) => (await call("outputs/list", { limit })).outputs,
228
+ getDiagnostics: () => call("diagnostics")
229
+ };
230
+ }
231
+ //#endregion
232
+ //#region src/client/WorkbenchSeat.tsx
233
+ /**
234
+ * 工作台 seat(入口侧薄壳):把整套界面按需加载成**插件自己的包内 chunk**。
235
+ *
236
+ * 为什么需要这一层(A-6 修订版):
237
+ * - 插件的客户端产物是"单入口 + 包内 chunk"模型,入口只能静态依赖**宿主模块表**里
238
+ * 已有的词(react / react-dom / cordis 服务),其余一律要惰性;
239
+ * - 若入口静态 import `Workbench`,React Flow(连 `d3-*` 闭包)会被内联进入口包,
240
+ * 体积回到 834 KB;若改由宿主提供(上一版方案),则要求每个 DSH 用户都装到带
241
+ * `@xyflow/react` 平台词的宿主——对第三方安装者不成立。
242
+ * - 折中:入口只留注册壳,界面(含 React Flow)进 `lib/client/client.Workbench.js`,
243
+ * 首次打开工作台时经 `require.async` 取。**不依赖宿主平台词,装到任何 DSH 都能用。**
244
+ *
245
+ * 注意:这里 `import type` 只为类型,不产生运行时依赖;`lazy()` 的 `import()` 会被
246
+ * 构建改写成 `require.async('./client.Workbench.js')`(见 tsdown.config.ts)。
247
+ */
248
+ /** 首次打开工作台时加载的界面 chunk(构建产物名由 tsdown 的 `chunkFileNames` 决定)。 */
249
+ const Workbench = (0, react.lazy)(async () => {
250
+ return { default: (await require.async("./client.Workbench.js")).Workbench };
251
+ });
252
+ /**
253
+ * 右栏 seat 的 body 组件:等 chunk 期间渲染一个最小占位(本地加载通常 <100ms)。
254
+ * @param props - 宿主 seat 注入的 props(原样透传给懒加载的 Workbench)。
255
+ * @returns 带 Suspense 边界的 seat 内容。
256
+ */
257
+ function WorkbenchSeat(props) {
258
+ return (0, react.createElement)(react.Suspense, { fallback: (0, react.createElement)("div", {
259
+ className: "iv-pane",
260
+ "data-workbench-loading": "true"
261
+ }) }, (0, react.createElement)(Workbench, props));
262
+ }
263
+ //#endregion
264
+ //#region src/client/WorkbenchPanelIcon.tsx
265
+ /**
266
+ * 画入口图标。
267
+ * @param props - 侧栏给的图标份额:请求的边长与是否选中。
268
+ * @returns 图标元素。
269
+ */
270
+ function WorkbenchPanelIcon({ size }) {
271
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
272
+ width: size,
273
+ height: size,
274
+ viewBox: "0 0 24 24",
275
+ "aria-hidden": "true",
276
+ focusable: "false",
277
+ children: [
278
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
279
+ width: "24",
280
+ height: "24",
281
+ rx: "5.6",
282
+ fill: "#31363D"
283
+ }),
284
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
285
+ x: "6.4",
286
+ y: "4.4",
287
+ width: "7.6",
288
+ height: "2.6",
289
+ rx: "1.3",
290
+ fill: "#FFFFFF"
291
+ }),
292
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
293
+ x: "6.4",
294
+ y: "9.7",
295
+ width: "7.6",
296
+ height: "2.6",
297
+ rx: "1.3",
298
+ fill: "#FFFFFF"
299
+ }),
300
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
301
+ x: "6.4",
302
+ y: "15",
303
+ width: "7.6",
304
+ height: "2.6",
305
+ rx: "1.3",
306
+ fill: "#FFFFFF"
307
+ }),
308
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
309
+ d: "M16.8 7.4 22 12l-5.2 4.6z",
310
+ fill: "#2F6FED"
311
+ })
312
+ ]
313
+ });
314
+ }
315
+ //#endregion
316
+ //#region src/client/RelocatedNotice.tsx
317
+ /**
318
+ * 画迁移提示。
319
+ * @param props - 壳文案与「切到主面板」动作。
320
+ * @returns 提示页元素。
321
+ */
322
+ function RelocatedNotice({ t, openPanel }) {
323
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
324
+ "data-workbench-relocated": "true",
325
+ style: {
326
+ display: "flex",
327
+ flexDirection: "column",
328
+ gap: 10,
329
+ alignItems: "flex-start",
330
+ padding: "18px 16px",
331
+ fontSize: 13,
332
+ lineHeight: 1.6,
333
+ color: "var(--dsw-alias-label-primary, currentColor)"
334
+ },
335
+ children: [
336
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", {
337
+ style: { fontSize: 13.5 },
338
+ children: t("relocatedTitle")
339
+ }),
340
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
341
+ style: { color: "var(--dsw-alias-label-tertiary, currentColor)" },
342
+ children: t("relocatedBody")
343
+ }),
344
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
345
+ type: "button",
346
+ onClick: () => {
347
+ openPanel();
348
+ },
349
+ style: {
350
+ marginTop: 2,
351
+ height: 28,
352
+ padding: "0 12px",
353
+ borderRadius: 8,
354
+ cursor: "pointer",
355
+ border: "none",
356
+ background: "var(--dsw-alias-button-info-fill, #4176e6)",
357
+ color: "#fff",
358
+ fontSize: 12.5
359
+ },
360
+ children: t("relocatedAction")
361
+ })
362
+ ]
363
+ });
364
+ }
365
+ //#endregion
366
+ //#region src/client/chrome-locales.ts
367
+ /**
368
+ * 入口壳专用文案:左栏入口名、旧 tab 标题、迁移页三条。
369
+ *
370
+ * 它们必须在界面 chunk 加载**之前**就可读,所以留在入口包里;其余 600+ 条文案随界面
371
+ * chunk 一起加载(`locales.ts`)。
372
+ *
373
+ * 为什么拆两个 namespace(N5,体积):locale 服务禁止同一 namespace 同一 locale 注册两次,
374
+ * 所以"入口注册一部分、chunk 再补其余"在同一个 ns 上做不到。入口注册
375
+ * `image-video-workbench-chrome`(5 条),界面 chunk 加载后注册 `image-video-workbench`。
376
+ *
377
+ * 约束:只有**入口可见**的文案才加到这里(入口体积预算敏感);界面里的文案一律加在 `locales.ts`。
378
+ *
379
+ * @module dsh-image-video/client/chrome-locales
380
+ */
381
+ /** 入口壳的 locale namespace(与界面字典分开:同一 ns 不允许二次注册)。 */
382
+ const CHROME_NS = "image-video-workbench-chrome";
383
+ /** 入口壳中文文案。 */
384
+ const chromeZh = {
385
+ panelLabel: "三视dsh-image-video",
386
+ tabTitle: "dsh-image-video 工作台",
387
+ relocatedTitle: "工作台已经搬到左栏",
388
+ relocatedBody: "从这个右栏页签改成了和「插件」「自动化任务」一样的主面板,整块区域都归它使用。点击下面按钮直接打开。",
389
+ relocatedAction: "打开工作台"
390
+ };
391
+ /** 入口壳英文文案。 */
392
+ const chromeEn = {
393
+ panelLabel: "dsh-image-video",
394
+ tabTitle: "dsh-image-video workbench",
395
+ relocatedTitle: "The workbench moved to the sidebar",
396
+ relocatedBody: "It is now a main panel like Plugins and Scheduled tasks, and owns the whole centre area. Use the button below to open it.",
397
+ relocatedAction: "Open workbench"
398
+ };
399
+ //#endregion
400
+ //#region src/client/plugin.ts
401
+ /** 主面板 id:左栏入口与 `main` 面板共用同一个品牌化 id。 */
402
+ const PANEL_ID = "dsh-image-video";
403
+ /**
404
+ * 旧版右栏 tab 的 id(= 当时 tab 类型的实现身份)。
405
+ * 保留它是为了兼容已经存在的右栏布局记录:那些记录按 id 找 tab 类型与 body。
406
+ */
407
+ const LEGACY_TAB_ID = "dsh-image-video";
408
+ /** 旧版 tab 的类型判别值(布局记录里存的是这个 kind)。 */
409
+ const LEGACY_TAB_KIND = "dsh-image-video-workbench";
410
+ /** 兼容旧名(`client-bundle.test.ts` 与既有文档仍按这两个名字对账)。 */
411
+ const WORKBENCH_TAB_ID = LEGACY_TAB_ID;
412
+ const WORKBENCH_TAB_KIND = LEGACY_TAB_KIND;
413
+ /**
414
+ * 界面 locale namespace。入口**不 import** `locale-ns.ts`:任何被入口与 chunk 同时引用的模块
415
+ * 都会被切成共享 chunk(`client.locale-ns.js`),入口反而多一次 require,断言也变复杂。
416
+ * 这里写字面量,值必须与 `locale-ns.ts` 一致(`client-lifecycle.test.ts` 钉住两者相等)。
417
+ */
418
+ const NS = "image-video-workbench";
419
+ /** 供测试钉住"入口字面量 == chunk 侧常量"(入口与 chunk 不能共享模块)。 */
420
+ const WORKBENCH_LOCALE_NS = NS;
421
+ /** Required services(cordis fiber inject)。 */
422
+ const inject = [
423
+ "slots",
424
+ "locale",
425
+ "sidebarRightTabs",
426
+ "connection"
427
+ ];
428
+ /**
429
+ * 注册主面板、左栏入口与旧 tab 的迁移页。
430
+ * @param ctx - client root context.
431
+ */
432
+ function apply(ctx) {
433
+ ctx.effect(() => ctx.locale.register(CHROME_NS, {
434
+ zh: chromeZh,
435
+ en: chromeEn
436
+ }), "image-video-workbench: chrome dictionaries");
437
+ let bodyDictionaries;
438
+ /**
439
+ * 界面 chunk 把自己那份完整字典交回来注册(入口持有 ctx,chunk 只持有字符串)。
440
+ * 幂等:重复调用只注册一次;卸载时随 fiber 撤销。
441
+ */
442
+ const registerDictionaries = (dicts) => {
443
+ if (bodyDictionaries !== void 0) return;
444
+ bodyDictionaries = ctx.locale.register(NS, dicts);
445
+ };
446
+ ctx.effect(() => () => {
447
+ bodyDictionaries?.();
448
+ bodyDictionaries = void 0;
449
+ }, "image-video-workbench: body dictionaries");
450
+ /**
451
+ * 零散小字典(引导页等)的注册口,按 ns 幂等。
452
+ *
453
+ * 面板每次重新挂载都会调一次,而 `ctx.locale.register` 对**同名 ns 的重复注册是抛错**的;
454
+ * 少了这层去重,「切到别的面板再切回来」会让 main 座位的渲染直接崩掉(表现为整块白屏)。
455
+ * 字典生命期跟随插件 fiber:同一份静态文案没有随面板反复挂/卸的意义。
456
+ */
457
+ const extraLocales = /* @__PURE__ */ new Map();
458
+ const registerExtraLocale = (ns, dicts) => {
459
+ if (extraLocales.has(ns)) return;
460
+ extraLocales.set(ns, ctx.locale.register(ns, dicts));
461
+ };
462
+ ctx.effect(() => () => {
463
+ for (const dispose of extraLocales.values()) dispose();
464
+ extraLocales.clear();
465
+ }, "image-video-workbench: extra dictionaries");
466
+ const t = ctx.locale.bind(CHROME_NS);
467
+ ctx.slots.inject("main", () => ctx.slots.register({
468
+ name: "main",
469
+ key: PANEL_ID,
470
+ locale: NS,
471
+ inject: () => ({
472
+ kind: LEGACY_TAB_KIND,
473
+ api: createWorkbenchApi(requireConnection(ctx)),
474
+ registerDictionaries,
475
+ registerExtraLocale,
476
+ bindLocale: (ns) => ctx.locale.bind(ns)
477
+ })
478
+ }, WorkbenchSeat));
479
+ ctx.slots.inject("sidebar.panellist", () => ctx.slots.register({
480
+ name: "sidebar.panellist",
481
+ id: PANEL_ID,
482
+ order: 20,
483
+ label: () => t("panelLabel"),
484
+ locale: CHROME_NS
485
+ }, WorkbenchPanelIcon));
486
+ ctx.effect(() => ctx.sidebarRightTabs.register({
487
+ id: LEGACY_TAB_ID,
488
+ kind: LEGACY_TAB_KIND,
489
+ title: () => t("tabTitle")
490
+ }), "image-video-workbench: legacy tab type");
491
+ ctx.slots.inject("sidebar.right.pane.tab", () => ctx.slots.register({
492
+ name: "sidebar.right.pane.tab",
493
+ key: LEGACY_TAB_ID,
494
+ locale: CHROME_NS,
495
+ inject: () => ({ openPanel: () => {
496
+ ctx.get("layout")?.selectPanel?.(PANEL_ID);
497
+ } })
498
+ }, RelocatedNotice));
499
+ }
500
+ /**
501
+ * Read the client connection service.
502
+ *
503
+ * `inject` already waits for it, so a miss here means the deployment wired the
504
+ * browser half without its RPC counterpart — worth a named error rather than a
505
+ * TypeError on the first click.
506
+ * @param ctx - client root context.
507
+ * @returns the connection handle.
508
+ */
509
+ function requireConnection(ctx) {
510
+ const connection = ctx.get("connection");
511
+ if (connection === void 0) throw new Error("image-video-workbench: connection service is unavailable");
512
+ return connection;
513
+ }
514
+ //#endregion
515
+ exports.LEGACY_TAB_ID = LEGACY_TAB_ID;
516
+ exports.LEGACY_TAB_KIND = LEGACY_TAB_KIND;
517
+ exports.PANEL_ID = PANEL_ID;
518
+ exports.WORKBENCH_LOCALE_NS = WORKBENCH_LOCALE_NS;
519
+ exports.WORKBENCH_TAB_ID = WORKBENCH_TAB_ID;
520
+ exports.WORKBENCH_TAB_KIND = WORKBENCH_TAB_KIND;
521
+ exports.apply = apply;
522
+ exports.inject = inject;
523
+ return module.exports;
524
+ }
525
+ });
526
+
527
+ //# sourceMappingURL=plugin.js.map