@raphy-js/raph 1.0.1-dev.25 → 1.0.1-dev.54
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 +100 -0
- package/dist/api/Raph.d.ts +15 -15
- package/dist/api/RaphFacadeSession.d.ts +4 -4
- package/dist/api/RaphReactivityInstance.d.ts +4 -4
- package/dist/api/types.d.ts +11 -11
- package/dist/compact.cjs +1 -0
- package/dist/compact.js +4 -0
- package/dist/debug/reactivity/engine-core.cjs +1 -0
- package/dist/debug/reactivity/engine-core.js +1760 -0
- package/dist/debug/reactivity/engine.cjs +1 -1
- package/dist/debug/reactivity/engine.js +25 -1689
- package/dist/debug/reactivity/reactive-object.cjs +1 -1
- package/dist/debug/reactivity/reactive-object.js +604 -167
- package/dist/debug/runtime/RaphCompactExecutionRuntime.cjs +1 -0
- package/dist/debug/runtime/RaphCompactExecutionRuntime.js +9 -0
- package/dist/debug/runtime/RaphExecutionRuntime.cjs +1 -0
- package/dist/debug/runtime/RaphExecutionRuntime.js +11 -0
- package/dist/debug/runtime/RaphRuntime.cjs +1 -1
- package/dist/debug/runtime/RaphRuntime.js +115 -1176
- package/dist/debug/runtime/RaphRuntimeBase.cjs +1 -0
- package/dist/debug/runtime/RaphRuntimeBase.js +941 -0
- package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -1
- package/dist/debug/runtime/diagnostics/RaphDebug.js +72 -66
- package/dist/debug/runtime/ownership/RaphNode.cjs +1 -1
- package/dist/debug/runtime/ownership/RaphNode.js +11 -0
- package/dist/debug/runtime/ownership/RaphScope.cjs +1 -1
- package/dist/debug/runtime/ownership/RaphScope.js +12 -12
- package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -1
- package/dist/debug/runtime/phases/RaphPhasePipeline.js +361 -242
- package/dist/debug/runtime/phases/RaphPhaseTaskRecord.cjs +1 -1
- package/dist/debug/runtime/phases/RaphPhaseTaskRecord.js +23 -22
- package/dist/debug/runtime/reactivity/RaphSelector.cjs +1 -1
- package/dist/debug/runtime/reactivity/RaphSelector.js +111 -90
- package/dist/debug/runtime/reactivity/RuntimeObjectSupport.cjs +1 -0
- package/dist/debug/runtime/reactivity/RuntimeObjectSupport.js +11 -0
- package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -1
- package/dist/debug/runtime/reactivity/RuntimeReactivity.js +118 -103
- package/dist/debug/runtime/reactivity/RuntimeSelectorSupport.cjs +1 -0
- package/dist/debug/runtime/reactivity/RuntimeSelectorSupport.js +12 -0
- package/dist/entrypoints/compact.d.ts +2 -0
- package/dist/entrypoints/execution.d.ts +2 -0
- package/dist/entrypoints/machine-testing.d.ts +2 -2
- package/dist/entrypoints/machine.d.ts +5 -5
- package/dist/entrypoints/observable.d.ts +4 -0
- package/dist/entrypoints/path.d.ts +14 -14
- package/dist/entrypoints/reactivity.d.ts +1 -1
- package/dist/entrypoints/runtime.d.ts +19 -18
- package/dist/execution.cjs +1 -0
- package/dist/execution.js +4 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +23 -21
- package/dist/machine/compiler.d.ts +1 -1
- package/dist/machine/core.d.ts +2 -2
- package/dist/machine/persistence.d.ts +1 -1
- package/dist/machine/runtime.d.ts +3 -3
- package/dist/machine/testing.d.ts +1 -1
- package/dist/machine/types.d.ts +3 -3
- package/dist/main.d.ts +19 -19
- package/dist/observable/buffer.d.ts +6 -0
- package/dist/observable/class-admin.d.ts +63 -0
- package/dist/observable/class-plan.d.ts +46 -0
- package/dist/observable/classes.d.ts +10 -0
- package/dist/observable/context.d.ts +73 -0
- package/dist/observable/native.d.ts +2 -0
- package/dist/observable/observable.d.ts +13 -0
- package/dist/observable/types.d.ts +60 -0
- package/dist/observable.cjs +1 -0
- package/dist/observable.js +1187 -0
- package/dist/path/DataPath.d.ts +2 -2
- package/dist/path/PathRouter.d.ts +1 -1
- package/dist/path/RaphKernel.d.ts +6 -6
- package/dist/path/data-path.types.d.ts +1 -1
- package/dist/path/data-path.utils.d.ts +2 -2
- package/dist/path/derived/DerivedRegistry.d.ts +3 -3
- package/dist/path/derived/RaphDerivedHandle.d.ts +3 -3
- package/dist/path/derived/derived-collection.types.d.ts +1 -1
- package/dist/path/derived/derived-collection.utils.d.ts +3 -3
- package/dist/path/derived/derived-strategy.utils.d.ts +1 -1
- package/dist/path/meta/MetaController.d.ts +5 -5
- package/dist/path/meta/RaphMeta.d.ts +3 -3
- package/dist/path/meta/RaphMetaStore.d.ts +1 -1
- package/dist/path/meta/meta.types.d.ts +2 -2
- package/dist/path/path.types.d.ts +2 -2
- package/dist/path/pathSegmentKey.d.ts +1 -1
- package/dist/path/storage/AdapterPathStore.d.ts +2 -2
- package/dist/path/storage/DefaultDataAdapter.d.ts +2 -2
- package/dist/path/storage/PathEventHub.d.ts +1 -1
- package/dist/path/storage/PathStore.d.ts +2 -2
- package/dist/path/storage/data-adapter.types.d.ts +1 -1
- package/dist/raph.cjs +1 -1
- package/dist/raph.js +23 -21
- package/dist/reactivity/engine-core.d.ts +600 -0
- package/dist/reactivity/engine.d.ts +6 -550
- package/dist/reactivity/reactive-object.d.ts +143 -2
- package/dist/reactivity/scope.d.ts +7 -6
- package/dist/reactivity/types.d.ts +9 -12
- package/dist/reactivity/watch.d.ts +1 -1
- package/dist/runtime/RaphCompactExecutionRuntime.d.ts +7 -0
- package/dist/runtime/RaphExecutionRuntime.d.ts +6 -0
- package/dist/runtime/RaphRuntime.d.ts +19 -403
- package/dist/runtime/RaphRuntimeBase.d.ts +194 -0
- package/dist/runtime/diagnostics/RaphDebug.d.ts +8 -5
- package/dist/runtime/errors.d.ts +1 -1
- package/dist/runtime/ownership/RaphEffectScope.d.ts +13 -12
- package/dist/runtime/ownership/RaphNode.d.ts +28 -21
- package/dist/runtime/ownership/RaphScope.d.ts +32 -19
- package/dist/runtime/ownership/parent-graph.types.d.ts +1 -1
- package/dist/runtime/ownership/parentGraph.d.ts +2 -2
- package/dist/runtime/phases/RaphFrameLoop.d.ts +1 -1
- package/dist/runtime/phases/RaphPhasePipeline.d.ts +80 -29
- package/dist/runtime/phases/RaphPhaseTaskRecord.d.ts +21 -21
- package/dist/runtime/phases/RaphPhaseWatch.d.ts +3 -3
- package/dist/runtime/phases/orderPhaseTasks.d.ts +4 -2
- package/dist/runtime/phases/phase.types.d.ts +36 -35
- package/dist/runtime/reactivity/PathHandle.d.ts +5 -5
- package/dist/runtime/reactivity/RaphMetaSource.d.ts +7 -7
- package/dist/runtime/reactivity/RaphSelector.d.ts +27 -6
- package/dist/runtime/reactivity/RaphWorkGraph.d.ts +40 -39
- package/dist/runtime/reactivity/RuntimeObjectSupport.d.ts +9 -0
- package/dist/runtime/reactivity/RuntimeReactivity.d.ts +27 -19
- package/dist/runtime/reactivity/RuntimeSelectorSupport.d.ts +10 -0
- package/dist/runtime/reactivity/RuntimeWatch.d.ts +1 -1
- package/dist/runtime/reactivity/disposal-sweep.utils.d.ts +1 -1
- package/dist/runtime/reactivity/runtime-reactivity.types.d.ts +3 -3
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.js +13 -11
- package/package.json +22 -62
|
@@ -0,0 +1,1187 @@
|
|
|
1
|
+
import { REACTIVE_OBJECT_IDENTITY as ee, WRITE_NESTED as le, WRITE_CALLBACK as de, getReactiveObjectSupport as he, isPlainReactiveValue as U } from "./debug/reactivity/reactive-object.js";
|
|
2
|
+
const B = Symbol("size"), K = Symbol("time"), I = Symbol("params"), be = new Set(Object.getOwnPropertyNames(Date.prototype).filter((t) => t.startsWith("set"))), we = /* @__PURE__ */ new Set(["append", "delete", "set", "sort"]), ve = Object.freeze([]);
|
|
3
|
+
class $ {
|
|
4
|
+
_key;
|
|
5
|
+
_source;
|
|
6
|
+
_map;
|
|
7
|
+
get(e) {
|
|
8
|
+
if (this._source !== void 0 && j(e, this._key))
|
|
9
|
+
return this._source;
|
|
10
|
+
const r = this._map?.get(e);
|
|
11
|
+
return r !== void 0 && (this._key = e, this._source = r), r;
|
|
12
|
+
}
|
|
13
|
+
set(e, r) {
|
|
14
|
+
this._map !== void 0 ? this._map.set(e, r) : this._source !== void 0 && !j(e, this._key) && (this._map = /* @__PURE__ */ new Map([[this._key, this._source], [e, r]])), this._key = e, this._source = r;
|
|
15
|
+
}
|
|
16
|
+
delete(e) {
|
|
17
|
+
const r = this._source !== void 0 && j(e, this._key), n = this._map?.delete(e) ?? r;
|
|
18
|
+
return r && (this._key = void 0, this._source = void 0), this._map?.size === 0 && (this._map = void 0), n;
|
|
19
|
+
}
|
|
20
|
+
keys() {
|
|
21
|
+
return this._map?.keys() ?? (this._source === void 0 ? [] : [this._key]).values();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function j(t, e) {
|
|
25
|
+
return t === e || t !== t && e !== e;
|
|
26
|
+
}
|
|
27
|
+
function ye(t, e, r) {
|
|
28
|
+
const n = e instanceof Map ? "map" : e instanceof Set ? "set" : e instanceof WeakMap ? "weak-map" : e instanceof WeakSet ? "weak-set" : e instanceof Date ? "date" : e instanceof URL ? "url" : e instanceof URLSearchParams ? "params" : void 0;
|
|
29
|
+
if (n === void 0)
|
|
30
|
+
throw new TypeError("[Raph] Unsupported observable value; use makeObservable, an adapter, or observableBuffer.");
|
|
31
|
+
const o = {
|
|
32
|
+
raw: e,
|
|
33
|
+
context: t,
|
|
34
|
+
kind: n,
|
|
35
|
+
deep: r,
|
|
36
|
+
sources: /* @__PURE__ */ new Map(),
|
|
37
|
+
getDeps: new $(),
|
|
38
|
+
hasDeps: new $(),
|
|
39
|
+
sizeSource: void 0,
|
|
40
|
+
keysSource: void 0,
|
|
41
|
+
valuesSource: void 0,
|
|
42
|
+
methods: /* @__PURE__ */ Object.create(null),
|
|
43
|
+
view: void 0
|
|
44
|
+
}, s = new Proxy(e, {
|
|
45
|
+
get(i, a) {
|
|
46
|
+
if (a === ee)
|
|
47
|
+
return t.support.identity(e);
|
|
48
|
+
t.assertRead();
|
|
49
|
+
const c = o.methods[a];
|
|
50
|
+
return c === void 0 ? me(o, a) : c;
|
|
51
|
+
},
|
|
52
|
+
set(i, a, c) {
|
|
53
|
+
if (n !== "url")
|
|
54
|
+
throw new TypeError("[Raph] Observable native properties cannot be assigned; use their native methods.");
|
|
55
|
+
return oe(o, () => Reflect.set(e, a, c, e));
|
|
56
|
+
},
|
|
57
|
+
defineProperty() {
|
|
58
|
+
throw new TypeError("[Raph] Observable native properties cannot be redefined.");
|
|
59
|
+
},
|
|
60
|
+
deleteProperty() {
|
|
61
|
+
throw new TypeError("[Raph] Observable native properties cannot be deleted.");
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return o.view = s, t.registerNative(o), s;
|
|
65
|
+
}
|
|
66
|
+
function me(t, e) {
|
|
67
|
+
const { context: r, raw: n, kind: o, deep: s } = t;
|
|
68
|
+
if (e === "constructor")
|
|
69
|
+
return Reflect.get(n, e, n);
|
|
70
|
+
if (o === "url") {
|
|
71
|
+
if (e === "searchParams") {
|
|
72
|
+
const c = r.wrap(n.searchParams, s);
|
|
73
|
+
return r.native(n.searchParams).parent = new WeakRef(t), c;
|
|
74
|
+
}
|
|
75
|
+
r.track(t.sources, e);
|
|
76
|
+
}
|
|
77
|
+
e === "size" && (o === "map" || o === "set" ? z(t, "sizeSource") : r.track(t.sources, B));
|
|
78
|
+
const i = Reflect.get(n, e, n);
|
|
79
|
+
if (typeof i != "function")
|
|
80
|
+
return i;
|
|
81
|
+
const a = Oe(t, e) ?? ((...c) => ge(t, e, i, c));
|
|
82
|
+
return t.methods[e] = a, a;
|
|
83
|
+
}
|
|
84
|
+
function ge(t, e, r, n) {
|
|
85
|
+
const { context: o, raw: s, kind: i } = t;
|
|
86
|
+
return o.assertRead(), i === "date" ? typeof e == "string" && be.has(e) ? o.write(() => {
|
|
87
|
+
const a = s.getTime(), c = Reflect.apply(r, s, n);
|
|
88
|
+
return Object.is(a, s.getTime()) || o.notify(t.sources, K), c;
|
|
89
|
+
}) : (o.track(t.sources, K), Reflect.apply(r, s, n)) : i === "url" ? (o.track(t.sources, "href"), Reflect.apply(r, s, n)) : i === "params" ? Ee(t, e, r, n) : i === "weak-map" || i === "weak-set" ? Ae(t, e, r, n) : Reflect.apply(r, s, n);
|
|
90
|
+
}
|
|
91
|
+
function Oe(t, e) {
|
|
92
|
+
const { context: r, raw: n, kind: o } = t;
|
|
93
|
+
if (!(o !== "map" && o !== "set")) {
|
|
94
|
+
if (e === "get" && o === "map")
|
|
95
|
+
return (s) => (r.assertRead(), r.track(t.getDeps, s), r.wrapChild(n.get(s), t.deep));
|
|
96
|
+
if (e === "has")
|
|
97
|
+
return (s) => (r.assertRead(), r.track(t.hasDeps, s), n.has(s));
|
|
98
|
+
if (e === "set" && o === "map")
|
|
99
|
+
return (s, i) => {
|
|
100
|
+
r.assertRead(), r.unwrap(s);
|
|
101
|
+
const a = r.unwrap(i);
|
|
102
|
+
return P(t, Re, s, a);
|
|
103
|
+
};
|
|
104
|
+
if (e === "add" && o === "set")
|
|
105
|
+
return (s) => (r.assertRead(), r.unwrap(s), P(t, _e, s, void 0));
|
|
106
|
+
if (e === "delete")
|
|
107
|
+
return (s) => (r.assertRead(), P(t, Se, s, void 0));
|
|
108
|
+
if (e === "clear")
|
|
109
|
+
return () => (r.assertRead(), r.write(() => {
|
|
110
|
+
if (n.size === 0)
|
|
111
|
+
return;
|
|
112
|
+
const s = [.../* @__PURE__ */ new Set([...t.getDeps.keys(), ...t.hasDeps.keys()])].filter((i) => n.has(i));
|
|
113
|
+
n.clear();
|
|
114
|
+
for (const i of s)
|
|
115
|
+
r.notify(t.getDeps, i), r.notify(t.hasDeps, i);
|
|
116
|
+
re(t);
|
|
117
|
+
}));
|
|
118
|
+
if (e === "keys" || e === "values" || e === "entries" || e === Symbol.iterator)
|
|
119
|
+
return () => (r.assertRead(), z(t, e === "keys" ? "keysSource" : "valuesSource"), Te(t, e));
|
|
120
|
+
if (e === "forEach")
|
|
121
|
+
return (s, i) => {
|
|
122
|
+
if (r.assertRead(), typeof s != "function")
|
|
123
|
+
throw new TypeError("[Raph] forEach callback must be a function.");
|
|
124
|
+
z(t, "valuesSource"), n.forEach((a, c) => {
|
|
125
|
+
r.assertRead();
|
|
126
|
+
const u = o === "map" ? r.wrapChild(a, t.deep) : a;
|
|
127
|
+
Reflect.apply(s, i, [u, c, t.view]);
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function P(t, e, r, n) {
|
|
133
|
+
const o = t.context.support, s = o.openWrite();
|
|
134
|
+
if (s === le)
|
|
135
|
+
return e(t, r, n);
|
|
136
|
+
if (s === de)
|
|
137
|
+
return t.context.write(() => e(t, r, n));
|
|
138
|
+
let i;
|
|
139
|
+
try {
|
|
140
|
+
i = e(t, r, n);
|
|
141
|
+
} catch (a) {
|
|
142
|
+
throw o.failWrite(a);
|
|
143
|
+
}
|
|
144
|
+
return o.closeWrite(), i;
|
|
145
|
+
}
|
|
146
|
+
function Re(t, e, r) {
|
|
147
|
+
const { context: n, raw: o } = t, s = o.get(e), i = s !== void 0 || o.has(e);
|
|
148
|
+
return o.set(e, r), (!i || !Object.is(s, r)) && (n.notify(t.getDeps, e), y(t, t.valuesSource), i || (n.notify(t.hasDeps, e), y(t, t.sizeSource), y(t, t.keysSource))), t.view;
|
|
149
|
+
}
|
|
150
|
+
function _e(t, e, r) {
|
|
151
|
+
const { context: n, raw: o } = t, s = o.has(e);
|
|
152
|
+
return o.add(e), s || (y(t, t.valuesSource), n.notify(t.hasDeps, e), y(t, t.sizeSource), y(t, t.keysSource)), t.view;
|
|
153
|
+
}
|
|
154
|
+
function Se(t, e, r) {
|
|
155
|
+
const { context: n, raw: o } = t, s = o.delete(e);
|
|
156
|
+
return s && (n.notify(t.getDeps, e), n.notify(t.hasDeps, e), re(t)), s;
|
|
157
|
+
}
|
|
158
|
+
class te {
|
|
159
|
+
constructor(e, r) {
|
|
160
|
+
this._record = e, this._key = r;
|
|
161
|
+
}
|
|
162
|
+
_iterator;
|
|
163
|
+
next() {
|
|
164
|
+
const e = this._record;
|
|
165
|
+
if (e === void 0)
|
|
166
|
+
return { value: void 0, done: !0 };
|
|
167
|
+
try {
|
|
168
|
+
const r = this._iterator ??= Reflect.apply(e.raw[this._key], e.raw, ve);
|
|
169
|
+
e.context.assertRead();
|
|
170
|
+
const n = r.next();
|
|
171
|
+
return n.done ? (this._close(), { value: void 0, done: !0 }) : (e.kind === "map" && this._key !== "keys" && (this._key === "values" ? n.value = e.context.wrapChild(n.value, e.deep) : n.value[1] = e.context.wrapChild(n.value[1], e.deep)), n);
|
|
172
|
+
} catch (r) {
|
|
173
|
+
throw this._close(), r;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return(e) {
|
|
177
|
+
return this._close(), { value: e, done: !0 };
|
|
178
|
+
}
|
|
179
|
+
throw(e) {
|
|
180
|
+
throw this._close(), e;
|
|
181
|
+
}
|
|
182
|
+
[Symbol.iterator]() {
|
|
183
|
+
return this;
|
|
184
|
+
}
|
|
185
|
+
_close() {
|
|
186
|
+
this._record = void 0, this._iterator = void 0;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
Object.setPrototypeOf(te.prototype, Object.getPrototypeOf(Object.getPrototypeOf((function* () {
|
|
190
|
+
})())));
|
|
191
|
+
function Te(t, e) {
|
|
192
|
+
return new te(t, e);
|
|
193
|
+
}
|
|
194
|
+
function re(t) {
|
|
195
|
+
y(t, t.sizeSource), y(t, t.keysSource), y(t, t.valuesSource);
|
|
196
|
+
}
|
|
197
|
+
function y(t, e) {
|
|
198
|
+
e !== void 0 && t.context.support.bridge.trigger(e);
|
|
199
|
+
}
|
|
200
|
+
function z(t, e) {
|
|
201
|
+
const r = t.context.support.bridge;
|
|
202
|
+
if (!r.isTracking())
|
|
203
|
+
return;
|
|
204
|
+
let n = t[e];
|
|
205
|
+
n === void 0 && (n = r.createTransient(() => {
|
|
206
|
+
t[e] = void 0;
|
|
207
|
+
}), t[e] = n), r.track(n);
|
|
208
|
+
}
|
|
209
|
+
function ke(t, e, r) {
|
|
210
|
+
const { context: n } = t, o = n.support.bridge;
|
|
211
|
+
if (!o.isTracking() || typeof r != "object" && typeof r != "function" && typeof r != "symbol" || r === null || typeof r == "symbol" && Symbol.keyFor(r) !== void 0)
|
|
212
|
+
return;
|
|
213
|
+
let s = e.get(r);
|
|
214
|
+
if (s === void 0) {
|
|
215
|
+
const i = new WeakRef(r);
|
|
216
|
+
s = o.createTransient(() => {
|
|
217
|
+
const a = i.deref();
|
|
218
|
+
a !== void 0 && e.delete(a);
|
|
219
|
+
}), e.set(r, s);
|
|
220
|
+
}
|
|
221
|
+
o.track(s);
|
|
222
|
+
}
|
|
223
|
+
function Ae(t, e, r, n) {
|
|
224
|
+
const { context: o, raw: s } = t;
|
|
225
|
+
if (e === "get" || e === "has") {
|
|
226
|
+
ke(t, e === "get" ? t.weakGet ??= /* @__PURE__ */ new WeakMap() : t.weakHas ??= /* @__PURE__ */ new WeakMap(), n[0]);
|
|
227
|
+
const i = Reflect.apply(r, s, n);
|
|
228
|
+
return e === "get" ? o.wrapChild(i, t.deep) : i;
|
|
229
|
+
}
|
|
230
|
+
if (e === "set" || e === "add" || e === "delete") {
|
|
231
|
+
o.unwrap(n[0]);
|
|
232
|
+
const i = e === "set" ? o.unwrap(n[1]) : n[0];
|
|
233
|
+
return o.write(() => {
|
|
234
|
+
const a = s.has(n[0]), c = t.kind === "weak-map" ? s.get(n[0]) : n[0], u = Reflect.apply(r, s, e === "set" ? [n[0], i] : n);
|
|
235
|
+
if (e === "delete" ? u : !a || !Object.is(c, i)) {
|
|
236
|
+
const p = t.weakGet?.get(n[0]);
|
|
237
|
+
if (p !== void 0 && o.support.bridge.trigger(p), e === "delete" || !a) {
|
|
238
|
+
const l = t.weakHas?.get(n[0]);
|
|
239
|
+
l !== void 0 && o.support.bridge.trigger(l);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return e === "delete" ? u : t.view;
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
return Reflect.apply(r, s, n);
|
|
246
|
+
}
|
|
247
|
+
function ne(t) {
|
|
248
|
+
const e = /* @__PURE__ */ new Map();
|
|
249
|
+
for (const r of t.sources.keys())
|
|
250
|
+
e.set(r, r === B ? t.raw.size : r === I ? t.raw.toString() : JSON.stringify(t.raw.getAll(r)));
|
|
251
|
+
return e;
|
|
252
|
+
}
|
|
253
|
+
function se(t, e) {
|
|
254
|
+
for (const [r, n] of e) {
|
|
255
|
+
const o = r === B ? t.raw.size : r === I ? t.raw.toString() : JSON.stringify(t.raw.getAll(r));
|
|
256
|
+
n !== o && t.context.notify(t.sources, r);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
function Ee(t, e, r, n) {
|
|
260
|
+
const { context: o, raw: s } = t;
|
|
261
|
+
if (typeof e == "string" && we.has(e)) {
|
|
262
|
+
const a = t.parent?.deref();
|
|
263
|
+
return a !== void 0 ? oe(a, () => Reflect.apply(r, s, n)) : o.write(() => {
|
|
264
|
+
const c = ne(t), u = Reflect.apply(r, s, n);
|
|
265
|
+
return se(t, c), u;
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
if (o.track(t.sources, e === "get" || e === "getAll" || e === "has" ? String(n[0]) : I), e === "forEach") {
|
|
269
|
+
if (typeof n[0] != "function")
|
|
270
|
+
throw new TypeError("[Raph] forEach callback must be a function.");
|
|
271
|
+
return s.forEach((a, c) => {
|
|
272
|
+
o.assertRead(), Reflect.apply(n[0], n[1], [a, c, t.view]);
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
const i = Reflect.apply(r, s, n);
|
|
276
|
+
return e === "entries" || e === "keys" || e === "values" || e === Symbol.iterator ? je(o, i) : i;
|
|
277
|
+
}
|
|
278
|
+
function* je(t, e) {
|
|
279
|
+
for (; ; ) {
|
|
280
|
+
t.assertRead();
|
|
281
|
+
const r = e.next();
|
|
282
|
+
if (r.done)
|
|
283
|
+
return;
|
|
284
|
+
yield r.value;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
function oe(t, e) {
|
|
288
|
+
const { context: r, raw: n } = t;
|
|
289
|
+
return r.write(() => {
|
|
290
|
+
const o = /* @__PURE__ */ new Map();
|
|
291
|
+
for (const c of t.sources.keys())
|
|
292
|
+
o.set(c, Reflect.get(n, c, n));
|
|
293
|
+
const s = r.native(n.searchParams), i = s === void 0 ? void 0 : ne(s), a = e();
|
|
294
|
+
for (const [c, u] of o)
|
|
295
|
+
u !== Reflect.get(n, c, n) && r.notify(t.sources, c);
|
|
296
|
+
return s !== void 0 && i !== void 0 && se(s, i), a;
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
const C = /* @__PURE__ */ new WeakMap();
|
|
300
|
+
class Pe {
|
|
301
|
+
runtime;
|
|
302
|
+
support;
|
|
303
|
+
engine;
|
|
304
|
+
unwrap;
|
|
305
|
+
write;
|
|
306
|
+
/** Owner record engine для identity экземпляров class plan. */
|
|
307
|
+
identityContext;
|
|
308
|
+
// Native records; plain views хранятся в записи raw (серия Raph Top-1).
|
|
309
|
+
_views = /* @__PURE__ */ new WeakMap();
|
|
310
|
+
_members = /* @__PURE__ */ new WeakMap();
|
|
311
|
+
_classActions;
|
|
312
|
+
_finalizers = /* @__PURE__ */ new Set();
|
|
313
|
+
_disposed = !1;
|
|
314
|
+
constructor(e) {
|
|
315
|
+
this.runtime = e, this.engine = e._getReactivity(), e.reactive({}), this.support = he(this.engine), this.unwrap = this.support.unwrap, this.write = this.support.write, this.identityContext = this.support.identity(this).context, e.rootScope.own(() => this.dispose());
|
|
316
|
+
}
|
|
317
|
+
get disposed() {
|
|
318
|
+
return this._disposed;
|
|
319
|
+
}
|
|
320
|
+
/** Policy читается каждый раз: Runtime переключает её между быстрой и проверяющей. */
|
|
321
|
+
assertRead() {
|
|
322
|
+
this.support.policy.assertRead?.();
|
|
323
|
+
}
|
|
324
|
+
wrap(e, r = !0) {
|
|
325
|
+
if (this.assertRead(), e === null || typeof e != "object")
|
|
326
|
+
return e;
|
|
327
|
+
const n = this._members.get(e);
|
|
328
|
+
if (n !== void 0)
|
|
329
|
+
return Object.hasOwn(n, "view") ? n.view : e;
|
|
330
|
+
const o = this.support.observedView(e) ?? this._views.get(e);
|
|
331
|
+
if (o !== void 0) {
|
|
332
|
+
if (o.deep !== r)
|
|
333
|
+
throw new TypeError("[Raph] Observable depth is already fixed for this value.");
|
|
334
|
+
return o.view;
|
|
335
|
+
}
|
|
336
|
+
const s = this.support.unwrap(e), i = this._members.get(s);
|
|
337
|
+
if (i !== void 0)
|
|
338
|
+
return Object.hasOwn(i, "view") ? i.view : s;
|
|
339
|
+
if (U(s)) {
|
|
340
|
+
const c = this.support.wrap(s, this, r);
|
|
341
|
+
return this.support.observedView(s) === void 0 && this.support.setObservedView(s, c, r), c;
|
|
342
|
+
}
|
|
343
|
+
const a = this._views.get(s);
|
|
344
|
+
if (a !== void 0) {
|
|
345
|
+
if (a.deep !== r)
|
|
346
|
+
throw new TypeError("[Raph] Observable depth is already fixed for this value.");
|
|
347
|
+
return a.view;
|
|
348
|
+
}
|
|
349
|
+
return ye(this, s, r);
|
|
350
|
+
}
|
|
351
|
+
wrapChild(e, r) {
|
|
352
|
+
if (!r)
|
|
353
|
+
return this.support.unwrap(e), e;
|
|
354
|
+
if (e === null || typeof e != "object")
|
|
355
|
+
return e;
|
|
356
|
+
const n = this.support.observedView(e) ?? this._views.get(e);
|
|
357
|
+
if (n !== void 0) {
|
|
358
|
+
if (!n.deep)
|
|
359
|
+
throw new TypeError("[Raph] Observable depth is already fixed for this value.");
|
|
360
|
+
return n.view;
|
|
361
|
+
}
|
|
362
|
+
const o = this.support.unwrap(e);
|
|
363
|
+
return U(o) || this._members.has(o) || Me(o) ? this.wrap(o, !0) : e;
|
|
364
|
+
}
|
|
365
|
+
assertUnwrappedTarget(e) {
|
|
366
|
+
if (this.unwrap(e) !== e || this.support.hasView(e) || this.support.observedView(e) !== void 0 || this._views.has(e))
|
|
367
|
+
throw new TypeError("[Raph] Instrument the original value before observable wrapping.");
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Проверка цели для экземпляра класса с готовым планом. Proxy view создаётся только для plain
|
|
371
|
+
* objects и arrays, native view — только для native prototypes, поэтому достаточно identity.
|
|
372
|
+
*/
|
|
373
|
+
assertUnwrappedClassTarget(e) {
|
|
374
|
+
if (this.unwrap(e) !== e)
|
|
375
|
+
throw new TypeError("[Raph] Instrument the original value before observable wrapping.");
|
|
376
|
+
}
|
|
377
|
+
registerAdapterView(e, r) {
|
|
378
|
+
e === null || typeof e != "object" || this.unwrap(e) !== e || this._members.has(e) || (this.assertUnwrappedTarget(e), this.registerMember(e, r));
|
|
379
|
+
}
|
|
380
|
+
readValue(e, r) {
|
|
381
|
+
return this.wrapChild(e, r);
|
|
382
|
+
}
|
|
383
|
+
registerNative(e) {
|
|
384
|
+
this.support.claim(e.raw), this._views.set(e.raw, e);
|
|
385
|
+
}
|
|
386
|
+
native(e) {
|
|
387
|
+
const r = this._views.get(e);
|
|
388
|
+
return r !== void 0 && "raw" in r ? r : void 0;
|
|
389
|
+
}
|
|
390
|
+
member(e) {
|
|
391
|
+
return this._members.get(e);
|
|
392
|
+
}
|
|
393
|
+
registerMember(e, r) {
|
|
394
|
+
this.support.claim(e), this._members.set(e, r);
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Регистрирует admin class plan без глобального rawOwners: владение публикует сам экземпляр
|
|
398
|
+
* через identity record. Read boundary проверяется так же, как в claim.
|
|
399
|
+
*/
|
|
400
|
+
registerClassAdmin(e, r) {
|
|
401
|
+
this.assertRead(), this._members.set(e, r);
|
|
402
|
+
}
|
|
403
|
+
classAction(e, r) {
|
|
404
|
+
const n = this._classActions ??= /* @__PURE__ */ new WeakMap(), o = String(e), s = n.get(r);
|
|
405
|
+
if (s?.name === o)
|
|
406
|
+
return s.invoke;
|
|
407
|
+
if (!o.trim())
|
|
408
|
+
throw new Error("[Raph] Action name must not be empty.");
|
|
409
|
+
const i = (a, c, u) => this.runtime._invokeAction(o, this.runtime.rootScope, a, u, c);
|
|
410
|
+
return n.set(r, { name: o, invoke: i }), i;
|
|
411
|
+
}
|
|
412
|
+
track(e, r, n) {
|
|
413
|
+
const o = this.support.bridge;
|
|
414
|
+
if (!o.isTracking())
|
|
415
|
+
return;
|
|
416
|
+
let s = e.get(r);
|
|
417
|
+
s === void 0 && (s = o.createTransient(() => {
|
|
418
|
+
e.delete(r), n?.();
|
|
419
|
+
}), e.set(r, s)), o.track(s);
|
|
420
|
+
}
|
|
421
|
+
notify(e, r) {
|
|
422
|
+
const n = e.get(r);
|
|
423
|
+
n !== void 0 && this.support.bridge.trigger(n);
|
|
424
|
+
}
|
|
425
|
+
retainFinalizer(e) {
|
|
426
|
+
const r = new WeakRef(e);
|
|
427
|
+
if (this._finalizers.add(r), this._finalizers.size % 128 === 0)
|
|
428
|
+
for (const n of this._finalizers)
|
|
429
|
+
n.deref() === void 0 && this._finalizers.delete(n);
|
|
430
|
+
}
|
|
431
|
+
computed(e) {
|
|
432
|
+
let r, n;
|
|
433
|
+
const o = () => (this.assertRead(), r === void 0 && !this.engine._isTracking() ? e() : (n === void 0 && (n = { dispose: () => {
|
|
434
|
+
const s = r;
|
|
435
|
+
r = void 0, s?.dispose();
|
|
436
|
+
} }, this.retainFinalizer(n)), r ??= this.engine._ownedComputed(
|
|
437
|
+
() => this.engine.runWithOwner(this.engine._lifecycle, this.runtime.rootScope, e),
|
|
438
|
+
{
|
|
439
|
+
dependencyOwner: this.runtime.rootScope,
|
|
440
|
+
onDependency: () => () => {
|
|
441
|
+
r !== void 0 && !this.support.bridge.hasMultipleSubscribers(r.source) && n.dispose();
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
), r.source.get()));
|
|
445
|
+
return { get: o, peek: () => this.runtime.untracked(o) };
|
|
446
|
+
}
|
|
447
|
+
adapterContext() {
|
|
448
|
+
const e = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set();
|
|
449
|
+
let o;
|
|
450
|
+
const s = {
|
|
451
|
+
active: !0,
|
|
452
|
+
dispose: () => {
|
|
453
|
+
if (!s.active)
|
|
454
|
+
return;
|
|
455
|
+
s.active = !1, o?.();
|
|
456
|
+
const a = [];
|
|
457
|
+
for (const c of r.values()) {
|
|
458
|
+
const u = c.stop;
|
|
459
|
+
c.stop = void 0, c.count = 0;
|
|
460
|
+
try {
|
|
461
|
+
u?.();
|
|
462
|
+
} catch (d) {
|
|
463
|
+
a.push(d);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
for (const c of e.values())
|
|
467
|
+
try {
|
|
468
|
+
this.support.bridge.release(c);
|
|
469
|
+
} catch (u) {
|
|
470
|
+
a.push(u);
|
|
471
|
+
}
|
|
472
|
+
e.clear(), r.clear();
|
|
473
|
+
for (const c of n)
|
|
474
|
+
try {
|
|
475
|
+
c();
|
|
476
|
+
} catch (u) {
|
|
477
|
+
a.push(u);
|
|
478
|
+
}
|
|
479
|
+
if (n.clear(), a.length > 0)
|
|
480
|
+
throw new AggregateError(a, "[Raph] Observable adapter cleanup failed.");
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
return this.retainFinalizer(s), { context: {
|
|
484
|
+
track: (a) => {
|
|
485
|
+
if (!s.active)
|
|
486
|
+
throw this.assertRead(), new Error("[Raph] Adapter is disposed.");
|
|
487
|
+
this.assertRead();
|
|
488
|
+
const c = this.support.bridge;
|
|
489
|
+
if (!c.isTracking())
|
|
490
|
+
return;
|
|
491
|
+
let u = e.get(a);
|
|
492
|
+
u === void 0 && (u = c.create({
|
|
493
|
+
onDependency: () => {
|
|
494
|
+
const d = r.get(a);
|
|
495
|
+
if (d !== void 0 && d.count++ === 0)
|
|
496
|
+
try {
|
|
497
|
+
d.stop = d.subscribe() ?? void 0;
|
|
498
|
+
} catch (p) {
|
|
499
|
+
throw --d.count, p;
|
|
500
|
+
}
|
|
501
|
+
return () => {
|
|
502
|
+
if (c.hasMultipleSubscribers(u) || e.delete(a), d !== void 0 && d.count > 0 && --d.count === 0) {
|
|
503
|
+
const p = d.stop;
|
|
504
|
+
d.stop = void 0, p?.();
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
}), e.set(a, u)), c.track(u);
|
|
509
|
+
},
|
|
510
|
+
notify: (a) => {
|
|
511
|
+
if (!s.active)
|
|
512
|
+
throw this.assertRead(), new Error("[Raph] Adapter is disposed.");
|
|
513
|
+
this.assertRead();
|
|
514
|
+
const c = () => this.support.bridge.batch(() => this.notify(e, a));
|
|
515
|
+
this.support.policy.runWrite === void 0 ? c() : this.support.policy.runWrite(c);
|
|
516
|
+
},
|
|
517
|
+
mutate: (a, c) => {
|
|
518
|
+
if (!s.active)
|
|
519
|
+
throw this.assertRead(), new Error("[Raph] Adapter is disposed.");
|
|
520
|
+
return this.write(() => {
|
|
521
|
+
try {
|
|
522
|
+
return c();
|
|
523
|
+
} finally {
|
|
524
|
+
this.notify(e, a);
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
},
|
|
528
|
+
onObserved: (a, c) => {
|
|
529
|
+
if (!s.active)
|
|
530
|
+
throw this.assertRead(), new Error("[Raph] Adapter is disposed.");
|
|
531
|
+
if (this.assertRead(), e.has(a) || r.has(a))
|
|
532
|
+
throw new TypeError("[Raph] onObserved must be registered before the first tracked read.");
|
|
533
|
+
if (typeof c != "function")
|
|
534
|
+
throw new TypeError("[Raph] subscribe must be a function.");
|
|
535
|
+
r.set(a, { subscribe: c, count: 0 });
|
|
536
|
+
},
|
|
537
|
+
onDispose: (a) => {
|
|
538
|
+
if (!s.active)
|
|
539
|
+
throw this.assertRead(), new Error("[Raph] Adapter is disposed.");
|
|
540
|
+
if (this.assertRead(), typeof a != "function")
|
|
541
|
+
throw new TypeError("[Raph] cleanup must be a function.");
|
|
542
|
+
n.add(a), o ??= this.runtime.rootScope.own(s.dispose);
|
|
543
|
+
}
|
|
544
|
+
}, dispose: s.dispose };
|
|
545
|
+
}
|
|
546
|
+
dispose() {
|
|
547
|
+
if (this._disposed)
|
|
548
|
+
return;
|
|
549
|
+
this._disposed = !0, C.delete(this.runtime), this._classActions = void 0;
|
|
550
|
+
const e = [];
|
|
551
|
+
for (const r of this._finalizers)
|
|
552
|
+
try {
|
|
553
|
+
r.deref()?.dispose();
|
|
554
|
+
} catch (n) {
|
|
555
|
+
e.push(n);
|
|
556
|
+
}
|
|
557
|
+
if (this._finalizers.clear(), e.length > 0)
|
|
558
|
+
throw new AggregateError(e, "[Raph] Observable cleanup failed.");
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
function V(t) {
|
|
562
|
+
t.rootScope._assertAlive();
|
|
563
|
+
let e = C.get(t);
|
|
564
|
+
return e === void 0 && (e = new Pe(t), C.set(t, e)), e;
|
|
565
|
+
}
|
|
566
|
+
const ie = /* @__PURE__ */ new Set([
|
|
567
|
+
Map.prototype,
|
|
568
|
+
Set.prototype,
|
|
569
|
+
WeakMap.prototype,
|
|
570
|
+
WeakSet.prototype,
|
|
571
|
+
Date.prototype,
|
|
572
|
+
URL.prototype,
|
|
573
|
+
URLSearchParams.prototype
|
|
574
|
+
]);
|
|
575
|
+
function Me(t) {
|
|
576
|
+
for (let e = Object.getPrototypeOf(t); e !== null && e !== Object.prototype; e = Object.getPrototypeOf(e))
|
|
577
|
+
if (ie.has(e))
|
|
578
|
+
return !0;
|
|
579
|
+
return !1;
|
|
580
|
+
}
|
|
581
|
+
const xe = /* @__PURE__ */ new Set([
|
|
582
|
+
...ie,
|
|
583
|
+
ArrayBuffer.prototype,
|
|
584
|
+
...typeof SharedArrayBuffer > "u" ? [] : [SharedArrayBuffer.prototype]
|
|
585
|
+
]);
|
|
586
|
+
function De(t) {
|
|
587
|
+
for (let e = Object.getPrototypeOf(t); e !== null && e !== Object.prototype; e = Object.getPrototypeOf(e))
|
|
588
|
+
if (xe.has(e))
|
|
589
|
+
return !0;
|
|
590
|
+
return ArrayBuffer.isView(t);
|
|
591
|
+
}
|
|
592
|
+
const G = /* @__PURE__ */ new WeakMap();
|
|
593
|
+
function Xe(t, e) {
|
|
594
|
+
const r = V(t), n = ArrayBuffer.isView(e);
|
|
595
|
+
if (!n && !(e instanceof ArrayBuffer) && !(typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer))
|
|
596
|
+
throw new TypeError("[Raph] observableBuffer requires ArrayBuffer, SharedArrayBuffer, TypedArray or DataView.");
|
|
597
|
+
const o = n ? e.buffer : e;
|
|
598
|
+
r.support.claim(o), r.support.claim(e);
|
|
599
|
+
let s = G.get(r);
|
|
600
|
+
s === void 0 && G.set(r, s = /* @__PURE__ */ new WeakMap());
|
|
601
|
+
let i = s.get(o);
|
|
602
|
+
i === void 0 && (i = { context: r, ranges: /* @__PURE__ */ new Map() }, s.set(o, i));
|
|
603
|
+
const a = i, c = n ? e.byteOffset : 0;
|
|
604
|
+
function u(p) {
|
|
605
|
+
r.assertRead();
|
|
606
|
+
let l = e.byteLength;
|
|
607
|
+
if (l === 0 && o.byteLength === 0 && (l = new Uint8Array(o, 0, 0).byteLength), !Number.isSafeInteger(p.offset) || !Number.isSafeInteger(p.length) || p.offset < 0 || p.length < 0 || p.offset + p.length > l)
|
|
608
|
+
throw new RangeError("[Raph] Observable buffer range is outside the native view.");
|
|
609
|
+
return { start: c + p.offset, end: c + p.offset + p.length };
|
|
610
|
+
}
|
|
611
|
+
function d(p, l) {
|
|
612
|
+
for (const [h, f] of a.ranges) {
|
|
613
|
+
if (f.sources.size === 0) {
|
|
614
|
+
a.ranges.delete(h);
|
|
615
|
+
continue;
|
|
616
|
+
}
|
|
617
|
+
p < f.end && f.start < l && r.notify(f.sources, h);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
return {
|
|
621
|
+
get value() {
|
|
622
|
+
return r.assertRead(), e;
|
|
623
|
+
},
|
|
624
|
+
read(p, l) {
|
|
625
|
+
const { start: h, end: f } = u(p);
|
|
626
|
+
if (h !== f && r.engine._isTracking()) {
|
|
627
|
+
const w = `${h}:${f}`;
|
|
628
|
+
let b = a.ranges.get(w);
|
|
629
|
+
b === void 0 && a.ranges.set(w, b = { start: h, end: f, sources: /* @__PURE__ */ new Map() }), r.track(b.sources, w, () => a.ranges.delete(w));
|
|
630
|
+
}
|
|
631
|
+
return Y(l(e));
|
|
632
|
+
},
|
|
633
|
+
mutate(p, l) {
|
|
634
|
+
const { start: h, end: f } = u(p);
|
|
635
|
+
return r.write(() => {
|
|
636
|
+
try {
|
|
637
|
+
return Y(l(e));
|
|
638
|
+
} finally {
|
|
639
|
+
d(h, f);
|
|
640
|
+
}
|
|
641
|
+
});
|
|
642
|
+
},
|
|
643
|
+
notify(p) {
|
|
644
|
+
const { start: l, end: h } = u(p), f = () => r.support.bridge.batch(() => d(l, h));
|
|
645
|
+
r.support.policy.runWrite === void 0 ? f() : r.support.policy.runWrite(f);
|
|
646
|
+
}
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
function Y(t) {
|
|
650
|
+
if (t !== null && (typeof t == "object" || typeof t == "function") && typeof t.then == "function")
|
|
651
|
+
throw new TypeError("[Raph] Observable buffer callbacks must be synchronous.");
|
|
652
|
+
return t;
|
|
653
|
+
}
|
|
654
|
+
const m = ee, g = Object.freeze([]);
|
|
655
|
+
class L {
|
|
656
|
+
/** Кольцо членов строится лениво, только для повторной разметки. */
|
|
657
|
+
members = void 0;
|
|
658
|
+
options;
|
|
659
|
+
/** Identity contract engine: владелец и исходный объект. */
|
|
660
|
+
context;
|
|
661
|
+
raw;
|
|
662
|
+
observable;
|
|
663
|
+
plan;
|
|
664
|
+
/** Число полей плана, уже установленных на экземпляре (префикс `plan.fields`). */
|
|
665
|
+
fields = 0;
|
|
666
|
+
materialized = !1;
|
|
667
|
+
attached = !1;
|
|
668
|
+
/** Ленивые computed sources по slot плана. */
|
|
669
|
+
computed = void 0;
|
|
670
|
+
/** Значения полей плана по индексу `plan.fields`; общие accessors читают их через receiver. */
|
|
671
|
+
values;
|
|
672
|
+
/** Ленивые property sources полей по тому же индексу. */
|
|
673
|
+
sources = void 0;
|
|
674
|
+
constructor(e, r, n, o, s) {
|
|
675
|
+
this.context = e.identityContext, this.raw = r, this.observable = e, this.plan = n, this.options = o, this.values = s;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
function S(t) {
|
|
679
|
+
if (t === null || typeof t != "object")
|
|
680
|
+
return;
|
|
681
|
+
const e = t[m];
|
|
682
|
+
return e instanceof L && e.raw === t ? e : void 0;
|
|
683
|
+
}
|
|
684
|
+
const M = { value: void 0, writable: !1, enumerable: !1, configurable: !0 };
|
|
685
|
+
function ae(t) {
|
|
686
|
+
if (!t.attached) {
|
|
687
|
+
M.value = t;
|
|
688
|
+
try {
|
|
689
|
+
Object.defineProperty(t.raw, m, M);
|
|
690
|
+
} finally {
|
|
691
|
+
M.value = void 0;
|
|
692
|
+
}
|
|
693
|
+
t.attached = !0;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
function W(t, e) {
|
|
697
|
+
const r = t.members;
|
|
698
|
+
e.next = r === void 0 ? e : r.next, r !== void 0 && (r.next = e), t.members = e;
|
|
699
|
+
}
|
|
700
|
+
const T = /* @__PURE__ */ new WeakMap(), F = Symbol("raph.observable.plan"), N = F, x = { value: void 0, writable: !0, enumerable: !1, configurable: !0 }, D = /* @__PURE__ */ new WeakMap(), ze = Object.prototype.__lookupGetter__;
|
|
701
|
+
function q(t) {
|
|
702
|
+
const e = t[N], r = e !== void 0 && e.prototype === t ? e : T.get(t);
|
|
703
|
+
if (r == null)
|
|
704
|
+
return r;
|
|
705
|
+
const n = r.members;
|
|
706
|
+
for (let o = 0; o < n.length; o++) {
|
|
707
|
+
const s = n[o];
|
|
708
|
+
if ((s.kind === "method" ? t[s.key] : ze.call(t, s.key)) !== (s.kind === "method" ? s.wrapper : s.installed.get))
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
return r;
|
|
712
|
+
}
|
|
713
|
+
function Ce(t, e) {
|
|
714
|
+
const r = T.get(t);
|
|
715
|
+
if (r === null)
|
|
716
|
+
return;
|
|
717
|
+
const n = [];
|
|
718
|
+
for (const c of Reflect.ownKeys(e)) {
|
|
719
|
+
if (c === m)
|
|
720
|
+
continue;
|
|
721
|
+
const u = Object.getOwnPropertyDescriptor(e, c);
|
|
722
|
+
if (u === void 0 || !("value" in u) || u.writable !== !0 || u.configurable !== !0 || u.enumerable !== !0)
|
|
723
|
+
return;
|
|
724
|
+
n.push(c);
|
|
725
|
+
}
|
|
726
|
+
const o = [], s = [];
|
|
727
|
+
let i = r?.slots ?? 0;
|
|
728
|
+
for (const c of Reflect.ownKeys(t)) {
|
|
729
|
+
if (c === "constructor" || c === m || c === N || n.includes(c))
|
|
730
|
+
continue;
|
|
731
|
+
const u = Object.getOwnPropertyDescriptor(t, c), d = String(c);
|
|
732
|
+
if (u.configurable !== !0 || !d.trim())
|
|
733
|
+
return J(t);
|
|
734
|
+
if (u.get !== void 0) {
|
|
735
|
+
const p = D.get(u.get);
|
|
736
|
+
if (p?.kind === "computed" && p.key === c && p.installed.set === u.set) {
|
|
737
|
+
o.push(p);
|
|
738
|
+
continue;
|
|
739
|
+
}
|
|
740
|
+
const l = Le(c, d, u, i++);
|
|
741
|
+
o.push(l), s.push({ member: l, installed: l.installed });
|
|
742
|
+
} else if (u.set === void 0 && typeof u.value == "function") {
|
|
743
|
+
const p = D.get(u.value);
|
|
744
|
+
if (p?.kind === "method" && p.key === c) {
|
|
745
|
+
o.push(p);
|
|
746
|
+
continue;
|
|
747
|
+
}
|
|
748
|
+
const l = Ue(c, d, u.value);
|
|
749
|
+
o.push(l), s.push({ member: l, installed: { configurable: !0, enumerable: u.enumerable ?? !1, writable: u.writable ?? !0, value: l.wrapper } });
|
|
750
|
+
} else
|
|
751
|
+
return J(t);
|
|
752
|
+
}
|
|
753
|
+
try {
|
|
754
|
+
for (const { member: c, installed: u } of s)
|
|
755
|
+
Object.defineProperty(t, c.key, u), D.set(c.kind === "method" ? c.wrapper : c.installed.get, c);
|
|
756
|
+
} catch {
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
const a = { prototype: t, fields: n, fieldDescriptors: n.map(We), members: o, slots: i };
|
|
760
|
+
T.set(t, a), x.value = a;
|
|
761
|
+
try {
|
|
762
|
+
Object.defineProperty(t, N, x);
|
|
763
|
+
} catch {
|
|
764
|
+
} finally {
|
|
765
|
+
x.value = void 0;
|
|
766
|
+
}
|
|
767
|
+
return a;
|
|
768
|
+
}
|
|
769
|
+
function We(t, e) {
|
|
770
|
+
return {
|
|
771
|
+
configurable: !0,
|
|
772
|
+
enumerable: !0,
|
|
773
|
+
get() {
|
|
774
|
+
return Ne(H(this, t), e);
|
|
775
|
+
},
|
|
776
|
+
set(r) {
|
|
777
|
+
Ie(H(this, t), e, r);
|
|
778
|
+
}
|
|
779
|
+
};
|
|
780
|
+
}
|
|
781
|
+
function H(t, e) {
|
|
782
|
+
const r = S(t);
|
|
783
|
+
if (r === void 0)
|
|
784
|
+
throw new TypeError(`[Raph] Observable field accessor requires its annotated instance: ${String(e)}`);
|
|
785
|
+
return r;
|
|
786
|
+
}
|
|
787
|
+
function Ne(t, e) {
|
|
788
|
+
const r = t.observable;
|
|
789
|
+
r.assertRead();
|
|
790
|
+
const n = r.support.bridge, o = t.sources, s = o === void 0 ? void 0 : o[e];
|
|
791
|
+
s !== void 0 ? n.track(s) : n.isTracking() && Be(t, e, n);
|
|
792
|
+
const i = t.values[e];
|
|
793
|
+
return i === null || typeof i != "object" ? i : t.options.deep ? r.wrapChild(i, !0) : r.wrap(i, !1);
|
|
794
|
+
}
|
|
795
|
+
function Be(t, e, r) {
|
|
796
|
+
const n = r.createTransient(() => {
|
|
797
|
+
const o = t.sources;
|
|
798
|
+
o !== void 0 && o[e] === n && (o[e] = void 0);
|
|
799
|
+
});
|
|
800
|
+
(t.sources ??= [])[e] = n, r.track(n);
|
|
801
|
+
}
|
|
802
|
+
function Ie(t, e, r) {
|
|
803
|
+
const n = t.observable;
|
|
804
|
+
if (n.support.tryDirectWrite()) {
|
|
805
|
+
ce(t, e, n.unwrap(r));
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
Ve(t, e, r);
|
|
809
|
+
}
|
|
810
|
+
function Ve(t, e, r) {
|
|
811
|
+
const n = t.observable;
|
|
812
|
+
n.write(() => {
|
|
813
|
+
ce(t, e, n.unwrap(r));
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
function ce(t, e, r) {
|
|
817
|
+
const n = t.values;
|
|
818
|
+
if (Object.is(r, n[e]))
|
|
819
|
+
return;
|
|
820
|
+
n[e] = r;
|
|
821
|
+
const o = t.sources, s = o === void 0 ? void 0 : o[e];
|
|
822
|
+
s !== void 0 && t.observable.support.bridge.trigger(s);
|
|
823
|
+
}
|
|
824
|
+
function J(t) {
|
|
825
|
+
T.set(t, null);
|
|
826
|
+
}
|
|
827
|
+
function Le(t, e, r, n) {
|
|
828
|
+
const o = r.get, s = r.set, i = { configurable: !0, enumerable: r.enumerable ?? !1 }, a = { kind: "computed", key: t, getter: o, setter: s, slot: n, installed: i };
|
|
829
|
+
return i.get = function() {
|
|
830
|
+
const c = S(this);
|
|
831
|
+
return c === void 0 ? Reflect.apply(o, this, g) : Fe(c, a);
|
|
832
|
+
}, s !== void 0 && (i.set = function(c) {
|
|
833
|
+
const u = S(this);
|
|
834
|
+
if (u === void 0) {
|
|
835
|
+
Reflect.apply(s, this, [c]);
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
838
|
+
const d = u.observable.runtime;
|
|
839
|
+
d._invokeAction(e, d.rootScope, s, [c], u.raw);
|
|
840
|
+
}), a;
|
|
841
|
+
}
|
|
842
|
+
function Fe(t, e) {
|
|
843
|
+
const r = t.computed, n = r === void 0 ? void 0 : r[e.slot];
|
|
844
|
+
if (n !== void 0)
|
|
845
|
+
return n.get();
|
|
846
|
+
const o = t.observable;
|
|
847
|
+
o.assertRead();
|
|
848
|
+
const s = t.raw;
|
|
849
|
+
if (!o.engine._isTracking())
|
|
850
|
+
return Reflect.apply(e.getter, s, g);
|
|
851
|
+
const i = o.computed(Function.prototype.bind.call(e.getter, s));
|
|
852
|
+
return (t.computed ??= [])[e.slot] = i, i.get();
|
|
853
|
+
}
|
|
854
|
+
function Ue(t, e, r) {
|
|
855
|
+
return { kind: "method", key: t, original: r, wrapper: function() {
|
|
856
|
+
const o = arguments.length === 0 ? g : arguments, s = S(this);
|
|
857
|
+
if (s === void 0)
|
|
858
|
+
return Reflect.apply(r, this, o);
|
|
859
|
+
const i = s.observable;
|
|
860
|
+
if (i.assertRead(), i.engine._isTracking())
|
|
861
|
+
return Reflect.apply(r, this, o);
|
|
862
|
+
const a = i.runtime;
|
|
863
|
+
return a._invokeAction(e, a.rootScope, r, o, this);
|
|
864
|
+
} };
|
|
865
|
+
}
|
|
866
|
+
function Ke(t) {
|
|
867
|
+
if (t.materialized)
|
|
868
|
+
return;
|
|
869
|
+
t.materialized = !0;
|
|
870
|
+
const { plan: e, raw: r, options: n } = t;
|
|
871
|
+
for (let o = 0; o < t.fields; o++) {
|
|
872
|
+
const s = e.fields[o], i = Object.getOwnPropertyDescriptor(r, s), a = i !== void 0 && "value" in i;
|
|
873
|
+
W(t, { key: s, annotation: a ? "autoAction" : n.deep ? "observable" : "shallow", inherited: !1 });
|
|
874
|
+
}
|
|
875
|
+
for (const o of e.members)
|
|
876
|
+
W(t, o.kind === "computed" ? { key: o.key, annotation: "computed", inherited: !0, descriptor: o.installed, shared: !0 } : { key: o.key, annotation: "autoAction", inherited: !0, shared: !0 });
|
|
877
|
+
ae(t);
|
|
878
|
+
}
|
|
879
|
+
const k = Object.freeze({ deep: !0, autoBind: !1 }), _ = Object.freeze({});
|
|
880
|
+
function et(t, e, r, n = k) {
|
|
881
|
+
return ue(t, e, r, n, !1);
|
|
882
|
+
}
|
|
883
|
+
function tt(t, e, r = _, n = k) {
|
|
884
|
+
return ue(t, e, r, n, !0);
|
|
885
|
+
}
|
|
886
|
+
function ue(t, e, r, n, o) {
|
|
887
|
+
const s = V(t);
|
|
888
|
+
if (e === null || typeof e != "object" || Array.isArray(e))
|
|
889
|
+
throw new TypeError("[Raph] makeObservable requires an initialized object or class instance.");
|
|
890
|
+
if (o && r === _ && n.autoBind !== !0) {
|
|
891
|
+
const f = Object.getPrototypeOf(e), w = f !== null && f !== Object.prototype ? q(f) : void 0;
|
|
892
|
+
if (w != null && (s.assertUnwrappedClassTarget(e), s.member(e) === void 0)) {
|
|
893
|
+
const b = Q(s, e, w, Z(n));
|
|
894
|
+
if (b !== void 0)
|
|
895
|
+
return b;
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
if (s.assertUnwrappedTarget(e), De(e))
|
|
899
|
+
throw new TypeError("[Raph] Native values use observable or observableBuffer, not class annotations.");
|
|
900
|
+
const i = Z(n), a = s.member(e);
|
|
901
|
+
if (a instanceof L && Ke(a), a !== void 0 && !Object.hasOwn(a, "members"))
|
|
902
|
+
throw new TypeError("[Raph] Target already uses a custom observable adapter.");
|
|
903
|
+
if (a !== void 0 && (a.options.deep !== i.deep || a.options.autoBind !== i.autoBind))
|
|
904
|
+
throw new TypeError("[Raph] Observable class options are already fixed.");
|
|
905
|
+
let c;
|
|
906
|
+
if (a !== void 0) {
|
|
907
|
+
c = /* @__PURE__ */ new Map();
|
|
908
|
+
const f = a.members;
|
|
909
|
+
if (f !== void 0) {
|
|
910
|
+
const w = f.next;
|
|
911
|
+
let b = w;
|
|
912
|
+
do
|
|
913
|
+
c.set(b.key, b), b = b.next;
|
|
914
|
+
while (b !== w);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
const u = Object.getPrototypeOf(e);
|
|
918
|
+
if (o && u !== null && u !== Object.prototype && Object.getPrototypeOf(u) !== Object.prototype)
|
|
919
|
+
throw new TypeError("[Raph] makeAutoObservable does not support inheritance; use makeObservable and override.");
|
|
920
|
+
if (o && r === _ && a === void 0) {
|
|
921
|
+
if (!i.autoBind && u !== null && u !== Object.prototype) {
|
|
922
|
+
const f = q(u) ?? Ce(u, e);
|
|
923
|
+
if (f !== void 0) {
|
|
924
|
+
const w = Q(s, e, f, i);
|
|
925
|
+
if (w !== void 0)
|
|
926
|
+
return w;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
return Ge(s, e, u, i);
|
|
930
|
+
}
|
|
931
|
+
const d = r === _, p = Reflect.ownKeys(o ? e : r);
|
|
932
|
+
if (o) {
|
|
933
|
+
if (u !== null && u !== Object.prototype)
|
|
934
|
+
for (const f of Reflect.ownKeys(u))
|
|
935
|
+
f !== "constructor" && f !== F && !Object.hasOwn(e, f) && p.push(f);
|
|
936
|
+
if (!d)
|
|
937
|
+
for (const f of Reflect.ownKeys(r))
|
|
938
|
+
p.includes(f) || p.push(f);
|
|
939
|
+
}
|
|
940
|
+
let l, h;
|
|
941
|
+
for (const f of p) {
|
|
942
|
+
if (f === "constructor" || f === m)
|
|
943
|
+
continue;
|
|
944
|
+
const w = Object.getOwnPropertyDescriptor(e, f), b = w ?? (o && u !== null && u !== Object.prototype ? Object.getOwnPropertyDescriptor(u, f) : Je(u, f));
|
|
945
|
+
if (b === void 0)
|
|
946
|
+
throw new TypeError(`[Raph] Observable member is not initialized: ${String(f)}`);
|
|
947
|
+
let v = d ? void 0 : r[f];
|
|
948
|
+
const O = c?.get(f);
|
|
949
|
+
if (d || !Object.hasOwn(r, f)) {
|
|
950
|
+
if (O !== void 0)
|
|
951
|
+
continue;
|
|
952
|
+
v = b.get !== void 0 ? "computed" : typeof b.value == "function" ? "autoAction" : i.deep ? "observable" : "shallow";
|
|
953
|
+
}
|
|
954
|
+
if (v === void 0)
|
|
955
|
+
throw new TypeError("[Raph] Missing observable annotation.");
|
|
956
|
+
const A = O?.annotation;
|
|
957
|
+
if (A !== void 0 && v !== "override") {
|
|
958
|
+
if (A === v)
|
|
959
|
+
continue;
|
|
960
|
+
throw new TypeError(`[Raph] Observable annotation is already fixed: ${String(f)}`);
|
|
961
|
+
}
|
|
962
|
+
if (v === "override") {
|
|
963
|
+
const R = O?.descriptor;
|
|
964
|
+
if (A === void 0 || R === void 0 || R.get !== b.get || R.set !== b.set || R.value !== b.value)
|
|
965
|
+
throw new TypeError("[Raph] override requires an inherited observable method or getter.");
|
|
966
|
+
if (w === void 0 && O?.shared !== !0)
|
|
967
|
+
throw new TypeError("[Raph] override requires a previously instrumented member.");
|
|
968
|
+
continue;
|
|
969
|
+
}
|
|
970
|
+
if (v !== !1) {
|
|
971
|
+
if (w !== void 0 && b.configurable === !1)
|
|
972
|
+
throw new TypeError(`[Raph] Observable member must be configurable: ${String(f)}`);
|
|
973
|
+
if (w === void 0 && !Object.isExtensible(e))
|
|
974
|
+
throw new TypeError("[Raph] Observable target is not extensible.");
|
|
975
|
+
if (v === "computed" ? typeof b.get != "function" : v === "action" || v === "action.bound" || v === "autoAction" ? typeof b.value != "function" : !(v === "observable" || v === "shallow" || v === "ref") || !("value" in b) || b.writable === !1)
|
|
976
|
+
throw new TypeError(`[Raph] Observable annotation does not match member: ${String(f)}`);
|
|
977
|
+
"value" in b && (b.value = s.unwrap(b.value));
|
|
978
|
+
}
|
|
979
|
+
const E = { key: f, descriptor: b, annotation: v, inherited: w === void 0, next: void 0 };
|
|
980
|
+
h === void 0 ? l = E : h.next = E, h = E;
|
|
981
|
+
}
|
|
982
|
+
return fe(s, e, l, i, a);
|
|
983
|
+
}
|
|
984
|
+
function Z(t) {
|
|
985
|
+
return t === k ? k : { deep: t.deep ?? !0, autoBind: t.autoBind ?? !1 };
|
|
986
|
+
}
|
|
987
|
+
function Q(t, e, r, n) {
|
|
988
|
+
const o = r.fields, s = o.length, i = e;
|
|
989
|
+
for (let l = 0; l < s; l++) {
|
|
990
|
+
const h = o[l];
|
|
991
|
+
if (!Object.hasOwn(e, h))
|
|
992
|
+
return;
|
|
993
|
+
const f = i[h];
|
|
994
|
+
f !== null && typeof f == "object" && t.unwrap(f);
|
|
995
|
+
}
|
|
996
|
+
if (!Object.isExtensible(e))
|
|
997
|
+
throw new TypeError("[Raph] Observable target is not extensible.");
|
|
998
|
+
const a = new Array(s), c = new L(t, e, r, n, a);
|
|
999
|
+
t.registerClassAdmin(e, c);
|
|
1000
|
+
const u = n.deep ? "observable" : "shallow", d = r.fieldDescriptors;
|
|
1001
|
+
let p = 0;
|
|
1002
|
+
try {
|
|
1003
|
+
for (; p < s; p++) {
|
|
1004
|
+
const l = o[p], h = i[l], f = typeof h == "function";
|
|
1005
|
+
a[p] = f || h === null || typeof h != "object" ? h : t.unwrap(h);
|
|
1006
|
+
const w = f ? pe(t, e, l, !1, "autoAction", !1, { configurable: !0, enumerable: !0, writable: !0, value: h }) : d[p];
|
|
1007
|
+
Object.defineProperty(e, l, w), c.fields = p + 1, c.materialized && W(c, { key: l, annotation: f ? "autoAction" : u, inherited: !1 });
|
|
1008
|
+
}
|
|
1009
|
+
} catch (l) {
|
|
1010
|
+
const h = $e(e, c, p, l);
|
|
1011
|
+
try {
|
|
1012
|
+
t.support.claim(e);
|
|
1013
|
+
} catch {
|
|
1014
|
+
}
|
|
1015
|
+
throw h;
|
|
1016
|
+
}
|
|
1017
|
+
return ae(c), e;
|
|
1018
|
+
}
|
|
1019
|
+
function $e(t, e, r, n) {
|
|
1020
|
+
const o = e.plan.fields;
|
|
1021
|
+
if (!e.materialized)
|
|
1022
|
+
for (let s = r - 1; s >= 0; s--) {
|
|
1023
|
+
try {
|
|
1024
|
+
Object.defineProperty(t, o[s], { value: e.values[s], writable: !0, enumerable: !0, configurable: !0 });
|
|
1025
|
+
} catch {
|
|
1026
|
+
break;
|
|
1027
|
+
}
|
|
1028
|
+
e.fields = s;
|
|
1029
|
+
}
|
|
1030
|
+
return n instanceof TypeError && r < o.length && Object.getOwnPropertyDescriptor(t, o[r])?.configurable === !1 ? new TypeError(`[Raph] Observable member must be configurable: ${String(o[r])}`) : n;
|
|
1031
|
+
}
|
|
1032
|
+
function Ge(t, e, r, n) {
|
|
1033
|
+
let o, s;
|
|
1034
|
+
for (const i of Reflect.ownKeys(e)) {
|
|
1035
|
+
if (i === "constructor" || i === m)
|
|
1036
|
+
continue;
|
|
1037
|
+
const a = X(t, e, i, Object.getOwnPropertyDescriptor(e, i), !1, n);
|
|
1038
|
+
s === void 0 ? o = a : s.next = a, s = a;
|
|
1039
|
+
}
|
|
1040
|
+
if (r !== null && r !== Object.prototype)
|
|
1041
|
+
for (const i of Reflect.ownKeys(r)) {
|
|
1042
|
+
if (i === "constructor" || i === F || Object.hasOwn(e, i))
|
|
1043
|
+
continue;
|
|
1044
|
+
const a = X(t, e, i, Object.getOwnPropertyDescriptor(r, i), !0, n);
|
|
1045
|
+
s === void 0 ? o = a : s.next = a, s = a;
|
|
1046
|
+
}
|
|
1047
|
+
return fe(t, e, o, n);
|
|
1048
|
+
}
|
|
1049
|
+
function X(t, e, r, n, o, s) {
|
|
1050
|
+
if (n === void 0)
|
|
1051
|
+
throw new TypeError(`[Raph] Observable member is not initialized: ${String(r)}`);
|
|
1052
|
+
const i = n.get !== void 0 ? "computed" : typeof n.value == "function" ? "autoAction" : s.deep ? "observable" : "shallow";
|
|
1053
|
+
if (!o && n.configurable === !1)
|
|
1054
|
+
throw new TypeError(`[Raph] Observable member must be configurable: ${String(r)}`);
|
|
1055
|
+
if (o && !Object.isExtensible(e))
|
|
1056
|
+
throw new TypeError("[Raph] Observable target is not extensible.");
|
|
1057
|
+
if ((i === "observable" || i === "shallow") && (!("value" in n) || n.writable === !1))
|
|
1058
|
+
throw new TypeError(`[Raph] Observable annotation does not match member: ${String(r)}`);
|
|
1059
|
+
return i !== "autoAction" && "value" in n && (n.value = t.unwrap(n.value)), { key: r, descriptor: n, annotation: i, inherited: o, next: void 0 };
|
|
1060
|
+
}
|
|
1061
|
+
function fe(t, e, r, n, o) {
|
|
1062
|
+
const s = o ?? { members: void 0, options: n };
|
|
1063
|
+
t.registerMember(e, s);
|
|
1064
|
+
for (let i = r; i !== void 0; ) {
|
|
1065
|
+
const a = i.next, { key: c, annotation: u } = i, d = i.descriptor;
|
|
1066
|
+
if (i.descriptor = void 0, u === !1) {
|
|
1067
|
+
const f = s.members;
|
|
1068
|
+
i.next = f === void 0 ? i : f.next, f !== void 0 && (f.next = i), s.members = i, i = a;
|
|
1069
|
+
continue;
|
|
1070
|
+
}
|
|
1071
|
+
const p = i.inherited && (u === "computed" || u === "action" || u === "action.bound"), l = Ye(t, e, i, d, n);
|
|
1072
|
+
Object.defineProperty(e, c, l), p && (i.descriptor = l);
|
|
1073
|
+
const h = s.members;
|
|
1074
|
+
i.next = h === void 0 ? i : h.next, h !== void 0 && (h.next = i), s.members = i, i = a;
|
|
1075
|
+
}
|
|
1076
|
+
return e;
|
|
1077
|
+
}
|
|
1078
|
+
function Ye(t, e, r, n, o) {
|
|
1079
|
+
const s = r.annotation;
|
|
1080
|
+
return s === "computed" ? qe(t, e, r.key, n) : s === "action" || s === "action.bound" || s === "autoAction" ? pe(t, e, r.key, r.inherited, s, o.autoBind, n) : He(t, s, n.value, n.enumerable ?? !1);
|
|
1081
|
+
}
|
|
1082
|
+
function qe(t, e, r, n) {
|
|
1083
|
+
const o = { configurable: !0, enumerable: n.enumerable ?? !1 }, s = n.get;
|
|
1084
|
+
let i;
|
|
1085
|
+
if (o.get = () => i !== void 0 ? i.get() : (t.assertRead(), t.engine._isTracking() ? (i = t.computed(Function.prototype.bind.call(s, e)), i.get()) : Reflect.apply(s, e, g)), n.set !== void 0) {
|
|
1086
|
+
const a = n.set, c = t.classAction(r, a);
|
|
1087
|
+
o.set = (u) => c(a, e, [u]);
|
|
1088
|
+
}
|
|
1089
|
+
return o;
|
|
1090
|
+
}
|
|
1091
|
+
function pe(t, e, r, n, o, s, i) {
|
|
1092
|
+
const a = i;
|
|
1093
|
+
a.configurable = !0;
|
|
1094
|
+
const c = i.value, u = typeof r == "string" ? r : { key: r, name: String(r) };
|
|
1095
|
+
if (!(typeof u == "string" ? u : u.name).trim())
|
|
1096
|
+
throw new Error("[Raph] Action name must not be empty.");
|
|
1097
|
+
const p = function() {
|
|
1098
|
+
const l = arguments.length === 0 ? g : arguments;
|
|
1099
|
+
t.assertRead();
|
|
1100
|
+
const h = typeof u == "string" ? u : u.key, f = n ? Ze(Object.getPrototypeOf(e), h) ?? c : c;
|
|
1101
|
+
return o === "autoAction" && t.engine._isTracking() ? Reflect.apply(f, this, l) : t.runtime._invokeAction(
|
|
1102
|
+
typeof u == "string" ? u : u.name,
|
|
1103
|
+
t.runtime.rootScope,
|
|
1104
|
+
f,
|
|
1105
|
+
l,
|
|
1106
|
+
this
|
|
1107
|
+
);
|
|
1108
|
+
};
|
|
1109
|
+
return a.value = o === "action.bound" || s ? p.bind(e) : p, a.writable = !0, a;
|
|
1110
|
+
}
|
|
1111
|
+
function He(t, e, r, n) {
|
|
1112
|
+
const o = { configurable: !0, enumerable: n };
|
|
1113
|
+
let s = r, i;
|
|
1114
|
+
const a = t.support.bridge;
|
|
1115
|
+
return o.get = () => (t.assertRead(), i !== void 0 ? a.track(i) : a.isTracking() && (i = a.createTransient(() => {
|
|
1116
|
+
i = void 0;
|
|
1117
|
+
}), a.track(i)), s === null || typeof s != "object" || e === "ref" ? s : e === "shallow" ? t.wrap(s, !1) : t.wrapChild(s, !0)), o.set = (c) => {
|
|
1118
|
+
if (t.support.tryDirectWrite()) {
|
|
1119
|
+
const u = t.unwrap(c);
|
|
1120
|
+
if (Object.is(u, s))
|
|
1121
|
+
return;
|
|
1122
|
+
s = u, i !== void 0 && a.trigger(i);
|
|
1123
|
+
} else {
|
|
1124
|
+
const u = c;
|
|
1125
|
+
t.write(() => {
|
|
1126
|
+
const d = t.unwrap(u);
|
|
1127
|
+
Object.is(d, s) || (s = d, i !== void 0 && a.trigger(i));
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
}, o;
|
|
1131
|
+
}
|
|
1132
|
+
function Je(t, e) {
|
|
1133
|
+
for (let r = t; r !== null && r !== Object.prototype; r = Object.getPrototypeOf(r)) {
|
|
1134
|
+
const n = Object.getOwnPropertyDescriptor(r, e);
|
|
1135
|
+
if (n !== void 0)
|
|
1136
|
+
return n;
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
function Ze(t, e) {
|
|
1140
|
+
for (let r = t; r !== null && r !== Object.prototype; r = Object.getPrototypeOf(r)) {
|
|
1141
|
+
const n = Object.getOwnPropertyDescriptor(r, e);
|
|
1142
|
+
if (n !== void 0)
|
|
1143
|
+
return n.value;
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
function rt(t, e, r = {}) {
|
|
1147
|
+
const n = V(t);
|
|
1148
|
+
if (e === null || typeof e != "object")
|
|
1149
|
+
throw new TypeError("[Raph] observable requires an object; use signal for primitives.");
|
|
1150
|
+
if (r.adapter === void 0)
|
|
1151
|
+
return n.wrap(e, r.deep ?? !0);
|
|
1152
|
+
n.assertRead();
|
|
1153
|
+
const o = n.member(e);
|
|
1154
|
+
if (o !== void 0) {
|
|
1155
|
+
if (o.adapter !== r.adapter)
|
|
1156
|
+
throw new TypeError("[Raph] Observable adapter is already fixed for this value.");
|
|
1157
|
+
return o.view;
|
|
1158
|
+
}
|
|
1159
|
+
n.assertUnwrappedTarget(e), n.support.claim(e);
|
|
1160
|
+
const s = n.adapterContext();
|
|
1161
|
+
let i;
|
|
1162
|
+
try {
|
|
1163
|
+
i = r.adapter.create(e, s.context);
|
|
1164
|
+
const a = { adapter: r.adapter, view: i };
|
|
1165
|
+
Object.is(i, e) || n.registerAdapterView(i, a), n.registerMember(e, a);
|
|
1166
|
+
} catch (a) {
|
|
1167
|
+
try {
|
|
1168
|
+
s.dispose();
|
|
1169
|
+
} catch (c) {
|
|
1170
|
+
throw new AggregateError([a, c], "[Raph] Observable adapter creation and cleanup failed.");
|
|
1171
|
+
}
|
|
1172
|
+
throw a;
|
|
1173
|
+
}
|
|
1174
|
+
return i;
|
|
1175
|
+
}
|
|
1176
|
+
function nt(t) {
|
|
1177
|
+
if (typeof t?.create != "function")
|
|
1178
|
+
throw new TypeError("[Raph] Observable adapter requires create().");
|
|
1179
|
+
return Object.freeze({ create: t.create });
|
|
1180
|
+
}
|
|
1181
|
+
export {
|
|
1182
|
+
nt as defineObservableAdapter,
|
|
1183
|
+
tt as makeAutoObservable,
|
|
1184
|
+
et as makeObservable,
|
|
1185
|
+
rt as observable,
|
|
1186
|
+
Xe as observableBuffer
|
|
1187
|
+
};
|