@raphy-js/raph 1.0.0-dev.2 → 1.0.1-dev.25
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/README.md +1096 -0
- package/dist/api/Raph.d.ts +59 -190
- package/dist/api/RaphFacadeSession.d.ts +90 -0
- package/dist/api/RaphReactivityInstance.d.ts +72 -0
- package/dist/api/errors.d.ts +9 -4
- package/dist/api/types.d.ts +162 -17
- package/dist/core-CClhT8WR.js +1044 -0
- package/dist/core-cPQWYD4K.cjs +1 -0
- package/dist/debug/api/Raph.cjs +1 -1
- package/dist/debug/api/Raph.js +368 -367
- package/dist/debug/api/RaphFacadeSession.cjs +1 -0
- package/dist/debug/api/RaphFacadeSession.js +302 -0
- package/dist/debug/api/RaphReactivityInstance.cjs +1 -0
- package/dist/debug/api/RaphReactivityInstance.js +146 -0
- package/dist/debug/api/errors.cjs +1 -1
- package/dist/debug/api/errors.js +10 -7
- package/dist/debug/path/DataPath.cjs +1 -0
- package/dist/debug/path/DataPath.js +390 -0
- package/dist/debug/path/PathRouter.cjs +1 -0
- package/dist/debug/path/PathRouter.js +80 -0
- package/dist/debug/path/RaphKernel.cjs +1 -1
- package/dist/debug/path/RaphKernel.js +316 -236
- package/dist/debug/path/data-path.utils.cjs +1 -0
- package/dist/debug/path/data-path.utils.js +56 -0
- package/dist/debug/path/derived/DerivedRegistry.cjs +1 -0
- package/dist/debug/path/derived/DerivedRegistry.js +143 -0
- package/dist/debug/path/derived/RaphDerivedHandle.cjs +1 -0
- package/dist/debug/path/{RaphDerivedHandle.js → derived/RaphDerivedHandle.js} +19 -22
- package/dist/debug/path/derived/derived-collection.utils.cjs +1 -0
- package/dist/debug/path/{derived-collection.js → derived/derived-collection.utils.js} +71 -71
- package/dist/debug/path/derived/derived-strategy.types.cjs +1 -0
- package/dist/debug/path/derived/derived-strategy.types.js +1 -0
- package/dist/debug/path/meta/MetaController.cjs +1 -0
- package/dist/debug/path/{MetaController.js → meta/MetaController.js} +58 -66
- package/dist/debug/path/meta/RaphMeta.cjs +1 -0
- package/dist/debug/path/meta/RaphMeta.js +62 -0
- package/dist/debug/path/meta/RaphMetaStore.cjs +1 -0
- package/dist/debug/path/{RaphMetaStore.js → meta/RaphMetaStore.js} +24 -30
- package/dist/debug/path/meta/meta.types.cjs +1 -0
- package/dist/debug/path/meta/meta.types.js +1 -0
- package/dist/debug/path/storage/AdapterPathStore.cjs +1 -0
- package/dist/debug/path/storage/AdapterPathStore.js +128 -0
- package/dist/debug/path/storage/DefaultDataAdapter.cjs +1 -0
- package/dist/debug/path/{data-adapter.js → storage/DefaultDataAdapter.js} +47 -57
- package/dist/debug/path/storage/PathEventHub.cjs +1 -0
- package/dist/debug/path/storage/PathEventHub.js +161 -0
- package/dist/debug/path/storage/PathStore.cjs +1 -0
- package/dist/debug/path/{PathStore.js → storage/PathStore.js} +88 -98
- package/dist/debug/path/storage/createDataDraft.cjs +1 -0
- package/dist/debug/path/{data-draft.js → storage/createDataDraft.js} +24 -28
- package/dist/debug/path/storage/data-adapter.types.cjs +1 -0
- package/dist/debug/path/storage/data-adapter.types.js +1 -0
- package/dist/debug/reactivity/disposal.cjs +1 -0
- package/dist/debug/reactivity/disposal.js +32 -0
- package/dist/debug/reactivity/engine.cjs +1 -1
- package/dist/debug/reactivity/engine.js +888 -321
- package/dist/debug/reactivity/reactive-object.cjs +1 -0
- package/dist/debug/reactivity/reactive-object.js +265 -0
- package/dist/debug/reactivity/scope.cjs +1 -1
- package/dist/debug/reactivity/scope.js +221 -117
- package/dist/debug/reactivity/watch.cjs +1 -1
- package/dist/debug/reactivity/watch.js +1 -1
- package/dist/debug/runtime/RaphRuntime.cjs +1 -1
- package/dist/debug/runtime/RaphRuntime.js +1134 -502
- package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -0
- package/dist/debug/runtime/diagnostics/RaphDebug.js +287 -0
- package/dist/debug/runtime/errors.cjs +1 -1
- package/dist/debug/runtime/errors.js +6 -3
- package/dist/debug/runtime/ownership/RaphEffectScope.cjs +1 -0
- package/dist/debug/runtime/ownership/RaphEffectScope.js +304 -0
- package/dist/debug/runtime/ownership/RaphNode.cjs +1 -0
- package/dist/debug/runtime/ownership/RaphNode.js +665 -0
- package/dist/debug/runtime/ownership/RaphScope.cjs +1 -0
- package/dist/debug/runtime/ownership/RaphScope.js +236 -0
- package/dist/debug/runtime/ownership/parent-graph.types.cjs +1 -0
- package/dist/debug/runtime/ownership/parent-graph.types.js +1 -0
- package/dist/debug/runtime/phases/RaphFrameLoop.cjs +1 -0
- package/dist/debug/runtime/{RaphFrameLoop.js → phases/RaphFrameLoop.js} +13 -17
- package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -0
- package/dist/debug/runtime/phases/RaphPhasePipeline.js +848 -0
- package/dist/debug/runtime/phases/RaphPhaseTaskRecord.cjs +1 -0
- package/dist/debug/runtime/phases/RaphPhaseTaskRecord.js +176 -0
- package/dist/debug/runtime/phases/RaphPhaseWatch.cjs +1 -0
- package/dist/debug/runtime/phases/RaphPhaseWatch.js +20 -0
- package/dist/debug/runtime/phases/orderPhaseTasks.cjs +1 -0
- package/dist/debug/runtime/phases/orderPhaseTasks.js +59 -0
- package/dist/debug/runtime/reactivity/PathHandle.cjs +1 -0
- package/dist/debug/runtime/reactivity/PathHandle.js +165 -0
- package/dist/debug/runtime/reactivity/RaphMetaSource.cjs +1 -0
- package/dist/debug/runtime/reactivity/RaphMetaSource.js +108 -0
- package/dist/debug/runtime/reactivity/RaphSelector.cjs +1 -0
- package/dist/debug/runtime/reactivity/RaphSelector.js +503 -0
- package/dist/debug/runtime/reactivity/RaphWorkGraph.cjs +1 -0
- package/dist/debug/runtime/reactivity/RaphWorkGraph.js +1157 -0
- package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -0
- package/dist/debug/runtime/reactivity/RuntimeReactivity.js +550 -0
- package/dist/debug/runtime/reactivity/RuntimeWatch.cjs +1 -0
- package/dist/debug/runtime/reactivity/RuntimeWatch.js +77 -0
- package/dist/debug/runtime/reactivity/disposal-sweep.utils.cjs +1 -0
- package/dist/debug/runtime/reactivity/disposal-sweep.utils.js +42 -0
- package/dist/debug/runtime/reactivity/runtime-reactivity.types.cjs +1 -0
- package/dist/debug/runtime/reactivity/runtime-reactivity.types.js +1 -0
- package/dist/entrypoints/machine-testing.d.ts +2 -0
- package/dist/entrypoints/machine.d.ts +5 -0
- package/dist/entrypoints/path.d.ts +14 -0
- package/dist/entrypoints/reactivity.d.ts +1 -0
- package/dist/entrypoints/runtime.d.ts +18 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +46 -38
- package/dist/machine/compiler.d.ts +71 -0
- package/dist/machine/core.d.ts +50 -0
- package/dist/machine/persistence.d.ts +5 -0
- package/dist/machine/runtime.d.ts +4 -0
- package/dist/machine/testing.d.ts +43 -0
- package/dist/machine/types.d.ts +155 -0
- package/dist/machine-testing.cjs +1 -0
- package/dist/machine-testing.js +188 -0
- package/dist/machine.cjs +1 -0
- package/dist/machine.js +822 -0
- package/dist/main.d.ts +20 -0
- package/dist/path/{data-path.d.ts → DataPath.d.ts} +16 -40
- package/dist/path/{path-router.d.ts → PathRouter.d.ts} +1 -1
- package/dist/path/RaphKernel.d.ts +37 -10
- package/dist/path/data-path.types.d.ts +34 -0
- package/dist/path/data-path.utils.d.ts +9 -0
- package/dist/path/{DerivedRegistry.d.ts → derived/DerivedRegistry.d.ts} +2 -2
- package/dist/path/{RaphDerivedHandle.d.ts → derived/RaphDerivedHandle.d.ts} +3 -3
- package/dist/path/derived/derived-collection.types.d.ts +12 -0
- package/dist/path/{derived-collection.d.ts → derived/derived-collection.utils.d.ts} +3 -13
- package/dist/path/{derived-strategies.d.ts → derived/derived-strategy.types.d.ts} +0 -3
- package/dist/path/derived/derived-strategy.utils.d.ts +4 -0
- package/dist/path/{MetaController.d.ts → meta/MetaController.d.ts} +4 -4
- package/dist/path/{RaphMeta.d.ts → meta/RaphMeta.d.ts} +2 -2
- package/dist/path/{RaphMetaStore.d.ts → meta/RaphMetaStore.d.ts} +1 -1
- package/dist/path/{meta.types.d.ts → meta/meta.types.d.ts} +2 -4
- package/dist/path/path.types.d.ts +3 -2
- package/dist/path/{segment-key.d.ts → pathSegmentKey.d.ts} +1 -1
- package/dist/path/{AdapterPathStore.d.ts → storage/AdapterPathStore.d.ts} +4 -4
- package/dist/path/{data-adapter.d.ts → storage/DefaultDataAdapter.d.ts} +2 -17
- package/dist/path/storage/PathEventHub.d.ts +62 -0
- package/dist/path/{PathStore.d.ts → storage/PathStore.d.ts} +7 -7
- package/dist/path/storage/data-adapter.types.d.ts +17 -0
- package/dist/path.cjs +1 -1
- package/dist/path.js +16 -16
- package/dist/raph.cjs +1 -1
- package/dist/raph.js +46 -38
- package/dist/reactivity/disposal.d.ts +14 -0
- package/dist/reactivity/engine.d.ts +193 -6
- package/dist/reactivity/reactive-object.d.ts +36 -0
- package/dist/reactivity/scope.d.ts +108 -30
- package/dist/reactivity/types.d.ts +25 -0
- package/dist/reactivity.cjs +1 -1
- package/dist/reactivity.js +12 -12
- package/dist/runtime/RaphRuntime.d.ts +319 -160
- package/dist/runtime/diagnostics/RaphDebug.d.ts +239 -0
- package/dist/runtime/errors.d.ts +5 -0
- package/dist/runtime/ownership/RaphEffectScope.d.ts +98 -0
- package/dist/runtime/ownership/RaphNode.d.ts +310 -0
- package/dist/runtime/ownership/RaphScope.d.ts +168 -0
- package/dist/runtime/{parent-graph.d.ts → ownership/parent-graph.types.d.ts} +0 -1
- package/dist/runtime/ownership/parentGraph.d.ts +3 -0
- package/dist/runtime/phases/RaphPhasePipeline.d.ts +253 -0
- package/dist/runtime/phases/RaphPhaseTaskRecord.d.ts +195 -0
- package/dist/runtime/phases/RaphPhaseWatch.d.ts +22 -0
- package/dist/runtime/phases/orderPhaseTasks.d.ts +6 -0
- package/dist/runtime/phases/phase.types.d.ts +171 -0
- package/dist/runtime/{PathHandle.d.ts → reactivity/PathHandle.d.ts} +14 -6
- package/dist/runtime/reactivity/RaphMetaSource.d.ts +32 -0
- package/dist/runtime/reactivity/RaphSelector.d.ts +338 -0
- package/dist/runtime/reactivity/RaphWorkGraph.d.ts +309 -0
- package/dist/runtime/reactivity/RuntimeReactivity.d.ts +293 -0
- package/dist/runtime/{RuntimeWatch.d.ts → reactivity/RuntimeWatch.d.ts} +12 -6
- package/dist/runtime/reactivity/disposal-sweep.utils.d.ts +19 -0
- package/dist/runtime/reactivity/runtime-reactivity.types.d.ts +56 -0
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.js +21 -16
- package/package.json +76 -35
- package/ReadMe.md +0 -153
- package/dist/api/public.d.ts +0 -22
- package/dist/debug/api/public.cjs +0 -1
- package/dist/debug/api/public.js +0 -40
- package/dist/debug/path/AdapterPathStore.cjs +0 -1
- package/dist/debug/path/AdapterPathStore.js +0 -133
- package/dist/debug/path/DerivedRegistry.cjs +0 -1
- package/dist/debug/path/DerivedRegistry.js +0 -157
- package/dist/debug/path/MetaController.cjs +0 -1
- package/dist/debug/path/PathEventHub.cjs +0 -1
- package/dist/debug/path/PathEventHub.js +0 -148
- package/dist/debug/path/PathStore.cjs +0 -1
- package/dist/debug/path/RaphDerivedHandle.cjs +0 -1
- package/dist/debug/path/RaphMeta.cjs +0 -1
- package/dist/debug/path/RaphMeta.js +0 -68
- package/dist/debug/path/RaphMetaStore.cjs +0 -1
- package/dist/debug/path/data-adapter.cjs +0 -1
- package/dist/debug/path/data-draft.cjs +0 -1
- package/dist/debug/path/data-path.cjs +0 -1
- package/dist/debug/path/data-path.js +0 -423
- package/dist/debug/path/derived-collection.cjs +0 -1
- package/dist/debug/path/path-router.cjs +0 -1
- package/dist/debug/path/path-router.js +0 -86
- package/dist/debug/path/public.cjs +0 -1
- package/dist/debug/path/public.js +0 -18
- package/dist/debug/runtime/PathHandle.cjs +0 -1
- package/dist/debug/runtime/PathHandle.js +0 -139
- package/dist/debug/runtime/RaphDebug.cjs +0 -1
- package/dist/debug/runtime/RaphDebug.js +0 -15
- package/dist/debug/runtime/RaphFrameLoop.cjs +0 -1
- package/dist/debug/runtime/RaphNode.cjs +0 -1
- package/dist/debug/runtime/RaphNode.js +0 -143
- package/dist/debug/runtime/RaphPhasePipeline.cjs +0 -1
- package/dist/debug/runtime/RaphPhasePipeline.js +0 -526
- package/dist/debug/runtime/RaphScope.cjs +0 -1
- package/dist/debug/runtime/RaphScope.js +0 -64
- package/dist/debug/runtime/RuntimeReactivity.cjs +0 -1
- package/dist/debug/runtime/RuntimeReactivity.js +0 -154
- package/dist/debug/runtime/RuntimeWatch.cjs +0 -1
- package/dist/debug/runtime/RuntimeWatch.js +0 -71
- package/dist/debug/runtime/public.cjs +0 -1
- package/dist/debug/runtime/public.js +0 -18
- package/dist/path/PathEventHub.d.ts +0 -48
- package/dist/path/public.d.ts +0 -14
- package/dist/runtime/RaphDebug.d.ts +0 -32
- package/dist/runtime/RaphNode.d.ts +0 -68
- package/dist/runtime/RaphPhasePipeline.d.ts +0 -133
- package/dist/runtime/RaphScope.d.ts +0 -50
- package/dist/runtime/RuntimeReactivity.d.ts +0 -40
- package/dist/runtime/phase.types.d.ts +0 -49
- package/dist/runtime/public.d.ts +0 -13
- package/dist/runtime/runtime-reactivity.types.d.ts +0 -9
- /package/dist/debug/path/{meta.types.cjs → data-path.types.cjs} +0 -0
- /package/dist/debug/path/{meta.types.js → data-path.types.js} +0 -0
- /package/dist/debug/{runtime/runtime-reactivity.types.cjs → path/derived/derived-collection.types.cjs} +0 -0
- /package/dist/debug/{runtime/runtime-reactivity.types.js → path/derived/derived-collection.types.js} +0 -0
- /package/dist/debug/path/{derived-strategies.cjs → derived/derived-strategy.utils.cjs} +0 -0
- /package/dist/debug/path/{derived-strategies.js → derived/derived-strategy.utils.js} +0 -0
- /package/dist/debug/path/{segment-key.cjs → pathSegmentKey.cjs} +0 -0
- /package/dist/debug/path/{segment-key.js → pathSegmentKey.js} +0 -0
- /package/dist/debug/runtime/{parent-graph.cjs → ownership/parentGraph.cjs} +0 -0
- /package/dist/debug/runtime/{parent-graph.js → ownership/parentGraph.js} +0 -0
- /package/dist/debug/runtime/{disposal.cjs → ownership/throwDisposalErrors.cjs} +0 -0
- /package/dist/debug/runtime/{disposal.js → ownership/throwDisposalErrors.js} +0 -0
- /package/dist/debug/runtime/{phase.types.cjs → phases/phase.types.cjs} +0 -0
- /package/dist/debug/runtime/{phase.types.js → phases/phase.types.js} +0 -0
- /package/dist/path/{data-draft.d.ts → storage/createDataDraft.d.ts} +0 -0
- /package/dist/runtime/{disposal.d.ts → ownership/throwDisposalErrors.d.ts} +0 -0
- /package/dist/runtime/{RaphFrameLoop.d.ts → phases/RaphFrameLoop.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./DataPath.cjs"),r=2e4;let c,i;function f(e,t){if(!t?.vars){const n=c?.get(e);if(n!==void 0)return n}if(typeof e!="string")return h(e,t);const a=s.DataPath._parseExactString(e,t);if(!t?.vars){const n=c??=new Map;n.size>=r&&n.clear(),n.set(e,a)}return a}function o(e){const t=i?.get(e);if(t!==void 0)return t;if(typeof e!="string")return l(e);const a=s.DataPath._parseMaskString(e),n=i??=new Map;return n.size>=r&&n.clear(),n.set(e,a),a}function u(e){if(e.segments.length===0)return["*"];const t=[`${e.canonical}.*`];for(let a=1;a<e.segments.length;a++)t.push(s.DataPath._renderSegments(e.segments.slice(0,a)));return t}function h(e,t){const a=s.DataPath.from(e,t)._asExact();if(e instanceof s.DataPath&&!t?.vars){const n=c??=new Map;n.size>=r&&n.clear(),n.set(e,a)}return a}function l(e){const t=s.DataPath.from(e)._asMask();if(e instanceof s.DataPath){const a=i??=new Map;a.size>=r&&a.clear(),a.set(e,t)}return t}exports.parseDataPath=f;exports.parsePathMask=o;exports.pathRelationMasks=u;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { DataPath as s } from "./DataPath.js";
|
|
2
|
+
const c = 2e4;
|
|
3
|
+
let a, i;
|
|
4
|
+
function l(e, t) {
|
|
5
|
+
if (!t?.vars) {
|
|
6
|
+
const r = a?.get(e);
|
|
7
|
+
if (r !== void 0)
|
|
8
|
+
return r;
|
|
9
|
+
}
|
|
10
|
+
if (typeof e != "string")
|
|
11
|
+
return f(e, t);
|
|
12
|
+
const n = s._parseExactString(e, t);
|
|
13
|
+
if (!t?.vars) {
|
|
14
|
+
const r = a ??= /* @__PURE__ */ new Map();
|
|
15
|
+
r.size >= c && r.clear(), r.set(e, n);
|
|
16
|
+
}
|
|
17
|
+
return n;
|
|
18
|
+
}
|
|
19
|
+
function g(e) {
|
|
20
|
+
const t = i?.get(e);
|
|
21
|
+
if (t !== void 0)
|
|
22
|
+
return t;
|
|
23
|
+
if (typeof e != "string")
|
|
24
|
+
return o(e);
|
|
25
|
+
const n = s._parseMaskString(e), r = i ??= /* @__PURE__ */ new Map();
|
|
26
|
+
return r.size >= c && r.clear(), r.set(e, n), n;
|
|
27
|
+
}
|
|
28
|
+
function h(e) {
|
|
29
|
+
if (e.segments.length === 0)
|
|
30
|
+
return ["*"];
|
|
31
|
+
const t = [`${e.canonical}.*`];
|
|
32
|
+
for (let n = 1; n < e.segments.length; n++)
|
|
33
|
+
t.push(s._renderSegments(e.segments.slice(0, n)));
|
|
34
|
+
return t;
|
|
35
|
+
}
|
|
36
|
+
function f(e, t) {
|
|
37
|
+
const n = s.from(e, t)._asExact();
|
|
38
|
+
if (e instanceof s && !t?.vars) {
|
|
39
|
+
const r = a ??= /* @__PURE__ */ new Map();
|
|
40
|
+
r.size >= c && r.clear(), r.set(e, n);
|
|
41
|
+
}
|
|
42
|
+
return n;
|
|
43
|
+
}
|
|
44
|
+
function o(e) {
|
|
45
|
+
const t = s.from(e)._asMask();
|
|
46
|
+
if (e instanceof s) {
|
|
47
|
+
const n = i ??= /* @__PURE__ */ new Map();
|
|
48
|
+
n.size >= c && n.clear(), n.set(e, t);
|
|
49
|
+
}
|
|
50
|
+
return t;
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
l as parseDataPath,
|
|
54
|
+
g as parsePathMask,
|
|
55
|
+
h as pathRelationMasks
|
|
56
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../data-path.utils.cjs"),l=require("../PathRouter.cjs"),r=require("./derived-collection.utils.cjs"),a=2e4;class h{_router;_handles;_matches;_pending;_collections;_counter=0;get size(){return this._handles?.size??0}get pending(){return this._pending}nextId(){return`derived-${this._counter++}`}has(e){return this._handles?.has(e)??!1}values(){return this._handles?.values()??[][Symbol.iterator]()}state(e){return this._collections?.get(e)}register(e,t,s){(this._handles??=new Map).set(e.id,e),s!==void 0&&(this._collections??=new Map).set(e,{from:t,kind:s.kind,key:s.key,initialized:!1,full:!0,keys:new Set,sourceIndex:void 0,targetIndex:void 0});const i=this._router??=new l.PathRouter;this._matches=void 0,e._attachRoutes(d.pathRelationMasks(t).map(n=>i.add(d.parsePathMask(n),e)))}remove(e){const t=this._handles;t?.get(e.id)===e&&(t.delete(e.id),e._detachRoutes(),this._matches=void 0,this._pending?.delete(e),this._collections?.delete(e),this._collections?.size===0&&(this._collections=void 0),t.size===0&&(this._handles=void 0,this._router=void 0,this._pending=void 0))}queue(e){const t=this._matching(e);if(t.length===0)return;const s=this._pending??=new Set;for(const o of t){if(o.paused||o.disposed)continue;const i=this._collections?.get(o);if(i!==void 0&&i.initialized&&!i.full){const n=r.collectionMutationImpact(i.from,i.key,e);n.kind==="full"?(i.full=!0,i.keys.clear()):i.keys.add(n.key)}s.add(o)}}queueReplacement(e,t){const s=this._matching(e);if(s.length===0)return;const o=this._pending??=new Set;for(const i of s){if(i.paused||i.disposed)continue;const n=this._collections?.get(i);if(n!==void 0&&n.initialized&&!n.full&&n.from.canonical===e.canonical)for(const c of t)n.keys.add(c);else n!==void 0&&(n.full=!0,n.keys.clear());o.add(i)}}clearPendingIfEmpty(){this._pending?.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){const t=this._router;if(t===void 0)return[];let s=this._matches?.get(e.canonical);if(s!==void 0)return s;s=[...e.segments.length===0?t.matchAll():t.match(e.segments)];const o=this._matches??=new Map;return o.size>=a&&o.clear(),o.set(e.canonical,s),s}}exports.DerivedRegistry=h;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { pathRelationMasks as d, parsePathMask as l } from "../data-path.utils.js";
|
|
2
|
+
import { PathRouter as r } from "../PathRouter.js";
|
|
3
|
+
import { collectionMutationImpact as a } from "./derived-collection.utils.js";
|
|
4
|
+
const h = 2e4;
|
|
5
|
+
class g {
|
|
6
|
+
// Хранят routes, handles и инкрементальное состояние materialized derived.
|
|
7
|
+
_router;
|
|
8
|
+
_handles;
|
|
9
|
+
_matches;
|
|
10
|
+
_pending;
|
|
11
|
+
_collections;
|
|
12
|
+
// Формирует локальные идентификаторы derived без глобального shared state.
|
|
13
|
+
_counter = 0;
|
|
14
|
+
/**
|
|
15
|
+
* Возвращает число зарегистрированных записей.
|
|
16
|
+
*/
|
|
17
|
+
get size() {
|
|
18
|
+
return this._handles?.size ?? 0;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Возвращает очередь derived-вычислений, ожидающих стабилизации.
|
|
22
|
+
*/
|
|
23
|
+
get pending() {
|
|
24
|
+
return this._pending;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Выделяет следующий стабильный идентификатор registry.
|
|
28
|
+
*/
|
|
29
|
+
nextId() {
|
|
30
|
+
return `derived-${this._counter++}`;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Проверяет наличие derived handle с указанным id.
|
|
34
|
+
*/
|
|
35
|
+
has(e) {
|
|
36
|
+
return this._handles?.has(e) ?? !1;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Возвращает зарегистрированные derived handles.
|
|
40
|
+
*/
|
|
41
|
+
values() {
|
|
42
|
+
return this._handles?.values() ?? [][Symbol.iterator]();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Возвращает внутреннее состояние зарегистрированного handle.
|
|
46
|
+
*/
|
|
47
|
+
state(e) {
|
|
48
|
+
return this._collections?.get(e);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Регистрирует derived handle и его зависимости.
|
|
52
|
+
*/
|
|
53
|
+
register(e, t, s) {
|
|
54
|
+
(this._handles ??= /* @__PURE__ */ new Map()).set(e.id, e), s !== void 0 && (this._collections ??= /* @__PURE__ */ new Map()).set(e, {
|
|
55
|
+
from: t,
|
|
56
|
+
kind: s.kind,
|
|
57
|
+
key: s.key,
|
|
58
|
+
initialized: !1,
|
|
59
|
+
full: !0,
|
|
60
|
+
keys: /* @__PURE__ */ new Set(),
|
|
61
|
+
sourceIndex: void 0,
|
|
62
|
+
targetIndex: void 0
|
|
63
|
+
});
|
|
64
|
+
const i = this._router ??= new r();
|
|
65
|
+
this._matches = void 0, e._attachRoutes(d(t).map(
|
|
66
|
+
(n) => i.add(l(n), e)
|
|
67
|
+
));
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Удаляет регистрацию и связанные pending-записи.
|
|
71
|
+
*/
|
|
72
|
+
remove(e) {
|
|
73
|
+
const t = this._handles;
|
|
74
|
+
t?.get(e.id) === e && (t.delete(e.id), e._detachRoutes(), this._matches = void 0, this._pending?.delete(e), this._collections?.delete(e), this._collections?.size === 0 && (this._collections = void 0), t.size === 0 && (this._handles = void 0, this._router = void 0, this._pending = void 0));
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Добавляет derived handle в очередь пересчёта.
|
|
78
|
+
*/
|
|
79
|
+
queue(e) {
|
|
80
|
+
const t = this._matching(e);
|
|
81
|
+
if (t.length === 0)
|
|
82
|
+
return;
|
|
83
|
+
const s = this._pending ??= /* @__PURE__ */ new Set();
|
|
84
|
+
for (const o of t) {
|
|
85
|
+
if (o.paused || o.disposed)
|
|
86
|
+
continue;
|
|
87
|
+
const i = this._collections?.get(o);
|
|
88
|
+
if (i !== void 0 && i.initialized && !i.full) {
|
|
89
|
+
const n = a(i.from, i.key, e);
|
|
90
|
+
n.kind === "full" ? (i.full = !0, i.keys.clear()) : i.keys.add(n.key);
|
|
91
|
+
}
|
|
92
|
+
s.add(o);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Запоминает полную замену, которую нужно применить при стабилизации.
|
|
97
|
+
*/
|
|
98
|
+
queueReplacement(e, t) {
|
|
99
|
+
const s = this._matching(e);
|
|
100
|
+
if (s.length === 0)
|
|
101
|
+
return;
|
|
102
|
+
const o = this._pending ??= /* @__PURE__ */ new Set();
|
|
103
|
+
for (const i of s) {
|
|
104
|
+
if (i.paused || i.disposed)
|
|
105
|
+
continue;
|
|
106
|
+
const n = this._collections?.get(i);
|
|
107
|
+
if (n !== void 0 && n.initialized && !n.full && n.from.canonical === e.canonical)
|
|
108
|
+
for (const c of t)
|
|
109
|
+
n.keys.add(c);
|
|
110
|
+
else n !== void 0 && (n.full = !0, n.keys.clear());
|
|
111
|
+
o.add(i);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Сбрасывает pending-состояние после опустошения очереди.
|
|
116
|
+
*/
|
|
117
|
+
clearPendingIfEmpty() {
|
|
118
|
+
this._pending?.size === 0 && (this._pending = void 0);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Освобождает все handles и очищает derived registry.
|
|
122
|
+
*/
|
|
123
|
+
dispose() {
|
|
124
|
+
if (this._handles !== void 0)
|
|
125
|
+
for (const e of this._handles.values())
|
|
126
|
+
e._disposeFromKernel();
|
|
127
|
+
this._handles = void 0, this._router = void 0, this._matches = void 0, this._pending = void 0, this._collections = void 0;
|
|
128
|
+
}
|
|
129
|
+
_matching(e) {
|
|
130
|
+
const t = this._router;
|
|
131
|
+
if (t === void 0)
|
|
132
|
+
return [];
|
|
133
|
+
let s = this._matches?.get(e.canonical);
|
|
134
|
+
if (s !== void 0)
|
|
135
|
+
return s;
|
|
136
|
+
s = [...e.segments.length === 0 ? t.matchAll() : t.match(e.segments)];
|
|
137
|
+
const o = this._matches ??= /* @__PURE__ */ new Map();
|
|
138
|
+
return o.size >= h && o.clear(), o.set(e.canonical, s), s;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
export {
|
|
142
|
+
g as DerivedRegistry
|
|
143
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class i extends Error{constructor(e){super(`[Raph] Derived target is read-only: "${e}".`),this.name="RaphDerivedTargetWriteError"}}class o{id;options;_kernel;_removeRoutes;_paused=!1;_disposed=!1;_status="idle";_lastError=null;constructor(e,s,r){this._kernel=e,this.id=s,this.options=r}get paused(){return this._paused}get disposed(){return this._disposed}get status(){return this._status}get lastError(){return this._lastError}_recordSuccess(){this._status="success",this._lastError=null}_recordFailure(e){this._status="error",this._lastError=e instanceof Error?e:new Error(String(e))}pause(){this._assertAlive(),this._paused=!0}resume(){this._assertAlive(),this._paused=!1,this.recompute()}recompute(){this._assertAlive(),this._kernel._recomputeDerived(this)}dispose(){this._disposed||(this._disposed=!0,this._kernel._removeDerived(this),this.options.disposeTarget==="delete"&&this._kernel.delete(this.options.to))}_attachRoutes(e){this._removeRoutes=e}_detachRoutes(){const e=this._removeRoutes;if(this._removeRoutes=void 0,e!==void 0)for(const s of e)s()}_disposeFromKernel(){this._disposed=!0,this._removeRoutes=void 0}_assertAlive(){if(this._disposed)throw new Error(`[Raph] Derived "${this.id}" is disposed.`)}}exports.RaphDerivedHandle=o;exports.RaphDerivedTargetWriteError=i;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var d = (r, e, t) => e in r ? o(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
-
var s = (r, e, t) => d(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
class h extends Error {
|
|
1
|
+
class i extends Error {
|
|
5
2
|
/**
|
|
6
3
|
* Создаёт ошибку с canonical path защищённого derived target.
|
|
7
4
|
*/
|
|
@@ -9,24 +6,24 @@ class h extends Error {
|
|
|
9
6
|
super(`[Raph] Derived target is read-only: "${e}".`), this.name = "RaphDerivedTargetWriteError";
|
|
10
7
|
}
|
|
11
8
|
}
|
|
12
|
-
class
|
|
9
|
+
class o {
|
|
10
|
+
// Публикуют identity и immutable параметры materialized dependency.
|
|
11
|
+
id;
|
|
12
|
+
options;
|
|
13
|
+
// Связывают handle с owning Kernel и зарегистрированными source routes.
|
|
14
|
+
_kernel;
|
|
15
|
+
_removeRoutes;
|
|
16
|
+
// Хранят lifecycle и результат последнего вычисления.
|
|
17
|
+
_paused = !1;
|
|
18
|
+
_disposed = !1;
|
|
19
|
+
_status = "idle";
|
|
20
|
+
_lastError = null;
|
|
13
21
|
/**
|
|
14
22
|
* Создаёт internal handle, которым управляет owning Kernel.
|
|
15
23
|
* @internal
|
|
16
24
|
*/
|
|
17
|
-
constructor(e,
|
|
18
|
-
|
|
19
|
-
s(this, "id");
|
|
20
|
-
s(this, "options");
|
|
21
|
-
// Связывают handle с owning Kernel и зарегистрированными source routes.
|
|
22
|
-
s(this, "_kernel");
|
|
23
|
-
s(this, "_removeRoutes");
|
|
24
|
-
// Хранят lifecycle и результат последнего вычисления.
|
|
25
|
-
s(this, "_paused", !1);
|
|
26
|
-
s(this, "_disposed", !1);
|
|
27
|
-
s(this, "_status", "idle");
|
|
28
|
-
s(this, "_lastError", null);
|
|
29
|
-
this._kernel = e, this.id = t, this.options = i;
|
|
25
|
+
constructor(e, s, r) {
|
|
26
|
+
this._kernel = e, this.id = s, this.options = r;
|
|
30
27
|
}
|
|
31
28
|
/**
|
|
32
29
|
* Показывает, приостановлено ли derived-вычисление.
|
|
@@ -104,8 +101,8 @@ class u {
|
|
|
104
101
|
_detachRoutes() {
|
|
105
102
|
const e = this._removeRoutes;
|
|
106
103
|
if (this._removeRoutes = void 0, e !== void 0)
|
|
107
|
-
for (const
|
|
108
|
-
|
|
104
|
+
for (const s of e)
|
|
105
|
+
s();
|
|
109
106
|
}
|
|
110
107
|
/**
|
|
111
108
|
* Помечает handle освобождённым после cleanup owning Kernel.
|
|
@@ -120,6 +117,6 @@ class u {
|
|
|
120
117
|
}
|
|
121
118
|
}
|
|
122
119
|
export {
|
|
123
|
-
|
|
124
|
-
|
|
120
|
+
o as RaphDerivedHandle,
|
|
121
|
+
i as RaphDerivedTargetWriteError
|
|
125
122
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../data-path.utils.cjs");function m(e,t,o){if(o.segments.length<=e.segments.length)return{kind:"full"};for(let r=0;r<e.segments.length;r++)if(!$(e.segments[r],o.segments[r]))return{kind:"full"};const i=o.segments[e.segments.length];if(i?.kind!=="selector"||i.key!==t||typeof i.value!="string"&&typeof i.value!="number")return{kind:"full"};const n=o.segments[e.segments.length+1];return n?.kind==="key"&&n.key===t?{kind:"full"}:{kind:"key",key:i.value}}function k(e,t,o){const i=p.parseDataPath(e).canonical,n=typeof o=="number"?String(o):JSON.stringify(o);return`${i}[${t}=${n}]`}function g(e,t,o,i){if(!Array.isArray(o)||!Array.isArray(i))throw f(e,"requires array source and output");if(o.length!==i.length)throw f(e,"must preserve collection cardinality");const n=a(o,t,"source"),r=a(i,t,"output");for(let s=0;s<n.length;s++)if(n[s]!==r[s])throw f(e,"must preserve key order")}function h(e,t,o,i){if(!Array.isArray(i))throw f(e,"incremental compute must return an array");if(o.length!==i.length)throw f(e,"incremental compute must preserve cardinality");const n=a(i,t,"output");for(let r=0;r<o.length;r++)if(o[r]!==n[r])throw f(e,"incremental compute must preserve key order")}function w(e,t,o,i){if(!Array.isArray(o)||!Array.isArray(i))throw u(e,"requires array source and output");d(e,"output must be an ordered subset of source",a(o,t,"source"),a(i,t,"output"))}function b(e,t,o,i){if(!Array.isArray(i))throw u(e,"incremental compute must return an array");d(e,"incremental output must be an ordered subset of input",o,a(i,t,"output"))}function a(e,t,o){const i=new Set,n=[];for(let r=0;r<e.length;r++){if(!(r in e)){n.push(void 0);continue}const s=e[r];if(!y(s))throw new TypeError(`[Raph] ${o} collection items must be objects.`);const c=s[t];if(typeof c!="string"&&typeof c!="number")throw new TypeError(`[Raph] ${o} item key "${t}" must be a string or number.`);if(i.has(c))throw new TypeError(`[Raph] Duplicate ${o} key: "${String(c)}".`);i.add(c),n.push(c)}return n}function A(e,t,o){const i=a(e,t,o),n=new Map;for(let r=0;r<i.length;r++){const s=i[r];s!==void 0&&n.set(s,r)}return n}function x(e,t,o,i){for(const n of i){const r=o.get(n);if(r===void 0)return!0;const s=e[r];if(!y(s)||s[t]!==n)return!0}return!1}function f(e,t){return new TypeError(`[Raph] collectionByKey derived "${e}" ${t}.`)}function u(e,t){return new TypeError(`[Raph] filterByKey derived "${e}" ${t}.`)}function E(e){return l(e,new WeakMap)}function d(e,t,o,i){const n=new Map;for(let s=0;s<o.length;s++){const c=o[s];c!==void 0&&n.set(c,s)}let r=-1;for(const s of i){if(s===void 0)continue;const c=n.get(s);if(c===void 0||c<=r)throw u(e,t);r=c}}function l(e,t){if(e===null||typeof e!="object")return e;const o=t.get(e);if(o!==void 0)return o;if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(e instanceof Map){const n=new Map;t.set(e,n);for(const[r,s]of e)n.set(l(r,t),l(s,t));return n}if(e instanceof Set){const n=new Set;t.set(e,n);for(const r of e)n.add(l(r,t));return n}if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return structuredClone(e);if(Array.isArray(e)){const n=[];t.set(e,n);for(let r=0;r<e.length;r++)r in e&&(n[r]=l(e[r],t));return n}const i=Object.create(Object.getPrototypeOf(e));t.set(e,i);for(const n of Reflect.ownKeys(e))i[n]=l(e[n],t);return i}function $(e,t){return e.kind!==t.kind?!1:e.kind==="key"&&t.kind==="key"?e.key===t.key:e.kind==="index"&&t.kind==="index"?e.index===t.index:e.kind==="selector"&&t.kind==="selector"&&e.key===t.key&&Object.is(e.value,t.value)}function y(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}exports.cloneMaterializedValue=E;exports.collectionError=f;exports.collectionIndex=A;exports.collectionKeys=a;exports.collectionMutationImpact=m;exports.filterError=u;exports.indexesAreStale=x;exports.keyedPath=k;exports.validateFullCollection=g;exports.validateFullFilter=w;exports.validateIncrementalCollection=h;exports.validateIncrementalFilter=b;
|
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
import { parseDataPath as p } from "
|
|
2
|
-
function g(e, t,
|
|
3
|
-
if (
|
|
1
|
+
import { parseDataPath as p } from "../data-path.utils.js";
|
|
2
|
+
function g(e, t, o) {
|
|
3
|
+
if (o.segments.length <= e.segments.length)
|
|
4
4
|
return { kind: "full" };
|
|
5
|
-
for (let
|
|
6
|
-
if (!m(e.segments[
|
|
5
|
+
for (let r = 0; r < e.segments.length; r++)
|
|
6
|
+
if (!m(e.segments[r], o.segments[r]))
|
|
7
7
|
return { kind: "full" };
|
|
8
|
-
const
|
|
9
|
-
if (
|
|
8
|
+
const i = o.segments[e.segments.length];
|
|
9
|
+
if (i?.kind !== "selector" || i.key !== t || typeof i.value != "string" && typeof i.value != "number")
|
|
10
10
|
return { kind: "full" };
|
|
11
|
-
const n =
|
|
12
|
-
return
|
|
11
|
+
const n = o.segments[e.segments.length + 1];
|
|
12
|
+
return n?.kind === "key" && n.key === t ? { kind: "full" } : { kind: "key", key: i.value };
|
|
13
13
|
}
|
|
14
|
-
function h(e, t,
|
|
15
|
-
const
|
|
16
|
-
return `${
|
|
14
|
+
function h(e, t, o) {
|
|
15
|
+
const i = p(e).canonical, n = typeof o == "number" ? String(o) : JSON.stringify(o);
|
|
16
|
+
return `${i}[${t}=${n}]`;
|
|
17
17
|
}
|
|
18
|
-
function w(e, t,
|
|
19
|
-
if (!Array.isArray(
|
|
18
|
+
function w(e, t, o, i) {
|
|
19
|
+
if (!Array.isArray(o) || !Array.isArray(i))
|
|
20
20
|
throw a(e, "requires array source and output");
|
|
21
|
-
if (
|
|
21
|
+
if (o.length !== i.length)
|
|
22
22
|
throw a(e, "must preserve collection cardinality");
|
|
23
|
-
const n = f(
|
|
23
|
+
const n = f(o, t, "source"), r = f(i, t, "output");
|
|
24
24
|
for (let s = 0; s < n.length; s++)
|
|
25
|
-
if (n[s] !==
|
|
25
|
+
if (n[s] !== r[s])
|
|
26
26
|
throw a(e, "must preserve key order");
|
|
27
27
|
}
|
|
28
|
-
function A(e, t,
|
|
29
|
-
if (!Array.isArray(
|
|
28
|
+
function A(e, t, o, i) {
|
|
29
|
+
if (!Array.isArray(i))
|
|
30
30
|
throw a(e, "incremental compute must return an array");
|
|
31
|
-
if (
|
|
31
|
+
if (o.length !== i.length)
|
|
32
32
|
throw a(e, "incremental compute must preserve cardinality");
|
|
33
|
-
const n = f(
|
|
34
|
-
for (let
|
|
35
|
-
if (
|
|
33
|
+
const n = f(i, t, "output");
|
|
34
|
+
for (let r = 0; r < o.length; r++)
|
|
35
|
+
if (o[r] !== n[r])
|
|
36
36
|
throw a(e, "incremental compute must preserve key order");
|
|
37
37
|
}
|
|
38
|
-
function b(e, t,
|
|
39
|
-
if (!Array.isArray(
|
|
38
|
+
function b(e, t, o, i) {
|
|
39
|
+
if (!Array.isArray(o) || !Array.isArray(i))
|
|
40
40
|
throw y(e, "requires array source and output");
|
|
41
41
|
d(
|
|
42
42
|
e,
|
|
43
43
|
"output must be an ordered subset of source",
|
|
44
|
-
f(
|
|
45
|
-
f(
|
|
44
|
+
f(o, t, "source"),
|
|
45
|
+
f(i, t, "output")
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
|
-
function x(e, t,
|
|
49
|
-
if (!Array.isArray(
|
|
48
|
+
function x(e, t, o, i) {
|
|
49
|
+
if (!Array.isArray(i))
|
|
50
50
|
throw y(e, "incremental compute must return an array");
|
|
51
51
|
d(
|
|
52
52
|
e,
|
|
53
53
|
"incremental output must be an ordered subset of input",
|
|
54
|
-
|
|
55
|
-
f(
|
|
54
|
+
o,
|
|
55
|
+
f(i, t, "output")
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
|
-
function f(e, t,
|
|
59
|
-
const
|
|
60
|
-
for (let
|
|
61
|
-
if (!(
|
|
58
|
+
function f(e, t, o) {
|
|
59
|
+
const i = /* @__PURE__ */ new Set(), n = [];
|
|
60
|
+
for (let r = 0; r < e.length; r++) {
|
|
61
|
+
if (!(r in e)) {
|
|
62
62
|
n.push(void 0);
|
|
63
63
|
continue;
|
|
64
64
|
}
|
|
65
|
-
const s = e[
|
|
65
|
+
const s = e[r];
|
|
66
66
|
if (!l(s))
|
|
67
|
-
throw new TypeError(`[Raph] ${
|
|
67
|
+
throw new TypeError(`[Raph] ${o} collection items must be objects.`);
|
|
68
68
|
const c = s[t];
|
|
69
69
|
if (typeof c != "string" && typeof c != "number")
|
|
70
|
-
throw new TypeError(`[Raph] ${
|
|
71
|
-
if (
|
|
72
|
-
throw new TypeError(`[Raph] Duplicate ${
|
|
73
|
-
|
|
70
|
+
throw new TypeError(`[Raph] ${o} item key "${t}" must be a string or number.`);
|
|
71
|
+
if (i.has(c))
|
|
72
|
+
throw new TypeError(`[Raph] Duplicate ${o} key: "${String(c)}".`);
|
|
73
|
+
i.add(c), n.push(c);
|
|
74
74
|
}
|
|
75
75
|
return n;
|
|
76
76
|
}
|
|
77
|
-
function $(e, t,
|
|
78
|
-
const
|
|
79
|
-
for (let
|
|
80
|
-
const s = r
|
|
81
|
-
s !== void 0 && n.set(s,
|
|
77
|
+
function $(e, t, o) {
|
|
78
|
+
const i = f(e, t, o), n = /* @__PURE__ */ new Map();
|
|
79
|
+
for (let r = 0; r < i.length; r++) {
|
|
80
|
+
const s = i[r];
|
|
81
|
+
s !== void 0 && n.set(s, r);
|
|
82
82
|
}
|
|
83
83
|
return n;
|
|
84
84
|
}
|
|
85
|
-
function E(e, t,
|
|
86
|
-
for (const n of
|
|
87
|
-
const
|
|
88
|
-
if (
|
|
85
|
+
function E(e, t, o, i) {
|
|
86
|
+
for (const n of i) {
|
|
87
|
+
const r = o.get(n);
|
|
88
|
+
if (r === void 0)
|
|
89
89
|
return !0;
|
|
90
|
-
const s = e[
|
|
90
|
+
const s = e[r];
|
|
91
91
|
if (!l(s) || s[t] !== n)
|
|
92
92
|
return !0;
|
|
93
93
|
}
|
|
@@ -102,28 +102,28 @@ function y(e, t) {
|
|
|
102
102
|
function R(e) {
|
|
103
103
|
return u(e, /* @__PURE__ */ new WeakMap());
|
|
104
104
|
}
|
|
105
|
-
function d(e, t,
|
|
105
|
+
function d(e, t, o, i) {
|
|
106
106
|
const n = /* @__PURE__ */ new Map();
|
|
107
|
-
for (let s = 0; s <
|
|
108
|
-
const c =
|
|
107
|
+
for (let s = 0; s < o.length; s++) {
|
|
108
|
+
const c = o[s];
|
|
109
109
|
c !== void 0 && n.set(c, s);
|
|
110
110
|
}
|
|
111
|
-
let
|
|
112
|
-
for (const s of
|
|
111
|
+
let r = -1;
|
|
112
|
+
for (const s of i) {
|
|
113
113
|
if (s === void 0)
|
|
114
114
|
continue;
|
|
115
115
|
const c = n.get(s);
|
|
116
|
-
if (c === void 0 || c <=
|
|
116
|
+
if (c === void 0 || c <= r)
|
|
117
117
|
throw y(e, t);
|
|
118
|
-
|
|
118
|
+
r = c;
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
function u(e, t) {
|
|
122
122
|
if (e === null || typeof e != "object")
|
|
123
123
|
return e;
|
|
124
|
-
const
|
|
125
|
-
if (
|
|
126
|
-
return
|
|
124
|
+
const o = t.get(e);
|
|
125
|
+
if (o !== void 0)
|
|
126
|
+
return o;
|
|
127
127
|
if (e instanceof Date)
|
|
128
128
|
return new Date(e.getTime());
|
|
129
129
|
if (e instanceof RegExp)
|
|
@@ -131,15 +131,15 @@ function u(e, t) {
|
|
|
131
131
|
if (e instanceof Map) {
|
|
132
132
|
const n = /* @__PURE__ */ new Map();
|
|
133
133
|
t.set(e, n);
|
|
134
|
-
for (const [
|
|
135
|
-
n.set(u(
|
|
134
|
+
for (const [r, s] of e)
|
|
135
|
+
n.set(u(r, t), u(s, t));
|
|
136
136
|
return n;
|
|
137
137
|
}
|
|
138
138
|
if (e instanceof Set) {
|
|
139
139
|
const n = /* @__PURE__ */ new Set();
|
|
140
140
|
t.set(e, n);
|
|
141
|
-
for (const
|
|
142
|
-
n.add(u(
|
|
141
|
+
for (const r of e)
|
|
142
|
+
n.add(u(r, t));
|
|
143
143
|
return n;
|
|
144
144
|
}
|
|
145
145
|
if (e instanceof ArrayBuffer || ArrayBuffer.isView(e))
|
|
@@ -147,15 +147,15 @@ function u(e, t) {
|
|
|
147
147
|
if (Array.isArray(e)) {
|
|
148
148
|
const n = [];
|
|
149
149
|
t.set(e, n);
|
|
150
|
-
for (let
|
|
151
|
-
|
|
150
|
+
for (let r = 0; r < e.length; r++)
|
|
151
|
+
r in e && (n[r] = u(e[r], t));
|
|
152
152
|
return n;
|
|
153
153
|
}
|
|
154
|
-
const
|
|
155
|
-
t.set(e,
|
|
154
|
+
const i = Object.create(Object.getPrototypeOf(e));
|
|
155
|
+
t.set(e, i);
|
|
156
156
|
for (const n of Reflect.ownKeys(e))
|
|
157
|
-
|
|
158
|
-
return
|
|
157
|
+
i[n] = u(e[n], t);
|
|
158
|
+
return i;
|
|
159
159
|
}
|
|
160
160
|
function m(e, t) {
|
|
161
161
|
return e.kind !== t.kind ? !1 : e.kind === "key" && t.kind === "key" ? e.key === t.key : e.kind === "index" && t.kind === "index" ? e.index === t.index : e.kind === "selector" && t.kind === "selector" && e.key === t.key && Object.is(e.value, t.value);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../DataPath.cjs"),_=require("../PathRouter.cjs"),p=require("./RaphMeta.cjs"),f=require("./RaphMetaStore.cjs");class v{constructor(e,t,r){this._kernel=e,this._ownerExists=t,this._publicationDeferred=r}_facade;_store;_router;_pending;_publishing=!1;_watcherCount=0;_deferredWatcherCount=0;get facade(){return this._facade??=new p.RaphMeta(this._kernel)}get size(){return this._store?.size??0}get hasWatchers(){return this._router!==void 0}get hasDeferredWatchers(){return this._deferredWatcherCount!==0}get(e,t){return this._store?.get(e,t)}has(e,t){return this._store?.has(e,t)??!1}set(e,t,r,s){(this._store??=new f.RaphMetaStore).set(e,t,r),this.record("set",e,t,"explicit",s)}merge(e,t,r,s){(this._store??=new f.RaphMetaStore).merge(e,t,r),this.record("merge",e,t,"explicit",s)}delete(e,t,r){return this._store?.delete(e,t)?(this.record("delete",e,t??null,"explicit",r),!0):!1}deleteSubtree(e,t){const r=this._store;if(r!==void 0)for(const s of r.deleteSubtree(e))this.record("delete",s,null,t)}pruneMissing(e,t){const r=this._store;if(r===void 0||r.size===0)return;const n=e.segments().findIndex(i=>i.kind==="index"||i.kind==="selector"),c=n===-1?e:u.DataPath.fromPlain({segs:e.toPlain().segs.slice(0,n)});for(const i of r.pruneMissing(c,o=>this._ownerExists(o)))this.record("delete",i,null,t)}watch(e,t,r={},s){const n=Array.isArray(e)?e:[e];if(n.length===0)throw new TypeError("[RaphMeta] watch requires at least one mask.");const c=new Map;for(const a of n){const l=u.DataPath.from(a,r)._asMask();c.set(l.canonical,l)}const i={active:!0,callback:t,afterPublish:s,...r.namespace===void 0?{}:{namespace:r.namespace}},o=this._router??=new _.PathRouter,h=[...c.values()].map(a=>o.add(a,i));return this._watcherCount++,s!==void 0&&this._deferredWatcherCount++,g(()=>{i.active=!1,i.callback=void 0,i.afterPublish=void 0;for(const a of h)a();this._watcherCount--,s!==void 0&&this._deferredWatcherCount--,this._watcherCount===0&&(this._router=void 0)})}record(e,t,r,s,n){(this._pending??=[]).push({event:{kind:e,path:t,namespace:r,cause:s},invalidate:n?.invalidate??!0}),!this._publicationDeferred()&&!this._publishing&&this.publish()}publish(){const e=this._pending;if(e===void 0||e.length===0||this._publishing)return;const t=[],r=new Map;this._publishing=!0;try{for(;e.length!==0;){const s=e.splice(0),n=this._router;if(n===void 0)continue;const c=new Map;for(const i of s){const o=i.event;for(const h of n.match(o.path._asExact().segments)){if(h.namespace!==void 0&&o.namespace!==null&&h.namespace!==o.namespace)continue;const a=c.get(h);a===void 0?c.set(h,{events:[o],invalidate:i.invalidate}):(a.events.push(o),i.invalidate&&(a.invalidate=!0))}}for(const[i,o]of c){if(!i.active||i.callback===void 0)continue;const h=i.afterPublish;h!==void 0&&r.set(h,(r.get(h)??!1)||o.invalidate);try{i.callback({events:o.events})}catch(a){t.push(a)}}}}finally{this._publishing=!1}for(const[s,n]of r)try{s(n)}catch(c){t.push(c)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"[RaphMeta] Multiple watchers failed.")}dispose(){this._store?.clear(),this._store=void 0,this._facade=void 0,this._router=void 0,this._pending=void 0,this._watcherCount=0,this._deferredWatcherCount=0}}function g(d){let e=d;return()=>{const t=e;e=void 0,t?.()}}exports.MetaController=v;
|