@raphy-js/raph 1.0.0-dev.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 (139) hide show
  1. package/LICENSE +202 -0
  2. package/ReadMe.md +153 -0
  3. package/dist/api/Raph.d.ts +228 -0
  4. package/dist/api/errors.d.ts +20 -0
  5. package/dist/api/public.d.ts +22 -0
  6. package/dist/api/types.d.ts +25 -0
  7. package/dist/debug/api/Raph.cjs +1 -0
  8. package/dist/debug/api/Raph.js +419 -0
  9. package/dist/debug/api/errors.cjs +1 -0
  10. package/dist/debug/api/errors.js +14 -0
  11. package/dist/debug/api/public.cjs +1 -0
  12. package/dist/debug/api/public.js +40 -0
  13. package/dist/debug/api/types.cjs +1 -0
  14. package/dist/debug/api/types.js +1 -0
  15. package/dist/debug/path/AdapterPathStore.cjs +1 -0
  16. package/dist/debug/path/AdapterPathStore.js +133 -0
  17. package/dist/debug/path/DerivedRegistry.cjs +1 -0
  18. package/dist/debug/path/DerivedRegistry.js +157 -0
  19. package/dist/debug/path/MetaController.cjs +1 -0
  20. package/dist/debug/path/MetaController.js +214 -0
  21. package/dist/debug/path/PathEventHub.cjs +1 -0
  22. package/dist/debug/path/PathEventHub.js +148 -0
  23. package/dist/debug/path/PathStore.cjs +1 -0
  24. package/dist/debug/path/PathStore.js +326 -0
  25. package/dist/debug/path/RaphDerivedHandle.cjs +1 -0
  26. package/dist/debug/path/RaphDerivedHandle.js +125 -0
  27. package/dist/debug/path/RaphKernel.cjs +1 -0
  28. package/dist/debug/path/RaphKernel.js +636 -0
  29. package/dist/debug/path/RaphMeta.cjs +1 -0
  30. package/dist/debug/path/RaphMeta.js +68 -0
  31. package/dist/debug/path/RaphMetaStore.cjs +1 -0
  32. package/dist/debug/path/RaphMetaStore.js +184 -0
  33. package/dist/debug/path/data-adapter.cjs +1 -0
  34. package/dist/debug/path/data-adapter.js +356 -0
  35. package/dist/debug/path/data-draft.cjs +1 -0
  36. package/dist/debug/path/data-draft.js +71 -0
  37. package/dist/debug/path/data-path.cjs +1 -0
  38. package/dist/debug/path/data-path.js +423 -0
  39. package/dist/debug/path/derived-collection.cjs +1 -0
  40. package/dist/debug/path/derived-collection.js +179 -0
  41. package/dist/debug/path/derived-strategies.cjs +1 -0
  42. package/dist/debug/path/derived-strategies.js +20 -0
  43. package/dist/debug/path/meta.types.cjs +1 -0
  44. package/dist/debug/path/meta.types.js +1 -0
  45. package/dist/debug/path/path-router.cjs +1 -0
  46. package/dist/debug/path/path-router.js +86 -0
  47. package/dist/debug/path/path.types.cjs +1 -0
  48. package/dist/debug/path/path.types.js +1 -0
  49. package/dist/debug/path/public.cjs +1 -0
  50. package/dist/debug/path/public.js +18 -0
  51. package/dist/debug/path/segment-key.cjs +1 -0
  52. package/dist/debug/path/segment-key.js +12 -0
  53. package/dist/debug/reactivity/engine.cjs +1 -0
  54. package/dist/debug/reactivity/engine.js +1133 -0
  55. package/dist/debug/reactivity/scope.cjs +1 -0
  56. package/dist/debug/reactivity/scope.js +274 -0
  57. package/dist/debug/reactivity/types.cjs +1 -0
  58. package/dist/debug/reactivity/types.js +1 -0
  59. package/dist/debug/reactivity/watch.cjs +1 -0
  60. package/dist/debug/reactivity/watch.js +64 -0
  61. package/dist/debug/runtime/PathHandle.cjs +1 -0
  62. package/dist/debug/runtime/PathHandle.js +139 -0
  63. package/dist/debug/runtime/RaphDebug.cjs +1 -0
  64. package/dist/debug/runtime/RaphDebug.js +15 -0
  65. package/dist/debug/runtime/RaphFrameLoop.cjs +1 -0
  66. package/dist/debug/runtime/RaphFrameLoop.js +106 -0
  67. package/dist/debug/runtime/RaphNode.cjs +1 -0
  68. package/dist/debug/runtime/RaphNode.js +143 -0
  69. package/dist/debug/runtime/RaphPhasePipeline.cjs +1 -0
  70. package/dist/debug/runtime/RaphPhasePipeline.js +526 -0
  71. package/dist/debug/runtime/RaphRuntime.cjs +1 -0
  72. package/dist/debug/runtime/RaphRuntime.js +700 -0
  73. package/dist/debug/runtime/RaphScope.cjs +1 -0
  74. package/dist/debug/runtime/RaphScope.js +64 -0
  75. package/dist/debug/runtime/RuntimeReactivity.cjs +1 -0
  76. package/dist/debug/runtime/RuntimeReactivity.js +154 -0
  77. package/dist/debug/runtime/RuntimeWatch.cjs +1 -0
  78. package/dist/debug/runtime/RuntimeWatch.js +71 -0
  79. package/dist/debug/runtime/disposal.cjs +1 -0
  80. package/dist/debug/runtime/disposal.js +9 -0
  81. package/dist/debug/runtime/errors.cjs +1 -0
  82. package/dist/debug/runtime/errors.js +12 -0
  83. package/dist/debug/runtime/parent-graph.cjs +1 -0
  84. package/dist/debug/runtime/parent-graph.js +10 -0
  85. package/dist/debug/runtime/phase.types.cjs +1 -0
  86. package/dist/debug/runtime/phase.types.js +8 -0
  87. package/dist/debug/runtime/public.cjs +1 -0
  88. package/dist/debug/runtime/public.js +18 -0
  89. package/dist/debug/runtime/runtime-reactivity.types.cjs +1 -0
  90. package/dist/debug/runtime/runtime-reactivity.types.js +1 -0
  91. package/dist/index.cjs +1 -0
  92. package/dist/index.js +40 -0
  93. package/dist/path/AdapterPathStore.d.ts +45 -0
  94. package/dist/path/DerivedRegistry.d.ts +67 -0
  95. package/dist/path/MetaController.d.ts +85 -0
  96. package/dist/path/PathEventHub.d.ts +48 -0
  97. package/dist/path/PathStore.d.ts +51 -0
  98. package/dist/path/RaphDerivedHandle.d.ts +97 -0
  99. package/dist/path/RaphKernel.d.ts +166 -0
  100. package/dist/path/RaphMeta.d.ts +45 -0
  101. package/dist/path/RaphMetaStore.d.ts +45 -0
  102. package/dist/path/data-adapter.d.ts +78 -0
  103. package/dist/path/data-draft.d.ts +4 -0
  104. package/dist/path/data-path.d.ts +97 -0
  105. package/dist/path/derived-collection.d.ts +30 -0
  106. package/dist/path/derived-strategies.d.ts +15 -0
  107. package/dist/path/meta.types.d.ts +33 -0
  108. package/dist/path/path-router.d.ts +21 -0
  109. package/dist/path/path.types.d.ts +26 -0
  110. package/dist/path/public.d.ts +14 -0
  111. package/dist/path/segment-key.d.ts +2 -0
  112. package/dist/path.cjs +1 -0
  113. package/dist/path.js +18 -0
  114. package/dist/raph.cjs +1 -0
  115. package/dist/raph.js +40 -0
  116. package/dist/reactivity/engine.d.ts +379 -0
  117. package/dist/reactivity/scope.d.ts +146 -0
  118. package/dist/reactivity/types.d.ts +150 -0
  119. package/dist/reactivity/watch.d.ts +15 -0
  120. package/dist/reactivity.cjs +1 -0
  121. package/dist/reactivity.js +14 -0
  122. package/dist/runtime/PathHandle.d.ts +72 -0
  123. package/dist/runtime/RaphDebug.d.ts +32 -0
  124. package/dist/runtime/RaphFrameLoop.d.ts +51 -0
  125. package/dist/runtime/RaphNode.d.ts +68 -0
  126. package/dist/runtime/RaphPhasePipeline.d.ts +133 -0
  127. package/dist/runtime/RaphRuntime.d.ts +285 -0
  128. package/dist/runtime/RaphScope.d.ts +50 -0
  129. package/dist/runtime/RuntimeReactivity.d.ts +40 -0
  130. package/dist/runtime/RuntimeWatch.d.ts +28 -0
  131. package/dist/runtime/disposal.d.ts +1 -0
  132. package/dist/runtime/errors.d.ts +16 -0
  133. package/dist/runtime/parent-graph.d.ts +5 -0
  134. package/dist/runtime/phase.types.d.ts +49 -0
  135. package/dist/runtime/public.d.ts +13 -0
  136. package/dist/runtime/runtime-reactivity.types.d.ts +9 -0
  137. package/dist/runtime.cjs +1 -0
  138. package/dist/runtime.js +18 -0
  139. package/package.json +109 -0
@@ -0,0 +1 @@
1
+ "use strict";var m=Object.defineProperty;var g=(u,e,t)=>e in u?m(u,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):u[e]=t;var s=(u,e,t)=>g(u,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../path/data-adapter.cjs");require("../path/data-path.cjs");const o=require("../path/derived-strategies.cjs");require("../path/RaphDerivedHandle.cjs");const d=require("../path/RaphKernel.cjs");require("../path/RaphMeta.cjs");require("../runtime/errors.cjs");require("../runtime/parent-graph.cjs");require("../runtime/PathHandle.cjs");const h=require("../runtime/phase.types.cjs");require("../runtime/RaphNode.cjs");const f=require("../runtime/RaphRuntime.cjs");require("../runtime/RaphScope.cjs");const r=require("./errors.cjs"),R=require("../reactivity/engine.cjs");function n(){throw new r.RaphConfigurationError("[Raph] Facade is not configured. Call Raph.configure({ mode }) first.")}class a{static get configured(){return this._state==="configured"}static get mode(){return this._mode}static configure(e){if(this._state!=="unconfigured")throw new r.RaphConfigurationError(`[Raph] Cannot configure facade while it is ${this._state}.`);this._state="configuring";try{if(this._validateConfigureOptions(e),e.mode==="reactivity")this._configureReactivity(new R.RaphReactivity);else if(e.mode==="runtime")this._configureRuntime(e);else throw new r.RaphConfigurationError("[Raph] Unsupported facade mode.");this._mode=e.mode,this._state="configured"}catch(t){const i=[t],c=[...this._runtimeOrder].reverse();this._clearSession();for(const l of c)try{l.dispose()}catch(_){i.push(_)}throw i.length===1?t:new AggregateError(i,"[Raph] Facade configuration and cleanup failed.")}}static reset(){if(this._state==="unconfigured")return;if(this._state!=="configured")throw new r.RaphConfigurationError(`[Raph] Cannot reset facade while it is ${this._state}.`);this._state="resetting";const e=[...this._runtimeOrder].reverse();this._clearBindings(),this._runtimes=new Map,this._runtimeOrder=[],this._defaultRuntime=void 0;const t=[];for(const i of e)try{i.dispose()}catch(c){t.push(c)}if(this._clearSession(),t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"[Raph] Facade reset failed.")}static get runtime(){return this._requireDefault()}static get meta(){return this._requireDefault().meta}static get debug(){return this._requireDefault().debug}static get root(){return this._requireDefault().root}static getDerivedSnapshot(){return this._requireDefault().getDerivedSnapshot()}static createKernel(e={}){return this._requireMode("runtime"),new d.RaphKernel(e)}static createRuntime(e={}){this._requireMode("runtime");const t=this._resolveRuntimeId(e.id);if(this._runtimes.has(t))throw new r.RaphConfigurationError(`[Raph] Runtime id "${t}" is already registered.`);const i=new f.RaphRuntime({...this._runtimeDefaults,...e,id:t});return this._registerRuntime(i),i}static getRuntime(e){return this._requireMode("runtime"),this._validateRuntimeId(e),this._runtimes.get(e)}static requireRuntime(e){const t=this.getRuntime(e);if(t===void 0)throw new r.RaphConfigurationError(`[Raph] Runtime "${e}" is not registered.`);return t}static hasRuntime(e){return this.getRuntime(e)!==void 0}static disposeRuntime(e){const t=this.getRuntime(e);return t===void 0?!1:(t.dispose(),!0)}static definePhases(e){this._requireDefault().definePhases(e)}static addPhase(e){this._requireDefault().addPhase(e)}static clearPhases(){this._requireDefault().clearPhases()}static flush(){this._requireDefault().flush()}static acquireLoop(e){return this._requireDefault().acquireLoop(e)}static startLoop(){this._requireDefault().startLoop()}static stopLoop(){this._requireDefault().stopLoop()}static node(e,t){return this._requireDefault().node(e,t)}static derive(e){return this._requireDefault().derive(e)}static path(e,t={}){return this._requireDefault().path(e,t)}static get(e,t){const i=this._requireDefault();return e===void 0?i.get():i.get(e,t)}static peek(e,t){const i=this._requireDefault();return e===void 0?i.peek():i.peek(e,t)}static has(e,t){return this._requireDefault().has(e,t)}static set(e,t,i){this._requireDefault().set(e,t,i)}static merge(e,t,i){this._requireDefault().merge(e,t,i)}static delete(e,t){this._requireDefault().delete(e,t)}static transaction(e){return this._requireDefault().transaction(e)}static action(e,t){return this._requireDefault().action(e,t)}static runInAction(e,t){return this._requireDefault().runInAction(e,t)}static _configureReactivity(e){this._reactivity=e,this.signal=e.signal,this.computed=e.computed,this.effect=(t=>{if(typeof t!="function")throw new r.RaphModeError("[Raph] Phase effects require runtime mode.");return e.effect(t)}),this.watch=e.watch,this.batch=e.batch,this.untracked=e.untracked,this.scope=e.scope}static _configureRuntime(e){if(this._runtimeDefaults={...e.scheduler===void 0?{}:{scheduler:e.scheduler},...e.enforceActions===void 0?{}:{enforceActions:e.enforceActions}},e.createDefaultRuntime===!1){this._installMissingDefaultBindings();return}const t=e.defaultRuntimeId??"default";this._validateRuntimeId(t);const i=new f.RaphRuntime({...this._runtimeDefaults,...e.kernel===void 0?{}:{kernel:e.kernel},id:t});this._registerRuntime(i),e.phases!==void 0&&i.definePhases(e.phases),this._defaultRuntime=i,this._bindRuntime(i)}static _bindRuntime(e){this.signal=e.signal.bind(e),this.computed=e.computed.bind(e),this.effect=e.effect.bind(e),this.watch=e.watch.bind(e),this.batch=e.transaction.bind(e),this.untracked=e.untracked.bind(e),this.scope=e.scope.bind(e)}static _registerRuntime(e){this._runtimes.set(e.id,e),this._runtimeOrder.push(e),e._onDisposed(()=>{this._runtimes.get(e.id)===e&&this._runtimes.delete(e.id);const t=this._runtimeOrder.indexOf(e);t>=0&&this._runtimeOrder.splice(t,1),this._defaultRuntime===e&&(this._defaultRuntime=void 0,this._state==="configured"&&this._installMissingDefaultBindings())})}static _requireDefault(){this._requireMode("runtime");const e=this._defaultRuntime;if(e===void 0)throw new r.RaphDefaultRuntimeError("[Raph] Runtime mode has no default Runtime.");return e}static _requireMode(e){if(this._state!=="configured"&&n(),this._mode!==e)throw new r.RaphModeError(`[Raph] Operation requires ${e} mode.`)}static _resolveRuntimeId(e){if(e!==void 0)return this._validateRuntimeId(e),e;let t;do t=`runtime-${this._runtimeCounter++}`;while(this._runtimes.has(t));return t}static _validateRuntimeId(e){if(typeof e!="string"||e.length===0||e.trim()!==e)throw new r.RaphConfigurationError("[Raph] Runtime id must be a non-empty string without surrounding whitespace.")}static _validateConfigureOptions(e){if(typeof e!="object"||e===null)throw new r.RaphConfigurationError("[Raph] Configure options must be an object.");if(e.mode==="reactivity"){this._assertKnownOptions(e,new Set(["mode"]));return}if(e.mode!=="runtime")throw new r.RaphConfigurationError("[Raph] Unsupported facade mode.");if(this._assertKnownOptions(e,new Set(["mode","createDefaultRuntime","defaultRuntimeId","kernel","phases","scheduler","enforceActions"])),e.createDefaultRuntime!==void 0&&e.createDefaultRuntime!==!0&&e.createDefaultRuntime!==!1)throw new r.RaphConfigurationError("[Raph] createDefaultRuntime must be boolean.");if(e.scheduler!==void 0&&!p(e.scheduler))throw new r.RaphConfigurationError(`[Raph] Unsupported scheduler "${String(e.scheduler)}".`);if(e.enforceActions!==void 0&&typeof e.enforceActions!="boolean")throw new r.RaphConfigurationError("[Raph] enforceActions must be boolean.");if(e.createDefaultRuntime===!1){if(e.defaultRuntimeId!==void 0||e.kernel!==void 0||e.phases!==void 0)throw new r.RaphConfigurationError("[Raph] Registry-only mode cannot receive defaultRuntimeId, kernel or phases.");return}if(e.defaultRuntimeId!==void 0&&this._validateRuntimeId(e.defaultRuntimeId),e.kernel!==void 0&&!(e.kernel instanceof d.RaphKernel))throw new r.RaphConfigurationError("[Raph] kernel must be a RaphKernel instance.");if(e.phases!==void 0&&!Array.isArray(e.phases))throw new r.RaphConfigurationError("[Raph] phases must be an array.")}static _assertKnownOptions(e,t){for(const i of Object.keys(e))if(!t.has(i))throw new r.RaphConfigurationError(`[Raph] Unsupported configure option "${i}".`)}static _installMissingDefaultBindings(){const e=()=>{throw new r.RaphDefaultRuntimeError("[Raph] Runtime mode has no default Runtime.")};this.signal=e,this.computed=e,this.effect=e,this.watch=e,this.batch=e,this.untracked=e,this.scope=e}static _clearBindings(){this.signal=n,this.computed=n,this.effect=n,this.watch=n,this.batch=n,this.untracked=n,this.scope=n}static _clearSession(){this._clearBindings(),this._state="unconfigured",this._mode=void 0,this._defaultRuntime=void 0,this._reactivity=void 0,this._runtimes=new Map,this._runtimeOrder=[],this._runtimeDefaults={}}constructor(){}}s(a,"_state","unconfigured"),s(a,"_mode"),s(a,"_defaultRuntime"),s(a,"_reactivity"),s(a,"_runtimes",new Map),s(a,"_runtimeOrder",[]),s(a,"_runtimeCounter",0),s(a,"_runtimeDefaults",{}),s(a,"signal",n),s(a,"computed",n),s(a,"effect",n),s(a,"watch",n),s(a,"batch",n),s(a,"untracked",n),s(a,"scope",n),s(a,"Scheduler",h.RaphSchedulerType),s(a,"DerivedStrategy",Object.freeze({full:o.full,collectionByKey:o.collectionByKey,filterByKey:o.filterByKey}));function p(u){return u===h.RaphSchedulerType.Sync||u===h.RaphSchedulerType.Microtask||u===h.RaphSchedulerType.AnimationFrame}exports.Raph=a;
@@ -0,0 +1,419 @@
1
+ var g = Object.defineProperty;
2
+ var w = (u, t, e) => t in u ? g(u, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : u[t] = e;
3
+ var r = (u, t, e) => w(u, typeof t != "symbol" ? t + "" : t, e);
4
+ import "../path/data-adapter.js";
5
+ import "../path/data-path.js";
6
+ import { filterByKey as R, collectionByKey as p, full as v } from "../path/derived-strategies.js";
7
+ import "../path/RaphDerivedHandle.js";
8
+ import { RaphKernel as o } from "../path/RaphKernel.js";
9
+ import "../path/RaphMeta.js";
10
+ import "../runtime/errors.js";
11
+ import "../runtime/parent-graph.js";
12
+ import "../runtime/PathHandle.js";
13
+ import { RaphSchedulerType as c } from "../runtime/phase.types.js";
14
+ import "../runtime/RaphNode.js";
15
+ import { RaphRuntime as d } from "../runtime/RaphRuntime.js";
16
+ import "../runtime/RaphScope.js";
17
+ import { RaphConfigurationError as a, RaphModeError as f, RaphDefaultRuntimeError as l } from "./errors.js";
18
+ import { RaphReactivity as D } from "../reactivity/engine.js";
19
+ function n() {
20
+ throw new a(
21
+ "[Raph] Facade is not configured. Call Raph.configure({ mode }) first."
22
+ );
23
+ }
24
+ class s {
25
+ /**
26
+ * Показывает, завершена ли явная конфигурация facade.
27
+ */
28
+ static get configured() {
29
+ return this._state === "configured";
30
+ }
31
+ /**
32
+ * Возвращает выбранный режим либо `undefined` до конфигурации.
33
+ */
34
+ static get mode() {
35
+ return this._mode;
36
+ }
37
+ /**
38
+ * Однократно выбирает backend и устанавливает публичные операции facade.
39
+ */
40
+ static configure(t) {
41
+ if (this._state !== "unconfigured")
42
+ throw new a(
43
+ `[Raph] Cannot configure facade while it is ${this._state}.`
44
+ );
45
+ this._state = "configuring";
46
+ try {
47
+ if (this._validateConfigureOptions(t), t.mode === "reactivity")
48
+ this._configureReactivity(new D());
49
+ else if (t.mode === "runtime")
50
+ this._configureRuntime(t);
51
+ else
52
+ throw new a("[Raph] Unsupported facade mode.");
53
+ this._mode = t.mode, this._state = "configured";
54
+ } catch (e) {
55
+ const i = [e], h = [...this._runtimeOrder].reverse();
56
+ this._clearSession();
57
+ for (const m of h)
58
+ try {
59
+ m.dispose();
60
+ } catch (_) {
61
+ i.push(_);
62
+ }
63
+ throw i.length === 1 ? e : new AggregateError(i, "[Raph] Facade configuration and cleanup failed.");
64
+ }
65
+ }
66
+ /**
67
+ * Освобождает принадлежащие facade runtimes и возвращает его в исходное состояние.
68
+ */
69
+ static reset() {
70
+ if (this._state === "unconfigured")
71
+ return;
72
+ if (this._state !== "configured")
73
+ throw new a(`[Raph] Cannot reset facade while it is ${this._state}.`);
74
+ this._state = "resetting";
75
+ const t = [...this._runtimeOrder].reverse();
76
+ this._clearBindings(), this._runtimes = /* @__PURE__ */ new Map(), this._runtimeOrder = [], this._defaultRuntime = void 0;
77
+ const e = [];
78
+ for (const i of t)
79
+ try {
80
+ i.dispose();
81
+ } catch (h) {
82
+ e.push(h);
83
+ }
84
+ if (this._clearSession(), e.length === 1)
85
+ throw e[0];
86
+ if (e.length > 1)
87
+ throw new AggregateError(e, "[Raph] Facade reset failed.");
88
+ }
89
+ /**
90
+ * Возвращает default runtime текущей runtime-сессии.
91
+ */
92
+ static get runtime() {
93
+ return this._requireDefault();
94
+ }
95
+ /**
96
+ * Возвращает metadata facade default runtime.
97
+ */
98
+ static get meta() {
99
+ return this._requireDefault().meta;
100
+ }
101
+ /**
102
+ * Возвращает диагностический facade default runtime.
103
+ */
104
+ static get debug() {
105
+ return this._requireDefault().debug;
106
+ }
107
+ /**
108
+ * Возвращает корневой node default runtime.
109
+ */
110
+ static get root() {
111
+ return this._requireDefault().root;
112
+ }
113
+ /**
114
+ * Формирует снимок materialized derived default runtime.
115
+ */
116
+ static getDerivedSnapshot() {
117
+ return this._requireDefault().getDerivedSnapshot();
118
+ }
119
+ /**
120
+ * Создаёт независимый path/kernel owner в runtime-режиме.
121
+ */
122
+ static createKernel(t = {}) {
123
+ return this._requireMode("runtime"), new o(t);
124
+ }
125
+ /**
126
+ * Создаёт и регистрирует принадлежащий facade runtime.
127
+ */
128
+ static createRuntime(t = {}) {
129
+ this._requireMode("runtime");
130
+ const e = this._resolveRuntimeId(t.id);
131
+ if (this._runtimes.has(e))
132
+ throw new a(`[Raph] Runtime id "${e}" is already registered.`);
133
+ const i = new d({
134
+ ...this._runtimeDefaults,
135
+ ...t,
136
+ id: e
137
+ });
138
+ return this._registerRuntime(i), i;
139
+ }
140
+ /**
141
+ * Возвращает зарегистрированный runtime без ошибки при его отсутствии.
142
+ */
143
+ static getRuntime(t) {
144
+ return this._requireMode("runtime"), this._validateRuntimeId(t), this._runtimes.get(t);
145
+ }
146
+ /**
147
+ * Возвращает зарегистрированный runtime либо отклоняет неизвестный id.
148
+ */
149
+ static requireRuntime(t) {
150
+ const e = this.getRuntime(t);
151
+ if (e === void 0)
152
+ throw new a(`[Raph] Runtime "${t}" is not registered.`);
153
+ return e;
154
+ }
155
+ /**
156
+ * Проверяет наличие runtime в registry текущей сессии.
157
+ */
158
+ static hasRuntime(t) {
159
+ return this.getRuntime(t) !== void 0;
160
+ }
161
+ /**
162
+ * Освобождает зарегистрированный runtime с указанным id.
163
+ */
164
+ static disposeRuntime(t) {
165
+ const e = this.getRuntime(t);
166
+ return e === void 0 ? !1 : (e.dispose(), !0);
167
+ }
168
+ /**
169
+ * Заменяет phases default runtime до первого выполнения pipeline.
170
+ */
171
+ static definePhases(t) {
172
+ this._requireDefault().definePhases(t);
173
+ }
174
+ /**
175
+ * Добавляет phase в default runtime до первого выполнения pipeline.
176
+ */
177
+ static addPhase(t) {
178
+ this._requireDefault().addPhase(t);
179
+ }
180
+ /**
181
+ * Удаляет phases default runtime до первого выполнения pipeline.
182
+ */
183
+ static clearPhases() {
184
+ this._requireDefault().clearPhases();
185
+ }
186
+ /**
187
+ * Синхронно выполняет накопленную работу default runtime.
188
+ */
189
+ static flush() {
190
+ this._requireDefault().flush();
191
+ }
192
+ /**
193
+ * Удерживает frame loop активным от имени указанного owner.
194
+ */
195
+ static acquireLoop(t) {
196
+ return this._requireDefault().acquireLoop(t);
197
+ }
198
+ /**
199
+ * Явно запускает frame loop default runtime.
200
+ */
201
+ static startLoop() {
202
+ this._requireDefault().startLoop();
203
+ }
204
+ /**
205
+ * Снимает явный запуск frame loop default runtime.
206
+ */
207
+ static stopLoop() {
208
+ this._requireDefault().stopLoop();
209
+ }
210
+ /**
211
+ * Создаёт принадлежащий default runtime node и выполняет его setup.
212
+ */
213
+ static node(t, e) {
214
+ return this._requireDefault().node(t, e);
215
+ }
216
+ /**
217
+ * Регистрирует materialized path dependency в default runtime.
218
+ */
219
+ static derive(t) {
220
+ return this._requireDefault().derive(t);
221
+ }
222
+ /**
223
+ * Создаёт lifecycle-aware handle указанного data path.
224
+ */
225
+ static path(t, e = {}) {
226
+ return this._requireDefault().path(t, e);
227
+ }
228
+ static get(t, e) {
229
+ const i = this._requireDefault();
230
+ return t === void 0 ? i.get() : i.get(t, e);
231
+ }
232
+ static peek(t, e) {
233
+ const i = this._requireDefault();
234
+ return t === void 0 ? i.peek() : i.peek(t, e);
235
+ }
236
+ /**
237
+ * Проверяет наличие значения по указанному path.
238
+ */
239
+ static has(t, e) {
240
+ return this._requireDefault().has(t, e);
241
+ }
242
+ /**
243
+ * Заменяет значение по указанному path.
244
+ */
245
+ static set(t, e, i) {
246
+ this._requireDefault().set(t, e, i);
247
+ }
248
+ /**
249
+ * Объединяет значение с существующим объектом по указанному path.
250
+ */
251
+ static merge(t, e, i) {
252
+ this._requireDefault().merge(t, e, i);
253
+ }
254
+ /**
255
+ * Удаляет значение по указанному path.
256
+ */
257
+ static delete(t, e) {
258
+ this._requireDefault().delete(t, e);
259
+ }
260
+ /**
261
+ * Выполняет несколько mutations как одну реактивную транзакцию.
262
+ */
263
+ static transaction(t) {
264
+ return this._requireDefault().transaction(t);
265
+ }
266
+ /**
267
+ * Оборачивает операцию в именованную action текущего runtime.
268
+ */
269
+ static action(t, e) {
270
+ return this._requireDefault().action(t, e);
271
+ }
272
+ /**
273
+ * Немедленно выполняет именованную action текущего runtime.
274
+ */
275
+ static runInAction(t, e) {
276
+ return this._requireDefault().runInAction(t, e);
277
+ }
278
+ static _configureReactivity(t) {
279
+ this._reactivity = t, this.signal = t.signal, this.computed = t.computed, this.effect = ((e) => {
280
+ if (typeof e != "function")
281
+ throw new f("[Raph] Phase effects require runtime mode.");
282
+ return t.effect(e);
283
+ }), this.watch = t.watch, this.batch = t.batch, this.untracked = t.untracked, this.scope = t.scope;
284
+ }
285
+ static _configureRuntime(t) {
286
+ if (this._runtimeDefaults = {
287
+ ...t.scheduler === void 0 ? {} : { scheduler: t.scheduler },
288
+ ...t.enforceActions === void 0 ? {} : { enforceActions: t.enforceActions }
289
+ }, t.createDefaultRuntime === !1) {
290
+ this._installMissingDefaultBindings();
291
+ return;
292
+ }
293
+ const e = t.defaultRuntimeId ?? "default";
294
+ this._validateRuntimeId(e);
295
+ const i = new d({
296
+ ...this._runtimeDefaults,
297
+ ...t.kernel === void 0 ? {} : { kernel: t.kernel },
298
+ id: e
299
+ });
300
+ this._registerRuntime(i), t.phases !== void 0 && i.definePhases(t.phases), this._defaultRuntime = i, this._bindRuntime(i);
301
+ }
302
+ static _bindRuntime(t) {
303
+ this.signal = t.signal.bind(t), this.computed = t.computed.bind(t), this.effect = t.effect.bind(t), this.watch = t.watch.bind(t), this.batch = t.transaction.bind(t), this.untracked = t.untracked.bind(t), this.scope = t.scope.bind(t);
304
+ }
305
+ static _registerRuntime(t) {
306
+ this._runtimes.set(t.id, t), this._runtimeOrder.push(t), t._onDisposed(() => {
307
+ this._runtimes.get(t.id) === t && this._runtimes.delete(t.id);
308
+ const e = this._runtimeOrder.indexOf(t);
309
+ e >= 0 && this._runtimeOrder.splice(e, 1), this._defaultRuntime === t && (this._defaultRuntime = void 0, this._state === "configured" && this._installMissingDefaultBindings());
310
+ });
311
+ }
312
+ static _requireDefault() {
313
+ this._requireMode("runtime");
314
+ const t = this._defaultRuntime;
315
+ if (t === void 0)
316
+ throw new l("[Raph] Runtime mode has no default Runtime.");
317
+ return t;
318
+ }
319
+ static _requireMode(t) {
320
+ if (this._state !== "configured" && n(), this._mode !== t)
321
+ throw new f(`[Raph] Operation requires ${t} mode.`);
322
+ }
323
+ static _resolveRuntimeId(t) {
324
+ if (t !== void 0)
325
+ return this._validateRuntimeId(t), t;
326
+ let e;
327
+ do
328
+ e = `runtime-${this._runtimeCounter++}`;
329
+ while (this._runtimes.has(e));
330
+ return e;
331
+ }
332
+ static _validateRuntimeId(t) {
333
+ if (typeof t != "string" || t.length === 0 || t.trim() !== t)
334
+ throw new a(
335
+ "[Raph] Runtime id must be a non-empty string without surrounding whitespace."
336
+ );
337
+ }
338
+ static _validateConfigureOptions(t) {
339
+ if (typeof t != "object" || t === null)
340
+ throw new a("[Raph] Configure options must be an object.");
341
+ if (t.mode === "reactivity") {
342
+ this._assertKnownOptions(t, /* @__PURE__ */ new Set(["mode"]));
343
+ return;
344
+ }
345
+ if (t.mode !== "runtime")
346
+ throw new a("[Raph] Unsupported facade mode.");
347
+ if (this._assertKnownOptions(t, /* @__PURE__ */ new Set([
348
+ "mode",
349
+ "createDefaultRuntime",
350
+ "defaultRuntimeId",
351
+ "kernel",
352
+ "phases",
353
+ "scheduler",
354
+ "enforceActions"
355
+ ])), t.createDefaultRuntime !== void 0 && t.createDefaultRuntime !== !0 && t.createDefaultRuntime !== !1)
356
+ throw new a("[Raph] createDefaultRuntime must be boolean.");
357
+ if (t.scheduler !== void 0 && !q(t.scheduler))
358
+ throw new a(
359
+ `[Raph] Unsupported scheduler "${String(t.scheduler)}".`
360
+ );
361
+ if (t.enforceActions !== void 0 && typeof t.enforceActions != "boolean")
362
+ throw new a("[Raph] enforceActions must be boolean.");
363
+ if (t.createDefaultRuntime === !1) {
364
+ if (t.defaultRuntimeId !== void 0 || t.kernel !== void 0 || t.phases !== void 0)
365
+ throw new a(
366
+ "[Raph] Registry-only mode cannot receive defaultRuntimeId, kernel or phases."
367
+ );
368
+ return;
369
+ }
370
+ if (t.defaultRuntimeId !== void 0 && this._validateRuntimeId(t.defaultRuntimeId), t.kernel !== void 0 && !(t.kernel instanceof o))
371
+ throw new a("[Raph] kernel must be a RaphKernel instance.");
372
+ if (t.phases !== void 0 && !Array.isArray(t.phases))
373
+ throw new a("[Raph] phases must be an array.");
374
+ }
375
+ static _assertKnownOptions(t, e) {
376
+ for (const i of Object.keys(t))
377
+ if (!e.has(i))
378
+ throw new a(`[Raph] Unsupported configure option "${i}".`);
379
+ }
380
+ static _installMissingDefaultBindings() {
381
+ const t = () => {
382
+ throw new l("[Raph] Runtime mode has no default Runtime.");
383
+ };
384
+ this.signal = t, this.computed = t, this.effect = t, this.watch = t, this.batch = t, this.untracked = t, this.scope = t;
385
+ }
386
+ static _clearBindings() {
387
+ this.signal = n, this.computed = n, this.effect = n, this.watch = n, this.batch = n, this.untracked = n, this.scope = n;
388
+ }
389
+ static _clearSession() {
390
+ this._clearBindings(), this._state = "unconfigured", this._mode = void 0, this._defaultRuntime = void 0, this._reactivity = void 0, this._runtimes = /* @__PURE__ */ new Map(), this._runtimeOrder = [], this._runtimeDefaults = {};
391
+ }
392
+ /**
393
+ * Запрещает создание экземпляров статического facade.
394
+ */
395
+ constructor() {
396
+ }
397
+ }
398
+ // Хранят lifecycle facade, выбранный backend и принадлежащий сессии runtime registry.
399
+ r(s, "_state", "unconfigured"), r(s, "_mode"), r(s, "_defaultRuntime"), r(s, "_reactivity"), r(s, "_runtimes", /* @__PURE__ */ new Map()), r(s, "_runtimeOrder", []), r(s, "_runtimeCounter", 0), r(s, "_runtimeDefaults", {}), // Публикуют операции выбранного backend после успешной конфигурации facade.
400
+ r(s, "signal", n), r(s, "computed", n), r(s, "effect", n), r(s, "watch", n), r(s, "batch", n), r(s, "untracked", n), r(s, "scope", n), // ---------------------------------------------
401
+ // SUGAR
402
+ // ---------------------------------------------
403
+ /**
404
+ * Предоставляет режимы scheduler без отдельного импорта константы.
405
+ */
406
+ r(s, "Scheduler", c), /**
407
+ * Предоставляет стратегии materialized derived рядом с facade API.
408
+ */
409
+ r(s, "DerivedStrategy", Object.freeze({
410
+ full: v,
411
+ collectionByKey: p,
412
+ filterByKey: R
413
+ }));
414
+ function q(u) {
415
+ return u === c.Sync || u === c.Microtask || u === c.AnimationFrame;
416
+ }
417
+ export {
418
+ s as Raph
419
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class o extends Error{}class e extends o{}class a extends e{}class t extends e{}exports.RaphConfigurationError=e;exports.RaphDefaultRuntimeError=t;exports.RaphError=o;exports.RaphModeError=a;
@@ -0,0 +1,14 @@
1
+ class s extends Error {
2
+ }
3
+ class e extends s {
4
+ }
5
+ class a extends e {
6
+ }
7
+ class o extends e {
8
+ }
9
+ export {
10
+ e as RaphConfigurationError,
11
+ o as RaphDefaultRuntimeError,
12
+ s as RaphError,
13
+ a as RaphModeError
14
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../path/data-adapter.cjs"),o=require("../path/data-path.cjs"),r=require("../path/derived-strategies.cjs"),t=require("../path/RaphDerivedHandle.cjs"),h=require("../path/RaphKernel.cjs"),u=require("../path/RaphMeta.cjs"),a=require("../runtime/errors.cjs"),i=require("../runtime/parent-graph.cjs"),n=require("../runtime/PathHandle.cjs"),R=require("../runtime/phase.types.cjs"),d=require("../runtime/RaphNode.cjs"),_=require("../runtime/RaphRuntime.cjs"),s=require("../runtime/RaphScope.cjs"),e=require("./errors.cjs"),c=require("./Raph.cjs");exports.DefaultDataAdapter=p.DefaultDataAdapter;exports.DataPath=o.DataPath;exports.collectionByKey=r.collectionByKey;exports.filterByKey=r.filterByKey;exports.full=r.full;exports.RaphDerivedHandle=t.RaphDerivedHandle;exports.RaphDerivedTargetWriteError=t.RaphDerivedTargetWriteError;exports.RaphKernel=h.RaphKernel;exports.RaphMeta=u.RaphMeta;exports.RaphActionError=a.RaphActionError;exports.RaphCrossRuntimeError=a.RaphCrossRuntimeError;exports.RaphDisposedError=a.RaphDisposedError;exports.parentGraph=i.parentGraph;exports.PathHandle=n.PathHandle;exports.RaphSchedulerType=R.RaphSchedulerType;exports.RaphNode=d.RaphNode;exports.RaphRuntime=_.RaphRuntime;exports.RaphScope=s.RaphScope;exports.RaphConfigurationError=e.RaphConfigurationError;exports.RaphDefaultRuntimeError=e.RaphDefaultRuntimeError;exports.RaphError=e.RaphError;exports.RaphModeError=e.RaphModeError;exports.Raph=c.Raph;
@@ -0,0 +1,40 @@
1
+ import { DefaultDataAdapter as e } from "../path/data-adapter.js";
2
+ import { DataPath as t } from "../path/data-path.js";
3
+ import { collectionByKey as f, filterByKey as h, full as R } from "../path/derived-strategies.js";
4
+ import { RaphDerivedHandle as x, RaphDerivedTargetWriteError as i } from "../path/RaphDerivedHandle.js";
5
+ import { RaphKernel as n } from "../path/RaphKernel.js";
6
+ import { RaphMeta as u } from "../path/RaphMeta.js";
7
+ import { RaphActionError as D, RaphCrossRuntimeError as c, RaphDisposedError as y } from "../runtime/errors.js";
8
+ import { parentGraph as K } from "../runtime/parent-graph.js";
9
+ import { PathHandle as v } from "../runtime/PathHandle.js";
10
+ import { RaphSchedulerType as B } from "../runtime/phase.types.js";
11
+ import { RaphNode as H } from "../runtime/RaphNode.js";
12
+ import { RaphRuntime as P } from "../runtime/RaphRuntime.js";
13
+ import { RaphScope as T } from "../runtime/RaphScope.js";
14
+ import { RaphConfigurationError as N, RaphDefaultRuntimeError as W, RaphError as b, RaphModeError as j } from "./errors.js";
15
+ import { Raph as q } from "./Raph.js";
16
+ export {
17
+ t as DataPath,
18
+ e as DefaultDataAdapter,
19
+ v as PathHandle,
20
+ q as Raph,
21
+ D as RaphActionError,
22
+ N as RaphConfigurationError,
23
+ c as RaphCrossRuntimeError,
24
+ W as RaphDefaultRuntimeError,
25
+ x as RaphDerivedHandle,
26
+ i as RaphDerivedTargetWriteError,
27
+ y as RaphDisposedError,
28
+ b as RaphError,
29
+ n as RaphKernel,
30
+ u as RaphMeta,
31
+ j as RaphModeError,
32
+ H as RaphNode,
33
+ P as RaphRuntime,
34
+ B as RaphSchedulerType,
35
+ T as RaphScope,
36
+ f as collectionByKey,
37
+ h as filterByKey,
38
+ R as full,
39
+ K as parentGraph
40
+ };
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
1
+ "use strict";var p=Object.defineProperty;var l=(r,e,t)=>e in r?p(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var d=(r,e,t)=>l(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./data-path.cjs"),_=require("./PathEventHub.cjs");class b{constructor(e){d(this,"_eventHub",new _.PathEventHub("[Raph] Adapter transaction and publication failed."));this._adapter=e}get(e,t){const a=i.parseDataPath(e,t);return this._adapter.get(a.canonical)}peek(e,t){return this.get(e,t)}has(e,t){var n,s;const a=i.parseDataPath(e,t);return((s=(n=this._adapter).has)==null?void 0:s.call(n,a.canonical))??u(this._adapter.root(),a.segments)}set(e,t,a){const n=i.parseDataPath(e,a),s=this._eventHub.hasWatchers?this._adapter.get(n.canonical):void 0;this._adapter.set(n.canonical,t),this._eventHub.record({kind:"set",path:n.canonical,previous:s,value:this._eventHub.hasWatchers?this._adapter.get(n.canonical):void 0})}merge(e,t,a){const n=i.parseDataPath(e,a),s=this._eventHub.hasWatchers?this._adapter.get(n.canonical):void 0,c=o(s)&&o(t)?f(s):s;this._adapter.merge(n.canonical,t),this._eventHub.record({kind:"merge",path:n.canonical,previous:c,value:this._eventHub.hasWatchers?this._adapter.get(n.canonical):void 0})}delete(e,t){var c,h;const a=i.parseDataPath(e,t);if(!(((h=(c=this._adapter).has)==null?void 0:h.call(c,a.canonical))??u(this._adapter.root(),a.segments)))return;const s=this._eventHub.hasWatchers?this._adapter.get(a.canonical):void 0;this._adapter.delete(a.canonical),this._eventHub.record({kind:"delete",path:a.canonical,previous:s,value:void 0})}transaction(e){return this._eventHub.transaction(e)}watch(e,t){return this._eventHub.watch(e,t)}}function u(r,e){let t=r;for(const a of e)if(a.kind==="key"){if(!v(t)||!Object.hasOwn(t,a.key))return!1;t=t[a.key]}else if(a.kind==="index"){if(!Array.isArray(t)||!Object.hasOwn(t,a.index))return!1;t=t[a.index]}else{if(!Array.isArray(t))return!1;const n=t.findIndex(s=>o(s)&&Object.hasOwn(s,a.key)&&Object.is(s[a.key],a.value));if(n===-1)return!1;t=t[n]}return!0}function f(r){const e=Object.create(Object.getPrototypeOf(r));for(const t of Object.keys(r))t==="__proto__"?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:r[t],writable:!0}):e[t]=r[t];return e}function o(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}function v(r){return Array.isArray(r)||o(r)}exports.AdapterPathStore=b;
@@ -0,0 +1,133 @@
1
+ var p = Object.defineProperty;
2
+ var l = (r, t, e) => t in r ? p(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var d = (r, t, e) => l(r, typeof t != "symbol" ? t + "" : t, e);
4
+ import { parseDataPath as i } from "./data-path.js";
5
+ import { PathEventHub as _ } from "./PathEventHub.js";
6
+ class k {
7
+ /**
8
+ * Связывает внешний DataAdapter с path events и watchers Kernel.
9
+ */
10
+ constructor(t) {
11
+ // Публикует изменения внешнего adapter через общий path event lifecycle.
12
+ d(this, "_eventHub", new _(
13
+ "[Raph] Adapter transaction and publication failed."
14
+ ));
15
+ this._adapter = t;
16
+ }
17
+ /**
18
+ * Возвращает значение по пути без создания отсутствующих данных.
19
+ */
20
+ get(t, e) {
21
+ const a = i(t, e);
22
+ return this._adapter.get(a.canonical);
23
+ }
24
+ /**
25
+ * Читает значение по пути без регистрации реактивной зависимости.
26
+ */
27
+ peek(t, e) {
28
+ return this.get(t, e);
29
+ }
30
+ /**
31
+ * Проверяет наличие значения по указанному пути.
32
+ */
33
+ has(t, e) {
34
+ var n, s;
35
+ const a = i(t, e);
36
+ return ((s = (n = this._adapter).has) == null ? void 0 : s.call(n, a.canonical)) ?? u(this._adapter.root(), a.segments);
37
+ }
38
+ /**
39
+ * Записывает значение и публикует соответствующее изменение.
40
+ */
41
+ set(t, e, a) {
42
+ const n = i(t, a), s = this._eventHub.hasWatchers ? this._adapter.get(n.canonical) : void 0;
43
+ this._adapter.set(n.canonical, e), this._eventHub.record({
44
+ kind: "set",
45
+ path: n.canonical,
46
+ previous: s,
47
+ value: this._eventHub.hasWatchers ? this._adapter.get(n.canonical) : void 0
48
+ });
49
+ }
50
+ /**
51
+ * Объединяет значение по пути и публикует соответствующее изменение.
52
+ */
53
+ merge(t, e, a) {
54
+ const n = i(t, a), s = this._eventHub.hasWatchers ? this._adapter.get(n.canonical) : void 0, c = o(s) && o(e) ? f(s) : s;
55
+ this._adapter.merge(n.canonical, e), this._eventHub.record({
56
+ kind: "merge",
57
+ path: n.canonical,
58
+ previous: c,
59
+ value: this._eventHub.hasWatchers ? this._adapter.get(n.canonical) : void 0
60
+ });
61
+ }
62
+ /**
63
+ * Удаляет значение по пути и публикует изменение при наличии данных.
64
+ */
65
+ delete(t, e) {
66
+ var c, h;
67
+ const a = i(t, e);
68
+ if (!(((h = (c = this._adapter).has) == null ? void 0 : h.call(c, a.canonical)) ?? u(this._adapter.root(), a.segments)))
69
+ return;
70
+ const s = this._eventHub.hasWatchers ? this._adapter.get(a.canonical) : void 0;
71
+ this._adapter.delete(a.canonical), this._eventHub.record({
72
+ kind: "delete",
73
+ path: a.canonical,
74
+ previous: s,
75
+ value: void 0
76
+ });
77
+ }
78
+ /**
79
+ * Выполняет операцию в общей синхронной transaction boundary.
80
+ */
81
+ transaction(t) {
82
+ return this._eventHub.transaction(t);
83
+ }
84
+ /**
85
+ * Подписывает callback на подходящие изменения и возвращает disposer.
86
+ */
87
+ watch(t, e) {
88
+ return this._eventHub.watch(t, e);
89
+ }
90
+ }
91
+ function u(r, t) {
92
+ let e = r;
93
+ for (const a of t)
94
+ if (a.kind === "key") {
95
+ if (!b(e) || !Object.hasOwn(e, a.key))
96
+ return !1;
97
+ e = e[a.key];
98
+ } else if (a.kind === "index") {
99
+ if (!Array.isArray(e) || !Object.hasOwn(e, a.index))
100
+ return !1;
101
+ e = e[a.index];
102
+ } else {
103
+ if (!Array.isArray(e))
104
+ return !1;
105
+ const n = e.findIndex(
106
+ (s) => o(s) && Object.hasOwn(s, a.key) && Object.is(s[a.key], a.value)
107
+ );
108
+ if (n === -1)
109
+ return !1;
110
+ e = e[n];
111
+ }
112
+ return !0;
113
+ }
114
+ function f(r) {
115
+ const t = Object.create(Object.getPrototypeOf(r));
116
+ for (const e of Object.keys(r))
117
+ e === "__proto__" ? Object.defineProperty(t, e, {
118
+ configurable: !0,
119
+ enumerable: !0,
120
+ value: r[e],
121
+ writable: !0
122
+ }) : t[e] = r[e];
123
+ return t;
124
+ }
125
+ function o(r) {
126
+ return typeof r == "object" && r !== null && !Array.isArray(r);
127
+ }
128
+ function b(r) {
129
+ return Array.isArray(r) || o(r);
130
+ }
131
+ export {
132
+ k as AdapterPathStore
133
+ };
@@ -0,0 +1 @@
1
+ "use strict";var h=Object.defineProperty;var u=(r,e,t)=>e in r?h(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var d=(r,e,t)=>u(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./data-path.cjs"),_=require("./derived-collection.cjs"),f=require("./path-router.cjs"),g=2e4;class v{constructor(){d(this,"_router");d(this,"_handles");d(this,"_matches");d(this,"_pending");d(this,"_collections");d(this,"_counter",0)}get size(){var e;return((e=this._handles)==null?void 0:e.size)??0}get pending(){return this._pending}nextId(){return`derived-${this._counter++}`}has(e){var t;return((t=this._handles)==null?void 0:t.has(e))??!1}values(){var e;return((e=this._handles)==null?void 0:e.values())??[][Symbol.iterator]()}state(e){var t;return(t=this._collections)==null?void 0:t.get(e)}register(e,t,i){(this._handles??(this._handles=new Map)).set(e.id,e),i!==void 0&&(this._collections??(this._collections=new Map)).set(e,{from:t,kind:i.kind,key:i.key,initialized:!1,full:!0,keys:new Set,sourceIndex:void 0,targetIndex:void 0});const n=this._router??(this._router=new f.PathRouter);this._matches=void 0,e._attachRoutes(l.pathRelationMasks(t).map(s=>n.add(l.parsePathMask(s),e)))}remove(e){var i,o,n;const t=this._handles;(t==null?void 0:t.get(e.id))===e&&(t.delete(e.id),e._detachRoutes(),this._matches=void 0,(i=this._pending)==null||i.delete(e),(o=this._collections)==null||o.delete(e),((n=this._collections)==null?void 0:n.size)===0&&(this._collections=void 0),t.size===0&&(this._handles=void 0,this._router=void 0,this._pending=void 0))}queue(e){var o;const t=this._matching(e);if(t.length===0)return;const i=this._pending??(this._pending=new Set);for(const n of t){if(n.paused||n.disposed)continue;const s=(o=this._collections)==null?void 0:o.get(n);if(s!==void 0&&s.initialized&&!s.full){const c=_.collectionMutationImpact(s.from,s.key,e);c.kind==="full"?(s.full=!0,s.keys.clear()):s.keys.add(c.key)}i.add(n)}}queueReplacement(e,t){var n;const i=this._matching(e);if(i.length===0)return;const o=this._pending??(this._pending=new Set);for(const s of i){if(s.paused||s.disposed)continue;const c=(n=this._collections)==null?void 0:n.get(s);if(c!==void 0&&c.initialized&&!c.full&&c.from.canonical===e.canonical)for(const a of t)c.keys.add(a);else c!==void 0&&(c.full=!0,c.keys.clear());o.add(s)}}clearPendingIfEmpty(){var e;((e=this._pending)==null?void 0:e.size)===0&&(this._pending=void 0)}dispose(){if(this._handles!==void 0)for(const e of this._handles.values())e._disposeFromKernel();this._handles=void 0,this._router=void 0,this._matches=void 0,this._pending=void 0,this._collections=void 0}_matching(e){var n;const t=this._router;if(t===void 0)return[];let i=(n=this._matches)==null?void 0:n.get(e.canonical);if(i!==void 0)return i;i=[...e.segments.length===0?t.matchAll():t.match(e.segments)];const o=this._matches??(this._matches=new Map);return o.size>=g&&o.clear(),o.set(e.canonical,i),i}}exports.DerivedRegistry=v;