@raphy-js/raph 1.0.0-dev.2 → 1.0.1-dev.20

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 (211) hide show
  1. package/README.md +1096 -0
  2. package/dist/api/Raph.d.ts +59 -190
  3. package/dist/api/RaphFacadeSession.d.ts +90 -0
  4. package/dist/api/RaphReactivityInstance.d.ts +72 -0
  5. package/dist/api/errors.d.ts +9 -4
  6. package/dist/api/types.d.ts +162 -17
  7. package/dist/core-CyilRD7s.js +1055 -0
  8. package/dist/core-ugchZNqC.cjs +1 -0
  9. package/dist/debug/api/Raph.cjs +1 -1
  10. package/dist/debug/api/Raph.js +368 -366
  11. package/dist/debug/api/RaphFacadeSession.cjs +1 -0
  12. package/dist/debug/api/RaphFacadeSession.js +306 -0
  13. package/dist/debug/api/RaphReactivityInstance.cjs +1 -0
  14. package/dist/debug/api/RaphReactivityInstance.js +149 -0
  15. package/dist/debug/api/errors.cjs +1 -1
  16. package/dist/debug/api/errors.js +10 -7
  17. package/dist/debug/path/DataPath.cjs +1 -0
  18. package/dist/debug/path/{data-path.js → DataPath.js} +151 -180
  19. package/dist/debug/path/PathRouter.cjs +1 -0
  20. package/dist/debug/path/{path-router.js → PathRouter.js} +1 -1
  21. package/dist/debug/path/RaphKernel.cjs +1 -1
  22. package/dist/debug/path/RaphKernel.js +258 -207
  23. package/dist/debug/path/data-path.utils.cjs +1 -0
  24. package/dist/debug/path/data-path.utils.js +56 -0
  25. package/dist/debug/path/derived/DerivedRegistry.cjs +1 -0
  26. package/dist/debug/path/{DerivedRegistry.js → derived/DerivedRegistry.js} +5 -5
  27. package/dist/debug/path/derived/derived-collection.utils.cjs +1 -0
  28. package/dist/debug/path/{derived-collection.js → derived/derived-collection.utils.js} +1 -1
  29. package/dist/debug/path/derived/derived-strategy.types.cjs +1 -0
  30. package/dist/debug/path/derived/derived-strategy.types.js +1 -0
  31. package/dist/debug/path/{MetaController.cjs → meta/MetaController.cjs} +1 -1
  32. package/dist/debug/path/{MetaController.js → meta/MetaController.js} +3 -3
  33. package/dist/debug/path/meta/RaphMetaStore.cjs +1 -0
  34. package/dist/debug/path/{RaphMetaStore.js → meta/RaphMetaStore.js} +1 -1
  35. package/dist/debug/path/meta/meta.types.cjs +1 -0
  36. package/dist/debug/path/meta/meta.types.js +1 -0
  37. package/dist/debug/path/storage/AdapterPathStore.cjs +1 -0
  38. package/dist/debug/path/{AdapterPathStore.js → storage/AdapterPathStore.js} +9 -9
  39. package/dist/debug/path/storage/DefaultDataAdapter.cjs +1 -0
  40. package/dist/debug/path/{data-adapter.js → storage/DefaultDataAdapter.js} +2 -2
  41. package/dist/debug/path/storage/PathEventHub.cjs +1 -0
  42. package/dist/debug/path/{PathEventHub.js → storage/PathEventHub.js} +34 -34
  43. package/dist/debug/path/storage/PathStore.cjs +1 -0
  44. package/dist/debug/path/{PathStore.js → storage/PathStore.js} +28 -28
  45. package/dist/debug/path/storage/data-adapter.types.cjs +1 -0
  46. package/dist/debug/path/storage/data-adapter.types.js +1 -0
  47. package/dist/debug/reactivity/engine.cjs +1 -1
  48. package/dist/debug/reactivity/engine.js +478 -306
  49. package/dist/debug/reactivity/reactive-object.cjs +1 -0
  50. package/dist/debug/reactivity/reactive-object.js +280 -0
  51. package/dist/debug/runtime/RaphRuntime.cjs +1 -1
  52. package/dist/debug/runtime/RaphRuntime.js +798 -519
  53. package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -0
  54. package/dist/debug/runtime/diagnostics/RaphDebug.js +297 -0
  55. package/dist/debug/runtime/errors.cjs +1 -1
  56. package/dist/debug/runtime/errors.js +6 -3
  57. package/dist/debug/runtime/ownership/RaphEffectScope.cjs +1 -0
  58. package/dist/debug/runtime/ownership/RaphEffectScope.js +171 -0
  59. package/dist/debug/runtime/ownership/RaphNode.cjs +1 -0
  60. package/dist/debug/runtime/ownership/RaphNode.js +206 -0
  61. package/dist/debug/runtime/ownership/RaphScope.cjs +1 -0
  62. package/dist/debug/runtime/ownership/RaphScope.js +101 -0
  63. package/dist/debug/runtime/ownership/parent-graph.types.cjs +1 -0
  64. package/dist/debug/runtime/ownership/parent-graph.types.js +1 -0
  65. package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -0
  66. package/dist/debug/runtime/phases/RaphPhasePipeline.js +587 -0
  67. package/dist/debug/runtime/phases/orderPhaseTasks.cjs +1 -0
  68. package/dist/debug/runtime/phases/orderPhaseTasks.js +59 -0
  69. package/dist/debug/runtime/reactivity/PathHandle.cjs +1 -0
  70. package/dist/debug/runtime/{PathHandle.js → reactivity/PathHandle.js} +75 -39
  71. package/dist/debug/runtime/reactivity/RaphMetaSource.cjs +1 -0
  72. package/dist/debug/runtime/reactivity/RaphMetaSource.js +112 -0
  73. package/dist/debug/runtime/reactivity/RaphWorkGraph.cjs +1 -0
  74. package/dist/debug/runtime/reactivity/RaphWorkGraph.js +995 -0
  75. package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -0
  76. package/dist/debug/runtime/reactivity/RuntimeReactivity.js +156 -0
  77. package/dist/debug/runtime/reactivity/RuntimeWatch.cjs +1 -0
  78. package/dist/debug/runtime/reactivity/RuntimeWatch.js +88 -0
  79. package/dist/debug/runtime/reactivity/runtime-reactivity.types.cjs +1 -0
  80. package/dist/debug/runtime/reactivity/runtime-reactivity.types.js +1 -0
  81. package/dist/entrypoints/machine-testing.d.ts +2 -0
  82. package/dist/entrypoints/machine.d.ts +5 -0
  83. package/dist/entrypoints/path.d.ts +14 -0
  84. package/dist/entrypoints/reactivity.d.ts +1 -0
  85. package/dist/entrypoints/runtime.d.ts +17 -0
  86. package/dist/index.cjs +1 -1
  87. package/dist/index.js +46 -38
  88. package/dist/machine/compiler.d.ts +71 -0
  89. package/dist/machine/core.d.ts +50 -0
  90. package/dist/machine/persistence.d.ts +5 -0
  91. package/dist/machine/runtime.d.ts +4 -0
  92. package/dist/machine/testing.d.ts +43 -0
  93. package/dist/machine/types.d.ts +155 -0
  94. package/dist/machine-testing.cjs +1 -0
  95. package/dist/machine-testing.js +188 -0
  96. package/dist/machine.cjs +1 -0
  97. package/dist/machine.js +837 -0
  98. package/dist/main.d.ts +20 -0
  99. package/dist/path/{data-path.d.ts → DataPath.d.ts} +16 -40
  100. package/dist/path/{path-router.d.ts → PathRouter.d.ts} +1 -1
  101. package/dist/path/RaphKernel.d.ts +13 -10
  102. package/dist/path/data-path.types.d.ts +34 -0
  103. package/dist/path/data-path.utils.d.ts +9 -0
  104. package/dist/path/{DerivedRegistry.d.ts → derived/DerivedRegistry.d.ts} +2 -2
  105. package/dist/path/{RaphDerivedHandle.d.ts → derived/RaphDerivedHandle.d.ts} +3 -3
  106. package/dist/path/derived/derived-collection.types.d.ts +12 -0
  107. package/dist/path/{derived-collection.d.ts → derived/derived-collection.utils.d.ts} +3 -13
  108. package/dist/path/{derived-strategies.d.ts → derived/derived-strategy.types.d.ts} +0 -3
  109. package/dist/path/derived/derived-strategy.utils.d.ts +4 -0
  110. package/dist/path/{MetaController.d.ts → meta/MetaController.d.ts} +4 -4
  111. package/dist/path/{RaphMeta.d.ts → meta/RaphMeta.d.ts} +2 -2
  112. package/dist/path/{RaphMetaStore.d.ts → meta/RaphMetaStore.d.ts} +1 -1
  113. package/dist/path/{meta.types.d.ts → meta/meta.types.d.ts} +2 -4
  114. package/dist/path/path.types.d.ts +3 -2
  115. package/dist/path/{segment-key.d.ts → pathSegmentKey.d.ts} +1 -1
  116. package/dist/path/{AdapterPathStore.d.ts → storage/AdapterPathStore.d.ts} +4 -4
  117. package/dist/path/{data-adapter.d.ts → storage/DefaultDataAdapter.d.ts} +2 -17
  118. package/dist/path/{PathEventHub.d.ts → storage/PathEventHub.d.ts} +9 -9
  119. package/dist/path/{PathStore.d.ts → storage/PathStore.d.ts} +3 -3
  120. package/dist/path/storage/data-adapter.types.d.ts +17 -0
  121. package/dist/path.cjs +1 -1
  122. package/dist/path.js +16 -16
  123. package/dist/raph.cjs +1 -1
  124. package/dist/raph.js +46 -38
  125. package/dist/reactivity/engine.d.ts +17 -3
  126. package/dist/reactivity/reactive-object.d.ts +36 -0
  127. package/dist/reactivity/types.d.ts +25 -0
  128. package/dist/reactivity.cjs +1 -1
  129. package/dist/reactivity.js +12 -12
  130. package/dist/runtime/RaphRuntime.d.ts +132 -192
  131. package/dist/runtime/diagnostics/RaphDebug.d.ts +239 -0
  132. package/dist/runtime/errors.d.ts +5 -0
  133. package/dist/runtime/ownership/RaphEffectScope.d.ts +29 -0
  134. package/dist/runtime/ownership/RaphNode.d.ts +40 -0
  135. package/dist/runtime/ownership/RaphScope.d.ts +38 -0
  136. package/dist/runtime/{parent-graph.d.ts → ownership/parent-graph.types.d.ts} +0 -1
  137. package/dist/runtime/ownership/parentGraph.d.ts +3 -0
  138. package/dist/runtime/phases/RaphPhasePipeline.d.ts +79 -0
  139. package/dist/runtime/phases/orderPhaseTasks.d.ts +6 -0
  140. package/dist/runtime/phases/phase.types.d.ts +92 -0
  141. package/dist/runtime/{PathHandle.d.ts → reactivity/PathHandle.d.ts} +14 -6
  142. package/dist/runtime/reactivity/RaphMetaSource.d.ts +32 -0
  143. package/dist/runtime/reactivity/RaphWorkGraph.d.ts +171 -0
  144. package/dist/runtime/{RuntimeReactivity.d.ts → reactivity/RuntimeReactivity.d.ts} +14 -9
  145. package/dist/runtime/{RuntimeWatch.d.ts → reactivity/RuntimeWatch.d.ts} +9 -3
  146. package/dist/runtime/{runtime-reactivity.types.d.ts → reactivity/runtime-reactivity.types.d.ts} +3 -1
  147. package/dist/runtime.cjs +1 -1
  148. package/dist/runtime.js +21 -16
  149. package/package.json +68 -35
  150. package/ReadMe.md +0 -153
  151. package/dist/api/public.d.ts +0 -22
  152. package/dist/debug/api/public.cjs +0 -1
  153. package/dist/debug/api/public.js +0 -40
  154. package/dist/debug/path/AdapterPathStore.cjs +0 -1
  155. package/dist/debug/path/DerivedRegistry.cjs +0 -1
  156. package/dist/debug/path/PathEventHub.cjs +0 -1
  157. package/dist/debug/path/PathStore.cjs +0 -1
  158. package/dist/debug/path/RaphMetaStore.cjs +0 -1
  159. package/dist/debug/path/data-adapter.cjs +0 -1
  160. package/dist/debug/path/data-path.cjs +0 -1
  161. package/dist/debug/path/derived-collection.cjs +0 -1
  162. package/dist/debug/path/path-router.cjs +0 -1
  163. package/dist/debug/path/public.cjs +0 -1
  164. package/dist/debug/path/public.js +0 -18
  165. package/dist/debug/runtime/PathHandle.cjs +0 -1
  166. package/dist/debug/runtime/RaphDebug.cjs +0 -1
  167. package/dist/debug/runtime/RaphDebug.js +0 -15
  168. package/dist/debug/runtime/RaphNode.cjs +0 -1
  169. package/dist/debug/runtime/RaphNode.js +0 -143
  170. package/dist/debug/runtime/RaphPhasePipeline.cjs +0 -1
  171. package/dist/debug/runtime/RaphPhasePipeline.js +0 -526
  172. package/dist/debug/runtime/RaphScope.cjs +0 -1
  173. package/dist/debug/runtime/RaphScope.js +0 -64
  174. package/dist/debug/runtime/RuntimeReactivity.cjs +0 -1
  175. package/dist/debug/runtime/RuntimeReactivity.js +0 -154
  176. package/dist/debug/runtime/RuntimeWatch.cjs +0 -1
  177. package/dist/debug/runtime/RuntimeWatch.js +0 -71
  178. package/dist/debug/runtime/public.cjs +0 -1
  179. package/dist/debug/runtime/public.js +0 -18
  180. package/dist/path/public.d.ts +0 -14
  181. package/dist/runtime/RaphDebug.d.ts +0 -32
  182. package/dist/runtime/RaphNode.d.ts +0 -68
  183. package/dist/runtime/RaphPhasePipeline.d.ts +0 -133
  184. package/dist/runtime/RaphScope.d.ts +0 -50
  185. package/dist/runtime/phase.types.d.ts +0 -49
  186. package/dist/runtime/public.d.ts +0 -13
  187. /package/dist/debug/path/{meta.types.cjs → data-path.types.cjs} +0 -0
  188. /package/dist/debug/path/{meta.types.js → data-path.types.js} +0 -0
  189. /package/dist/debug/path/{RaphDerivedHandle.cjs → derived/RaphDerivedHandle.cjs} +0 -0
  190. /package/dist/debug/path/{RaphDerivedHandle.js → derived/RaphDerivedHandle.js} +0 -0
  191. /package/dist/debug/{runtime/runtime-reactivity.types.cjs → path/derived/derived-collection.types.cjs} +0 -0
  192. /package/dist/debug/{runtime/runtime-reactivity.types.js → path/derived/derived-collection.types.js} +0 -0
  193. /package/dist/debug/path/{derived-strategies.cjs → derived/derived-strategy.utils.cjs} +0 -0
  194. /package/dist/debug/path/{derived-strategies.js → derived/derived-strategy.utils.js} +0 -0
  195. /package/dist/debug/path/{RaphMeta.cjs → meta/RaphMeta.cjs} +0 -0
  196. /package/dist/debug/path/{RaphMeta.js → meta/RaphMeta.js} +0 -0
  197. /package/dist/debug/path/{segment-key.cjs → pathSegmentKey.cjs} +0 -0
  198. /package/dist/debug/path/{segment-key.js → pathSegmentKey.js} +0 -0
  199. /package/dist/debug/path/{data-draft.cjs → storage/createDataDraft.cjs} +0 -0
  200. /package/dist/debug/path/{data-draft.js → storage/createDataDraft.js} +0 -0
  201. /package/dist/debug/runtime/{parent-graph.cjs → ownership/parentGraph.cjs} +0 -0
  202. /package/dist/debug/runtime/{parent-graph.js → ownership/parentGraph.js} +0 -0
  203. /package/dist/debug/runtime/{disposal.cjs → ownership/throwDisposalErrors.cjs} +0 -0
  204. /package/dist/debug/runtime/{disposal.js → ownership/throwDisposalErrors.js} +0 -0
  205. /package/dist/debug/runtime/{RaphFrameLoop.cjs → phases/RaphFrameLoop.cjs} +0 -0
  206. /package/dist/debug/runtime/{RaphFrameLoop.js → phases/RaphFrameLoop.js} +0 -0
  207. /package/dist/debug/runtime/{phase.types.cjs → phases/phase.types.cjs} +0 -0
  208. /package/dist/debug/runtime/{phase.types.js → phases/phase.types.js} +0 -0
  209. /package/dist/path/{data-draft.d.ts → storage/createDataDraft.d.ts} +0 -0
  210. /package/dist/runtime/{disposal.d.ts → ownership/throwDisposalErrors.d.ts} +0 -0
  211. /package/dist/runtime/{RaphFrameLoop.d.ts → phases/RaphFrameLoop.d.ts} +0 -0
@@ -1,526 +0,0 @@
1
- var w = Object.defineProperty;
2
- var k = (d, e, s) => e in d ? w(d, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : d[e] = s;
3
- var h = (d, e, s) => k(d, typeof e != "symbol" ? e + "" : e, s);
4
- import { DataPath as g, parseDataPath as b } from "../path/data-path.js";
5
- import { PathRouter as v } from "../path/path-router.js";
6
- const y = 1e4, P = () => {
7
- };
8
- class M {
9
- /**
10
- * Создаёт phase pipeline для runtime и его root node.
11
- */
12
- constructor(e, s, t, n, a = () => !1) {
13
- // Индексируют data observers и phase definitions.
14
- h(this, "_observerRouter");
15
- h(this, "_phaseRouter", new v());
16
- h(this, "_observers");
17
- h(this, "_stopKernel");
18
- h(this, "_phases", []);
19
- h(this, "_phaseByName", /* @__PURE__ */ new Map());
20
- // Хранят pending nodes, effect tasks и registration counters.
21
- h(this, "_pending", /* @__PURE__ */ new Map());
22
- h(this, "_tasks", /* @__PURE__ */ new Map());
23
- h(this, "_phaseBindings", /* @__PURE__ */ new Map());
24
- h(this, "_taskSequence", 0);
25
- // Управляют выбранным scheduler и текущим flush lifecycle.
26
- h(this, "_scheduled", !1);
27
- h(this, "_scheduleToken", 0);
28
- h(this, "_frameHandle");
29
- h(this, "_frameHandleKind");
30
- h(this, "_configurationLocked", !1);
31
- h(this, "_running", !1);
32
- h(this, "_disposed", !1);
33
- // Формируют immutable frame context для phase callbacks.
34
- h(this, "_firstFrameAt");
35
- h(this, "_lastFrameAt");
36
- h(this, "_frameNumber", 0);
37
- h(this, "_frame", Object.freeze({ now: 0, delta: 0, elapsed: 0, frame: 0 }));
38
- this._kernel = e, this._root = s, this._scheduler = t, this._runUntracked = n, this._deferSync = a;
39
- }
40
- /**
41
- * Возвращает последний frame context pipeline.
42
- */
43
- get frame() {
44
- return this._frame;
45
- }
46
- /**
47
- * Возвращает текущее упорядоченное определение phases.
48
- */
49
- get phases() {
50
- return this._phases.map((e) => e.phase);
51
- }
52
- /**
53
- * Заменяет полное определение phase pipeline до его первого выполнения.
54
- */
55
- definePhases(e) {
56
- if (this._assertAlive(), this._configurationLocked || this._firstFrameAt !== void 0)
57
- throw new Error("[Raph] Cannot redefine phases after phase pipeline execution has started.");
58
- const s = /* @__PURE__ */ new Map(), t = new v(), n = [];
59
- for (const a of e) {
60
- const r = a.name.trim();
61
- if (!r)
62
- throw new Error("[Raph] Phase name must not be empty.");
63
- if (s.has(r))
64
- throw new Error(`[Raph] Duplicate phase name "${r}".`);
65
- if (!R(a.traversal))
66
- throw new Error(`[Raph] Unsupported phase traversal "${String(a.traversal)}".`);
67
- if (!A(a.mode))
68
- throw new Error(`[Raph] Unsupported phase mode "${String(a.mode)}".`);
69
- if (a.each !== void 0 && typeof a.each != "function")
70
- throw new TypeError(`[Raph] Phase "${r}" each executor must be a function.`);
71
- if (a.all !== void 0 && typeof a.all != "function")
72
- throw new TypeError(`[Raph] Phase "${r}" all executor must be a function.`);
73
- if (a.each !== void 0 && a.all !== void 0)
74
- throw new TypeError(`[Raph] Phase "${r}" cannot define both each and all executors.`);
75
- const i = Object.freeze({
76
- ...a,
77
- name: r,
78
- mode: a.mode ?? "dirty",
79
- routes: Object.freeze([...a.routes ?? []])
80
- }), o = { phase: i };
81
- n.push(o), s.set(r, o);
82
- for (const l of i.routes)
83
- t.add(g.from(l)._asMask(), o);
84
- }
85
- this._assertRetainedPhases(s), this._phases = n, this._phaseByName = s, this._phaseRouter = t;
86
- }
87
- /**
88
- * Добавляет phase до первого выполнения pipeline.
89
- */
90
- addPhase(e) {
91
- this.definePhases([...this._phases.map((s) => s.phase), e]);
92
- }
93
- /**
94
- * Удаляет пользовательские phases до первого выполнения pipeline.
95
- */
96
- clearPhases() {
97
- this.definePhases([]);
98
- }
99
- /**
100
- * Возвращает phase либо отклоняет неизвестное имя.
101
- */
102
- requirePhase(e) {
103
- if (this._assertAlive(), !this._phaseByName.has(e))
104
- throw new Error(`[Raph] Phase "${e}" is not defined.`);
105
- }
106
- /**
107
- * Фиксирует phase definitions перед синхронным выполнением вне flush.
108
- */
109
- lockConfiguration() {
110
- this._assertAlive(), this._configurationLocked = !0;
111
- }
112
- /**
113
- * Удерживает определение фазы для idle registrations вне data observer/effect.
114
- */
115
- retainPhase(e) {
116
- this.requirePhase(e), this._phaseBindings.set(e, (this._phaseBindings.get(e) ?? 0) + 1);
117
- let s = !0;
118
- return () => {
119
- if (!s)
120
- return;
121
- s = !1;
122
- const t = (this._phaseBindings.get(e) ?? 1) - 1;
123
- t === 0 ? this._phaseBindings.delete(e) : this._phaseBindings.set(e, t);
124
- };
125
- }
126
- /**
127
- * Возвращает scheduler mode указанной phase.
128
- */
129
- phaseMode(e) {
130
- this._assertAlive();
131
- const s = this._phaseByName.get(e);
132
- if (s === void 0)
133
- throw new Error(`[Raph] Phase "${e}" is not defined.`);
134
- return s.phase.mode ?? "dirty";
135
- }
136
- /**
137
- * Связывает реактивный effect с phase scheduler.
138
- */
139
- registerEffect(e) {
140
- return this.requirePhase(e), P;
141
- }
142
- /**
143
- * Один раз связывает watcher с task и callback.
144
- * Повторные invalidations используют ту же task без hot-path поиска node и phase.
145
- */
146
- bindEffect(e, s, t, n) {
147
- const a = this.registerEffect(e), r = {
148
- active: !0,
149
- pending: !1,
150
- persistent: !0,
151
- priority: s,
152
- sequence: 0,
153
- run: t,
154
- node: n
155
- };
156
- return {
157
- schedule: () => {
158
- if (!r.active || r.pending || this._disposed || n != null && n.disposed)
159
- return;
160
- r.pending = !0, r.sequence = this._taskSequence++;
161
- let i = this._tasks.get(e);
162
- i === void 0 && (i = [], this._tasks.set(e, i)), i.push(r), this._schedule();
163
- },
164
- dispose: () => {
165
- if (!r.active)
166
- return;
167
- r.active = !1, r.pending = !1, a();
168
- const i = this._tasks.get(e);
169
- if (i !== void 0) {
170
- const o = i.indexOf(r);
171
- o !== -1 && i.splice(o, 1), i.length === 0 && this._tasks.delete(e);
172
- }
173
- this._hasPending() || this._cancelScheduled();
174
- }
175
- };
176
- }
177
- /**
178
- * Ставит уже зарегистрированный effect в очередь его phase.
179
- */
180
- queueEffect(e, s, t, n = !0) {
181
- this.requirePhase(e);
182
- const a = {
183
- active: !0,
184
- pending: !0,
185
- persistent: !1,
186
- priority: s,
187
- sequence: this._taskSequence++,
188
- run: t
189
- };
190
- let r = this._tasks.get(e);
191
- return r === void 0 && (r = [], this._tasks.set(e, r)), r.push(a), n && this._schedule(), () => {
192
- if (!a.active)
193
- return;
194
- a.active = !1;
195
- const i = this._tasks.get(e);
196
- if (i !== void 0) {
197
- const o = i.indexOf(a);
198
- o >= 0 && i.splice(o, 1), i.length === 0 && this._tasks.delete(e);
199
- }
200
- this._hasPending() || this._cancelScheduled();
201
- };
202
- }
203
- /**
204
- * Запрашивает выполнение pipeline согласно scheduler mode.
205
- */
206
- request() {
207
- this._assertAlive(), this._hasPending() && this._schedule();
208
- }
209
- /**
210
- * Ставит frame-driven обход всего дерева в очередь даже без reactive effect.
211
- */
212
- requestAlwaysPhases() {
213
- this._assertAlive();
214
- for (const e of this._phases) {
215
- const s = e.phase;
216
- if (s.mode !== "always" || s.traversal !== "all" || s.all === void 0)
217
- continue;
218
- let t = this._pending.get(s.name);
219
- t === void 0 && (t = /* @__PURE__ */ new Map(), this._pending.set(s.name, t)), u(t, this._root, []);
220
- }
221
- this._pending.size !== 0 && this._schedule();
222
- }
223
- /**
224
- * Регистрирует path observer в phase pipeline.
225
- */
226
- observeData(e, s, t) {
227
- const n = t.phase.trim();
228
- if (!this._phaseByName.has(n))
229
- throw new Error(`[Raph] Phase "${n}" is not defined.`);
230
- return this._addObserver(e, s, n, t);
231
- }
232
- /**
233
- * Регистрирует tracked executor указанной phase.
234
- */
235
- track(e, s, t) {
236
- return this._addObserver(e, s, void 0, t);
237
- }
238
- /**
239
- * Помечает node и зависимых владельцев как требующих выполнения.
240
- */
241
- invalidate(e, s) {
242
- this.requirePhase(s);
243
- let t = this._pending.get(s);
244
- t === void 0 && (t = /* @__PURE__ */ new Map(), this._pending.set(s, t)), u(t, e, []), this._schedule();
245
- }
246
- /**
247
- * Синхронно выполняет все готовые очереди pipeline.
248
- */
249
- flush() {
250
- var n;
251
- if (this._assertAlive(), this._cancelScheduled(), this._running || !this._hasPending())
252
- return;
253
- this._running = !0;
254
- const e = [], s = this._nextFrame();
255
- let t = 0;
256
- try {
257
- for (; this._hasPending() && !this._disposed; ) {
258
- if (++t > y) {
259
- this._pending.clear();
260
- for (const i of this._tasks.values())
261
- for (const o of i)
262
- o.active = !1;
263
- throw this._tasks.clear(), new Error("[Raph] Phase flush exceeded 10000 passes.");
264
- }
265
- const a = this._pending;
266
- this._pending = /* @__PURE__ */ new Map();
267
- const r = this._tasks;
268
- this._tasks = /* @__PURE__ */ new Map();
269
- for (const i of this._phases) {
270
- if (this._disposed)
271
- break;
272
- const o = i.phase.name, l = a.get(o);
273
- if (l !== void 0 && l.size !== 0) {
274
- const f = this._expandContexts(i.phase, l, s);
275
- if (i.phase.each !== void 0)
276
- for (const c of f) {
277
- if (this._disposed)
278
- break;
279
- if (!c.node.disposed)
280
- try {
281
- this._runUntracked(() => i.phase.each(c));
282
- } catch (p) {
283
- e.push(p);
284
- }
285
- }
286
- else if (i.phase.all !== void 0 && !this._disposed)
287
- try {
288
- this._runUntracked(() => i.phase.all(f));
289
- } catch (c) {
290
- e.push(c);
291
- }
292
- }
293
- if (this._disposed)
294
- break;
295
- const _ = r.get(o);
296
- if (!(_ === void 0 || _.length === 0)) {
297
- _.length > 1 && _.sort(
298
- (f, c) => c.priority - f.priority || f.sequence - c.sequence
299
- );
300
- for (const f of _) {
301
- if (this._disposed)
302
- break;
303
- if (!(!f.active || !f.pending || (n = f.node) != null && n.disposed)) {
304
- f.pending = !1, f.persistent || (f.active = !1);
305
- try {
306
- f.run();
307
- } catch (c) {
308
- e.push(c);
309
- }
310
- }
311
- }
312
- }
313
- }
314
- }
315
- } finally {
316
- this._running = !1;
317
- }
318
- if (e.length === 1)
319
- throw e[0];
320
- if (e.length > 1)
321
- throw new AggregateError(e, "[Raph] Multiple phase executors failed.");
322
- }
323
- /**
324
- * Останавливает scheduler и удаляет observers, tasks и phase definitions.
325
- */
326
- dispose() {
327
- var e;
328
- if (!this._disposed) {
329
- this._disposed = !0, this._cancelScheduled(), this._pending.clear();
330
- for (const s of this._tasks.values())
331
- for (const t of s)
332
- t.active = !1;
333
- if (this._tasks.clear(), this._phaseBindings.clear(), (e = this._stopKernel) == null || e.call(this), this._stopKernel = void 0, this._observers !== void 0) {
334
- for (const s of this._observers) {
335
- s.active = !1;
336
- for (const t of s.removeRoutes)
337
- t();
338
- }
339
- this._observers.clear(), this._observers = void 0;
340
- }
341
- this._observerRouter = void 0, this._phases = [], this._phaseByName.clear(), this._phaseRouter = new v();
342
- }
343
- }
344
- /**
345
- * Показывает наличие запланированной или выполняемой работы pipeline.
346
- * @internal
347
- */
348
- _debugPending() {
349
- return this._scheduled || this._running || this._hasPending();
350
- }
351
- _addObserver(e, s, t, n) {
352
- this._assertAlive();
353
- const a = Array.isArray(s) ? s : [s];
354
- if (a.length === 0)
355
- throw new TypeError("[Raph] Phase observer requires at least one mask.");
356
- const r = /* @__PURE__ */ new Map();
357
- for (const c of a) {
358
- const p = g.from(c, n)._asMask();
359
- r.set(p.canonical, p);
360
- }
361
- const i = this._observerRouter ?? (this._observerRouter = new v()), o = {
362
- active: !0,
363
- node: e,
364
- ...t === void 0 ? {} : { phase: t },
365
- removeRoutes: []
366
- }, l = [...r.values()].map((c) => i.add(c, o));
367
- o.removeRoutes = l;
368
- const _ = this._observers ?? (this._observers = /* @__PURE__ */ new Set());
369
- _.add(o), this._ensureKernelWatch();
370
- let f = !0;
371
- return () => {
372
- var c;
373
- if (f) {
374
- f = !1, o.active = !1;
375
- for (const p of o.removeRoutes)
376
- p();
377
- _.delete(o), _.size === 0 && (this._observers = void 0, this._observerRouter = void 0, (c = this._stopKernel) == null || c.call(this), this._stopKernel = void 0);
378
- }
379
- };
380
- }
381
- _ensureKernelWatch() {
382
- this._stopKernel ?? (this._stopKernel = this._kernel.watch("*", ({ events: e }) => {
383
- this._receive(e);
384
- }));
385
- }
386
- _assertRetainedPhases(e) {
387
- for (const s of this._phaseBindings.keys())
388
- if (!e.has(s))
389
- throw new Error(`[Raph] Cannot remove phase "${s}" while it is still bound.`);
390
- for (const s of this._observers ?? []) {
391
- const t = s.phase;
392
- if (s.active && t !== void 0 && !e.has(t))
393
- throw new Error(`[Raph] Cannot remove phase "${t}" while it is still observed.`);
394
- }
395
- for (const s of this._pending.keys())
396
- if (!e.has(s))
397
- throw new Error(`[Raph] Cannot remove phase "${s}" while it has pending work.`);
398
- for (const s of this._tasks.keys())
399
- if (!e.has(s))
400
- throw new Error(`[Raph] Cannot remove phase "${s}" while it has queued effects.`);
401
- }
402
- _receive(e) {
403
- if (this._disposed)
404
- return;
405
- const s = this._observerRouter;
406
- if (s !== void 0) {
407
- for (const t of e) {
408
- const n = t.path === "", a = n ? void 0 : b(t.path), r = n ? s.matchAll() : s.match(a.segments);
409
- for (const i of r) {
410
- if (!i.active || i.node.disposed)
411
- continue;
412
- if (i.phase !== void 0) {
413
- this._queue(i.phase, i.node, t);
414
- continue;
415
- }
416
- const o = n ? this._phaseRouter.matchAll() : this._phaseRouter.match(a.segments);
417
- for (const l of o)
418
- this._queue(l.phase.name, i.node, t);
419
- }
420
- }
421
- this._pending.size !== 0 && this._schedule();
422
- }
423
- }
424
- _queue(e, s, t) {
425
- if (!this._phaseByName.has(e))
426
- return;
427
- let n = this._pending.get(e);
428
- n === void 0 && (n = /* @__PURE__ */ new Map(), this._pending.set(e, n)), u(n, s, [t]);
429
- }
430
- _schedule() {
431
- if (this._running || this._scheduled || this._disposed)
432
- return;
433
- if (this._scheduler === "sync") {
434
- if (this._deferSync())
435
- return;
436
- this.flush();
437
- return;
438
- }
439
- this._scheduled = !0;
440
- const e = ++this._scheduleToken, s = () => {
441
- this._disposed || !this._scheduled || e !== this._scheduleToken || (this._scheduled = !1, this._frameHandle = void 0, this._frameHandleKind = void 0, this.flush());
442
- };
443
- if (this._scheduler === "microtask") {
444
- queueMicrotask(s);
445
- return;
446
- }
447
- typeof globalThis.requestAnimationFrame == "function" ? (this._frameHandleKind = "animation-frame", this._frameHandle = globalThis.requestAnimationFrame(s)) : (this._frameHandleKind = "timeout", this._frameHandle = setTimeout(s, 16));
448
- }
449
- _cancelScheduled() {
450
- var e;
451
- this._scheduled && (this._scheduled = !1, this._scheduleToken++, this._frameHandleKind === "animation-frame" && this._frameHandle !== void 0 ? (e = globalThis.cancelAnimationFrame) == null || e.call(globalThis, this._frameHandle) : this._frameHandleKind === "timeout" && this._frameHandle !== void 0 && clearTimeout(this._frameHandle), this._frameHandle = void 0, this._frameHandleKind = void 0);
452
- }
453
- _nextFrame() {
454
- var t;
455
- const e = ((t = globalThis.performance) == null ? void 0 : t.now()) ?? Date.now();
456
- if (this._firstFrameAt === void 0 || this._lastFrameAt === void 0)
457
- return this._firstFrameAt = e, this._lastFrameAt = e, this._frame = Object.freeze({ now: e, delta: 0, elapsed: 0, frame: 0 });
458
- this._frameNumber++;
459
- const s = Object.freeze({
460
- now: e,
461
- delta: Math.min(Math.max(e - this._lastFrameAt, 0), 100),
462
- elapsed: Math.max(e - this._firstFrameAt, 0),
463
- frame: this._frameNumber
464
- });
465
- return this._lastFrameAt = e, this._frame = s;
466
- }
467
- _hasPending() {
468
- return this._pending.size !== 0 || this._tasks.size !== 0;
469
- }
470
- _expandContexts(e, s, t) {
471
- const n = [...s.entries()].filter(([r]) => !r.disposed).sort(([r], [i]) => i.priority - r.priority), a = /* @__PURE__ */ new Map();
472
- if (e.traversal === "dirty-only")
473
- for (const [r, i] of n)
474
- u(a, r, i.events);
475
- else if (e.traversal === "dirty-and-down")
476
- for (const [r, i] of n)
477
- m(r, (o) => u(a, o, i.events));
478
- else if (e.traversal === "dirty-and-up")
479
- for (const [r, i] of n) {
480
- let o = r;
481
- for (; o !== null && o !== this._root; )
482
- u(a, o, i.events), o = o.parent;
483
- }
484
- else {
485
- const r = [], i = /* @__PURE__ */ new Set();
486
- for (const o of s.values())
487
- for (const l of o.events)
488
- i.has(l) || (i.add(l), r.push(l));
489
- for (const o of this._root.children)
490
- m(o, (l) => u(a, l, r));
491
- }
492
- return [...a].filter(([r]) => {
493
- var i;
494
- return ((i = e.nodes) == null ? void 0 : i.call(e, r)) ?? !0;
495
- }).map(([r, i]) => ({
496
- events: i.events,
497
- frame: t,
498
- node: r,
499
- phase: e.name
500
- }));
501
- }
502
- _assertAlive() {
503
- if (this._disposed)
504
- throw new Error("[Raph] Phase pipeline is disposed.");
505
- }
506
- }
507
- function u(d, e, s) {
508
- let t = d.get(e);
509
- t === void 0 && (t = { events: [], seen: /* @__PURE__ */ new Set() }, d.set(e, t));
510
- for (const n of s)
511
- t.seen.has(n) || (t.seen.add(n), t.events.push(n));
512
- }
513
- function m(d, e) {
514
- e(d);
515
- for (const s of d.children)
516
- m(s, e);
517
- }
518
- function R(d) {
519
- return d === "dirty-only" || d === "dirty-and-down" || d === "dirty-and-up" || d === "all";
520
- }
521
- function A(d) {
522
- return d === void 0 || d === "dirty" || d === "always";
523
- }
524
- export {
525
- M as RaphPhasePipeline
526
- };
@@ -1 +0,0 @@
1
- "use strict";var n=Object.defineProperty;var o=(s,i,t)=>i in s?n(s,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[i]=t;var h=(s,i,t)=>o(s,typeof i!="symbol"?i+"":i,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../reactivity/scope.cjs"),c=require("./errors.cjs");class d extends u.ScopeNode{constructor(t,e){super(e._getReactivity());h(this,"id");h(this,"runtime");this.id=t,this.runtime=e,e._registerOwner(this)}signal(t){return this._assertAlive(),this.runtime.signal(t,this)}computed(t){return this._assertAlive(),typeof t=="function"?this.runtime.computed(t,this):this.runtime.computed(t,this)}effect(t,e,r){return this._assertAlive(),typeof t=="string"?this.runtime.effect(t,e,r,this):this.runtime.effect(t,this)}watch(t,e,r){return this._assertAlive(),this.runtime.watch(t,e,r,this)}action(t,e){return this._assertAlive(),this.runtime.action(t,e,this)}_afterDispose(){this.runtime._unregisterOwner(this)}_disposalMessage(){return`[Raph] Scope "${this.id}" disposal failed.`}_assertAlive(){if(this._disposed||this._disposing)throw new c.RaphDisposedError(`[Raph] Owner "${this.id}" is disposed.`)}}exports.RaphScope=d;
@@ -1,64 +0,0 @@
1
- var o = Object.defineProperty;
2
- var n = (e, s, t) => s in e ? o(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t;
3
- var h = (e, s, t) => n(e, typeof s != "symbol" ? s + "" : s, t);
4
- import { ScopeNode as p } from "../reactivity/scope.js";
5
- import { RaphDisposedError as u } from "./errors.js";
6
- class m extends p {
7
- /**
8
- * Создаёт lifecycle scope внутри указанного runtime.
9
- */
10
- constructor(t, i) {
11
- super(i._getReactivity());
12
- // Публикуют identity scope и единственного runtime-owner.
13
- h(this, "id");
14
- h(this, "runtime");
15
- this.id = t, this.runtime = i, i._registerOwner(this);
16
- }
17
- /**
18
- * Создаёт writable signal, принадлежащий указанному owner.
19
- */
20
- signal(t) {
21
- return this._assertAlive(), this.runtime.signal(t, this);
22
- }
23
- computed(t) {
24
- return this._assertAlive(), typeof t == "function" ? this.runtime.computed(t, this) : this.runtime.computed(t, this);
25
- }
26
- effect(t, i, r) {
27
- return this._assertAlive(), typeof t == "string" ? this.runtime.effect(t, i, r, this) : this.runtime.effect(t, this);
28
- }
29
- /**
30
- * Подписывает callback и привязывает disposer к lifecycle scope.
31
- */
32
- watch(t, i, r) {
33
- return this._assertAlive(), this.runtime.watch(t, i, r, this);
34
- }
35
- /**
36
- * Создаёт action, выполнение которой привязано к lifecycle scope.
37
- */
38
- action(t, i) {
39
- return this._assertAlive(), this.runtime.action(t, i, this);
40
- }
41
- /**
42
- * Выполняет runtime cleanup после освобождения scope.
43
- */
44
- _afterDispose() {
45
- this.runtime._unregisterOwner(this);
46
- }
47
- /**
48
- * Возвращает диагностическое сообщение для освобождённого scope.
49
- */
50
- _disposalMessage() {
51
- return `[Raph] Scope "${this.id}" disposal failed.`;
52
- }
53
- /**
54
- * Запрещает операции после начала освобождения scope.
55
- * @internal
56
- */
57
- _assertAlive() {
58
- if (this._disposed || this._disposing)
59
- throw new u(`[Raph] Owner "${this.id}" is disposed.`);
60
- }
61
- }
62
- export {
63
- m as RaphScope
64
- };
@@ -1 +0,0 @@
1
- "use strict";var _=Object.defineProperty;var f=(u,e,i)=>e in u?_(u,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):u[e]=i;var a=(u,e,i)=>f(u,typeof e!="symbol"?e+"":e,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../reactivity/engine.cjs");let c;class o{constructor(){a(this,"_active")}bind(e){const i=this._active;if(i===void 0)return{schedule:e,dispose:b};const t=i.binding(e);if(i.initial==="scheduled")return t;let s=!0;return{dispose:t.dispose,schedule:()=>{if(!s){t.schedule();return}s=!1,e()}}}runWith(e,i,t){const s=this._active;this._active=e===void 0?void 0:{binding:e,initial:i};try{return t()}finally{this._active=s}}}class g extends p.RaphReactivity{constructor(i){const t=new o;super({effectScheduler:{bind:t.bind.bind(t)}});a(this,"_bindings");this._lifecycle=i,this._bindings=t}withEffectBinding(i,t,s){return this._bindings.runWith(i,t,s)}untrackedWithOwner(i){const t=c;c=void 0;try{return this.untracked(i)}finally{c=t}}getActiveOwner(){return c==null?void 0:c.owner}runWithOwner(i,t){const s=c;c=i;try{return t()}finally{c=s}}signalForOwner(i,t){const s=this._lifecycle,r=t===void 0?this.signal(i):t._adoptSource(this._ownedSignal(i)),v=s.assertWriteAllowed,h=s.runWrite??y;return v!==void 0?{get(){return l(s),t==null||t._assertAlive(),r.get()},peek(){return n(s),t==null||t._assertAlive(),r.peek()},set(d){t==null||t._assertAlive(),v(),h(()=>r.set(d))}}:{get(){return l(s),t==null||t._assertAlive(),r.get()},peek(){return n(s),t==null||t._assertAlive(),r.peek()},set(d){n(s),t==null||t._assertAlive(),h(()=>r.set(d))}}}computedForOwner(i,t){const s=this._lifecycle,r=t===void 0?this.computed(i):t._adoptSource(this._ownedComputed(i));return{get(){return l(s),t==null||t._assertAlive(),r.get()},peek(){return n(s),t==null||t._assertAlive(),r.peek()}}}}function n(u){u.owner===void 0&&u.throwDisposed()}function l(u){n(u);const e=c;e!==void 0&&e!==u&&u.throwCrossRuntime(e.owner)}function y(u){return u()}function b(){}exports.RuntimeReactivity=g;