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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/README.md +1096 -0
  2. package/dist/api/Raph.d.ts +59 -190
  3. package/dist/api/RaphFacadeSession.d.ts +90 -0
  4. package/dist/api/RaphReactivityInstance.d.ts +72 -0
  5. package/dist/api/errors.d.ts +9 -4
  6. package/dist/api/types.d.ts +162 -17
  7. package/dist/core-CyilRD7s.js +1055 -0
  8. package/dist/core-ugchZNqC.cjs +1 -0
  9. package/dist/debug/api/Raph.cjs +1 -1
  10. package/dist/debug/api/Raph.js +368 -366
  11. package/dist/debug/api/RaphFacadeSession.cjs +1 -0
  12. package/dist/debug/api/RaphFacadeSession.js +306 -0
  13. package/dist/debug/api/RaphReactivityInstance.cjs +1 -0
  14. package/dist/debug/api/RaphReactivityInstance.js +149 -0
  15. package/dist/debug/api/errors.cjs +1 -1
  16. package/dist/debug/api/errors.js +10 -7
  17. package/dist/debug/path/DataPath.cjs +1 -0
  18. package/dist/debug/path/{data-path.js → DataPath.js} +151 -180
  19. package/dist/debug/path/PathRouter.cjs +1 -0
  20. package/dist/debug/path/{path-router.js → PathRouter.js} +1 -1
  21. package/dist/debug/path/RaphKernel.cjs +1 -1
  22. package/dist/debug/path/RaphKernel.js +258 -207
  23. package/dist/debug/path/data-path.utils.cjs +1 -0
  24. package/dist/debug/path/data-path.utils.js +56 -0
  25. package/dist/debug/path/derived/DerivedRegistry.cjs +1 -0
  26. package/dist/debug/path/{DerivedRegistry.js → derived/DerivedRegistry.js} +5 -5
  27. package/dist/debug/path/derived/derived-collection.utils.cjs +1 -0
  28. package/dist/debug/path/{derived-collection.js → derived/derived-collection.utils.js} +1 -1
  29. package/dist/debug/path/derived/derived-strategy.types.cjs +1 -0
  30. package/dist/debug/path/derived/derived-strategy.types.js +1 -0
  31. package/dist/debug/path/{MetaController.cjs → meta/MetaController.cjs} +1 -1
  32. package/dist/debug/path/{MetaController.js → meta/MetaController.js} +3 -3
  33. package/dist/debug/path/meta/RaphMetaStore.cjs +1 -0
  34. package/dist/debug/path/{RaphMetaStore.js → meta/RaphMetaStore.js} +1 -1
  35. package/dist/debug/path/meta/meta.types.cjs +1 -0
  36. package/dist/debug/path/meta/meta.types.js +1 -0
  37. package/dist/debug/path/storage/AdapterPathStore.cjs +1 -0
  38. package/dist/debug/path/{AdapterPathStore.js → storage/AdapterPathStore.js} +9 -9
  39. package/dist/debug/path/storage/DefaultDataAdapter.cjs +1 -0
  40. package/dist/debug/path/{data-adapter.js → storage/DefaultDataAdapter.js} +2 -2
  41. package/dist/debug/path/storage/PathEventHub.cjs +1 -0
  42. package/dist/debug/path/{PathEventHub.js → storage/PathEventHub.js} +34 -34
  43. package/dist/debug/path/storage/PathStore.cjs +1 -0
  44. package/dist/debug/path/{PathStore.js → storage/PathStore.js} +28 -28
  45. package/dist/debug/path/storage/data-adapter.types.cjs +1 -0
  46. package/dist/debug/path/storage/data-adapter.types.js +1 -0
  47. package/dist/debug/reactivity/engine.cjs +1 -1
  48. package/dist/debug/reactivity/engine.js +478 -306
  49. package/dist/debug/reactivity/reactive-object.cjs +1 -0
  50. package/dist/debug/reactivity/reactive-object.js +280 -0
  51. package/dist/debug/runtime/RaphRuntime.cjs +1 -1
  52. package/dist/debug/runtime/RaphRuntime.js +798 -519
  53. package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -0
  54. package/dist/debug/runtime/diagnostics/RaphDebug.js +297 -0
  55. package/dist/debug/runtime/errors.cjs +1 -1
  56. package/dist/debug/runtime/errors.js +6 -3
  57. package/dist/debug/runtime/ownership/RaphEffectScope.cjs +1 -0
  58. package/dist/debug/runtime/ownership/RaphEffectScope.js +171 -0
  59. package/dist/debug/runtime/ownership/RaphNode.cjs +1 -0
  60. package/dist/debug/runtime/ownership/RaphNode.js +206 -0
  61. package/dist/debug/runtime/ownership/RaphScope.cjs +1 -0
  62. package/dist/debug/runtime/ownership/RaphScope.js +101 -0
  63. package/dist/debug/runtime/ownership/parent-graph.types.cjs +1 -0
  64. package/dist/debug/runtime/ownership/parent-graph.types.js +1 -0
  65. package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -0
  66. package/dist/debug/runtime/phases/RaphPhasePipeline.js +587 -0
  67. package/dist/debug/runtime/phases/orderPhaseTasks.cjs +1 -0
  68. package/dist/debug/runtime/phases/orderPhaseTasks.js +59 -0
  69. package/dist/debug/runtime/reactivity/PathHandle.cjs +1 -0
  70. package/dist/debug/runtime/{PathHandle.js → reactivity/PathHandle.js} +75 -39
  71. package/dist/debug/runtime/reactivity/RaphMetaSource.cjs +1 -0
  72. package/dist/debug/runtime/reactivity/RaphMetaSource.js +112 -0
  73. package/dist/debug/runtime/reactivity/RaphWorkGraph.cjs +1 -0
  74. package/dist/debug/runtime/reactivity/RaphWorkGraph.js +995 -0
  75. package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -0
  76. package/dist/debug/runtime/reactivity/RuntimeReactivity.js +156 -0
  77. package/dist/debug/runtime/reactivity/RuntimeWatch.cjs +1 -0
  78. package/dist/debug/runtime/reactivity/RuntimeWatch.js +88 -0
  79. package/dist/debug/runtime/reactivity/runtime-reactivity.types.cjs +1 -0
  80. package/dist/debug/runtime/reactivity/runtime-reactivity.types.js +1 -0
  81. package/dist/entrypoints/machine-testing.d.ts +2 -0
  82. package/dist/entrypoints/machine.d.ts +5 -0
  83. package/dist/entrypoints/path.d.ts +14 -0
  84. package/dist/entrypoints/reactivity.d.ts +1 -0
  85. package/dist/entrypoints/runtime.d.ts +17 -0
  86. package/dist/index.cjs +1 -1
  87. package/dist/index.js +46 -38
  88. package/dist/machine/compiler.d.ts +71 -0
  89. package/dist/machine/core.d.ts +50 -0
  90. package/dist/machine/persistence.d.ts +5 -0
  91. package/dist/machine/runtime.d.ts +4 -0
  92. package/dist/machine/testing.d.ts +43 -0
  93. package/dist/machine/types.d.ts +155 -0
  94. package/dist/machine-testing.cjs +1 -0
  95. package/dist/machine-testing.js +188 -0
  96. package/dist/machine.cjs +1 -0
  97. package/dist/machine.js +837 -0
  98. package/dist/main.d.ts +20 -0
  99. package/dist/path/{data-path.d.ts → DataPath.d.ts} +16 -40
  100. package/dist/path/{path-router.d.ts → PathRouter.d.ts} +1 -1
  101. package/dist/path/RaphKernel.d.ts +13 -10
  102. package/dist/path/data-path.types.d.ts +34 -0
  103. package/dist/path/data-path.utils.d.ts +9 -0
  104. package/dist/path/{DerivedRegistry.d.ts → derived/DerivedRegistry.d.ts} +2 -2
  105. package/dist/path/{RaphDerivedHandle.d.ts → derived/RaphDerivedHandle.d.ts} +3 -3
  106. package/dist/path/derived/derived-collection.types.d.ts +12 -0
  107. package/dist/path/{derived-collection.d.ts → derived/derived-collection.utils.d.ts} +3 -13
  108. package/dist/path/{derived-strategies.d.ts → derived/derived-strategy.types.d.ts} +0 -3
  109. package/dist/path/derived/derived-strategy.utils.d.ts +4 -0
  110. package/dist/path/{MetaController.d.ts → meta/MetaController.d.ts} +4 -4
  111. package/dist/path/{RaphMeta.d.ts → meta/RaphMeta.d.ts} +2 -2
  112. package/dist/path/{RaphMetaStore.d.ts → meta/RaphMetaStore.d.ts} +1 -1
  113. package/dist/path/{meta.types.d.ts → meta/meta.types.d.ts} +2 -4
  114. package/dist/path/path.types.d.ts +3 -2
  115. package/dist/path/{segment-key.d.ts → pathSegmentKey.d.ts} +1 -1
  116. package/dist/path/{AdapterPathStore.d.ts → storage/AdapterPathStore.d.ts} +4 -4
  117. package/dist/path/{data-adapter.d.ts → storage/DefaultDataAdapter.d.ts} +2 -17
  118. package/dist/path/{PathEventHub.d.ts → storage/PathEventHub.d.ts} +9 -9
  119. package/dist/path/{PathStore.d.ts → storage/PathStore.d.ts} +3 -3
  120. package/dist/path/storage/data-adapter.types.d.ts +17 -0
  121. package/dist/path.cjs +1 -1
  122. package/dist/path.js +16 -16
  123. package/dist/raph.cjs +1 -1
  124. package/dist/raph.js +46 -38
  125. package/dist/reactivity/engine.d.ts +17 -3
  126. package/dist/reactivity/reactive-object.d.ts +36 -0
  127. package/dist/reactivity/types.d.ts +25 -0
  128. package/dist/reactivity.cjs +1 -1
  129. package/dist/reactivity.js +12 -12
  130. package/dist/runtime/RaphRuntime.d.ts +132 -192
  131. package/dist/runtime/diagnostics/RaphDebug.d.ts +239 -0
  132. package/dist/runtime/errors.d.ts +5 -0
  133. package/dist/runtime/ownership/RaphEffectScope.d.ts +29 -0
  134. package/dist/runtime/ownership/RaphNode.d.ts +40 -0
  135. package/dist/runtime/ownership/RaphScope.d.ts +38 -0
  136. package/dist/runtime/{parent-graph.d.ts → ownership/parent-graph.types.d.ts} +0 -1
  137. package/dist/runtime/ownership/parentGraph.d.ts +3 -0
  138. package/dist/runtime/phases/RaphPhasePipeline.d.ts +79 -0
  139. package/dist/runtime/phases/orderPhaseTasks.d.ts +6 -0
  140. package/dist/runtime/phases/phase.types.d.ts +92 -0
  141. package/dist/runtime/{PathHandle.d.ts → reactivity/PathHandle.d.ts} +14 -6
  142. package/dist/runtime/reactivity/RaphMetaSource.d.ts +32 -0
  143. package/dist/runtime/reactivity/RaphWorkGraph.d.ts +171 -0
  144. package/dist/runtime/{RuntimeReactivity.d.ts → reactivity/RuntimeReactivity.d.ts} +14 -9
  145. package/dist/runtime/{RuntimeWatch.d.ts → reactivity/RuntimeWatch.d.ts} +9 -3
  146. package/dist/runtime/{runtime-reactivity.types.d.ts → reactivity/runtime-reactivity.types.d.ts} +3 -1
  147. package/dist/runtime.cjs +1 -1
  148. package/dist/runtime.js +21 -16
  149. package/package.json +68 -35
  150. package/ReadMe.md +0 -153
  151. package/dist/api/public.d.ts +0 -22
  152. package/dist/debug/api/public.cjs +0 -1
  153. package/dist/debug/api/public.js +0 -40
  154. package/dist/debug/path/AdapterPathStore.cjs +0 -1
  155. package/dist/debug/path/DerivedRegistry.cjs +0 -1
  156. package/dist/debug/path/PathEventHub.cjs +0 -1
  157. package/dist/debug/path/PathStore.cjs +0 -1
  158. package/dist/debug/path/RaphMetaStore.cjs +0 -1
  159. package/dist/debug/path/data-adapter.cjs +0 -1
  160. package/dist/debug/path/data-path.cjs +0 -1
  161. package/dist/debug/path/derived-collection.cjs +0 -1
  162. package/dist/debug/path/path-router.cjs +0 -1
  163. package/dist/debug/path/public.cjs +0 -1
  164. package/dist/debug/path/public.js +0 -18
  165. package/dist/debug/runtime/PathHandle.cjs +0 -1
  166. package/dist/debug/runtime/RaphDebug.cjs +0 -1
  167. package/dist/debug/runtime/RaphDebug.js +0 -15
  168. package/dist/debug/runtime/RaphNode.cjs +0 -1
  169. package/dist/debug/runtime/RaphNode.js +0 -143
  170. package/dist/debug/runtime/RaphPhasePipeline.cjs +0 -1
  171. package/dist/debug/runtime/RaphPhasePipeline.js +0 -526
  172. package/dist/debug/runtime/RaphScope.cjs +0 -1
  173. package/dist/debug/runtime/RaphScope.js +0 -64
  174. package/dist/debug/runtime/RuntimeReactivity.cjs +0 -1
  175. package/dist/debug/runtime/RuntimeReactivity.js +0 -154
  176. package/dist/debug/runtime/RuntimeWatch.cjs +0 -1
  177. package/dist/debug/runtime/RuntimeWatch.js +0 -71
  178. package/dist/debug/runtime/public.cjs +0 -1
  179. package/dist/debug/runtime/public.js +0 -18
  180. package/dist/path/public.d.ts +0 -14
  181. package/dist/runtime/RaphDebug.d.ts +0 -32
  182. package/dist/runtime/RaphNode.d.ts +0 -68
  183. package/dist/runtime/RaphPhasePipeline.d.ts +0 -133
  184. package/dist/runtime/RaphScope.d.ts +0 -50
  185. package/dist/runtime/phase.types.d.ts +0 -49
  186. package/dist/runtime/public.d.ts +0 -13
  187. /package/dist/debug/path/{meta.types.cjs → data-path.types.cjs} +0 -0
  188. /package/dist/debug/path/{meta.types.js → data-path.types.js} +0 -0
  189. /package/dist/debug/path/{RaphDerivedHandle.cjs → derived/RaphDerivedHandle.cjs} +0 -0
  190. /package/dist/debug/path/{RaphDerivedHandle.js → derived/RaphDerivedHandle.js} +0 -0
  191. /package/dist/debug/{runtime/runtime-reactivity.types.cjs → path/derived/derived-collection.types.cjs} +0 -0
  192. /package/dist/debug/{runtime/runtime-reactivity.types.js → path/derived/derived-collection.types.js} +0 -0
  193. /package/dist/debug/path/{derived-strategies.cjs → derived/derived-strategy.utils.cjs} +0 -0
  194. /package/dist/debug/path/{derived-strategies.js → derived/derived-strategy.utils.js} +0 -0
  195. /package/dist/debug/path/{RaphMeta.cjs → meta/RaphMeta.cjs} +0 -0
  196. /package/dist/debug/path/{RaphMeta.js → meta/RaphMeta.js} +0 -0
  197. /package/dist/debug/path/{segment-key.cjs → pathSegmentKey.cjs} +0 -0
  198. /package/dist/debug/path/{segment-key.js → pathSegmentKey.js} +0 -0
  199. /package/dist/debug/path/{data-draft.cjs → storage/createDataDraft.cjs} +0 -0
  200. /package/dist/debug/path/{data-draft.js → storage/createDataDraft.js} +0 -0
  201. /package/dist/debug/runtime/{parent-graph.cjs → ownership/parentGraph.cjs} +0 -0
  202. /package/dist/debug/runtime/{parent-graph.js → ownership/parentGraph.js} +0 -0
  203. /package/dist/debug/runtime/{disposal.cjs → ownership/throwDisposalErrors.cjs} +0 -0
  204. /package/dist/debug/runtime/{disposal.js → ownership/throwDisposalErrors.js} +0 -0
  205. /package/dist/debug/runtime/{RaphFrameLoop.cjs → phases/RaphFrameLoop.cjs} +0 -0
  206. /package/dist/debug/runtime/{RaphFrameLoop.js → phases/RaphFrameLoop.js} +0 -0
  207. /package/dist/debug/runtime/{phase.types.cjs → phases/phase.types.cjs} +0 -0
  208. /package/dist/debug/runtime/{phase.types.js → phases/phase.types.js} +0 -0
  209. /package/dist/path/{data-draft.d.ts → storage/createDataDraft.d.ts} +0 -0
  210. /package/dist/runtime/{disposal.d.ts → ownership/throwDisposalErrors.d.ts} +0 -0
  211. /package/dist/runtime/{RaphFrameLoop.d.ts → phases/RaphFrameLoop.d.ts} +0 -0
@@ -1,419 +1,421 @@
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
+ var d = Object.defineProperty;
2
+ var f = (i, e, t) => e in i ? d(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
+ var u = (i, e, t) => f(i, typeof e != "symbol" ? e + "" : e, t);
4
+ import { filterByKey as p, collectionByKey as m, full as g } from "../path/derived/derived-strategy.utils.js";
5
+ import { RaphSchedulerType as q } from "../runtime/phases/phase.types.js";
6
+ import { RaphRuntime as v } from "../runtime/RaphRuntime.js";
7
+ import { RaphConfigurationError as _, RaphCapabilityError as a } from "./errors.js";
8
+ import { RaphFacadeSession as l } from "./RaphFacadeSession.js";
9
+ import { RaphReactivityInstance as o } from "./RaphReactivityInstance.js";
10
+ class y {
11
+ constructor(e) {
12
+ this._session = e;
30
13
  }
31
- /**
32
- * Возвращает выбранный режим либо `undefined` до конфигурации.
33
- */
34
- static get mode() {
35
- return this._mode;
14
+ // ---------------------------------------------
15
+ // PUBLIC API
16
+ // ---------------------------------------------
17
+ get configured() {
18
+ return !0;
36
19
  }
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}.`
20
+ get defaultInstanceId() {
21
+ return this._session.defaultInstanceId;
22
+ }
23
+ get kernel() {
24
+ return this._runtime().kernel;
25
+ }
26
+ get meta() {
27
+ return this._runtime().meta;
28
+ }
29
+ get debug() {
30
+ return this._runtime().debug;
31
+ }
32
+ get root() {
33
+ return this._runtime().root;
34
+ }
35
+ get rootScope() {
36
+ return this._runtime().rootScope;
37
+ }
38
+ get frameTick() {
39
+ return this._runtime().frameTick;
40
+ }
41
+ get frame() {
42
+ return this._runtime().frame;
43
+ }
44
+ get phases() {
45
+ return this._runtime().phases;
46
+ }
47
+ get loopEnabled() {
48
+ return this._runtime().loopEnabled;
49
+ }
50
+ instance(e) {
51
+ return this._session.instance(e);
52
+ }
53
+ getInstance(e) {
54
+ return this._session.getInstance(e);
55
+ }
56
+ hasInstance(e) {
57
+ return this._session.hasInstance(e);
58
+ }
59
+ disposeInstance(e) {
60
+ return this._session.disposeInstance(e);
61
+ }
62
+ runtime(e) {
63
+ return this._session.runtime(e);
64
+ }
65
+ reactivity(e) {
66
+ return this._session.reactivity(e);
67
+ }
68
+ createRuntime(e = {}) {
69
+ return this._session.createRuntime(e);
70
+ }
71
+ createReactivity(e = {}) {
72
+ return this._session.createReactivity(e);
73
+ }
74
+ createKernel(e = {}) {
75
+ return this._session.createKernel(e);
76
+ }
77
+ signal(e) {
78
+ return this._reactive().signal(e);
79
+ }
80
+ reactive(e) {
81
+ return this._reactive().reactive(e);
82
+ }
83
+ computed(e) {
84
+ const t = this._reactive();
85
+ return t instanceof v, t.computed(e);
86
+ }
87
+ effect(e, t, r) {
88
+ const s = this._session.instance();
89
+ if (s instanceof o) {
90
+ if (typeof e != "function" || t !== void 0)
91
+ throw h("phase effect", s);
92
+ return s.effect(e);
93
+ }
94
+ if (typeof e != "string" || t === void 0)
95
+ throw new a("[Raph] Runtime effects require an explicit phase.");
96
+ return s.effect(s.rootScope, e, t, r);
97
+ }
98
+ watch(e, t, r, s) {
99
+ const n = this._session.instance();
100
+ if (n instanceof o) {
101
+ if (typeof t != "function")
102
+ throw h("phase watch", n);
103
+ return n.watch(
104
+ e,
105
+ t,
106
+ r
44
107
  );
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
108
  }
109
+ if (typeof t != "string" || typeof r != "function")
110
+ throw new a("[Raph] Runtime watches require an explicit phase.");
111
+ return n.watch(
112
+ n.rootScope,
113
+ e,
114
+ t,
115
+ r,
116
+ s
117
+ );
118
+ }
119
+ batch(e) {
120
+ return this._reactive().batch(e);
121
+ }
122
+ untracked(e) {
123
+ return this._reactive().untracked(e);
124
+ }
125
+ scope(e) {
126
+ const t = this._session.instance();
127
+ if (t instanceof o) {
128
+ if (e !== void 0)
129
+ throw h("named Runtime scope", t);
130
+ return t.scope();
131
+ }
132
+ if (e === void 0)
133
+ throw new a("[Raph] Runtime scopes require an explicit id.");
134
+ return t.scope(e);
65
135
  }
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.");
136
+ action(e, t) {
137
+ return typeof e == "function" ? this._runtime().action(e) : this._runtime().action(e, t);
88
138
  }
89
- /**
90
- * Возвращает default runtime текущей runtime-сессии.
91
- */
92
- static get runtime() {
93
- return this._requireDefault();
139
+ definePhases(e) {
140
+ this._runtime().definePhases(e);
141
+ }
142
+ addPhase(e) {
143
+ this._runtime().addPhase(e);
94
144
  }
145
+ clearPhases() {
146
+ this._runtime().clearPhases();
147
+ }
148
+ requestExecution() {
149
+ this._runtime().requestExecution();
150
+ }
151
+ flush() {
152
+ this._runtime().flush();
153
+ }
154
+ afterFlush() {
155
+ return this._runtime().afterFlush();
156
+ }
157
+ acquireLoop(e) {
158
+ return this._runtime().acquireLoop(e);
159
+ }
160
+ startLoop() {
161
+ this._runtime().startLoop();
162
+ }
163
+ stopLoop() {
164
+ this._runtime().stopLoop();
165
+ }
166
+ aggregate(e) {
167
+ const t = this._runtime();
168
+ return t.aggregate(t.rootScope, e);
169
+ }
170
+ node(e, t) {
171
+ return this._runtime().node(e, t);
172
+ }
173
+ getNode(e) {
174
+ return this._runtime().getNode(e);
175
+ }
176
+ derive(e) {
177
+ return this._runtime().derive(e);
178
+ }
179
+ getDerivedSnapshot() {
180
+ return this._runtime().getDerivedSnapshot();
181
+ }
182
+ path(e, t = {}) {
183
+ return this._runtime().path(e, t);
184
+ }
185
+ get(e, t) {
186
+ return e === void 0 ? this._runtime().get() : this._runtime().get(e, t);
187
+ }
188
+ peek(e, t) {
189
+ return e === void 0 ? this._runtime().peek() : this._runtime().peek(e, t);
190
+ }
191
+ has(e, t) {
192
+ return this._runtime().has(e, t);
193
+ }
194
+ set(e, t, r) {
195
+ this._runtime().set(e, t, r);
196
+ }
197
+ merge(e, t, r) {
198
+ this._runtime().merge(e, t, r);
199
+ }
200
+ delete(e, t) {
201
+ this._runtime().delete(e, t);
202
+ }
203
+ // ---------------------------------------------
204
+ // INTERNAL
205
+ // ---------------------------------------------
95
206
  /**
96
- * Возвращает metadata facade default runtime.
207
+ * Освобождает точную session generation для global reset.
208
+ * @internal
97
209
  */
210
+ _dispose() {
211
+ this._session.dispose();
212
+ }
213
+ // ---------------------------------------------
214
+ // PRIVATE
215
+ // ---------------------------------------------
216
+ _runtime() {
217
+ return this._session.runtime();
218
+ }
219
+ _reactive() {
220
+ return this._session.instance();
221
+ }
222
+ }
223
+ class c {
224
+ constructor() {
225
+ }
226
+ // ---------------------------------------------
227
+ // PUBLIC API
228
+ // ---------------------------------------------
229
+ static get configured() {
230
+ return this._handle !== void 0;
231
+ }
232
+ static get defaultInstanceId() {
233
+ return this._require().defaultInstanceId;
234
+ }
235
+ static get kernel() {
236
+ return this._require().kernel;
237
+ }
98
238
  static get meta() {
99
- return this._requireDefault().meta;
239
+ return this._require().meta;
100
240
  }
101
- /**
102
- * Возвращает диагностический facade default runtime.
103
- */
104
241
  static get debug() {
105
- return this._requireDefault().debug;
242
+ return this._require().debug;
106
243
  }
107
- /**
108
- * Возвращает корневой node default runtime.
109
- */
110
244
  static get root() {
111
- return this._requireDefault().root;
245
+ return this._require().root;
112
246
  }
113
- /**
114
- * Формирует снимок materialized derived default runtime.
115
- */
116
- static getDerivedSnapshot() {
117
- return this._requireDefault().getDerivedSnapshot();
247
+ static get rootScope() {
248
+ return this._require().rootScope;
118
249
  }
119
- /**
120
- * Создаёт независимый path/kernel owner в runtime-режиме.
121
- */
122
- static createKernel(t = {}) {
123
- return this._requireMode("runtime"), new o(t);
250
+ static get frameTick() {
251
+ return this._require().frameTick;
124
252
  }
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;
253
+ static get frame() {
254
+ return this._require().frame;
139
255
  }
140
- /**
141
- * Возвращает зарегистрированный runtime без ошибки при его отсутствии.
142
- */
143
- static getRuntime(t) {
144
- return this._requireMode("runtime"), this._validateRuntimeId(t), this._runtimes.get(t);
256
+ static get phases() {
257
+ return this._require().phases;
145
258
  }
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;
259
+ static get loopEnabled() {
260
+ return this._require().loopEnabled;
154
261
  }
155
- /**
156
- * Проверяет наличие runtime в registry текущей сессии.
157
- */
158
- static hasRuntime(t) {
159
- return this.getRuntime(t) !== void 0;
262
+ static configure(e) {
263
+ if (this._handle !== void 0)
264
+ throw new _("[Raph] Facade is already configured.");
265
+ const t = new y(l.create(e));
266
+ return this._handle = t, t;
160
267
  }
161
- /**
162
- * Освобождает зарегистрированный runtime с указанным id.
163
- */
164
- static disposeRuntime(t) {
165
- const e = this.getRuntime(t);
166
- return e === void 0 ? !1 : (e.dispose(), !0);
268
+ static reset() {
269
+ const e = this._handle;
270
+ e !== void 0 && (this._handle = void 0, e._dispose());
167
271
  }
168
- /**
169
- * Заменяет phases default runtime до первого выполнения pipeline.
170
- */
171
- static definePhases(t) {
172
- this._requireDefault().definePhases(t);
272
+ static instance(e) {
273
+ return this._require().instance(e);
173
274
  }
174
- /**
175
- * Добавляет phase в default runtime до первого выполнения pipeline.
176
- */
177
- static addPhase(t) {
178
- this._requireDefault().addPhase(t);
275
+ static getInstance(e) {
276
+ return this._require().getInstance(e);
179
277
  }
180
- /**
181
- * Удаляет phases default runtime до первого выполнения pipeline.
182
- */
183
- static clearPhases() {
184
- this._requireDefault().clearPhases();
278
+ static hasInstance(e) {
279
+ return this._require().hasInstance(e);
185
280
  }
186
- /**
187
- * Синхронно выполняет накопленную работу default runtime.
188
- */
189
- static flush() {
190
- this._requireDefault().flush();
281
+ static disposeInstance(e) {
282
+ return this._require().disposeInstance(e);
191
283
  }
192
- /**
193
- * Удерживает frame loop активным от имени указанного owner.
194
- */
195
- static acquireLoop(t) {
196
- return this._requireDefault().acquireLoop(t);
284
+ static runtime(e) {
285
+ return this._require().runtime(e);
197
286
  }
198
- /**
199
- * Явно запускает frame loop default runtime.
200
- */
201
- static startLoop() {
202
- this._requireDefault().startLoop();
287
+ static reactivity(e) {
288
+ return this._require().reactivity(e);
203
289
  }
204
- /**
205
- * Снимает явный запуск frame loop default runtime.
206
- */
207
- static stopLoop() {
208
- this._requireDefault().stopLoop();
290
+ static createRuntime(e = {}) {
291
+ return this._require().createRuntime(e);
209
292
  }
210
- /**
211
- * Создаёт принадлежащий default runtime node и выполняет его setup.
212
- */
213
- static node(t, e) {
214
- return this._requireDefault().node(t, e);
293
+ static createReactivity(e = {}) {
294
+ return this._require().createReactivity(e);
215
295
  }
216
- /**
217
- * Регистрирует materialized path dependency в default runtime.
218
- */
219
- static derive(t) {
220
- return this._requireDefault().derive(t);
296
+ static createKernel(e = {}) {
297
+ return this._require().createKernel(e);
221
298
  }
222
- /**
223
- * Создаёт lifecycle-aware handle указанного data path.
224
- */
225
- static path(t, e = {}) {
226
- return this._requireDefault().path(t, e);
299
+ static signal(e) {
300
+ return this._require().signal(e);
227
301
  }
228
- static get(t, e) {
229
- const i = this._requireDefault();
230
- return t === void 0 ? i.get() : i.get(t, e);
302
+ static reactive(e) {
303
+ return this._require().reactive(e);
231
304
  }
232
- static peek(t, e) {
233
- const i = this._requireDefault();
234
- return t === void 0 ? i.peek() : i.peek(t, e);
305
+ static computed(e) {
306
+ return typeof e == "function" ? this._require().computed(e) : this._require().computed(e);
235
307
  }
236
- /**
237
- * Проверяет наличие значения по указанному path.
238
- */
239
- static has(t, e) {
240
- return this._requireDefault().has(t, e);
308
+ static effect(e, t, r) {
309
+ return typeof e == "function" ? this._require().effect(e) : this._require().effect(e, t, r);
241
310
  }
242
- /**
243
- * Заменяет значение по указанному path.
244
- */
245
- static set(t, e, i) {
246
- this._requireDefault().set(t, e, i);
311
+ static watch(e, t, r, s) {
312
+ const n = this._require();
313
+ return typeof t == "string" ? n.watch(
314
+ e,
315
+ t,
316
+ r,
317
+ s
318
+ ) : n.watch(
319
+ e,
320
+ t,
321
+ r
322
+ );
247
323
  }
248
- /**
249
- * Объединяет значение с существующим объектом по указанному path.
250
- */
251
- static merge(t, e, i) {
252
- this._requireDefault().merge(t, e, i);
324
+ static batch(e) {
325
+ return this._require().batch(e);
253
326
  }
254
- /**
255
- * Удаляет значение по указанному path.
256
- */
257
- static delete(t, e) {
258
- this._requireDefault().delete(t, e);
327
+ static untracked(e) {
328
+ return this._require().untracked(e);
259
329
  }
260
- /**
261
- * Выполняет несколько mutations как одну реактивную транзакцию.
262
- */
263
- static transaction(t) {
264
- return this._requireDefault().transaction(t);
330
+ static scope(e) {
331
+ return e === void 0 ? this._require().scope() : this._require().scope(e);
265
332
  }
266
- /**
267
- * Оборачивает операцию в именованную action текущего runtime.
268
- */
269
- static action(t, e) {
270
- return this._requireDefault().action(t, e);
333
+ static action(e, t) {
334
+ return typeof e == "function" ? this._require().action(e) : this._require().action(e, t);
271
335
  }
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;
336
+ static definePhases(e) {
337
+ this._require().definePhases(e);
331
338
  }
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
- );
339
+ static addPhase(e) {
340
+ this._require().addPhase(e);
337
341
  }
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.");
342
+ static clearPhases() {
343
+ this._require().clearPhases();
374
344
  }
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}".`);
345
+ static requestExecution() {
346
+ this._require().requestExecution();
379
347
  }
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;
348
+ static flush() {
349
+ this._require().flush();
385
350
  }
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;
351
+ static afterFlush() {
352
+ return this._require().afterFlush();
388
353
  }
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 = {};
354
+ static acquireLoop(e) {
355
+ return this._require().acquireLoop(e);
391
356
  }
392
- /**
393
- * Запрещает создание экземпляров статического facade.
394
- */
395
- constructor() {
357
+ static startLoop() {
358
+ this._require().startLoop();
359
+ }
360
+ static stopLoop() {
361
+ this._require().stopLoop();
362
+ }
363
+ static aggregate(e) {
364
+ return this._require().aggregate(e);
365
+ }
366
+ static node(e, t) {
367
+ return this._require().node(e, t);
368
+ }
369
+ static getNode(e) {
370
+ return this._require().getNode(e);
371
+ }
372
+ static derive(e) {
373
+ return this._require().derive(e);
374
+ }
375
+ static getDerivedSnapshot() {
376
+ return this._require().getDerivedSnapshot();
377
+ }
378
+ static path(e, t = {}) {
379
+ return this._require().path(e, t);
380
+ }
381
+ static get(e, t) {
382
+ return e === void 0 ? this._require().get() : this._require().get(e, t);
383
+ }
384
+ static peek(e, t) {
385
+ return e === void 0 ? this._require().peek() : this._require().peek(e, t);
386
+ }
387
+ static has(e, t) {
388
+ return this._require().has(e, t);
389
+ }
390
+ static set(e, t, r) {
391
+ this._require().set(e, t, r);
392
+ }
393
+ static merge(e, t, r) {
394
+ this._require().merge(e, t, r);
395
+ }
396
+ static delete(e, t) {
397
+ this._require().delete(e, t);
398
+ }
399
+ // ---------------------------------------------
400
+ // PRIVATE
401
+ // ---------------------------------------------
402
+ static _require() {
403
+ const e = this._handle;
404
+ if (e === void 0)
405
+ throw new _("[Raph] Facade is not configured. Call Raph.configure(...) first.");
406
+ return e;
396
407
  }
397
408
  }
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
409
+ u(c, "_handle"), u(c, "Scheduler", q), u(c, "DerivedStrategy", Object.freeze({
410
+ full: g,
411
+ collectionByKey: m,
412
+ filterByKey: p
413
413
  }));
414
- function q(u) {
415
- return u === c.Sync || u === c.Microtask || u === c.AnimationFrame;
414
+ function h(i, e) {
415
+ return new a(
416
+ `[Raph] ${i} is unavailable for reactivity instance "${e.id}".`
417
+ );
416
418
  }
417
419
  export {
418
- s as Raph
420
+ c as Raph
419
421
  };