@raphy-js/raph 1.0.1-dev.20 → 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.
Files changed (107) hide show
  1. package/dist/{core-CyilRD7s.js → core-CClhT8WR.js} +389 -400
  2. package/dist/core-cPQWYD4K.cjs +1 -0
  3. package/dist/debug/api/Raph.cjs +1 -1
  4. package/dist/debug/api/Raph.js +46 -47
  5. package/dist/debug/api/RaphFacadeSession.cjs +1 -1
  6. package/dist/debug/api/RaphFacadeSession.js +85 -89
  7. package/dist/debug/api/RaphReactivityInstance.cjs +1 -1
  8. package/dist/debug/api/RaphReactivityInstance.js +27 -30
  9. package/dist/debug/path/DataPath.cjs +1 -1
  10. package/dist/debug/path/DataPath.js +198 -202
  11. package/dist/debug/path/PathRouter.cjs +1 -1
  12. package/dist/debug/path/PathRouter.js +44 -50
  13. package/dist/debug/path/RaphKernel.cjs +1 -1
  14. package/dist/debug/path/RaphKernel.js +257 -228
  15. package/dist/debug/path/data-path.utils.cjs +1 -1
  16. package/dist/debug/path/data-path.utils.js +41 -41
  17. package/dist/debug/path/derived/DerivedRegistry.cjs +1 -1
  18. package/dist/debug/path/derived/DerivedRegistry.js +52 -66
  19. package/dist/debug/path/derived/RaphDerivedHandle.cjs +1 -1
  20. package/dist/debug/path/derived/RaphDerivedHandle.js +19 -22
  21. package/dist/debug/path/derived/derived-collection.utils.cjs +1 -1
  22. package/dist/debug/path/derived/derived-collection.utils.js +70 -70
  23. package/dist/debug/path/meta/MetaController.cjs +1 -1
  24. package/dist/debug/path/meta/MetaController.js +57 -65
  25. package/dist/debug/path/meta/RaphMeta.cjs +1 -1
  26. package/dist/debug/path/meta/RaphMeta.js +26 -32
  27. package/dist/debug/path/meta/RaphMetaStore.cjs +1 -1
  28. package/dist/debug/path/meta/RaphMetaStore.js +24 -30
  29. package/dist/debug/path/storage/AdapterPathStore.cjs +1 -1
  30. package/dist/debug/path/storage/AdapterPathStore.js +49 -54
  31. package/dist/debug/path/storage/DefaultDataAdapter.cjs +1 -1
  32. package/dist/debug/path/storage/DefaultDataAdapter.js +46 -56
  33. package/dist/debug/path/storage/PathEventHub.cjs +1 -1
  34. package/dist/debug/path/storage/PathEventHub.js +74 -61
  35. package/dist/debug/path/storage/PathStore.cjs +1 -1
  36. package/dist/debug/path/storage/PathStore.js +89 -99
  37. package/dist/debug/path/storage/createDataDraft.cjs +1 -1
  38. package/dist/debug/path/storage/createDataDraft.js +24 -28
  39. package/dist/debug/reactivity/disposal.cjs +1 -0
  40. package/dist/debug/reactivity/disposal.js +32 -0
  41. package/dist/debug/reactivity/engine.cjs +1 -1
  42. package/dist/debug/reactivity/engine.js +787 -392
  43. package/dist/debug/reactivity/reactive-object.cjs +1 -1
  44. package/dist/debug/reactivity/reactive-object.js +81 -96
  45. package/dist/debug/reactivity/scope.cjs +1 -1
  46. package/dist/debug/reactivity/scope.js +221 -117
  47. package/dist/debug/reactivity/watch.cjs +1 -1
  48. package/dist/debug/reactivity/watch.js +1 -1
  49. package/dist/debug/runtime/RaphRuntime.cjs +1 -1
  50. package/dist/debug/runtime/RaphRuntime.js +764 -411
  51. package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -1
  52. package/dist/debug/runtime/diagnostics/RaphDebug.js +90 -100
  53. package/dist/debug/runtime/ownership/RaphEffectScope.cjs +1 -1
  54. package/dist/debug/runtime/ownership/RaphEffectScope.js +215 -82
  55. package/dist/debug/runtime/ownership/RaphNode.cjs +1 -1
  56. package/dist/debug/runtime/ownership/RaphNode.js +595 -136
  57. package/dist/debug/runtime/ownership/RaphScope.cjs +1 -1
  58. package/dist/debug/runtime/ownership/RaphScope.js +203 -68
  59. package/dist/debug/runtime/phases/RaphFrameLoop.cjs +1 -1
  60. package/dist/debug/runtime/phases/RaphFrameLoop.js +13 -17
  61. package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -1
  62. package/dist/debug/runtime/phases/RaphPhasePipeline.js +618 -357
  63. package/dist/debug/runtime/phases/RaphPhaseTaskRecord.cjs +1 -0
  64. package/dist/debug/runtime/phases/RaphPhaseTaskRecord.js +176 -0
  65. package/dist/debug/runtime/phases/RaphPhaseWatch.cjs +1 -0
  66. package/dist/debug/runtime/phases/RaphPhaseWatch.js +20 -0
  67. package/dist/debug/runtime/reactivity/PathHandle.cjs +1 -1
  68. package/dist/debug/runtime/reactivity/PathHandle.js +50 -60
  69. package/dist/debug/runtime/reactivity/RaphMetaSource.cjs +1 -1
  70. package/dist/debug/runtime/reactivity/RaphMetaSource.js +28 -32
  71. package/dist/debug/runtime/reactivity/RaphSelector.cjs +1 -0
  72. package/dist/debug/runtime/reactivity/RaphSelector.js +503 -0
  73. package/dist/debug/runtime/reactivity/RaphWorkGraph.cjs +1 -1
  74. package/dist/debug/runtime/reactivity/RaphWorkGraph.js +541 -379
  75. package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -1
  76. package/dist/debug/runtime/reactivity/RuntimeReactivity.js +484 -90
  77. package/dist/debug/runtime/reactivity/RuntimeWatch.cjs +1 -1
  78. package/dist/debug/runtime/reactivity/RuntimeWatch.js +33 -44
  79. package/dist/debug/runtime/reactivity/disposal-sweep.utils.cjs +1 -0
  80. package/dist/debug/runtime/reactivity/disposal-sweep.utils.js +42 -0
  81. package/dist/entrypoints/runtime.d.ts +2 -1
  82. package/dist/machine-testing.cjs +1 -1
  83. package/dist/machine-testing.js +1 -1
  84. package/dist/machine.cjs +1 -1
  85. package/dist/machine.js +216 -231
  86. package/dist/path/RaphKernel.d.ts +24 -0
  87. package/dist/path/storage/PathEventHub.d.ts +14 -0
  88. package/dist/path/storage/PathStore.d.ts +4 -4
  89. package/dist/reactivity/disposal.d.ts +14 -0
  90. package/dist/reactivity/engine.d.ts +177 -4
  91. package/dist/reactivity/scope.d.ts +108 -30
  92. package/dist/runtime/RaphRuntime.d.ts +236 -17
  93. package/dist/runtime/ownership/RaphEffectScope.d.ts +70 -1
  94. package/dist/runtime/ownership/RaphNode.d.ts +276 -6
  95. package/dist/runtime/ownership/RaphScope.d.ts +144 -14
  96. package/dist/runtime/phases/RaphPhasePipeline.d.ts +202 -28
  97. package/dist/runtime/phases/RaphPhaseTaskRecord.d.ts +195 -0
  98. package/dist/runtime/phases/RaphPhaseWatch.d.ts +22 -0
  99. package/dist/runtime/phases/phase.types.d.ts +83 -4
  100. package/dist/runtime/reactivity/RaphSelector.d.ts +338 -0
  101. package/dist/runtime/reactivity/RaphWorkGraph.d.ts +163 -25
  102. package/dist/runtime/reactivity/RuntimeReactivity.d.ts +258 -10
  103. package/dist/runtime/reactivity/RuntimeWatch.d.ts +8 -8
  104. package/dist/runtime/reactivity/disposal-sweep.utils.d.ts +19 -0
  105. package/dist/runtime/reactivity/runtime-reactivity.types.d.ts +48 -3
  106. package/package.json +9 -1
  107. 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, i) {
3
- if (i.segments.length <= e.segments.length)
2
+ function g(e, t, o) {
3
+ if (o.segments.length <= e.segments.length)
4
4
  return { kind: "full" };
5
- for (let o = 0; o < e.segments.length; o++)
6
- if (!m(e.segments[o], i.segments[o]))
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 r = i.segments[e.segments.length];
9
- if ((r == null ? void 0 : r.kind) !== "selector" || r.key !== t || typeof r.value != "string" && typeof r.value != "number")
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 = i.segments[e.segments.length + 1];
12
- return (n == null ? void 0 : n.kind) === "key" && n.key === t ? { kind: "full" } : { kind: "key", key: r.value };
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, i) {
15
- const r = p(e).canonical, n = typeof i == "number" ? String(i) : JSON.stringify(i);
16
- return `${r}[${t}=${n}]`;
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, i, r) {
19
- if (!Array.isArray(i) || !Array.isArray(r))
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 (i.length !== r.length)
21
+ if (o.length !== i.length)
22
22
  throw a(e, "must preserve collection cardinality");
23
- const n = f(i, t, "source"), o = f(r, t, "output");
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] !== o[s])
25
+ if (n[s] !== r[s])
26
26
  throw a(e, "must preserve key order");
27
27
  }
28
- function A(e, t, i, r) {
29
- if (!Array.isArray(r))
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 (i.length !== r.length)
31
+ if (o.length !== i.length)
32
32
  throw a(e, "incremental compute must preserve cardinality");
33
- const n = f(r, t, "output");
34
- for (let o = 0; o < i.length; o++)
35
- if (i[o] !== n[o])
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, i, r) {
39
- if (!Array.isArray(i) || !Array.isArray(r))
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(i, t, "source"),
45
- f(r, t, "output")
44
+ f(o, t, "source"),
45
+ f(i, t, "output")
46
46
  );
47
47
  }
48
- function x(e, t, i, r) {
49
- if (!Array.isArray(r))
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
- i,
55
- f(r, t, "output")
54
+ o,
55
+ f(i, t, "output")
56
56
  );
57
57
  }
58
- function f(e, t, i) {
59
- const r = /* @__PURE__ */ new Set(), n = [];
60
- for (let o = 0; o < e.length; o++) {
61
- if (!(o in e)) {
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[o];
65
+ const s = e[r];
66
66
  if (!l(s))
67
- throw new TypeError(`[Raph] ${i} collection items must be objects.`);
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] ${i} item key "${t}" must be a string or number.`);
71
- if (r.has(c))
72
- throw new TypeError(`[Raph] Duplicate ${i} key: "${String(c)}".`);
73
- r.add(c), n.push(c);
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, i) {
78
- const r = f(e, t, i), n = /* @__PURE__ */ new Map();
79
- for (let o = 0; o < r.length; o++) {
80
- const s = r[o];
81
- s !== void 0 && n.set(s, o);
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, i, r) {
86
- for (const n of r) {
87
- const o = i.get(n);
88
- if (o === void 0)
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[o];
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, i, r) {
105
+ function d(e, t, o, i) {
106
106
  const n = /* @__PURE__ */ new Map();
107
- for (let s = 0; s < i.length; s++) {
108
- const c = i[s];
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 o = -1;
112
- for (const s of r) {
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 <= o)
116
+ if (c === void 0 || c <= r)
117
117
  throw y(e, t);
118
- o = c;
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 i = t.get(e);
125
- if (i !== void 0)
126
- return i;
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 [o, s] of e)
135
- n.set(u(o, t), u(s, t));
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 o of e)
142
- n.add(u(o, t));
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 o = 0; o < e.length; o++)
151
- o in e && (n[o] = u(e[o], t));
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 r = Object.create(Object.getPrototypeOf(e));
155
- t.set(e, r);
154
+ const i = Object.create(Object.getPrototypeOf(e));
155
+ t.set(e, i);
156
156
  for (const n of Reflect.ownKeys(e))
157
- r[n] = u(e[n], t);
158
- return r;
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";var v=Object.defineProperty;var p=(d,e,t)=>e in d?v(d,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[e]=t;var l=(d,e,t)=>p(d,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../DataPath.cjs"),g=require("../PathRouter.cjs"),m=require("./RaphMeta.cjs"),_=require("./RaphMetaStore.cjs");class b{constructor(e,t,r){l(this,"_facade");l(this,"_store");l(this,"_router");l(this,"_pending");l(this,"_publishing",!1);l(this,"_watcherCount",0);l(this,"_deferredWatcherCount",0);this._kernel=e,this._ownerExists=t,this._publicationDeferred=r}get facade(){return this._facade??(this._facade=new m.RaphMeta(this._kernel))}get size(){var e;return((e=this._store)==null?void 0:e.size)??0}get hasWatchers(){return this._router!==void 0}get hasDeferredWatchers(){return this._deferredWatcherCount!==0}get(e,t){var r;return(r=this._store)==null?void 0:r.get(e,t)}has(e,t){var r;return((r=this._store)==null?void 0:r.has(e,t))??!1}set(e,t,r,i){(this._store??(this._store=new _.RaphMetaStore)).set(e,t,r),this.record("set",e,t,"explicit",i)}merge(e,t,r,i){(this._store??(this._store=new _.RaphMetaStore)).merge(e,t,r),this.record("merge",e,t,"explicit",i)}delete(e,t,r){var i;return(i=this._store)!=null&&i.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 i of r.deleteSubtree(e))this.record("delete",i,null,t)}pruneMissing(e,t){const r=this._store;if(r===void 0||r.size===0)return;const n=e.segments().findIndex(s=>s.kind==="index"||s.kind==="selector"),c=n===-1?e:f.DataPath.fromPlain({segs:e.toPlain().segs.slice(0,n)});for(const s of r.pruneMissing(c,o=>this._ownerExists(o)))this.record("delete",s,null,t)}watch(e,t,r={},i){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 u=f.DataPath.from(a,r)._asMask();c.set(u.canonical,u)}const s={active:!0,callback:t,afterPublish:i,...r.namespace===void 0?{}:{namespace:r.namespace}},o=this._router??(this._router=new g.PathRouter),h=[...c.values()].map(a=>o.add(a,s));return this._watcherCount++,i!==void 0&&this._deferredWatcherCount++,w(()=>{s.active=!1,s.callback=void 0,s.afterPublish=void 0;for(const a of h)a();this._watcherCount--,i!==void 0&&this._deferredWatcherCount--,this._watcherCount===0&&(this._router=void 0)})}record(e,t,r,i,n){(this._pending??(this._pending=[])).push({event:{kind:e,path:t,namespace:r,cause:i},invalidate:(n==null?void 0: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 i=e.splice(0),n=this._router;if(n===void 0)continue;const c=new Map;for(const s of i){const o=s.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:s.invalidate}):(a.events.push(o),s.invalidate&&(a.invalidate=!0))}}for(const[s,o]of c){if(!s.active||s.callback===void 0)continue;const h=s.afterPublish;h!==void 0&&r.set(h,(r.get(h)??!1)||o.invalidate);try{s.callback({events:o.events})}catch(a){t.push(a)}}}}finally{this._publishing=!1}for(const[i,n]of r)try{i(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(){var e;(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}}function w(d){let e=d;return()=>{const t=e;e=void 0,t==null||t()}}exports.MetaController=b;
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
- var v = Object.defineProperty;
2
- var p = (d, e, t) => e in d ? v(d, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[e] = t;
3
- var l = (d, e, t) => p(d, typeof e != "symbol" ? e + "" : e, t);
4
- import { DataPath as f } from "../DataPath.js";
5
- import { PathRouter as g } from "../PathRouter.js";
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 ?? (this._facade = new m(this._kernel));
25
+ return this._facade ??= new v(this._kernel);
29
26
  }
30
27
  /**
31
28
  * Возвращает число зарегистрированных записей.
32
29
  */
33
30
  get size() {
34
- var e;
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
- var r;
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
- var r;
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, i) {
67
- (this._store ?? (this._store = new _())).set(e, t, r), this.record("set", e, t, "explicit", i);
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, i) {
73
- (this._store ?? (this._store = new _())).merge(e, t, r), this.record("merge", e, t, "explicit", i);
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
- var i;
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 i of r.deleteSubtree(e))
89
- this.record("delete", i, null, t);
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
- (s) => s.kind === "index" || s.kind === "selector"
100
- ), c = o === -1 ? e : f.fromPlain({ segs: e.toPlain().segs.slice(0, o) });
101
- for (const s of r.pruneMissing(
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", s, null, t);
98
+ this.record("delete", i, null, t);
106
99
  }
107
100
  /**
108
101
  * Подписывает callback на подходящие изменения и возвращает disposer.
109
102
  */
110
- watch(e, t, r = {}, i) {
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 u = f.from(a, r)._asMask();
117
- c.set(u.canonical, u);
109
+ const l = u.from(a, r)._asMask();
110
+ c.set(l.canonical, l);
118
111
  }
119
- const s = {
112
+ const i = {
120
113
  active: !0,
121
114
  callback: t,
122
- afterPublish: i,
115
+ afterPublish: s,
123
116
  ...r.namespace === void 0 ? {} : { namespace: r.namespace }
124
- }, n = this._router ?? (this._router = new g()), h = [...c.values()].map((a) => n.add(a, s));
125
- return this._watcherCount++, i !== void 0 && this._deferredWatcherCount++, w(() => {
126
- s.active = !1, s.callback = void 0, s.afterPublish = void 0;
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--, i !== void 0 && this._deferredWatcherCount--, this._watcherCount === 0 && (this._router = void 0);
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, i, o) {
136
- (this._pending ?? (this._pending = [])).push({
137
- event: { kind: e, path: t, namespace: r, cause: i },
138
- invalidate: (o == null ? void 0 : o.invalidate) ?? !0
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 i = e.splice(0), o = this._router;
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 s of i) {
157
- const n = s.event;
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: s.invalidate
165
- }) : (a.events.push(n), s.invalidate && (a.invalidate = !0));
157
+ invalidate: i.invalidate
158
+ }) : (a.events.push(n), i.invalidate && (a.invalidate = !0));
166
159
  }
167
160
  }
168
- for (const [s, n] of c) {
169
- if (!s.active || s.callback === void 0)
161
+ for (const [i, n] of c) {
162
+ if (!i.active || i.callback === void 0)
170
163
  continue;
171
- const h = s.afterPublish;
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
- s.callback({ events: n.events });
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 [i, o] of r)
179
+ for (const [s, o] of r)
187
180
  try {
188
- i(o);
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
- var e;
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 w(d) {
197
+ function p(d) {
206
198
  let e = d;
207
199
  return () => {
208
200
  const t = e;
209
- e = void 0, t == null || t();
201
+ e = void 0, t?.();
210
202
  };
211
203
  }
212
204
  export {
213
- k as MetaController
205
+ C as MetaController
214
206
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class s{constructor(r,a={}){this._kernel=r,this._binding=a}get(r,a,t){var e,i;return(i=(e=this._binding).assertReadable)==null||i.call(e),this._kernel.getMeta(r,a,t)}has(r,a,t){var e,i;return(i=(e=this._binding).assertReadable)==null||i.call(e),this._kernel.hasMeta(r,a,t)}set(r,a,t,e){var i,h;(h=(i=this._binding).assertWritable)==null||h.call(i),this._write(()=>this._kernel.setMeta(r,a,t,e),(e==null?void 0:e.invalidate)??!0)}merge(r,a,t,e){var i,h;(h=(i=this._binding).assertWritable)==null||h.call(i),this._write(()=>this._kernel.mergeMeta(r,a,t,e),(e==null?void 0:e.invalidate)??!0)}delete(r,a,t){var e,i;(i=(e=this._binding).assertWritable)==null||i.call(e),this._write(()=>this._kernel.deleteMeta(r,a,t),(t==null?void 0:t.invalidate)??!0)}watch(r,a,t={}){var e,i;if((i=(e=this._binding).assertReadable)==null||i.call(e),this._binding.watch===void 0)throw new Error("[RaphMeta] watch requires a runtime-bound Meta facade.");return this._binding.watch(r,a,t)}_write(r,a){const t=this._binding.runWrite;t===void 0?r():t(r,a)}}exports.RaphMeta=s;
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 n {
1
+ class s {
2
2
  /**
3
3
  * Создаёт metadata facade поверх указанного Kernel.
4
4
  */
5
- constructor(r, a = {}) {
6
- this._kernel = r, this._binding = a;
5
+ constructor(e, t = {}) {
6
+ this._kernel = e, this._binding = t;
7
7
  }
8
8
  /**
9
9
  * Возвращает значение по пути без создания отсутствующих данных.
10
10
  */
11
- get(r, a, t) {
12
- var e, i;
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(r, a, t) {
19
- var e, i;
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(r, a, t, e) {
26
- var i, h;
27
- (h = (i = this._binding).assertWritable) == null || h.call(i), this._write(
28
- () => this._kernel.setMeta(r, a, t, e),
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(r, a, t, e) {
36
- var i, h;
37
- (h = (i = this._binding).assertWritable) == null || h.call(i), this._write(
38
- () => this._kernel.mergeMeta(r, a, t, e),
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(r, a, t) {
46
- var e, i;
47
- (i = (e = this._binding).assertWritable) == null || i.call(e), this._write(
48
- () => this._kernel.deleteMeta(r, a, t),
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(r, a, t = {}) {
56
- var e, i;
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(r, a, t);
53
+ return this._binding.watch(e, t, i);
60
54
  }
61
- _write(r, a) {
62
- const t = this._binding.runWrite;
63
- t === void 0 ? r() : t(r, a);
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
- n as RaphMeta
61
+ s as RaphMeta
68
62
  };
@@ -1 +1 @@
1
- "use strict";var p=Object.defineProperty;var _=(n,e,t)=>e in n?p(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var a=(n,e,t)=>_(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("../pathSegmentKey.cjs");function d(){return{children:new Map,namespaces:new Map,path:void 0}}class g{constructor(){a(this,"_root",d());a(this,"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(l(s)&&l(r)){for(const i of Object.keys(r))y(s,i,r[i]);return}this.set(e,t,r)}delete(e,t){var i;const r=this._findStack(e),s=(i=r.at(-1))==null?void 0:i.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 u=r.children.get(t[c]);if(u===void 0)return[];r=u}const s=r.children.get(t.at(-1));if(s===void 0)return[];const i=h(s);return this.size-=f(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=h(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=d(),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(m.pathSegmentKey)}function h(n){const e=n.path!==void 0&&n.namespaces.size!==0?[n.path]:[];for(const t of n.children.values())e.push(...h(t));return e}function f(n){let e=n.namespaces.size;for(const t of n.children.values())e+=f(t);return e}function l(n){if(typeof n!="object"||n===null||Array.isArray(n))return!1;const e=Object.getPrototypeOf(n);return e===Object.prototype||e===null}function y(n,e,t){if(e!=="__proto__"){n[e]=t;return}Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:t,writable:!0})}exports.RaphMetaStore=g;
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;