dsh-hyperframes 0.11.6 → 0.12.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.
@@ -470,11 +470,12 @@ export class MediaWorkbench {
470
470
  }
471
471
  export function installMediaWorkbench(ctx, engine) {
472
472
  const workbench = new MediaWorkbench(engine);
473
+ const disposers = [() => workbench.dispose()];
473
474
  ctx.inject?.(['connection'], (host) => {
474
- host.connection?.fetch?.register({ path: workbench.route, methods: ['GET', 'POST'], requestBody: 'buffered', fetch: (request) => workbench.fetch(request) });
475
- host.connection?.fetch?.register({ path: workbench.route + '/upload', methods: ['POST'], requestBody: 'streaming', fetch: (request) => workbench.fetch(request) });
475
+ const r1 = host.connection?.fetch?.register({ path: workbench.route, methods: ['GET', 'POST'], requestBody: 'buffered', fetch: (request) => workbench.fetch(request) });
476
+ const r2 = host.connection?.fetch?.register({ path: workbench.route + '/upload', methods: ['POST'], requestBody: 'streaming', fetch: (request) => workbench.fetch(request) });
477
+ host.effect?.(() => () => { r2?.(); r1?.(); });
476
478
  });
477
- ctx.on?.('dispose', () => workbench.dispose());
478
479
  for (const action of ['project', 'render']) {
479
480
  const dispose = ctx.tools?.register({
480
481
  name: engine + '_' + action,
@@ -518,7 +519,17 @@ export function installMediaWorkbench(ctx, engine) {
518
519
  },
519
520
  });
520
521
  if (typeof dispose === 'function')
521
- ctx.on?.('dispose', dispose);
522
+ disposers.push(dispose);
522
523
  }
524
+ let cleaned = false;
525
+ const cleanup = () => {
526
+ if (cleaned)
527
+ return;
528
+ cleaned = true;
529
+ for (const fn of disposers.splice(0).reverse())
530
+ fn();
531
+ };
532
+ ctx.effect?.(() => cleanup);
533
+ ctx.on?.('dispose', cleanup);
523
534
  return workbench;
524
535
  }
@@ -16,6 +16,7 @@ export interface SkillsPluginContext {
16
16
  tools?: {
17
17
  register(definition: Record<string, unknown>): () => void;
18
18
  };
19
+ effect?(fn: () => () => void): unknown;
19
20
  on?(event: string, listener: () => void): (() => void) | void;
20
21
  logger?: {
21
22
  warn(message: string): void;
@@ -99,6 +99,7 @@ export function createSkillBundle(options) {
99
99
  }
100
100
  }
101
101
  };
102
+ ctx.effect?.(() => dispose);
102
103
  ctx.on?.('dispose', dispose);
103
104
  for (const result of inspectAll()) {
104
105
  const registration = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-hyperframes",
3
- "version": "0.11.6",
3
+ "version": "0.12.0",
4
4
  "description": "DSH HTML 视频工作台:官方 HyperFrames 技能、工程检索、模板、素材排序、预览与本地 MP4 导出。欢迎提交 issues 和 PR。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -62,7 +62,7 @@
62
62
  "fflate": "0.8.3",
63
63
  "proper-lockfile": "4.1.2",
64
64
  "yaml": "^2.9.0",
65
- "@stardustlc/dsh-updates": "0.1.4"
65
+ "@stardustlc/dsh-updates": "0.2.0"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@types/node": "^24.0.0",