@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.
- package/README.md +1096 -0
- package/dist/api/Raph.d.ts +59 -190
- package/dist/api/RaphFacadeSession.d.ts +90 -0
- package/dist/api/RaphReactivityInstance.d.ts +72 -0
- package/dist/api/errors.d.ts +9 -4
- package/dist/api/types.d.ts +162 -17
- package/dist/core-CyilRD7s.js +1055 -0
- package/dist/core-ugchZNqC.cjs +1 -0
- package/dist/debug/api/Raph.cjs +1 -1
- package/dist/debug/api/Raph.js +368 -366
- package/dist/debug/api/RaphFacadeSession.cjs +1 -0
- package/dist/debug/api/RaphFacadeSession.js +306 -0
- package/dist/debug/api/RaphReactivityInstance.cjs +1 -0
- package/dist/debug/api/RaphReactivityInstance.js +149 -0
- package/dist/debug/api/errors.cjs +1 -1
- package/dist/debug/api/errors.js +10 -7
- package/dist/debug/path/DataPath.cjs +1 -0
- package/dist/debug/path/{data-path.js → DataPath.js} +151 -180
- package/dist/debug/path/PathRouter.cjs +1 -0
- package/dist/debug/path/{path-router.js → PathRouter.js} +1 -1
- package/dist/debug/path/RaphKernel.cjs +1 -1
- package/dist/debug/path/RaphKernel.js +258 -207
- package/dist/debug/path/data-path.utils.cjs +1 -0
- package/dist/debug/path/data-path.utils.js +56 -0
- package/dist/debug/path/derived/DerivedRegistry.cjs +1 -0
- package/dist/debug/path/{DerivedRegistry.js → derived/DerivedRegistry.js} +5 -5
- package/dist/debug/path/derived/derived-collection.utils.cjs +1 -0
- package/dist/debug/path/{derived-collection.js → derived/derived-collection.utils.js} +1 -1
- package/dist/debug/path/derived/derived-strategy.types.cjs +1 -0
- package/dist/debug/path/derived/derived-strategy.types.js +1 -0
- package/dist/debug/path/{MetaController.cjs → meta/MetaController.cjs} +1 -1
- package/dist/debug/path/{MetaController.js → meta/MetaController.js} +3 -3
- package/dist/debug/path/meta/RaphMetaStore.cjs +1 -0
- package/dist/debug/path/{RaphMetaStore.js → meta/RaphMetaStore.js} +1 -1
- package/dist/debug/path/meta/meta.types.cjs +1 -0
- package/dist/debug/path/meta/meta.types.js +1 -0
- package/dist/debug/path/storage/AdapterPathStore.cjs +1 -0
- package/dist/debug/path/{AdapterPathStore.js → storage/AdapterPathStore.js} +9 -9
- package/dist/debug/path/storage/DefaultDataAdapter.cjs +1 -0
- package/dist/debug/path/{data-adapter.js → storage/DefaultDataAdapter.js} +2 -2
- package/dist/debug/path/storage/PathEventHub.cjs +1 -0
- package/dist/debug/path/{PathEventHub.js → storage/PathEventHub.js} +34 -34
- package/dist/debug/path/storage/PathStore.cjs +1 -0
- package/dist/debug/path/{PathStore.js → storage/PathStore.js} +28 -28
- package/dist/debug/path/storage/data-adapter.types.cjs +1 -0
- package/dist/debug/path/storage/data-adapter.types.js +1 -0
- package/dist/debug/reactivity/engine.cjs +1 -1
- package/dist/debug/reactivity/engine.js +478 -306
- package/dist/debug/reactivity/reactive-object.cjs +1 -0
- package/dist/debug/reactivity/reactive-object.js +280 -0
- package/dist/debug/runtime/RaphRuntime.cjs +1 -1
- package/dist/debug/runtime/RaphRuntime.js +798 -519
- package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -0
- package/dist/debug/runtime/diagnostics/RaphDebug.js +297 -0
- package/dist/debug/runtime/errors.cjs +1 -1
- package/dist/debug/runtime/errors.js +6 -3
- package/dist/debug/runtime/ownership/RaphEffectScope.cjs +1 -0
- package/dist/debug/runtime/ownership/RaphEffectScope.js +171 -0
- package/dist/debug/runtime/ownership/RaphNode.cjs +1 -0
- package/dist/debug/runtime/ownership/RaphNode.js +206 -0
- package/dist/debug/runtime/ownership/RaphScope.cjs +1 -0
- package/dist/debug/runtime/ownership/RaphScope.js +101 -0
- package/dist/debug/runtime/ownership/parent-graph.types.cjs +1 -0
- package/dist/debug/runtime/ownership/parent-graph.types.js +1 -0
- package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -0
- package/dist/debug/runtime/phases/RaphPhasePipeline.js +587 -0
- package/dist/debug/runtime/phases/orderPhaseTasks.cjs +1 -0
- package/dist/debug/runtime/phases/orderPhaseTasks.js +59 -0
- package/dist/debug/runtime/reactivity/PathHandle.cjs +1 -0
- package/dist/debug/runtime/{PathHandle.js → reactivity/PathHandle.js} +75 -39
- package/dist/debug/runtime/reactivity/RaphMetaSource.cjs +1 -0
- package/dist/debug/runtime/reactivity/RaphMetaSource.js +112 -0
- package/dist/debug/runtime/reactivity/RaphWorkGraph.cjs +1 -0
- package/dist/debug/runtime/reactivity/RaphWorkGraph.js +995 -0
- package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -0
- package/dist/debug/runtime/reactivity/RuntimeReactivity.js +156 -0
- package/dist/debug/runtime/reactivity/RuntimeWatch.cjs +1 -0
- package/dist/debug/runtime/reactivity/RuntimeWatch.js +88 -0
- package/dist/debug/runtime/reactivity/runtime-reactivity.types.cjs +1 -0
- package/dist/debug/runtime/reactivity/runtime-reactivity.types.js +1 -0
- package/dist/entrypoints/machine-testing.d.ts +2 -0
- package/dist/entrypoints/machine.d.ts +5 -0
- package/dist/entrypoints/path.d.ts +14 -0
- package/dist/entrypoints/reactivity.d.ts +1 -0
- package/dist/entrypoints/runtime.d.ts +17 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +46 -38
- package/dist/machine/compiler.d.ts +71 -0
- package/dist/machine/core.d.ts +50 -0
- package/dist/machine/persistence.d.ts +5 -0
- package/dist/machine/runtime.d.ts +4 -0
- package/dist/machine/testing.d.ts +43 -0
- package/dist/machine/types.d.ts +155 -0
- package/dist/machine-testing.cjs +1 -0
- package/dist/machine-testing.js +188 -0
- package/dist/machine.cjs +1 -0
- package/dist/machine.js +837 -0
- package/dist/main.d.ts +20 -0
- package/dist/path/{data-path.d.ts → DataPath.d.ts} +16 -40
- package/dist/path/{path-router.d.ts → PathRouter.d.ts} +1 -1
- package/dist/path/RaphKernel.d.ts +13 -10
- package/dist/path/data-path.types.d.ts +34 -0
- package/dist/path/data-path.utils.d.ts +9 -0
- package/dist/path/{DerivedRegistry.d.ts → derived/DerivedRegistry.d.ts} +2 -2
- package/dist/path/{RaphDerivedHandle.d.ts → derived/RaphDerivedHandle.d.ts} +3 -3
- package/dist/path/derived/derived-collection.types.d.ts +12 -0
- package/dist/path/{derived-collection.d.ts → derived/derived-collection.utils.d.ts} +3 -13
- package/dist/path/{derived-strategies.d.ts → derived/derived-strategy.types.d.ts} +0 -3
- package/dist/path/derived/derived-strategy.utils.d.ts +4 -0
- package/dist/path/{MetaController.d.ts → meta/MetaController.d.ts} +4 -4
- package/dist/path/{RaphMeta.d.ts → meta/RaphMeta.d.ts} +2 -2
- package/dist/path/{RaphMetaStore.d.ts → meta/RaphMetaStore.d.ts} +1 -1
- package/dist/path/{meta.types.d.ts → meta/meta.types.d.ts} +2 -4
- package/dist/path/path.types.d.ts +3 -2
- package/dist/path/{segment-key.d.ts → pathSegmentKey.d.ts} +1 -1
- package/dist/path/{AdapterPathStore.d.ts → storage/AdapterPathStore.d.ts} +4 -4
- package/dist/path/{data-adapter.d.ts → storage/DefaultDataAdapter.d.ts} +2 -17
- package/dist/path/{PathEventHub.d.ts → storage/PathEventHub.d.ts} +9 -9
- package/dist/path/{PathStore.d.ts → storage/PathStore.d.ts} +3 -3
- package/dist/path/storage/data-adapter.types.d.ts +17 -0
- package/dist/path.cjs +1 -1
- package/dist/path.js +16 -16
- package/dist/raph.cjs +1 -1
- package/dist/raph.js +46 -38
- package/dist/reactivity/engine.d.ts +17 -3
- package/dist/reactivity/reactive-object.d.ts +36 -0
- package/dist/reactivity/types.d.ts +25 -0
- package/dist/reactivity.cjs +1 -1
- package/dist/reactivity.js +12 -12
- package/dist/runtime/RaphRuntime.d.ts +132 -192
- package/dist/runtime/diagnostics/RaphDebug.d.ts +239 -0
- package/dist/runtime/errors.d.ts +5 -0
- package/dist/runtime/ownership/RaphEffectScope.d.ts +29 -0
- package/dist/runtime/ownership/RaphNode.d.ts +40 -0
- package/dist/runtime/ownership/RaphScope.d.ts +38 -0
- package/dist/runtime/{parent-graph.d.ts → ownership/parent-graph.types.d.ts} +0 -1
- package/dist/runtime/ownership/parentGraph.d.ts +3 -0
- package/dist/runtime/phases/RaphPhasePipeline.d.ts +79 -0
- package/dist/runtime/phases/orderPhaseTasks.d.ts +6 -0
- package/dist/runtime/phases/phase.types.d.ts +92 -0
- package/dist/runtime/{PathHandle.d.ts → reactivity/PathHandle.d.ts} +14 -6
- package/dist/runtime/reactivity/RaphMetaSource.d.ts +32 -0
- package/dist/runtime/reactivity/RaphWorkGraph.d.ts +171 -0
- package/dist/runtime/{RuntimeReactivity.d.ts → reactivity/RuntimeReactivity.d.ts} +14 -9
- package/dist/runtime/{RuntimeWatch.d.ts → reactivity/RuntimeWatch.d.ts} +9 -3
- package/dist/runtime/{runtime-reactivity.types.d.ts → reactivity/runtime-reactivity.types.d.ts} +3 -1
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.js +21 -16
- package/package.json +68 -35
- package/ReadMe.md +0 -153
- package/dist/api/public.d.ts +0 -22
- package/dist/debug/api/public.cjs +0 -1
- package/dist/debug/api/public.js +0 -40
- package/dist/debug/path/AdapterPathStore.cjs +0 -1
- package/dist/debug/path/DerivedRegistry.cjs +0 -1
- package/dist/debug/path/PathEventHub.cjs +0 -1
- package/dist/debug/path/PathStore.cjs +0 -1
- package/dist/debug/path/RaphMetaStore.cjs +0 -1
- package/dist/debug/path/data-adapter.cjs +0 -1
- package/dist/debug/path/data-path.cjs +0 -1
- package/dist/debug/path/derived-collection.cjs +0 -1
- package/dist/debug/path/path-router.cjs +0 -1
- package/dist/debug/path/public.cjs +0 -1
- package/dist/debug/path/public.js +0 -18
- package/dist/debug/runtime/PathHandle.cjs +0 -1
- package/dist/debug/runtime/RaphDebug.cjs +0 -1
- package/dist/debug/runtime/RaphDebug.js +0 -15
- package/dist/debug/runtime/RaphNode.cjs +0 -1
- package/dist/debug/runtime/RaphNode.js +0 -143
- package/dist/debug/runtime/RaphPhasePipeline.cjs +0 -1
- package/dist/debug/runtime/RaphPhasePipeline.js +0 -526
- package/dist/debug/runtime/RaphScope.cjs +0 -1
- package/dist/debug/runtime/RaphScope.js +0 -64
- package/dist/debug/runtime/RuntimeReactivity.cjs +0 -1
- package/dist/debug/runtime/RuntimeReactivity.js +0 -154
- package/dist/debug/runtime/RuntimeWatch.cjs +0 -1
- package/dist/debug/runtime/RuntimeWatch.js +0 -71
- package/dist/debug/runtime/public.cjs +0 -1
- package/dist/debug/runtime/public.js +0 -18
- package/dist/path/public.d.ts +0 -14
- package/dist/runtime/RaphDebug.d.ts +0 -32
- package/dist/runtime/RaphNode.d.ts +0 -68
- package/dist/runtime/RaphPhasePipeline.d.ts +0 -133
- package/dist/runtime/RaphScope.d.ts +0 -50
- package/dist/runtime/phase.types.d.ts +0 -49
- package/dist/runtime/public.d.ts +0 -13
- /package/dist/debug/path/{meta.types.cjs → data-path.types.cjs} +0 -0
- /package/dist/debug/path/{meta.types.js → data-path.types.js} +0 -0
- /package/dist/debug/path/{RaphDerivedHandle.cjs → derived/RaphDerivedHandle.cjs} +0 -0
- /package/dist/debug/path/{RaphDerivedHandle.js → derived/RaphDerivedHandle.js} +0 -0
- /package/dist/debug/{runtime/runtime-reactivity.types.cjs → path/derived/derived-collection.types.cjs} +0 -0
- /package/dist/debug/{runtime/runtime-reactivity.types.js → path/derived/derived-collection.types.js} +0 -0
- /package/dist/debug/path/{derived-strategies.cjs → derived/derived-strategy.utils.cjs} +0 -0
- /package/dist/debug/path/{derived-strategies.js → derived/derived-strategy.utils.js} +0 -0
- /package/dist/debug/path/{RaphMeta.cjs → meta/RaphMeta.cjs} +0 -0
- /package/dist/debug/path/{RaphMeta.js → meta/RaphMeta.js} +0 -0
- /package/dist/debug/path/{segment-key.cjs → pathSegmentKey.cjs} +0 -0
- /package/dist/debug/path/{segment-key.js → pathSegmentKey.js} +0 -0
- /package/dist/debug/path/{data-draft.cjs → storage/createDataDraft.cjs} +0 -0
- /package/dist/debug/path/{data-draft.js → storage/createDataDraft.js} +0 -0
- /package/dist/debug/runtime/{parent-graph.cjs → ownership/parentGraph.cjs} +0 -0
- /package/dist/debug/runtime/{parent-graph.js → ownership/parentGraph.js} +0 -0
- /package/dist/debug/runtime/{disposal.cjs → ownership/throwDisposalErrors.cjs} +0 -0
- /package/dist/debug/runtime/{disposal.js → ownership/throwDisposalErrors.js} +0 -0
- /package/dist/debug/runtime/{RaphFrameLoop.cjs → phases/RaphFrameLoop.cjs} +0 -0
- /package/dist/debug/runtime/{RaphFrameLoop.js → phases/RaphFrameLoop.js} +0 -0
- /package/dist/debug/runtime/{phase.types.cjs → phases/phase.types.cjs} +0 -0
- /package/dist/debug/runtime/{phase.types.js → phases/phase.types.js} +0 -0
- /package/dist/path/{data-draft.d.ts → storage/createDataDraft.d.ts} +0 -0
- /package/dist/runtime/{disposal.d.ts → ownership/throwDisposalErrors.d.ts} +0 -0
- /package/dist/runtime/{RaphFrameLoop.d.ts → phases/RaphFrameLoop.d.ts} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var d=Object.defineProperty;var _=(s,i,e)=>i in s?d(s,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[i]=e;var n=(s,i,e)=>_(s,typeof i!="symbol"?i+"":i,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./disposal.cjs"),c=require("./errors.cjs"),m=require("./RaphScope.cjs");let y=0;class h extends m.RaphScope{constructor(e,t={},o){const a=o??(e instanceof h?e.runtime:e??void 0);if(a===void 0)throw new Error("[RaphNode] A root node requires an explicit runtime.");const r=e instanceof h?e:(e==null?void 0:e.root)??null;super(t.id??`node-${y++}`,a);n(this,"priority");n(this,"_parent");n(this,"_children",[]);n(this,"api");n(this,"meta");n(this,"type");if(r!==null&&r.runtime!==a)throw super.dispose(),new c.RaphCrossRuntimeError("[Raph] Parent belongs to another runtime.");try{r==null||r._assertAlive()}catch(p){throw super.dispose(),p}const u=t.priority??0;l(u),this.priority=u,this._parent=r,this.meta={...t.meta},this.type=t.type??"default",this.api=Object.freeze({}),r==null||r._children.push(this)}get parent(){return this._parent}get children(){return this._children}addChild(e){if(this._assertAlive(),e._assertAlive(),e.runtime!==this.runtime)throw new c.RaphCrossRuntimeError("[Raph] Child belongs to another runtime.");if(this===e)throw new Error("[Raph] A node cannot become its own ancestor.");for(let t=this._parent;t!==null;t=t.parent)if(t===e)throw new Error("[Raph] A node cannot become its own ancestor.");if(e.parent===this)return!0;if(e._parent!==null){const t=e._parent._children,o=t.indexOf(e);o>=0&&t.splice(o,1)}return e._parent=this,this._children.push(e),!0}options(e){this._assertAlive(),e.meta!==void 0&&(this.meta={...e.meta}),e.priority!==void 0&&(l(e.priority),this.priority=e.priority),e.type!==void 0&&(this.type=e.type)}dirty(e){this._assertAlive(),this.runtime.invalidateNode(this,e)}remove(){this.dispose()}dispose(){if(this._disposed||this._disposing)return;this._disposing=!0;const e=[];for(const t of[...this._children])try{t.dispose()}catch(o){e.push(o)}if(this._children.length=0,this._parent!==null){const t=this._parent._children.indexOf(this);t>=0&&this._parent._children.splice(t,1)}this._parent=null;try{super.dispose()}catch(t){e.push(t)}f.throwDisposalErrors(e,`[Raph] Node "${this.id}" disposal failed.`)}observeData(e,t){return this._assertAlive(),this.runtime.observeData(this,e,t)}track(e,t={}){return this._assertAlive(),this.runtime.track(this,e,t)}_setApi(e){const t=typeof e=="object"&&e!==null?Object.freeze(e):e;Object.defineProperty(this,"api",{configurable:!1,enumerable:!0,value:t,writable:!1})}}function l(s){if(!Number.isFinite(s))throw new TypeError("[Raph] Node priority must be finite.")}exports.RaphNode=h;
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
var d = Object.defineProperty;
|
|
2
|
-
var f = (s, r, t) => r in s ? d(s, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[r] = t;
|
|
3
|
-
var h = (s, r, t) => f(s, typeof r != "symbol" ? r + "" : r, t);
|
|
4
|
-
import { throwDisposalErrors as m } from "./disposal.js";
|
|
5
|
-
import { RaphCrossRuntimeError as p } from "./errors.js";
|
|
6
|
-
import { RaphScope as _ } from "./RaphScope.js";
|
|
7
|
-
let y = 0;
|
|
8
|
-
class a extends _ {
|
|
9
|
-
/**
|
|
10
|
-
* Создаёт node внутри ownership tree указанного runtime.
|
|
11
|
-
*/
|
|
12
|
-
constructor(t, i = {}, n) {
|
|
13
|
-
const o = n ?? (t instanceof a ? t.runtime : t ?? void 0);
|
|
14
|
-
if (o === void 0)
|
|
15
|
-
throw new Error("[RaphNode] A root node requires an explicit runtime.");
|
|
16
|
-
const e = t instanceof a ? t : (t == null ? void 0 : t.root) ?? null;
|
|
17
|
-
super(i.id ?? `node-${y++}`, o);
|
|
18
|
-
// Описывают положение и порядок node в ownership tree.
|
|
19
|
-
h(this, "priority");
|
|
20
|
-
h(this, "_parent");
|
|
21
|
-
h(this, "_children", []);
|
|
22
|
-
// Публикуют прикладной API и диагностические атрибуты node.
|
|
23
|
-
h(this, "api");
|
|
24
|
-
h(this, "meta");
|
|
25
|
-
h(this, "type");
|
|
26
|
-
if (e !== null && e.runtime !== o)
|
|
27
|
-
throw super.dispose(), new p("[Raph] Parent belongs to another runtime.");
|
|
28
|
-
try {
|
|
29
|
-
e == null || e._assertAlive();
|
|
30
|
-
} catch (u) {
|
|
31
|
-
throw super.dispose(), u;
|
|
32
|
-
}
|
|
33
|
-
const l = i.priority ?? 0;
|
|
34
|
-
c(l), this.priority = l, this._parent = e, this.meta = { ...i.meta }, this.type = i.type ?? "default", this.api = Object.freeze({}), e == null || e._children.push(this);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Возвращает текущего родителя node либо null для root.
|
|
38
|
-
*/
|
|
39
|
-
get parent() {
|
|
40
|
-
return this._parent;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Возвращает снимок непосредственных дочерних nodes.
|
|
44
|
-
*/
|
|
45
|
-
get children() {
|
|
46
|
-
return this._children;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Перемещает node внутри ownership tree одного Runtime.
|
|
50
|
-
*/
|
|
51
|
-
addChild(t) {
|
|
52
|
-
if (this._assertAlive(), t._assertAlive(), t.runtime !== this.runtime)
|
|
53
|
-
throw new p("[Raph] Child belongs to another runtime.");
|
|
54
|
-
if (this === t)
|
|
55
|
-
throw new Error("[Raph] A node cannot become its own ancestor.");
|
|
56
|
-
for (let i = this._parent; i !== null; i = i.parent)
|
|
57
|
-
if (i === t)
|
|
58
|
-
throw new Error("[Raph] A node cannot become its own ancestor.");
|
|
59
|
-
if (t.parent === this)
|
|
60
|
-
return !0;
|
|
61
|
-
if (t._parent !== null) {
|
|
62
|
-
const i = t._parent._children, n = i.indexOf(t);
|
|
63
|
-
n >= 0 && i.splice(n, 1);
|
|
64
|
-
}
|
|
65
|
-
return t._parent = this, this._children.push(t), !0;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Обновляет изменяемые priority, meta и type node.
|
|
69
|
-
*/
|
|
70
|
-
options(t) {
|
|
71
|
-
this._assertAlive(), t.meta !== void 0 && (this.meta = { ...t.meta }), t.priority !== void 0 && (c(t.priority), this.priority = t.priority), t.type !== void 0 && (this.type = t.type);
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Показывает, ожидает ли node выполнения.
|
|
75
|
-
*/
|
|
76
|
-
dirty(t) {
|
|
77
|
-
this._assertAlive(), this.runtime.invalidateNode(this, t);
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Отсоединяет node от ownership tree с заданной lifecycle-семантикой.
|
|
81
|
-
*/
|
|
82
|
-
remove() {
|
|
83
|
-
this.dispose();
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Освобождает node вместе с дочерними owners и registrations.
|
|
87
|
-
*/
|
|
88
|
-
dispose() {
|
|
89
|
-
if (this._disposed || this._disposing)
|
|
90
|
-
return;
|
|
91
|
-
this._disposing = !0;
|
|
92
|
-
const t = [];
|
|
93
|
-
for (const i of [...this._children])
|
|
94
|
-
try {
|
|
95
|
-
i.dispose();
|
|
96
|
-
} catch (n) {
|
|
97
|
-
t.push(n);
|
|
98
|
-
}
|
|
99
|
-
if (this._children.length = 0, this._parent !== null) {
|
|
100
|
-
const i = this._parent._children.indexOf(this);
|
|
101
|
-
i >= 0 && this._parent._children.splice(i, 1);
|
|
102
|
-
}
|
|
103
|
-
this._parent = null;
|
|
104
|
-
try {
|
|
105
|
-
super.dispose();
|
|
106
|
-
} catch (i) {
|
|
107
|
-
t.push(i);
|
|
108
|
-
}
|
|
109
|
-
m(t, `[Raph] Node "${this.id}" disposal failed.`);
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Регистрирует path observer в phase pipeline.
|
|
113
|
-
*/
|
|
114
|
-
observeData(t, i) {
|
|
115
|
-
return this._assertAlive(), this.runtime.observeData(this, t, i);
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Регистрирует tracked executor указанной phase.
|
|
119
|
-
*/
|
|
120
|
-
track(t, i = {}) {
|
|
121
|
-
return this._assertAlive(), this.runtime.track(this, t, i);
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Однократно устанавливает immutable API, принадлежащий node.
|
|
125
|
-
* @internal
|
|
126
|
-
*/
|
|
127
|
-
_setApi(t) {
|
|
128
|
-
const i = typeof t == "object" && t !== null ? Object.freeze(t) : t;
|
|
129
|
-
Object.defineProperty(this, "api", {
|
|
130
|
-
configurable: !1,
|
|
131
|
-
enumerable: !0,
|
|
132
|
-
value: i,
|
|
133
|
-
writable: !1
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
function c(s) {
|
|
138
|
-
if (!Number.isFinite(s))
|
|
139
|
-
throw new TypeError("[Raph] Node priority must be finite.");
|
|
140
|
-
}
|
|
141
|
-
export {
|
|
142
|
-
a as RaphNode
|
|
143
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var w=Object.defineProperty;var k=(d,e,s)=>e in d?w(d,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):d[e]=s;var h=(d,e,s)=>k(d,typeof e!="symbol"?e+"":e,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("../path/data-path.cjs"),v=require("../path/path-router.cjs"),b=1e4,y=()=>{};class P{constructor(e,s,t,n,a=()=>!1){h(this,"_observerRouter");h(this,"_phaseRouter",new v.PathRouter);h(this,"_observers");h(this,"_stopKernel");h(this,"_phases",[]);h(this,"_phaseByName",new Map);h(this,"_pending",new Map);h(this,"_tasks",new Map);h(this,"_phaseBindings",new Map);h(this,"_taskSequence",0);h(this,"_scheduled",!1);h(this,"_scheduleToken",0);h(this,"_frameHandle");h(this,"_frameHandleKind");h(this,"_configurationLocked",!1);h(this,"_running",!1);h(this,"_disposed",!1);h(this,"_firstFrameAt");h(this,"_lastFrameAt");h(this,"_frameNumber",0);h(this,"_frame",Object.freeze({now:0,delta:0,elapsed:0,frame:0}));this._kernel=e,this._root=s,this._scheduler=t,this._runUntracked=n,this._deferSync=a}get frame(){return this._frame}get phases(){return this._phases.map(e=>e.phase)}definePhases(e){if(this._assertAlive(),this._configurationLocked||this._firstFrameAt!==void 0)throw new Error("[Raph] Cannot redefine phases after phase pipeline execution has started.");const s=new Map,t=new v.PathRouter,n=[];for(const a of e){const r=a.name.trim();if(!r)throw new Error("[Raph] Phase name must not be empty.");if(s.has(r))throw new Error(`[Raph] Duplicate phase name "${r}".`);if(!R(a.traversal))throw new Error(`[Raph] Unsupported phase traversal "${String(a.traversal)}".`);if(!A(a.mode))throw new Error(`[Raph] Unsupported phase mode "${String(a.mode)}".`);if(a.each!==void 0&&typeof a.each!="function")throw new TypeError(`[Raph] Phase "${r}" each executor must be a function.`);if(a.all!==void 0&&typeof a.all!="function")throw new TypeError(`[Raph] Phase "${r}" all executor must be a function.`);if(a.each!==void 0&&a.all!==void 0)throw new TypeError(`[Raph] Phase "${r}" cannot define both each and all executors.`);const i=Object.freeze({...a,name:r,mode:a.mode??"dirty",routes:Object.freeze([...a.routes??[]])}),o={phase:i};n.push(o),s.set(r,o);for(const l of i.routes)t.add(m.DataPath.from(l)._asMask(),o)}this._assertRetainedPhases(s),this._phases=n,this._phaseByName=s,this._phaseRouter=t}addPhase(e){this.definePhases([...this._phases.map(s=>s.phase),e])}clearPhases(){this.definePhases([])}requirePhase(e){if(this._assertAlive(),!this._phaseByName.has(e))throw new Error(`[Raph] Phase "${e}" is not defined.`)}lockConfiguration(){this._assertAlive(),this._configurationLocked=!0}retainPhase(e){this.requirePhase(e),this._phaseBindings.set(e,(this._phaseBindings.get(e)??0)+1);let s=!0;return()=>{if(!s)return;s=!1;const t=(this._phaseBindings.get(e)??1)-1;t===0?this._phaseBindings.delete(e):this._phaseBindings.set(e,t)}}phaseMode(e){this._assertAlive();const s=this._phaseByName.get(e);if(s===void 0)throw new Error(`[Raph] Phase "${e}" is not defined.`);return s.phase.mode??"dirty"}registerEffect(e){return this.requirePhase(e),y}bindEffect(e,s,t,n){const a=this.registerEffect(e),r={active:!0,pending:!1,persistent:!0,priority:s,sequence:0,run:t,node:n};return{schedule:()=>{if(!r.active||r.pending||this._disposed||n!=null&&n.disposed)return;r.pending=!0,r.sequence=this._taskSequence++;let i=this._tasks.get(e);i===void 0&&(i=[],this._tasks.set(e,i)),i.push(r),this._schedule()},dispose:()=>{if(!r.active)return;r.active=!1,r.pending=!1,a();const i=this._tasks.get(e);if(i!==void 0){const o=i.indexOf(r);o!==-1&&i.splice(o,1),i.length===0&&this._tasks.delete(e)}this._hasPending()||this._cancelScheduled()}}}queueEffect(e,s,t,n=!0){this.requirePhase(e);const a={active:!0,pending:!0,persistent:!1,priority:s,sequence:this._taskSequence++,run:t};let r=this._tasks.get(e);return r===void 0&&(r=[],this._tasks.set(e,r)),r.push(a),n&&this._schedule(),()=>{if(!a.active)return;a.active=!1;const i=this._tasks.get(e);if(i!==void 0){const o=i.indexOf(a);o>=0&&i.splice(o,1),i.length===0&&this._tasks.delete(e)}this._hasPending()||this._cancelScheduled()}}request(){this._assertAlive(),this._hasPending()&&this._schedule()}requestAlwaysPhases(){this._assertAlive();for(const e of this._phases){const s=e.phase;if(s.mode!=="always"||s.traversal!=="all"||s.all===void 0)continue;let t=this._pending.get(s.name);t===void 0&&(t=new Map,this._pending.set(s.name,t)),u(t,this._root,[])}this._pending.size!==0&&this._schedule()}observeData(e,s,t){const n=t.phase.trim();if(!this._phaseByName.has(n))throw new Error(`[Raph] Phase "${n}" is not defined.`);return this._addObserver(e,s,n,t)}track(e,s,t){return this._addObserver(e,s,void 0,t)}invalidate(e,s){this.requirePhase(s);let t=this._pending.get(s);t===void 0&&(t=new Map,this._pending.set(s,t)),u(t,e,[]),this._schedule()}flush(){var n;if(this._assertAlive(),this._cancelScheduled(),this._running||!this._hasPending())return;this._running=!0;const e=[],s=this._nextFrame();let t=0;try{for(;this._hasPending()&&!this._disposed;){if(++t>b){this._pending.clear();for(const i of this._tasks.values())for(const o of i)o.active=!1;throw this._tasks.clear(),new Error("[Raph] Phase flush exceeded 10000 passes.")}const a=this._pending;this._pending=new Map;const r=this._tasks;this._tasks=new Map;for(const i of this._phases){if(this._disposed)break;const o=i.phase.name,l=a.get(o);if(l!==void 0&&l.size!==0){const f=this._expandContexts(i.phase,l,s);if(i.phase.each!==void 0)for(const c of f){if(this._disposed)break;if(!c.node.disposed)try{this._runUntracked(()=>i.phase.each(c))}catch(p){e.push(p)}}else if(i.phase.all!==void 0&&!this._disposed)try{this._runUntracked(()=>i.phase.all(f))}catch(c){e.push(c)}}if(this._disposed)break;const _=r.get(o);if(!(_===void 0||_.length===0)){_.length>1&&_.sort((f,c)=>c.priority-f.priority||f.sequence-c.sequence);for(const f of _){if(this._disposed)break;if(!(!f.active||!f.pending||(n=f.node)!=null&&n.disposed)){f.pending=!1,f.persistent||(f.active=!1);try{f.run()}catch(c){e.push(c)}}}}}}}finally{this._running=!1}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"[Raph] Multiple phase executors failed.")}dispose(){var e;if(!this._disposed){this._disposed=!0,this._cancelScheduled(),this._pending.clear();for(const s of this._tasks.values())for(const t of s)t.active=!1;if(this._tasks.clear(),this._phaseBindings.clear(),(e=this._stopKernel)==null||e.call(this),this._stopKernel=void 0,this._observers!==void 0){for(const s of this._observers){s.active=!1;for(const t of s.removeRoutes)t()}this._observers.clear(),this._observers=void 0}this._observerRouter=void 0,this._phases=[],this._phaseByName.clear(),this._phaseRouter=new v.PathRouter}}_debugPending(){return this._scheduled||this._running||this._hasPending()}_addObserver(e,s,t,n){this._assertAlive();const a=Array.isArray(s)?s:[s];if(a.length===0)throw new TypeError("[Raph] Phase observer requires at least one mask.");const r=new Map;for(const c of a){const p=m.DataPath.from(c,n)._asMask();r.set(p.canonical,p)}const i=this._observerRouter??(this._observerRouter=new v.PathRouter),o={active:!0,node:e,...t===void 0?{}:{phase:t},removeRoutes:[]},l=[...r.values()].map(c=>i.add(c,o));o.removeRoutes=l;const _=this._observers??(this._observers=new Set);_.add(o),this._ensureKernelWatch();let f=!0;return()=>{var c;if(f){f=!1,o.active=!1;for(const p of o.removeRoutes)p();_.delete(o),_.size===0&&(this._observers=void 0,this._observerRouter=void 0,(c=this._stopKernel)==null||c.call(this),this._stopKernel=void 0)}}}_ensureKernelWatch(){this._stopKernel??(this._stopKernel=this._kernel.watch("*",({events:e})=>{this._receive(e)}))}_assertRetainedPhases(e){for(const s of this._phaseBindings.keys())if(!e.has(s))throw new Error(`[Raph] Cannot remove phase "${s}" while it is still bound.`);for(const s of this._observers??[]){const t=s.phase;if(s.active&&t!==void 0&&!e.has(t))throw new Error(`[Raph] Cannot remove phase "${t}" while it is still observed.`)}for(const s of this._pending.keys())if(!e.has(s))throw new Error(`[Raph] Cannot remove phase "${s}" while it has pending work.`);for(const s of this._tasks.keys())if(!e.has(s))throw new Error(`[Raph] Cannot remove phase "${s}" while it has queued effects.`)}_receive(e){if(this._disposed)return;const s=this._observerRouter;if(s!==void 0){for(const t of e){const n=t.path==="",a=n?void 0:m.parseDataPath(t.path),r=n?s.matchAll():s.match(a.segments);for(const i of r){if(!i.active||i.node.disposed)continue;if(i.phase!==void 0){this._queue(i.phase,i.node,t);continue}const o=n?this._phaseRouter.matchAll():this._phaseRouter.match(a.segments);for(const l of o)this._queue(l.phase.name,i.node,t)}}this._pending.size!==0&&this._schedule()}}_queue(e,s,t){if(!this._phaseByName.has(e))return;let n=this._pending.get(e);n===void 0&&(n=new Map,this._pending.set(e,n)),u(n,s,[t])}_schedule(){if(this._running||this._scheduled||this._disposed)return;if(this._scheduler==="sync"){if(this._deferSync())return;this.flush();return}this._scheduled=!0;const e=++this._scheduleToken,s=()=>{this._disposed||!this._scheduled||e!==this._scheduleToken||(this._scheduled=!1,this._frameHandle=void 0,this._frameHandleKind=void 0,this.flush())};if(this._scheduler==="microtask"){queueMicrotask(s);return}typeof globalThis.requestAnimationFrame=="function"?(this._frameHandleKind="animation-frame",this._frameHandle=globalThis.requestAnimationFrame(s)):(this._frameHandleKind="timeout",this._frameHandle=setTimeout(s,16))}_cancelScheduled(){var e;this._scheduled&&(this._scheduled=!1,this._scheduleToken++,this._frameHandleKind==="animation-frame"&&this._frameHandle!==void 0?(e=globalThis.cancelAnimationFrame)==null||e.call(globalThis,this._frameHandle):this._frameHandleKind==="timeout"&&this._frameHandle!==void 0&&clearTimeout(this._frameHandle),this._frameHandle=void 0,this._frameHandleKind=void 0)}_nextFrame(){var t;const e=((t=globalThis.performance)==null?void 0:t.now())??Date.now();if(this._firstFrameAt===void 0||this._lastFrameAt===void 0)return this._firstFrameAt=e,this._lastFrameAt=e,this._frame=Object.freeze({now:e,delta:0,elapsed:0,frame:0});this._frameNumber++;const s=Object.freeze({now:e,delta:Math.min(Math.max(e-this._lastFrameAt,0),100),elapsed:Math.max(e-this._firstFrameAt,0),frame:this._frameNumber});return this._lastFrameAt=e,this._frame=s}_hasPending(){return this._pending.size!==0||this._tasks.size!==0}_expandContexts(e,s,t){const n=[...s.entries()].filter(([r])=>!r.disposed).sort(([r],[i])=>i.priority-r.priority),a=new Map;if(e.traversal==="dirty-only")for(const[r,i]of n)u(a,r,i.events);else if(e.traversal==="dirty-and-down")for(const[r,i]of n)g(r,o=>u(a,o,i.events));else if(e.traversal==="dirty-and-up")for(const[r,i]of n){let o=r;for(;o!==null&&o!==this._root;)u(a,o,i.events),o=o.parent}else{const r=[],i=new Set;for(const o of s.values())for(const l of o.events)i.has(l)||(i.add(l),r.push(l));for(const o of this._root.children)g(o,l=>u(a,l,r))}return[...a].filter(([r])=>{var i;return((i=e.nodes)==null?void 0:i.call(e,r))??!0}).map(([r,i])=>({events:i.events,frame:t,node:r,phase:e.name}))}_assertAlive(){if(this._disposed)throw new Error("[Raph] Phase pipeline is disposed.")}}function u(d,e,s){let t=d.get(e);t===void 0&&(t={events:[],seen:new Set},d.set(e,t));for(const n of s)t.seen.has(n)||(t.seen.add(n),t.events.push(n))}function g(d,e){e(d);for(const s of d.children)g(s,e)}function R(d){return d==="dirty-only"||d==="dirty-and-down"||d==="dirty-and-up"||d==="all"}function A(d){return d===void 0||d==="dirty"||d==="always"}exports.RaphPhasePipeline=P;
|