@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 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./DataPath.cjs"),f=2e4;let n,s;function u(e,t){if(!(t!=null&&t.vars)){const r=n==null?void 0:n.get(e);if(r!==void 0)return r}if(typeof e!="string")return g(e,t);const a=c.DataPath._parseExactString(e,t);if(!(t!=null&&t.vars)){const r=n??(n=new Map);r.size>=f&&r.clear(),r.set(e,a)}return a}function i(e){const t=s==null?void 0:s.get(e);if(t!==void 0)return t;if(typeof e!="string")return h(e);const a=c.DataPath._parseMaskString(e),r=s??(s=new Map);return r.size>=f&&r.clear(),r.set(e,a),a}function l(e){if(e.segments.length===0)return["*"];const t=[`${e.canonical}.*`];for(let a=1;a<e.segments.length;a++)t.push(c.DataPath._renderSegments(e.segments.slice(0,a)));return t}function g(e,t){const a=c.DataPath.from(e,t)._asExact();if(e instanceof c.DataPath&&!(t!=null&&t.vars)){const r=n??(n=new Map);r.size>=f&&r.clear(),r.set(e,a)}return a}function h(e){const t=c.DataPath.from(e)._asMask();if(e instanceof c.DataPath){const a=s??(s=new Map);a.size>=f&&a.clear(),a.set(e,t)}return t}exports.parseDataPath=u;exports.parsePathMask=i;exports.pathRelationMasks=l;
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;
@@ -1,56 +1,56 @@
1
- import { DataPath as n } from "./DataPath.js";
2
- const f = 2e4;
3
- let a, s;
4
- function g(e, r) {
5
- if (!(r != null && r.vars)) {
6
- const c = a == null ? void 0 : a.get(e);
7
- if (c !== void 0)
8
- return c;
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
9
  }
10
10
  if (typeof e != "string")
11
- return i(e, r);
12
- const t = n._parseExactString(e, r);
13
- if (!(r != null && r.vars)) {
14
- const c = a ?? (a = /* @__PURE__ */ new Map());
15
- c.size >= f && c.clear(), c.set(e, t);
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
16
  }
17
- return t;
17
+ return n;
18
18
  }
19
- function M(e) {
20
- const r = s == null ? void 0 : s.get(e);
21
- if (r !== void 0)
22
- return r;
19
+ function g(e) {
20
+ const t = i?.get(e);
21
+ if (t !== void 0)
22
+ return t;
23
23
  if (typeof e != "string")
24
- return u(e);
25
- const t = n._parseMaskString(e), c = s ?? (s = /* @__PURE__ */ new Map());
26
- return c.size >= f && c.clear(), c.set(e, t), t;
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
27
  }
28
- function d(e) {
28
+ function h(e) {
29
29
  if (e.segments.length === 0)
30
30
  return ["*"];
31
- const r = [`${e.canonical}.*`];
32
- for (let t = 1; t < e.segments.length; t++)
33
- r.push(n._renderSegments(e.segments.slice(0, t)));
34
- return r;
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
35
  }
36
- function i(e, r) {
37
- const t = n.from(e, r)._asExact();
38
- if (e instanceof n && !(r != null && r.vars)) {
39
- const c = a ?? (a = /* @__PURE__ */ new Map());
40
- c.size >= f && c.clear(), c.set(e, t);
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
41
  }
42
- return t;
42
+ return n;
43
43
  }
44
- function u(e) {
45
- const r = n.from(e)._asMask();
46
- if (e instanceof n) {
47
- const t = s ?? (s = /* @__PURE__ */ new Map());
48
- t.size >= f && t.clear(), t.set(e, r);
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
49
  }
50
- return r;
50
+ return t;
51
51
  }
52
52
  export {
53
- g as parseDataPath,
54
- M as parsePathMask,
55
- d as pathRelationMasks
53
+ l as parseDataPath,
54
+ g as parsePathMask,
55
+ h as pathRelationMasks
56
56
  };
@@ -1 +1 @@
1
- "use strict";var h=Object.defineProperty;var _=(r,e,t)=>e in r?h(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var d=(r,e,t)=>_(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../data-path.utils.cjs"),u=require("../PathRouter.cjs"),f=require("./derived-collection.utils.cjs"),g=2e4;class v{constructor(){d(this,"_router");d(this,"_handles");d(this,"_matches");d(this,"_pending");d(this,"_collections");d(this,"_counter",0)}get size(){var e;return((e=this._handles)==null?void 0:e.size)??0}get pending(){return this._pending}nextId(){return`derived-${this._counter++}`}has(e){var t;return((t=this._handles)==null?void 0:t.has(e))??!1}values(){var e;return((e=this._handles)==null?void 0:e.values())??[][Symbol.iterator]()}state(e){var t;return(t=this._collections)==null?void 0:t.get(e)}register(e,t,i){(this._handles??(this._handles=new Map)).set(e.id,e),i!==void 0&&(this._collections??(this._collections=new Map)).set(e,{from:t,kind:i.kind,key:i.key,initialized:!1,full:!0,keys:new Set,sourceIndex:void 0,targetIndex:void 0});const n=this._router??(this._router=new u.PathRouter);this._matches=void 0,e._attachRoutes(l.pathRelationMasks(t).map(s=>n.add(l.parsePathMask(s),e)))}remove(e){var i,o,n;const t=this._handles;(t==null?void 0:t.get(e.id))===e&&(t.delete(e.id),e._detachRoutes(),this._matches=void 0,(i=this._pending)==null||i.delete(e),(o=this._collections)==null||o.delete(e),((n=this._collections)==null?void 0:n.size)===0&&(this._collections=void 0),t.size===0&&(this._handles=void 0,this._router=void 0,this._pending=void 0))}queue(e){var o;const t=this._matching(e);if(t.length===0)return;const i=this._pending??(this._pending=new Set);for(const n of t){if(n.paused||n.disposed)continue;const s=(o=this._collections)==null?void 0:o.get(n);if(s!==void 0&&s.initialized&&!s.full){const c=f.collectionMutationImpact(s.from,s.key,e);c.kind==="full"?(s.full=!0,s.keys.clear()):s.keys.add(c.key)}i.add(n)}}queueReplacement(e,t){var n;const i=this._matching(e);if(i.length===0)return;const o=this._pending??(this._pending=new Set);for(const s of i){if(s.paused||s.disposed)continue;const c=(n=this._collections)==null?void 0:n.get(s);if(c!==void 0&&c.initialized&&!c.full&&c.from.canonical===e.canonical)for(const a of t)c.keys.add(a);else c!==void 0&&(c.full=!0,c.keys.clear());o.add(s)}}clearPendingIfEmpty(){var e;((e=this._pending)==null?void 0:e.size)===0&&(this._pending=void 0)}dispose(){if(this._handles!==void 0)for(const e of this._handles.values())e._disposeFromKernel();this._handles=void 0,this._router=void 0,this._matches=void 0,this._pending=void 0,this._collections=void 0}_matching(e){var n;const t=this._router;if(t===void 0)return[];let i=(n=this._matches)==null?void 0:n.get(e.canonical);if(i!==void 0)return i;i=[...e.segments.length===0?t.matchAll():t.match(e.segments)];const o=this._matches??(this._matches=new Map);return o.size>=g&&o.clear(),o.set(e.canonical,i),i}}exports.DerivedRegistry=v;
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;
@@ -1,27 +1,21 @@
1
- var a = Object.defineProperty;
2
- var h = (l, e, t) => e in l ? a(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
- var d = (l, e, t) => h(l, typeof e != "symbol" ? e + "" : e, t);
4
- import { pathRelationMasks as _, parsePathMask as u } from "../data-path.utils.js";
5
- import { PathRouter as f } from "../PathRouter.js";
6
- import { collectionMutationImpact as m } from "./derived-collection.utils.js";
7
- const g = 2e4;
8
- class z {
9
- constructor() {
10
- // Хранят routes, handles и инкрементальное состояние materialized derived.
11
- d(this, "_router");
12
- d(this, "_handles");
13
- d(this, "_matches");
14
- d(this, "_pending");
15
- d(this, "_collections");
16
- // Формирует локальные идентификаторы derived без глобального shared state.
17
- d(this, "_counter", 0);
18
- }
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;
19
14
  /**
20
15
  * Возвращает число зарегистрированных записей.
21
16
  */
22
17
  get size() {
23
- var e;
24
- return ((e = this._handles) == null ? void 0 : e.size) ?? 0;
18
+ return this._handles?.size ?? 0;
25
19
  }
26
20
  /**
27
21
  * Возвращает очередь derived-вычислений, ожидающих стабилизации.
@@ -39,96 +33,89 @@ class z {
39
33
  * Проверяет наличие derived handle с указанным id.
40
34
  */
41
35
  has(e) {
42
- var t;
43
- return ((t = this._handles) == null ? void 0 : t.has(e)) ?? !1;
36
+ return this._handles?.has(e) ?? !1;
44
37
  }
45
38
  /**
46
39
  * Возвращает зарегистрированные derived handles.
47
40
  */
48
41
  values() {
49
- var e;
50
- return ((e = this._handles) == null ? void 0 : e.values()) ?? [][Symbol.iterator]();
42
+ return this._handles?.values() ?? [][Symbol.iterator]();
51
43
  }
52
44
  /**
53
45
  * Возвращает внутреннее состояние зарегистрированного handle.
54
46
  */
55
47
  state(e) {
56
- var t;
57
- return (t = this._collections) == null ? void 0 : t.get(e);
48
+ return this._collections?.get(e);
58
49
  }
59
50
  /**
60
51
  * Регистрирует derived handle и его зависимости.
61
52
  */
62
- register(e, t, i) {
63
- (this._handles ?? (this._handles = /* @__PURE__ */ new Map())).set(e.id, e), i !== void 0 && (this._collections ?? (this._collections = /* @__PURE__ */ new Map())).set(e, {
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, {
64
55
  from: t,
65
- kind: i.kind,
66
- key: i.key,
56
+ kind: s.kind,
57
+ key: s.key,
67
58
  initialized: !1,
68
59
  full: !0,
69
60
  keys: /* @__PURE__ */ new Set(),
70
61
  sourceIndex: void 0,
71
62
  targetIndex: void 0
72
63
  });
73
- const n = this._router ?? (this._router = new f());
74
- this._matches = void 0, e._attachRoutes(_(t).map(
75
- (s) => n.add(u(s), e)
64
+ const i = this._router ??= new r();
65
+ this._matches = void 0, e._attachRoutes(d(t).map(
66
+ (n) => i.add(l(n), e)
76
67
  ));
77
68
  }
78
69
  /**
79
70
  * Удаляет регистрацию и связанные pending-записи.
80
71
  */
81
72
  remove(e) {
82
- var i, o, n;
83
73
  const t = this._handles;
84
- (t == null ? void 0 : t.get(e.id)) === e && (t.delete(e.id), e._detachRoutes(), this._matches = void 0, (i = this._pending) == null || i.delete(e), (o = this._collections) == null || o.delete(e), ((n = this._collections) == null ? void 0 : n.size) === 0 && (this._collections = void 0), t.size === 0 && (this._handles = void 0, this._router = void 0, this._pending = void 0));
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));
85
75
  }
86
76
  /**
87
77
  * Добавляет derived handle в очередь пересчёта.
88
78
  */
89
79
  queue(e) {
90
- var o;
91
80
  const t = this._matching(e);
92
81
  if (t.length === 0)
93
82
  return;
94
- const i = this._pending ?? (this._pending = /* @__PURE__ */ new Set());
95
- for (const n of t) {
96
- if (n.paused || n.disposed)
83
+ const s = this._pending ??= /* @__PURE__ */ new Set();
84
+ for (const o of t) {
85
+ if (o.paused || o.disposed)
97
86
  continue;
98
- const s = (o = this._collections) == null ? void 0 : o.get(n);
99
- if (s !== void 0 && s.initialized && !s.full) {
100
- const c = m(s.from, s.key, e);
101
- c.kind === "full" ? (s.full = !0, s.keys.clear()) : s.keys.add(c.key);
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);
102
91
  }
103
- i.add(n);
92
+ s.add(o);
104
93
  }
105
94
  }
106
95
  /**
107
96
  * Запоминает полную замену, которую нужно применить при стабилизации.
108
97
  */
109
98
  queueReplacement(e, t) {
110
- var n;
111
- const i = this._matching(e);
112
- if (i.length === 0)
99
+ const s = this._matching(e);
100
+ if (s.length === 0)
113
101
  return;
114
- const o = this._pending ?? (this._pending = /* @__PURE__ */ new Set());
115
- for (const s of i) {
116
- if (s.paused || s.disposed)
102
+ const o = this._pending ??= /* @__PURE__ */ new Set();
103
+ for (const i of s) {
104
+ if (i.paused || i.disposed)
117
105
  continue;
118
- const c = (n = this._collections) == null ? void 0 : n.get(s);
119
- if (c !== void 0 && c.initialized && !c.full && c.from.canonical === e.canonical)
120
- for (const r of t)
121
- c.keys.add(r);
122
- else c !== void 0 && (c.full = !0, c.keys.clear());
123
- o.add(s);
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);
124
112
  }
125
113
  }
126
114
  /**
127
115
  * Сбрасывает pending-состояние после опустошения очереди.
128
116
  */
129
117
  clearPendingIfEmpty() {
130
- var e;
131
- ((e = this._pending) == null ? void 0 : e.size) === 0 && (this._pending = void 0);
118
+ this._pending?.size === 0 && (this._pending = void 0);
132
119
  }
133
120
  /**
134
121
  * Освобождает все handles и очищает derived registry.
@@ -140,18 +127,17 @@ class z {
140
127
  this._handles = void 0, this._router = void 0, this._matches = void 0, this._pending = void 0, this._collections = void 0;
141
128
  }
142
129
  _matching(e) {
143
- var n;
144
130
  const t = this._router;
145
131
  if (t === void 0)
146
132
  return [];
147
- let i = (n = this._matches) == null ? void 0 : n.get(e.canonical);
148
- if (i !== void 0)
149
- return i;
150
- i = [...e.segments.length === 0 ? t.matchAll() : t.match(e.segments)];
151
- const o = this._matches ?? (this._matches = /* @__PURE__ */ new Map());
152
- return o.size >= g && o.clear(), o.set(e.canonical, i), i;
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;
153
139
  }
154
140
  }
155
141
  export {
156
- z as DerivedRegistry
142
+ g as DerivedRegistry
157
143
  };
@@ -1 +1 @@
1
- "use strict";var o=Object.defineProperty;var d=(r,e,t)=>e in r?o(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var s=(r,e,t)=>d(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class a extends Error{constructor(e){super(`[Raph] Derived target is read-only: "${e}".`),this.name="RaphDerivedTargetWriteError"}}class h{constructor(e,t,i){s(this,"id");s(this,"options");s(this,"_kernel");s(this,"_removeRoutes");s(this,"_paused",!1);s(this,"_disposed",!1);s(this,"_status","idle");s(this,"_lastError",null);this._kernel=e,this.id=t,this.options=i}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 t of e)t()}_disposeFromKernel(){this._disposed=!0,this._removeRoutes=void 0}_assertAlive(){if(this._disposed)throw new Error(`[Raph] Derived "${this.id}" is disposed.`)}}exports.RaphDerivedHandle=h;exports.RaphDerivedTargetWriteError=a;
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
- var o = Object.defineProperty;
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 u {
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, t, i) {
18
- // Публикуют identity и immutable параметры materialized dependency.
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 t of e)
108
- t();
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
- u as RaphDerivedHandle,
124
- h as RaphDerivedTargetWriteError
120
+ o as RaphDerivedHandle,
121
+ i as RaphDerivedTargetWriteError
125
122
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../data-path.utils.cjs");function m(e,t,i){if(i.segments.length<=e.segments.length)return{kind:"full"};for(let o=0;o<e.segments.length;o++)if(!$(e.segments[o],i.segments[o]))return{kind:"full"};const r=i.segments[e.segments.length];if((r==null?void 0:r.kind)!=="selector"||r.key!==t||typeof r.value!="string"&&typeof r.value!="number")return{kind:"full"};const n=i.segments[e.segments.length+1];return(n==null?void 0:n.kind)==="key"&&n.key===t?{kind:"full"}:{kind:"key",key:r.value}}function k(e,t,i){const r=p.parseDataPath(e).canonical,n=typeof i=="number"?String(i):JSON.stringify(i);return`${r}[${t}=${n}]`}function g(e,t,i,r){if(!Array.isArray(i)||!Array.isArray(r))throw f(e,"requires array source and output");if(i.length!==r.length)throw f(e,"must preserve collection cardinality");const n=a(i,t,"source"),o=a(r,t,"output");for(let s=0;s<n.length;s++)if(n[s]!==o[s])throw f(e,"must preserve key order")}function h(e,t,i,r){if(!Array.isArray(r))throw f(e,"incremental compute must return an array");if(i.length!==r.length)throw f(e,"incremental compute must preserve cardinality");const n=a(r,t,"output");for(let o=0;o<i.length;o++)if(i[o]!==n[o])throw f(e,"incremental compute must preserve key order")}function w(e,t,i,r){if(!Array.isArray(i)||!Array.isArray(r))throw u(e,"requires array source and output");d(e,"output must be an ordered subset of source",a(i,t,"source"),a(r,t,"output"))}function b(e,t,i,r){if(!Array.isArray(r))throw u(e,"incremental compute must return an array");d(e,"incremental output must be an ordered subset of input",i,a(r,t,"output"))}function a(e,t,i){const r=new Set,n=[];for(let o=0;o<e.length;o++){if(!(o in e)){n.push(void 0);continue}const s=e[o];if(!y(s))throw new TypeError(`[Raph] ${i} collection items must be objects.`);const c=s[t];if(typeof c!="string"&&typeof c!="number")throw new TypeError(`[Raph] ${i} item key "${t}" must be a string or number.`);if(r.has(c))throw new TypeError(`[Raph] Duplicate ${i} key: "${String(c)}".`);r.add(c),n.push(c)}return n}function A(e,t,i){const r=a(e,t,i),n=new Map;for(let o=0;o<r.length;o++){const s=r[o];s!==void 0&&n.set(s,o)}return n}function x(e,t,i,r){for(const n of r){const o=i.get(n);if(o===void 0)return!0;const s=e[o];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,i,r){const n=new Map;for(let s=0;s<i.length;s++){const c=i[s];c!==void 0&&n.set(c,s)}let o=-1;for(const s of r){if(s===void 0)continue;const c=n.get(s);if(c===void 0||c<=o)throw u(e,t);o=c}}function l(e,t){if(e===null||typeof e!="object")return e;const i=t.get(e);if(i!==void 0)return i;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[o,s]of e)n.set(l(o,t),l(s,t));return n}if(e instanceof Set){const n=new Set;t.set(e,n);for(const o of e)n.add(l(o,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 o=0;o<e.length;o++)o in e&&(n[o]=l(e[o],t));return n}const r=Object.create(Object.getPrototypeOf(e));t.set(e,r);for(const n of Reflect.ownKeys(e))r[n]=l(e[n],t);return r}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
+ "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;