@raphy-js/raph 1.0.1-dev.20 → 1.0.1-dev.26
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/dist/{core-CyilRD7s.js → core-CClhT8WR.js} +389 -400
- package/dist/core-cPQWYD4K.cjs +1 -0
- package/dist/debug/api/Raph.cjs +1 -1
- package/dist/debug/api/Raph.js +46 -47
- package/dist/debug/api/RaphFacadeSession.cjs +1 -1
- package/dist/debug/api/RaphFacadeSession.js +85 -89
- package/dist/debug/api/RaphReactivityInstance.cjs +1 -1
- package/dist/debug/api/RaphReactivityInstance.js +27 -30
- package/dist/debug/path/DataPath.cjs +1 -1
- package/dist/debug/path/DataPath.js +198 -202
- package/dist/debug/path/PathRouter.cjs +1 -1
- package/dist/debug/path/PathRouter.js +44 -50
- package/dist/debug/path/RaphKernel.cjs +1 -1
- package/dist/debug/path/RaphKernel.js +257 -228
- package/dist/debug/path/data-path.utils.cjs +1 -1
- package/dist/debug/path/data-path.utils.js +41 -41
- package/dist/debug/path/derived/DerivedRegistry.cjs +1 -1
- package/dist/debug/path/derived/DerivedRegistry.js +52 -66
- package/dist/debug/path/derived/RaphDerivedHandle.cjs +1 -1
- package/dist/debug/path/derived/RaphDerivedHandle.js +19 -22
- package/dist/debug/path/derived/derived-collection.utils.cjs +1 -1
- package/dist/debug/path/derived/derived-collection.utils.js +70 -70
- package/dist/debug/path/meta/MetaController.cjs +1 -1
- package/dist/debug/path/meta/MetaController.js +57 -65
- package/dist/debug/path/meta/RaphMeta.cjs +1 -1
- package/dist/debug/path/meta/RaphMeta.js +26 -32
- package/dist/debug/path/meta/RaphMetaStore.cjs +1 -1
- package/dist/debug/path/meta/RaphMetaStore.js +24 -30
- package/dist/debug/path/storage/AdapterPathStore.cjs +1 -1
- package/dist/debug/path/storage/AdapterPathStore.js +49 -54
- package/dist/debug/path/storage/DefaultDataAdapter.cjs +1 -1
- package/dist/debug/path/storage/DefaultDataAdapter.js +46 -56
- package/dist/debug/path/storage/PathEventHub.cjs +1 -1
- package/dist/debug/path/storage/PathEventHub.js +74 -61
- package/dist/debug/path/storage/PathStore.cjs +1 -1
- package/dist/debug/path/storage/PathStore.js +89 -99
- package/dist/debug/path/storage/createDataDraft.cjs +1 -1
- package/dist/debug/path/storage/createDataDraft.js +24 -28
- 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 +787 -392
- package/dist/debug/reactivity/reactive-object.cjs +1 -1
- package/dist/debug/reactivity/reactive-object.js +81 -96
- 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 +764 -411
- package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -1
- package/dist/debug/runtime/diagnostics/RaphDebug.js +90 -100
- package/dist/debug/runtime/ownership/RaphEffectScope.cjs +1 -1
- package/dist/debug/runtime/ownership/RaphEffectScope.js +215 -82
- package/dist/debug/runtime/ownership/RaphNode.cjs +1 -1
- package/dist/debug/runtime/ownership/RaphNode.js +595 -136
- package/dist/debug/runtime/ownership/RaphScope.cjs +1 -1
- package/dist/debug/runtime/ownership/RaphScope.js +203 -68
- package/dist/debug/runtime/phases/RaphFrameLoop.cjs +1 -1
- package/dist/debug/runtime/phases/RaphFrameLoop.js +13 -17
- package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -1
- package/dist/debug/runtime/phases/RaphPhasePipeline.js +618 -357
- 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/reactivity/PathHandle.cjs +1 -1
- package/dist/debug/runtime/reactivity/PathHandle.js +50 -60
- package/dist/debug/runtime/reactivity/RaphMetaSource.cjs +1 -1
- package/dist/debug/runtime/reactivity/RaphMetaSource.js +28 -32
- 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 -1
- package/dist/debug/runtime/reactivity/RaphWorkGraph.js +541 -379
- package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -1
- package/dist/debug/runtime/reactivity/RuntimeReactivity.js +484 -90
- package/dist/debug/runtime/reactivity/RuntimeWatch.cjs +1 -1
- package/dist/debug/runtime/reactivity/RuntimeWatch.js +33 -44
- package/dist/debug/runtime/reactivity/disposal-sweep.utils.cjs +1 -0
- package/dist/debug/runtime/reactivity/disposal-sweep.utils.js +42 -0
- package/dist/entrypoints/runtime.d.ts +2 -1
- package/dist/machine-testing.cjs +1 -1
- package/dist/machine-testing.js +1 -1
- package/dist/machine.cjs +1 -1
- package/dist/machine.js +216 -231
- package/dist/path/RaphKernel.d.ts +24 -0
- package/dist/path/storage/PathEventHub.d.ts +14 -0
- package/dist/path/storage/PathStore.d.ts +4 -4
- package/dist/reactivity/disposal.d.ts +14 -0
- package/dist/reactivity/engine.d.ts +177 -4
- package/dist/reactivity/scope.d.ts +108 -30
- package/dist/runtime/RaphRuntime.d.ts +236 -17
- package/dist/runtime/ownership/RaphEffectScope.d.ts +70 -1
- package/dist/runtime/ownership/RaphNode.d.ts +276 -6
- package/dist/runtime/ownership/RaphScope.d.ts +144 -14
- package/dist/runtime/phases/RaphPhasePipeline.d.ts +202 -28
- package/dist/runtime/phases/RaphPhaseTaskRecord.d.ts +195 -0
- package/dist/runtime/phases/RaphPhaseWatch.d.ts +22 -0
- package/dist/runtime/phases/phase.types.d.ts +83 -4
- package/dist/runtime/reactivity/RaphSelector.d.ts +338 -0
- package/dist/runtime/reactivity/RaphWorkGraph.d.ts +163 -25
- package/dist/runtime/reactivity/RuntimeReactivity.d.ts +258 -10
- package/dist/runtime/reactivity/RuntimeWatch.d.ts +8 -8
- package/dist/runtime/reactivity/disposal-sweep.utils.d.ts +19 -0
- package/dist/runtime/reactivity/runtime-reactivity.types.d.ts +48 -3
- package/package.json +10 -2
- package/dist/core-ugchZNqC.cjs +0 -1
|
@@ -1,93 +1,93 @@
|
|
|
1
1
|
import { parseDataPath as p } from "../data-path.utils.js";
|
|
2
|
-
function g(e, t,
|
|
3
|
-
if (
|
|
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);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
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;
|
|
@@ -1,38 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { RaphMeta as m } from "./RaphMeta.js";
|
|
7
|
-
import { RaphMetaStore as _ } from "./RaphMetaStore.js";
|
|
8
|
-
class k {
|
|
1
|
+
import { DataPath as u } from "../DataPath.js";
|
|
2
|
+
import { PathRouter as _ } from "../PathRouter.js";
|
|
3
|
+
import { RaphMeta as v } from "./RaphMeta.js";
|
|
4
|
+
import { RaphMetaStore as f } from "./RaphMetaStore.js";
|
|
5
|
+
class C {
|
|
9
6
|
/**
|
|
10
7
|
* Создаёт lifecycle-контроллер metadata для одного Kernel.
|
|
11
8
|
*/
|
|
12
9
|
constructor(e, t, r) {
|
|
13
|
-
// Лениво создают metadata facade, storage и routing только при первом использовании.
|
|
14
|
-
l(this, "_facade");
|
|
15
|
-
l(this, "_store");
|
|
16
|
-
l(this, "_router");
|
|
17
|
-
l(this, "_pending");
|
|
18
|
-
// Управляют reentrant publication и режимами активных watchers.
|
|
19
|
-
l(this, "_publishing", !1);
|
|
20
|
-
l(this, "_watcherCount", 0);
|
|
21
|
-
l(this, "_deferredWatcherCount", 0);
|
|
22
10
|
this._kernel = e, this._ownerExists = t, this._publicationDeferred = r;
|
|
23
11
|
}
|
|
12
|
+
// Лениво создают metadata facade, storage и routing только при первом использовании.
|
|
13
|
+
_facade;
|
|
14
|
+
_store;
|
|
15
|
+
_router;
|
|
16
|
+
_pending;
|
|
17
|
+
// Управляют reentrant publication и режимами активных watchers.
|
|
18
|
+
_publishing = !1;
|
|
19
|
+
_watcherCount = 0;
|
|
20
|
+
_deferredWatcherCount = 0;
|
|
24
21
|
/**
|
|
25
22
|
* Возвращает metadata facade, принадлежащий контроллеру.
|
|
26
23
|
*/
|
|
27
24
|
get facade() {
|
|
28
|
-
return this._facade
|
|
25
|
+
return this._facade ??= new v(this._kernel);
|
|
29
26
|
}
|
|
30
27
|
/**
|
|
31
28
|
* Возвращает число зарегистрированных записей.
|
|
32
29
|
*/
|
|
33
30
|
get size() {
|
|
34
|
-
|
|
35
|
-
return ((e = this._store) == null ? void 0 : e.size) ?? 0;
|
|
31
|
+
return this._store?.size ?? 0;
|
|
36
32
|
}
|
|
37
33
|
/**
|
|
38
34
|
* Показывает, есть ли активные синхронные metadata/path watchers.
|
|
@@ -50,34 +46,31 @@ class k {
|
|
|
50
46
|
* Возвращает значение по пути без создания отсутствующих данных.
|
|
51
47
|
*/
|
|
52
48
|
get(e, t) {
|
|
53
|
-
|
|
54
|
-
return (r = this._store) == null ? void 0 : r.get(e, t);
|
|
49
|
+
return this._store?.get(e, t);
|
|
55
50
|
}
|
|
56
51
|
/**
|
|
57
52
|
* Проверяет наличие значения по указанному пути.
|
|
58
53
|
*/
|
|
59
54
|
has(e, t) {
|
|
60
|
-
|
|
61
|
-
return ((r = this._store) == null ? void 0 : r.has(e, t)) ?? !1;
|
|
55
|
+
return this._store?.has(e, t) ?? !1;
|
|
62
56
|
}
|
|
63
57
|
/**
|
|
64
58
|
* Записывает значение и публикует соответствующее изменение.
|
|
65
59
|
*/
|
|
66
|
-
set(e, t, r,
|
|
67
|
-
(this._store
|
|
60
|
+
set(e, t, r, s) {
|
|
61
|
+
(this._store ??= new f()).set(e, t, r), this.record("set", e, t, "explicit", s);
|
|
68
62
|
}
|
|
69
63
|
/**
|
|
70
64
|
* Объединяет значение по пути и публикует соответствующее изменение.
|
|
71
65
|
*/
|
|
72
|
-
merge(e, t, r,
|
|
73
|
-
(this._store
|
|
66
|
+
merge(e, t, r, s) {
|
|
67
|
+
(this._store ??= new f()).merge(e, t, r), this.record("merge", e, t, "explicit", s);
|
|
74
68
|
}
|
|
75
69
|
/**
|
|
76
70
|
* Удаляет значение по пути и публикует изменение при наличии данных.
|
|
77
71
|
*/
|
|
78
72
|
delete(e, t, r) {
|
|
79
|
-
|
|
80
|
-
return (i = this._store) != null && i.delete(e, t) ? (this.record("delete", e, t ?? null, "explicit", r), !0) : !1;
|
|
73
|
+
return this._store?.delete(e, t) ? (this.record("delete", e, t ?? null, "explicit", r), !0) : !1;
|
|
81
74
|
}
|
|
82
75
|
/**
|
|
83
76
|
* Удаляет metadata всего поддерева указанного data-owner.
|
|
@@ -85,8 +78,8 @@ class k {
|
|
|
85
78
|
deleteSubtree(e, t) {
|
|
86
79
|
const r = this._store;
|
|
87
80
|
if (r !== void 0)
|
|
88
|
-
for (const
|
|
89
|
-
this.record("delete",
|
|
81
|
+
for (const s of r.deleteSubtree(e))
|
|
82
|
+
this.record("delete", s, null, t);
|
|
90
83
|
}
|
|
91
84
|
/**
|
|
92
85
|
* Удаляет metadata, владельцы которой отсутствуют в data tree.
|
|
@@ -96,46 +89,46 @@ class k {
|
|
|
96
89
|
if (r === void 0 || r.size === 0)
|
|
97
90
|
return;
|
|
98
91
|
const o = e.segments().findIndex(
|
|
99
|
-
(
|
|
100
|
-
), c = o === -1 ? e :
|
|
101
|
-
for (const
|
|
92
|
+
(i) => i.kind === "index" || i.kind === "selector"
|
|
93
|
+
), c = o === -1 ? e : u.fromPlain({ segs: e.toPlain().segs.slice(0, o) });
|
|
94
|
+
for (const i of r.pruneMissing(
|
|
102
95
|
c,
|
|
103
96
|
(n) => this._ownerExists(n)
|
|
104
97
|
))
|
|
105
|
-
this.record("delete",
|
|
98
|
+
this.record("delete", i, null, t);
|
|
106
99
|
}
|
|
107
100
|
/**
|
|
108
101
|
* Подписывает callback на подходящие изменения и возвращает disposer.
|
|
109
102
|
*/
|
|
110
|
-
watch(e, t, r = {},
|
|
103
|
+
watch(e, t, r = {}, s) {
|
|
111
104
|
const o = Array.isArray(e) ? e : [e];
|
|
112
105
|
if (o.length === 0)
|
|
113
106
|
throw new TypeError("[RaphMeta] watch requires at least one mask.");
|
|
114
107
|
const c = /* @__PURE__ */ new Map();
|
|
115
108
|
for (const a of o) {
|
|
116
|
-
const
|
|
117
|
-
c.set(
|
|
109
|
+
const l = u.from(a, r)._asMask();
|
|
110
|
+
c.set(l.canonical, l);
|
|
118
111
|
}
|
|
119
|
-
const
|
|
112
|
+
const i = {
|
|
120
113
|
active: !0,
|
|
121
114
|
callback: t,
|
|
122
|
-
afterPublish:
|
|
115
|
+
afterPublish: s,
|
|
123
116
|
...r.namespace === void 0 ? {} : { namespace: r.namespace }
|
|
124
|
-
}, n = this._router
|
|
125
|
-
return this._watcherCount++,
|
|
126
|
-
|
|
117
|
+
}, n = this._router ??= new _(), h = [...c.values()].map((a) => n.add(a, i));
|
|
118
|
+
return this._watcherCount++, s !== void 0 && this._deferredWatcherCount++, p(() => {
|
|
119
|
+
i.active = !1, i.callback = void 0, i.afterPublish = void 0;
|
|
127
120
|
for (const a of h)
|
|
128
121
|
a();
|
|
129
|
-
this._watcherCount--,
|
|
122
|
+
this._watcherCount--, s !== void 0 && this._deferredWatcherCount--, this._watcherCount === 0 && (this._router = void 0);
|
|
130
123
|
});
|
|
131
124
|
}
|
|
132
125
|
/**
|
|
133
126
|
* Добавляет событие в текущую batch либо публикует его сразу.
|
|
134
127
|
*/
|
|
135
|
-
record(e, t, r,
|
|
136
|
-
(this._pending
|
|
137
|
-
event: { kind: e, path: t, namespace: r, cause:
|
|
138
|
-
invalidate:
|
|
128
|
+
record(e, t, r, s, o) {
|
|
129
|
+
(this._pending ??= []).push({
|
|
130
|
+
event: { kind: e, path: t, namespace: r, cause: s },
|
|
131
|
+
invalidate: o?.invalidate ?? !0
|
|
139
132
|
}), !this._publicationDeferred() && !this._publishing && this.publish();
|
|
140
133
|
}
|
|
141
134
|
/**
|
|
@@ -149,32 +142,32 @@ class k {
|
|
|
149
142
|
this._publishing = !0;
|
|
150
143
|
try {
|
|
151
144
|
for (; e.length !== 0; ) {
|
|
152
|
-
const
|
|
145
|
+
const s = e.splice(0), o = this._router;
|
|
153
146
|
if (o === void 0)
|
|
154
147
|
continue;
|
|
155
148
|
const c = /* @__PURE__ */ new Map();
|
|
156
|
-
for (const
|
|
157
|
-
const n =
|
|
149
|
+
for (const i of s) {
|
|
150
|
+
const n = i.event;
|
|
158
151
|
for (const h of o.match(n.path._asExact().segments)) {
|
|
159
152
|
if (h.namespace !== void 0 && n.namespace !== null && h.namespace !== n.namespace)
|
|
160
153
|
continue;
|
|
161
154
|
const a = c.get(h);
|
|
162
155
|
a === void 0 ? c.set(h, {
|
|
163
156
|
events: [n],
|
|
164
|
-
invalidate:
|
|
165
|
-
}) : (a.events.push(n),
|
|
157
|
+
invalidate: i.invalidate
|
|
158
|
+
}) : (a.events.push(n), i.invalidate && (a.invalidate = !0));
|
|
166
159
|
}
|
|
167
160
|
}
|
|
168
|
-
for (const [
|
|
169
|
-
if (!
|
|
161
|
+
for (const [i, n] of c) {
|
|
162
|
+
if (!i.active || i.callback === void 0)
|
|
170
163
|
continue;
|
|
171
|
-
const h =
|
|
164
|
+
const h = i.afterPublish;
|
|
172
165
|
h !== void 0 && r.set(
|
|
173
166
|
h,
|
|
174
167
|
(r.get(h) ?? !1) || n.invalidate
|
|
175
168
|
);
|
|
176
169
|
try {
|
|
177
|
-
|
|
170
|
+
i.callback({ events: n.events });
|
|
178
171
|
} catch (a) {
|
|
179
172
|
t.push(a);
|
|
180
173
|
}
|
|
@@ -183,9 +176,9 @@ class k {
|
|
|
183
176
|
} finally {
|
|
184
177
|
this._publishing = !1;
|
|
185
178
|
}
|
|
186
|
-
for (const [
|
|
179
|
+
for (const [s, o] of r)
|
|
187
180
|
try {
|
|
188
|
-
|
|
181
|
+
s(o);
|
|
189
182
|
} catch (c) {
|
|
190
183
|
t.push(c);
|
|
191
184
|
}
|
|
@@ -198,17 +191,16 @@ class k {
|
|
|
198
191
|
* Очищает metadata storage, subscriptions и pending publication state.
|
|
199
192
|
*/
|
|
200
193
|
dispose() {
|
|
201
|
-
|
|
202
|
-
(e = this._store) == null || e.clear(), this._store = void 0, this._facade = void 0, this._router = void 0, this._pending = void 0, this._watcherCount = 0, this._deferredWatcherCount = 0;
|
|
194
|
+
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;
|
|
203
195
|
}
|
|
204
196
|
}
|
|
205
|
-
function
|
|
197
|
+
function p(d) {
|
|
206
198
|
let e = d;
|
|
207
199
|
return () => {
|
|
208
200
|
const t = e;
|
|
209
|
-
e = void 0, t
|
|
201
|
+
e = void 0, t?.();
|
|
210
202
|
};
|
|
211
203
|
}
|
|
212
204
|
export {
|
|
213
|
-
|
|
205
|
+
C as MetaController
|
|
214
206
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class a{constructor(e,t={}){this._kernel=e,this._binding=t}get(e,t,i){return this._binding.assertReadable?.(),this._kernel.getMeta(e,t,i)}has(e,t,i){return this._binding.assertReadable?.(),this._kernel.hasMeta(e,t,i)}set(e,t,i,r){this._binding.assertWritable?.(),this._write(()=>this._kernel.setMeta(e,t,i,r),r?.invalidate??!0)}merge(e,t,i,r){this._binding.assertWritable?.(),this._write(()=>this._kernel.mergeMeta(e,t,i,r),r?.invalidate??!0)}delete(e,t,i){this._binding.assertWritable?.(),this._write(()=>this._kernel.deleteMeta(e,t,i),i?.invalidate??!0)}watch(e,t,i={}){if(this._binding.assertReadable?.(),this._binding.watch===void 0)throw new Error("[RaphMeta] watch requires a runtime-bound Meta facade.");return this._binding.watch(e,t,i)}_write(e,t){const i=this._binding.runWrite;i===void 0?e():i(e,t)}}exports.RaphMeta=a;
|
|
@@ -1,68 +1,62 @@
|
|
|
1
|
-
class
|
|
1
|
+
class s {
|
|
2
2
|
/**
|
|
3
3
|
* Создаёт metadata facade поверх указанного Kernel.
|
|
4
4
|
*/
|
|
5
|
-
constructor(
|
|
6
|
-
this._kernel =
|
|
5
|
+
constructor(e, t = {}) {
|
|
6
|
+
this._kernel = e, this._binding = t;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Возвращает значение по пути без создания отсутствующих данных.
|
|
10
10
|
*/
|
|
11
|
-
get(
|
|
12
|
-
|
|
13
|
-
return (i = (e = this._binding).assertReadable) == null || i.call(e), this._kernel.getMeta(r, a, t);
|
|
11
|
+
get(e, t, i) {
|
|
12
|
+
return this._binding.assertReadable?.(), this._kernel.getMeta(e, t, i);
|
|
14
13
|
}
|
|
15
14
|
/**
|
|
16
15
|
* Проверяет наличие значения по указанному пути.
|
|
17
16
|
*/
|
|
18
|
-
has(
|
|
19
|
-
|
|
20
|
-
return (i = (e = this._binding).assertReadable) == null || i.call(e), this._kernel.hasMeta(r, a, t);
|
|
17
|
+
has(e, t, i) {
|
|
18
|
+
return this._binding.assertReadable?.(), this._kernel.hasMeta(e, t, i);
|
|
21
19
|
}
|
|
22
20
|
/**
|
|
23
21
|
* Записывает значение и публикует соответствующее изменение.
|
|
24
22
|
*/
|
|
25
|
-
set(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
(e == null ? void 0 : e.invalidate) ?? !0
|
|
23
|
+
set(e, t, i, r) {
|
|
24
|
+
this._binding.assertWritable?.(), this._write(
|
|
25
|
+
() => this._kernel.setMeta(e, t, i, r),
|
|
26
|
+
r?.invalidate ?? !0
|
|
30
27
|
);
|
|
31
28
|
}
|
|
32
29
|
/**
|
|
33
30
|
* Объединяет значение по пути и публикует соответствующее изменение.
|
|
34
31
|
*/
|
|
35
|
-
merge(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
(e == null ? void 0 : e.invalidate) ?? !0
|
|
32
|
+
merge(e, t, i, r) {
|
|
33
|
+
this._binding.assertWritable?.(), this._write(
|
|
34
|
+
() => this._kernel.mergeMeta(e, t, i, r),
|
|
35
|
+
r?.invalidate ?? !0
|
|
40
36
|
);
|
|
41
37
|
}
|
|
42
38
|
/**
|
|
43
39
|
* Удаляет значение по пути и публикует изменение при наличии данных.
|
|
44
40
|
*/
|
|
45
|
-
delete(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
(t == null ? void 0 : t.invalidate) ?? !0
|
|
41
|
+
delete(e, t, i) {
|
|
42
|
+
this._binding.assertWritable?.(), this._write(
|
|
43
|
+
() => this._kernel.deleteMeta(e, t, i),
|
|
44
|
+
i?.invalidate ?? !0
|
|
50
45
|
);
|
|
51
46
|
}
|
|
52
47
|
/**
|
|
53
48
|
* Подписывает callback на metadata-изменения и возвращает disposer.
|
|
54
49
|
*/
|
|
55
|
-
watch(
|
|
56
|
-
|
|
57
|
-
if ((i = (e = this._binding).assertReadable) == null || i.call(e), this._binding.watch === void 0)
|
|
50
|
+
watch(e, t, i = {}) {
|
|
51
|
+
if (this._binding.assertReadable?.(), this._binding.watch === void 0)
|
|
58
52
|
throw new Error("[RaphMeta] watch requires a runtime-bound Meta facade.");
|
|
59
|
-
return this._binding.watch(
|
|
53
|
+
return this._binding.watch(e, t, i);
|
|
60
54
|
}
|
|
61
|
-
_write(
|
|
62
|
-
const
|
|
63
|
-
|
|
55
|
+
_write(e, t) {
|
|
56
|
+
const i = this._binding.runWrite;
|
|
57
|
+
i === void 0 ? e() : i(e, t);
|
|
64
58
|
}
|
|
65
59
|
}
|
|
66
60
|
export {
|
|
67
|
-
|
|
61
|
+
s as RaphMeta
|
|
68
62
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../pathSegmentKey.cjs");function u(){return{children:new Map,namespaces:new Map,path:void 0}}class p{_root=u();size=0;get(e,t){const r=this._find(e);if(r!==void 0)return t===void 0?Object.fromEntries(r.namespaces):r.namespaces.get(t)}has(e,t){const r=this._find(e);return r===void 0?!1:t===void 0?r.namespaces.size!==0:r.namespaces.has(t)}set(e,t,r){const s=this._ensure(e);s.namespaces.has(t)||this.size++,s.namespaces.set(t,r),s.path=e}merge(e,t,r){const s=this.get(e,t);if(d(s)&&d(r)){for(const i of Object.keys(r))_(s,i,r[i]);return}this.set(e,t,r)}delete(e,t){const r=this._findStack(e),s=r.at(-1)?.node;if(s===void 0)return!1;if(t===void 0){if(s.namespaces.size===0)return!1;this.size-=s.namespaces.size,s.namespaces.clear()}else{if(!s.namespaces.delete(t))return!1;this.size--}return this._pruneEmpty(r),!0}deleteSubtree(e){const t=o(e);if(t.length===0)return this.clear();let r=this._root;for(let c=0;c<t.length-1;c++){const h=r.children.get(t[c]);if(h===void 0)return[];r=h}const s=r.children.get(t.at(-1));if(s===void 0)return[];const i=a(s);return this.size-=l(s),r.children.delete(t.at(-1)),i}pruneMissing(e,t){const r=this._find(e);if(r===void 0)return[];const s=[];return this._pruneMissingNode(r,t,s),s}clear(){const e=a(this._root);return this._root.children.clear(),this._root.namespaces.clear(),this._root.path=void 0,this.size=0,e}_find(e){let t=this._root;for(const r of o(e)){const s=t.children.get(r);if(s===void 0)return;t=s}return t}_ensure(e){let t=this._root;for(const r of o(e)){let s=t.children.get(r);s===void 0&&(s=u(),t.children.set(r,s)),t=s}return t}_findStack(e){const t=[{key:void 0,node:this._root}];let r=this._root;for(const s of o(e)){const i=r.children.get(s);if(i===void 0)return[];t.push({key:s,node:i}),r=i}return t}_pruneEmpty(e){for(let t=e.length-1;t>0;t--){const r=e[t];if(r.node.namespaces.size!==0||r.node.children.size!==0)return;e[t-1].node.children.delete(r.key)}}_pruneMissingNode(e,t,r){for(const[s,i]of[...e.children])this._pruneMissingNode(i,t,r)&&e.children.delete(s);return e.path!==void 0&&e.namespaces.size!==0&&!t(e.path)&&(this.size-=e.namespaces.size,e.namespaces.clear(),r.push(e.path)),e!==this._root&&e.namespaces.size===0&&e.children.size===0}}function o(n){return n.segments().map(f.pathSegmentKey)}function a(n){const e=n.path!==void 0&&n.namespaces.size!==0?[n.path]:[];for(const t of n.children.values())e.push(...a(t));return e}function l(n){let e=n.namespaces.size;for(const t of n.children.values())e+=l(t);return e}function d(n){if(typeof n!="object"||n===null||Array.isArray(n))return!1;const e=Object.getPrototypeOf(n);return e===Object.prototype||e===null}function _(n,e,t){if(e!=="__proto__"){n[e]=t;return}Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:t,writable:!0})}exports.RaphMetaStore=p;
|