@raphy-js/raph 1.0.0-dev.2 → 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 (246) 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-CClhT8WR.js +1044 -0
  8. package/dist/core-cPQWYD4K.cjs +1 -0
  9. package/dist/debug/api/Raph.cjs +1 -1
  10. package/dist/debug/api/Raph.js +368 -367
  11. package/dist/debug/api/RaphFacadeSession.cjs +1 -0
  12. package/dist/debug/api/RaphFacadeSession.js +302 -0
  13. package/dist/debug/api/RaphReactivityInstance.cjs +1 -0
  14. package/dist/debug/api/RaphReactivityInstance.js +146 -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/DataPath.js +390 -0
  19. package/dist/debug/path/PathRouter.cjs +1 -0
  20. package/dist/debug/path/PathRouter.js +80 -0
  21. package/dist/debug/path/RaphKernel.cjs +1 -1
  22. package/dist/debug/path/RaphKernel.js +316 -236
  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/derived/DerivedRegistry.js +143 -0
  27. package/dist/debug/path/derived/RaphDerivedHandle.cjs +1 -0
  28. package/dist/debug/path/{RaphDerivedHandle.js → derived/RaphDerivedHandle.js} +19 -22
  29. package/dist/debug/path/derived/derived-collection.utils.cjs +1 -0
  30. package/dist/debug/path/{derived-collection.js → derived/derived-collection.utils.js} +71 -71
  31. package/dist/debug/path/derived/derived-strategy.types.cjs +1 -0
  32. package/dist/debug/path/derived/derived-strategy.types.js +1 -0
  33. package/dist/debug/path/meta/MetaController.cjs +1 -0
  34. package/dist/debug/path/{MetaController.js → meta/MetaController.js} +58 -66
  35. package/dist/debug/path/meta/RaphMeta.cjs +1 -0
  36. package/dist/debug/path/meta/RaphMeta.js +62 -0
  37. package/dist/debug/path/meta/RaphMetaStore.cjs +1 -0
  38. package/dist/debug/path/{RaphMetaStore.js → meta/RaphMetaStore.js} +24 -30
  39. package/dist/debug/path/meta/meta.types.cjs +1 -0
  40. package/dist/debug/path/meta/meta.types.js +1 -0
  41. package/dist/debug/path/storage/AdapterPathStore.cjs +1 -0
  42. package/dist/debug/path/storage/AdapterPathStore.js +128 -0
  43. package/dist/debug/path/storage/DefaultDataAdapter.cjs +1 -0
  44. package/dist/debug/path/{data-adapter.js → storage/DefaultDataAdapter.js} +47 -57
  45. package/dist/debug/path/storage/PathEventHub.cjs +1 -0
  46. package/dist/debug/path/storage/PathEventHub.js +161 -0
  47. package/dist/debug/path/storage/PathStore.cjs +1 -0
  48. package/dist/debug/path/{PathStore.js → storage/PathStore.js} +88 -98
  49. package/dist/debug/path/storage/createDataDraft.cjs +1 -0
  50. package/dist/debug/path/{data-draft.js → storage/createDataDraft.js} +24 -28
  51. package/dist/debug/path/storage/data-adapter.types.cjs +1 -0
  52. package/dist/debug/path/storage/data-adapter.types.js +1 -0
  53. package/dist/debug/reactivity/disposal.cjs +1 -0
  54. package/dist/debug/reactivity/disposal.js +32 -0
  55. package/dist/debug/reactivity/engine.cjs +1 -1
  56. package/dist/debug/reactivity/engine.js +888 -321
  57. package/dist/debug/reactivity/reactive-object.cjs +1 -0
  58. package/dist/debug/reactivity/reactive-object.js +265 -0
  59. package/dist/debug/reactivity/scope.cjs +1 -1
  60. package/dist/debug/reactivity/scope.js +221 -117
  61. package/dist/debug/reactivity/watch.cjs +1 -1
  62. package/dist/debug/reactivity/watch.js +1 -1
  63. package/dist/debug/runtime/RaphRuntime.cjs +1 -1
  64. package/dist/debug/runtime/RaphRuntime.js +1134 -502
  65. package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -0
  66. package/dist/debug/runtime/diagnostics/RaphDebug.js +287 -0
  67. package/dist/debug/runtime/errors.cjs +1 -1
  68. package/dist/debug/runtime/errors.js +6 -3
  69. package/dist/debug/runtime/ownership/RaphEffectScope.cjs +1 -0
  70. package/dist/debug/runtime/ownership/RaphEffectScope.js +304 -0
  71. package/dist/debug/runtime/ownership/RaphNode.cjs +1 -0
  72. package/dist/debug/runtime/ownership/RaphNode.js +665 -0
  73. package/dist/debug/runtime/ownership/RaphScope.cjs +1 -0
  74. package/dist/debug/runtime/ownership/RaphScope.js +236 -0
  75. package/dist/debug/runtime/ownership/parent-graph.types.cjs +1 -0
  76. package/dist/debug/runtime/ownership/parent-graph.types.js +1 -0
  77. package/dist/debug/runtime/phases/RaphFrameLoop.cjs +1 -0
  78. package/dist/debug/runtime/{RaphFrameLoop.js → phases/RaphFrameLoop.js} +13 -17
  79. package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -0
  80. package/dist/debug/runtime/phases/RaphPhasePipeline.js +848 -0
  81. package/dist/debug/runtime/phases/RaphPhaseTaskRecord.cjs +1 -0
  82. package/dist/debug/runtime/phases/RaphPhaseTaskRecord.js +176 -0
  83. package/dist/debug/runtime/phases/RaphPhaseWatch.cjs +1 -0
  84. package/dist/debug/runtime/phases/RaphPhaseWatch.js +20 -0
  85. package/dist/debug/runtime/phases/orderPhaseTasks.cjs +1 -0
  86. package/dist/debug/runtime/phases/orderPhaseTasks.js +59 -0
  87. package/dist/debug/runtime/reactivity/PathHandle.cjs +1 -0
  88. package/dist/debug/runtime/reactivity/PathHandle.js +165 -0
  89. package/dist/debug/runtime/reactivity/RaphMetaSource.cjs +1 -0
  90. package/dist/debug/runtime/reactivity/RaphMetaSource.js +108 -0
  91. package/dist/debug/runtime/reactivity/RaphSelector.cjs +1 -0
  92. package/dist/debug/runtime/reactivity/RaphSelector.js +503 -0
  93. package/dist/debug/runtime/reactivity/RaphWorkGraph.cjs +1 -0
  94. package/dist/debug/runtime/reactivity/RaphWorkGraph.js +1157 -0
  95. package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -0
  96. package/dist/debug/runtime/reactivity/RuntimeReactivity.js +550 -0
  97. package/dist/debug/runtime/reactivity/RuntimeWatch.cjs +1 -0
  98. package/dist/debug/runtime/reactivity/RuntimeWatch.js +77 -0
  99. package/dist/debug/runtime/reactivity/disposal-sweep.utils.cjs +1 -0
  100. package/dist/debug/runtime/reactivity/disposal-sweep.utils.js +42 -0
  101. package/dist/debug/runtime/reactivity/runtime-reactivity.types.cjs +1 -0
  102. package/dist/debug/runtime/reactivity/runtime-reactivity.types.js +1 -0
  103. package/dist/entrypoints/machine-testing.d.ts +2 -0
  104. package/dist/entrypoints/machine.d.ts +5 -0
  105. package/dist/entrypoints/path.d.ts +14 -0
  106. package/dist/entrypoints/reactivity.d.ts +1 -0
  107. package/dist/entrypoints/runtime.d.ts +18 -0
  108. package/dist/index.cjs +1 -1
  109. package/dist/index.js +46 -38
  110. package/dist/machine/compiler.d.ts +71 -0
  111. package/dist/machine/core.d.ts +50 -0
  112. package/dist/machine/persistence.d.ts +5 -0
  113. package/dist/machine/runtime.d.ts +4 -0
  114. package/dist/machine/testing.d.ts +43 -0
  115. package/dist/machine/types.d.ts +155 -0
  116. package/dist/machine-testing.cjs +1 -0
  117. package/dist/machine-testing.js +188 -0
  118. package/dist/machine.cjs +1 -0
  119. package/dist/machine.js +822 -0
  120. package/dist/main.d.ts +20 -0
  121. package/dist/path/{data-path.d.ts → DataPath.d.ts} +16 -40
  122. package/dist/path/{path-router.d.ts → PathRouter.d.ts} +1 -1
  123. package/dist/path/RaphKernel.d.ts +37 -10
  124. package/dist/path/data-path.types.d.ts +34 -0
  125. package/dist/path/data-path.utils.d.ts +9 -0
  126. package/dist/path/{DerivedRegistry.d.ts → derived/DerivedRegistry.d.ts} +2 -2
  127. package/dist/path/{RaphDerivedHandle.d.ts → derived/RaphDerivedHandle.d.ts} +3 -3
  128. package/dist/path/derived/derived-collection.types.d.ts +12 -0
  129. package/dist/path/{derived-collection.d.ts → derived/derived-collection.utils.d.ts} +3 -13
  130. package/dist/path/{derived-strategies.d.ts → derived/derived-strategy.types.d.ts} +0 -3
  131. package/dist/path/derived/derived-strategy.utils.d.ts +4 -0
  132. package/dist/path/{MetaController.d.ts → meta/MetaController.d.ts} +4 -4
  133. package/dist/path/{RaphMeta.d.ts → meta/RaphMeta.d.ts} +2 -2
  134. package/dist/path/{RaphMetaStore.d.ts → meta/RaphMetaStore.d.ts} +1 -1
  135. package/dist/path/{meta.types.d.ts → meta/meta.types.d.ts} +2 -4
  136. package/dist/path/path.types.d.ts +3 -2
  137. package/dist/path/{segment-key.d.ts → pathSegmentKey.d.ts} +1 -1
  138. package/dist/path/{AdapterPathStore.d.ts → storage/AdapterPathStore.d.ts} +4 -4
  139. package/dist/path/{data-adapter.d.ts → storage/DefaultDataAdapter.d.ts} +2 -17
  140. package/dist/path/storage/PathEventHub.d.ts +62 -0
  141. package/dist/path/{PathStore.d.ts → storage/PathStore.d.ts} +7 -7
  142. package/dist/path/storage/data-adapter.types.d.ts +17 -0
  143. package/dist/path.cjs +1 -1
  144. package/dist/path.js +16 -16
  145. package/dist/raph.cjs +1 -1
  146. package/dist/raph.js +46 -38
  147. package/dist/reactivity/disposal.d.ts +14 -0
  148. package/dist/reactivity/engine.d.ts +193 -6
  149. package/dist/reactivity/reactive-object.d.ts +36 -0
  150. package/dist/reactivity/scope.d.ts +108 -30
  151. package/dist/reactivity/types.d.ts +25 -0
  152. package/dist/reactivity.cjs +1 -1
  153. package/dist/reactivity.js +12 -12
  154. package/dist/runtime/RaphRuntime.d.ts +319 -160
  155. package/dist/runtime/diagnostics/RaphDebug.d.ts +239 -0
  156. package/dist/runtime/errors.d.ts +5 -0
  157. package/dist/runtime/ownership/RaphEffectScope.d.ts +98 -0
  158. package/dist/runtime/ownership/RaphNode.d.ts +310 -0
  159. package/dist/runtime/ownership/RaphScope.d.ts +168 -0
  160. package/dist/runtime/{parent-graph.d.ts → ownership/parent-graph.types.d.ts} +0 -1
  161. package/dist/runtime/ownership/parentGraph.d.ts +3 -0
  162. package/dist/runtime/phases/RaphPhasePipeline.d.ts +253 -0
  163. package/dist/runtime/phases/RaphPhaseTaskRecord.d.ts +195 -0
  164. package/dist/runtime/phases/RaphPhaseWatch.d.ts +22 -0
  165. package/dist/runtime/phases/orderPhaseTasks.d.ts +6 -0
  166. package/dist/runtime/phases/phase.types.d.ts +171 -0
  167. package/dist/runtime/{PathHandle.d.ts → reactivity/PathHandle.d.ts} +14 -6
  168. package/dist/runtime/reactivity/RaphMetaSource.d.ts +32 -0
  169. package/dist/runtime/reactivity/RaphSelector.d.ts +338 -0
  170. package/dist/runtime/reactivity/RaphWorkGraph.d.ts +309 -0
  171. package/dist/runtime/reactivity/RuntimeReactivity.d.ts +293 -0
  172. package/dist/runtime/{RuntimeWatch.d.ts → reactivity/RuntimeWatch.d.ts} +12 -6
  173. package/dist/runtime/reactivity/disposal-sweep.utils.d.ts +19 -0
  174. package/dist/runtime/reactivity/runtime-reactivity.types.d.ts +56 -0
  175. package/dist/runtime.cjs +1 -1
  176. package/dist/runtime.js +21 -16
  177. package/package.json +76 -35
  178. package/ReadMe.md +0 -153
  179. package/dist/api/public.d.ts +0 -22
  180. package/dist/debug/api/public.cjs +0 -1
  181. package/dist/debug/api/public.js +0 -40
  182. package/dist/debug/path/AdapterPathStore.cjs +0 -1
  183. package/dist/debug/path/AdapterPathStore.js +0 -133
  184. package/dist/debug/path/DerivedRegistry.cjs +0 -1
  185. package/dist/debug/path/DerivedRegistry.js +0 -157
  186. package/dist/debug/path/MetaController.cjs +0 -1
  187. package/dist/debug/path/PathEventHub.cjs +0 -1
  188. package/dist/debug/path/PathEventHub.js +0 -148
  189. package/dist/debug/path/PathStore.cjs +0 -1
  190. package/dist/debug/path/RaphDerivedHandle.cjs +0 -1
  191. package/dist/debug/path/RaphMeta.cjs +0 -1
  192. package/dist/debug/path/RaphMeta.js +0 -68
  193. package/dist/debug/path/RaphMetaStore.cjs +0 -1
  194. package/dist/debug/path/data-adapter.cjs +0 -1
  195. package/dist/debug/path/data-draft.cjs +0 -1
  196. package/dist/debug/path/data-path.cjs +0 -1
  197. package/dist/debug/path/data-path.js +0 -423
  198. package/dist/debug/path/derived-collection.cjs +0 -1
  199. package/dist/debug/path/path-router.cjs +0 -1
  200. package/dist/debug/path/path-router.js +0 -86
  201. package/dist/debug/path/public.cjs +0 -1
  202. package/dist/debug/path/public.js +0 -18
  203. package/dist/debug/runtime/PathHandle.cjs +0 -1
  204. package/dist/debug/runtime/PathHandle.js +0 -139
  205. package/dist/debug/runtime/RaphDebug.cjs +0 -1
  206. package/dist/debug/runtime/RaphDebug.js +0 -15
  207. package/dist/debug/runtime/RaphFrameLoop.cjs +0 -1
  208. package/dist/debug/runtime/RaphNode.cjs +0 -1
  209. package/dist/debug/runtime/RaphNode.js +0 -143
  210. package/dist/debug/runtime/RaphPhasePipeline.cjs +0 -1
  211. package/dist/debug/runtime/RaphPhasePipeline.js +0 -526
  212. package/dist/debug/runtime/RaphScope.cjs +0 -1
  213. package/dist/debug/runtime/RaphScope.js +0 -64
  214. package/dist/debug/runtime/RuntimeReactivity.cjs +0 -1
  215. package/dist/debug/runtime/RuntimeReactivity.js +0 -154
  216. package/dist/debug/runtime/RuntimeWatch.cjs +0 -1
  217. package/dist/debug/runtime/RuntimeWatch.js +0 -71
  218. package/dist/debug/runtime/public.cjs +0 -1
  219. package/dist/debug/runtime/public.js +0 -18
  220. package/dist/path/PathEventHub.d.ts +0 -48
  221. package/dist/path/public.d.ts +0 -14
  222. package/dist/runtime/RaphDebug.d.ts +0 -32
  223. package/dist/runtime/RaphNode.d.ts +0 -68
  224. package/dist/runtime/RaphPhasePipeline.d.ts +0 -133
  225. package/dist/runtime/RaphScope.d.ts +0 -50
  226. package/dist/runtime/RuntimeReactivity.d.ts +0 -40
  227. package/dist/runtime/phase.types.d.ts +0 -49
  228. package/dist/runtime/public.d.ts +0 -13
  229. package/dist/runtime/runtime-reactivity.types.d.ts +0 -9
  230. /package/dist/debug/path/{meta.types.cjs → data-path.types.cjs} +0 -0
  231. /package/dist/debug/path/{meta.types.js → data-path.types.js} +0 -0
  232. /package/dist/debug/{runtime/runtime-reactivity.types.cjs → path/derived/derived-collection.types.cjs} +0 -0
  233. /package/dist/debug/{runtime/runtime-reactivity.types.js → path/derived/derived-collection.types.js} +0 -0
  234. /package/dist/debug/path/{derived-strategies.cjs → derived/derived-strategy.utils.cjs} +0 -0
  235. /package/dist/debug/path/{derived-strategies.js → derived/derived-strategy.utils.js} +0 -0
  236. /package/dist/debug/path/{segment-key.cjs → pathSegmentKey.cjs} +0 -0
  237. /package/dist/debug/path/{segment-key.js → pathSegmentKey.js} +0 -0
  238. /package/dist/debug/runtime/{parent-graph.cjs → ownership/parentGraph.cjs} +0 -0
  239. /package/dist/debug/runtime/{parent-graph.js → ownership/parentGraph.js} +0 -0
  240. /package/dist/debug/runtime/{disposal.cjs → ownership/throwDisposalErrors.cjs} +0 -0
  241. /package/dist/debug/runtime/{disposal.js → ownership/throwDisposalErrors.js} +0 -0
  242. /package/dist/debug/runtime/{phase.types.cjs → phases/phase.types.cjs} +0 -0
  243. /package/dist/debug/runtime/{phase.types.js → phases/phase.types.js} +0 -0
  244. /package/dist/path/{data-draft.d.ts → storage/createDataDraft.d.ts} +0 -0
  245. /package/dist/runtime/{disposal.d.ts → ownership/throwDisposalErrors.d.ts} +0 -0
  246. /package/dist/runtime/{RaphFrameLoop.d.ts → phases/RaphFrameLoop.d.ts} +0 -0
@@ -1,42 +1,48 @@
1
- var F = Object.defineProperty;
2
- var R = (f, e, t) => e in f ? F(f, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : f[e] = t;
3
- var p = (f, e, t) => R(f, typeof e != "symbol" ? e + "" : e, t);
4
- import { AdapterPathStore as b } from "./AdapterPathStore.js";
5
- import { DefaultDataAdapter as O } from "./data-adapter.js";
6
- import { parseDataPath as k, DataPath as W } from "./data-path.js";
7
- import { validateFullFilter as S, cloneMaterializedValue as z, validateFullCollection as K, collectionIndex as w, collectionError as M, indexesAreStale as P, validateIncrementalCollection as q, collectionKeys as C, keyedPath as A, filterError as I, validateIncrementalFilter as N } from "./derived-collection.js";
8
- import { DerivedRegistry as $ } from "./DerivedRegistry.js";
9
- import { MetaController as j } from "./MetaController.js";
10
- import { PathStore as L } from "./PathStore.js";
11
- import { RaphDerivedHandle as B, RaphDerivedTargetWriteError as H } from "./RaphDerivedHandle.js";
12
- const x = class x {
1
+ import { parseDataPath as p } from "./data-path.utils.js";
2
+ import { DataPath as B } from "./DataPath.js";
3
+ import { validateFullFilter as I, cloneMaterializedValue as M, validateFullCollection as E, collectionIndex as w, collectionError as D, indexesAreStale as x, validateIncrementalCollection as F, collectionKeys as b, keyedPath as C, filterError as R, validateIncrementalFilter as K } from "./derived/derived-collection.utils.js";
4
+ import { DerivedRegistry as O } from "./derived/DerivedRegistry.js";
5
+ import { RaphDerivedHandle as S, RaphDerivedTargetWriteError as T } from "./derived/RaphDerivedHandle.js";
6
+ import { MetaController as W } from "./meta/MetaController.js";
7
+ import { AdapterPathStore as z } from "./storage/AdapterPathStore.js";
8
+ import { DefaultDataAdapter as q } from "./storage/DefaultDataAdapter.js";
9
+ import { PathStore as N } from "./storage/PathStore.js";
10
+ class P {
11
+ // Формирует локальный id для Kernel без явно заданного имени.
12
+ static _kernelCounter = 0;
13
+ // Публикует стабильную identity data/meta owner.
14
+ id;
15
+ // Лениво создают независимые data, derived, runtime и metadata controllers.
16
+ _paths;
17
+ _derivedController;
18
+ _runtimes;
19
+ _metaController;
20
+ // Что читает `_openSoleRuntimeBatch()`: единственный присоединённый Runtime
21
+ // и владелец batch boundary встроенного store. Первое пусто, пока Runtime
22
+ // нет либо их несколько; второе — у store над adapter и после dispose.
23
+ _soleRuntime;
24
+ _pathBatch;
25
+ // Защищают batch stabilization и записи в derived targets.
26
+ _batchDepth = 0;
27
+ _runtimeMutationDepth = 0;
28
+ _stabilizing = !1;
29
+ _derivedWriteDepth = 0;
13
30
  /**
14
31
  * Создаёт data/meta owner с независимым lifecycle и derived registry.
15
32
  */
16
33
  constructor(e = {}) {
17
- // Публикует стабильную identity data/meta owner.
18
- p(this, "id");
19
- // Лениво создают независимые data, derived, runtime и metadata controllers.
20
- p(this, "_paths");
21
- p(this, "_derivedController");
22
- p(this, "_runtimes");
23
- p(this, "_metaController");
24
- // Защищают transaction stabilization и записи в derived targets.
25
- p(this, "_transactionDepth", 0);
26
- p(this, "_stabilizing", !1);
27
- p(this, "_derivedWriteDepth", 0);
28
- if (this.id = e.id ?? `kernel-${x._kernelCounter++}`, e.adapter !== void 0) {
34
+ if (this.id = e.id ?? `kernel-${P._kernelCounter++}`, e.adapter !== void 0) {
29
35
  if (e.initial !== void 0 || e.adapterOptions !== void 0)
30
36
  throw new TypeError("[Raph] A custom adapter cannot be combined with initial or adapterOptions.");
31
- this._paths = new b(e.adapter);
37
+ this._paths = new z(e.adapter);
32
38
  } else if (e.adapterOptions !== void 0)
33
- this._paths = new b(new O(
39
+ this._paths = new z(new q(
34
40
  e.initial,
35
41
  e.adapterOptions
36
42
  ));
37
43
  else {
38
- const t = this._paths = new L();
39
- e.initial !== void 0 && t.set("", e.initial);
44
+ const t = this._paths = new N();
45
+ this._pathBatch = t._batchHub, e.initial !== void 0 && t.set("", e.initial);
40
46
  }
41
47
  }
42
48
  /**
@@ -49,12 +55,11 @@ const x = class x {
49
55
  * Формирует диагностический снимок materialized derived registry.
50
56
  */
51
57
  getDerivedSnapshot() {
52
- var t;
53
58
  const e = this._derivedController;
54
59
  return {
55
- registrations: (e == null ? void 0 : e.size) ?? 0,
56
- errors: [...(e == null ? void 0 : e.values()) ?? []].filter((r) => r.status === "error").length,
57
- pending: ((t = e == null ? void 0 : e.pending) == null ? void 0 : t.size) ?? 0,
60
+ registrations: e?.size ?? 0,
61
+ errors: [...e?.values() ?? []].filter((t) => t.status === "error").length,
62
+ pending: e?.pending?.size ?? 0,
58
63
  stabilizing: this._stabilizing
59
64
  };
60
65
  }
@@ -80,10 +85,13 @@ const x = class x {
80
85
  * Записывает значение и публикует соответствующее изменение.
81
86
  */
82
87
  set(e, t, r) {
83
- var s;
88
+ if (this._runtimeMutationDepth === 0 && this._runtimes !== void 0) {
89
+ this._withAttachedRuntimeBoundary(() => this.set(e, t, r));
90
+ return;
91
+ }
84
92
  this._assertWritablePath("set", e, t, r);
85
93
  const i = this._store;
86
- if ((((s = this._metaController) == null ? void 0 : s.size) ?? 0) === 0) {
94
+ if ((this._metaController?.size ?? 0) === 0) {
87
95
  if (this._derivedController === void 0) {
88
96
  i.set(e, t, r);
89
97
  return;
@@ -99,10 +107,13 @@ const x = class x {
99
107
  * Объединяет значение по пути и публикует соответствующее изменение.
100
108
  */
101
109
  merge(e, t, r) {
102
- var s;
110
+ if (this._runtimeMutationDepth === 0 && this._runtimes !== void 0) {
111
+ this._withAttachedRuntimeBoundary(() => this.merge(e, t, r));
112
+ return;
113
+ }
103
114
  this._assertWritablePath("merge", e, t, r);
104
115
  const i = this._store;
105
- if ((((s = this._metaController) == null ? void 0 : s.size) ?? 0) === 0) {
116
+ if ((this._metaController?.size ?? 0) === 0) {
106
117
  if (this._derivedController === void 0) {
107
118
  i.merge(e, t, r);
108
119
  return;
@@ -118,10 +129,13 @@ const x = class x {
118
129
  * Удаляет значение по пути и публикует изменение при наличии данных.
119
130
  */
120
131
  delete(e, t) {
121
- var i;
132
+ if (this._runtimeMutationDepth === 0 && this._runtimes !== void 0) {
133
+ this._withAttachedRuntimeBoundary(() => this.delete(e, t));
134
+ return;
135
+ }
122
136
  this._assertWritablePath("delete", e, void 0, t);
123
137
  const r = this._store;
124
- if ((((i = this._metaController) == null ? void 0 : i.size) ?? 0) === 0) {
138
+ if ((this._metaController?.size ?? 0) === 0) {
125
139
  if (this._derivedController === void 0) {
126
140
  r.delete(e, t);
127
141
  return;
@@ -131,41 +145,71 @@ const x = class x {
131
145
  }
132
146
  r.has(e, t) && this._mutateWithMetaLifecycle(() => {
133
147
  this._derivedController === void 0 ? r.delete(e, t) : this._mutateDerived(r, "delete", e, void 0, t);
134
- const s = this._metaPath(e, t);
135
- this._metaController.deleteSubtree(s, "owner-delete"), this._pruneMissingMetaOwners(s, "owner-delete");
148
+ const i = this._metaPath(e, t);
149
+ this._metaController.deleteSubtree(i, "owner-delete"), this._pruneMissingMetaOwners(i, "owner-delete");
136
150
  });
137
151
  }
138
152
  /**
139
- * Выполняет операцию в общей синхронной transaction boundary.
153
+ * Выполняет операцию в общей синхронной batch boundary.
140
154
  */
141
- transaction(e) {
142
- var c, l, v, _;
155
+ batch(e) {
156
+ if (this._runtimeMutationDepth === 0 && this._runtimes !== void 0)
157
+ return this._withAttachedRuntimeBoundary(() => this.batch(e));
143
158
  const t = this._store;
144
- if (this._derivedController === void 0 && !((c = this._metaController) != null && c.hasWatchers))
145
- return t.transaction(e);
146
- const r = this._transactionDepth === 0 && ((l = this._metaController) != null && l.hasDeferredWatchers) && this._runtimes !== void 0 ? [...this._runtimes] : void 0;
147
- if (r !== void 0)
148
- for (const o of r)
149
- (v = o._beginKernelTransaction) == null || v.call(o);
150
- let i, s, a = !1;
159
+ if (this._derivedController === void 0 && !this._metaController?.hasWatchers)
160
+ return t.batch(e);
161
+ let r, i, s = !1;
151
162
  try {
152
- i = t.transaction(() => this._runDerivedTransaction(e));
163
+ r = t.batch(() => this._runDerivedBatch(e));
153
164
  } catch (o) {
154
- a = !0, s = o;
165
+ s = !0, i = o;
155
166
  }
156
- const d = [];
157
- if (a && d.push(s), r !== void 0)
158
- for (const o of r)
159
- try {
160
- (_ = o._endKernelTransaction) == null || _.call(o);
161
- } catch (m) {
162
- d.push(m);
163
- }
164
- if (d.length === 1)
165
- throw d[0];
166
- if (d.length > 1)
167
- throw new AggregateError(d, "[Raph] Kernel transaction execution failed.");
168
- return i;
167
+ if (s)
168
+ throw i;
169
+ return r;
170
+ }
171
+ /**
172
+ * Открывает то же, что `batch()`, для единственного присоединённого Runtime
173
+ * без closure операции и без массивов: границу этого Runtime и path batch.
174
+ * Возвращает владельца path batch, которого вызывающий передаёт в
175
+ * `_closeSoleRuntimeBatch()` после операции.
176
+ *
177
+ * Возвращает `undefined` и ничего не открывает в любом другом состоянии:
178
+ * Kernel разделяют несколько Runtime, граница Runtime уже открыта, есть
179
+ * derived handles либо metadata watchers, store построен над adapter. Тогда
180
+ * вызывающий исполняет `batch()`. Состояние читается при входе, как в
181
+ * `batch()`: то, что появилось во время операции, выход не меняет.
182
+ * @internal
183
+ */
184
+ _openSoleRuntimeBatch(e) {
185
+ const t = this._pathBatch;
186
+ if (!(this._soleRuntime !== e || t === void 0 || this._runtimeMutationDepth !== 0 || this._derivedController !== void 0 || this._metaController?.hasWatchers === !0))
187
+ return this._runtimeMutationDepth++, e._beginKernelBatch?.(), t._openBatch(), t;
188
+ }
189
+ /**
190
+ * Закрывает границу, открытую `_openSoleRuntimeBatch()`, в порядке `batch()`:
191
+ * публикация path events, затем граница Runtime. Бросает то же, что бросил бы
192
+ * `batch()` с этой операцией; после успешного выхода возвращает управление.
193
+ * @internal
194
+ */
195
+ _closeSoleRuntimeBatch(e, t, r, i) {
196
+ let s = r, o = i;
197
+ try {
198
+ t._closeBatch(r, i);
199
+ } catch (n) {
200
+ s = !0, o = n;
201
+ }
202
+ this._runtimeMutationDepth--;
203
+ try {
204
+ e._endKernelBatch?.();
205
+ } catch (n) {
206
+ throw s ? new AggregateError(
207
+ [o, n],
208
+ "[Raph] Kernel mutation and Runtime publication failed."
209
+ ) : n;
210
+ }
211
+ if (s)
212
+ throw o;
169
213
  }
170
214
  /**
171
215
  * Подписывает callback на подходящие изменения и возвращает disposer.
@@ -177,20 +221,22 @@ const x = class x {
177
221
  * Возвращает metadata указанного data-owner.
178
222
  */
179
223
  getMeta(e, t, r) {
180
- var i;
181
- return this._store, t !== void 0 && this._assertMetaNamespace(t), (i = this._metaController) == null ? void 0 : i.get(this._metaPath(e, r), t);
224
+ return this._store, t !== void 0 && this._assertMetaNamespace(t), this._metaController?.get(this._metaPath(e, r), t);
182
225
  }
183
226
  /**
184
227
  * Проверяет наличие metadata у указанного data-owner.
185
228
  */
186
229
  hasMeta(e, t, r) {
187
- var i;
188
- return this._store, t !== void 0 && this._assertMetaNamespace(t), ((i = this._metaController) == null ? void 0 : i.has(this._metaPath(e, r), t)) ?? !1;
230
+ return this._store, t !== void 0 && this._assertMetaNamespace(t), this._metaController?.has(this._metaPath(e, r), t) ?? !1;
189
231
  }
190
232
  /**
191
233
  * Записывает metadata указанного data-owner.
192
234
  */
193
235
  setMeta(e, t, r, i) {
236
+ if (this._runtimeMutationDepth === 0 && this._runtimes !== void 0) {
237
+ this._withAttachedRuntimeBoundary(() => this.setMeta(e, t, r, i));
238
+ return;
239
+ }
194
240
  this._assertMetaNamespace(t);
195
241
  const s = this._exactMetaPath(e, i);
196
242
  this._assertMetaOwner(s), this._metadata.set(s, t, r, i);
@@ -199,6 +245,10 @@ const x = class x {
199
245
  * Объединяет metadata указанного data-owner.
200
246
  */
201
247
  mergeMeta(e, t, r, i) {
248
+ if (this._runtimeMutationDepth === 0 && this._runtimes !== void 0) {
249
+ this._withAttachedRuntimeBoundary(() => this.mergeMeta(e, t, r, i));
250
+ return;
251
+ }
202
252
  this._assertMetaNamespace(t);
203
253
  const s = this._exactMetaPath(e, i);
204
254
  this._assertMetaOwner(s), this._metadata.merge(s, t, r, i);
@@ -207,10 +257,13 @@ const x = class x {
207
257
  * Удаляет metadata указанного data-owner.
208
258
  */
209
259
  deleteMeta(e, t, r) {
210
- var s;
260
+ if (this._runtimeMutationDepth === 0 && this._runtimes !== void 0) {
261
+ this._withAttachedRuntimeBoundary(() => this.deleteMeta(e, t, r));
262
+ return;
263
+ }
211
264
  t !== void 0 && this._assertMetaNamespace(t);
212
265
  const i = this._exactMetaPath(e, r);
213
- (s = this._metaController) == null || s.delete(i, t, r);
266
+ this._metaController?.delete(i, t, r);
214
267
  }
215
268
  /**
216
269
  * Подписывает runtime adapter на metadata-события Kernel.
@@ -223,33 +276,34 @@ const x = class x {
223
276
  * Создаёт управляемое derived-представление source path в target path.
224
277
  */
225
278
  derive(e) {
226
- var l, v, _;
227
279
  if (this._store, e.strategy !== void 0 && e.strategy.kind !== "full" && e.strategy.kind !== "collection-by-key" && e.strategy.kind !== "filter-by-key")
228
280
  throw new Error(`[Raph] Unsupported derived strategy "${String(e.strategy.kind)}".`);
229
- if (e.id !== void 0 && ((l = this._derivedController) != null && l.has(e.id)))
281
+ if (e.id !== void 0 && this._derivedController?.has(e.id))
230
282
  throw new Error(`[Raph] Duplicate derived id "${e.id}".`);
231
- const t = k(e.from), r = k(e.to);
232
- if (T(t, r))
283
+ const t = p(e.from), r = p(e.to);
284
+ if (A(t, r))
233
285
  throw new Error("[Raph] Derived source and target must not overlap.");
234
- const i = this._derivedController ?? new $(), s = e.id ?? i.nextId(), a = {
286
+ const i = this._derivedController ?? new O(), s = e.id ?? i.nextId(), o = {
235
287
  ...e,
236
288
  from: t.canonical,
237
289
  to: r.canonical
238
- }, d = new B(this, s, a), c = ((v = e.strategy) == null ? void 0 : v.kind) === "collection-by-key" || ((_ = e.strategy) == null ? void 0 : _.kind) === "filter-by-key" ? e.strategy : void 0;
239
- this._derivedController = i, i.register(d, t, c);
290
+ }, n = new S(this, s, o), c = e.strategy?.kind === "collection-by-key" || e.strategy?.kind === "filter-by-key" ? e.strategy : void 0;
291
+ this._derivedController = i, i.register(n, t, c);
240
292
  try {
241
- e.immediate !== !1 && d.recompute();
242
- } catch (o) {
243
- throw this._removeDerived(d), d._disposeFromKernel(), o;
293
+ e.immediate !== !1 && n.recompute();
294
+ } catch (l) {
295
+ throw this._removeDerived(n), n._disposeFromKernel(), l;
244
296
  }
245
- return d;
297
+ return n;
246
298
  }
247
299
  /**
248
300
  * Регистрирует runtime, разделяющий этот Kernel.
249
301
  * @internal
250
302
  */
251
303
  _attachRuntime(e) {
252
- this._store, (this._runtimes ?? (this._runtimes = /* @__PURE__ */ new Set())).add(e);
304
+ this._store;
305
+ const t = this._runtimes ??= /* @__PURE__ */ new Set();
306
+ t.add(e), this._soleRuntime = t.size === 1 ? e : void 0;
253
307
  }
254
308
  /**
255
309
  * Удаляет runtime из shared Kernel registry.
@@ -257,24 +311,23 @@ const x = class x {
257
311
  */
258
312
  _detachRuntime(e) {
259
313
  const t = this._runtimes;
260
- t !== void 0 && (t.delete(e), t.size === 0 && (this._runtimes = void 0));
314
+ t !== void 0 && (t.delete(e), t.size === 0 && (this._runtimes = void 0), this._soleRuntime = t.size === 1 ? t.values().next().value : void 0);
261
315
  }
262
316
  /**
263
317
  * Освобождает shared runtimes, derived handles и data/meta state Kernel.
264
318
  */
265
319
  dispose() {
266
- var t, r;
267
320
  if (this._paths === void 0)
268
321
  return;
269
322
  const e = [];
270
323
  if (this._runtimes !== void 0)
271
- for (const i of [...this._runtimes])
324
+ for (const t of [...this._runtimes])
272
325
  try {
273
- i.dispose();
274
- } catch (s) {
275
- e.push(s);
326
+ t.dispose();
327
+ } catch (r) {
328
+ e.push(r);
276
329
  }
277
- if (this._runtimes = void 0, (t = this._derivedController) == null || t.dispose(), this._derivedController = void 0, (r = this._metaController) == null || r.dispose(), this._metaController = void 0, this._paths = void 0, e.length === 1)
330
+ if (this._runtimes = void 0, this._soleRuntime = void 0, this._derivedController?.dispose(), this._derivedController = void 0, this._metaController?.dispose(), this._metaController = void 0, this._paths = void 0, this._pathBatch = void 0, e.length === 1)
278
331
  throw e[0];
279
332
  if (e.length > 1)
280
333
  throw new AggregateError(e, `[Raph] Kernel "${this.id}" disposal failed.`);
@@ -306,24 +359,60 @@ const x = class x {
306
359
  throw new Error(`[Raph] Kernel "${this.id}" is disposed.`);
307
360
  }
308
361
  get _metadata() {
309
- return this._store, this._metaController ?? (this._metaController = new j(
362
+ return this._store, this._metaController ??= new W(
310
363
  this,
311
364
  (e) => this.has(e),
312
- () => this._transactionDepth !== 0 || this._stabilizing
313
- ));
365
+ () => this._batchDepth !== 0 || this._stabilizing
366
+ );
367
+ }
368
+ /** Keeps every attached Runtime quiescent until one Kernel publication completes. */
369
+ _withAttachedRuntimeBoundary(e) {
370
+ const t = this._runtimes === void 0 ? [] : [...this._runtimes];
371
+ if (t.length === 0)
372
+ return e();
373
+ const r = [], i = [];
374
+ let s, o = !1;
375
+ this._runtimeMutationDepth++;
376
+ try {
377
+ for (const n of t)
378
+ n._beginKernelBatch?.(), r.push(n);
379
+ try {
380
+ s = e();
381
+ } catch (n) {
382
+ o = !0, i.push(n);
383
+ }
384
+ } catch (n) {
385
+ o = !0, i.push(n);
386
+ } finally {
387
+ this._runtimeMutationDepth--;
388
+ for (let n = r.length - 1; n >= 0; n--)
389
+ try {
390
+ r[n]._endKernelBatch?.();
391
+ } catch (c) {
392
+ i.push(c);
393
+ }
394
+ }
395
+ if (i.length === 1)
396
+ throw i[0];
397
+ if (i.length > 1)
398
+ throw new AggregateError(
399
+ i,
400
+ o ? "[Raph] Kernel mutation and Runtime publication failed." : "[Raph] Runtime publication failed after a Kernel mutation."
401
+ );
402
+ return s;
314
403
  }
315
404
  _assertWritablePath(e, t, r, i) {
316
405
  const s = this._derivedController;
317
406
  if (s === void 0 || this._derivedWriteDepth !== 0)
318
407
  return;
319
- const a = k(t, i);
320
- for (const d of s.values()) {
321
- const c = k(d.options.to);
322
- if (!T(a, c))
408
+ const o = p(t, i);
409
+ for (const n of s.values()) {
410
+ const c = p(n.options.to);
411
+ if (!A(o, c))
323
412
  continue;
324
- const l = a.segments.length < c.segments.length;
325
- if (!(e === "merge" && l && !U(r, c.segments[a.segments.length])))
326
- throw new H(a.canonical);
413
+ const l = o.segments.length < c.segments.length;
414
+ if (!(e === "merge" && l && !$(r, c.segments[o.segments.length])))
415
+ throw new T(o.canonical);
327
416
  }
328
417
  }
329
418
  _writeDerivedTarget(e, t) {
@@ -335,57 +424,55 @@ const x = class x {
335
424
  }
336
425
  }
337
426
  _mutateDerived(e, t, r, i, s) {
338
- const a = k(r, s);
339
- t === "delete" && !e.has(r, s) || e.transaction(() => {
340
- t === "set" ? e.set(r, i, s) : t === "merge" ? e.merge(r, i, s) : e.delete(r, s), this._queueDerived(a), this._transactionDepth === 0 && !this._stabilizing && this._stabilizeDerived();
427
+ const o = p(r, s);
428
+ t === "delete" && !e.has(r, s) || e.batch(() => {
429
+ t === "set" ? e.set(r, i, s) : t === "merge" ? e.merge(r, i, s) : e.delete(r, s), this._queueDerived(o), this._batchDepth === 0 && !this._stabilizing && this._stabilizeDerived();
341
430
  });
342
431
  }
343
- _runDerivedTransaction(e) {
344
- var v;
345
- let t = !1, r, i = !1, s, a = !1, d, c;
346
- this._transactionDepth++;
432
+ _runDerivedBatch(e) {
433
+ let t = !1, r, i = !1, s, o = !1, n, c;
434
+ this._batchDepth++;
347
435
  try {
348
436
  c = e();
349
- } catch (_) {
350
- t = !0, r = _;
437
+ } catch (m) {
438
+ t = !0, r = m;
351
439
  } finally {
352
- if (this._transactionDepth--, this._transactionDepth === 0) {
440
+ if (this._batchDepth--, this._batchDepth === 0) {
353
441
  if (!this._stabilizing)
354
442
  try {
355
443
  this._stabilizeDerived();
356
- } catch (_) {
357
- i = !0, s = _;
444
+ } catch (m) {
445
+ i = !0, s = m;
358
446
  }
359
447
  try {
360
- (v = this._metaController) == null || v.publish();
361
- } catch (_) {
362
- a = !0, d = _;
448
+ this._metaController?.publish();
449
+ } catch (m) {
450
+ o = !0, n = m;
363
451
  }
364
452
  }
365
453
  }
366
454
  const l = [];
367
- if (t && l.push(r), i && l.push(s), a && l.push(d), l.length > 1)
455
+ if (t && l.push(r), i && l.push(s), o && l.push(n), l.length > 1)
368
456
  throw new AggregateError(
369
457
  l,
370
- "[Raph] Kernel transaction publication failed."
458
+ "[Raph] Kernel batch publication failed."
371
459
  );
372
460
  if (l.length === 1)
373
461
  throw l[0];
374
462
  return c;
375
463
  }
376
464
  _mutateWithMetaLifecycle(e) {
377
- if (this._transactionDepth !== 0 || this._stabilizing) {
465
+ if (this._batchDepth !== 0 || this._stabilizing) {
378
466
  e();
379
467
  return;
380
468
  }
381
- this.transaction(e);
469
+ this.batch(e);
382
470
  }
383
471
  _pruneMissingMetaOwners(e, t, r) {
384
- var i;
385
- (i = this._metaController) == null || i.pruneMissing(this._metaPath(e, r), t);
472
+ this._metaController?.pruneMissing(this._metaPath(e, r), t);
386
473
  }
387
474
  _metaPath(e, t) {
388
- return W.from(e, t);
475
+ return B.from(e, t);
389
476
  }
390
477
  _exactMetaPath(e, t) {
391
478
  const r = this._metaPath(e, t);
@@ -402,19 +489,17 @@ const x = class x {
402
489
  throw new Error(`[RaphMeta] Owner data path does not exist: "${e}".`);
403
490
  }
404
491
  _queueDerived(e) {
405
- var t;
406
- (t = this._derivedController) == null || t.queue(e);
492
+ this._derivedController?.queue(e);
407
493
  }
408
494
  _queueDerivedReplacement(e, t) {
409
- var r;
410
- (r = this._derivedController) == null || r.queueReplacement(e, t);
495
+ this._derivedController?.queueReplacement(e, t);
411
496
  }
412
497
  _replaceDerivedTarget(e, t, r) {
413
- const i = k(e);
498
+ const i = p(e);
414
499
  this._store.set(i.canonical, t), this._queueDerivedReplacement(i, r);
415
500
  }
416
501
  _stabilizeDerived() {
417
- const e = this._derivedController, t = e == null ? void 0 : e.pending;
502
+ const e = this._derivedController, t = e?.pending;
418
503
  if (t === void 0 || t.size === 0)
419
504
  return;
420
505
  this._stabilizing = !0;
@@ -435,12 +520,11 @@ const x = class x {
435
520
  } catch (i) {
436
521
  throw t.clear(), i;
437
522
  } finally {
438
- this._stabilizing = !1, e == null || e.clearPendingIfEmpty();
523
+ this._stabilizing = !1, e?.clearPendingIfEmpty();
439
524
  }
440
525
  }
441
526
  _recomputePendingDerived(e) {
442
- var r;
443
- const t = (r = this._derivedController) == null ? void 0 : r.state(e);
527
+ const t = this._derivedController?.state(e);
444
528
  if (t === void 0 || !t.initialized || t.full) {
445
529
  this._recomputeDerivedFull(e);
446
530
  return;
@@ -448,61 +532,60 @@ const x = class x {
448
532
  t.kind === "filter-by-key" ? this._recomputeDerivedFilter(e, t) : this._recomputeDerivedCollection(e, t);
449
533
  }
450
534
  _recomputeDerivedFull(e) {
451
- var c;
452
- const t = (c = this._derivedController) == null ? void 0 : c.state(e);
535
+ const t = this._derivedController?.state(e);
453
536
  t !== void 0 && (t.full = !0);
454
537
  const r = this.get(e.options.from), i = e.options.compute(r);
455
- let s = i, a, d;
456
- t !== void 0 && (r === void 0 && (i === void 0 || Array.isArray(i) && i.length === 0) ? (a = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map()) : (t.kind === "filter-by-key" ? (S(e.id, t.key, r, i), s = z(i)) : K(e.id, t.key, r, i), a = w(r, t.key, "source"), d = w(s, t.key, "output"))), this._writeDerivedTarget(e.options.to, s), t !== void 0 && (t.sourceIndex = a, t.targetIndex = d, t.initialized = !0, t.full = !1, t.keys.clear());
538
+ let s = i, o, n;
539
+ t !== void 0 && (r === void 0 && (i === void 0 || Array.isArray(i) && i.length === 0) ? (o = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map()) : (t.kind === "filter-by-key" ? (I(e.id, t.key, r, i), s = M(i)) : E(e.id, t.key, r, i), o = w(r, t.key, "source"), n = w(s, t.key, "output"))), this._writeDerivedTarget(e.options.to, s), t !== void 0 && (t.sourceIndex = o, t.targetIndex = n, t.initialized = !0, t.full = !1, t.keys.clear());
457
540
  }
458
541
  _recomputeDerivedCollection(e, t) {
459
542
  t.full = !0;
460
543
  const r = this.get(e.options.from), i = this.get(e.options.to);
461
544
  if (!Array.isArray(r) || !Array.isArray(i))
462
- throw M(e.id, "requires array source and target");
463
- (t.sourceIndex === void 0 || P(r, t.key, t.sourceIndex, t.keys)) && (t.sourceIndex = w(r, t.key, "source"));
545
+ throw D(e.id, "requires array source and target");
546
+ (t.sourceIndex === void 0 || x(r, t.key, t.sourceIndex, t.keys)) && (t.sourceIndex = w(r, t.key, "source"));
464
547
  const s = t.targetIndex;
465
548
  if (s === void 0)
466
- throw M(e.id, "has no materialized target index");
467
- const a = [], d = [];
468
- for (const o of t.keys) {
469
- const m = t.sourceIndex.get(o);
470
- m === void 0 ? d.push(o) : a.push({ key: o, index: m, item: r[m] });
549
+ throw D(e.id, "has no materialized target index");
550
+ const o = [], n = [];
551
+ for (const h of t.keys) {
552
+ const _ = t.sourceIndex.get(h);
553
+ _ === void 0 ? n.push(h) : o.push({ key: h, index: _, item: r[_] });
471
554
  }
472
- a.sort((o, m) => o.index - m.index);
473
- const c = a.map((o) => o.item), l = c.length === 0 ? [] : e.options.compute(c);
474
- q(
555
+ o.sort((h, _) => h.index - _.index);
556
+ const c = o.map((h) => h.item), l = c.length === 0 ? [] : e.options.compute(c);
557
+ F(
475
558
  e.id,
476
559
  t.key,
477
- a.map((o) => o.key),
560
+ o.map((h) => h.key),
478
561
  l
479
562
  );
480
- const v = l;
481
- if (d.length !== 0 || a.some((o) => !s.has(o.key))) {
482
- const o = /* @__PURE__ */ new Map();
483
- for (let u = 0; u < a.length; u++)
484
- o.set(a[u].key, v[u]);
485
- const m = /* @__PURE__ */ new Map();
486
- for (const [u, g] of s)
487
- m.set(u, i[g]);
488
- const n = C(r, t.key, "source"), h = [];
489
- h.length = n.length;
490
- for (let u = 0; u < n.length; u++) {
491
- const g = n[u];
492
- if (g === void 0)
563
+ const m = l;
564
+ if (n.length !== 0 || o.some((h) => !s.has(h.key))) {
565
+ const h = /* @__PURE__ */ new Map();
566
+ for (let u = 0; u < o.length; u++)
567
+ h.set(o[u].key, m[u]);
568
+ const _ = /* @__PURE__ */ new Map();
569
+ for (const [u, v] of s)
570
+ _.set(u, i[v]);
571
+ const a = b(r, t.key, "source"), d = [];
572
+ d.length = a.length;
573
+ for (let u = 0; u < a.length; u++) {
574
+ const v = a[u];
575
+ if (v === void 0)
493
576
  continue;
494
- const D = o.has(g) ? o.get(g) : m.get(g);
495
- if (D === void 0)
496
- throw M(e.id, `is missing target item for key "${String(g)}"`);
497
- h[u] = D;
577
+ const k = h.has(v) ? h.get(v) : _.get(v);
578
+ if (k === void 0)
579
+ throw D(e.id, `is missing target item for key "${String(v)}"`);
580
+ d[u] = k;
498
581
  }
499
- const y = w(h, t.key, "target");
500
- this._replaceDerivedTarget(e.options.to, h, t.keys), t.targetIndex = y;
582
+ const g = w(d, t.key, "target");
583
+ this._replaceDerivedTarget(e.options.to, d, t.keys), t.targetIndex = g;
501
584
  } else
502
- for (let o = 0; o < a.length; o++)
585
+ for (let h = 0; h < o.length; h++)
503
586
  this._writeDerivedTarget(
504
- A(e.options.to, t.key, a[o].key),
505
- v[o]
587
+ C(e.options.to, t.key, o[h].key),
588
+ m[h]
506
589
  );
507
590
  t.keys.clear(), t.full = !1;
508
591
  }
@@ -510,127 +593,124 @@ const x = class x {
510
593
  t.full = !0;
511
594
  const r = this.get(e.options.from), i = this.get(e.options.to);
512
595
  if (!Array.isArray(r) || !Array.isArray(i))
513
- throw I(e.id, "requires array source and target");
514
- (t.sourceIndex === void 0 || P(r, t.key, t.sourceIndex, t.keys)) && (t.sourceIndex = w(r, t.key, "source"));
596
+ throw R(e.id, "requires array source and target");
597
+ (t.sourceIndex === void 0 || x(r, t.key, t.sourceIndex, t.keys)) && (t.sourceIndex = w(r, t.key, "source"));
515
598
  const s = t.targetIndex;
516
599
  if (s === void 0)
517
- throw I(e.id, "has no materialized target index");
518
- const a = [];
519
- for (const n of t.keys) {
520
- const h = t.sourceIndex.get(n);
521
- h !== void 0 && a.push({ key: n, index: h, item: r[h] });
600
+ throw R(e.id, "has no materialized target index");
601
+ const o = [];
602
+ for (const a of t.keys) {
603
+ const d = t.sourceIndex.get(a);
604
+ d !== void 0 && o.push({ key: a, index: d, item: r[d] });
522
605
  }
523
- a.sort((n, h) => n.index - h.index);
524
- const d = a.map((n) => n.item), c = d.length === 0 ? [] : e.options.compute(d);
525
- N(
606
+ o.sort((a, d) => a.index - d.index);
607
+ const n = o.map((a) => a.item), c = n.length === 0 ? [] : e.options.compute(n);
608
+ K(
526
609
  e.id,
527
610
  t.key,
528
- a.map((n) => n.key),
611
+ o.map((a) => a.key),
529
612
  c
530
613
  );
531
- const l = /* @__PURE__ */ new Map(), v = c, _ = C(v, t.key, "output");
532
- for (let n = 0; n < _.length; n++) {
533
- const h = _[n];
534
- h !== void 0 && l.set(h, z(v[n]));
614
+ const l = /* @__PURE__ */ new Map(), m = c, y = b(m, t.key, "output");
615
+ for (let a = 0; a < y.length; a++) {
616
+ const d = y[a];
617
+ d !== void 0 && l.set(d, M(m[a]));
535
618
  }
536
- const o = /* @__PURE__ */ new Set();
537
- let m = !1;
538
- for (const n of t.keys) {
539
- const h = s.has(n), y = l.has(n);
540
- !h && !y || (o.add(n), h !== y && (m = !0));
619
+ const h = /* @__PURE__ */ new Set();
620
+ let _ = !1;
621
+ for (const a of t.keys) {
622
+ const d = s.has(a), g = l.has(a);
623
+ !d && !g || (h.add(a), d !== g && (_ = !0));
541
624
  }
542
- if (m && t.keys.size === 1 && i.length === s.size && this._patchSingleFilterMembership(
625
+ if (_ && t.keys.size === 1 && i.length === s.size && this._patchSingleFilterMembership(
543
626
  e,
544
627
  t,
545
628
  i,
546
629
  s,
547
630
  l,
548
- o
631
+ h
549
632
  )) {
550
633
  t.keys.clear(), t.full = !1;
551
634
  return;
552
635
  }
553
- if (m) {
554
- const n = /* @__PURE__ */ new Map();
555
- for (const [u, g] of s)
556
- n.set(u, i[g]);
557
- const h = [];
558
- for (const u of C(r, t.key, "source"))
636
+ if (_) {
637
+ const a = /* @__PURE__ */ new Map();
638
+ for (const [u, v] of s)
639
+ a.set(u, i[v]);
640
+ const d = [];
641
+ for (const u of b(r, t.key, "source"))
559
642
  if (u !== void 0) {
560
643
  if (t.keys.has(u)) {
561
- l.has(u) && h.push(l.get(u));
644
+ l.has(u) && d.push(l.get(u));
562
645
  continue;
563
646
  }
564
- n.has(u) && h.push(n.get(u));
647
+ a.has(u) && d.push(a.get(u));
565
648
  }
566
- const y = w(h, t.key, "target");
567
- this._replaceDerivedTarget(e.options.to, h, o), t.targetIndex = y;
649
+ const g = w(d, t.key, "target");
650
+ this._replaceDerivedTarget(e.options.to, d, h), t.targetIndex = g;
568
651
  } else
569
- for (const [n, h] of l)
570
- this._writeDerivedTarget(A(e.options.to, t.key, n), h);
652
+ for (const [a, d] of l)
653
+ this._writeDerivedTarget(C(e.options.to, t.key, a), d);
571
654
  t.keys.clear(), t.full = !1;
572
655
  }
573
- _patchSingleFilterMembership(e, t, r, i, s, a) {
574
- const d = t.sourceIndex;
575
- if (d === void 0)
656
+ _patchSingleFilterMembership(e, t, r, i, s, o) {
657
+ const n = t.sourceIndex;
658
+ if (n === void 0)
576
659
  return !1;
577
660
  const c = t.keys.values().next().value;
578
661
  if (c === void 0)
579
662
  return !1;
580
- const l = i.get(c), v = s.has(c);
581
- if (l !== void 0 === v)
663
+ const l = i.get(c), m = s.has(c);
664
+ if (l !== void 0 === m)
582
665
  return !1;
583
- const _ = r.slice();
584
- let o;
666
+ const y = r.slice();
667
+ let h;
585
668
  if (l !== void 0)
586
- o = l, _.splice(o, 1);
669
+ h = l, y.splice(h, 1);
587
670
  else {
588
- const m = d.get(c);
589
- if (m === void 0)
671
+ const _ = n.get(c);
672
+ if (_ === void 0)
590
673
  return !1;
591
- let n = 0, h = _.length;
592
- for (; n < h; ) {
593
- const y = n + h >>> 1, u = _[y];
674
+ let a = 0, d = y.length;
675
+ for (; a < d; ) {
676
+ const g = a + d >>> 1, u = y[g];
594
677
  if (typeof u != "object" || u === null || Array.isArray(u))
595
678
  return !1;
596
- const g = u[t.key];
597
- if (typeof g != "string" && typeof g != "number")
679
+ const v = u[t.key];
680
+ if (typeof v != "string" && typeof v != "number")
598
681
  return !1;
599
- const D = d.get(g);
600
- if (D === void 0)
682
+ const k = n.get(v);
683
+ if (k === void 0)
601
684
  return !1;
602
- D < m ? n = y + 1 : h = y;
685
+ k < _ ? a = g + 1 : d = g;
603
686
  }
604
- o = n, _.splice(o, 0, s.get(c));
687
+ h = a, y.splice(h, 0, s.get(c));
605
688
  }
606
- if (this._replaceDerivedTarget(e.options.to, _, a), l !== void 0) {
689
+ if (this._replaceDerivedTarget(e.options.to, y, o), l !== void 0) {
607
690
  i.delete(c);
608
- for (const [m, n] of i)
609
- n > o && i.set(m, n - 1);
691
+ for (const [_, a] of i)
692
+ a > h && i.set(_, a - 1);
610
693
  } else {
611
- for (const [m, n] of i)
612
- n >= o && i.set(m, n + 1);
613
- i.set(c, o);
694
+ for (const [_, a] of i)
695
+ a >= h && i.set(_, a + 1);
696
+ i.set(c, h);
614
697
  }
615
698
  return !0;
616
699
  }
617
- };
618
- // Формирует локальный id для Kernel без явно заданного имени.
619
- p(x, "_kernelCounter", 0);
620
- let E = x;
621
- function T(f, e) {
700
+ }
701
+ function A(f, e) {
622
702
  const t = Math.min(f.segments.length, e.segments.length);
623
703
  for (let r = 0; r < t; r++)
624
- if (!V(f.segments[r], e.segments[r]))
704
+ if (!j(f.segments[r], e.segments[r]))
625
705
  return !1;
626
706
  return !0;
627
707
  }
628
- function U(f, e) {
708
+ function $(f, e) {
629
709
  return typeof f != "object" || f === null || Array.isArray(f) || e.kind !== "key" ? !0 : Object.hasOwn(f, e.key);
630
710
  }
631
- function V(f, e) {
711
+ function j(f, e) {
632
712
  return f.kind !== e.kind ? !1 : f.kind === "key" && e.kind === "key" ? f.key === e.key : f.kind === "index" && e.kind === "index" ? f.index === e.index : f.kind === "selector" && e.kind === "selector" && f.key === e.key && Object.is(f.value, e.value);
633
713
  }
634
714
  export {
635
- E as RaphKernel
715
+ P as RaphKernel
636
716
  };