@raphy-js/raph 1.0.1-dev.20 → 1.0.1-dev.26
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/dist/{core-CyilRD7s.js → core-CClhT8WR.js} +389 -400
- package/dist/core-cPQWYD4K.cjs +1 -0
- package/dist/debug/api/Raph.cjs +1 -1
- package/dist/debug/api/Raph.js +46 -47
- package/dist/debug/api/RaphFacadeSession.cjs +1 -1
- package/dist/debug/api/RaphFacadeSession.js +85 -89
- package/dist/debug/api/RaphReactivityInstance.cjs +1 -1
- package/dist/debug/api/RaphReactivityInstance.js +27 -30
- package/dist/debug/path/DataPath.cjs +1 -1
- package/dist/debug/path/DataPath.js +198 -202
- package/dist/debug/path/PathRouter.cjs +1 -1
- package/dist/debug/path/PathRouter.js +44 -50
- package/dist/debug/path/RaphKernel.cjs +1 -1
- package/dist/debug/path/RaphKernel.js +257 -228
- package/dist/debug/path/data-path.utils.cjs +1 -1
- package/dist/debug/path/data-path.utils.js +41 -41
- package/dist/debug/path/derived/DerivedRegistry.cjs +1 -1
- package/dist/debug/path/derived/DerivedRegistry.js +52 -66
- package/dist/debug/path/derived/RaphDerivedHandle.cjs +1 -1
- package/dist/debug/path/derived/RaphDerivedHandle.js +19 -22
- package/dist/debug/path/derived/derived-collection.utils.cjs +1 -1
- package/dist/debug/path/derived/derived-collection.utils.js +70 -70
- package/dist/debug/path/meta/MetaController.cjs +1 -1
- package/dist/debug/path/meta/MetaController.js +57 -65
- package/dist/debug/path/meta/RaphMeta.cjs +1 -1
- package/dist/debug/path/meta/RaphMeta.js +26 -32
- package/dist/debug/path/meta/RaphMetaStore.cjs +1 -1
- package/dist/debug/path/meta/RaphMetaStore.js +24 -30
- package/dist/debug/path/storage/AdapterPathStore.cjs +1 -1
- package/dist/debug/path/storage/AdapterPathStore.js +49 -54
- package/dist/debug/path/storage/DefaultDataAdapter.cjs +1 -1
- package/dist/debug/path/storage/DefaultDataAdapter.js +46 -56
- package/dist/debug/path/storage/PathEventHub.cjs +1 -1
- package/dist/debug/path/storage/PathEventHub.js +74 -61
- package/dist/debug/path/storage/PathStore.cjs +1 -1
- package/dist/debug/path/storage/PathStore.js +89 -99
- package/dist/debug/path/storage/createDataDraft.cjs +1 -1
- package/dist/debug/path/storage/createDataDraft.js +24 -28
- package/dist/debug/reactivity/disposal.cjs +1 -0
- package/dist/debug/reactivity/disposal.js +32 -0
- package/dist/debug/reactivity/engine.cjs +1 -1
- package/dist/debug/reactivity/engine.js +787 -392
- package/dist/debug/reactivity/reactive-object.cjs +1 -1
- package/dist/debug/reactivity/reactive-object.js +81 -96
- package/dist/debug/reactivity/scope.cjs +1 -1
- package/dist/debug/reactivity/scope.js +221 -117
- package/dist/debug/reactivity/watch.cjs +1 -1
- package/dist/debug/reactivity/watch.js +1 -1
- package/dist/debug/runtime/RaphRuntime.cjs +1 -1
- package/dist/debug/runtime/RaphRuntime.js +764 -411
- package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -1
- package/dist/debug/runtime/diagnostics/RaphDebug.js +90 -100
- package/dist/debug/runtime/ownership/RaphEffectScope.cjs +1 -1
- package/dist/debug/runtime/ownership/RaphEffectScope.js +215 -82
- package/dist/debug/runtime/ownership/RaphNode.cjs +1 -1
- package/dist/debug/runtime/ownership/RaphNode.js +595 -136
- package/dist/debug/runtime/ownership/RaphScope.cjs +1 -1
- package/dist/debug/runtime/ownership/RaphScope.js +203 -68
- package/dist/debug/runtime/phases/RaphFrameLoop.cjs +1 -1
- package/dist/debug/runtime/phases/RaphFrameLoop.js +13 -17
- package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -1
- package/dist/debug/runtime/phases/RaphPhasePipeline.js +618 -357
- package/dist/debug/runtime/phases/RaphPhaseTaskRecord.cjs +1 -0
- package/dist/debug/runtime/phases/RaphPhaseTaskRecord.js +176 -0
- package/dist/debug/runtime/phases/RaphPhaseWatch.cjs +1 -0
- package/dist/debug/runtime/phases/RaphPhaseWatch.js +20 -0
- package/dist/debug/runtime/reactivity/PathHandle.cjs +1 -1
- package/dist/debug/runtime/reactivity/PathHandle.js +50 -60
- package/dist/debug/runtime/reactivity/RaphMetaSource.cjs +1 -1
- package/dist/debug/runtime/reactivity/RaphMetaSource.js +28 -32
- package/dist/debug/runtime/reactivity/RaphSelector.cjs +1 -0
- package/dist/debug/runtime/reactivity/RaphSelector.js +503 -0
- package/dist/debug/runtime/reactivity/RaphWorkGraph.cjs +1 -1
- package/dist/debug/runtime/reactivity/RaphWorkGraph.js +541 -379
- package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -1
- package/dist/debug/runtime/reactivity/RuntimeReactivity.js +484 -90
- package/dist/debug/runtime/reactivity/RuntimeWatch.cjs +1 -1
- package/dist/debug/runtime/reactivity/RuntimeWatch.js +33 -44
- package/dist/debug/runtime/reactivity/disposal-sweep.utils.cjs +1 -0
- package/dist/debug/runtime/reactivity/disposal-sweep.utils.js +42 -0
- package/dist/entrypoints/runtime.d.ts +2 -1
- package/dist/machine-testing.cjs +1 -1
- package/dist/machine-testing.js +1 -1
- package/dist/machine.cjs +1 -1
- package/dist/machine.js +216 -231
- package/dist/path/RaphKernel.d.ts +24 -0
- package/dist/path/storage/PathEventHub.d.ts +14 -0
- package/dist/path/storage/PathStore.d.ts +4 -4
- package/dist/reactivity/disposal.d.ts +14 -0
- package/dist/reactivity/engine.d.ts +177 -4
- package/dist/reactivity/scope.d.ts +108 -30
- package/dist/runtime/RaphRuntime.d.ts +236 -17
- package/dist/runtime/ownership/RaphEffectScope.d.ts +70 -1
- package/dist/runtime/ownership/RaphNode.d.ts +276 -6
- package/dist/runtime/ownership/RaphScope.d.ts +144 -14
- package/dist/runtime/phases/RaphPhasePipeline.d.ts +202 -28
- package/dist/runtime/phases/RaphPhaseTaskRecord.d.ts +195 -0
- package/dist/runtime/phases/RaphPhaseWatch.d.ts +22 -0
- package/dist/runtime/phases/phase.types.d.ts +83 -4
- package/dist/runtime/reactivity/RaphSelector.d.ts +338 -0
- package/dist/runtime/reactivity/RaphWorkGraph.d.ts +163 -25
- package/dist/runtime/reactivity/RuntimeReactivity.d.ts +258 -10
- package/dist/runtime/reactivity/RuntimeWatch.d.ts +8 -8
- package/dist/runtime/reactivity/disposal-sweep.utils.d.ts +19 -0
- package/dist/runtime/reactivity/runtime-reactivity.types.d.ts +48 -3
- package/package.json +10 -2
- package/dist/core-ugchZNqC.cjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../ownership/RaphNode.cjs"),_=Object.freeze(["action","machine","error"]),f=1024;class l{_capacity=f;_context="none";_guards="failed";_include=new Set(_);_enabled=!1;_events;_eventStart=0;_eventSize=0;_sequence=0;_operationSequence=0;_machines;trace;machines;constructor(e){const s=e?.trace;s!==void 0&&s!==!1&&(this._applyOptions(s),this._enabled=!0,this._ensureBuffer()),this.trace=Object.freeze({clear:()=>this.clear(),read:t=>this.read(t),start:t=>this.start(t),status:()=>this.status(),stop:()=>this.stop()}),this.machines=Object.freeze({list:()=>this.listMachines(),snapshot:t=>this.machineSnapshot(t)})}start(e){e!==void 0&&this._applyOptions(e),this._enabled=!0,this._ensureBuffer()}stop(){this._enabled=!1}clear(){this._events?.fill(void 0),this._eventStart=0,this._eventSize=0}read(e={}){const s=e.since??-1,t=e.limit??Number.POSITIVE_INFINITY;if(!Number.isFinite(t)&&t!==Number.POSITIVE_INFINITY)throw new TypeError("[Raph] Trace limit must be a positive integer.");if(t!==Number.POSITIVE_INFINITY&&(!Number.isInteger(t)||t<0))throw new TypeError("[Raph] Trace limit must be a positive integer.");const a=this._events;if(a===void 0||this._eventSize===0||t===0)return Object.freeze([]);const n=[];for(let r=0;r<this._eventSize;r++){const d=a[(this._eventStart+r)%this._capacity];if(!(d===void 0||d.sequence<=s)&&(n.push(d),n.length>=t))break}return Object.freeze(n)}status(){return Object.freeze({capacity:this._capacity,context:this._context,enabled:this._enabled,guards:this._guards,include:Object.freeze([...this._include]),size:this._eventSize})}nextOperationId(e){if(!(!this._enabled||!this._include.has(e)))return++this._operationSequence}traces(e){return this._enabled&&this._include.has(e)}record(e){if(!this._enabled||!this._include.has(e.kind)||e.guard!==void 0&&(this._guards==="none"||this._guards==="failed"&&e.guard!=="failed"))return;const s=Object.freeze({...e.causeId===void 0?{}:{causeId:e.causeId},...e.context===void 0||this._context==="none"?{}:{contextKeys:Object.freeze(Object.keys(e.context))},...e.details===void 0?{}:{details:Object.freeze({...e.details})},...e.guard===void 0?{}:{guard:e.guard},...e.operationId===void 0?{}:{operationId:e.operationId},...e.status===void 0?{}:{status:e.status},kind:e.kind,name:e.name,sequence:++this._sequence,timestamp:Date.now()}),t=this._ensureBuffer();if(this._eventSize<this._capacity){t[(this._eventStart+this._eventSize++)%this._capacity]=s;return}t[this._eventStart]=s,this._eventStart=(this._eventStart+1)%this._capacity}registerMachine(e){const s=this._machines??=new Map;if(s.has(e.id))throw new Error(`[Raph] Machine diagnostic id "${e.id}" is already registered.`);return s.set(e.id,e),()=>{s.get(e.id)===e&&s.delete(e.id),s.size===0&&this._machines===s&&(this._machines=void 0)}}hasMachine(e){return this._machines?.has(e)??!1}listMachines(){const e=[];for(const s of this._machines?.values()??[]){const t=s.snapshot();e.push(Object.freeze({active:t.active,id:t.id,modelId:t.modelId,ownerId:t.ownerId,...t.parentId===void 0?{}:{parentId:t.parentId},revision:t.revision,status:t.status}))}return Object.freeze(e)}machineSnapshot(e){return this._machines?.get(e)?.snapshot()}get machineCount(){return this._machines?.size??0}get traceSize(){return this._eventSize}get actorCount(){let e=0;for(const s of this._machines?.values()??[])e+=s.snapshot().actors.length;return e}machineTreeNodesByOwner(){const e=[...this._machines?.values()??[]],s=new Map(e.map(n=>[n.id,n])),t=new Map;for(const n of e){if(n.parentId===void 0||!s.has(n.parentId))continue;const r=t.get(n.parentId)??[];r.push(n),t.set(n.parentId,r)}const a=new Map;for(const n of e){if(n.parentId!==void 0&&s.has(n.parentId))continue;const r=a.get(n.ownerId)??[];r.push(u(n,t,!1)),a.set(n.ownerId,r)}return new Map([...a].map(([n,r])=>[n,Object.freeze(r)]))}_applyOptions(e){if(e.capacity!==void 0){if(!Number.isInteger(e.capacity)||e.capacity<=0)throw new TypeError("[Raph] Trace capacity must be a positive integer.");e.capacity!==this._capacity&&(this._capacity=e.capacity,this._events=void 0,this._eventStart=0,this._eventSize=0)}if(e.context!==void 0){if(e.context!=="none"&&e.context!=="keys")throw new TypeError('[Raph] Trace context must be "none" or "keys".');this._context=e.context}if(e.guards!==void 0){if(e.guards!=="none"&&e.guards!=="failed"&&e.guards!=="all")throw new TypeError('[Raph] Trace guards must be "none", "failed" or "all".');this._guards=e.guards}if(e.include!==void 0){const s=new Set;for(const t of e.include){if(t!=="action"&&t!=="machine"&&t!=="phase"&&t!=="error")throw new TypeError(`[Raph] Unsupported trace kind "${String(t)}".`);s.add(t)}this._include=s}}_ensureBuffer(){return this._events??=new Array(this._capacity)}}function h(i){const e=i instanceof c.RaphNode?i.children.map(h):[];return Object.freeze({children:Object.freeze(e),disposed:i.disposed,id:i.id,kind:i instanceof c.RaphNode?"node":"scope",resources:i._debugResourceCount(),sources:i._debugSourceCount()})}function o(i,e=new Map){const s=i instanceof c.RaphNode?i.children.map(a=>o(a,e)):[],t=i._debugResourceCount();return t!==0&&s.push(Object.freeze({children:Object.freeze([]),count:t,id:`${i.id}:resources`,kind:"resource"})),s.push(...e.get(i.id)??[]),Object.freeze({children:Object.freeze(s),disposed:i.disposed,id:i.id,kind:i instanceof c.RaphNode?"node":"scope"})}function u(i,e,s){const t=i.snapshot();return Object.freeze({children:Object.freeze((e.get(i.id)??[]).map(a=>u(a,e,!0))),id:t.id,kind:s?"actor":"machine",status:t.status})}exports.RaphDebugController=l;exports.createOwnerSnapshot=h;exports.createOwnerTree=o;
|
|
@@ -1,40 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var a = (i, e, t) => f(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { RaphNode as h } from "../ownership/RaphNode.js";
|
|
5
|
-
const _ = Object.freeze([
|
|
1
|
+
import { RaphNode as c } from "../ownership/RaphNode.js";
|
|
2
|
+
const o = Object.freeze([
|
|
6
3
|
"action",
|
|
7
4
|
"machine",
|
|
8
5
|
"error"
|
|
9
|
-
]),
|
|
10
|
-
class
|
|
6
|
+
]), u = 1024;
|
|
7
|
+
class p {
|
|
8
|
+
_capacity = u;
|
|
9
|
+
_context = "none";
|
|
10
|
+
_guards = "failed";
|
|
11
|
+
_include = new Set(o);
|
|
12
|
+
_enabled = !1;
|
|
13
|
+
_events;
|
|
14
|
+
_eventStart = 0;
|
|
15
|
+
_eventSize = 0;
|
|
16
|
+
_sequence = 0;
|
|
17
|
+
_operationSequence = 0;
|
|
18
|
+
_machines;
|
|
19
|
+
trace;
|
|
20
|
+
machines;
|
|
11
21
|
/**
|
|
12
22
|
* Создаёт controller; ring buffer появляется только при включённом trace.
|
|
13
23
|
*/
|
|
14
24
|
constructor(e) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
a(this, "_guards", "failed");
|
|
18
|
-
a(this, "_include", new Set(_));
|
|
19
|
-
a(this, "_enabled", !1);
|
|
20
|
-
a(this, "_events");
|
|
21
|
-
a(this, "_eventStart", 0);
|
|
22
|
-
a(this, "_eventSize", 0);
|
|
23
|
-
a(this, "_sequence", 0);
|
|
24
|
-
a(this, "_operationSequence", 0);
|
|
25
|
-
a(this, "_machines");
|
|
26
|
-
a(this, "trace");
|
|
27
|
-
a(this, "machines");
|
|
28
|
-
const t = e == null ? void 0 : e.trace;
|
|
29
|
-
t !== void 0 && t !== !1 && (this._applyOptions(t), this._enabled = !0, this._ensureBuffer()), this.trace = Object.freeze({
|
|
25
|
+
const s = e?.trace;
|
|
26
|
+
s !== void 0 && s !== !1 && (this._applyOptions(s), this._enabled = !0, this._ensureBuffer()), this.trace = Object.freeze({
|
|
30
27
|
clear: () => this.clear(),
|
|
31
|
-
read: (
|
|
32
|
-
start: (
|
|
28
|
+
read: (t) => this.read(t),
|
|
29
|
+
start: (t) => this.start(t),
|
|
33
30
|
status: () => this.status(),
|
|
34
31
|
stop: () => this.stop()
|
|
35
32
|
}), this.machines = Object.freeze({
|
|
36
33
|
list: () => this.listMachines(),
|
|
37
|
-
snapshot: (
|
|
34
|
+
snapshot: (t) => this.machineSnapshot(t)
|
|
38
35
|
});
|
|
39
36
|
}
|
|
40
37
|
// ---------------------------------------------
|
|
@@ -56,28 +53,27 @@ class I {
|
|
|
56
53
|
* Удаляет все накопленные events, не меняя status trace.
|
|
57
54
|
*/
|
|
58
55
|
clear() {
|
|
59
|
-
|
|
60
|
-
(e = this._events) == null || e.fill(void 0), this._eventStart = 0, this._eventSize = 0;
|
|
56
|
+
this._events?.fill(void 0), this._eventStart = 0, this._eventSize = 0;
|
|
61
57
|
}
|
|
62
58
|
/**
|
|
63
59
|
* Формирует immutable chronological copy ring buffer.
|
|
64
60
|
*/
|
|
65
61
|
read(e = {}) {
|
|
66
|
-
const
|
|
67
|
-
if (!Number.isFinite(
|
|
62
|
+
const s = e.since ?? -1, t = e.limit ?? Number.POSITIVE_INFINITY;
|
|
63
|
+
if (!Number.isFinite(t) && t !== Number.POSITIVE_INFINITY)
|
|
68
64
|
throw new TypeError("[Raph] Trace limit must be a positive integer.");
|
|
69
|
-
if (
|
|
65
|
+
if (t !== Number.POSITIVE_INFINITY && (!Number.isInteger(t) || t < 0))
|
|
70
66
|
throw new TypeError("[Raph] Trace limit must be a positive integer.");
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
67
|
+
const a = this._events;
|
|
68
|
+
if (a === void 0 || this._eventSize === 0 || t === 0)
|
|
73
69
|
return Object.freeze([]);
|
|
74
|
-
const
|
|
70
|
+
const n = [];
|
|
75
71
|
for (let r = 0; r < this._eventSize; r++) {
|
|
76
|
-
const
|
|
77
|
-
if (!(
|
|
72
|
+
const d = a[(this._eventStart + r) % this._capacity];
|
|
73
|
+
if (!(d === void 0 || d.sequence <= s) && (n.push(d), n.length >= t))
|
|
78
74
|
break;
|
|
79
75
|
}
|
|
80
|
-
return Object.freeze(
|
|
76
|
+
return Object.freeze(n);
|
|
81
77
|
}
|
|
82
78
|
/**
|
|
83
79
|
* Возвращает текущую конфигурацию и заполнение buffer.
|
|
@@ -115,7 +111,7 @@ class I {
|
|
|
115
111
|
record(e) {
|
|
116
112
|
if (!this._enabled || !this._include.has(e.kind) || e.guard !== void 0 && (this._guards === "none" || this._guards === "failed" && e.guard !== "failed"))
|
|
117
113
|
return;
|
|
118
|
-
const
|
|
114
|
+
const s = Object.freeze({
|
|
119
115
|
...e.causeId === void 0 ? {} : { causeId: e.causeId },
|
|
120
116
|
...e.context === void 0 || this._context === "none" ? {} : { contextKeys: Object.freeze(Object.keys(e.context)) },
|
|
121
117
|
...e.details === void 0 ? {} : { details: Object.freeze({ ...e.details }) },
|
|
@@ -126,23 +122,23 @@ class I {
|
|
|
126
122
|
name: e.name,
|
|
127
123
|
sequence: ++this._sequence,
|
|
128
124
|
timestamp: Date.now()
|
|
129
|
-
}),
|
|
125
|
+
}), t = this._ensureBuffer();
|
|
130
126
|
if (this._eventSize < this._capacity) {
|
|
131
|
-
|
|
127
|
+
t[(this._eventStart + this._eventSize++) % this._capacity] = s;
|
|
132
128
|
return;
|
|
133
129
|
}
|
|
134
|
-
|
|
130
|
+
t[this._eventStart] = s, this._eventStart = (this._eventStart + 1) % this._capacity;
|
|
135
131
|
}
|
|
136
132
|
/**
|
|
137
133
|
* Регистрирует read-only machine projection без импорта machine engine в Runtime.
|
|
138
134
|
* @internal
|
|
139
135
|
*/
|
|
140
136
|
registerMachine(e) {
|
|
141
|
-
const
|
|
142
|
-
if (
|
|
137
|
+
const s = this._machines ??= /* @__PURE__ */ new Map();
|
|
138
|
+
if (s.has(e.id))
|
|
143
139
|
throw new Error(`[Raph] Machine diagnostic id "${e.id}" is already registered.`);
|
|
144
|
-
return
|
|
145
|
-
|
|
140
|
+
return s.set(e.id, e), () => {
|
|
141
|
+
s.get(e.id) === e && s.delete(e.id), s.size === 0 && this._machines === s && (this._machines = void 0);
|
|
146
142
|
};
|
|
147
143
|
}
|
|
148
144
|
/**
|
|
@@ -151,25 +147,23 @@ class I {
|
|
|
151
147
|
* @internal
|
|
152
148
|
*/
|
|
153
149
|
hasMachine(e) {
|
|
154
|
-
|
|
155
|
-
return ((t = this._machines) == null ? void 0 : t.has(e)) ?? !1;
|
|
150
|
+
return this._machines?.has(e) ?? !1;
|
|
156
151
|
}
|
|
157
152
|
/**
|
|
158
153
|
* Возвращает compact machine summaries без выполнения guards.
|
|
159
154
|
*/
|
|
160
155
|
listMachines() {
|
|
161
|
-
var t;
|
|
162
156
|
const e = [];
|
|
163
|
-
for (const s of
|
|
164
|
-
const
|
|
157
|
+
for (const s of this._machines?.values() ?? []) {
|
|
158
|
+
const t = s.snapshot();
|
|
165
159
|
e.push(Object.freeze({
|
|
166
|
-
active:
|
|
167
|
-
id:
|
|
168
|
-
modelId:
|
|
169
|
-
ownerId:
|
|
170
|
-
...
|
|
171
|
-
revision:
|
|
172
|
-
status:
|
|
160
|
+
active: t.active,
|
|
161
|
+
id: t.id,
|
|
162
|
+
modelId: t.modelId,
|
|
163
|
+
ownerId: t.ownerId,
|
|
164
|
+
...t.parentId === void 0 ? {} : { parentId: t.parentId },
|
|
165
|
+
revision: t.revision,
|
|
166
|
+
status: t.status
|
|
173
167
|
}));
|
|
174
168
|
}
|
|
175
169
|
return Object.freeze(e);
|
|
@@ -178,16 +172,14 @@ class I {
|
|
|
178
172
|
* Читает готовый machine snapshot; transition selection и guards не вызываются.
|
|
179
173
|
*/
|
|
180
174
|
machineSnapshot(e) {
|
|
181
|
-
|
|
182
|
-
return (s = (t = this._machines) == null ? void 0 : t.get(e)) == null ? void 0 : s.snapshot();
|
|
175
|
+
return this._machines?.get(e)?.snapshot();
|
|
183
176
|
}
|
|
184
177
|
/**
|
|
185
178
|
* Возвращает число зарегистрированных machines.
|
|
186
179
|
* @internal
|
|
187
180
|
*/
|
|
188
181
|
get machineCount() {
|
|
189
|
-
|
|
190
|
-
return ((e = this._machines) == null ? void 0 : e.size) ?? 0;
|
|
182
|
+
return this._machines?.size ?? 0;
|
|
191
183
|
}
|
|
192
184
|
/**
|
|
193
185
|
* Возвращает число текущих trace events.
|
|
@@ -198,30 +190,28 @@ class I {
|
|
|
198
190
|
}
|
|
199
191
|
/** Возвращает число child actors по уже готовым snapshots. @internal */
|
|
200
192
|
get actorCount() {
|
|
201
|
-
var t;
|
|
202
193
|
let e = 0;
|
|
203
|
-
for (const s of
|
|
194
|
+
for (const s of this._machines?.values() ?? [])
|
|
204
195
|
e += s.snapshot().actors.length;
|
|
205
196
|
return e;
|
|
206
197
|
}
|
|
207
198
|
/** Группирует machine/actor ветви по фактическому lifecycle owner. @internal */
|
|
208
199
|
machineTreeNodesByOwner() {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
if (r.parentId === void 0 || !t.has(r.parentId))
|
|
200
|
+
const e = [...this._machines?.values() ?? []], s = new Map(e.map((n) => [n.id, n])), t = /* @__PURE__ */ new Map();
|
|
201
|
+
for (const n of e) {
|
|
202
|
+
if (n.parentId === void 0 || !s.has(n.parentId))
|
|
213
203
|
continue;
|
|
214
|
-
const
|
|
215
|
-
|
|
204
|
+
const r = t.get(n.parentId) ?? [];
|
|
205
|
+
r.push(n), t.set(n.parentId, r);
|
|
216
206
|
}
|
|
217
|
-
const
|
|
218
|
-
for (const
|
|
219
|
-
if (
|
|
207
|
+
const a = /* @__PURE__ */ new Map();
|
|
208
|
+
for (const n of e) {
|
|
209
|
+
if (n.parentId !== void 0 && s.has(n.parentId))
|
|
220
210
|
continue;
|
|
221
|
-
const
|
|
222
|
-
|
|
211
|
+
const r = a.get(n.ownerId) ?? [];
|
|
212
|
+
r.push(h(n, t, !1)), a.set(n.ownerId, r);
|
|
223
213
|
}
|
|
224
|
-
return new Map([...
|
|
214
|
+
return new Map([...a].map(([n, r]) => [n, Object.freeze(r)]));
|
|
225
215
|
}
|
|
226
216
|
// ---------------------------------------------
|
|
227
217
|
// PRIVATE
|
|
@@ -243,55 +233,55 @@ class I {
|
|
|
243
233
|
this._guards = e.guards;
|
|
244
234
|
}
|
|
245
235
|
if (e.include !== void 0) {
|
|
246
|
-
const
|
|
247
|
-
for (const
|
|
248
|
-
if (
|
|
249
|
-
throw new TypeError(`[Raph] Unsupported trace kind "${String(
|
|
250
|
-
|
|
236
|
+
const s = /* @__PURE__ */ new Set();
|
|
237
|
+
for (const t of e.include) {
|
|
238
|
+
if (t !== "action" && t !== "machine" && t !== "phase" && t !== "error")
|
|
239
|
+
throw new TypeError(`[Raph] Unsupported trace kind "${String(t)}".`);
|
|
240
|
+
s.add(t);
|
|
251
241
|
}
|
|
252
|
-
this._include =
|
|
242
|
+
this._include = s;
|
|
253
243
|
}
|
|
254
244
|
}
|
|
255
245
|
_ensureBuffer() {
|
|
256
|
-
return this._events
|
|
246
|
+
return this._events ??= new Array(this._capacity);
|
|
257
247
|
}
|
|
258
248
|
}
|
|
259
|
-
function
|
|
260
|
-
const e = i instanceof
|
|
249
|
+
function f(i) {
|
|
250
|
+
const e = i instanceof c ? i.children.map(f) : [];
|
|
261
251
|
return Object.freeze({
|
|
262
252
|
children: Object.freeze(e),
|
|
263
253
|
disposed: i.disposed,
|
|
264
254
|
id: i.id,
|
|
265
|
-
kind: i instanceof
|
|
255
|
+
kind: i instanceof c ? "node" : "scope",
|
|
266
256
|
resources: i._debugResourceCount(),
|
|
267
257
|
sources: i._debugSourceCount()
|
|
268
258
|
});
|
|
269
259
|
}
|
|
270
|
-
function
|
|
271
|
-
const
|
|
272
|
-
return
|
|
260
|
+
function _(i, e = /* @__PURE__ */ new Map()) {
|
|
261
|
+
const s = i instanceof c ? i.children.map((a) => _(a, e)) : [], t = i._debugResourceCount();
|
|
262
|
+
return t !== 0 && s.push(Object.freeze({
|
|
273
263
|
children: Object.freeze([]),
|
|
274
|
-
count:
|
|
264
|
+
count: t,
|
|
275
265
|
id: `${i.id}:resources`,
|
|
276
266
|
kind: "resource"
|
|
277
|
-
})),
|
|
278
|
-
children: Object.freeze(
|
|
267
|
+
})), s.push(...e.get(i.id) ?? []), Object.freeze({
|
|
268
|
+
children: Object.freeze(s),
|
|
279
269
|
disposed: i.disposed,
|
|
280
270
|
id: i.id,
|
|
281
|
-
kind: i instanceof
|
|
271
|
+
kind: i instanceof c ? "node" : "scope"
|
|
282
272
|
});
|
|
283
273
|
}
|
|
284
|
-
function
|
|
285
|
-
const
|
|
274
|
+
function h(i, e, s) {
|
|
275
|
+
const t = i.snapshot();
|
|
286
276
|
return Object.freeze({
|
|
287
|
-
children: Object.freeze((e.get(i.id) ?? []).map((
|
|
288
|
-
id:
|
|
289
|
-
kind:
|
|
290
|
-
status:
|
|
277
|
+
children: Object.freeze((e.get(i.id) ?? []).map((a) => h(a, e, !0))),
|
|
278
|
+
id: t.id,
|
|
279
|
+
kind: s ? "actor" : "machine",
|
|
280
|
+
status: t.status
|
|
291
281
|
});
|
|
292
282
|
}
|
|
293
283
|
export {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
284
|
+
p as RaphDebugController,
|
|
285
|
+
f as createOwnerSnapshot,
|
|
286
|
+
_ as createOwnerTree
|
|
297
287
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../errors.cjs"),_=16;class c{constructor(s,e=null){if(this._owner=s,s._assertAlive(),e?.disposed===!0)throw new u.RaphDisposedError("[Raph] Parent effect scope is disposed.");if(e!==null&&e._owner.runtime!==s.runtime)throw new TypeError("[Raph] Parent effect scope belongs to another runtime.");this._parent=e,e?._addChild(this),this._ancestorPauses=e?.paused===!0?1:0,this._releaseOwner=s.own(()=>this.dispose())}_registrations;_pruneAt=_;_children;_selfPaused=!1;_ancestorPauses=0;_disposed=!1;_releaseOwner;_parent;get paused(){return this._selfPaused||this._ancestorPauses!==0}get disposed(){return this._disposed}fork(s){return this._assertAlive(),new c(s,this)}effect(s,e,t){return this._assertAlive(),this._add(this._owner.runtime._effectRegistration(this._owner,s,e,t,this.paused))}bindEffect(s,e,t){this._assertAlive(),this._track(this._owner.runtime._effectRegistration(this._owner,s,e,t,this.paused,!0))}effectGroup(s,e,t,r,i){this._assertAlive();const o=this._owner.runtime._effectGroupRegistration(this._owner,s,e,t,r,i,this.paused);return this._track(o),o}watch(s,e,t,r){return this._assertAlive(),this._add(this._owner.runtime._watchRegistration(this._owner,s,e,t,r,this.paused))}_registerEffect(s,e,t,r,i,o){this._assertAlive();const h=this._owner.runtime._effectRegistration(this._owner,s,e,t,this.paused,r,i,o);o?.()||this._track(h)}_registerWatch(s,e,t,r,i,o){this._assertAlive();const h=this._owner.runtime._watchRegistration(this._owner,s,e,t,r,this.paused,i,o);o?.()||this._track(h)}_registerEffectGroup(s,e,t,r,i){this._assertAlive();const o=this._owner.runtime._effectGroupRegistration(this._owner,s,e,t,r,i,this.paused);return this._track(o),o}pause(){this._assertAlive(),this._owner.runtime._runPhaseTransition(()=>this._pause())}resume(){this._assertAlive(),this._owner.runtime._runPhaseTransition(()=>this._resume())}_pause(){if(this._selfPaused)return;const s=this.paused;if(this._selfPaused=!0,s)return;const e=[];for(const t of this._registrations??[])try{t.registration.pause()}catch(r){e.push(r)}for(const t of this._children??[])try{t._changeAncestorPause(1)}catch(r){e.push(r)}n(e,"[Raph] Pausable effect scope pause failed.")}_resume(){if(!this._selfPaused||(this._selfPaused=!1,this.paused))return;const s=[];for(const e of this._registrations??[])try{e.registration.resume()}catch(t){s.push(t)}for(const e of this._children??[])try{e._changeAncestorPause(-1)}catch(t){s.push(t)}n(s,"[Raph] Pausable effect scope resume failed.")}dispose(){if(this._disposed)return;this._disposed=!0;const s=this._owner.disposed,e=[];for(const t of[...this._children??[]])try{t.dispose()}catch(r){e.push(r)}this._children?.clear(),this._children=void 0;for(const t of this._registrations??[])if(t.active=!1,!s)try{t.registration.dispose()}catch(r){e.push(r)}if(this._registrations?.clear(),this._registrations=void 0,this._parent?._children?.delete(this),!s)try{this._releaseOwner()}catch(t){e.push(t)}n(e,"[Raph] Pausable effect scope disposal failed.")}_add(s){const e=this._track(s);return e===void 0?d:()=>{e.active&&(e.active=!1,this._registrations?.delete(e),e.registration.dispose())}}_track(s){if(this._disposed||this._owner.disposed){s.dispose();return}const e={active:!0,registration:s},t=this._registrations??=new Set;return t.add(e),t.size>=this._pruneAt&&this._prune(t),e}_prune(s){for(const e of s)e.registration.active||(e.active=!1,s.delete(e));this._pruneAt=Math.max(_,s.size*2)}_assertAlive(){if(this._disposed||this._owner.disposed)throw new u.RaphDisposedError("[Raph] Pausable effect scope is disposed.")}_addChild(s){(this._children??=new Set).add(s)}_changeAncestorPause(s){if(this._disposed)return;const e=this.paused;if(this._ancestorPauses+=s,this._ancestorPauses<0)throw this._ancestorPauses=0,new Error("[Raph] Effect scope ancestor pause state is unbalanced.");if(e===this.paused)return;const t=[];for(const r of this._registrations??[])try{this.paused?r.registration.pause():r.registration.resume()}catch(i){t.push(i)}for(const r of this._children??[])try{r._changeAncestorPause(s)}catch(i){t.push(i)}n(t,"[Raph] Pausable effect scope ancestor transition failed.")}}function n(a,s){if(a.length===1)throw a[0];if(a.length>1)throw new AggregateError(a,s)}function d(){}exports.RaphEffectScope=c;
|