dsh-edge 0.18.0 → 0.19.0-alpha.2

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 (118) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +8 -8
  3. package/README.zh.md +8 -8
  4. package/THIRD_PARTY_NOTICES.md +2011 -449
  5. package/dist/assets/fonts/Montserrat-OFL.txt +93 -0
  6. package/dist/assets/fonts/montserrat-light-Cvd2VjE_.woff2 +0 -0
  7. package/dist/assets/fonts/montserrat-medium-B4OyO9CN.woff2 +0 -0
  8. package/dist/assets/fonts/montserrat-regular-DYep38cA.woff2 +0 -0
  9. package/dist/assets/index-Cq6ljTv2.css +1 -0
  10. package/dist/assets/index-Dy0OhsZ5.js +127 -0
  11. package/dist/assets/langs/asciidoc-Ve4PFQV2.js +2 -0
  12. package/dist/assets/langs/bat-BkioyH1T.js +2 -0
  13. package/dist/assets/langs/bibtex-CHM0blh-.js +2 -0
  14. package/dist/assets/langs/clojure-P80f7IUj.js +2 -0
  15. package/dist/assets/langs/cmake-D1j8_8rp.js +2 -0
  16. package/dist/assets/langs/csv-fuZLfV_i.js +2 -0
  17. package/dist/assets/langs/dart-bE4Kk8sk.js +2 -0
  18. package/dist/assets/langs/diff-D97Zzqfu.js +2 -0
  19. package/dist/assets/langs/dotenv-Da5cRb03.js +2 -0
  20. package/dist/assets/langs/elixir-CvYZzuDY.js +2 -0
  21. package/dist/assets/langs/erlang-DsQrWhSR.js +2 -0
  22. package/dist/assets/langs/fish-BvzEVeQv.js +2 -0
  23. package/dist/assets/langs/fsharp-CXgrBDvD.js +2 -0
  24. package/dist/assets/langs/graphql-DujV8YkJ.js +2 -0
  25. package/dist/assets/langs/groovy-gcz8RCvz.js +2 -0
  26. package/dist/assets/langs/haskell-Df6bDoY_.js +2 -0
  27. package/dist/assets/langs/hcl-BWvSN4gD.js +2 -0
  28. package/dist/assets/langs/html-derivative-DOyKdj44.js +2 -0
  29. package/dist/assets/langs/html-fwsONPVS.js +2 -0
  30. package/dist/assets/langs/http-DcV90OkR.js +2 -0
  31. package/dist/assets/langs/javascript-DI5JR1nB.js +2 -0
  32. package/dist/assets/langs/julia-BpJ6DjL_.js +2 -0
  33. package/dist/assets/langs/latex-B4C7GdlO.js +2 -0
  34. package/dist/assets/langs/log-2UxHyX5q.js +2 -0
  35. package/dist/assets/langs/make-CHLpvVh8.js +2 -0
  36. package/dist/assets/langs/nix-CwoSXNpI.js +2 -0
  37. package/dist/assets/langs/perl-DsWkoyyU.js +2 -0
  38. package/dist/assets/langs/php-LEPfNACG.js +2 -0
  39. package/dist/assets/langs/powershell-Dpen1YoG.js +2 -0
  40. package/dist/assets/langs/proto-C7zT0LnQ.js +2 -0
  41. package/dist/assets/langs/r-Dspwwk_N.js +2 -0
  42. package/dist/assets/langs/rst-BbocfKWr.js +2 -0
  43. package/dist/assets/langs/ruby-R292Iif0.js +2 -0
  44. package/dist/assets/langs/scala-C151Ov-r.js +2 -0
  45. package/dist/assets/langs/svelte-DNMY6jOf.js +2 -0
  46. package/dist/assets/langs/system-verilog-CnnmHF94.js +2 -0
  47. package/dist/assets/langs/vb-D17OF-Vu.js +2 -0
  48. package/dist/assets/langs/verilog-BQ8w6xss.js +2 -0
  49. package/dist/assets/langs/vue-Dq2x6432.js +2 -0
  50. package/dist/favicon-dark.svg +3 -0
  51. package/dist/favicon.svg +0 -5
  52. package/dist/index.html +5 -4
  53. package/dist/manifest.webmanifest +3 -4
  54. package/dist/plugins/@deepseek-ai/dsh-api-gateway/client.js +353 -101
  55. package/dist/plugins/@deepseek-ai/dsh-api-job-controller/client.js +367 -0
  56. package/dist/plugins/@deepseek-ai/dsh-api-remotes/client.js +7223 -3584
  57. package/dist/plugins/@deepseek-ai/dsh-api-session-controller/client.js +1107 -991
  58. package/dist/plugins/@deepseek-ai/dsh-api-workspace-controller/client.js +119 -6
  59. package/dist/plugins/@deepseek-ai/dsh-api-workspace-files/client.js +41 -35
  60. package/dist/plugins/@deepseek-ai/dsh-client-connection/client.js +354 -5279
  61. package/dist/plugins/@deepseek-ai/dsh-client-file-upload/client.js +10 -23
  62. package/dist/plugins/@deepseek-ai/dsh-client-locale/client.js +234 -80
  63. package/dist/plugins/@deepseek-ai/dsh-client-modules/client.js +554 -46
  64. package/dist/plugins/@deepseek-ai/dsh-client-shortcuts/client.js +2006 -0
  65. package/dist/plugins/@deepseek-ai/dsh-client-ui-agent-preset/client.js +1090 -914
  66. package/dist/plugins/@deepseek-ai/dsh-client-ui-approval/client.js +79 -6
  67. package/dist/plugins/@deepseek-ai/dsh-client-ui-attachment/client.js +126 -155
  68. package/dist/plugins/@deepseek-ai/dsh-client-ui-chat/client.js +5776 -1593
  69. package/dist/plugins/@deepseek-ai/dsh-client-ui-commands/client.js +375 -121
  70. package/dist/plugins/@deepseek-ai/dsh-client-ui-conversation/client.js +3524 -1923
  71. package/dist/plugins/@deepseek-ai/dsh-client-ui-deliverables/client.js +1615 -258
  72. package/dist/plugins/@deepseek-ai/dsh-client-ui-directory-picker-browse/client.js +9 -9
  73. package/dist/plugins/@deepseek-ai/dsh-client-ui-goal/client.js +25 -10
  74. package/dist/plugins/@deepseek-ai/dsh-client-ui-input-trigger/client.js +169 -24
  75. package/dist/plugins/@deepseek-ai/dsh-client-ui-jobs/client.js +413 -63
  76. package/dist/plugins/@deepseek-ai/dsh-client-ui-layout/client.js +131 -14
  77. package/dist/plugins/@deepseek-ai/dsh-client-ui-message-feedback/client.js +24 -22
  78. package/dist/plugins/@deepseek-ai/dsh-client-ui-model-selection/client.js +281 -128
  79. package/dist/plugins/@deepseek-ai/dsh-client-ui-open-in-app/client.js +674 -223
  80. package/dist/plugins/@deepseek-ai/dsh-client-ui-plan/client.js +596 -18
  81. package/dist/plugins/@deepseek-ai/dsh-client-ui-reference/client.js +92 -9
  82. package/dist/plugins/@deepseek-ai/dsh-client-ui-renderer/client.js +467 -59
  83. package/dist/plugins/@deepseek-ai/dsh-client-ui-session/client.js +231 -72
  84. package/dist/plugins/@deepseek-ai/dsh-client-ui-settings/client.js +281 -117
  85. package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-general/client.js +642 -122
  86. package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-models/client.js +1565 -438
  87. package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-plugin-inventory/client.js +201 -75
  88. package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-plugins/client.js +30 -1628
  89. package/dist/plugins/@deepseek-ai/dsh-client-ui-shortcuts/client.js +1163 -0
  90. package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar/client.js +165 -39
  91. package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-browser/client.js +1648 -0
  92. package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-documentpreview/client.js +5515 -25622
  93. package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-files/client.js +419 -118
  94. package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-right/client.js +5692 -260
  95. package/dist/plugins/@deepseek-ai/dsh-client-ui-skill/client.js +156 -41
  96. package/dist/plugins/@deepseek-ai/dsh-client-ui-subagent/client.js +386 -263
  97. package/dist/plugins/@deepseek-ai/dsh-client-ui-theme/client.js +183 -73
  98. package/dist/plugins/@deepseek-ai/dsh-client-ui-tool/client.js +2367 -429
  99. package/dist/plugins/@deepseek-ai/dsh-client-ui-trajectory/client.js +788 -270
  100. package/dist/plugins/@deepseek-ai/dsh-client-ui-user-questions/client.js +87 -79
  101. package/dist/plugins/@deepseek-ai/dsh-client-ui-workflow-run/client.js +28 -14
  102. package/dist/plugins/@deepseek-ai/dsh-client-ui-workspace/client.js +2647 -1044
  103. package/dist/plugins/@deepseek-ai/dsh-typert-registry/client.js +22 -7
  104. package/dist/plugins/dsh-edge-client-ui/client.js +1 -10
  105. package/package.json +96 -86
  106. package/scripts/cli.mjs +16 -4
  107. package/scripts/install.d.mts +12 -2
  108. package/scripts/install.mjs +36 -9
  109. package/scripts/legal-files.mjs +15 -0
  110. package/worker/direct/index.js +2564 -1822
  111. package/worker/isolated/index.js +2144 -1402
  112. package/dist/assets/index-BKQ_L1z6.js +0 -117
  113. package/dist/assets/index-DPX2bQLO.css +0 -1
  114. package/dist/assets/langs/html-CfGypltT.js +0 -2
  115. package/dist/assets/langs/php-DJl5gRdb.js +0 -2
  116. package/dist/assets/langs/ruby-5eNB0pDK.js +0 -2
  117. package/dist/plugins/@deepseek-ai/dsh-client-ui-permission-presets/client.js +0 -505
  118. package/dist/plugins/@deepseek-ai/dsh-client-ui-schedule/client.js +0 -307
@@ -160,10 +160,13 @@ window.__ModuleLoader__.load({
160
160
  };
161
161
  }
162
162
  //#endregion
163
+ //#region lib/types/client/errors.js
164
+ /** Shared renderer failure categories. @module */
165
+ /** Renderer assembly failures that must escape component error boundaries. */
166
+ var SlotAssemblyError = class extends Error {};
167
+ //#endregion
163
168
  //#region lib/types/client/bindings.js
164
169
  /** Internal React bindings for renderer hosts and standard-source scopes. */
165
- /** Missing renderer assembly dependency. */
166
- var SlotAssemblyError = class extends Error {};
167
170
  /** In-package renderer host context. */
168
171
  const HostContext = (0, react.createContext)(null);
169
172
  /**
@@ -196,6 +199,19 @@ window.__ModuleLoader__.load({
196
199
  return binding;
197
200
  }
198
201
  /**
202
+ * Publish one resolved scope binding to a renderer subtree.
203
+ * @param props - provider inputs.
204
+ * @param props.binding - binding exposed to scoped entries.
205
+ * @param props.children - subtree that inherits the binding.
206
+ * @returns the scoped React provider.
207
+ */
208
+ function ScopeBindingProvider({ binding, children }) {
209
+ return (0, react_jsx_runtime.jsx)(ScopeBindingContext.Provider, {
210
+ value: binding,
211
+ children
212
+ });
213
+ }
214
+ /**
199
215
  * Bind one observable source to an identity-stable selector Hook.
200
216
  * @param source - observable source.
201
217
  * @returns cached selector Hook.
@@ -230,20 +246,36 @@ window.__ModuleLoader__.load({
230
246
  * @param source - keyed resolver, or absence for an optional scope.
231
247
  * @returns cached keyed selector Hook.
232
248
  */
233
- function keyedObservableHook(source) {
249
+ function keyedObservableHook(source, defaultKey) {
234
250
  if (source === void 0) return absentKeyedHook;
235
- let hook = keyedHookCache.get(source);
251
+ let hooks = keyedHookCache.get(source);
252
+ if (hooks === void 0) {
253
+ hooks = /* @__PURE__ */ new Map();
254
+ keyedHookCache.set(source, hooks);
255
+ }
256
+ const cacheKey = defaultKey ?? NO_DEFAULT_KEY;
257
+ let hook = hooks.get(cacheKey);
236
258
  if (hook === void 0) {
237
- hook = (key, selector, equal) => {
238
- return observableHook(source(key) ?? absentSource)(selector ?? identity, equal);
259
+ hook = (keyOrSelector, selectorOrEqual, equal) => {
260
+ const keyed = typeof keyOrSelector === "string";
261
+ const key = keyed ? keyOrSelector : defaultKey;
262
+ const selector = keyed ? selectorOrEqual : keyOrSelector;
263
+ const comparison = keyed ? equal : selectorOrEqual;
264
+ return observableHook(key === void 0 ? absentSource : source(key) ?? absentSource)(selector ?? identity, comparison);
239
265
  };
240
- keyedHookCache.set(source, hook);
266
+ hooks.set(cacheKey, hook);
241
267
  }
242
268
  return hook;
243
269
  }
270
+ const NO_DEFAULT_KEY = Symbol("no default key");
244
271
  const keyedHookCache = /* @__PURE__ */ new WeakMap();
245
272
  const identity = (value) => value;
246
- const absentKeyedHook = (_key, selector, equal) => observableHook(absentSource)(selector ?? identity, equal);
273
+ const absentKeyedHook = (keyOrSelector, selectorOrEqual, equal) => {
274
+ const keyed = typeof keyOrSelector === "string";
275
+ const selector = keyed ? selectorOrEqual : keyOrSelector;
276
+ const comparison = keyed ? equal : selectorOrEqual;
277
+ return observableHook(absentSource)(selector ?? identity, comparison);
278
+ };
247
279
  /** Subscribe the tree to the atomically assembled root standard-source roster. */
248
280
  function RootStandardProvider({ children }) {
249
281
  const binding = observableHook(useHost().root)((value) => value);
@@ -270,6 +302,20 @@ window.__ModuleLoader__.load({
270
302
  * React renderer for declarative slots. Per-entry bindings enforce child
271
303
  * authorization, and entry boundaries contain registrant failures.
272
304
  */
305
+ const factoryRenderCache = /* @__PURE__ */ new WeakMap();
306
+ function boundRenderFactorySlot(caller) {
307
+ let render = factoryRenderCache.get(caller);
308
+ if (render !== void 0) return render;
309
+ render = ((name, props, options) => (0, react_jsx_runtime.jsx)(FactoryOutlet, {
310
+ name,
311
+ inputProps: props,
312
+ slots: options?.slots,
313
+ fallback: options?.fallback,
314
+ caller
315
+ }));
316
+ factoryRenderCache.set(caller, render);
317
+ return render;
318
+ }
273
319
  /**
274
320
  * Per-entry renderSlot bindings. The binding is identity-stable per entry
275
321
  * (memoized components must not resubscribe on unrelated re-renders) and dies
@@ -320,6 +366,42 @@ window.__ModuleLoader__.load({
320
366
  }
321
367
  return binding;
322
368
  }
369
+ const factoryRenderSlotCache = /* @__PURE__ */ new WeakMap();
370
+ const factoryRenderSlotChainCache = /* @__PURE__ */ new WeakMap();
371
+ function boundFactoryRenderSlot(host, definition) {
372
+ let binding = factoryRenderSlotCache.get(definition);
373
+ if (binding !== void 0) return binding;
374
+ binding = (key, owner, opts) => {
375
+ if (!host.isFactoryLive(definition)) throw new _deepseek_ai_dsh_client_ui_slots.StaleAuthorizationError(`renderSlot('${key}') from a disposed Factory`);
376
+ const declared = definition.children?.[key];
377
+ if (declared === void 0) throw new _deepseek_ai_dsh_client_ui_slots.SlotOwnershipError(`slot '${key}' is not declared by this Factory`);
378
+ if (declared.kind === "chain") throw new _deepseek_ai_dsh_client_ui_slots.SlotOwnershipError(`slot '${key}' is declared 'chain' — use renderSlotChain`);
379
+ return (0, react_jsx_runtime.jsx)(SlotOutlet, {
380
+ slotKey: key,
381
+ ownerProps: owner,
382
+ opts
383
+ });
384
+ };
385
+ factoryRenderSlotCache.set(definition, binding);
386
+ return binding;
387
+ }
388
+ function boundFactoryRenderSlotChain(host, definition) {
389
+ let binding = factoryRenderSlotChainCache.get(definition);
390
+ if (binding !== void 0) return binding;
391
+ binding = (key, owner, opts) => {
392
+ if (!host.isFactoryLive(definition)) throw new _deepseek_ai_dsh_client_ui_slots.StaleAuthorizationError(`renderSlotChain('${key}') from a disposed Factory`);
393
+ const declared = definition.children?.[key];
394
+ if (declared === void 0) throw new _deepseek_ai_dsh_client_ui_slots.SlotOwnershipError(`slot '${key}' is not declared by this Factory`);
395
+ if (declared.kind !== "chain") throw new _deepseek_ai_dsh_client_ui_slots.SlotOwnershipError(`slot '${key}' is declared '${declared.kind}', not 'chain' — use renderSlot`);
396
+ return (0, react_jsx_runtime.jsx)(SlotOutlet, {
397
+ slotKey: key,
398
+ ownerProps: owner,
399
+ opts
400
+ });
401
+ };
402
+ factoryRenderSlotChainCache.set(definition, binding);
403
+ return binding;
404
+ }
323
405
  /**
324
406
  * Inject results cache: root entries per entry, session entries per
325
407
  * (entry x scope binding). WeakMap keys are entry/binding objects (both
@@ -506,6 +588,16 @@ window.__ModuleLoader__.load({
506
588
  }
507
589
  return key;
508
590
  }
591
+ let nextSessionGenerationKey = 0;
592
+ const sessionGenerationKeys = /* @__PURE__ */ new WeakMap();
593
+ function sessionGenerationKeyOf(binding) {
594
+ let key = sessionGenerationKeys.get(binding.ctx);
595
+ if (key === void 0) {
596
+ key = nextSessionGenerationKey++;
597
+ sessionGenerationKeys.set(binding.ctx, key);
598
+ }
599
+ return key;
600
+ }
509
601
  /**
510
602
  * Per-entry isolation: one registrant crashing (component render or inject
511
603
  * factory) must not take down siblings. Assembly errors (missing providers)
@@ -531,11 +623,27 @@ window.__ModuleLoader__.load({
531
623
  return this.props.children;
532
624
  }
533
625
  };
626
+ /** Contain one Factory occurrence without retiring the shared definition. */
627
+ var FactoryErrorBoundary = class extends react.Component {
628
+ state = { failed: false };
629
+ static getDerivedStateFromError(error) {
630
+ if (error instanceof SlotAssemblyError) throw error;
631
+ return { failed: true };
632
+ }
633
+ componentDidCatch(error) {
634
+ console.error(`slot factory occurrence crashed in '${this.props.name}':`, error);
635
+ this.props.onEntryError(error);
636
+ }
637
+ render() {
638
+ if (this.state.failed) return (0, react_jsx_runtime.jsx)("div", { "data-factory-error": this.props.name });
639
+ return this.props.children;
640
+ }
641
+ };
534
642
  const rootStandardCache = /* @__PURE__ */ new WeakMap();
535
643
  const sessionStandardCache = /* @__PURE__ */ new WeakMap();
536
644
  const sessionMaybeStandardCache = /* @__PURE__ */ new WeakMap();
537
645
  /** Materialize one binding into stable framework Hook and plain-prop seats. */
538
- function materializeStandardBinding(binding, optional) {
646
+ function materializeStandardBinding(binding, optional, defaultKey) {
539
647
  const standard = { ...binding.props };
540
648
  for (const [name, source] of Object.entries(binding.hooks)) {
541
649
  if (source === void 0 && !optional) throw new SlotAssemblyError(`strict standard hook '${name}' has no source`);
@@ -543,7 +651,7 @@ window.__ModuleLoader__.load({
543
651
  }
544
652
  for (const [name, source] of Object.entries(binding.keyedHooks)) {
545
653
  if (source === void 0 && !optional) throw new SlotAssemblyError(`strict keyed standard hook '${name}' has no source resolver`);
546
- standard[(0, _deepseek_ai_dsh_client_ui_slots.standardHookPropName)(name)] = keyedObservableHook(source);
654
+ standard[(0, _deepseek_ai_dsh_client_ui_slots.standardHookPropName)(name)] = keyedObservableHook(source, defaultKey);
547
655
  }
548
656
  return standard;
549
657
  }
@@ -565,7 +673,7 @@ window.__ModuleLoader__.load({
565
673
  let standard = perScope.get(scopeBinding);
566
674
  if (standard !== void 0) return standard;
567
675
  standard = {
568
- ...root,
676
+ ...materializeStandardBinding(rootBinding, false, scopeBinding.key),
569
677
  ...materializeStandardBinding(scopeBinding, scope === "session-maybe")
570
678
  };
571
679
  perScope.set(scopeBinding, standard);
@@ -579,7 +687,15 @@ window.__ModuleLoader__.load({
579
687
  if (adapter.renderArea === void 0) throw new SlotAssemblyError("scope 'session' adapter does not provide its area renderer");
580
688
  const renderArea = adapter.renderArea.bind(adapter);
581
689
  Provider = function ScopeAreaProvider(props) {
582
- return renderArea(useScopeBinding(), props);
690
+ const inherited = useScopeBinding();
691
+ const explicit = Object.hasOwn(props, "session");
692
+ const source = adapter.bindingSource(props.session);
693
+ const resolved = (0, react.useSyncExternalStore)((listener) => source.subscribe(listener), () => source.getSnapshot(), () => source.getSnapshot());
694
+ const binding = explicit ? resolved : inherited;
695
+ return (0, react_jsx_runtime.jsx)(ScopeBindingProvider, {
696
+ binding,
697
+ children: renderArea(binding, props)
698
+ });
583
699
  };
584
700
  scopeAreaCache.set(adapter, Provider);
585
701
  return Provider;
@@ -598,7 +714,10 @@ window.__ModuleLoader__.load({
598
714
  */
599
715
  function standardKit(host, entry, scope, rootBinding, scopeBinding) {
600
716
  const standard = standardProps(scope, rootBinding, scopeBinding);
601
- const kit = { ...standard };
717
+ const kit = {
718
+ ...standard,
719
+ renderFactorySlot: boundRenderFactorySlot(entry)
720
+ };
602
721
  if (entry.locale !== void 0) {
603
722
  const face = host.locale;
604
723
  if (face === void 0) throw new SlotAssemblyError(`entry declares locale namespace '${entry.locale}' but no locale face is installed (locale plugin missing from the composition?)`);
@@ -613,7 +732,7 @@ window.__ModuleLoader__.load({
613
732
  if (entry.children !== void 0) {
614
733
  kit["renderSlot"] = boundRenderSlot(host, entry);
615
734
  if (Object.values(entry.children).some((spec) => spec.kind === "chain")) kit["renderSlotChain"] = boundRenderSlotChain(host, entry);
616
- if (Object.values(entry.children).some((spec) => spec.scope === "session")) {
735
+ if (Object.values(entry.children).some((spec) => spec.scope !== "root")) {
617
736
  const adapter = host.scope("session");
618
737
  if (adapter === void 0) throw new SlotAssemblyError("entry declares a session child without an installed 'session' scope adapter");
619
738
  kit["SessionProvider"] = scopeAreaProvider(adapter);
@@ -697,22 +816,39 @@ window.__ModuleLoader__.load({
697
816
  */
698
817
  function SessionMaybeEntry({ entry, ownerProps, slotKey, slotInjected, hookContext, hasHookContext }) {
699
818
  const binding = useScopeBinding();
819
+ const epoch = useMaybeIncarnation(binding);
820
+ return (0, react_jsx_runtime.jsx)(SessionMaybeEntryBody, {
821
+ entry,
822
+ ownerProps,
823
+ binding,
824
+ slotKey,
825
+ slotInjected,
826
+ hookContext,
827
+ hasHookContext
828
+ }, epoch);
829
+ }
830
+ const FIRST_INCARNATION = {
831
+ adopted: void 0,
832
+ epoch: 0
833
+ };
834
+ function useMaybeIncarnation(binding) {
835
+ const identity = binding.key === void 0 ? void 0 : binding.ctx;
700
836
  const [state, setState] = (0, react.useState)(FIRST_INCARNATION);
701
837
  let { adopted, epoch } = state;
702
- if (binding.key !== void 0 && adopted === void 0) {
703
- adopted = binding.key;
838
+ if (identity !== void 0 && adopted === void 0) {
839
+ adopted = identity;
704
840
  setState({
705
841
  adopted,
706
842
  epoch
707
843
  });
708
- } else if (adopted !== void 0 && binding.key !== void 0 && binding.key !== adopted) {
709
- adopted = binding.key;
844
+ } else if (adopted !== void 0 && identity !== void 0 && identity !== adopted) {
845
+ adopted = identity;
710
846
  epoch += 1;
711
847
  setState({
712
848
  adopted,
713
849
  epoch
714
850
  });
715
- } else if (adopted !== void 0 && binding.key === void 0) {
851
+ } else if (adopted !== void 0 && identity === void 0) {
716
852
  adopted = void 0;
717
853
  epoch += 1;
718
854
  setState({
@@ -720,20 +856,8 @@ window.__ModuleLoader__.load({
720
856
  epoch
721
857
  });
722
858
  }
723
- return (0, react_jsx_runtime.jsx)(SessionMaybeEntryBody, {
724
- entry,
725
- ownerProps,
726
- binding,
727
- slotKey,
728
- slotInjected,
729
- hookContext,
730
- hasHookContext
731
- }, epoch);
859
+ return epoch;
732
860
  }
733
- const FIRST_INCARNATION = {
734
- adopted: void 0,
735
- epoch: 0
736
- };
737
861
  function RootEntry({ entry, ownerProps, slotKey, slotInjected, hookContext, hasHookContext }) {
738
862
  const host = useHost();
739
863
  const rootBinding = useRootBinding();
@@ -741,22 +865,225 @@ window.__ModuleLoader__.load({
741
865
  const { kit, standard, actions } = standardKit(host, entry, "root", rootBinding, void 0);
742
866
  return renderEntry(slotKey, Comp, kit, standard, cachedRootInject(entry, actions), slotInjected, ownerProps, hookContext, hasHookContext);
743
867
  }
868
+ const FactoryOccurrenceContext = (0, react.createContext)(null);
869
+ const FactoryAncestryContext = (0, react.createContext)(/* @__PURE__ */ new Set());
870
+ const EMPTY_FACTORY_SELECTION = {};
871
+ function useFactorySlotRuntime(name, fallback) {
872
+ const occurrence = (0, react.useContext)(FactoryOccurrenceContext);
873
+ if (occurrence === null) throw new SlotAssemblyError("useFactorySlot() called outside a Factory occurrence");
874
+ if (!occurrence.host.isFactoryLive(occurrence.definition)) throw new _deepseek_ai_dsh_client_ui_slots.StaleAuthorizationError(`useFactorySlot('${name}') from a disposed Factory`);
875
+ const declared = occurrence.definition.slots?.[name];
876
+ if (declared === void 0) throw new _deepseek_ai_dsh_client_ui_slots.SlotOwnershipError(`local slot '${name}' is not declared by factory '${occurrence.definition.name}'`);
877
+ const selected = occurrence.selected[name];
878
+ const Selected = selected ?? fallback;
879
+ const usesFallback = selected === void 0;
880
+ const { definition, host } = occurrence;
881
+ return (0, react.useMemo)(function bindFactoryLocalComponent() {
882
+ return function BoundFactoryLocalComponent(localProps) {
883
+ const current = (0, react.useContext)(FactoryOccurrenceContext);
884
+ const localScopeBinding = useScopeBinding();
885
+ const localMaybeEpoch = useMaybeIncarnation(localScopeBinding);
886
+ if (!host.isFactoryLive(definition)) throw new _deepseek_ai_dsh_client_ui_slots.StaleAuthorizationError(`local slot '${name}' from a disposed Factory`);
887
+ if (current === null || current.definition !== definition) throw new _deepseek_ai_dsh_client_ui_slots.SlotOwnershipError(`local slot '${name}' rendered outside factory '${definition.name}'`);
888
+ if (declared.scope === "session" && localScopeBinding.key === void 0) throw new SlotAssemblyError(`strict session local slot '${name}' from factory '${definition.name}' rendered without a scope binding`);
889
+ const localOwner = usesFallback ? definition : current.caller;
890
+ const localScopeIdentity = declared.scope === "root" ? "root" : declared.scope === "session" ? `session:${sessionGenerationKeyOf(localScopeBinding)}` : `session-maybe:${localMaybeEpoch}`;
891
+ const localStandard = standardProps(declared.scope, current.rootBinding, localScopeBinding);
892
+ const localRegistrationKit = {
893
+ ...current.registrationKit,
894
+ renderFactorySlot: boundRenderFactorySlot(localOwner)
895
+ };
896
+ assertNoPropOverlap(`factory '${definition.name}' local slot '${name}'`, localRegistrationKit, localStandard);
897
+ const provided = {
898
+ ...localRegistrationKit,
899
+ ...localStandard
900
+ };
901
+ assertNoPropOverlap(`factory '${definition.name}' local slot '${name}'`, provided, localProps);
902
+ return (0, react_jsx_runtime.jsx)(FactoryErrorBoundary, {
903
+ name: `${definition.name}:${name}`,
904
+ onEntryError: (error) => {
905
+ host.reportFactoryError(definition.name, localOwner, error);
906
+ },
907
+ children: (0, react_jsx_runtime.jsx)(Selected, {
908
+ ...provided,
909
+ ...localProps
910
+ })
911
+ }, `${definition.name}:${name}:${localScopeIdentity}`);
912
+ };
913
+ }, [
914
+ Selected,
915
+ declared.scope,
916
+ definition,
917
+ host,
918
+ name,
919
+ usesFallback
920
+ ]);
921
+ }
922
+ function assertNoPropOverlap(owner, provided, received) {
923
+ for (const name of Object.keys(received)) if (Object.hasOwn(provided, name)) throw new SlotAssemblyError(`${owner} received duplicate prop '${name}'`);
924
+ }
925
+ function factoryKit(host, definition, rootBinding, scopeBinding, occurrence) {
926
+ const standard = standardProps(definition.scope, rootBinding, scopeBinding);
927
+ const registrationKit = { renderFactorySlot: boundRenderFactorySlot(definition) };
928
+ if (definition.locale !== void 0) {
929
+ const face = host.locale;
930
+ if (face === void 0) throw new SlotAssemblyError(`factory declares locale namespace '${definition.locale}' but no locale face is installed`);
931
+ registrationKit["t"] = localeSeat(face, definition.locale);
932
+ }
933
+ const scoped = scopeBinding?.key === void 0 ? void 0 : scopeBinding;
934
+ const store = host.factoryStoreOf(definition, scoped, occurrence);
935
+ if (store !== void 0) {
936
+ registrationKit["useStore"] = observableHook(store);
937
+ registrationKit["actions"] = store.actions;
938
+ }
939
+ if (definition.children !== void 0) {
940
+ registrationKit["renderSlot"] = boundFactoryRenderSlot(host, definition);
941
+ if (Object.values(definition.children).some((spec) => spec.kind === "chain")) registrationKit["renderSlotChain"] = boundFactoryRenderSlotChain(host, definition);
942
+ if (Object.values(definition.children).some((spec) => spec.scope !== "root")) {
943
+ const sessionAdapter = host.scope("session");
944
+ if (sessionAdapter === void 0) throw new SlotAssemblyError("factory declares a session child without an installed 'session' scope adapter");
945
+ registrationKit["SessionProvider"] = scopeAreaProvider(sessionAdapter);
946
+ }
947
+ }
948
+ return {
949
+ kit: {
950
+ ...standard,
951
+ ...registrationKit
952
+ },
953
+ registrationKit,
954
+ actions: store?.actions
955
+ };
956
+ }
957
+ function FactoryOccurrence({ definition, inputProps, selected, caller, binding, maybeEpoch }) {
958
+ if (definition.scope === "root") return (0, react_jsx_runtime.jsx)(FactoryOccurrenceBody, {
959
+ definition,
960
+ inputProps,
961
+ selected,
962
+ caller
963
+ });
964
+ if (definition.scope === "session") {
965
+ if (binding.key === void 0) throw new SlotAssemblyError(`strict session factory '${definition.name}' rendered without a scope binding`);
966
+ return (0, react_jsx_runtime.jsx)(FactoryOccurrenceBody, {
967
+ definition,
968
+ inputProps,
969
+ selected,
970
+ caller,
971
+ scopeBinding: binding
972
+ }, sessionGenerationKeyOf(binding));
973
+ }
974
+ return (0, react_jsx_runtime.jsx)(FactoryOccurrenceBody, {
975
+ definition,
976
+ inputProps,
977
+ selected,
978
+ caller,
979
+ scopeBinding: binding
980
+ }, maybeEpoch);
981
+ }
982
+ function FactoryOccurrenceBody({ definition, inputProps, selected, caller, scopeBinding }) {
983
+ const host = useHost();
984
+ const rootBinding = useRootBinding();
985
+ const occurrence = (0, react.useRef)({}).current;
986
+ const localeRevision = useLocaleRevision(host.locale);
987
+ (0, react.useEffect)(() => host.retainFactoryOccurrence(definition, occurrence), [
988
+ definition,
989
+ host,
990
+ occurrence
991
+ ]);
992
+ const { kit, registrationKit, actions } = (0, react.useMemo)(() => factoryKit(host, definition, rootBinding, scopeBinding, occurrence), [
993
+ definition,
994
+ host,
995
+ localeRevision,
996
+ occurrence,
997
+ rootBinding,
998
+ scopeBinding
999
+ ]);
1000
+ const injected = (0, react.useMemo)(() => runInject(definition, scopeBinding, actions), [
1001
+ actions,
1002
+ definition,
1003
+ scopeBinding
1004
+ ]);
1005
+ assertNoPropOverlap(`factory '${definition.name}' inject`, kit, injected);
1006
+ const provided = {
1007
+ ...kit,
1008
+ ...injected,
1009
+ useFactorySlot: useFactorySlotRuntime
1010
+ };
1011
+ assertNoPropOverlap(`factory '${definition.name}' occurrence`, provided, inputProps);
1012
+ const context = (0, react.useMemo)(() => ({
1013
+ host,
1014
+ definition,
1015
+ selected,
1016
+ registrationKit: {
1017
+ ...registrationKit,
1018
+ ...injected
1019
+ },
1020
+ rootBinding,
1021
+ caller
1022
+ }), [
1023
+ caller,
1024
+ definition,
1025
+ host,
1026
+ injected,
1027
+ registrationKit,
1028
+ rootBinding,
1029
+ selected
1030
+ ]);
1031
+ const Comp = definition.component;
1032
+ return (0, react_jsx_runtime.jsx)(FactoryOccurrenceContext.Provider, {
1033
+ value: context,
1034
+ children: (0, react_jsx_runtime.jsx)(Comp, {
1035
+ ...provided,
1036
+ ...inputProps
1037
+ })
1038
+ });
1039
+ }
1040
+ function FactoryOutlet({ name, inputProps, slots: selected = EMPTY_FACTORY_SELECTION, fallback, caller }) {
1041
+ const host = useHost();
1042
+ const ancestors = (0, react.useContext)(FactoryAncestryContext);
1043
+ const binding = useScopeBinding();
1044
+ const maybeEpoch = useMaybeIncarnation(binding);
1045
+ const version = (0, react.useSyncExternalStore)((listener) => host.subscribeFactory(name, listener), () => host.getFactoryVersion(name));
1046
+ const definition = host.factoryOf(name);
1047
+ if (definition === void 0) return (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: fallback ?? null });
1048
+ if (ancestors.has(name)) throw new _deepseek_ai_dsh_client_ui_slots.SlotOwnershipError(`recursive render of factory '${name}'`);
1049
+ for (const localName of Object.keys(selected)) if (definition.slots?.[localName] === void 0) throw new _deepseek_ai_dsh_client_ui_slots.SlotOwnershipError(`local slot '${localName}' is not declared by factory '${name}'`);
1050
+ const nextAncestors = new Set(ancestors).add(name);
1051
+ const scopeIdentity = definition.scope === "root" ? "root" : definition.scope === "session" ? binding.key === void 0 ? "session:absent" : `session:${sessionGenerationKeyOf(binding)}` : `session-maybe:${maybeEpoch}`;
1052
+ return (0, react_jsx_runtime.jsx)(FactoryErrorBoundary, {
1053
+ name,
1054
+ onEntryError: (error) => {
1055
+ host.reportFactoryError(name, definition, error);
1056
+ },
1057
+ children: (0, react_jsx_runtime.jsx)(FactoryAncestryContext.Provider, {
1058
+ value: nextAncestors,
1059
+ children: (0, react_jsx_runtime.jsx)(FactoryOccurrence, {
1060
+ definition,
1061
+ inputProps,
1062
+ selected,
1063
+ caller,
1064
+ binding,
1065
+ maybeEpoch
1066
+ })
1067
+ })
1068
+ }, `${name}:${version}:${scopeIdentity}`);
1069
+ }
744
1070
  function StrictSessionEntry({ slotKey, entry, ownerProps, slotInjected, hookContext, hasHookContext, onEntryError }) {
745
1071
  const binding = useScopeBinding();
746
1072
  if (binding.key === void 0) throw new SlotAssemblyError(`strict session slot '${slotKey}' rendered without a scope binding`);
1073
+ const scopedBinding = binding;
747
1074
  return (0, react_jsx_runtime.jsx)(SlotErrorBoundary, {
748
1075
  slotKey,
749
1076
  onEntryError,
750
1077
  children: (0, react_jsx_runtime.jsx)(SessionEntry, {
751
1078
  entry,
752
1079
  ownerProps,
753
- binding,
1080
+ binding: scopedBinding,
754
1081
  slotKey,
755
1082
  slotInjected,
756
1083
  hookContext,
757
1084
  hasHookContext
758
1085
  })
759
- }, binding.key);
1086
+ }, sessionGenerationKeyOf(scopedBinding));
760
1087
  }
761
1088
  /**
762
1089
  * Anchor style shared by every outlet wrapper: `display:contents` keeps the
@@ -944,8 +1271,8 @@ window.__ModuleLoader__.load({
944
1271
  * declaration injection through the caller's ctx.effect (fiber unload
945
1272
  * collects both), the renderer installation contract (install()/renderSlot('root') +
946
1273
  * the SlotRendererHost face), and the store INSTANCE axis — handle x scope
947
- * key -> create/cache, dropped with the last holding entry, session instances
948
- * cleared (with persisted state) on scope death.
1274
+ * key -> create/cache, dropped with the last holding entry, and in-memory
1275
+ * session instances released without clearing persisted state on scope death.
949
1276
  */
950
1277
  /** Instance key for root-scoped store records (session records key by session id, so the literal cannot collide). */
951
1278
  const ROOT_INSTANCE_KEY = "root";
@@ -954,6 +1281,7 @@ window.__ModuleLoader__.load({
954
1281
  _core = new _deepseek_ai_dsh_client_ui_slots.SlotCore();
955
1282
  /** Store-instance axis: handle -> mounted scope, refcount, resolved instances. */
956
1283
  _stores = /* @__PURE__ */ new Map();
1284
+ _factoryStores = /* @__PURE__ */ new Map();
957
1285
  /** Latest live Context generation for each scoped store key. */
958
1286
  _storeScopeOwners = /* @__PURE__ */ new Map();
959
1287
  _renderer;
@@ -1149,21 +1477,22 @@ window.__ModuleLoader__.load({
1149
1477
  }, `slots.installScope(${JSON.stringify(scope)})`);
1150
1478
  }
1151
1479
  /**
1152
- * Bind all scoped Store handles to one owner Context lifetime. The cleanup
1153
- * materializes an otherwise-unused handle before clearing it, because a
1154
- * previous application run may have persisted state for a Slot that this
1155
- * scope never rendered. Rebinding the same key transfers cleanup ownership
1156
- * to the newest Context generation.
1480
+ * Bind scoped Store instances to one Context generation. Rebinding the key
1481
+ * drops the previous generation's memory instances before the new owner can
1482
+ * resolve them. Cleanup never clears persisted state, which belongs to the
1483
+ * durable scope key, or drops a replacement generation's instances.
1157
1484
  *
1158
1485
  * @param binding - materialized scope identity and its owning Context.
1159
1486
  */
1160
1487
  bindStoreScope(binding) {
1161
- if (this._storeScopeOwners.get(binding.key) === binding.ctx) return;
1488
+ const current = this._storeScopeOwners.get(binding.key);
1489
+ if (current === binding.ctx) return;
1490
+ if (current !== void 0) this.releaseStoreScope(binding.key);
1162
1491
  this._storeScopeOwners.set(binding.key, binding.ctx);
1163
1492
  binding.ctx.effect(() => () => {
1164
1493
  if (this._storeScopeOwners.get(binding.key) !== binding.ctx) return;
1165
1494
  this._storeScopeOwners.delete(binding.key);
1166
- this.clearStoreScope(binding.key);
1495
+ this.releaseStoreScope(binding.key);
1167
1496
  }, `slots: store scope ${binding.key}`);
1168
1497
  }
1169
1498
  /**
@@ -1192,7 +1521,7 @@ window.__ModuleLoader__.load({
1192
1521
  * Shadowing winners per cell for a key: the first live (non-abdicated)
1193
1522
  * entry of each cell in priority order — what outlets render; chain keys
1194
1523
  * pass through unchanged (election consumes every entry). The raw
1195
- * {@link SlotsService.entries} view stays the inspection surface. Fresh
1524
+ * {@link SlotRegistry.entries} view stays the inspection surface. Fresh
1196
1525
  * array per call, not a uSES getSnapshot source.
1197
1526
  * @param key - SlotMap key.
1198
1527
  * @returns the winning entry per occupied cell.
@@ -1201,22 +1530,20 @@ window.__ModuleLoader__.load({
1201
1530
  return this._core.entriesOfSlot(key);
1202
1531
  }
1203
1532
  /**
1204
- * Export the current JSON-safe Slot declaration tree for read-only inspection.
1205
- * @param root - exact live Slot root; omitted returns all roots.
1206
- * @returns selected Slot trees.
1533
+ * Export the current JSON-safe Slot and Factory declaration trees for read-only inspection.
1534
+ * @param root - exact live Slot key or `factory:<name>`; omitted returns all roots.
1535
+ * @returns selected composition trees.
1207
1536
  */
1208
1537
  snapshot(root) {
1209
1538
  return this._core.snapshot(root);
1210
1539
  }
1211
1540
  /**
1212
- * Observe entry boundary crashes (every render-time entry failure the
1213
- * boundaries contain, abdicating or not) — the supervision seam for
1214
- * plugins mirroring contribution health. Fires synchronously per report,
1215
- * after the registry mutated for abdicating crashes. Callers own the
1216
- * disposer (wire it through ctx.effect for fiber-lifetime cleanup, as with
1217
- * {@link SlotsService.subscribe}).
1218
- * @param fn - called with the slot key, the crashed entry, the crash
1219
- * cause, and `abdicated`: whether the crash retired the entry from its cell.
1541
+ * Observe ordinary entry and Factory occurrence crashes through one
1542
+ * supervision channel. Fires synchronously after any ordinary-entry
1543
+ * abdication mutation. Callers own the disposer (wire it through ctx.effect
1544
+ * for fiber-lifetime cleanup, as with {@link SlotRegistry.subscribe}).
1545
+ * @param fn - called with the Slot or `factory:<name>` key, crashed
1546
+ * registration, cause, and whether an ordinary entry was retired.
1220
1547
  * @returns unsubscribe.
1221
1548
  */
1222
1549
  onEntryError(fn) {
@@ -1269,6 +1596,29 @@ window.__ModuleLoader__.load({
1269
1596
  if (store !== void 0) this._release(store);
1270
1597
  };
1271
1598
  }
1599
+ _registerFactory(options, component) {
1600
+ const registrant = this.ctx.fiber?.name;
1601
+ const erased = {
1602
+ ...options,
1603
+ ...registrant === void 0 ? {} : { registrant }
1604
+ };
1605
+ const dispose = this._core.registerFactory(erased, component);
1606
+ const definition = this._core.factory(options.name);
1607
+ if (definition === void 0) throw new Error(`slot factory "${options.name}" disappeared during registration`);
1608
+ if (definition.store !== void 0 && typeof definition.store !== "function") this._acquire(definition.store, definition.scope);
1609
+ else if (typeof definition.store === "function") this._factoryStores.set(definition, {
1610
+ occurrences: /* @__PURE__ */ new WeakMap(),
1611
+ mounted: /* @__PURE__ */ new Map()
1612
+ });
1613
+ let disposed = false;
1614
+ return () => {
1615
+ if (disposed) return;
1616
+ disposed = true;
1617
+ dispose();
1618
+ this._factoryStores.delete(definition);
1619
+ if (definition.store !== void 0 && typeof definition.store !== "function") this._release(definition.store);
1620
+ };
1621
+ }
1272
1622
  /** Build the domain-neutral host face once; installed adapters remain live through getters. */
1273
1623
  hostFace() {
1274
1624
  if (this._host !== void 0) return this._host;
@@ -1281,9 +1631,18 @@ window.__ModuleLoader__.load({
1281
1631
  reportEntryError: (key, entry, error, info) => {
1282
1632
  this._core.reportEntryError(key, entry, error, info);
1283
1633
  },
1634
+ reportFactoryError: (name, registration, error) => {
1635
+ this._core.reportFactoryError(name, registration, error);
1636
+ },
1284
1637
  specOf: (key) => this._core.specDynamic(key),
1285
1638
  isLive: (entry) => this._core.isLive(entry),
1286
1639
  storeOf: (entry, scopeBinding) => entry.store === void 0 ? void 0 : this.resolveStore(entry.store, scopeBinding),
1640
+ factoryStoreOf: (definition, scopeBinding, occurrence) => this.resolveFactoryStore(definition, scopeBinding, occurrence),
1641
+ retainFactoryOccurrence: (definition, occurrence) => this.retainFactoryOccurrence(definition, occurrence),
1642
+ subscribeFactory: (name, fn) => this._core.subscribeFactory(name, fn),
1643
+ getFactoryVersion: (name) => this._core.factoryVersion(name),
1644
+ factoryOf: (name) => this._core.factory(name),
1645
+ isFactoryLive: (definition) => this._core.isFactoryLive(definition),
1287
1646
  root: this._rootSource,
1288
1647
  scopeRevision: this._scopeRevisionSource,
1289
1648
  scope: (scope) => service._scopes.get(scope === "session-maybe" ? "session" : scope),
@@ -1343,13 +1702,54 @@ window.__ModuleLoader__.load({
1343
1702
  }
1344
1703
  return instance;
1345
1704
  }
1346
- /** Clear every live non-root Store handle for one dead scope key. */
1347
- clearStoreScope(key) {
1348
- for (const [handle, record] of this._stores) {
1705
+ resolveFactoryStore(definition, scopeBinding, occurrence) {
1706
+ if (!this._core.isFactoryLive(definition)) throw new _deepseek_ai_dsh_client_ui_slots.StaleAuthorizationError(`slot factory "${definition.name}" is not registered`);
1707
+ const declaration = definition.store;
1708
+ if (declaration === void 0) return void 0;
1709
+ if (typeof declaration !== "function") return this.resolveStore(declaration, scopeBinding);
1710
+ const axis = this._factoryStores.get(definition);
1711
+ const scopeKey = definition.scope === "root" ? ROOT_INSTANCE_KEY : requireScopeKey(definition, scopeBinding);
1712
+ if (scopeBinding !== void 0 && definition.scope !== "root") this.bindStoreScope(scopeBinding);
1713
+ let record = axis.occurrences.get(occurrence);
1714
+ if (record === void 0) {
1715
+ const handle = declaration();
1716
+ if (handle.spec.persist !== void 0) throw new SlotAssemblyError(`exclusive store for factory "${definition.name}" cannot declare persistence`);
1717
+ record = {
1718
+ handle,
1719
+ instances: /* @__PURE__ */ new Map(),
1720
+ retainers: 0
1721
+ };
1722
+ axis.occurrences.set(occurrence, record);
1723
+ }
1724
+ const existing = record.instances.get(scopeKey);
1725
+ if (existing !== void 0) return existing;
1726
+ const instance = definition.scope === "root" || scopeBinding === void 0 ? record.handle.create() : record.handle.create(scopeBinding.key);
1727
+ record.instances.set(scopeKey, instance);
1728
+ return instance;
1729
+ }
1730
+ retainFactoryOccurrence(definition, occurrence) {
1731
+ if (!this._core.isFactoryLive(definition)) return () => {};
1732
+ if (typeof definition.store !== "function") return () => {};
1733
+ const axis = this._factoryStores.get(definition);
1734
+ const record = axis.occurrences.get(occurrence);
1735
+ record.retainers += 1;
1736
+ axis.mounted.set(occurrence, record);
1737
+ let released = false;
1738
+ return () => {
1739
+ if (released) return;
1740
+ released = true;
1741
+ record.retainers -= 1;
1742
+ if (record.retainers !== 0) return;
1743
+ axis.mounted.delete(occurrence);
1744
+ };
1745
+ }
1746
+ /** Drop every materialized non-root Store instance for one ended Context generation. */
1747
+ releaseStoreScope(key) {
1748
+ for (const record of this._stores.values()) {
1349
1749
  if (record.scope === "root") continue;
1350
- (record.instances.get(key) ?? handle.create(key)).clearPersisted();
1351
1750
  record.instances.delete(key);
1352
1751
  }
1752
+ for (const axis of this._factoryStores.values()) for (const record of axis.mounted.values()) record.instances.delete(key);
1353
1753
  }
1354
1754
  /** Bind (or re-reference) a handle on the axis; cross-scope conflicts already threw in the core. */
1355
1755
  _acquire(handle, scope) {
@@ -1389,6 +1789,14 @@ window.__ModuleLoader__.load({
1389
1789
  const options = rawOptions;
1390
1790
  return this.ctx.effect(() => this["_register"](options, component), "slots.register()");
1391
1791
  };
1792
+ SlotRegistry.prototype.registerFactory = function registerFactory(rawOptions, component) {
1793
+ const options = rawOptions;
1794
+ return this.ctx.effect(() => this["_registerFactory"](options, component), "slots.registerFactory()");
1795
+ };
1796
+ function requireScopeKey(definition, binding) {
1797
+ if (binding === void 0) throw new Error(`${definition.scope} factory store resolution requires a session id`);
1798
+ return binding.key;
1799
+ }
1392
1800
  //#endregion
1393
1801
  //#region lib/types/client/index.js
1394
1802
  /**