@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,419 +1,420 @@
1
- var g = Object.defineProperty;
2
- var w = (u, t, e) => t in u ? g(u, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : u[t] = e;
3
- var r = (u, t, e) => w(u, typeof t != "symbol" ? t + "" : t, e);
4
- import "../path/data-adapter.js";
5
- import "../path/data-path.js";
6
- import { filterByKey as R, collectionByKey as p, full as v } from "../path/derived-strategies.js";
7
- import "../path/RaphDerivedHandle.js";
8
- import { RaphKernel as o } from "../path/RaphKernel.js";
9
- import "../path/RaphMeta.js";
10
- import "../runtime/errors.js";
11
- import "../runtime/parent-graph.js";
12
- import "../runtime/PathHandle.js";
13
- import { RaphSchedulerType as c } from "../runtime/phase.types.js";
14
- import "../runtime/RaphNode.js";
15
- import { RaphRuntime as d } from "../runtime/RaphRuntime.js";
16
- import "../runtime/RaphScope.js";
17
- import { RaphConfigurationError as a, RaphModeError as f, RaphDefaultRuntimeError as l } from "./errors.js";
18
- import { RaphReactivity as D } from "../reactivity/engine.js";
19
- function n() {
20
- throw new a(
21
- "[Raph] Facade is not configured. Call Raph.configure({ mode }) first."
22
- );
23
- }
24
- class s {
25
- /**
26
- * Показывает, завершена ли явная конфигурация facade.
27
- */
28
- static get configured() {
29
- return this._state === "configured";
1
+ import { filterByKey as h, collectionByKey as _, full as d } from "../path/derived/derived-strategy.utils.js";
2
+ import { RaphSchedulerType as f } from "../runtime/phases/phase.types.js";
3
+ import { RaphRuntime as p } from "../runtime/RaphRuntime.js";
4
+ import { RaphConfigurationError as c, RaphCapabilityError as n } from "./errors.js";
5
+ import { RaphFacadeSession as m } from "./RaphFacadeSession.js";
6
+ import { RaphReactivityInstance as a } from "./RaphReactivityInstance.js";
7
+ class g {
8
+ constructor(e) {
9
+ this._session = e;
30
10
  }
31
- /**
32
- * Возвращает выбранный режим либо `undefined` до конфигурации.
33
- */
34
- static get mode() {
35
- return this._mode;
11
+ // ---------------------------------------------
12
+ // PUBLIC API
13
+ // ---------------------------------------------
14
+ get configured() {
15
+ return !0;
36
16
  }
37
- /**
38
- * Однократно выбирает backend и устанавливает публичные операции facade.
39
- */
40
- static configure(t) {
41
- if (this._state !== "unconfigured")
42
- throw new a(
43
- `[Raph] Cannot configure facade while it is ${this._state}.`
17
+ get defaultInstanceId() {
18
+ return this._session.defaultInstanceId;
19
+ }
20
+ get kernel() {
21
+ return this._runtime().kernel;
22
+ }
23
+ get meta() {
24
+ return this._runtime().meta;
25
+ }
26
+ get debug() {
27
+ return this._runtime().debug;
28
+ }
29
+ get root() {
30
+ return this._runtime().root;
31
+ }
32
+ get rootScope() {
33
+ return this._runtime().rootScope;
34
+ }
35
+ get frameTick() {
36
+ return this._runtime().frameTick;
37
+ }
38
+ get frame() {
39
+ return this._runtime().frame;
40
+ }
41
+ get phases() {
42
+ return this._runtime().phases;
43
+ }
44
+ get loopEnabled() {
45
+ return this._runtime().loopEnabled;
46
+ }
47
+ instance(e) {
48
+ return this._session.instance(e);
49
+ }
50
+ getInstance(e) {
51
+ return this._session.getInstance(e);
52
+ }
53
+ hasInstance(e) {
54
+ return this._session.hasInstance(e);
55
+ }
56
+ disposeInstance(e) {
57
+ return this._session.disposeInstance(e);
58
+ }
59
+ runtime(e) {
60
+ return this._session.runtime(e);
61
+ }
62
+ reactivity(e) {
63
+ return this._session.reactivity(e);
64
+ }
65
+ createRuntime(e = {}) {
66
+ return this._session.createRuntime(e);
67
+ }
68
+ createReactivity(e = {}) {
69
+ return this._session.createReactivity(e);
70
+ }
71
+ createKernel(e = {}) {
72
+ return this._session.createKernel(e);
73
+ }
74
+ signal(e) {
75
+ return this._reactive().signal(e);
76
+ }
77
+ reactive(e) {
78
+ return this._reactive().reactive(e);
79
+ }
80
+ computed(e) {
81
+ const t = this._reactive();
82
+ return t instanceof p, t.computed(e);
83
+ }
84
+ effect(e, t, r) {
85
+ const i = this._session.instance();
86
+ if (i instanceof a) {
87
+ if (typeof e != "function" || t !== void 0)
88
+ throw o("phase effect", i);
89
+ return i.effect(e);
90
+ }
91
+ if (typeof e != "string" || t === void 0)
92
+ throw new n("[Raph] Runtime effects require an explicit phase.");
93
+ return i.effect(i.rootScope, e, t, r);
94
+ }
95
+ watch(e, t, r, i) {
96
+ const s = this._session.instance();
97
+ if (s instanceof a) {
98
+ if (typeof t != "function")
99
+ throw o("phase watch", s);
100
+ return s.watch(
101
+ e,
102
+ t,
103
+ r
44
104
  );
45
- this._state = "configuring";
46
- try {
47
- if (this._validateConfigureOptions(t), t.mode === "reactivity")
48
- this._configureReactivity(new D());
49
- else if (t.mode === "runtime")
50
- this._configureRuntime(t);
51
- else
52
- throw new a("[Raph] Unsupported facade mode.");
53
- this._mode = t.mode, this._state = "configured";
54
- } catch (e) {
55
- const i = [e], h = [...this._runtimeOrder].reverse();
56
- this._clearSession();
57
- for (const m of h)
58
- try {
59
- m.dispose();
60
- } catch (_) {
61
- i.push(_);
62
- }
63
- throw i.length === 1 ? e : new AggregateError(i, "[Raph] Facade configuration and cleanup failed.");
64
105
  }
106
+ if (typeof t != "string" || typeof r != "function")
107
+ throw new n("[Raph] Runtime watches require an explicit phase.");
108
+ return s.watch(
109
+ s.rootScope,
110
+ e,
111
+ t,
112
+ r,
113
+ i
114
+ );
115
+ }
116
+ batch(e) {
117
+ return this._reactive().batch(e);
118
+ }
119
+ untracked(e) {
120
+ return this._reactive().untracked(e);
121
+ }
122
+ scope(e) {
123
+ const t = this._session.instance();
124
+ if (t instanceof a) {
125
+ if (e !== void 0)
126
+ throw o("named Runtime scope", t);
127
+ return t.scope();
128
+ }
129
+ if (e === void 0)
130
+ throw new n("[Raph] Runtime scopes require an explicit id.");
131
+ return t.scope(e);
65
132
  }
66
- /**
67
- * Освобождает принадлежащие facade runtimes и возвращает его в исходное состояние.
68
- */
69
- static reset() {
70
- if (this._state === "unconfigured")
71
- return;
72
- if (this._state !== "configured")
73
- throw new a(`[Raph] Cannot reset facade while it is ${this._state}.`);
74
- this._state = "resetting";
75
- const t = [...this._runtimeOrder].reverse();
76
- this._clearBindings(), this._runtimes = /* @__PURE__ */ new Map(), this._runtimeOrder = [], this._defaultRuntime = void 0;
77
- const e = [];
78
- for (const i of t)
79
- try {
80
- i.dispose();
81
- } catch (h) {
82
- e.push(h);
83
- }
84
- if (this._clearSession(), e.length === 1)
85
- throw e[0];
86
- if (e.length > 1)
87
- throw new AggregateError(e, "[Raph] Facade reset failed.");
133
+ action(e, t) {
134
+ return typeof e == "function" ? this._runtime().action(e) : this._runtime().action(e, t);
88
135
  }
89
- /**
90
- * Возвращает default runtime текущей runtime-сессии.
91
- */
92
- static get runtime() {
93
- return this._requireDefault();
136
+ definePhases(e) {
137
+ this._runtime().definePhases(e);
138
+ }
139
+ addPhase(e) {
140
+ this._runtime().addPhase(e);
94
141
  }
142
+ clearPhases() {
143
+ this._runtime().clearPhases();
144
+ }
145
+ requestExecution() {
146
+ this._runtime().requestExecution();
147
+ }
148
+ flush() {
149
+ this._runtime().flush();
150
+ }
151
+ afterFlush() {
152
+ return this._runtime().afterFlush();
153
+ }
154
+ acquireLoop(e) {
155
+ return this._runtime().acquireLoop(e);
156
+ }
157
+ startLoop() {
158
+ this._runtime().startLoop();
159
+ }
160
+ stopLoop() {
161
+ this._runtime().stopLoop();
162
+ }
163
+ aggregate(e) {
164
+ const t = this._runtime();
165
+ return t.aggregate(t.rootScope, e);
166
+ }
167
+ node(e, t) {
168
+ return this._runtime().node(e, t);
169
+ }
170
+ getNode(e) {
171
+ return this._runtime().getNode(e);
172
+ }
173
+ derive(e) {
174
+ return this._runtime().derive(e);
175
+ }
176
+ getDerivedSnapshot() {
177
+ return this._runtime().getDerivedSnapshot();
178
+ }
179
+ path(e, t = {}) {
180
+ return this._runtime().path(e, t);
181
+ }
182
+ get(e, t) {
183
+ return e === void 0 ? this._runtime().get() : this._runtime().get(e, t);
184
+ }
185
+ peek(e, t) {
186
+ return e === void 0 ? this._runtime().peek() : this._runtime().peek(e, t);
187
+ }
188
+ has(e, t) {
189
+ return this._runtime().has(e, t);
190
+ }
191
+ set(e, t, r) {
192
+ this._runtime().set(e, t, r);
193
+ }
194
+ merge(e, t, r) {
195
+ this._runtime().merge(e, t, r);
196
+ }
197
+ delete(e, t) {
198
+ this._runtime().delete(e, t);
199
+ }
200
+ // ---------------------------------------------
201
+ // INTERNAL
202
+ // ---------------------------------------------
95
203
  /**
96
- * Возвращает metadata facade default runtime.
204
+ * Освобождает точную session generation для global reset.
205
+ * @internal
97
206
  */
207
+ _dispose() {
208
+ this._session.dispose();
209
+ }
210
+ // ---------------------------------------------
211
+ // PRIVATE
212
+ // ---------------------------------------------
213
+ _runtime() {
214
+ return this._session.runtime();
215
+ }
216
+ _reactive() {
217
+ return this._session.instance();
218
+ }
219
+ }
220
+ class I {
221
+ static _handle;
222
+ constructor() {
223
+ }
224
+ // ---------------------------------------------
225
+ // PUBLIC API
226
+ // ---------------------------------------------
227
+ static get configured() {
228
+ return this._handle !== void 0;
229
+ }
230
+ static get defaultInstanceId() {
231
+ return this._require().defaultInstanceId;
232
+ }
233
+ static get kernel() {
234
+ return this._require().kernel;
235
+ }
98
236
  static get meta() {
99
- return this._requireDefault().meta;
237
+ return this._require().meta;
100
238
  }
101
- /**
102
- * Возвращает диагностический facade default runtime.
103
- */
104
239
  static get debug() {
105
- return this._requireDefault().debug;
240
+ return this._require().debug;
106
241
  }
107
- /**
108
- * Возвращает корневой node default runtime.
109
- */
110
242
  static get root() {
111
- return this._requireDefault().root;
243
+ return this._require().root;
112
244
  }
113
- /**
114
- * Формирует снимок materialized derived default runtime.
115
- */
116
- static getDerivedSnapshot() {
117
- return this._requireDefault().getDerivedSnapshot();
245
+ static get rootScope() {
246
+ return this._require().rootScope;
118
247
  }
119
- /**
120
- * Создаёт независимый path/kernel owner в runtime-режиме.
121
- */
122
- static createKernel(t = {}) {
123
- return this._requireMode("runtime"), new o(t);
248
+ static get frameTick() {
249
+ return this._require().frameTick;
124
250
  }
125
- /**
126
- * Создаёт и регистрирует принадлежащий facade runtime.
127
- */
128
- static createRuntime(t = {}) {
129
- this._requireMode("runtime");
130
- const e = this._resolveRuntimeId(t.id);
131
- if (this._runtimes.has(e))
132
- throw new a(`[Raph] Runtime id "${e}" is already registered.`);
133
- const i = new d({
134
- ...this._runtimeDefaults,
135
- ...t,
136
- id: e
137
- });
138
- return this._registerRuntime(i), i;
251
+ static get frame() {
252
+ return this._require().frame;
139
253
  }
140
- /**
141
- * Возвращает зарегистрированный runtime без ошибки при его отсутствии.
142
- */
143
- static getRuntime(t) {
144
- return this._requireMode("runtime"), this._validateRuntimeId(t), this._runtimes.get(t);
254
+ static get phases() {
255
+ return this._require().phases;
145
256
  }
146
- /**
147
- * Возвращает зарегистрированный runtime либо отклоняет неизвестный id.
148
- */
149
- static requireRuntime(t) {
150
- const e = this.getRuntime(t);
151
- if (e === void 0)
152
- throw new a(`[Raph] Runtime "${t}" is not registered.`);
153
- return e;
257
+ static get loopEnabled() {
258
+ return this._require().loopEnabled;
154
259
  }
155
- /**
156
- * Проверяет наличие runtime в registry текущей сессии.
157
- */
158
- static hasRuntime(t) {
159
- return this.getRuntime(t) !== void 0;
260
+ static configure(e) {
261
+ if (this._handle !== void 0)
262
+ throw new c("[Raph] Facade is already configured.");
263
+ const t = new g(m.create(e));
264
+ return this._handle = t, t;
160
265
  }
161
- /**
162
- * Освобождает зарегистрированный runtime с указанным id.
163
- */
164
- static disposeRuntime(t) {
165
- const e = this.getRuntime(t);
166
- return e === void 0 ? !1 : (e.dispose(), !0);
266
+ static reset() {
267
+ const e = this._handle;
268
+ e !== void 0 && (this._handle = void 0, e._dispose());
167
269
  }
168
- /**
169
- * Заменяет phases default runtime до первого выполнения pipeline.
170
- */
171
- static definePhases(t) {
172
- this._requireDefault().definePhases(t);
270
+ static instance(e) {
271
+ return this._require().instance(e);
173
272
  }
174
- /**
175
- * Добавляет phase в default runtime до первого выполнения pipeline.
176
- */
177
- static addPhase(t) {
178
- this._requireDefault().addPhase(t);
273
+ static getInstance(e) {
274
+ return this._require().getInstance(e);
179
275
  }
180
- /**
181
- * Удаляет phases default runtime до первого выполнения pipeline.
182
- */
183
- static clearPhases() {
184
- this._requireDefault().clearPhases();
276
+ static hasInstance(e) {
277
+ return this._require().hasInstance(e);
185
278
  }
186
- /**
187
- * Синхронно выполняет накопленную работу default runtime.
188
- */
189
- static flush() {
190
- this._requireDefault().flush();
279
+ static disposeInstance(e) {
280
+ return this._require().disposeInstance(e);
191
281
  }
192
- /**
193
- * Удерживает frame loop активным от имени указанного owner.
194
- */
195
- static acquireLoop(t) {
196
- return this._requireDefault().acquireLoop(t);
282
+ static runtime(e) {
283
+ return this._require().runtime(e);
197
284
  }
198
- /**
199
- * Явно запускает frame loop default runtime.
200
- */
201
- static startLoop() {
202
- this._requireDefault().startLoop();
285
+ static reactivity(e) {
286
+ return this._require().reactivity(e);
203
287
  }
204
- /**
205
- * Снимает явный запуск frame loop default runtime.
206
- */
207
- static stopLoop() {
208
- this._requireDefault().stopLoop();
288
+ static createRuntime(e = {}) {
289
+ return this._require().createRuntime(e);
209
290
  }
210
- /**
211
- * Создаёт принадлежащий default runtime node и выполняет его setup.
212
- */
213
- static node(t, e) {
214
- return this._requireDefault().node(t, e);
291
+ static createReactivity(e = {}) {
292
+ return this._require().createReactivity(e);
215
293
  }
216
- /**
217
- * Регистрирует materialized path dependency в default runtime.
218
- */
219
- static derive(t) {
220
- return this._requireDefault().derive(t);
294
+ static createKernel(e = {}) {
295
+ return this._require().createKernel(e);
221
296
  }
222
- /**
223
- * Создаёт lifecycle-aware handle указанного data path.
224
- */
225
- static path(t, e = {}) {
226
- return this._requireDefault().path(t, e);
297
+ static signal(e) {
298
+ return this._require().signal(e);
227
299
  }
228
- static get(t, e) {
229
- const i = this._requireDefault();
230
- return t === void 0 ? i.get() : i.get(t, e);
300
+ static reactive(e) {
301
+ return this._require().reactive(e);
231
302
  }
232
- static peek(t, e) {
233
- const i = this._requireDefault();
234
- return t === void 0 ? i.peek() : i.peek(t, e);
303
+ static computed(e) {
304
+ return typeof e == "function" ? this._require().computed(e) : this._require().computed(e);
235
305
  }
236
- /**
237
- * Проверяет наличие значения по указанному path.
238
- */
239
- static has(t, e) {
240
- return this._requireDefault().has(t, e);
306
+ static effect(e, t, r) {
307
+ return typeof e == "function" ? this._require().effect(e) : this._require().effect(e, t, r);
241
308
  }
242
- /**
243
- * Заменяет значение по указанному path.
244
- */
245
- static set(t, e, i) {
246
- this._requireDefault().set(t, e, i);
309
+ static watch(e, t, r, i) {
310
+ const s = this._require();
311
+ return typeof t == "string" ? s.watch(
312
+ e,
313
+ t,
314
+ r,
315
+ i
316
+ ) : s.watch(
317
+ e,
318
+ t,
319
+ r
320
+ );
247
321
  }
248
- /**
249
- * Объединяет значение с существующим объектом по указанному path.
250
- */
251
- static merge(t, e, i) {
252
- this._requireDefault().merge(t, e, i);
322
+ static batch(e) {
323
+ return this._require().batch(e);
253
324
  }
254
- /**
255
- * Удаляет значение по указанному path.
256
- */
257
- static delete(t, e) {
258
- this._requireDefault().delete(t, e);
325
+ static untracked(e) {
326
+ return this._require().untracked(e);
259
327
  }
260
- /**
261
- * Выполняет несколько mutations как одну реактивную транзакцию.
262
- */
263
- static transaction(t) {
264
- return this._requireDefault().transaction(t);
328
+ static scope(e) {
329
+ return e === void 0 ? this._require().scope() : this._require().scope(e);
265
330
  }
266
- /**
267
- * Оборачивает операцию в именованную action текущего runtime.
268
- */
269
- static action(t, e) {
270
- return this._requireDefault().action(t, e);
331
+ static action(e, t) {
332
+ return typeof e == "function" ? this._require().action(e) : this._require().action(e, t);
271
333
  }
272
- /**
273
- * Немедленно выполняет именованную action текущего runtime.
274
- */
275
- static runInAction(t, e) {
276
- return this._requireDefault().runInAction(t, e);
277
- }
278
- static _configureReactivity(t) {
279
- this._reactivity = t, this.signal = t.signal, this.computed = t.computed, this.effect = ((e) => {
280
- if (typeof e != "function")
281
- throw new f("[Raph] Phase effects require runtime mode.");
282
- return t.effect(e);
283
- }), this.watch = t.watch, this.batch = t.batch, this.untracked = t.untracked, this.scope = t.scope;
284
- }
285
- static _configureRuntime(t) {
286
- if (this._runtimeDefaults = {
287
- ...t.scheduler === void 0 ? {} : { scheduler: t.scheduler },
288
- ...t.enforceActions === void 0 ? {} : { enforceActions: t.enforceActions }
289
- }, t.createDefaultRuntime === !1) {
290
- this._installMissingDefaultBindings();
291
- return;
292
- }
293
- const e = t.defaultRuntimeId ?? "default";
294
- this._validateRuntimeId(e);
295
- const i = new d({
296
- ...this._runtimeDefaults,
297
- ...t.kernel === void 0 ? {} : { kernel: t.kernel },
298
- id: e
299
- });
300
- this._registerRuntime(i), t.phases !== void 0 && i.definePhases(t.phases), this._defaultRuntime = i, this._bindRuntime(i);
301
- }
302
- static _bindRuntime(t) {
303
- this.signal = t.signal.bind(t), this.computed = t.computed.bind(t), this.effect = t.effect.bind(t), this.watch = t.watch.bind(t), this.batch = t.transaction.bind(t), this.untracked = t.untracked.bind(t), this.scope = t.scope.bind(t);
304
- }
305
- static _registerRuntime(t) {
306
- this._runtimes.set(t.id, t), this._runtimeOrder.push(t), t._onDisposed(() => {
307
- this._runtimes.get(t.id) === t && this._runtimes.delete(t.id);
308
- const e = this._runtimeOrder.indexOf(t);
309
- e >= 0 && this._runtimeOrder.splice(e, 1), this._defaultRuntime === t && (this._defaultRuntime = void 0, this._state === "configured" && this._installMissingDefaultBindings());
310
- });
311
- }
312
- static _requireDefault() {
313
- this._requireMode("runtime");
314
- const t = this._defaultRuntime;
315
- if (t === void 0)
316
- throw new l("[Raph] Runtime mode has no default Runtime.");
317
- return t;
318
- }
319
- static _requireMode(t) {
320
- if (this._state !== "configured" && n(), this._mode !== t)
321
- throw new f(`[Raph] Operation requires ${t} mode.`);
322
- }
323
- static _resolveRuntimeId(t) {
324
- if (t !== void 0)
325
- return this._validateRuntimeId(t), t;
326
- let e;
327
- do
328
- e = `runtime-${this._runtimeCounter++}`;
329
- while (this._runtimes.has(e));
330
- return e;
334
+ static definePhases(e) {
335
+ this._require().definePhases(e);
331
336
  }
332
- static _validateRuntimeId(t) {
333
- if (typeof t != "string" || t.length === 0 || t.trim() !== t)
334
- throw new a(
335
- "[Raph] Runtime id must be a non-empty string without surrounding whitespace."
336
- );
337
+ static addPhase(e) {
338
+ this._require().addPhase(e);
337
339
  }
338
- static _validateConfigureOptions(t) {
339
- if (typeof t != "object" || t === null)
340
- throw new a("[Raph] Configure options must be an object.");
341
- if (t.mode === "reactivity") {
342
- this._assertKnownOptions(t, /* @__PURE__ */ new Set(["mode"]));
343
- return;
344
- }
345
- if (t.mode !== "runtime")
346
- throw new a("[Raph] Unsupported facade mode.");
347
- if (this._assertKnownOptions(t, /* @__PURE__ */ new Set([
348
- "mode",
349
- "createDefaultRuntime",
350
- "defaultRuntimeId",
351
- "kernel",
352
- "phases",
353
- "scheduler",
354
- "enforceActions"
355
- ])), t.createDefaultRuntime !== void 0 && t.createDefaultRuntime !== !0 && t.createDefaultRuntime !== !1)
356
- throw new a("[Raph] createDefaultRuntime must be boolean.");
357
- if (t.scheduler !== void 0 && !q(t.scheduler))
358
- throw new a(
359
- `[Raph] Unsupported scheduler "${String(t.scheduler)}".`
360
- );
361
- if (t.enforceActions !== void 0 && typeof t.enforceActions != "boolean")
362
- throw new a("[Raph] enforceActions must be boolean.");
363
- if (t.createDefaultRuntime === !1) {
364
- if (t.defaultRuntimeId !== void 0 || t.kernel !== void 0 || t.phases !== void 0)
365
- throw new a(
366
- "[Raph] Registry-only mode cannot receive defaultRuntimeId, kernel or phases."
367
- );
368
- return;
369
- }
370
- if (t.defaultRuntimeId !== void 0 && this._validateRuntimeId(t.defaultRuntimeId), t.kernel !== void 0 && !(t.kernel instanceof o))
371
- throw new a("[Raph] kernel must be a RaphKernel instance.");
372
- if (t.phases !== void 0 && !Array.isArray(t.phases))
373
- throw new a("[Raph] phases must be an array.");
340
+ static clearPhases() {
341
+ this._require().clearPhases();
374
342
  }
375
- static _assertKnownOptions(t, e) {
376
- for (const i of Object.keys(t))
377
- if (!e.has(i))
378
- throw new a(`[Raph] Unsupported configure option "${i}".`);
343
+ static requestExecution() {
344
+ this._require().requestExecution();
379
345
  }
380
- static _installMissingDefaultBindings() {
381
- const t = () => {
382
- throw new l("[Raph] Runtime mode has no default Runtime.");
383
- };
384
- this.signal = t, this.computed = t, this.effect = t, this.watch = t, this.batch = t, this.untracked = t, this.scope = t;
346
+ static flush() {
347
+ this._require().flush();
385
348
  }
386
- static _clearBindings() {
387
- this.signal = n, this.computed = n, this.effect = n, this.watch = n, this.batch = n, this.untracked = n, this.scope = n;
349
+ static afterFlush() {
350
+ return this._require().afterFlush();
388
351
  }
389
- static _clearSession() {
390
- this._clearBindings(), this._state = "unconfigured", this._mode = void 0, this._defaultRuntime = void 0, this._reactivity = void 0, this._runtimes = /* @__PURE__ */ new Map(), this._runtimeOrder = [], this._runtimeDefaults = {};
352
+ static acquireLoop(e) {
353
+ return this._require().acquireLoop(e);
391
354
  }
392
- /**
393
- * Запрещает создание экземпляров статического facade.
394
- */
395
- constructor() {
355
+ static startLoop() {
356
+ this._require().startLoop();
357
+ }
358
+ static stopLoop() {
359
+ this._require().stopLoop();
360
+ }
361
+ static aggregate(e) {
362
+ return this._require().aggregate(e);
363
+ }
364
+ static node(e, t) {
365
+ return this._require().node(e, t);
366
+ }
367
+ static getNode(e) {
368
+ return this._require().getNode(e);
369
+ }
370
+ static derive(e) {
371
+ return this._require().derive(e);
372
+ }
373
+ static getDerivedSnapshot() {
374
+ return this._require().getDerivedSnapshot();
375
+ }
376
+ static path(e, t = {}) {
377
+ return this._require().path(e, t);
378
+ }
379
+ static get(e, t) {
380
+ return e === void 0 ? this._require().get() : this._require().get(e, t);
381
+ }
382
+ static peek(e, t) {
383
+ return e === void 0 ? this._require().peek() : this._require().peek(e, t);
384
+ }
385
+ static has(e, t) {
386
+ return this._require().has(e, t);
387
+ }
388
+ static set(e, t, r) {
389
+ this._require().set(e, t, r);
390
+ }
391
+ static merge(e, t, r) {
392
+ this._require().merge(e, t, r);
393
+ }
394
+ static delete(e, t) {
395
+ this._require().delete(e, t);
396
+ }
397
+ static Scheduler = f;
398
+ static DerivedStrategy = Object.freeze({
399
+ full: d,
400
+ collectionByKey: _,
401
+ filterByKey: h
402
+ });
403
+ // ---------------------------------------------
404
+ // PRIVATE
405
+ // ---------------------------------------------
406
+ static _require() {
407
+ const e = this._handle;
408
+ if (e === void 0)
409
+ throw new c("[Raph] Facade is not configured. Call Raph.configure(...) first.");
410
+ return e;
396
411
  }
397
412
  }
398
- // Хранят lifecycle facade, выбранный backend и принадлежащий сессии runtime registry.
399
- r(s, "_state", "unconfigured"), r(s, "_mode"), r(s, "_defaultRuntime"), r(s, "_reactivity"), r(s, "_runtimes", /* @__PURE__ */ new Map()), r(s, "_runtimeOrder", []), r(s, "_runtimeCounter", 0), r(s, "_runtimeDefaults", {}), // Публикуют операции выбранного backend после успешной конфигурации facade.
400
- r(s, "signal", n), r(s, "computed", n), r(s, "effect", n), r(s, "watch", n), r(s, "batch", n), r(s, "untracked", n), r(s, "scope", n), // ---------------------------------------------
401
- // SUGAR
402
- // ---------------------------------------------
403
- /**
404
- * Предоставляет режимы scheduler без отдельного импорта константы.
405
- */
406
- r(s, "Scheduler", c), /**
407
- * Предоставляет стратегии materialized derived рядом с facade API.
408
- */
409
- r(s, "DerivedStrategy", Object.freeze({
410
- full: v,
411
- collectionByKey: p,
412
- filterByKey: R
413
- }));
414
- function q(u) {
415
- return u === c.Sync || u === c.Microtask || u === c.AnimationFrame;
413
+ function o(u, e) {
414
+ return new n(
415
+ `[Raph] ${u} is unavailable for reactivity instance "${e.id}".`
416
+ );
416
417
  }
417
418
  export {
418
- s as Raph
419
+ I as Raph
419
420
  };