@raphy-js/raph 1.0.1-dev.20 → 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/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 +9 -1
- package/dist/core-ugchZNqC.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=Object.freeze([]),c=Object.freeze({now:0,delta:0,elapsed:0,frame:0}),o=1,_=2,E=4,p=8,d=16,T=32,l=64,A=128,u=256,f=1536,R=0,D=512,v=1024,K=1536,C=2048,O=0,U=1,P=2;class S{constructor(e){this._record=e,Object.freeze(this)}get phase(){return this._record.phaseState.name}get consumerOwner(){return this._record.consumerOwner}get effect(){return this._record.effect}get causes(){return this._record.causes}get frame(){return this._record.frame}get priority(){return this._record.priority}get sequence(){return this._record.sequence}run(){const e=this._record;e.phaseState.pipeline._runDelivery(e)}defer(){const e=this._record;e.phaseState.pipeline._deferDelivery(e)}cancel(){const e=this._record;e.phaseState.pipeline._cancelDelivery(e)}}class a{constructor(){this.extraCauses=void 0,this.deliveryFirstCause=void 0,this.deliveryFirstCauseKey=void 0,this.deliveryExtraCauses=void 0,this.deliveryCauses=void 0,this.deferCount=0}}a._shapeAnchor=new a;class y{constructor(e,t,s,i){this.state=o,this.sequence=0,this.phaseState=e,this.priority=t,this.consumerOwner=s,this.effect=i,this.node=void 0,this.watch=void 0,this.group=void 0,this.scopeParent=void 0,this.scopePrevious=void 0,this.scopeNext=void 0,this.firstCause=void 0,this.firstCauseKey=void 0,this.frame=c,this.facade=void 0,this.detail=void 0}get phase(){return this.phaseState.name}get dependencyOwner(){return this.consumerOwner}get allowScheduleDuringRun(){return!0}get active(){return(this.state&o)!==0}get causes(){const e=this.detail;if(e!==void 0){const r=e.deliveryCauses;if(r!==void 0)return r}let t,s;if(this.state&u?(t=this.firstCause,e!==void 0&&(s=e.extraCauses)):e!==void 0&&(t=e.deliveryFirstCause,s=e.deliveryExtraCauses),t===void 0)return h;const i=[Object.freeze(t)];if(s!==void 0)for(const r of s.values())i.push(Object.freeze(r));return this.detailed().deliveryCauses=Object.freeze(i)}get task(){let e=this.facade;return e===void 0&&(this.state&d&&(this.frame=this.phaseState.pipeline.frame),this.facade=e=new S(this)),e}detailed(){return this.detail??=new a}notify(e){this.phaseState.pipeline._notifyTask(this,e)}schedule(){this.phaseState.pipeline._queue(this,!0)}enqueue(e,t=e.source,s=!0){const i=this.phaseState.pipeline;i._appendCause(this,e,t),i._queue(this,s)}start(e,t="scheduled"){this.consumerOwner.runtime._startGroupSlot(this,e,t)}_start(e,t,s){this.consumerOwner.runtime._startGroupSlot(this,e,t,s)}pause(){this.phaseState.pipeline._pauseTask(this)}resume(){this.phaseState.pipeline._resumeTask(this)}dispose(){this.phaseState.pipeline._disposeBinding(this)}}exports.EMPTY_CAUSES=h;exports.EMPTY_FRAME=c;exports.GROUP_CONTEXT=O;exports.GROUP_CURSOR=U;exports.GROUP_NODES=P;exports.RaphPhaseTaskDetail=a;exports.RaphPhaseTaskHandle=S;exports.RaphPhaseTaskRecord=y;exports.TASK_ACTIVE=o;exports.TASK_CANCEL=K;exports.TASK_CAUSES_DELIVERED=u;exports.TASK_DEFER=v;exports.TASK_DEFERRED=p;exports.TASK_DISCARD_ACKNOWLEDGED=T;exports.TASK_EXECUTED=A;exports.TASK_IN_DELIVERY=d;exports.TASK_PAUSED=_;exports.TASK_PENDING=E;exports.TASK_REQUESTED=l;exports.TASK_RESOLUTION=f;exports.TASK_RUN=D;exports.TASK_TASKLESS=C;exports.TASK_UNRESOLVED=R;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
const h = Object.freeze([]), c = Object.freeze({ now: 0, delta: 0, elapsed: 0, frame: 0 }), n = 1, l = 2, _ = 4, S = 8, u = 16, f = 32, v = 64, E = 128, d = 256, T = 1536, A = 0, C = 512, O = 1024, D = 1536, R = 2048, y = 0, K = 1, m = 2;
|
|
2
|
+
class p {
|
|
3
|
+
constructor(e) {
|
|
4
|
+
this._record = e, Object.freeze(this);
|
|
5
|
+
}
|
|
6
|
+
get phase() {
|
|
7
|
+
return this._record.phaseState.name;
|
|
8
|
+
}
|
|
9
|
+
get consumerOwner() {
|
|
10
|
+
return this._record.consumerOwner;
|
|
11
|
+
}
|
|
12
|
+
get effect() {
|
|
13
|
+
return this._record.effect;
|
|
14
|
+
}
|
|
15
|
+
get causes() {
|
|
16
|
+
return this._record.causes;
|
|
17
|
+
}
|
|
18
|
+
get frame() {
|
|
19
|
+
return this._record.frame;
|
|
20
|
+
}
|
|
21
|
+
get priority() {
|
|
22
|
+
return this._record.priority;
|
|
23
|
+
}
|
|
24
|
+
get sequence() {
|
|
25
|
+
return this._record.sequence;
|
|
26
|
+
}
|
|
27
|
+
run() {
|
|
28
|
+
const e = this._record;
|
|
29
|
+
e.phaseState.pipeline._runDelivery(e);
|
|
30
|
+
}
|
|
31
|
+
defer() {
|
|
32
|
+
const e = this._record;
|
|
33
|
+
e.phaseState.pipeline._deferDelivery(e);
|
|
34
|
+
}
|
|
35
|
+
cancel() {
|
|
36
|
+
const e = this._record;
|
|
37
|
+
e.phaseState.pipeline._cancelDelivery(e);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
class a {
|
|
41
|
+
constructor() {
|
|
42
|
+
this.extraCauses = void 0, this.deliveryFirstCause = void 0, this.deliveryFirstCauseKey = void 0, this.deliveryExtraCauses = void 0, this.deliveryCauses = void 0, this.deferCount = 0;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
a._shapeAnchor = new a();
|
|
46
|
+
class g {
|
|
47
|
+
constructor(e, t, s, i) {
|
|
48
|
+
this.state = n, this.sequence = 0, this.phaseState = e, this.priority = t, this.consumerOwner = s, this.effect = i, this.node = void 0, this.watch = void 0, this.group = void 0, this.scopeParent = void 0, this.scopePrevious = void 0, this.scopeNext = void 0, this.firstCause = void 0, this.firstCauseKey = void 0, this.frame = c, this.facade = void 0, this.detail = void 0;
|
|
49
|
+
}
|
|
50
|
+
get phase() {
|
|
51
|
+
return this.phaseState.name;
|
|
52
|
+
}
|
|
53
|
+
get dependencyOwner() {
|
|
54
|
+
return this.consumerOwner;
|
|
55
|
+
}
|
|
56
|
+
get allowScheduleDuringRun() {
|
|
57
|
+
return !0;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Становится false, когда binding остановлен: так запись видят effect scopes,
|
|
61
|
+
* которым она передана как pausable-регистрация.
|
|
62
|
+
*/
|
|
63
|
+
get active() {
|
|
64
|
+
return (this.state & n) !== 0;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Причины текущей доставки в том виде, в каком их получает callback или
|
|
68
|
+
* `process`. Массив строится при первом чтении в доставке и до её конца
|
|
69
|
+
* остаётся тем же объектом; доставка, причины которой никто не прочитал, не
|
|
70
|
+
* создаёт ни массива, ни заморозки. Вне доставки и для доставки без причин
|
|
71
|
+
* это общий пустой массив.
|
|
72
|
+
*
|
|
73
|
+
* Это единственное место, где причины выходят наружу, поэтому здесь же они
|
|
74
|
+
* становятся неизменяемыми: WorkGraph создаёт причину без заморозки, а
|
|
75
|
+
* замораживает её первое чтение.
|
|
76
|
+
*/
|
|
77
|
+
get causes() {
|
|
78
|
+
const e = this.detail;
|
|
79
|
+
if (e !== void 0) {
|
|
80
|
+
const r = e.deliveryCauses;
|
|
81
|
+
if (r !== void 0)
|
|
82
|
+
return r;
|
|
83
|
+
}
|
|
84
|
+
let t, s;
|
|
85
|
+
if (this.state & d ? (t = this.firstCause, e !== void 0 && (s = e.extraCauses)) : e !== void 0 && (t = e.deliveryFirstCause, s = e.deliveryExtraCauses), t === void 0)
|
|
86
|
+
return h;
|
|
87
|
+
const i = [Object.freeze(t)];
|
|
88
|
+
if (s !== void 0)
|
|
89
|
+
for (const r of s.values())
|
|
90
|
+
i.push(Object.freeze(r));
|
|
91
|
+
return this.detailed().deliveryCauses = Object.freeze(i);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* One facade per record: created on first exposure, then reused.
|
|
95
|
+
*
|
|
96
|
+
* Запись начинает вести frame с появлением facade. Facade создаётся внутри
|
|
97
|
+
* открытой доставки своей записи — его запрашивают только тело binding и
|
|
98
|
+
* `process` — и получает её frame; frame каждой следующей доставки
|
|
99
|
+
* записывает её открытие.
|
|
100
|
+
*/
|
|
101
|
+
get task() {
|
|
102
|
+
let e = this.facade;
|
|
103
|
+
return e === void 0 && (this.state & u && (this.frame = this.phaseState.pipeline.frame), this.facade = e = new p(this)), e;
|
|
104
|
+
}
|
|
105
|
+
/** Возвращает редкое состояние записи и создаёт его при первом обращении. */
|
|
106
|
+
detailed() {
|
|
107
|
+
return this.detail ??= new a();
|
|
108
|
+
}
|
|
109
|
+
notify(e) {
|
|
110
|
+
this.phaseState.pipeline._notifyTask(this, e);
|
|
111
|
+
}
|
|
112
|
+
schedule() {
|
|
113
|
+
this.phaseState.pipeline._queue(this, !0);
|
|
114
|
+
}
|
|
115
|
+
enqueue(e, t = e.source, s = !0) {
|
|
116
|
+
const i = this.phaseState.pipeline;
|
|
117
|
+
i._appendCause(this, e, t), i._queue(this, s);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Запускает slot группы effects; у записи одиночного effect и watch ничего
|
|
121
|
+
* не делает. Запись группы сама является handle, который возвращает
|
|
122
|
+
* `effectGroup`.
|
|
123
|
+
*/
|
|
124
|
+
start(e, t = "scheduled") {
|
|
125
|
+
this.consumerOwner.runtime._startGroupSlot(this, e, t);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Внутренний initial invocation renderer; публичный start не меняет signature.
|
|
129
|
+
* Continuation не сохраняется в записи и не вызывается при последующих runs.
|
|
130
|
+
* @internal
|
|
131
|
+
*/
|
|
132
|
+
_start(e, t, s) {
|
|
133
|
+
this.consumerOwner.runtime._startGroupSlot(this, e, t, s);
|
|
134
|
+
}
|
|
135
|
+
pause() {
|
|
136
|
+
this.phaseState.pipeline._pauseTask(this);
|
|
137
|
+
}
|
|
138
|
+
resume() {
|
|
139
|
+
this.phaseState.pipeline._resumeTask(this);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Полностью освобождает binding; безопасен для повторного и вложенного вызова:
|
|
143
|
+
* снимает запись со списка владельца, останавливает engine effect или watch
|
|
144
|
+
* lifecycle и сбрасывает состояние pipeline. Engine вызывает его как task hook
|
|
145
|
+
* остановленного effect, владелец — как элемент списка ресурсов, а
|
|
146
|
+
* пользователь — через disposer.
|
|
147
|
+
*/
|
|
148
|
+
dispose() {
|
|
149
|
+
this.phaseState.pipeline._disposeBinding(this);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
export {
|
|
153
|
+
h as EMPTY_CAUSES,
|
|
154
|
+
c as EMPTY_FRAME,
|
|
155
|
+
y as GROUP_CONTEXT,
|
|
156
|
+
K as GROUP_CURSOR,
|
|
157
|
+
m as GROUP_NODES,
|
|
158
|
+
a as RaphPhaseTaskDetail,
|
|
159
|
+
p as RaphPhaseTaskHandle,
|
|
160
|
+
g as RaphPhaseTaskRecord,
|
|
161
|
+
n as TASK_ACTIVE,
|
|
162
|
+
D as TASK_CANCEL,
|
|
163
|
+
d as TASK_CAUSES_DELIVERED,
|
|
164
|
+
O as TASK_DEFER,
|
|
165
|
+
S as TASK_DEFERRED,
|
|
166
|
+
f as TASK_DISCARD_ACKNOWLEDGED,
|
|
167
|
+
E as TASK_EXECUTED,
|
|
168
|
+
u as TASK_IN_DELIVERY,
|
|
169
|
+
l as TASK_PAUSED,
|
|
170
|
+
_ as TASK_PENDING,
|
|
171
|
+
v as TASK_REQUESTED,
|
|
172
|
+
T as TASK_RESOLUTION,
|
|
173
|
+
C as TASK_RUN,
|
|
174
|
+
R as TASK_TASKLESS,
|
|
175
|
+
A as TASK_UNRESOLVED
|
|
176
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../reactivity/RuntimeWatch.cjs");class a extends o.RuntimeWatch{constructor(t,e){super(t,e),this.source=void 0,this.record=void 0}}function s(r,t){const e=new a(r,()=>{const c=e.record;return c===void 0?void 0:c.effect(c.task)});return e.record=t,e}exports.RaphPhaseWatch=a;exports.createPhaseWatch=s;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RuntimeWatch as c } from "../reactivity/RuntimeWatch.js";
|
|
2
|
+
class s extends c {
|
|
3
|
+
/**
|
|
4
|
+
* Создаёт lifecycle без подписки и без binding; оба поля задаёт регистрация.
|
|
5
|
+
*/
|
|
6
|
+
constructor(e, t) {
|
|
7
|
+
super(e, t), this.source = void 0, this.record = void 0;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function a(o, e) {
|
|
11
|
+
const t = new s(o, () => {
|
|
12
|
+
const r = t.record;
|
|
13
|
+
return r === void 0 ? void 0 : r.effect(r.task);
|
|
14
|
+
});
|
|
15
|
+
return t.record = e, t;
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
s as RaphPhaseWatch,
|
|
19
|
+
a as createPhaseWatch
|
|
20
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../path/data-path.utils.cjs"),l=require("../errors.cjs"),p=require("../ownership/throwDisposalErrors.cjs");class u{path;options;_revision;_disposeRevision;_isTracking;_store;_release;_masks;_assertOwnerAlive;_assertTrackedRead;_assertWriteAllowed;_runWrite;_notifyEvents;_hasRevisionSubscribers;_stop;_activationLeases=0;_trackedActivation=!1;_disposed=!1;constructor(s,t,r,e,i,o,a,_,n,d,v){const h=i._ownedSignal(0,d);this._store=s,this._revision=h.source,this._disposeRevision=h.dispose,this._isTracking=i._isTracking,this.path=t.canonical,this.options=r,this._release=e,this._masks=c.pathRelationMasks(t),this._assertOwnerAlive=o,this._assertTrackedRead=a,this._assertWriteAllowed=_,this._runWrite=n,this._notifyEvents=v,this._hasRevisionSubscribers=h.hasSubscribers}get disposed(){return this._disposed}get(){return this._assertAlive(),this._assertTrackedRead?.(),this._isTracking()?this._readTracked():this._store.peek(this.path)}peek(){return this._assertAlive(),this._store.peek(this.path)}set(s){this._assertAlive(),this._assertWriteAllowed?.(),this._write(()=>this._store.set(this.path,s))}merge(s){this._assertAlive(),this._assertWriteAllowed?.(),this._write(()=>this._store.merge(this.path,s))}delete(){this._assertAlive(),this._assertWriteAllowed?.(),this._write(()=>this._store.delete(this.path))}has(){return this._assertAlive(),this._store.has(this.path)}dispose(){if(this._disposed)return;const s=this._runWrite;s===void 0?this._disposeNow():s(()=>this._disposeNow())}_disposeNow(){if(this._disposed)return;this._disposed=!0;const s=[],t=this._stop;this._stop=void 0;const r=this._disposeRevision;this._disposeRevision=void 0;const e=this._release;this._release=void 0,this._revision=void 0,this._isTracking=void 0,this._store=void 0,this._assertOwnerAlive=void 0,this._assertTrackedRead=void 0,this._assertWriteAllowed=void 0,this._runWrite=void 0,this._notifyEvents=void 0,this._hasRevisionSubscribers=void 0,this._activationLeases=0,this._trackedActivation=!1;try{t?.()}catch(i){s.push(i)}try{r?.()}catch(i){s.push(i)}try{e?.(this)}catch(i){s.push(i)}p.throwDisposalErrors(s,`[Raph] Path handle "${this.path}" disposal failed.`)}_getTracked(){return this._assertAlive(),this._assertTrackedRead?.(),this._readTracked()}_activate(){this._assertAlive(),this._activationLeases++;try{this._observe()}catch(t){throw this._activationLeases--,t}let s=!0;return()=>{s&&(s=!1,this._activationLeases!==0&&this._activationLeases--,this._releaseObserverIfIdle())}}_readTracked(){return this._trackedActivation=!0,this._observe(),this._revision.get(),this._store.get(this.path)}_observe(){this._stop??=this._store.watch(this._masks,s=>{const t=()=>{if(this._disposed)return;const e=this._revision;e!==void 0&&(this._notifyEvents?.(s,this._hasRevisionSubscribers?.()??!1),!(this._disposed||this._revision!==e)&&e.set(e.peek()+1))},r=this._runWrite;r===void 0?t():r(t)})}_releaseObserverIfIdle(){if(this._disposed||this._trackedActivation||this._activationLeases!==0)return;const s=this._stop;this._stop=void 0,s?.()}_write(s){const t=this._runWrite;t===void 0?s():t(s)}_assertAlive(){if(this._disposed)throw new l.RaphDisposedError(`[Raph] Path handle "${this.path}" is disposed.`);this._assertOwnerAlive?.()}}exports.PathHandle=u;
|
|
@@ -1,39 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { pathRelationMasks as c } from "../../path/data-path.utils.js";
|
|
2
|
+
import { RaphDisposedError as p } from "../errors.js";
|
|
3
|
+
import { throwDisposalErrors as l } from "../ownership/throwDisposalErrors.js";
|
|
4
|
+
class A {
|
|
5
|
+
// Публикуют canonical path и нормализованные параметры handle.
|
|
6
|
+
path;
|
|
7
|
+
options;
|
|
8
|
+
// Связывают path revision с runtime reactivity и owning Kernel.
|
|
9
|
+
_revision;
|
|
10
|
+
_disposeRevision;
|
|
11
|
+
_isTracking;
|
|
12
|
+
_store;
|
|
13
|
+
_release;
|
|
14
|
+
_masks;
|
|
15
|
+
// Применяют runtime lifecycle и write policy к операциям handle.
|
|
16
|
+
_assertOwnerAlive;
|
|
17
|
+
_assertTrackedRead;
|
|
18
|
+
_assertWriteAllowed;
|
|
19
|
+
_runWrite;
|
|
20
|
+
_notifyEvents;
|
|
21
|
+
_hasRevisionSubscribers;
|
|
22
|
+
// Хранят активную Kernel subscription и окончательное состояние handle.
|
|
23
|
+
_stop;
|
|
24
|
+
_activationLeases = 0;
|
|
25
|
+
_trackedActivation = !1;
|
|
26
|
+
_disposed = !1;
|
|
8
27
|
/**
|
|
9
28
|
* Создаёт internal path handle и связывает его с runtime lifecycle.
|
|
10
29
|
* @internal
|
|
11
30
|
*/
|
|
12
|
-
constructor(s, t,
|
|
13
|
-
|
|
14
|
-
i(this,
|
|
15
|
-
i(this, "options");
|
|
16
|
-
// Связывают path revision с runtime reactivity и owning Kernel.
|
|
17
|
-
i(this, "_revision");
|
|
18
|
-
i(this, "_disposeRevision");
|
|
19
|
-
i(this, "_isTracking");
|
|
20
|
-
i(this, "_store");
|
|
21
|
-
i(this, "_release");
|
|
22
|
-
i(this, "_masks");
|
|
23
|
-
// Применяют runtime lifecycle и write policy к операциям handle.
|
|
24
|
-
i(this, "_assertOwnerAlive");
|
|
25
|
-
i(this, "_assertTrackedRead");
|
|
26
|
-
i(this, "_assertWriteAllowed");
|
|
27
|
-
i(this, "_runWrite");
|
|
28
|
-
i(this, "_notifyEvents");
|
|
29
|
-
i(this, "_hasRevisionSubscribers");
|
|
30
|
-
// Хранят активную Kernel subscription и окончательное состояние handle.
|
|
31
|
-
i(this, "_stop");
|
|
32
|
-
i(this, "_activationLeases", 0);
|
|
33
|
-
i(this, "_trackedActivation", !1);
|
|
34
|
-
i(this, "_disposed", !1);
|
|
35
|
-
const _ = e._ownedSignal(0, c);
|
|
36
|
-
this._store = s, this._revision = _.source, this._disposeRevision = _.dispose, this._isTracking = e._isTracking, this.path = t.canonical, this.options = h, this._release = r, this._masks = f(t), this._assertOwnerAlive = a, this._assertTrackedRead = n, this._assertWriteAllowed = d, this._runWrite = v, this._notifyEvents = l, this._hasRevisionSubscribers = _.hasSubscribers;
|
|
31
|
+
constructor(s, t, r, i, e, o, a, _, n, d, v) {
|
|
32
|
+
const h = e._ownedSignal(0, d);
|
|
33
|
+
this._store = s, this._revision = h.source, this._disposeRevision = h.dispose, this._isTracking = e._isTracking, this.path = t.canonical, this.options = r, this._release = i, this._masks = c(t), this._assertOwnerAlive = o, this._assertTrackedRead = a, this._assertWriteAllowed = _, this._runWrite = n, this._notifyEvents = v, this._hasRevisionSubscribers = h.hasSubscribers;
|
|
37
34
|
}
|
|
38
35
|
/**
|
|
39
36
|
* Показывает, освобождён ли path handle.
|
|
@@ -45,8 +42,7 @@ class T {
|
|
|
45
42
|
* Читает path с регистрацией реактивной зависимости.
|
|
46
43
|
*/
|
|
47
44
|
get() {
|
|
48
|
-
|
|
49
|
-
return this._assertAlive(), (s = this._assertTrackedRead) == null || s.call(this), this._isTracking() ? this._readTracked() : this._store.peek(this.path);
|
|
45
|
+
return this._assertAlive(), this._assertTrackedRead?.(), this._isTracking() ? this._readTracked() : this._store.peek(this.path);
|
|
50
46
|
}
|
|
51
47
|
/**
|
|
52
48
|
* Читает path без регистрации реактивной зависимости.
|
|
@@ -58,22 +54,19 @@ class T {
|
|
|
58
54
|
* Записывает значение path через runtime write policy.
|
|
59
55
|
*/
|
|
60
56
|
set(s) {
|
|
61
|
-
|
|
62
|
-
this._assertAlive(), (t = this._assertWriteAllowed) == null || t.call(this), this._write(() => this._store.set(this.path, s));
|
|
57
|
+
this._assertAlive(), this._assertWriteAllowed?.(), this._write(() => this._store.set(this.path, s));
|
|
63
58
|
}
|
|
64
59
|
/**
|
|
65
60
|
* Объединяет значение path через runtime write policy.
|
|
66
61
|
*/
|
|
67
62
|
merge(s) {
|
|
68
|
-
|
|
69
|
-
this._assertAlive(), (t = this._assertWriteAllowed) == null || t.call(this), this._write(() => this._store.merge(this.path, s));
|
|
63
|
+
this._assertAlive(), this._assertWriteAllowed?.(), this._write(() => this._store.merge(this.path, s));
|
|
70
64
|
}
|
|
71
65
|
/**
|
|
72
66
|
* Удаляет значение path через runtime write policy.
|
|
73
67
|
*/
|
|
74
68
|
delete() {
|
|
75
|
-
|
|
76
|
-
this._assertAlive(), (s = this._assertWriteAllowed) == null || s.call(this), this._write(() => this._store.delete(this.path));
|
|
69
|
+
this._assertAlive(), this._assertWriteAllowed?.(), this._write(() => this._store.delete(this.path));
|
|
77
70
|
}
|
|
78
71
|
/**
|
|
79
72
|
* Проверяет наличие значения path.
|
|
@@ -96,34 +89,33 @@ class T {
|
|
|
96
89
|
this._disposed = !0;
|
|
97
90
|
const s = [], t = this._stop;
|
|
98
91
|
this._stop = void 0;
|
|
99
|
-
const
|
|
92
|
+
const r = this._disposeRevision;
|
|
100
93
|
this._disposeRevision = void 0;
|
|
101
|
-
const
|
|
94
|
+
const i = this._release;
|
|
102
95
|
this._release = void 0, this._revision = void 0, this._isTracking = void 0, this._store = void 0, this._assertOwnerAlive = void 0, this._assertTrackedRead = void 0, this._assertWriteAllowed = void 0, this._runWrite = void 0, this._notifyEvents = void 0, this._hasRevisionSubscribers = void 0, this._activationLeases = 0, this._trackedActivation = !1;
|
|
103
96
|
try {
|
|
104
|
-
t
|
|
97
|
+
t?.();
|
|
105
98
|
} catch (e) {
|
|
106
99
|
s.push(e);
|
|
107
100
|
}
|
|
108
101
|
try {
|
|
109
|
-
|
|
102
|
+
r?.();
|
|
110
103
|
} catch (e) {
|
|
111
104
|
s.push(e);
|
|
112
105
|
}
|
|
113
106
|
try {
|
|
114
|
-
|
|
107
|
+
i?.(this);
|
|
115
108
|
} catch (e) {
|
|
116
109
|
s.push(e);
|
|
117
110
|
}
|
|
118
|
-
|
|
111
|
+
l(s, `[Raph] Path handle "${this.path}" disposal failed.`);
|
|
119
112
|
}
|
|
120
113
|
/**
|
|
121
114
|
* Читает path с регистрацией runtime reactive dependency.
|
|
122
115
|
* @internal
|
|
123
116
|
*/
|
|
124
117
|
_getTracked() {
|
|
125
|
-
|
|
126
|
-
return this._assertAlive(), (s = this._assertTrackedRead) == null || s.call(this), this._readTracked();
|
|
118
|
+
return this._assertAlive(), this._assertTrackedRead?.(), this._readTracked();
|
|
127
119
|
}
|
|
128
120
|
/** Activates the lazy Kernel observer for an explicit granular watch. @internal */
|
|
129
121
|
_activate() {
|
|
@@ -142,34 +134,32 @@ class T {
|
|
|
142
134
|
return this._trackedActivation = !0, this._observe(), this._revision.get(), this._store.get(this.path);
|
|
143
135
|
}
|
|
144
136
|
_observe() {
|
|
145
|
-
this._stop
|
|
137
|
+
this._stop ??= this._store.watch(this._masks, (s) => {
|
|
146
138
|
const t = () => {
|
|
147
|
-
var e, a;
|
|
148
139
|
if (this._disposed)
|
|
149
140
|
return;
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
},
|
|
153
|
-
|
|
154
|
-
})
|
|
141
|
+
const i = this._revision;
|
|
142
|
+
i !== void 0 && (this._notifyEvents?.(s, this._hasRevisionSubscribers?.() ?? !1), !(this._disposed || this._revision !== i) && i.set(i.peek() + 1));
|
|
143
|
+
}, r = this._runWrite;
|
|
144
|
+
r === void 0 ? t() : r(t);
|
|
145
|
+
});
|
|
155
146
|
}
|
|
156
147
|
_releaseObserverIfIdle() {
|
|
157
148
|
if (this._disposed || this._trackedActivation || this._activationLeases !== 0)
|
|
158
149
|
return;
|
|
159
150
|
const s = this._stop;
|
|
160
|
-
this._stop = void 0, s
|
|
151
|
+
this._stop = void 0, s?.();
|
|
161
152
|
}
|
|
162
153
|
_write(s) {
|
|
163
154
|
const t = this._runWrite;
|
|
164
155
|
t === void 0 ? s() : t(s);
|
|
165
156
|
}
|
|
166
157
|
_assertAlive() {
|
|
167
|
-
var s;
|
|
168
158
|
if (this._disposed)
|
|
169
|
-
throw new
|
|
170
|
-
|
|
159
|
+
throw new p(`[Raph] Path handle "${this.path}" is disposed.`);
|
|
160
|
+
this._assertOwnerAlive?.();
|
|
171
161
|
}
|
|
172
162
|
}
|
|
173
163
|
export {
|
|
174
|
-
|
|
164
|
+
A as PathHandle
|
|
175
165
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../path/DataPath.cjs"),d=require("../errors.cjs");class a{constructor(e,t,s,r,i){this.owner=e,this._start=r,this._release=i;const o=Object.freeze({...s,...s.vars===void 0?{}:{vars:Object.freeze({...s.vars})}});this.options=o,this.masks=Array.isArray(t)?Object.freeze(t.map(c=>n.DataPath.from(c,o))):n.DataPath.from(t,o)}masks;options;_stop;_activationLeases=0;_disposed=!1;_releaseOwner;static _create(e,t,s,r,i){return new a(e,t,s,r,i)}get runtime(){return this.owner.runtime}get disposed(){return this._disposed}dispose(){if(this._disposed)return;const e=this.runtime,t=!e._ownerDisposalActive();t&&e._beginOwnerDisposal();const s=[];try{const r=this._releaseOwner;r!==void 0?(this._releaseOwner=void 0,r()):this._disposeOwned()}catch(r){s.push(r)}finally{if(t)try{e._endOwnerDisposal()}catch(r){s.push(r)}}if(s.length===1)throw s[0];if(s.length>1)throw new AggregateError(s,"[Raph] Meta source disposal failed.")}_bindOwner(e){this._releaseOwner=e}_disposeOwned(){if(this._disposed)return;this._disposed=!0,this._releaseOwner=void 0;const e=[];try{this._stop?.()}catch(t){e.push(t)}this._stop=void 0,this._activationLeases=0;try{this._release()}catch(t){e.push(t)}if(this._start=_,this._release=h,e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"[Raph] Meta source disposal failed.")}_activate(){this._assertAlive(),this._activationLeases++;try{this._stop??=this._start()}catch(t){throw this._activationLeases--,t}let e=!0;return()=>{if(!e||(e=!1,this._activationLeases!==0&&this._activationLeases--,this._disposed||this._activationLeases!==0))return;const t=this._stop;this._stop=void 0,t?.()}}_assertAlive(){if(this._disposed||this.owner.disposed)throw new d.RaphDisposedError("[Raph] Meta source is disposed.")}}function h(){}function _(){return h}exports.RaphMetaSource=a;
|
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { DataPath as h } from "../../path/DataPath.js";
|
|
5
|
-
import { RaphDisposedError as f } from "../errors.js";
|
|
6
|
-
class c {
|
|
1
|
+
import { DataPath as a } from "../../path/DataPath.js";
|
|
2
|
+
import { RaphDisposedError as c } from "../errors.js";
|
|
3
|
+
class n {
|
|
7
4
|
/** @internal */
|
|
8
|
-
constructor(e, s, t, r,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
i(this, "_stop");
|
|
12
|
-
i(this, "_activationLeases", 0);
|
|
13
|
-
i(this, "_disposed", !1);
|
|
14
|
-
i(this, "_releaseOwner");
|
|
15
|
-
this.owner = e, this._start = r, this._release = a;
|
|
16
|
-
const n = Object.freeze({
|
|
5
|
+
constructor(e, s, t, r, i) {
|
|
6
|
+
this.owner = e, this._start = r, this._release = i;
|
|
7
|
+
const o = Object.freeze({
|
|
17
8
|
...t,
|
|
18
9
|
...t.vars === void 0 ? {} : { vars: Object.freeze({ ...t.vars }) }
|
|
19
10
|
});
|
|
20
|
-
this.options =
|
|
11
|
+
this.options = o, this.masks = Array.isArray(s) ? Object.freeze(s.map((p) => a.from(p, o))) : a.from(s, o);
|
|
21
12
|
}
|
|
13
|
+
masks;
|
|
14
|
+
options;
|
|
15
|
+
_stop;
|
|
16
|
+
_activationLeases = 0;
|
|
17
|
+
_disposed = !1;
|
|
18
|
+
_releaseOwner;
|
|
22
19
|
/** @internal */
|
|
23
|
-
static _create(e, s, t, r,
|
|
24
|
-
return new
|
|
20
|
+
static _create(e, s, t, r, i) {
|
|
21
|
+
return new n(e, s, t, r, i);
|
|
25
22
|
}
|
|
26
23
|
get runtime() {
|
|
27
24
|
return this.owner.runtime;
|
|
@@ -59,23 +56,22 @@ class c {
|
|
|
59
56
|
}
|
|
60
57
|
/** @internal */
|
|
61
58
|
_disposeOwned() {
|
|
62
|
-
var s;
|
|
63
59
|
if (this._disposed)
|
|
64
60
|
return;
|
|
65
61
|
this._disposed = !0, this._releaseOwner = void 0;
|
|
66
62
|
const e = [];
|
|
67
63
|
try {
|
|
68
|
-
|
|
69
|
-
} catch (
|
|
70
|
-
e.push(
|
|
64
|
+
this._stop?.();
|
|
65
|
+
} catch (s) {
|
|
66
|
+
e.push(s);
|
|
71
67
|
}
|
|
72
68
|
this._stop = void 0, this._activationLeases = 0;
|
|
73
69
|
try {
|
|
74
70
|
this._release();
|
|
75
|
-
} catch (
|
|
76
|
-
e.push(
|
|
71
|
+
} catch (s) {
|
|
72
|
+
e.push(s);
|
|
77
73
|
}
|
|
78
|
-
if (this._start =
|
|
74
|
+
if (this._start = d, this._release = h, e.length === 1)
|
|
79
75
|
throw e[0];
|
|
80
76
|
if (e.length > 1)
|
|
81
77
|
throw new AggregateError(e, "[Raph] Meta source disposal failed.");
|
|
@@ -84,7 +80,7 @@ class c {
|
|
|
84
80
|
_activate() {
|
|
85
81
|
this._assertAlive(), this._activationLeases++;
|
|
86
82
|
try {
|
|
87
|
-
this._stop
|
|
83
|
+
this._stop ??= this._start();
|
|
88
84
|
} catch (s) {
|
|
89
85
|
throw this._activationLeases--, s;
|
|
90
86
|
}
|
|
@@ -93,20 +89,20 @@ class c {
|
|
|
93
89
|
if (!e || (e = !1, this._activationLeases !== 0 && this._activationLeases--, this._disposed || this._activationLeases !== 0))
|
|
94
90
|
return;
|
|
95
91
|
const s = this._stop;
|
|
96
|
-
this._stop = void 0, s
|
|
92
|
+
this._stop = void 0, s?.();
|
|
97
93
|
};
|
|
98
94
|
}
|
|
99
95
|
/** @internal */
|
|
100
96
|
_assertAlive() {
|
|
101
97
|
if (this._disposed || this.owner.disposed)
|
|
102
|
-
throw new
|
|
98
|
+
throw new c("[Raph] Meta source is disposed.");
|
|
103
99
|
}
|
|
104
100
|
}
|
|
105
|
-
function
|
|
101
|
+
function h() {
|
|
106
102
|
}
|
|
107
|
-
function
|
|
108
|
-
return
|
|
103
|
+
function d() {
|
|
104
|
+
return h;
|
|
109
105
|
}
|
|
110
106
|
export {
|
|
111
|
-
|
|
107
|
+
n as RaphMetaSource
|
|
112
108
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=32,a=32;class f{constructor(e,s,t,r){this.select=u(this),this._previousSource=void 0,this._trackedKey=void 0,this._owner=e,this._reactivity=s,this._source=t,this._equals=r,this._dense=[],this._denseBase=0,this._denseCount=0,this._triggers=void 0,this._scanning=!1,this._objectHooks=l(this,t),this._growthLimit=1,this._sweptAt=0,this._sweepStride=0,this._disposed=!1,this._tapSlot=-1,this._sweepSlot=-1,this._sweepDue=0,t._addWriteTap(this)}get[Symbol.toStringTag](){return"RaphSelector"}toJSON(){return{owner:this._owner.id,triggers:this._size(),disposed:this._disposed}}get _tapOwner(){return this._owner}_debugTriggerCount(){return this._size()}_test(e){const s=this._owner,t=this._reactivity;t._assertTrackedRead(s),s._assertAlive(),this._track(e,t);const r=this._source.peek(),i=this._equals;return i!==void 0?i(e,r):e===r||typeof e=="number"&&typeof r=="number"&&Object.is(e,r)}_observesWrites(){return this._size()!==0}_afterSourceWrite(e,s){if(this._size()===0)return;const t=this._reactivity,r=this._equals;if(r===void 0){if(Object.is(e,s))return;this._wakePair(e,s,t);return}let i;const n=this._scanning;this._scanning=!0;const o=this._dense;for(let _=0;_<o.length;_++){const d=o[_];if(d!==void 0){if(!t._signalNodeHasSubscribers(d)){o[_]=void 0,this._denseCount--;continue}i=this._wakeChanged(this._denseBase+_,d,e,s,r,i)}}const h=this._triggers;if(h!==void 0)for(const[_,d]of h){if(!t._signalNodeHasSubscribers(d)){h.delete(_);continue}i=this._wakeChanged(_,d,e,s,r,i)}if(this._scanning=n,this._settleDense(),i!==void 0)throw i.length===1?i[0]:new AggregateError(i,"[Raph] Selector notification failed.")}_afterOwnerDisposals(e){const s=this._size(),t=this._sweepStride,r=this._sweptAt+(t>s?t:s);if(e<r)return r;this._sweep(e);const i=this._size();if(i===0)return this._sweepStride=0,this._growthLimit=1,0;if(i!==s)return this._sweepStride=0,e+i;const n=(t>i?t:i)*2;return this._sweepStride=n,e+n}_edgeDetached(e){if(this._disposed)return;const s=this._triggers,t=s.get(e);t!==void 0&&this._reactivity._hasSingleSubscriber(t)&&s.delete(e)}_findConsumerOwner(e,s){const t=this._reactivity,r=this._dense;for(let n=0;n<r.length;n++){const o=r[n];if(o===void 0)continue;const h=t._findSubscriberOwner(o,e,s);if(h!==void 0)return h}const i=this._triggers;if(i!==void 0)for(const n of i.values()){const o=t._findSubscriberOwner(n,e,s);if(o!==void 0)return o}}_finalizeSource(){if(this._disposed)return!0;this._disposed=!0,this._equals=void 0,this._source._removeWriteTap(this),this._sweepSlot!==-1&&this._owner.runtime._removeDisposalSweeper(this);const e=this._reactivity;let s;const t=this._dense;for(let i=0;i<t.length;i++){const n=t[i];if(n!==void 0)try{e._releaseSignalNode(n)}catch(o){(s??=[]).push(o)}}t.length=0,this._denseCount=0;const r=this._triggers;if(r!==void 0){for(const i of r.values())try{e._releaseSignalNode(i)}catch(n){(s??=[]).push(n)}r.clear()}if(s!==void 0)throw s.length===1?s[0]:new AggregateError(s,"[Raph] Selector disposal failed.");return!0}_sweep(e=this._owner.runtime._ownerDisposalCount()){this._sweptAt=e;const s=this._size();if(s===0)return;const t=this._dense,r=this._triggers,i=this._reactivity,n=i._countObserved(t,r);if(n===s){t.length!==this._denseCount&&this._settleDense();return}if(n===0){t.length=0,this._denseCount=0,r!==void 0&&r.clear();return}this._denseCount=i._dropUnobserved(t,r),this._settleDense()}_size(){const e=this._triggers;return e===void 0?this._denseCount:this._denseCount+e.size}_track(e,s){if(typeof e=="number"){const n=this._dense,o=n.length;if(o===0){if(Number.isInteger(e)){this._trackDense(e,0,s);return}}else{const h=this._denseBase,_=e-h;if(_>=0&&_<=o&&_===(_|0)&&h+_===e){const d=_<o?n[_]:void 0;d!==void 0?s._readSignalNode(d):this._trackDense(e,_,s);return}}}const t=this._triggers,r=t===void 0?void 0:t.get(e);if(typeof e=="object"?e!==null:typeof e=="function"){this._trackObject(e,r,s);return}if(r!==void 0){s._readSignalNode(r);return}const i=s._trackCounterNode(this._source);i!==void 0&&(t===void 0?this._triggers=new Map().set(e,i):t.set(e,i),this._size()>=this._growthLimit&&this._grow())}_trackDense(e,s,t){const r=this._triggers;if(r!==void 0&&r.size!==0){const o=r.get(e);if(o!==void 0){t._readSignalNode(o);return}}const i=t._trackCounterNode(this._source);if(i===void 0)return;const n=this._dense;s===n.length?(s===0&&(this._denseBase=e+0),n.push(i)):n[s]=i,this._denseCount++,this._size()>=this._growthLimit&&this._grow()}_trackObject(e,s,t){if(this._trackedKey=e,s!==void 0)t._readSignalNode(s);else{const r=t._trackCounterNode(this._objectHooks);if(r!==void 0){const i=this._triggers;i===void 0?this._triggers=new Map().set(e,r):i.set(e,r),this._size()>=this._growthLimit&&this._grow()}}this._trackedKey=void 0}_grow(){const e=this._owner.runtime,s=e._ownerDisposalCount();this._sweep(s);const t=this._size();this._growthLimit=t*2>g?t*2:g,this._sweepSlot===-1&&(this._sweepStride=0,e._addDisposalSweeper(this,s+t))}_wakePair(e,s,t){let r=!1,i;const n=this._find(e);if(n!==void 0)try{this._bump(e,n,t)}catch(h){r=!0,i=h}const o=this._find(s);if(o!==void 0)try{this._bump(s,o,t)}catch(h){throw r?new AggregateError([i,h],"[Raph] Selector notification failed."):h}if(r)throw i}_bump(e,s,t){t._bumpSignalNode(s)||this._forget(e)}_wakeChanged(e,s,t,r,i,n){let o=!0;try{o=i(e,t)!==i(e,r)}catch(h){(n??=[]).push(h)}if(o)try{this._bump(e,s,this._reactivity)}catch(h){(n??=[]).push(h)}return n}_find(e){if(typeof e=="number"){const t=this._dense,r=this._denseBase,i=e-r;if(i>=0&&i<t.length&&i===(i|0)&&r+i===e)return t[i]}const s=this._triggers;return s===void 0?void 0:s.get(e)}_forget(e){if(typeof e=="number"){const t=this._dense,r=this._denseBase,i=e-r;if(i>=0&&i<t.length&&i===(i|0)&&r+i===e){if(t[i]!==void 0){t[i]=void 0;const n=--this._denseCount;(n===0||t.length>(n*2+a)*2)&&this._settleDense()}return}}const s=this._triggers;s!==void 0&&s.delete(e)}_settleDense(){if(this._scanning)return;const e=this._dense,s=this._denseCount;if(s===0){e.length=0;return}let t=e.length,r=0;for(;r<t&&e[r]===void 0;)r++;for(;t>r&&e[t-1]===void 0;)t--;if(t-r>s*2+a){const i=this._denseBase,n=this._triggers??=new Map;for(let o=r;o<t;o++){const h=e[o];h!==void 0&&n.set(i+o,h)}e.length=0,this._denseCount=0;return}r!==0&&(e.copyWithin(0,r,t),this._denseBase+=r),e.length=t-r}}function u(c){return e=>c._test(e)}function l(c,e){return{token:e,onDependency:()=>{const s=c._trackedKey;return()=>{c._edgeDetached(s)}}}}exports.RuntimeSelector=f;
|