@raphy-js/raph 1.0.0-dev.2

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 (139) hide show
  1. package/LICENSE +202 -0
  2. package/ReadMe.md +153 -0
  3. package/dist/api/Raph.d.ts +228 -0
  4. package/dist/api/errors.d.ts +20 -0
  5. package/dist/api/public.d.ts +22 -0
  6. package/dist/api/types.d.ts +25 -0
  7. package/dist/debug/api/Raph.cjs +1 -0
  8. package/dist/debug/api/Raph.js +419 -0
  9. package/dist/debug/api/errors.cjs +1 -0
  10. package/dist/debug/api/errors.js +14 -0
  11. package/dist/debug/api/public.cjs +1 -0
  12. package/dist/debug/api/public.js +40 -0
  13. package/dist/debug/api/types.cjs +1 -0
  14. package/dist/debug/api/types.js +1 -0
  15. package/dist/debug/path/AdapterPathStore.cjs +1 -0
  16. package/dist/debug/path/AdapterPathStore.js +133 -0
  17. package/dist/debug/path/DerivedRegistry.cjs +1 -0
  18. package/dist/debug/path/DerivedRegistry.js +157 -0
  19. package/dist/debug/path/MetaController.cjs +1 -0
  20. package/dist/debug/path/MetaController.js +214 -0
  21. package/dist/debug/path/PathEventHub.cjs +1 -0
  22. package/dist/debug/path/PathEventHub.js +148 -0
  23. package/dist/debug/path/PathStore.cjs +1 -0
  24. package/dist/debug/path/PathStore.js +326 -0
  25. package/dist/debug/path/RaphDerivedHandle.cjs +1 -0
  26. package/dist/debug/path/RaphDerivedHandle.js +125 -0
  27. package/dist/debug/path/RaphKernel.cjs +1 -0
  28. package/dist/debug/path/RaphKernel.js +636 -0
  29. package/dist/debug/path/RaphMeta.cjs +1 -0
  30. package/dist/debug/path/RaphMeta.js +68 -0
  31. package/dist/debug/path/RaphMetaStore.cjs +1 -0
  32. package/dist/debug/path/RaphMetaStore.js +184 -0
  33. package/dist/debug/path/data-adapter.cjs +1 -0
  34. package/dist/debug/path/data-adapter.js +356 -0
  35. package/dist/debug/path/data-draft.cjs +1 -0
  36. package/dist/debug/path/data-draft.js +71 -0
  37. package/dist/debug/path/data-path.cjs +1 -0
  38. package/dist/debug/path/data-path.js +423 -0
  39. package/dist/debug/path/derived-collection.cjs +1 -0
  40. package/dist/debug/path/derived-collection.js +179 -0
  41. package/dist/debug/path/derived-strategies.cjs +1 -0
  42. package/dist/debug/path/derived-strategies.js +20 -0
  43. package/dist/debug/path/meta.types.cjs +1 -0
  44. package/dist/debug/path/meta.types.js +1 -0
  45. package/dist/debug/path/path-router.cjs +1 -0
  46. package/dist/debug/path/path-router.js +86 -0
  47. package/dist/debug/path/path.types.cjs +1 -0
  48. package/dist/debug/path/path.types.js +1 -0
  49. package/dist/debug/path/public.cjs +1 -0
  50. package/dist/debug/path/public.js +18 -0
  51. package/dist/debug/path/segment-key.cjs +1 -0
  52. package/dist/debug/path/segment-key.js +12 -0
  53. package/dist/debug/reactivity/engine.cjs +1 -0
  54. package/dist/debug/reactivity/engine.js +1133 -0
  55. package/dist/debug/reactivity/scope.cjs +1 -0
  56. package/dist/debug/reactivity/scope.js +274 -0
  57. package/dist/debug/reactivity/types.cjs +1 -0
  58. package/dist/debug/reactivity/types.js +1 -0
  59. package/dist/debug/reactivity/watch.cjs +1 -0
  60. package/dist/debug/reactivity/watch.js +64 -0
  61. package/dist/debug/runtime/PathHandle.cjs +1 -0
  62. package/dist/debug/runtime/PathHandle.js +139 -0
  63. package/dist/debug/runtime/RaphDebug.cjs +1 -0
  64. package/dist/debug/runtime/RaphDebug.js +15 -0
  65. package/dist/debug/runtime/RaphFrameLoop.cjs +1 -0
  66. package/dist/debug/runtime/RaphFrameLoop.js +106 -0
  67. package/dist/debug/runtime/RaphNode.cjs +1 -0
  68. package/dist/debug/runtime/RaphNode.js +143 -0
  69. package/dist/debug/runtime/RaphPhasePipeline.cjs +1 -0
  70. package/dist/debug/runtime/RaphPhasePipeline.js +526 -0
  71. package/dist/debug/runtime/RaphRuntime.cjs +1 -0
  72. package/dist/debug/runtime/RaphRuntime.js +700 -0
  73. package/dist/debug/runtime/RaphScope.cjs +1 -0
  74. package/dist/debug/runtime/RaphScope.js +64 -0
  75. package/dist/debug/runtime/RuntimeReactivity.cjs +1 -0
  76. package/dist/debug/runtime/RuntimeReactivity.js +154 -0
  77. package/dist/debug/runtime/RuntimeWatch.cjs +1 -0
  78. package/dist/debug/runtime/RuntimeWatch.js +71 -0
  79. package/dist/debug/runtime/disposal.cjs +1 -0
  80. package/dist/debug/runtime/disposal.js +9 -0
  81. package/dist/debug/runtime/errors.cjs +1 -0
  82. package/dist/debug/runtime/errors.js +12 -0
  83. package/dist/debug/runtime/parent-graph.cjs +1 -0
  84. package/dist/debug/runtime/parent-graph.js +10 -0
  85. package/dist/debug/runtime/phase.types.cjs +1 -0
  86. package/dist/debug/runtime/phase.types.js +8 -0
  87. package/dist/debug/runtime/public.cjs +1 -0
  88. package/dist/debug/runtime/public.js +18 -0
  89. package/dist/debug/runtime/runtime-reactivity.types.cjs +1 -0
  90. package/dist/debug/runtime/runtime-reactivity.types.js +1 -0
  91. package/dist/index.cjs +1 -0
  92. package/dist/index.js +40 -0
  93. package/dist/path/AdapterPathStore.d.ts +45 -0
  94. package/dist/path/DerivedRegistry.d.ts +67 -0
  95. package/dist/path/MetaController.d.ts +85 -0
  96. package/dist/path/PathEventHub.d.ts +48 -0
  97. package/dist/path/PathStore.d.ts +51 -0
  98. package/dist/path/RaphDerivedHandle.d.ts +97 -0
  99. package/dist/path/RaphKernel.d.ts +166 -0
  100. package/dist/path/RaphMeta.d.ts +45 -0
  101. package/dist/path/RaphMetaStore.d.ts +45 -0
  102. package/dist/path/data-adapter.d.ts +78 -0
  103. package/dist/path/data-draft.d.ts +4 -0
  104. package/dist/path/data-path.d.ts +97 -0
  105. package/dist/path/derived-collection.d.ts +30 -0
  106. package/dist/path/derived-strategies.d.ts +15 -0
  107. package/dist/path/meta.types.d.ts +33 -0
  108. package/dist/path/path-router.d.ts +21 -0
  109. package/dist/path/path.types.d.ts +26 -0
  110. package/dist/path/public.d.ts +14 -0
  111. package/dist/path/segment-key.d.ts +2 -0
  112. package/dist/path.cjs +1 -0
  113. package/dist/path.js +18 -0
  114. package/dist/raph.cjs +1 -0
  115. package/dist/raph.js +40 -0
  116. package/dist/reactivity/engine.d.ts +379 -0
  117. package/dist/reactivity/scope.d.ts +146 -0
  118. package/dist/reactivity/types.d.ts +150 -0
  119. package/dist/reactivity/watch.d.ts +15 -0
  120. package/dist/reactivity.cjs +1 -0
  121. package/dist/reactivity.js +14 -0
  122. package/dist/runtime/PathHandle.d.ts +72 -0
  123. package/dist/runtime/RaphDebug.d.ts +32 -0
  124. package/dist/runtime/RaphFrameLoop.d.ts +51 -0
  125. package/dist/runtime/RaphNode.d.ts +68 -0
  126. package/dist/runtime/RaphPhasePipeline.d.ts +133 -0
  127. package/dist/runtime/RaphRuntime.d.ts +285 -0
  128. package/dist/runtime/RaphScope.d.ts +50 -0
  129. package/dist/runtime/RuntimeReactivity.d.ts +40 -0
  130. package/dist/runtime/RuntimeWatch.d.ts +28 -0
  131. package/dist/runtime/disposal.d.ts +1 -0
  132. package/dist/runtime/errors.d.ts +16 -0
  133. package/dist/runtime/parent-graph.d.ts +5 -0
  134. package/dist/runtime/phase.types.d.ts +49 -0
  135. package/dist/runtime/public.d.ts +13 -0
  136. package/dist/runtime/runtime-reactivity.types.d.ts +9 -0
  137. package/dist/runtime.cjs +1 -0
  138. package/dist/runtime.js +18 -0
  139. package/package.json +109 -0
@@ -0,0 +1 @@
1
+ "use strict";var d=Object.defineProperty;var l=(t,e,s)=>e in t?d(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var o=(t,e,s)=>l(t,typeof e!="symbol"?e+"":e,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class _{constructor(e){o(this,"scopeFirstChild");o(this,"scopeLastChild");o(this,"_resourceCount",0);o(this,"_sourceFinalizers");o(this,"_disposed",!1);o(this,"_disposing",!1);this.reactivity=e}get disposed(){return this._disposed}get active(){return!this._disposed&&!this._disposing}signal(e){this._assertAlive();const s=this._adoptSource(this.reactivity._ownedSignal(e));return{get:()=>(this._assertAlive(),s.get()),peek:()=>(this._assertAlive(),s.peek()),set:i=>{this._assertAlive(),s.set(i)}}}computed(e){this._assertAlive();const s=typeof e=="function"?e:e.get,i=this._adoptSource(this.reactivity._ownedComputed(s)),r={get:()=>(this._assertAlive(),i.get()),peek:()=>(this._assertAlive(),i.peek())};if(typeof e=="function")return r;let c=e.set;this._own(()=>{c=void 0});const n=r;return n.set=a=>{this._assertAlive(),c(a)},n}effect(e){return this._assertAlive(),this._adoptResource(this.reactivity.effect(e))}watch(e,s,i){return this._assertAlive(),this._adoptResource(this.reactivity.watch(e,s,i))}own(e){return this.active?this._own(e):(e(),v)}_debugResourceCount(){return this._resourceCount}_debugSourceCount(){var e;return((e=this._sourceFinalizers)==null?void 0:e.size)??0}dispose(){if(this._disposed)return;this._disposed=!0,this._disposing=!0;const e=[];try{for(;this.scopeLastChild!==void 0;)try{this.scopeLastChild.dispose()}catch(s){e.push(s)}this._finalizeSources(e)}finally{this._disposing=!1;try{this._afterDispose()}catch(s){e.push(s)}}p(e,this._disposalMessage())}_own(e){this._assertAlive();let s=e;const i={scopeParent:void 0,scopePrevious:void 0,scopeNext:void 0,dispose:()=>{const r=s;r!==void 0&&(s=void 0,h(i),--this._resourceCount,r())}};return u(this,i),++this._resourceCount,i.dispose}_adoptResource(e){try{return this._own(e)}catch(s){try{e()}catch(i){throw new AggregateError([s,i],"Resource registration and cleanup failed.")}throw s}}_adoptSource(e){try{this._ownSource(e.dispose)}catch(s){try{e.dispose()}catch(i){throw new AggregateError([s,i],"Source registration and cleanup failed.")}throw s}return e.source}_ownSource(e){this._assertAlive(),this._sourceFinalizers===void 0&&(this._sourceFinalizers=new Set),this._sourceFinalizers.add(e)}_assertAlive(){if(this._disposed||this._disposing)throw new Error("ScopeNode is disposed.")}_afterDispose(){}_disposalMessage(){return"ScopeNode disposal failed."}_finalizeSources(e){const s=this._sourceFinalizers;if(this._sourceFinalizers=void 0,s===void 0)return;let i=[...s].reverse();for(s.clear();i.length>0;){const r=[];let c=!1;for(const n of i)try{n()?c=!0:r.push(n)}catch(a){e.push(a),c=!0}if(!c)return;i=r}}}function u(t,e){const s=t.scopeLastChild;e.scopeParent=t,e.scopePrevious=s,e.scopeNext=void 0,s===void 0?t.scopeFirstChild=e:s.scopeNext=e,t.scopeLastChild=e}function h(t){const e=t.scopeParent;if(e===void 0)return;const s=t.scopePrevious,i=t.scopeNext;s===void 0?e.scopeFirstChild=i:s.scopeNext=i,i===void 0?e.scopeLastChild=s:i.scopePrevious=s,t.scopeParent=void 0,t.scopePrevious=void 0,t.scopeNext=void 0}function p(t,e){if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,e)}function v(){}exports.ScopeNode=_;exports.appendScopeChild=u;exports.detachScopeChild=h;exports.throwScopeErrors=p;
@@ -0,0 +1,274 @@
1
+ var u = Object.defineProperty;
2
+ var h = (t, e, s) => e in t ? u(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
3
+ var o = (t, e, s) => h(t, typeof e != "symbol" ? e + "" : e, s);
4
+ class f {
5
+ /**
6
+ * Связывает владельца с реактивным экземпляром без создания нового графа.
7
+ * @param reactivity Экземпляр, в котором создаются owned-ресурсы.
8
+ */
9
+ constructor(e) {
10
+ /**
11
+ * Первый зарегистрированный ресурс; не является ребёнком execution-дерева.
12
+ * @internal
13
+ */
14
+ o(this, "scopeFirstChild");
15
+ /**
16
+ * Последний ресурс, с которого начинается освобождение владельца.
17
+ * @internal
18
+ */
19
+ o(this, "scopeLastChild");
20
+ // Число активных записей owned-ресурсов; финализаторы источников считаются отдельно.
21
+ o(this, "_resourceCount", 0);
22
+ // Лениво создаваемое множество финализаторов owned-источников.
23
+ o(this, "_sourceFinalizers");
24
+ // Окончательное состояние владельца; устанавливается до пользовательских cleanup.
25
+ o(this, "_disposed", !1);
26
+ // Признак выполняющегося освобождения для проверок lifetime и наследников.
27
+ o(this, "_disposing", !1);
28
+ this.reactivity = e;
29
+ }
30
+ /**
31
+ * Показывает, началось ли окончательное освобождение владельца.
32
+ */
33
+ get disposed() {
34
+ return this._disposed;
35
+ }
36
+ /**
37
+ * Разрешает регистрацию и доступ только до начала освобождения.
38
+ */
39
+ get active() {
40
+ return !this._disposed && !this._disposing;
41
+ }
42
+ /**
43
+ * Создаёт owned signal и регистрирует его финализатор.
44
+ * Все методы возвращённого handle проверяют, что владелец ещё активен.
45
+ */
46
+ signal(e) {
47
+ this._assertAlive();
48
+ const s = this._adoptSource(this.reactivity._ownedSignal(e));
49
+ return {
50
+ get: () => (this._assertAlive(), s.get()),
51
+ peek: () => (this._assertAlive(), s.peek()),
52
+ set: (i) => {
53
+ this._assertAlive(), s.set(i);
54
+ }
55
+ };
56
+ }
57
+ /**
58
+ * Создаёт owned computed; getter освобождается при dispose владельца.
59
+ * Для writable computed отдельно освобождает захваченный setter.
60
+ */
61
+ computed(e) {
62
+ this._assertAlive();
63
+ const s = typeof e == "function" ? e : e.get, i = this._adoptSource(this.reactivity._ownedComputed(s)), r = {
64
+ get: () => (this._assertAlive(), i.get()),
65
+ peek: () => (this._assertAlive(), i.peek())
66
+ };
67
+ if (typeof e == "function")
68
+ return r;
69
+ let c = e.set;
70
+ this._own(() => {
71
+ c = void 0;
72
+ });
73
+ const n = r;
74
+ return n.set = (a) => {
75
+ this._assertAlive(), c(a);
76
+ }, n;
77
+ }
78
+ /**
79
+ * Создаёт эффект и принимает его disposer во владение.
80
+ * Если владелец уничтожен во время синхронного запуска, немедленно останавливает эффект.
81
+ */
82
+ effect(e) {
83
+ return this._assertAlive(), this._adoptResource(this.reactivity.effect(e));
84
+ }
85
+ /**
86
+ * Создаёт watch и регистрирует окончательную остановку у владельца.
87
+ */
88
+ watch(e, s, i) {
89
+ return this._assertAlive(), this._adoptResource(this.reactivity.watch(e, s, i));
90
+ }
91
+ /**
92
+ * Принимает произвольный cleanup и возвращает однократный disposer.
93
+ * Если владелец уже неактивен, выполняет cleanup сразу и возвращает пустой disposer.
94
+ */
95
+ own(e) {
96
+ return this.active ? this._own(e) : (e(), _);
97
+ }
98
+ /**
99
+ * Возвращает число ещё не освобождённых записей ресурсов.
100
+ * @internal
101
+ */
102
+ _debugResourceCount() {
103
+ return this._resourceCount;
104
+ }
105
+ /**
106
+ * Возвращает число зарегистрированных финализаторов источников.
107
+ * @internal
108
+ */
109
+ _debugSourceCount() {
110
+ var e;
111
+ return ((e = this._sourceFinalizers) == null ? void 0 : e.size) ?? 0;
112
+ }
113
+ /**
114
+ * Освобождает ресурсы в обратном порядке, затем финализирует источники.
115
+ * Повторный вызов безопасен. Ошибки cleanup и завершающего hook собираются
116
+ * и передаются только после завершения остальных стадий.
117
+ */
118
+ dispose() {
119
+ if (this._disposed)
120
+ return;
121
+ this._disposed = !0, this._disposing = !0;
122
+ const e = [];
123
+ try {
124
+ for (; this.scopeLastChild !== void 0; )
125
+ try {
126
+ this.scopeLastChild.dispose();
127
+ } catch (s) {
128
+ e.push(s);
129
+ }
130
+ this._finalizeSources(e);
131
+ } finally {
132
+ this._disposing = !1;
133
+ try {
134
+ this._afterDispose();
135
+ } catch (s) {
136
+ e.push(s);
137
+ }
138
+ }
139
+ l(e, this._disposalMessage());
140
+ }
141
+ /**
142
+ * Регистрирует ресурс только у активного владельца.
143
+ * Дочерняя запись отсоединяется до вызова cleanup, включая ошибочный и вложенный stop.
144
+ * В отличие от own(), не принимает регистрацию после dispose.
145
+ * @internal
146
+ */
147
+ _own(e) {
148
+ this._assertAlive();
149
+ let s = e;
150
+ const i = {
151
+ scopeParent: void 0,
152
+ scopePrevious: void 0,
153
+ scopeNext: void 0,
154
+ dispose: () => {
155
+ const r = s;
156
+ r !== void 0 && (s = void 0, d(i), --this._resourceCount, r());
157
+ }
158
+ };
159
+ return p(this, i), ++this._resourceCount, i.dispose;
160
+ }
161
+ /**
162
+ * Принимает уже созданный ресурс и не оставляет его без владельца при ошибке регистрации.
163
+ * При неудачной очистке сохраняет и ошибку регистрации, и ошибку освобождения.
164
+ * @internal
165
+ */
166
+ _adoptResource(e) {
167
+ try {
168
+ return this._own(e);
169
+ } catch (s) {
170
+ try {
171
+ e();
172
+ } catch (i) {
173
+ throw new AggregateError([s, i], "Resource registration and cleanup failed.");
174
+ }
175
+ throw s;
176
+ }
177
+ }
178
+ /**
179
+ * Регистрирует финализатор owned-источника и возвращает его handle.
180
+ * Если владелец уже недоступен, освобождает источник до передачи ошибки.
181
+ * @internal
182
+ */
183
+ _adoptSource(e) {
184
+ try {
185
+ this._ownSource(e.dispose);
186
+ } catch (s) {
187
+ try {
188
+ e.dispose();
189
+ } catch (i) {
190
+ throw new AggregateError([s, i], "Source registration and cleanup failed.");
191
+ }
192
+ throw s;
193
+ }
194
+ return e.source;
195
+ }
196
+ /**
197
+ * Добавляет финализатор источника. Возвращённый им false означает повторную попытку
198
+ * после прогресса других финализаторов, а не успешное освобождение.
199
+ * @internal
200
+ */
201
+ _ownSource(e) {
202
+ this._assertAlive(), this._sourceFinalizers === void 0 && (this._sourceFinalizers = /* @__PURE__ */ new Set()), this._sourceFinalizers.add(e);
203
+ }
204
+ /**
205
+ * Запрещает операции после начала освобождения владельца.
206
+ * Текст существующей ошибки сохранён для совместимости вызывающих слоёв.
207
+ * @internal
208
+ */
209
+ _assertAlive() {
210
+ if (this._disposed || this._disposing)
211
+ throw new Error("ScopeNode is disposed.");
212
+ }
213
+ /**
214
+ * Завершающий hook для наследников после ресурсов и источников.
215
+ * Базовая реализация ничего не делает; исключение наследника попадёт в общий результат.
216
+ */
217
+ _afterDispose() {
218
+ }
219
+ /**
220
+ * Возвращает сообщение для AggregateError при нескольких ошибках освобождения.
221
+ */
222
+ _disposalMessage() {
223
+ return "ScopeNode disposal failed.";
224
+ }
225
+ /**
226
+ * Освобождает источники в обратном порядке регистрации с повторными попытками.
227
+ * Если в проходе не было прогресса, прекращает обход, сохраняя существующий контракт.
228
+ * Исключение одного финализатора не блокирует остальные.
229
+ */
230
+ _finalizeSources(e) {
231
+ const s = this._sourceFinalizers;
232
+ if (this._sourceFinalizers = void 0, s === void 0)
233
+ return;
234
+ let i = [...s].reverse();
235
+ for (s.clear(); i.length > 0; ) {
236
+ const r = [];
237
+ let c = !1;
238
+ for (const n of i)
239
+ try {
240
+ n() ? c = !0 : r.push(n);
241
+ } catch (a) {
242
+ e.push(a), c = !0;
243
+ }
244
+ if (!c)
245
+ return;
246
+ i = r;
247
+ }
248
+ }
249
+ }
250
+ function p(t, e) {
251
+ const s = t.scopeLastChild;
252
+ e.scopeParent = t, e.scopePrevious = s, e.scopeNext = void 0, s === void 0 ? t.scopeFirstChild = e : s.scopeNext = e, t.scopeLastChild = e;
253
+ }
254
+ function d(t) {
255
+ const e = t.scopeParent;
256
+ if (e === void 0)
257
+ return;
258
+ const s = t.scopePrevious, i = t.scopeNext;
259
+ s === void 0 ? e.scopeFirstChild = i : s.scopeNext = i, i === void 0 ? e.scopeLastChild = s : i.scopePrevious = s, t.scopeParent = void 0, t.scopePrevious = void 0, t.scopeNext = void 0;
260
+ }
261
+ function l(t, e) {
262
+ if (t.length === 1)
263
+ throw t[0];
264
+ if (t.length > 1)
265
+ throw new AggregateError(t, e);
266
+ }
267
+ function _() {
268
+ }
269
+ export {
270
+ f as ScopeNode,
271
+ p as appendScopeChild,
272
+ d as detachScopeChild,
273
+ l as throwScopeErrors
274
+ };
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("./scope.cjs");function A(t,e,i,d,v={},f){const s=W(i);let l=!1,u,o,a=!1;function h(){if(a)return;a=!0;const n=o;o=void 0,n!==void 0&&e(n)}return t(()=>{if(a)return;const n=f===void 0?s():f(s),p=!l;if(!p&&m(n,u))return;const b=u;if(u=n,l=!0,p&&!v.immediate)return;const y=o;o=void 0;let c;if(y!==void 0)try{e(y)}catch(r){c=[r]}if(!a)try{const r=w(e(()=>d(n,b)));a?r!==void 0&&e(r):o=r}catch(r){c??(c=[]),c.push(r)}c!==void 0&&g.throwScopeErrors(c,"Watch callback and cleanup failed.")},h)}function W(t){if(Array.isArray(t))return()=>t.map(S);const e=t;return typeof e=="function"?e:()=>e.get()}function S(t){return typeof t=="function"?t():t.get()}function m(t,e){if(!Array.isArray(t)||!Array.isArray(e))return Object.is(t,e);if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!Object.is(t[i],e[i]))return!1;return!0}function w(t){return typeof t=="function"?t:void 0}exports.watchWithReactivity=A;
@@ -0,0 +1,64 @@
1
+ import { throwScopeErrors as m } from "./scope.js";
2
+ function C(t, e, i, y, h = {}, u) {
3
+ const l = W(i);
4
+ let s = !1, c, o, a = !1;
5
+ function v() {
6
+ if (a)
7
+ return;
8
+ a = !0;
9
+ const n = o;
10
+ o = void 0, n !== void 0 && e(n);
11
+ }
12
+ return t(() => {
13
+ if (a)
14
+ return;
15
+ const n = u === void 0 ? l() : u(l), p = !s;
16
+ if (!p && g(n, c))
17
+ return;
18
+ const A = c;
19
+ if (c = n, s = !0, p && !h.immediate)
20
+ return;
21
+ const d = o;
22
+ o = void 0;
23
+ let f;
24
+ if (d !== void 0)
25
+ try {
26
+ e(d);
27
+ } catch (r) {
28
+ f = [r];
29
+ }
30
+ if (!a)
31
+ try {
32
+ const r = w(e(() => y(n, A)));
33
+ a ? r !== void 0 && e(r) : o = r;
34
+ } catch (r) {
35
+ f ?? (f = []), f.push(r);
36
+ }
37
+ f !== void 0 && m(f, "Watch callback and cleanup failed.");
38
+ }, v);
39
+ }
40
+ function W(t) {
41
+ if (Array.isArray(t))
42
+ return () => t.map(b);
43
+ const e = t;
44
+ return typeof e == "function" ? e : () => e.get();
45
+ }
46
+ function b(t) {
47
+ return typeof t == "function" ? t() : t.get();
48
+ }
49
+ function g(t, e) {
50
+ if (!Array.isArray(t) || !Array.isArray(e))
51
+ return Object.is(t, e);
52
+ if (t.length !== e.length)
53
+ return !1;
54
+ for (let i = 0; i < t.length; i++)
55
+ if (!Object.is(t[i], e[i]))
56
+ return !1;
57
+ return !0;
58
+ }
59
+ function w(t) {
60
+ return typeof t == "function" ? t : void 0;
61
+ }
62
+ export {
63
+ C as watchWithReactivity
64
+ };
@@ -0,0 +1 @@
1
+ "use strict";var p=Object.defineProperty;var c=(r,s,t)=>s in r?p(r,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[s]=t;var e=(r,s,t)=>c(r,typeof s!="symbol"?s+"":s,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("../path/data-path.cjs"),u=require("./disposal.cjs"),k=require("./errors.cjs");class w{constructor(s,t,h,a,i,_,d,n,l){e(this,"path");e(this,"options");e(this,"_revision");e(this,"_disposeRevision");e(this,"_isTracking");e(this,"_store");e(this,"_release");e(this,"_masks");e(this,"_assertOwnerAlive");e(this,"_assertTrackedRead");e(this,"_assertWriteAllowed");e(this,"_runWrite");e(this,"_stop");e(this,"_disposed",!1);const o=i._ownedSignal(0);this._store=s,this._revision=o.source,this._disposeRevision=o.dispose,this._isTracking=i._isTracking,this.path=t.canonical,this.options=h,this._release=a,this._masks=v.pathRelationMasks(t),this._assertOwnerAlive=_,this._assertTrackedRead=d,this._assertWriteAllowed=n,this._runWrite=l}get disposed(){return this._disposed}get(){var s;return this._assertAlive(),(s=this._assertTrackedRead)==null||s.call(this),this._isTracking()?this._readTracked():this._store.peek(this.path)}peek(){return this._assertAlive(),this._store.peek(this.path)}set(s){var t;this._assertAlive(),(t=this._assertWriteAllowed)==null||t.call(this),this._write(()=>this._store.set(this.path,s))}merge(s){var t;this._assertAlive(),(t=this._assertWriteAllowed)==null||t.call(this),this._write(()=>this._store.merge(this.path,s))}delete(){var s;this._assertAlive(),(s=this._assertWriteAllowed)==null||s.call(this),this._write(()=>this._store.delete(this.path))}has(){return this._assertAlive(),this._store.has(this.path)}dispose(){if(this._disposed)return;this._disposed=!0;const s=[],t=this._stop;this._stop=void 0;const h=this._disposeRevision;this._disposeRevision=void 0;const a=this._release;this._release=void 0,this._revision=void 0,this._isTracking=void 0,this._store=void 0,this._assertOwnerAlive=void 0,this._assertTrackedRead=void 0,this._assertWriteAllowed=void 0,this._runWrite=void 0;try{t==null||t()}catch(i){s.push(i)}try{h==null||h()}catch(i){s.push(i)}try{a==null||a(this)}catch(i){s.push(i)}u.throwDisposalErrors(s,`[Raph] Path handle "${this.path}" disposal failed.`)}_getTracked(){var s;return this._assertAlive(),(s=this._assertTrackedRead)==null||s.call(this),this._readTracked()}_readTracked(){return this._observe(),this._revision.get(),this._store.get(this.path)}_observe(){this._stop??(this._stop=this._store.watch(this._masks,()=>{this._revision.set(this._revision.peek()+1)}))}_write(s){const t=this._runWrite;t===void 0?s():t(s)}_assertAlive(){var s;if(this._disposed)throw new k.RaphDisposedError(`[Raph] Path handle "${this.path}" is disposed.`);(s=this._assertOwnerAlive)==null||s.call(this)}}exports.PathHandle=w;
@@ -0,0 +1,139 @@
1
+ var l = Object.defineProperty;
2
+ var v = (r, s, t) => s in r ? l(r, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[s] = t;
3
+ var e = (r, s, t) => v(r, typeof s != "symbol" ? s + "" : s, t);
4
+ import { pathRelationMasks as c } from "../path/data-path.js";
5
+ import { throwDisposalErrors as k } from "./disposal.js";
6
+ import { RaphDisposedError as w } from "./errors.js";
7
+ class R {
8
+ /**
9
+ * Создаёт internal path handle и связывает его с runtime lifecycle.
10
+ * @internal
11
+ */
12
+ constructor(s, t, h, o, i, _, d, n, p) {
13
+ // Публикуют canonical path и нормализованные параметры handle.
14
+ e(this, "path");
15
+ e(this, "options");
16
+ // Связывают path revision с runtime reactivity и owning Kernel.
17
+ e(this, "_revision");
18
+ e(this, "_disposeRevision");
19
+ e(this, "_isTracking");
20
+ e(this, "_store");
21
+ e(this, "_release");
22
+ e(this, "_masks");
23
+ // Применяют runtime lifecycle и write policy к операциям handle.
24
+ e(this, "_assertOwnerAlive");
25
+ e(this, "_assertTrackedRead");
26
+ e(this, "_assertWriteAllowed");
27
+ e(this, "_runWrite");
28
+ // Хранят активную Kernel subscription и окончательное состояние handle.
29
+ e(this, "_stop");
30
+ e(this, "_disposed", !1);
31
+ const a = i._ownedSignal(0);
32
+ this._store = s, this._revision = a.source, this._disposeRevision = a.dispose, this._isTracking = i._isTracking, this.path = t.canonical, this.options = h, this._release = o, this._masks = c(t), this._assertOwnerAlive = _, this._assertTrackedRead = d, this._assertWriteAllowed = n, this._runWrite = p;
33
+ }
34
+ /**
35
+ * Показывает, освобождён ли path handle.
36
+ */
37
+ get disposed() {
38
+ return this._disposed;
39
+ }
40
+ /**
41
+ * Читает path с регистрацией реактивной зависимости.
42
+ */
43
+ get() {
44
+ var s;
45
+ return this._assertAlive(), (s = this._assertTrackedRead) == null || s.call(this), this._isTracking() ? this._readTracked() : this._store.peek(this.path);
46
+ }
47
+ /**
48
+ * Читает path без регистрации реактивной зависимости.
49
+ */
50
+ peek() {
51
+ return this._assertAlive(), this._store.peek(this.path);
52
+ }
53
+ /**
54
+ * Записывает значение path через runtime write policy.
55
+ */
56
+ set(s) {
57
+ var t;
58
+ this._assertAlive(), (t = this._assertWriteAllowed) == null || t.call(this), this._write(() => this._store.set(this.path, s));
59
+ }
60
+ /**
61
+ * Объединяет значение path через runtime write policy.
62
+ */
63
+ merge(s) {
64
+ var t;
65
+ this._assertAlive(), (t = this._assertWriteAllowed) == null || t.call(this), this._write(() => this._store.merge(this.path, s));
66
+ }
67
+ /**
68
+ * Удаляет значение path через runtime write policy.
69
+ */
70
+ delete() {
71
+ var s;
72
+ this._assertAlive(), (s = this._assertWriteAllowed) == null || s.call(this), this._write(() => this._store.delete(this.path));
73
+ }
74
+ /**
75
+ * Проверяет наличие значения path.
76
+ */
77
+ has() {
78
+ return this._assertAlive(), this._store.has(this.path);
79
+ }
80
+ /**
81
+ * Отсоединяет Kernel subscription и освобождает reactive revision handle.
82
+ */
83
+ dispose() {
84
+ if (this._disposed)
85
+ return;
86
+ this._disposed = !0;
87
+ const s = [], t = this._stop;
88
+ this._stop = void 0;
89
+ const h = this._disposeRevision;
90
+ this._disposeRevision = void 0;
91
+ const o = this._release;
92
+ this._release = void 0, this._revision = void 0, this._isTracking = void 0, this._store = void 0, this._assertOwnerAlive = void 0, this._assertTrackedRead = void 0, this._assertWriteAllowed = void 0, this._runWrite = void 0;
93
+ try {
94
+ t == null || t();
95
+ } catch (i) {
96
+ s.push(i);
97
+ }
98
+ try {
99
+ h == null || h();
100
+ } catch (i) {
101
+ s.push(i);
102
+ }
103
+ try {
104
+ o == null || o(this);
105
+ } catch (i) {
106
+ s.push(i);
107
+ }
108
+ k(s, `[Raph] Path handle "${this.path}" disposal failed.`);
109
+ }
110
+ /**
111
+ * Читает path с регистрацией runtime reactive dependency.
112
+ * @internal
113
+ */
114
+ _getTracked() {
115
+ var s;
116
+ return this._assertAlive(), (s = this._assertTrackedRead) == null || s.call(this), this._readTracked();
117
+ }
118
+ _readTracked() {
119
+ return this._observe(), this._revision.get(), this._store.get(this.path);
120
+ }
121
+ _observe() {
122
+ this._stop ?? (this._stop = this._store.watch(this._masks, () => {
123
+ this._revision.set(this._revision.peek() + 1);
124
+ }));
125
+ }
126
+ _write(s) {
127
+ const t = this._runWrite;
128
+ t === void 0 ? s() : t(s);
129
+ }
130
+ _assertAlive() {
131
+ var s;
132
+ if (this._disposed)
133
+ throw new w(`[Raph] Path handle "${this.path}" is disposed.`);
134
+ (s = this._assertOwnerAlive) == null || s.call(this);
135
+ }
136
+ }
137
+ export {
138
+ R as PathHandle
139
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./RaphNode.cjs");function c(e){const d=e instanceof t.RaphNode?e.children.map(c):[];return Object.freeze({id:e.id,kind:e instanceof t.RaphNode?"node":"scope",disposed:e.disposed,resources:e._debugResourceCount(),sources:e._debugSourceCount(),children:Object.freeze(d)})}exports.createOwnerSnapshot=c;
@@ -0,0 +1,15 @@
1
+ import { RaphNode as c } from "./RaphNode.js";
2
+ function s(e) {
3
+ const d = e instanceof c ? e.children.map(s) : [];
4
+ return Object.freeze({
5
+ id: e.id,
6
+ kind: e instanceof c ? "node" : "scope",
7
+ disposed: e.disposed,
8
+ resources: e._debugResourceCount(),
9
+ sources: e._debugSourceCount(),
10
+ children: Object.freeze(d)
11
+ });
12
+ }
13
+ export {
14
+ s as createOwnerSnapshot
15
+ };
@@ -0,0 +1 @@
1
+ "use strict";var a=Object.defineProperty;var r=(n,e,i)=>e in n?a(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i;var s=(n,e,i)=>r(n,typeof e!="symbol"?e+"":e,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class l{constructor(e){s(this,"_leases",new Map);s(this,"_frameHandle");s(this,"_frameHandleKind");s(this,"_scheduleToken",0);s(this,"_running",!1);s(this,"_manual",!1);this._tick=e}get running(){return this._running}acquire(e){this._leases.set(e,(this._leases.get(e)??0)+1),this._ensureRunning();let i=!0;return{owner:e,release:()=>{if(!i)return;i=!1;const t=this._leases.get(e)??0;t<=1?this._leases.delete(e):this._leases.set(e,t-1),this._reconcile()}}}start(){this._manual=!0,this._ensureRunning()}stop(){this._manual=!1,this._reconcile()}dispose(){this._manual=!1,this._leases.clear(),this._stop()}_debugState(){let e=0;for(const i of this._leases.values())e+=i;return{running:this._running,manual:this._manual,leases:e}}_onFrame(e){if(!(!this._running||e!==this._scheduleToken)){this._frameHandle=void 0,this._frameHandleKind=void 0;try{this._tick()}catch(i){throw this._running=!1,i}this._running&&this._schedule()}}_ensureRunning(){this._running||(this._running=!0,this._schedule())}_schedule(){const e=++this._scheduleToken;if(typeof globalThis.requestAnimationFrame=="function"){this._frameHandleKind="animation-frame",this._frameHandle=globalThis.requestAnimationFrame(()=>this._onFrame(e));return}this._frameHandleKind="timeout",this._frameHandle=setTimeout(()=>this._onFrame(e),16)}_reconcile(){if(this._manual||this._leases.size!==0){this._ensureRunning();return}this._stop()}_stop(){var e;this._running=!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}}exports.RaphFrameLoop=l;
@@ -0,0 +1,106 @@
1
+ var a = Object.defineProperty;
2
+ var r = (n, e, i) => e in n ? a(n, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : n[e] = i;
3
+ var s = (n, e, i) => r(n, typeof e != "symbol" ? e + "" : e, i);
4
+ class h {
5
+ /**
6
+ * Создаёт frame-loop, который запрашивает выполнение runtime pipeline.
7
+ */
8
+ constructor(e) {
9
+ // Хранят leases и текущую browser/timeout frame registration.
10
+ s(this, "_leases", /* @__PURE__ */ new Map());
11
+ s(this, "_frameHandle");
12
+ s(this, "_frameHandleKind");
13
+ s(this, "_scheduleToken", 0);
14
+ // Различают фактический loop lifecycle и ручной lease.
15
+ s(this, "_running", !1);
16
+ s(this, "_manual", !1);
17
+ this._tick = e;
18
+ }
19
+ /**
20
+ * Показывает, выполняется ли автоматический frame-loop.
21
+ */
22
+ get running() {
23
+ return this._running;
24
+ }
25
+ /**
26
+ * Получает lease, удерживающий автоматический frame-loop активным.
27
+ */
28
+ acquire(e) {
29
+ this._leases.set(e, (this._leases.get(e) ?? 0) + 1), this._ensureRunning();
30
+ let i = !0;
31
+ return {
32
+ owner: e,
33
+ release: () => {
34
+ if (!i)
35
+ return;
36
+ i = !1;
37
+ const t = this._leases.get(e) ?? 0;
38
+ t <= 1 ? this._leases.delete(e) : this._leases.set(e, t - 1), this._reconcile();
39
+ }
40
+ };
41
+ }
42
+ /**
43
+ * Запускает manual lease frame-loop.
44
+ */
45
+ start() {
46
+ this._manual = !0, this._ensureRunning();
47
+ }
48
+ /**
49
+ * Останавливает manual lease, не затрагивая внешние leases.
50
+ */
51
+ stop() {
52
+ this._manual = !1, this._reconcile();
53
+ }
54
+ /**
55
+ * Снимает все leases и отменяет запланированный frame callback.
56
+ */
57
+ dispose() {
58
+ this._manual = !1, this._leases.clear(), this._stop();
59
+ }
60
+ /**
61
+ * Возвращает внутреннее состояние frame-loop для диагностики.
62
+ * @internal
63
+ */
64
+ _debugState() {
65
+ let e = 0;
66
+ for (const i of this._leases.values())
67
+ e += i;
68
+ return { running: this._running, manual: this._manual, leases: e };
69
+ }
70
+ _onFrame(e) {
71
+ if (!(!this._running || e !== this._scheduleToken)) {
72
+ this._frameHandle = void 0, this._frameHandleKind = void 0;
73
+ try {
74
+ this._tick();
75
+ } catch (i) {
76
+ throw this._running = !1, i;
77
+ }
78
+ this._running && this._schedule();
79
+ }
80
+ }
81
+ _ensureRunning() {
82
+ this._running || (this._running = !0, this._schedule());
83
+ }
84
+ _schedule() {
85
+ const e = ++this._scheduleToken;
86
+ if (typeof globalThis.requestAnimationFrame == "function") {
87
+ this._frameHandleKind = "animation-frame", this._frameHandle = globalThis.requestAnimationFrame(() => this._onFrame(e));
88
+ return;
89
+ }
90
+ this._frameHandleKind = "timeout", this._frameHandle = setTimeout(() => this._onFrame(e), 16);
91
+ }
92
+ _reconcile() {
93
+ if (this._manual || this._leases.size !== 0) {
94
+ this._ensureRunning();
95
+ return;
96
+ }
97
+ this._stop();
98
+ }
99
+ _stop() {
100
+ var e;
101
+ this._running = !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;
102
+ }
103
+ }
104
+ export {
105
+ h as RaphFrameLoop
106
+ };
@@ -0,0 +1 @@
1
+ "use strict";var d=Object.defineProperty;var _=(s,i,e)=>i in s?d(s,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[i]=e;var n=(s,i,e)=>_(s,typeof i!="symbol"?i+"":i,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./disposal.cjs"),c=require("./errors.cjs"),m=require("./RaphScope.cjs");let y=0;class h extends m.RaphScope{constructor(e,t={},o){const a=o??(e instanceof h?e.runtime:e??void 0);if(a===void 0)throw new Error("[RaphNode] A root node requires an explicit runtime.");const r=e instanceof h?e:(e==null?void 0:e.root)??null;super(t.id??`node-${y++}`,a);n(this,"priority");n(this,"_parent");n(this,"_children",[]);n(this,"api");n(this,"meta");n(this,"type");if(r!==null&&r.runtime!==a)throw super.dispose(),new c.RaphCrossRuntimeError("[Raph] Parent belongs to another runtime.");try{r==null||r._assertAlive()}catch(p){throw super.dispose(),p}const u=t.priority??0;l(u),this.priority=u,this._parent=r,this.meta={...t.meta},this.type=t.type??"default",this.api=Object.freeze({}),r==null||r._children.push(this)}get parent(){return this._parent}get children(){return this._children}addChild(e){if(this._assertAlive(),e._assertAlive(),e.runtime!==this.runtime)throw new c.RaphCrossRuntimeError("[Raph] Child belongs to another runtime.");if(this===e)throw new Error("[Raph] A node cannot become its own ancestor.");for(let t=this._parent;t!==null;t=t.parent)if(t===e)throw new Error("[Raph] A node cannot become its own ancestor.");if(e.parent===this)return!0;if(e._parent!==null){const t=e._parent._children,o=t.indexOf(e);o>=0&&t.splice(o,1)}return e._parent=this,this._children.push(e),!0}options(e){this._assertAlive(),e.meta!==void 0&&(this.meta={...e.meta}),e.priority!==void 0&&(l(e.priority),this.priority=e.priority),e.type!==void 0&&(this.type=e.type)}dirty(e){this._assertAlive(),this.runtime.invalidateNode(this,e)}remove(){this.dispose()}dispose(){if(this._disposed||this._disposing)return;this._disposing=!0;const e=[];for(const t of[...this._children])try{t.dispose()}catch(o){e.push(o)}if(this._children.length=0,this._parent!==null){const t=this._parent._children.indexOf(this);t>=0&&this._parent._children.splice(t,1)}this._parent=null;try{super.dispose()}catch(t){e.push(t)}f.throwDisposalErrors(e,`[Raph] Node "${this.id}" disposal failed.`)}observeData(e,t){return this._assertAlive(),this.runtime.observeData(this,e,t)}track(e,t={}){return this._assertAlive(),this.runtime.track(this,e,t)}_setApi(e){const t=typeof e=="object"&&e!==null?Object.freeze(e):e;Object.defineProperty(this,"api",{configurable:!1,enumerable:!0,value:t,writable:!1})}}function l(s){if(!Number.isFinite(s))throw new TypeError("[Raph] Node priority must be finite.")}exports.RaphNode=h;