@linxin666/dsh-remote-web-ui 0.1.18 → 0.1.19

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/lib/client.js CHANGED
@@ -2558,6 +2558,9 @@ window.__ModuleLoader__.load({
2558
2558
  specs;
2559
2559
  staged = /* @__PURE__ */ new Map();
2560
2560
  listeners = /* @__PURE__ */ new Set();
2561
+ /** The scope subscription installed in the constructor; released by dispose(). */
2562
+ disposeScope;
2563
+ disposed = false;
2561
2564
  saving = false;
2562
2565
  failed = false;
2563
2566
  failedReason;
@@ -2565,10 +2568,20 @@ window.__ModuleLoader__.load({
2565
2568
  constructor(scope, specs) {
2566
2569
  this.scope = scope;
2567
2570
  this.specs = new Map(specs.map((spec) => [spec.field, spec]));
2568
- scope.subscribe(() => {
2571
+ this.disposeScope = scope.subscribe(() => {
2569
2572
  this.publish();
2570
2573
  });
2571
2574
  }
2575
+ /**
2576
+ * Release the scope subscription and every bound store listener. The card
2577
+ * must call this on teardown; later calls are no-ops.
2578
+ */
2579
+ dispose() {
2580
+ if (this.disposed) return;
2581
+ this.disposed = true;
2582
+ this.disposeScope();
2583
+ this.listeners.clear();
2584
+ }
2572
2585
  /** Publish a projection of this form, rebuilt whenever the scope or a draft changes. */
2573
2586
  bind(project) {
2574
2587
  const store = (0, _deepseek_ai_dsh_client_runtime_client.createSnapshotStore)(project());
@@ -2811,6 +2824,13 @@ window.__ModuleLoader__.load({
2811
2824
  ...this.form.actions()
2812
2825
  };
2813
2826
  }
2827
+ /**
2828
+ * Release the card's scope subscription and bound stores; the slot
2829
+ * disposer calls this on teardown.
2830
+ */
2831
+ dispose() {
2832
+ this.form.dispose();
2833
+ }
2814
2834
  };
2815
2835
  /**
2816
2836
  * Render the remote-control card.
@@ -3349,13 +3369,19 @@ window.__ModuleLoader__.load({
3349
3369
  };
3350
3370
  });
3351
3371
  const remoteSettings = new RemoteSettingsCardController(settingsScope);
3352
- ctx.slots.inject("web-ui.plugin.item", () => ctx.slots.register({
3353
- name: "web-ui.plugin.item",
3354
- id: "remote-web-ui",
3355
- order: 90,
3356
- locale: NS,
3357
- inject: () => remoteSettings.inject()
3358
- }, RemoteSettingsCard));
3372
+ ctx.slots.inject("web-ui.plugin.item", () => {
3373
+ const unregister = ctx.slots.register({
3374
+ name: "web-ui.plugin.item",
3375
+ id: "remote-web-ui",
3376
+ order: 90,
3377
+ locale: NS,
3378
+ inject: () => remoteSettings.inject()
3379
+ }, RemoteSettingsCard);
3380
+ return () => {
3381
+ remoteSettings.dispose();
3382
+ unregister();
3383
+ };
3384
+ });
3359
3385
  let disposeRuntime;
3360
3386
  const syncRuntime = () => {
3361
3387
  if (enabled() && disposeRuntime === void 0) disposeRuntime = ctx.effect(() => {