@raphy-js/raph 1.0.0-dev.2 → 1.0.1-dev.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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-CClhT8WR.js +1044 -0
- package/dist/core-cPQWYD4K.cjs +1 -0
- package/dist/debug/api/Raph.cjs +1 -1
- package/dist/debug/api/Raph.js +368 -367
- package/dist/debug/api/RaphFacadeSession.cjs +1 -0
- package/dist/debug/api/RaphFacadeSession.js +302 -0
- package/dist/debug/api/RaphReactivityInstance.cjs +1 -0
- package/dist/debug/api/RaphReactivityInstance.js +146 -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/DataPath.js +390 -0
- package/dist/debug/path/PathRouter.cjs +1 -0
- package/dist/debug/path/PathRouter.js +80 -0
- package/dist/debug/path/RaphKernel.cjs +1 -1
- package/dist/debug/path/RaphKernel.js +316 -236
- 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/derived/DerivedRegistry.js +143 -0
- package/dist/debug/path/derived/RaphDerivedHandle.cjs +1 -0
- package/dist/debug/path/{RaphDerivedHandle.js → derived/RaphDerivedHandle.js} +19 -22
- package/dist/debug/path/derived/derived-collection.utils.cjs +1 -0
- package/dist/debug/path/{derived-collection.js → derived/derived-collection.utils.js} +71 -71
- 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/meta/MetaController.cjs +1 -0
- package/dist/debug/path/{MetaController.js → meta/MetaController.js} +58 -66
- package/dist/debug/path/meta/RaphMeta.cjs +1 -0
- package/dist/debug/path/meta/RaphMeta.js +62 -0
- package/dist/debug/path/meta/RaphMetaStore.cjs +1 -0
- package/dist/debug/path/{RaphMetaStore.js → meta/RaphMetaStore.js} +24 -30
- 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/storage/AdapterPathStore.js +128 -0
- package/dist/debug/path/storage/DefaultDataAdapter.cjs +1 -0
- package/dist/debug/path/{data-adapter.js → storage/DefaultDataAdapter.js} +47 -57
- package/dist/debug/path/storage/PathEventHub.cjs +1 -0
- package/dist/debug/path/storage/PathEventHub.js +161 -0
- package/dist/debug/path/storage/PathStore.cjs +1 -0
- package/dist/debug/path/{PathStore.js → storage/PathStore.js} +88 -98
- package/dist/debug/path/storage/createDataDraft.cjs +1 -0
- package/dist/debug/path/{data-draft.js → storage/createDataDraft.js} +24 -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/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 +888 -321
- package/dist/debug/reactivity/reactive-object.cjs +1 -0
- package/dist/debug/reactivity/reactive-object.js +265 -0
- 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 +1134 -502
- package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -0
- package/dist/debug/runtime/diagnostics/RaphDebug.js +287 -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 +304 -0
- package/dist/debug/runtime/ownership/RaphNode.cjs +1 -0
- package/dist/debug/runtime/ownership/RaphNode.js +665 -0
- package/dist/debug/runtime/ownership/RaphScope.cjs +1 -0
- package/dist/debug/runtime/ownership/RaphScope.js +236 -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/RaphFrameLoop.cjs +1 -0
- package/dist/debug/runtime/{RaphFrameLoop.js → phases/RaphFrameLoop.js} +13 -17
- package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -0
- package/dist/debug/runtime/phases/RaphPhasePipeline.js +848 -0
- 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/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/reactivity/PathHandle.js +165 -0
- package/dist/debug/runtime/reactivity/RaphMetaSource.cjs +1 -0
- package/dist/debug/runtime/reactivity/RaphMetaSource.js +108 -0
- 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 -0
- package/dist/debug/runtime/reactivity/RaphWorkGraph.js +1157 -0
- package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -0
- package/dist/debug/runtime/reactivity/RuntimeReactivity.js +550 -0
- package/dist/debug/runtime/reactivity/RuntimeWatch.cjs +1 -0
- package/dist/debug/runtime/reactivity/RuntimeWatch.js +77 -0
- package/dist/debug/runtime/reactivity/disposal-sweep.utils.cjs +1 -0
- package/dist/debug/runtime/reactivity/disposal-sweep.utils.js +42 -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 +18 -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 +822 -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 +37 -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/storage/PathEventHub.d.ts +62 -0
- package/dist/path/{PathStore.d.ts → storage/PathStore.d.ts} +7 -7
- 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/disposal.d.ts +14 -0
- package/dist/reactivity/engine.d.ts +193 -6
- package/dist/reactivity/reactive-object.d.ts +36 -0
- package/dist/reactivity/scope.d.ts +108 -30
- 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 +319 -160
- package/dist/runtime/diagnostics/RaphDebug.d.ts +239 -0
- package/dist/runtime/errors.d.ts +5 -0
- package/dist/runtime/ownership/RaphEffectScope.d.ts +98 -0
- package/dist/runtime/ownership/RaphNode.d.ts +310 -0
- package/dist/runtime/ownership/RaphScope.d.ts +168 -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 +253 -0
- package/dist/runtime/phases/RaphPhaseTaskRecord.d.ts +195 -0
- package/dist/runtime/phases/RaphPhaseWatch.d.ts +22 -0
- package/dist/runtime/phases/orderPhaseTasks.d.ts +6 -0
- package/dist/runtime/phases/phase.types.d.ts +171 -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/RaphSelector.d.ts +338 -0
- package/dist/runtime/reactivity/RaphWorkGraph.d.ts +309 -0
- package/dist/runtime/reactivity/RuntimeReactivity.d.ts +293 -0
- package/dist/runtime/{RuntimeWatch.d.ts → reactivity/RuntimeWatch.d.ts} +12 -6
- package/dist/runtime/reactivity/disposal-sweep.utils.d.ts +19 -0
- package/dist/runtime/reactivity/runtime-reactivity.types.d.ts +56 -0
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.js +21 -16
- package/package.json +76 -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/AdapterPathStore.js +0 -133
- package/dist/debug/path/DerivedRegistry.cjs +0 -1
- package/dist/debug/path/DerivedRegistry.js +0 -157
- package/dist/debug/path/MetaController.cjs +0 -1
- package/dist/debug/path/PathEventHub.cjs +0 -1
- package/dist/debug/path/PathEventHub.js +0 -148
- package/dist/debug/path/PathStore.cjs +0 -1
- package/dist/debug/path/RaphDerivedHandle.cjs +0 -1
- package/dist/debug/path/RaphMeta.cjs +0 -1
- package/dist/debug/path/RaphMeta.js +0 -68
- package/dist/debug/path/RaphMetaStore.cjs +0 -1
- package/dist/debug/path/data-adapter.cjs +0 -1
- package/dist/debug/path/data-draft.cjs +0 -1
- package/dist/debug/path/data-path.cjs +0 -1
- package/dist/debug/path/data-path.js +0 -423
- package/dist/debug/path/derived-collection.cjs +0 -1
- package/dist/debug/path/path-router.cjs +0 -1
- package/dist/debug/path/path-router.js +0 -86
- 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/PathHandle.js +0 -139
- package/dist/debug/runtime/RaphDebug.cjs +0 -1
- package/dist/debug/runtime/RaphDebug.js +0 -15
- package/dist/debug/runtime/RaphFrameLoop.cjs +0 -1
- 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/PathEventHub.d.ts +0 -48
- 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/RuntimeReactivity.d.ts +0 -40
- package/dist/runtime/phase.types.d.ts +0 -49
- package/dist/runtime/public.d.ts +0 -13
- package/dist/runtime/runtime-reactivity.types.d.ts +0 -9
- /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/{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/{segment-key.cjs → pathSegmentKey.cjs} +0 -0
- /package/dist/debug/path/{segment-key.js → pathSegmentKey.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/{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
|
@@ -0,0 +1 @@
|
|
|
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;
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { RaphNode as c } from "../ownership/RaphNode.js";
|
|
2
|
+
const o = Object.freeze([
|
|
3
|
+
"action",
|
|
4
|
+
"machine",
|
|
5
|
+
"error"
|
|
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;
|
|
21
|
+
/**
|
|
22
|
+
* Создаёт controller; ring buffer появляется только при включённом trace.
|
|
23
|
+
*/
|
|
24
|
+
constructor(e) {
|
|
25
|
+
const s = e?.trace;
|
|
26
|
+
s !== void 0 && s !== !1 && (this._applyOptions(s), this._enabled = !0, this._ensureBuffer()), this.trace = Object.freeze({
|
|
27
|
+
clear: () => this.clear(),
|
|
28
|
+
read: (t) => this.read(t),
|
|
29
|
+
start: (t) => this.start(t),
|
|
30
|
+
status: () => this.status(),
|
|
31
|
+
stop: () => this.stop()
|
|
32
|
+
}), this.machines = Object.freeze({
|
|
33
|
+
list: () => this.listMachines(),
|
|
34
|
+
snapshot: (t) => this.machineSnapshot(t)
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
// ---------------------------------------------
|
|
38
|
+
// PUBLIC API
|
|
39
|
+
// ---------------------------------------------
|
|
40
|
+
/**
|
|
41
|
+
* Включает trace с текущими или явно переданными настройками.
|
|
42
|
+
*/
|
|
43
|
+
start(e) {
|
|
44
|
+
e !== void 0 && this._applyOptions(e), this._enabled = !0, this._ensureBuffer();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Останавливает запись, сохраняя уже накопленные events.
|
|
48
|
+
*/
|
|
49
|
+
stop() {
|
|
50
|
+
this._enabled = !1;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Удаляет все накопленные events, не меняя status trace.
|
|
54
|
+
*/
|
|
55
|
+
clear() {
|
|
56
|
+
this._events?.fill(void 0), this._eventStart = 0, this._eventSize = 0;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Формирует immutable chronological copy ring buffer.
|
|
60
|
+
*/
|
|
61
|
+
read(e = {}) {
|
|
62
|
+
const s = e.since ?? -1, t = e.limit ?? Number.POSITIVE_INFINITY;
|
|
63
|
+
if (!Number.isFinite(t) && t !== Number.POSITIVE_INFINITY)
|
|
64
|
+
throw new TypeError("[Raph] Trace limit must be a positive integer.");
|
|
65
|
+
if (t !== Number.POSITIVE_INFINITY && (!Number.isInteger(t) || t < 0))
|
|
66
|
+
throw new TypeError("[Raph] Trace limit must be a positive integer.");
|
|
67
|
+
const a = this._events;
|
|
68
|
+
if (a === void 0 || this._eventSize === 0 || t === 0)
|
|
69
|
+
return Object.freeze([]);
|
|
70
|
+
const n = [];
|
|
71
|
+
for (let r = 0; r < this._eventSize; r++) {
|
|
72
|
+
const d = a[(this._eventStart + r) % this._capacity];
|
|
73
|
+
if (!(d === void 0 || d.sequence <= s) && (n.push(d), n.length >= t))
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
return Object.freeze(n);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Возвращает текущую конфигурацию и заполнение buffer.
|
|
80
|
+
*/
|
|
81
|
+
status() {
|
|
82
|
+
return Object.freeze({
|
|
83
|
+
capacity: this._capacity,
|
|
84
|
+
context: this._context,
|
|
85
|
+
enabled: this._enabled,
|
|
86
|
+
guards: this._guards,
|
|
87
|
+
include: Object.freeze([...this._include]),
|
|
88
|
+
size: this._eventSize
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Выделяет operation ID только когда trace активен для этого kind.
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
nextOperationId(e) {
|
|
96
|
+
if (!(!this._enabled || !this._include.has(e)))
|
|
97
|
+
return ++this._operationSequence;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Проверяет active trace path без выделения operation ID.
|
|
101
|
+
*
|
|
102
|
+
* @internal
|
|
103
|
+
*/
|
|
104
|
+
traces(e) {
|
|
105
|
+
return this._enabled && this._include.has(e);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Записывает одно событие без allocations/timestamp на disabled path.
|
|
109
|
+
* @internal
|
|
110
|
+
*/
|
|
111
|
+
record(e) {
|
|
112
|
+
if (!this._enabled || !this._include.has(e.kind) || e.guard !== void 0 && (this._guards === "none" || this._guards === "failed" && e.guard !== "failed"))
|
|
113
|
+
return;
|
|
114
|
+
const s = Object.freeze({
|
|
115
|
+
...e.causeId === void 0 ? {} : { causeId: e.causeId },
|
|
116
|
+
...e.context === void 0 || this._context === "none" ? {} : { contextKeys: Object.freeze(Object.keys(e.context)) },
|
|
117
|
+
...e.details === void 0 ? {} : { details: Object.freeze({ ...e.details }) },
|
|
118
|
+
...e.guard === void 0 ? {} : { guard: e.guard },
|
|
119
|
+
...e.operationId === void 0 ? {} : { operationId: e.operationId },
|
|
120
|
+
...e.status === void 0 ? {} : { status: e.status },
|
|
121
|
+
kind: e.kind,
|
|
122
|
+
name: e.name,
|
|
123
|
+
sequence: ++this._sequence,
|
|
124
|
+
timestamp: Date.now()
|
|
125
|
+
}), t = this._ensureBuffer();
|
|
126
|
+
if (this._eventSize < this._capacity) {
|
|
127
|
+
t[(this._eventStart + this._eventSize++) % this._capacity] = s;
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
t[this._eventStart] = s, this._eventStart = (this._eventStart + 1) % this._capacity;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Регистрирует read-only machine projection без импорта machine engine в Runtime.
|
|
134
|
+
* @internal
|
|
135
|
+
*/
|
|
136
|
+
registerMachine(e) {
|
|
137
|
+
const s = this._machines ??= /* @__PURE__ */ new Map();
|
|
138
|
+
if (s.has(e.id))
|
|
139
|
+
throw new Error(`[Raph] Machine diagnostic id "${e.id}" is already registered.`);
|
|
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);
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Проверяет diagnostic identity без создания public snapshot.
|
|
146
|
+
*
|
|
147
|
+
* @internal
|
|
148
|
+
*/
|
|
149
|
+
hasMachine(e) {
|
|
150
|
+
return this._machines?.has(e) ?? !1;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Возвращает compact machine summaries без выполнения guards.
|
|
154
|
+
*/
|
|
155
|
+
listMachines() {
|
|
156
|
+
const e = [];
|
|
157
|
+
for (const s of this._machines?.values() ?? []) {
|
|
158
|
+
const t = s.snapshot();
|
|
159
|
+
e.push(Object.freeze({
|
|
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
|
|
167
|
+
}));
|
|
168
|
+
}
|
|
169
|
+
return Object.freeze(e);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Читает готовый machine snapshot; transition selection и guards не вызываются.
|
|
173
|
+
*/
|
|
174
|
+
machineSnapshot(e) {
|
|
175
|
+
return this._machines?.get(e)?.snapshot();
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Возвращает число зарегистрированных machines.
|
|
179
|
+
* @internal
|
|
180
|
+
*/
|
|
181
|
+
get machineCount() {
|
|
182
|
+
return this._machines?.size ?? 0;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Возвращает число текущих trace events.
|
|
186
|
+
* @internal
|
|
187
|
+
*/
|
|
188
|
+
get traceSize() {
|
|
189
|
+
return this._eventSize;
|
|
190
|
+
}
|
|
191
|
+
/** Возвращает число child actors по уже готовым snapshots. @internal */
|
|
192
|
+
get actorCount() {
|
|
193
|
+
let e = 0;
|
|
194
|
+
for (const s of this._machines?.values() ?? [])
|
|
195
|
+
e += s.snapshot().actors.length;
|
|
196
|
+
return e;
|
|
197
|
+
}
|
|
198
|
+
/** Группирует machine/actor ветви по фактическому lifecycle owner. @internal */
|
|
199
|
+
machineTreeNodesByOwner() {
|
|
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))
|
|
203
|
+
continue;
|
|
204
|
+
const r = t.get(n.parentId) ?? [];
|
|
205
|
+
r.push(n), t.set(n.parentId, r);
|
|
206
|
+
}
|
|
207
|
+
const a = /* @__PURE__ */ new Map();
|
|
208
|
+
for (const n of e) {
|
|
209
|
+
if (n.parentId !== void 0 && s.has(n.parentId))
|
|
210
|
+
continue;
|
|
211
|
+
const r = a.get(n.ownerId) ?? [];
|
|
212
|
+
r.push(h(n, t, !1)), a.set(n.ownerId, r);
|
|
213
|
+
}
|
|
214
|
+
return new Map([...a].map(([n, r]) => [n, Object.freeze(r)]));
|
|
215
|
+
}
|
|
216
|
+
// ---------------------------------------------
|
|
217
|
+
// PRIVATE
|
|
218
|
+
// ---------------------------------------------
|
|
219
|
+
_applyOptions(e) {
|
|
220
|
+
if (e.capacity !== void 0) {
|
|
221
|
+
if (!Number.isInteger(e.capacity) || e.capacity <= 0)
|
|
222
|
+
throw new TypeError("[Raph] Trace capacity must be a positive integer.");
|
|
223
|
+
e.capacity !== this._capacity && (this._capacity = e.capacity, this._events = void 0, this._eventStart = 0, this._eventSize = 0);
|
|
224
|
+
}
|
|
225
|
+
if (e.context !== void 0) {
|
|
226
|
+
if (e.context !== "none" && e.context !== "keys")
|
|
227
|
+
throw new TypeError('[Raph] Trace context must be "none" or "keys".');
|
|
228
|
+
this._context = e.context;
|
|
229
|
+
}
|
|
230
|
+
if (e.guards !== void 0) {
|
|
231
|
+
if (e.guards !== "none" && e.guards !== "failed" && e.guards !== "all")
|
|
232
|
+
throw new TypeError('[Raph] Trace guards must be "none", "failed" or "all".');
|
|
233
|
+
this._guards = e.guards;
|
|
234
|
+
}
|
|
235
|
+
if (e.include !== void 0) {
|
|
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);
|
|
241
|
+
}
|
|
242
|
+
this._include = s;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
_ensureBuffer() {
|
|
246
|
+
return this._events ??= new Array(this._capacity);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
function f(i) {
|
|
250
|
+
const e = i instanceof c ? i.children.map(f) : [];
|
|
251
|
+
return Object.freeze({
|
|
252
|
+
children: Object.freeze(e),
|
|
253
|
+
disposed: i.disposed,
|
|
254
|
+
id: i.id,
|
|
255
|
+
kind: i instanceof c ? "node" : "scope",
|
|
256
|
+
resources: i._debugResourceCount(),
|
|
257
|
+
sources: i._debugSourceCount()
|
|
258
|
+
});
|
|
259
|
+
}
|
|
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({
|
|
263
|
+
children: Object.freeze([]),
|
|
264
|
+
count: t,
|
|
265
|
+
id: `${i.id}:resources`,
|
|
266
|
+
kind: "resource"
|
|
267
|
+
})), s.push(...e.get(i.id) ?? []), Object.freeze({
|
|
268
|
+
children: Object.freeze(s),
|
|
269
|
+
disposed: i.disposed,
|
|
270
|
+
id: i.id,
|
|
271
|
+
kind: i instanceof c ? "node" : "scope"
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
function h(i, e, s) {
|
|
275
|
+
const t = i.snapshot();
|
|
276
|
+
return Object.freeze({
|
|
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
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
export {
|
|
284
|
+
p as RaphDebugController,
|
|
285
|
+
f as createOwnerSnapshot,
|
|
286
|
+
_ as createOwnerTree
|
|
287
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../api/errors.cjs");class
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../api/errors.cjs");class e extends r.RaphError{}class o extends r.RaphError{}class a extends r.RaphError{}class p extends r.RaphError{}exports.RaphActionError=e;exports.RaphCrossRuntimeError=a;exports.RaphDisposedError=o;exports.RaphPhaseProcessError=p;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { RaphError as r } from "../api/errors.js";
|
|
2
|
-
class
|
|
2
|
+
class o extends r {
|
|
3
3
|
}
|
|
4
4
|
class a extends r {
|
|
5
5
|
}
|
|
6
6
|
class p extends r {
|
|
7
7
|
}
|
|
8
|
+
class t extends r {
|
|
9
|
+
}
|
|
8
10
|
export {
|
|
9
|
-
|
|
11
|
+
o as RaphActionError,
|
|
10
12
|
p as RaphCrossRuntimeError,
|
|
11
|
-
a as RaphDisposedError
|
|
13
|
+
a as RaphDisposedError,
|
|
14
|
+
t as RaphPhaseProcessError
|
|
12
15
|
};
|
|
@@ -0,0 +1 @@
|
|
|
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;
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { RaphDisposedError as c } from "../errors.js";
|
|
2
|
+
const u = 16;
|
|
3
|
+
class _ {
|
|
4
|
+
constructor(s, e = null) {
|
|
5
|
+
if (this._owner = s, s._assertAlive(), e?.disposed === !0)
|
|
6
|
+
throw new c("[Raph] Parent effect scope is disposed.");
|
|
7
|
+
if (e !== null && e._owner.runtime !== s.runtime)
|
|
8
|
+
throw new TypeError("[Raph] Parent effect scope belongs to another runtime.");
|
|
9
|
+
this._parent = e, e?._addChild(this), this._ancestorPauses = e?.paused === !0 ? 1 : 0, this._releaseOwner = s.own(() => this.dispose());
|
|
10
|
+
}
|
|
11
|
+
_registrations;
|
|
12
|
+
// Число регистраций, при котором группа в следующий раз забывает остановленные.
|
|
13
|
+
_pruneAt = u;
|
|
14
|
+
_children;
|
|
15
|
+
_selfPaused = !1;
|
|
16
|
+
_ancestorPauses = 0;
|
|
17
|
+
_disposed = !1;
|
|
18
|
+
_releaseOwner;
|
|
19
|
+
_parent;
|
|
20
|
+
get paused() {
|
|
21
|
+
return this._selfPaused || this._ancestorPauses !== 0;
|
|
22
|
+
}
|
|
23
|
+
get disposed() {
|
|
24
|
+
return this._disposed;
|
|
25
|
+
}
|
|
26
|
+
fork(s) {
|
|
27
|
+
return this._assertAlive(), new _(s, this);
|
|
28
|
+
}
|
|
29
|
+
effect(s, e, t) {
|
|
30
|
+
return this._assertAlive(), this._add(this._owner.runtime._effectRegistration(
|
|
31
|
+
this._owner,
|
|
32
|
+
s,
|
|
33
|
+
e,
|
|
34
|
+
t,
|
|
35
|
+
this.paused
|
|
36
|
+
));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Регистрирует в этой группе phase effect без task и без disposer: тело
|
|
40
|
+
* вызывается без аргументов, а binding живёт до освобождения группы или её
|
|
41
|
+
* владельца. Pause и resume группы действуют на него так же, как на effect,
|
|
42
|
+
* зарегистрированный через `effect()`.
|
|
43
|
+
*
|
|
44
|
+
* Binding, зарегистрированный внутри тела другого effect, останавливает ещё и
|
|
45
|
+
* перезапуск этого effect. Остановленный binding больше не исполняется и не
|
|
46
|
+
* реагирует на pause и resume; группа забывает его не сразу, а когда число её
|
|
47
|
+
* регистраций удваивается, поэтому остановленных регистраций в группе не
|
|
48
|
+
* больше, чем действующих, либо меньше `PRUNE_FLOOR`.
|
|
49
|
+
*/
|
|
50
|
+
bindEffect(s, e, t) {
|
|
51
|
+
this._assertAlive(), this._track(this._owner.runtime._effectRegistration(
|
|
52
|
+
this._owner,
|
|
53
|
+
s,
|
|
54
|
+
e,
|
|
55
|
+
t,
|
|
56
|
+
this.paused,
|
|
57
|
+
!0
|
|
58
|
+
));
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Регистрирует в этой группе регистраций группу из `count` phase effects на
|
|
62
|
+
* одном binding, как `owner.effectGroup()`: без task и без disposer, с
|
|
63
|
+
* отдельным набором зависимостей у каждого slot и с запуском slots через
|
|
64
|
+
* `start()` возвращённой группы. Pause и resume действуют на все slots
|
|
65
|
+
* сразу; slots, запущенные или изменившиеся за время pause, исполняются
|
|
66
|
+
* одной доставкой после resume. Binding живёт до освобождения этой группы
|
|
67
|
+
* регистраций или её владельца.
|
|
68
|
+
*
|
|
69
|
+
* Pause изнутри тела slot останавливает доставку: оставшиеся slots
|
|
70
|
+
* исполняются после resume, и причины прерванной доставки приходят в
|
|
71
|
+
* `causes` следующей целиком, вместе с причинами уже исполненных slots.
|
|
72
|
+
*
|
|
73
|
+
* Освобождение отличается от отдельных bindings этой же группы регистраций:
|
|
74
|
+
* slots останавливаются в порядке, обратном порядку номеров, а не в порядке
|
|
75
|
+
* регистрации, и несколько сбоев их cleanup приходят одним вложенным
|
|
76
|
+
* `AggregateError` с сообщением `[Raph] Effect group disposal failed.`.
|
|
77
|
+
*
|
|
78
|
+
* @typeParam Context — значение, которое получает тело каждого slot.
|
|
79
|
+
* @param phase Имя объявленной phase.
|
|
80
|
+
* @param count Число slots: целое от 1 до 4294967293, иначе `RangeError`.
|
|
81
|
+
* @param runSlot Тело slot: получает запуск с `context` и номером slot.
|
|
82
|
+
* @param context Значение, которое группа передаёт телу каждого slot.
|
|
83
|
+
* @param options `priority` task группы, как у `effect()`.
|
|
84
|
+
*/
|
|
85
|
+
effectGroup(s, e, t, r, i) {
|
|
86
|
+
this._assertAlive();
|
|
87
|
+
const o = this._owner.runtime._effectGroupRegistration(
|
|
88
|
+
this._owner,
|
|
89
|
+
s,
|
|
90
|
+
e,
|
|
91
|
+
t,
|
|
92
|
+
r,
|
|
93
|
+
i,
|
|
94
|
+
this.paused
|
|
95
|
+
);
|
|
96
|
+
return this._track(o), o;
|
|
97
|
+
}
|
|
98
|
+
watch(s, e, t, r) {
|
|
99
|
+
return this._assertAlive(), this._add(this._owner.runtime._watchRegistration(
|
|
100
|
+
this._owner,
|
|
101
|
+
s,
|
|
102
|
+
e,
|
|
103
|
+
t,
|
|
104
|
+
r,
|
|
105
|
+
this.paused
|
|
106
|
+
));
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Внутренний путь renderer сохраняет pause ancestry и late-disposal tracking.
|
|
110
|
+
* Возвращаемый disposer renderer не использует; регистрация остаётся у scope.
|
|
111
|
+
* @internal
|
|
112
|
+
*/
|
|
113
|
+
_registerEffect(s, e, t, r, i, o) {
|
|
114
|
+
this._assertAlive();
|
|
115
|
+
const h = this._owner.runtime._effectRegistration(
|
|
116
|
+
this._owner,
|
|
117
|
+
s,
|
|
118
|
+
e,
|
|
119
|
+
t,
|
|
120
|
+
this.paused,
|
|
121
|
+
r,
|
|
122
|
+
i,
|
|
123
|
+
o
|
|
124
|
+
);
|
|
125
|
+
o?.() || this._track(h);
|
|
126
|
+
}
|
|
127
|
+
/** @internal */
|
|
128
|
+
_registerWatch(s, e, t, r, i, o) {
|
|
129
|
+
this._assertAlive();
|
|
130
|
+
const h = this._owner.runtime._watchRegistration(
|
|
131
|
+
this._owner,
|
|
132
|
+
s,
|
|
133
|
+
e,
|
|
134
|
+
t,
|
|
135
|
+
r,
|
|
136
|
+
this.paused,
|
|
137
|
+
i,
|
|
138
|
+
o
|
|
139
|
+
);
|
|
140
|
+
o?.() || this._track(h);
|
|
141
|
+
}
|
|
142
|
+
/** @internal */
|
|
143
|
+
_registerEffectGroup(s, e, t, r, i) {
|
|
144
|
+
this._assertAlive();
|
|
145
|
+
const o = this._owner.runtime._effectGroupRegistration(
|
|
146
|
+
this._owner,
|
|
147
|
+
s,
|
|
148
|
+
e,
|
|
149
|
+
t,
|
|
150
|
+
r,
|
|
151
|
+
i,
|
|
152
|
+
this.paused
|
|
153
|
+
);
|
|
154
|
+
return this._track(o), o;
|
|
155
|
+
}
|
|
156
|
+
pause() {
|
|
157
|
+
this._assertAlive(), this._owner.runtime._runPhaseTransition(() => this._pause());
|
|
158
|
+
}
|
|
159
|
+
resume() {
|
|
160
|
+
this._assertAlive(), this._owner.runtime._runPhaseTransition(() => this._resume());
|
|
161
|
+
}
|
|
162
|
+
_pause() {
|
|
163
|
+
if (this._selfPaused)
|
|
164
|
+
return;
|
|
165
|
+
const s = this.paused;
|
|
166
|
+
if (this._selfPaused = !0, s)
|
|
167
|
+
return;
|
|
168
|
+
const e = [];
|
|
169
|
+
for (const t of this._registrations ?? [])
|
|
170
|
+
try {
|
|
171
|
+
t.registration.pause();
|
|
172
|
+
} catch (r) {
|
|
173
|
+
e.push(r);
|
|
174
|
+
}
|
|
175
|
+
for (const t of this._children ?? [])
|
|
176
|
+
try {
|
|
177
|
+
t._changeAncestorPause(1);
|
|
178
|
+
} catch (r) {
|
|
179
|
+
e.push(r);
|
|
180
|
+
}
|
|
181
|
+
n(e, "[Raph] Pausable effect scope pause failed.");
|
|
182
|
+
}
|
|
183
|
+
_resume() {
|
|
184
|
+
if (!this._selfPaused || (this._selfPaused = !1, this.paused))
|
|
185
|
+
return;
|
|
186
|
+
const s = [];
|
|
187
|
+
for (const e of this._registrations ?? [])
|
|
188
|
+
try {
|
|
189
|
+
e.registration.resume();
|
|
190
|
+
} catch (t) {
|
|
191
|
+
s.push(t);
|
|
192
|
+
}
|
|
193
|
+
for (const e of this._children ?? [])
|
|
194
|
+
try {
|
|
195
|
+
e._changeAncestorPause(-1);
|
|
196
|
+
} catch (t) {
|
|
197
|
+
s.push(t);
|
|
198
|
+
}
|
|
199
|
+
n(s, "[Raph] Pausable effect scope resume failed.");
|
|
200
|
+
}
|
|
201
|
+
dispose() {
|
|
202
|
+
if (this._disposed)
|
|
203
|
+
return;
|
|
204
|
+
this._disposed = !0;
|
|
205
|
+
const s = this._owner.disposed, e = [];
|
|
206
|
+
for (const t of [...this._children ?? []])
|
|
207
|
+
try {
|
|
208
|
+
t.dispose();
|
|
209
|
+
} catch (r) {
|
|
210
|
+
e.push(r);
|
|
211
|
+
}
|
|
212
|
+
this._children?.clear(), this._children = void 0;
|
|
213
|
+
for (const t of this._registrations ?? [])
|
|
214
|
+
if (t.active = !1, !s)
|
|
215
|
+
try {
|
|
216
|
+
t.registration.dispose();
|
|
217
|
+
} catch (r) {
|
|
218
|
+
e.push(r);
|
|
219
|
+
}
|
|
220
|
+
if (this._registrations?.clear(), this._registrations = void 0, this._parent?._children?.delete(this), !s)
|
|
221
|
+
try {
|
|
222
|
+
this._releaseOwner();
|
|
223
|
+
} catch (t) {
|
|
224
|
+
e.push(t);
|
|
225
|
+
}
|
|
226
|
+
n(e, "[Raph] Pausable effect scope disposal failed.");
|
|
227
|
+
}
|
|
228
|
+
_add(s) {
|
|
229
|
+
const e = this._track(s);
|
|
230
|
+
return e === void 0 ? d : () => {
|
|
231
|
+
e.active && (e.active = !1, this._registrations?.delete(e), e.registration.dispose());
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Вносит регистрацию в группу и возвращает её элемент либо `undefined`,
|
|
236
|
+
* когда группа уже освобождена. Disposer здесь не создаётся: его строит
|
|
237
|
+
* только `_add()`, поэтому `bindEffect()` обходится без closure.
|
|
238
|
+
*/
|
|
239
|
+
_track(s) {
|
|
240
|
+
if (this._disposed || this._owner.disposed) {
|
|
241
|
+
s.dispose();
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
const e = { active: !0, registration: s }, t = this._registrations ??= /* @__PURE__ */ new Set();
|
|
245
|
+
return t.add(e), t.size >= this._pruneAt && this._prune(t), e;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Забывает регистрации, которые уже остановлены не через disposer группы:
|
|
249
|
+
* binding, вложенный в тело другого effect, останавливает engine при
|
|
250
|
+
* перезапуске этого effect, а у `bindEffect()` нет disposer, который убрал бы
|
|
251
|
+
* его отсюда. Без этого группа держала бы тело каждого такого binding до
|
|
252
|
+
* собственного освобождения.
|
|
253
|
+
*
|
|
254
|
+
* Проход выполняется, когда число регистраций достигает порога, и ставит
|
|
255
|
+
* следующий порог вдвое выше числа оставшихся: цена регистрации остаётся
|
|
256
|
+
* постоянной в среднем.
|
|
257
|
+
*/
|
|
258
|
+
_prune(s) {
|
|
259
|
+
for (const e of s)
|
|
260
|
+
e.registration.active || (e.active = !1, s.delete(e));
|
|
261
|
+
this._pruneAt = Math.max(u, s.size * 2);
|
|
262
|
+
}
|
|
263
|
+
_assertAlive() {
|
|
264
|
+
if (this._disposed || this._owner.disposed)
|
|
265
|
+
throw new c("[Raph] Pausable effect scope is disposed.");
|
|
266
|
+
}
|
|
267
|
+
_addChild(s) {
|
|
268
|
+
(this._children ??= /* @__PURE__ */ new Set()).add(s);
|
|
269
|
+
}
|
|
270
|
+
_changeAncestorPause(s) {
|
|
271
|
+
if (this._disposed)
|
|
272
|
+
return;
|
|
273
|
+
const e = this.paused;
|
|
274
|
+
if (this._ancestorPauses += s, this._ancestorPauses < 0)
|
|
275
|
+
throw this._ancestorPauses = 0, new Error("[Raph] Effect scope ancestor pause state is unbalanced.");
|
|
276
|
+
if (e === this.paused)
|
|
277
|
+
return;
|
|
278
|
+
const t = [];
|
|
279
|
+
for (const r of this._registrations ?? [])
|
|
280
|
+
try {
|
|
281
|
+
this.paused ? r.registration.pause() : r.registration.resume();
|
|
282
|
+
} catch (i) {
|
|
283
|
+
t.push(i);
|
|
284
|
+
}
|
|
285
|
+
for (const r of this._children ?? [])
|
|
286
|
+
try {
|
|
287
|
+
r._changeAncestorPause(s);
|
|
288
|
+
} catch (i) {
|
|
289
|
+
t.push(i);
|
|
290
|
+
}
|
|
291
|
+
n(t, "[Raph] Pausable effect scope ancestor transition failed.");
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
function n(a, s) {
|
|
295
|
+
if (a.length === 1)
|
|
296
|
+
throw a[0];
|
|
297
|
+
if (a.length > 1)
|
|
298
|
+
throw new AggregateError(a, s);
|
|
299
|
+
}
|
|
300
|
+
function d() {
|
|
301
|
+
}
|
|
302
|
+
export {
|
|
303
|
+
_ as RaphEffectScope
|
|
304
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../reactivity/disposal.cjs"),b=require("../errors.cjs"),S=require("../reactivity/RaphWorkGraph.cjs"),w=require("./RaphScope.cjs");let x=0;const C=Symbol("RaphProvisionalNode"),A=Object.freeze({}),O="[Raph] Child order must contain every direct child exactly once.",p="[Raph] Child order can contain only direct children of the node.";let f,c;class u extends w.RaphScope{#i;constructor(i,t={},e,r){const s=e??(i instanceof u?i.runtime:i??void 0);if(s===void 0)throw new Error("[RaphNode] A root node requires an explicit runtime.");const n=i instanceof u?i:i?.root??null;if(n!==null&&n.runtime!==s)throw new b.RaphCrossRuntimeError("[Raph] Parent belongs to another runtime.");const l=t.priority??0,h=t.id,a=t.meta,y=a===void 0?void 0:{...a},g=t.type??"default";n?._assertAlive(),v(l),super(h??x++,s);const m=r===C;if(this.priority=l,this._parent=n,this._prevSibling=null,this._nextSibling=null,this._firstChild=null,this._lastChild=null,this._childCount=0,this._childArray=void 0,this._published=n===null||!m&&n._published,this.#i=A,new.target!==u&&Object.defineProperty(this,"api",{configurable:!0,enumerable:!0,value:this.#i,writable:!0}),this._meta=y,this.type=g,this._subtreeIdentity=void 0,n!==null){if(n._appendChild(this),!this._published)return;s._hasNodeStructureDemand(this)?s._notifyNodeStructure(this,{node:this,newIndex:n._childCount-1,newParent:n},[],d(this)):s._touchMutationBoundary(),this._assertAlive()}else s._addTopOwner(this)}get id(){const i=this._id;return typeof i=="string"?i:this._id=`node-${i}`}get meta(){return this._meta??={}}set meta(i){this._meta=i}get api(){return this.#i}get _subtreeSourceIdentity(){return this._subtreeIdentity??=Object.freeze({})}get node(){return this}get parent(){return this._parent}get children(){return this._childArray??this._materializeChildren()}addChild(i){if(this._assertAlive(),i._assertAlive(),i.runtime!==this.runtime)throw new b.RaphCrossRuntimeError("[Raph] Child belongs to another runtime.");if(this===i)throw new Error("[Raph] A node cannot become its own ancestor.");if(!i._published||!this._published)throw new Error("[Raph] A provisional node cannot be reparented before setup commits.");for(let t=this;t!==null;t=t.parent)if(t===i)throw new Error("[Raph] A node cannot become its own ancestor.");return i.parent===this?!0:this.runtime._runNodeMutation(()=>{const t=this.runtime;t._assertNodeReparentAllowed(i,this);const e=i._parent;if(!t._hasNodeStructureDemand(i))return e!==null&&i._unlinkFrom(e,-1),i._parent=this,this._appendChild(i),e===null&&t._removeTopOwner(i),!0;const r=d(i),s=e===null?-1:i._indexIn(e);e!==null&&i._unlinkFrom(e,s),i._parent=this;const n=this._childCount;return this._appendChild(i),e===null&&t._removeTopOwner(i),t._notifyNodeStructure(i,{node:i,...e===null?{}:{oldParent:e},...s<0?{}:{oldIndex:s},newParent:this,newIndex:n},r,d(i)),!0})}reorderChildren(i){this._assertAlive(),this._applyChildOrder(i)||this._rejectChildOrder(i)}moveChild(i,t){if(this._assertAlive(),i._assertAlive(),t!==null&&t._assertAlive(),i._parent!==this||t!==null&&t._parent!==this)throw new Error(p);const e=this.runtime;if(i===t||i._nextSibling===t){e._touchMutationBoundary();return}const r=e._hasNodeSubscribers()?this._indexChildren():void 0;if(this._relinkBefore(i,t),r!==void 0){this._publishChildOrder(r);return}this._childArray=void 0,e._touchMutationBoundary()}_swapChildren(i,t){if(this._assertAlive(),i._assertAlive(),t._assertAlive(),i._parent!==this||t._parent!==this)throw new Error(p);const e=this.runtime;if(i===t){e._touchMutationBoundary();return}const r=e._hasNodeSubscribers()?this._indexChildren():void 0,s=i._nextSibling,n=t._nextSibling;if(s===t?this._relinkBefore(t,i):n===i?this._relinkBefore(i,t):(this._relinkBefore(i,n),this._relinkBefore(t,s)),r!==void 0){this._publishChildOrder(r);return}this._childArray=void 0,e._touchMutationBoundary()}_disposeChildren(i,t=0,e=i===void 0?0:i.length){let r=i;if(r===void 0&&(r=this._childArray??this._collectChildren(),e=r.length),t>=e)return;const s=this._childArray;s!==void 0&&(s===r||this._firstChild===r[t].node)&&(this._childArray=void 0);const n=this.runtime;let l;n._beginOwnerDisposal();for(let h=t;h<e;h++)try{r[h].node.dispose()}catch(a){(l??=[]).push(a)}try{n._endOwnerDisposal()}catch(h){(l??=[]).push(h)}return l}options(i){this._assertAlive(),i.meta!==void 0&&(this._meta={...i.meta}),i.priority!==void 0&&(v(i.priority),this.priority=i.priority),i.type!==void 0&&(this.type=i.type),this.touch(Object.freeze({options:Object.freeze({...i})}))}touch(i){this._assertAlive(),this.runtime._runNodeMutation(()=>this.runtime._notifyNodeTouch(this,i))}remove(){this.dispose()}dispose(){o.throwDisposalFailure(c.call(this))}_disposeForOwner(){try{const i=this.dispose;if(i===f)return c.call(this);i.call(this);return}catch(i){return o.unroutedDisposalFailure(i)}}_disposeWithOutcome(){if(this._disposed||this._disposing)return;this._disposing=!0;const i=this.runtime;i._beginOwnerDisposal(this);let t;try{if(this._firstChild!==null){const r=this._takeChildSnapshot();for(let s=0;s<r.length;s++){const n=r[s];try{const l=n.dispose;if(l===f){const h=c.call(n);h!==void 0&&(t??=[]).push(h)}else l.call(n)}catch(l){(t??=[]).push(o.unroutedDisposalFailure(l))}}this._resetChildList(r)}const e=this._parent;if(this._published&&i._hasNodeStructureDemand(this)){const r=d(this),s=e===null?-1:this._indexIn(e);e!==null&&(this._unlinkFrom(e,s),this._parent=null);try{i._notifyNodeStructure(this,{node:this,...e===null?{}:{oldParent:e},...s<0?{}:{oldIndex:s}},r,[])}catch(n){(t??=[]).push(o.unroutedDisposalFailure(n))}}else if(e!==null&&(this._unlinkFrom(e,-1),this._parent=null),this._published)try{i._touchMutationBoundary()}catch(r){(t??=[]).push(o.unroutedDisposalFailure(r))}try{const r=super._disposeScopeForOwner(super.dispose);r!==void 0&&(t??=[]).push(r)}catch(r){(t??=[]).push(o.unroutedDisposalFailure(r))}e===null&&i._removeTopOwner(this),this._published=!1;try{i._releaseNode(this)}catch(r){(t??=[]).push(o.unroutedDisposalFailure(r))}}finally{try{i._endOwnerDisposal()}catch(e){(t??=[]).push(o.unroutedDisposalFailure(e))}}if(t!==void 0)return o.combineDisposalFailures(t,`[Raph] Node "${this.id}" disposal failed.`)}_setApi(i){this.#i=typeof i=="object"&&i!==null&&!(i instanceof S.RaphProducer)?Object.freeze(i):i,Object.hasOwn(this,"api")&&Object.defineProperty(this,"api",{configurable:!1,enumerable:!0,value:this.#i,writable:!1})}_publishCreation(){if(this._published)return;const i=this._parent;if(!(i===null||!i._published)){this._published=!0;try{const t=this.runtime;t._hasNodeStructureDemand(this)?t._notifyNodeStructure(this,{node:this,newIndex:this._indexIn(i),newParent:i},[],d(this)):t._touchMutationBoundary();for(let e=this._firstChild;e!==null;e=e._nextSibling)e._publishCreation()}catch(t){throw this._published=!1,t}}}_isPublished(){return this._published}_isLinked(){const i=this._parent;return i!==null&&(this._prevSibling!==null||i._firstChild===this)}_collectDescendants(i){let t=this;for(;;){let e=t._firstChild;for(;e===null;){if(t===this)return;e=t._nextSibling,e===null&&(t=t._parent)}t=e,i.push(t)}}_countSubtree(i){let t=this;for(;;){i.resources+=t._debugResourceCount(),i.sources+=t._debugSourceCount();let e=t._firstChild;for(;e===null;){if(t===this)return;e=t._nextSibling,e===null&&(t=t._parent)}t=e}}_findNode(i){let t=this;for(;;){if(t.id===i)return t;let e=t._lastChild;for(;e===null;){if(t===this)return;e=t._prevSibling,e===null&&(t=t._parent)}t=e}}_applyChildOrder(i){const t=i.length;if(t!==this._childCount)return!1;const e=[];for(let l=0;l<t;l++)e.push(i[l]);if(t!==this._childCount)return!1;const r=this.runtime,s=r._hasNodeSubscribers()?this._indexChildren():void 0;if(!this._relinkChildren(e))return!1;const n=this._childArray;if(n!==void 0&&n!==i)for(let l=0;l<t;l++)n[l]=e[l];return s===void 0?r._touchMutationBoundary():this._notifyChildOrder(e,s),!0}_relinkChildren(i){for(let n=this._firstChild;n!==null;n=n._nextSibling)n._prevSibling=this;const t=i.length;let e=null,r=0;try{for(;r<t;r++){const n=i[r];if(n?._parent!==this||n._prevSibling!==this||n._disposing)break;n._prevSibling=e,e=n}}finally{if(r!==t){let n=null;for(let l=this._firstChild;l!==null;l=l._nextSibling)l._prevSibling=n,n=l}}if(r!==t)return!1;let s=null;for(let n=e;n!==null;n=n._prevSibling)n._nextSibling=s,s=n;return this._firstChild=s,this._lastChild=e,!0}_rejectChildOrder(i){if(i.length===this._childCount&&new Set(i).size===i.length){for(const t of i)if(t._assertAlive(),t._parent!==this)throw new Error(p)}throw new Error(O)}_indexChildren(){const i=new Map;let t=0;for(let e=this._firstChild;e!==null;e=e._nextSibling)i.set(e,t++);return i}_publishChildOrder(i){let t=this._childArray;if(t===void 0)t=this._materializeChildren();else{let e=0;for(let r=this._firstChild;r!==null;r=r._nextSibling)t[e++]=r}this._notifyChildOrder(t,i)}_notifyChildOrder(i,t){const e=this.runtime;e._runNodeMutation(()=>{for(let r=0;r<i.length;r++){const s=i[r],n=t.get(s);if(n===r)continue;const l=d(s);e._notifyNodeStructure(s,{node:s,oldParent:this,newParent:this,oldIndex:n,newIndex:r},l,l)}})}_relinkBefore(i,t){const e=i._prevSibling,r=i._nextSibling;e===null?this._firstChild=r:e._nextSibling=r,r===null?this._lastChild=e:r._prevSibling=e;const s=t===null?this._lastChild:t._prevSibling;i._prevSibling=s,i._nextSibling=t,s===null?this._firstChild=i:s._nextSibling=i,t===null?this._lastChild=i:t._prevSibling=i}_materializeChildren(){return this._childArray=this._collectChildren()}_collectChildren(){const i=[];for(let t=this._firstChild;t!==null;t=t._nextSibling)i.push(t);return i}_clearChildArray(){const i=this._childArray;i!==void 0&&(i.length=0,this._childArray=void 0)}_appendChild(i){const t=this._lastChild;i._prevSibling=t,t===null?this._firstChild=i:t._nextSibling=i,this._lastChild=i,this._childCount++;const e=this._childArray;e!==void 0&&e.push(i)}_indexIn(i){return this._prevSibling===null?i._firstChild===this?0:-1:i._lastChild===this?i._childCount-1:(i._childArray??i._materializeChildren()).indexOf(this)}_unlinkFrom(i,t){const e=this._prevSibling,r=this._nextSibling;if(e===null){if(i._firstChild!==this)return;i._firstChild=r}else e._nextSibling=r,this._prevSibling=null;r===null?i._lastChild=e:(r._prevSibling=e,this._nextSibling=null),i._childCount--;const s=i._childArray;if(s!==void 0)if(r===null)s.pop();else if(t<0&&!i._disposing&&!this.runtime._hasNodeSubscribers())i._childArray=void 0;else if(e===null)s.shift();else{const n=t>=0?t:s.indexOf(this);n>=0?s.splice(n,1):i._childArray=void 0}}_takeChildSnapshot(){const i=this._childArray;return i===void 0?this._collectChildren():(this._childArray=void 0,i)}_resetChildList(i){i.length=0,this._clearChildArray();let t=this._firstChild;for(;t!==null;){const e=t._nextSibling;t._prevSibling=null,t._nextSibling=null,t=e}this._firstChild=null,this._lastChild=null,this._childCount=0}}function N(_,i,t){return new u(_,i,t,C)}u.prototype._isNode=!0;function d(_){const i=[];for(let t=_;t!==null;t=t.parent)i.push(t);return i}function v(_){if(!Number.isFinite(_))throw new TypeError("[Raph] Node priority must be finite.")}f=u.prototype.dispose;c=u.prototype._disposeWithOutcome;exports.RaphNode=u;exports.createProvisionalNode=N;
|