@raphy-js/raph 1.0.0-dev.2 → 1.0.1-dev.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1096 -0
- package/dist/api/Raph.d.ts +59 -190
- package/dist/api/RaphFacadeSession.d.ts +90 -0
- package/dist/api/RaphReactivityInstance.d.ts +72 -0
- package/dist/api/errors.d.ts +9 -4
- package/dist/api/types.d.ts +162 -17
- package/dist/core-CClhT8WR.js +1044 -0
- package/dist/core-cPQWYD4K.cjs +1 -0
- package/dist/debug/api/Raph.cjs +1 -1
- package/dist/debug/api/Raph.js +368 -367
- package/dist/debug/api/RaphFacadeSession.cjs +1 -0
- package/dist/debug/api/RaphFacadeSession.js +302 -0
- package/dist/debug/api/RaphReactivityInstance.cjs +1 -0
- package/dist/debug/api/RaphReactivityInstance.js +146 -0
- package/dist/debug/api/errors.cjs +1 -1
- package/dist/debug/api/errors.js +10 -7
- package/dist/debug/path/DataPath.cjs +1 -0
- package/dist/debug/path/DataPath.js +390 -0
- package/dist/debug/path/PathRouter.cjs +1 -0
- package/dist/debug/path/PathRouter.js +80 -0
- package/dist/debug/path/RaphKernel.cjs +1 -1
- package/dist/debug/path/RaphKernel.js +316 -236
- package/dist/debug/path/data-path.utils.cjs +1 -0
- package/dist/debug/path/data-path.utils.js +56 -0
- package/dist/debug/path/derived/DerivedRegistry.cjs +1 -0
- package/dist/debug/path/derived/DerivedRegistry.js +143 -0
- package/dist/debug/path/derived/RaphDerivedHandle.cjs +1 -0
- package/dist/debug/path/{RaphDerivedHandle.js → derived/RaphDerivedHandle.js} +19 -22
- package/dist/debug/path/derived/derived-collection.utils.cjs +1 -0
- package/dist/debug/path/{derived-collection.js → derived/derived-collection.utils.js} +71 -71
- package/dist/debug/path/derived/derived-strategy.types.cjs +1 -0
- package/dist/debug/path/derived/derived-strategy.types.js +1 -0
- package/dist/debug/path/meta/MetaController.cjs +1 -0
- package/dist/debug/path/{MetaController.js → meta/MetaController.js} +58 -66
- package/dist/debug/path/meta/RaphMeta.cjs +1 -0
- package/dist/debug/path/meta/RaphMeta.js +62 -0
- package/dist/debug/path/meta/RaphMetaStore.cjs +1 -0
- package/dist/debug/path/{RaphMetaStore.js → meta/RaphMetaStore.js} +24 -30
- package/dist/debug/path/meta/meta.types.cjs +1 -0
- package/dist/debug/path/meta/meta.types.js +1 -0
- package/dist/debug/path/storage/AdapterPathStore.cjs +1 -0
- package/dist/debug/path/storage/AdapterPathStore.js +128 -0
- package/dist/debug/path/storage/DefaultDataAdapter.cjs +1 -0
- package/dist/debug/path/{data-adapter.js → storage/DefaultDataAdapter.js} +47 -57
- package/dist/debug/path/storage/PathEventHub.cjs +1 -0
- package/dist/debug/path/storage/PathEventHub.js +161 -0
- package/dist/debug/path/storage/PathStore.cjs +1 -0
- package/dist/debug/path/{PathStore.js → storage/PathStore.js} +88 -98
- package/dist/debug/path/storage/createDataDraft.cjs +1 -0
- package/dist/debug/path/{data-draft.js → storage/createDataDraft.js} +24 -28
- package/dist/debug/path/storage/data-adapter.types.cjs +1 -0
- package/dist/debug/path/storage/data-adapter.types.js +1 -0
- package/dist/debug/reactivity/disposal.cjs +1 -0
- package/dist/debug/reactivity/disposal.js +32 -0
- package/dist/debug/reactivity/engine.cjs +1 -1
- package/dist/debug/reactivity/engine.js +888 -321
- package/dist/debug/reactivity/reactive-object.cjs +1 -0
- package/dist/debug/reactivity/reactive-object.js +265 -0
- package/dist/debug/reactivity/scope.cjs +1 -1
- package/dist/debug/reactivity/scope.js +221 -117
- package/dist/debug/reactivity/watch.cjs +1 -1
- package/dist/debug/reactivity/watch.js +1 -1
- package/dist/debug/runtime/RaphRuntime.cjs +1 -1
- package/dist/debug/runtime/RaphRuntime.js +1134 -502
- package/dist/debug/runtime/diagnostics/RaphDebug.cjs +1 -0
- package/dist/debug/runtime/diagnostics/RaphDebug.js +287 -0
- package/dist/debug/runtime/errors.cjs +1 -1
- package/dist/debug/runtime/errors.js +6 -3
- package/dist/debug/runtime/ownership/RaphEffectScope.cjs +1 -0
- package/dist/debug/runtime/ownership/RaphEffectScope.js +304 -0
- package/dist/debug/runtime/ownership/RaphNode.cjs +1 -0
- package/dist/debug/runtime/ownership/RaphNode.js +665 -0
- package/dist/debug/runtime/ownership/RaphScope.cjs +1 -0
- package/dist/debug/runtime/ownership/RaphScope.js +236 -0
- package/dist/debug/runtime/ownership/parent-graph.types.cjs +1 -0
- package/dist/debug/runtime/ownership/parent-graph.types.js +1 -0
- package/dist/debug/runtime/phases/RaphFrameLoop.cjs +1 -0
- package/dist/debug/runtime/{RaphFrameLoop.js → phases/RaphFrameLoop.js} +13 -17
- package/dist/debug/runtime/phases/RaphPhasePipeline.cjs +1 -0
- package/dist/debug/runtime/phases/RaphPhasePipeline.js +848 -0
- package/dist/debug/runtime/phases/RaphPhaseTaskRecord.cjs +1 -0
- package/dist/debug/runtime/phases/RaphPhaseTaskRecord.js +176 -0
- package/dist/debug/runtime/phases/RaphPhaseWatch.cjs +1 -0
- package/dist/debug/runtime/phases/RaphPhaseWatch.js +20 -0
- package/dist/debug/runtime/phases/orderPhaseTasks.cjs +1 -0
- package/dist/debug/runtime/phases/orderPhaseTasks.js +59 -0
- package/dist/debug/runtime/reactivity/PathHandle.cjs +1 -0
- package/dist/debug/runtime/reactivity/PathHandle.js +165 -0
- package/dist/debug/runtime/reactivity/RaphMetaSource.cjs +1 -0
- package/dist/debug/runtime/reactivity/RaphMetaSource.js +108 -0
- package/dist/debug/runtime/reactivity/RaphSelector.cjs +1 -0
- package/dist/debug/runtime/reactivity/RaphSelector.js +503 -0
- package/dist/debug/runtime/reactivity/RaphWorkGraph.cjs +1 -0
- package/dist/debug/runtime/reactivity/RaphWorkGraph.js +1157 -0
- package/dist/debug/runtime/reactivity/RuntimeReactivity.cjs +1 -0
- package/dist/debug/runtime/reactivity/RuntimeReactivity.js +550 -0
- package/dist/debug/runtime/reactivity/RuntimeWatch.cjs +1 -0
- package/dist/debug/runtime/reactivity/RuntimeWatch.js +77 -0
- package/dist/debug/runtime/reactivity/disposal-sweep.utils.cjs +1 -0
- package/dist/debug/runtime/reactivity/disposal-sweep.utils.js +42 -0
- package/dist/debug/runtime/reactivity/runtime-reactivity.types.cjs +1 -0
- package/dist/debug/runtime/reactivity/runtime-reactivity.types.js +1 -0
- package/dist/entrypoints/machine-testing.d.ts +2 -0
- package/dist/entrypoints/machine.d.ts +5 -0
- package/dist/entrypoints/path.d.ts +14 -0
- package/dist/entrypoints/reactivity.d.ts +1 -0
- package/dist/entrypoints/runtime.d.ts +18 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +46 -38
- package/dist/machine/compiler.d.ts +71 -0
- package/dist/machine/core.d.ts +50 -0
- package/dist/machine/persistence.d.ts +5 -0
- package/dist/machine/runtime.d.ts +4 -0
- package/dist/machine/testing.d.ts +43 -0
- package/dist/machine/types.d.ts +155 -0
- package/dist/machine-testing.cjs +1 -0
- package/dist/machine-testing.js +188 -0
- package/dist/machine.cjs +1 -0
- package/dist/machine.js +822 -0
- package/dist/main.d.ts +20 -0
- package/dist/path/{data-path.d.ts → DataPath.d.ts} +16 -40
- package/dist/path/{path-router.d.ts → PathRouter.d.ts} +1 -1
- package/dist/path/RaphKernel.d.ts +37 -10
- package/dist/path/data-path.types.d.ts +34 -0
- package/dist/path/data-path.utils.d.ts +9 -0
- package/dist/path/{DerivedRegistry.d.ts → derived/DerivedRegistry.d.ts} +2 -2
- package/dist/path/{RaphDerivedHandle.d.ts → derived/RaphDerivedHandle.d.ts} +3 -3
- package/dist/path/derived/derived-collection.types.d.ts +12 -0
- package/dist/path/{derived-collection.d.ts → derived/derived-collection.utils.d.ts} +3 -13
- package/dist/path/{derived-strategies.d.ts → derived/derived-strategy.types.d.ts} +0 -3
- package/dist/path/derived/derived-strategy.utils.d.ts +4 -0
- package/dist/path/{MetaController.d.ts → meta/MetaController.d.ts} +4 -4
- package/dist/path/{RaphMeta.d.ts → meta/RaphMeta.d.ts} +2 -2
- package/dist/path/{RaphMetaStore.d.ts → meta/RaphMetaStore.d.ts} +1 -1
- package/dist/path/{meta.types.d.ts → meta/meta.types.d.ts} +2 -4
- package/dist/path/path.types.d.ts +3 -2
- package/dist/path/{segment-key.d.ts → pathSegmentKey.d.ts} +1 -1
- package/dist/path/{AdapterPathStore.d.ts → storage/AdapterPathStore.d.ts} +4 -4
- package/dist/path/{data-adapter.d.ts → storage/DefaultDataAdapter.d.ts} +2 -17
- package/dist/path/storage/PathEventHub.d.ts +62 -0
- package/dist/path/{PathStore.d.ts → storage/PathStore.d.ts} +7 -7
- package/dist/path/storage/data-adapter.types.d.ts +17 -0
- package/dist/path.cjs +1 -1
- package/dist/path.js +16 -16
- package/dist/raph.cjs +1 -1
- package/dist/raph.js +46 -38
- package/dist/reactivity/disposal.d.ts +14 -0
- package/dist/reactivity/engine.d.ts +193 -6
- package/dist/reactivity/reactive-object.d.ts +36 -0
- package/dist/reactivity/scope.d.ts +108 -30
- package/dist/reactivity/types.d.ts +25 -0
- package/dist/reactivity.cjs +1 -1
- package/dist/reactivity.js +12 -12
- package/dist/runtime/RaphRuntime.d.ts +319 -160
- package/dist/runtime/diagnostics/RaphDebug.d.ts +239 -0
- package/dist/runtime/errors.d.ts +5 -0
- package/dist/runtime/ownership/RaphEffectScope.d.ts +98 -0
- package/dist/runtime/ownership/RaphNode.d.ts +310 -0
- package/dist/runtime/ownership/RaphScope.d.ts +168 -0
- package/dist/runtime/{parent-graph.d.ts → ownership/parent-graph.types.d.ts} +0 -1
- package/dist/runtime/ownership/parentGraph.d.ts +3 -0
- package/dist/runtime/phases/RaphPhasePipeline.d.ts +253 -0
- package/dist/runtime/phases/RaphPhaseTaskRecord.d.ts +195 -0
- package/dist/runtime/phases/RaphPhaseWatch.d.ts +22 -0
- package/dist/runtime/phases/orderPhaseTasks.d.ts +6 -0
- package/dist/runtime/phases/phase.types.d.ts +171 -0
- package/dist/runtime/{PathHandle.d.ts → reactivity/PathHandle.d.ts} +14 -6
- package/dist/runtime/reactivity/RaphMetaSource.d.ts +32 -0
- package/dist/runtime/reactivity/RaphSelector.d.ts +338 -0
- package/dist/runtime/reactivity/RaphWorkGraph.d.ts +309 -0
- package/dist/runtime/reactivity/RuntimeReactivity.d.ts +293 -0
- package/dist/runtime/{RuntimeWatch.d.ts → reactivity/RuntimeWatch.d.ts} +12 -6
- package/dist/runtime/reactivity/disposal-sweep.utils.d.ts +19 -0
- package/dist/runtime/reactivity/runtime-reactivity.types.d.ts +56 -0
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.js +21 -16
- package/package.json +76 -35
- package/ReadMe.md +0 -153
- package/dist/api/public.d.ts +0 -22
- package/dist/debug/api/public.cjs +0 -1
- package/dist/debug/api/public.js +0 -40
- package/dist/debug/path/AdapterPathStore.cjs +0 -1
- package/dist/debug/path/AdapterPathStore.js +0 -133
- package/dist/debug/path/DerivedRegistry.cjs +0 -1
- package/dist/debug/path/DerivedRegistry.js +0 -157
- package/dist/debug/path/MetaController.cjs +0 -1
- package/dist/debug/path/PathEventHub.cjs +0 -1
- package/dist/debug/path/PathEventHub.js +0 -148
- package/dist/debug/path/PathStore.cjs +0 -1
- package/dist/debug/path/RaphDerivedHandle.cjs +0 -1
- package/dist/debug/path/RaphMeta.cjs +0 -1
- package/dist/debug/path/RaphMeta.js +0 -68
- package/dist/debug/path/RaphMetaStore.cjs +0 -1
- package/dist/debug/path/data-adapter.cjs +0 -1
- package/dist/debug/path/data-draft.cjs +0 -1
- package/dist/debug/path/data-path.cjs +0 -1
- package/dist/debug/path/data-path.js +0 -423
- package/dist/debug/path/derived-collection.cjs +0 -1
- package/dist/debug/path/path-router.cjs +0 -1
- package/dist/debug/path/path-router.js +0 -86
- package/dist/debug/path/public.cjs +0 -1
- package/dist/debug/path/public.js +0 -18
- package/dist/debug/runtime/PathHandle.cjs +0 -1
- package/dist/debug/runtime/PathHandle.js +0 -139
- package/dist/debug/runtime/RaphDebug.cjs +0 -1
- package/dist/debug/runtime/RaphDebug.js +0 -15
- package/dist/debug/runtime/RaphFrameLoop.cjs +0 -1
- package/dist/debug/runtime/RaphNode.cjs +0 -1
- package/dist/debug/runtime/RaphNode.js +0 -143
- package/dist/debug/runtime/RaphPhasePipeline.cjs +0 -1
- package/dist/debug/runtime/RaphPhasePipeline.js +0 -526
- package/dist/debug/runtime/RaphScope.cjs +0 -1
- package/dist/debug/runtime/RaphScope.js +0 -64
- package/dist/debug/runtime/RuntimeReactivity.cjs +0 -1
- package/dist/debug/runtime/RuntimeReactivity.js +0 -154
- package/dist/debug/runtime/RuntimeWatch.cjs +0 -1
- package/dist/debug/runtime/RuntimeWatch.js +0 -71
- package/dist/debug/runtime/public.cjs +0 -1
- package/dist/debug/runtime/public.js +0 -18
- package/dist/path/PathEventHub.d.ts +0 -48
- package/dist/path/public.d.ts +0 -14
- package/dist/runtime/RaphDebug.d.ts +0 -32
- package/dist/runtime/RaphNode.d.ts +0 -68
- package/dist/runtime/RaphPhasePipeline.d.ts +0 -133
- package/dist/runtime/RaphScope.d.ts +0 -50
- package/dist/runtime/RuntimeReactivity.d.ts +0 -40
- package/dist/runtime/phase.types.d.ts +0 -49
- package/dist/runtime/public.d.ts +0 -13
- package/dist/runtime/runtime-reactivity.types.d.ts +0 -9
- /package/dist/debug/path/{meta.types.cjs → data-path.types.cjs} +0 -0
- /package/dist/debug/path/{meta.types.js → data-path.types.js} +0 -0
- /package/dist/debug/{runtime/runtime-reactivity.types.cjs → path/derived/derived-collection.types.cjs} +0 -0
- /package/dist/debug/{runtime/runtime-reactivity.types.js → path/derived/derived-collection.types.js} +0 -0
- /package/dist/debug/path/{derived-strategies.cjs → derived/derived-strategy.utils.cjs} +0 -0
- /package/dist/debug/path/{derived-strategies.js → derived/derived-strategy.utils.js} +0 -0
- /package/dist/debug/path/{segment-key.cjs → pathSegmentKey.cjs} +0 -0
- /package/dist/debug/path/{segment-key.js → pathSegmentKey.js} +0 -0
- /package/dist/debug/runtime/{parent-graph.cjs → ownership/parentGraph.cjs} +0 -0
- /package/dist/debug/runtime/{parent-graph.js → ownership/parentGraph.js} +0 -0
- /package/dist/debug/runtime/{disposal.cjs → ownership/throwDisposalErrors.cjs} +0 -0
- /package/dist/debug/runtime/{disposal.js → ownership/throwDisposalErrors.js} +0 -0
- /package/dist/debug/runtime/{phase.types.cjs → phases/phase.types.cjs} +0 -0
- /package/dist/debug/runtime/{phase.types.js → phases/phase.types.js} +0 -0
- /package/dist/path/{data-draft.d.ts → storage/createDataDraft.d.ts} +0 -0
- /package/dist/runtime/{disposal.d.ts → ownership/throwDisposalErrors.d.ts} +0 -0
- /package/dist/runtime/{RaphFrameLoop.d.ts → phases/RaphFrameLoop.d.ts} +0 -0
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
var p = Object.defineProperty;
|
|
2
|
-
var l = (r, t, e) => t in r ? p(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
-
var d = (r, t, e) => l(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
import { parseDataPath as i } from "./data-path.js";
|
|
5
|
-
import { PathEventHub as _ } from "./PathEventHub.js";
|
|
6
|
-
class k {
|
|
7
|
-
/**
|
|
8
|
-
* Связывает внешний DataAdapter с path events и watchers Kernel.
|
|
9
|
-
*/
|
|
10
|
-
constructor(t) {
|
|
11
|
-
// Публикует изменения внешнего adapter через общий path event lifecycle.
|
|
12
|
-
d(this, "_eventHub", new _(
|
|
13
|
-
"[Raph] Adapter transaction and publication failed."
|
|
14
|
-
));
|
|
15
|
-
this._adapter = t;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Возвращает значение по пути без создания отсутствующих данных.
|
|
19
|
-
*/
|
|
20
|
-
get(t, e) {
|
|
21
|
-
const a = i(t, e);
|
|
22
|
-
return this._adapter.get(a.canonical);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Читает значение по пути без регистрации реактивной зависимости.
|
|
26
|
-
*/
|
|
27
|
-
peek(t, e) {
|
|
28
|
-
return this.get(t, e);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Проверяет наличие значения по указанному пути.
|
|
32
|
-
*/
|
|
33
|
-
has(t, e) {
|
|
34
|
-
var n, s;
|
|
35
|
-
const a = i(t, e);
|
|
36
|
-
return ((s = (n = this._adapter).has) == null ? void 0 : s.call(n, a.canonical)) ?? u(this._adapter.root(), a.segments);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Записывает значение и публикует соответствующее изменение.
|
|
40
|
-
*/
|
|
41
|
-
set(t, e, a) {
|
|
42
|
-
const n = i(t, a), s = this._eventHub.hasWatchers ? this._adapter.get(n.canonical) : void 0;
|
|
43
|
-
this._adapter.set(n.canonical, e), this._eventHub.record({
|
|
44
|
-
kind: "set",
|
|
45
|
-
path: n.canonical,
|
|
46
|
-
previous: s,
|
|
47
|
-
value: this._eventHub.hasWatchers ? this._adapter.get(n.canonical) : void 0
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Объединяет значение по пути и публикует соответствующее изменение.
|
|
52
|
-
*/
|
|
53
|
-
merge(t, e, a) {
|
|
54
|
-
const n = i(t, a), s = this._eventHub.hasWatchers ? this._adapter.get(n.canonical) : void 0, c = o(s) && o(e) ? f(s) : s;
|
|
55
|
-
this._adapter.merge(n.canonical, e), this._eventHub.record({
|
|
56
|
-
kind: "merge",
|
|
57
|
-
path: n.canonical,
|
|
58
|
-
previous: c,
|
|
59
|
-
value: this._eventHub.hasWatchers ? this._adapter.get(n.canonical) : void 0
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Удаляет значение по пути и публикует изменение при наличии данных.
|
|
64
|
-
*/
|
|
65
|
-
delete(t, e) {
|
|
66
|
-
var c, h;
|
|
67
|
-
const a = i(t, e);
|
|
68
|
-
if (!(((h = (c = this._adapter).has) == null ? void 0 : h.call(c, a.canonical)) ?? u(this._adapter.root(), a.segments)))
|
|
69
|
-
return;
|
|
70
|
-
const s = this._eventHub.hasWatchers ? this._adapter.get(a.canonical) : void 0;
|
|
71
|
-
this._adapter.delete(a.canonical), this._eventHub.record({
|
|
72
|
-
kind: "delete",
|
|
73
|
-
path: a.canonical,
|
|
74
|
-
previous: s,
|
|
75
|
-
value: void 0
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Выполняет операцию в общей синхронной transaction boundary.
|
|
80
|
-
*/
|
|
81
|
-
transaction(t) {
|
|
82
|
-
return this._eventHub.transaction(t);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Подписывает callback на подходящие изменения и возвращает disposer.
|
|
86
|
-
*/
|
|
87
|
-
watch(t, e) {
|
|
88
|
-
return this._eventHub.watch(t, e);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
function u(r, t) {
|
|
92
|
-
let e = r;
|
|
93
|
-
for (const a of t)
|
|
94
|
-
if (a.kind === "key") {
|
|
95
|
-
if (!b(e) || !Object.hasOwn(e, a.key))
|
|
96
|
-
return !1;
|
|
97
|
-
e = e[a.key];
|
|
98
|
-
} else if (a.kind === "index") {
|
|
99
|
-
if (!Array.isArray(e) || !Object.hasOwn(e, a.index))
|
|
100
|
-
return !1;
|
|
101
|
-
e = e[a.index];
|
|
102
|
-
} else {
|
|
103
|
-
if (!Array.isArray(e))
|
|
104
|
-
return !1;
|
|
105
|
-
const n = e.findIndex(
|
|
106
|
-
(s) => o(s) && Object.hasOwn(s, a.key) && Object.is(s[a.key], a.value)
|
|
107
|
-
);
|
|
108
|
-
if (n === -1)
|
|
109
|
-
return !1;
|
|
110
|
-
e = e[n];
|
|
111
|
-
}
|
|
112
|
-
return !0;
|
|
113
|
-
}
|
|
114
|
-
function f(r) {
|
|
115
|
-
const t = Object.create(Object.getPrototypeOf(r));
|
|
116
|
-
for (const e of Object.keys(r))
|
|
117
|
-
e === "__proto__" ? Object.defineProperty(t, e, {
|
|
118
|
-
configurable: !0,
|
|
119
|
-
enumerable: !0,
|
|
120
|
-
value: r[e],
|
|
121
|
-
writable: !0
|
|
122
|
-
}) : t[e] = r[e];
|
|
123
|
-
return t;
|
|
124
|
-
}
|
|
125
|
-
function o(r) {
|
|
126
|
-
return typeof r == "object" && r !== null && !Array.isArray(r);
|
|
127
|
-
}
|
|
128
|
-
function b(r) {
|
|
129
|
-
return Array.isArray(r) || o(r);
|
|
130
|
-
}
|
|
131
|
-
export {
|
|
132
|
-
k as AdapterPathStore
|
|
133
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var h=Object.defineProperty;var u=(r,e,t)=>e in r?h(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var d=(r,e,t)=>u(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./data-path.cjs"),_=require("./derived-collection.cjs"),f=require("./path-router.cjs"),g=2e4;class v{constructor(){d(this,"_router");d(this,"_handles");d(this,"_matches");d(this,"_pending");d(this,"_collections");d(this,"_counter",0)}get size(){var e;return((e=this._handles)==null?void 0:e.size)??0}get pending(){return this._pending}nextId(){return`derived-${this._counter++}`}has(e){var t;return((t=this._handles)==null?void 0:t.has(e))??!1}values(){var e;return((e=this._handles)==null?void 0:e.values())??[][Symbol.iterator]()}state(e){var t;return(t=this._collections)==null?void 0:t.get(e)}register(e,t,i){(this._handles??(this._handles=new Map)).set(e.id,e),i!==void 0&&(this._collections??(this._collections=new Map)).set(e,{from:t,kind:i.kind,key:i.key,initialized:!1,full:!0,keys:new Set,sourceIndex:void 0,targetIndex:void 0});const n=this._router??(this._router=new f.PathRouter);this._matches=void 0,e._attachRoutes(l.pathRelationMasks(t).map(s=>n.add(l.parsePathMask(s),e)))}remove(e){var i,o,n;const t=this._handles;(t==null?void 0:t.get(e.id))===e&&(t.delete(e.id),e._detachRoutes(),this._matches=void 0,(i=this._pending)==null||i.delete(e),(o=this._collections)==null||o.delete(e),((n=this._collections)==null?void 0:n.size)===0&&(this._collections=void 0),t.size===0&&(this._handles=void 0,this._router=void 0,this._pending=void 0))}queue(e){var o;const t=this._matching(e);if(t.length===0)return;const i=this._pending??(this._pending=new Set);for(const n of t){if(n.paused||n.disposed)continue;const s=(o=this._collections)==null?void 0:o.get(n);if(s!==void 0&&s.initialized&&!s.full){const c=_.collectionMutationImpact(s.from,s.key,e);c.kind==="full"?(s.full=!0,s.keys.clear()):s.keys.add(c.key)}i.add(n)}}queueReplacement(e,t){var n;const i=this._matching(e);if(i.length===0)return;const o=this._pending??(this._pending=new Set);for(const s of i){if(s.paused||s.disposed)continue;const c=(n=this._collections)==null?void 0:n.get(s);if(c!==void 0&&c.initialized&&!c.full&&c.from.canonical===e.canonical)for(const a of t)c.keys.add(a);else c!==void 0&&(c.full=!0,c.keys.clear());o.add(s)}}clearPendingIfEmpty(){var e;((e=this._pending)==null?void 0:e.size)===0&&(this._pending=void 0)}dispose(){if(this._handles!==void 0)for(const e of this._handles.values())e._disposeFromKernel();this._handles=void 0,this._router=void 0,this._matches=void 0,this._pending=void 0,this._collections=void 0}_matching(e){var n;const t=this._router;if(t===void 0)return[];let i=(n=this._matches)==null?void 0:n.get(e.canonical);if(i!==void 0)return i;i=[...e.segments.length===0?t.matchAll():t.match(e.segments)];const o=this._matches??(this._matches=new Map);return o.size>=g&&o.clear(),o.set(e.canonical,i),i}}exports.DerivedRegistry=v;
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
var a = Object.defineProperty;
|
|
2
|
-
var h = (l, e, t) => e in l ? a(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
|
|
3
|
-
var d = (l, e, t) => h(l, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { pathRelationMasks as _, parsePathMask as u } from "./data-path.js";
|
|
5
|
-
import { collectionMutationImpact as f } from "./derived-collection.js";
|
|
6
|
-
import { PathRouter as m } from "./path-router.js";
|
|
7
|
-
const g = 2e4;
|
|
8
|
-
class z {
|
|
9
|
-
constructor() {
|
|
10
|
-
// Хранят routes, handles и инкрементальное состояние materialized derived.
|
|
11
|
-
d(this, "_router");
|
|
12
|
-
d(this, "_handles");
|
|
13
|
-
d(this, "_matches");
|
|
14
|
-
d(this, "_pending");
|
|
15
|
-
d(this, "_collections");
|
|
16
|
-
// Формирует локальные идентификаторы derived без глобального shared state.
|
|
17
|
-
d(this, "_counter", 0);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Возвращает число зарегистрированных записей.
|
|
21
|
-
*/
|
|
22
|
-
get size() {
|
|
23
|
-
var e;
|
|
24
|
-
return ((e = this._handles) == null ? void 0 : e.size) ?? 0;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Возвращает очередь derived-вычислений, ожидающих стабилизации.
|
|
28
|
-
*/
|
|
29
|
-
get pending() {
|
|
30
|
-
return this._pending;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Выделяет следующий стабильный идентификатор registry.
|
|
34
|
-
*/
|
|
35
|
-
nextId() {
|
|
36
|
-
return `derived-${this._counter++}`;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Проверяет наличие derived handle с указанным id.
|
|
40
|
-
*/
|
|
41
|
-
has(e) {
|
|
42
|
-
var t;
|
|
43
|
-
return ((t = this._handles) == null ? void 0 : t.has(e)) ?? !1;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Возвращает зарегистрированные derived handles.
|
|
47
|
-
*/
|
|
48
|
-
values() {
|
|
49
|
-
var e;
|
|
50
|
-
return ((e = this._handles) == null ? void 0 : e.values()) ?? [][Symbol.iterator]();
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Возвращает внутреннее состояние зарегистрированного handle.
|
|
54
|
-
*/
|
|
55
|
-
state(e) {
|
|
56
|
-
var t;
|
|
57
|
-
return (t = this._collections) == null ? void 0 : t.get(e);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Регистрирует derived handle и его зависимости.
|
|
61
|
-
*/
|
|
62
|
-
register(e, t, i) {
|
|
63
|
-
(this._handles ?? (this._handles = /* @__PURE__ */ new Map())).set(e.id, e), i !== void 0 && (this._collections ?? (this._collections = /* @__PURE__ */ new Map())).set(e, {
|
|
64
|
-
from: t,
|
|
65
|
-
kind: i.kind,
|
|
66
|
-
key: i.key,
|
|
67
|
-
initialized: !1,
|
|
68
|
-
full: !0,
|
|
69
|
-
keys: /* @__PURE__ */ new Set(),
|
|
70
|
-
sourceIndex: void 0,
|
|
71
|
-
targetIndex: void 0
|
|
72
|
-
});
|
|
73
|
-
const n = this._router ?? (this._router = new m());
|
|
74
|
-
this._matches = void 0, e._attachRoutes(_(t).map(
|
|
75
|
-
(s) => n.add(u(s), e)
|
|
76
|
-
));
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Удаляет регистрацию и связанные pending-записи.
|
|
80
|
-
*/
|
|
81
|
-
remove(e) {
|
|
82
|
-
var i, o, n;
|
|
83
|
-
const t = this._handles;
|
|
84
|
-
(t == null ? void 0 : t.get(e.id)) === e && (t.delete(e.id), e._detachRoutes(), this._matches = void 0, (i = this._pending) == null || i.delete(e), (o = this._collections) == null || o.delete(e), ((n = this._collections) == null ? void 0 : n.size) === 0 && (this._collections = void 0), t.size === 0 && (this._handles = void 0, this._router = void 0, this._pending = void 0));
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Добавляет derived handle в очередь пересчёта.
|
|
88
|
-
*/
|
|
89
|
-
queue(e) {
|
|
90
|
-
var o;
|
|
91
|
-
const t = this._matching(e);
|
|
92
|
-
if (t.length === 0)
|
|
93
|
-
return;
|
|
94
|
-
const i = this._pending ?? (this._pending = /* @__PURE__ */ new Set());
|
|
95
|
-
for (const n of t) {
|
|
96
|
-
if (n.paused || n.disposed)
|
|
97
|
-
continue;
|
|
98
|
-
const s = (o = this._collections) == null ? void 0 : o.get(n);
|
|
99
|
-
if (s !== void 0 && s.initialized && !s.full) {
|
|
100
|
-
const c = f(s.from, s.key, e);
|
|
101
|
-
c.kind === "full" ? (s.full = !0, s.keys.clear()) : s.keys.add(c.key);
|
|
102
|
-
}
|
|
103
|
-
i.add(n);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Запоминает полную замену, которую нужно применить при стабилизации.
|
|
108
|
-
*/
|
|
109
|
-
queueReplacement(e, t) {
|
|
110
|
-
var n;
|
|
111
|
-
const i = this._matching(e);
|
|
112
|
-
if (i.length === 0)
|
|
113
|
-
return;
|
|
114
|
-
const o = this._pending ?? (this._pending = /* @__PURE__ */ new Set());
|
|
115
|
-
for (const s of i) {
|
|
116
|
-
if (s.paused || s.disposed)
|
|
117
|
-
continue;
|
|
118
|
-
const c = (n = this._collections) == null ? void 0 : n.get(s);
|
|
119
|
-
if (c !== void 0 && c.initialized && !c.full && c.from.canonical === e.canonical)
|
|
120
|
-
for (const r of t)
|
|
121
|
-
c.keys.add(r);
|
|
122
|
-
else c !== void 0 && (c.full = !0, c.keys.clear());
|
|
123
|
-
o.add(s);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Сбрасывает pending-состояние после опустошения очереди.
|
|
128
|
-
*/
|
|
129
|
-
clearPendingIfEmpty() {
|
|
130
|
-
var e;
|
|
131
|
-
((e = this._pending) == null ? void 0 : e.size) === 0 && (this._pending = void 0);
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Освобождает все handles и очищает derived registry.
|
|
135
|
-
*/
|
|
136
|
-
dispose() {
|
|
137
|
-
if (this._handles !== void 0)
|
|
138
|
-
for (const e of this._handles.values())
|
|
139
|
-
e._disposeFromKernel();
|
|
140
|
-
this._handles = void 0, this._router = void 0, this._matches = void 0, this._pending = void 0, this._collections = void 0;
|
|
141
|
-
}
|
|
142
|
-
_matching(e) {
|
|
143
|
-
var n;
|
|
144
|
-
const t = this._router;
|
|
145
|
-
if (t === void 0)
|
|
146
|
-
return [];
|
|
147
|
-
let i = (n = this._matches) == null ? void 0 : n.get(e.canonical);
|
|
148
|
-
if (i !== void 0)
|
|
149
|
-
return i;
|
|
150
|
-
i = [...e.segments.length === 0 ? t.matchAll() : t.match(e.segments)];
|
|
151
|
-
const o = this._matches ?? (this._matches = /* @__PURE__ */ new Map());
|
|
152
|
-
return o.size >= g && o.clear(), o.set(e.canonical, i), i;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
export {
|
|
156
|
-
z as DerivedRegistry
|
|
157
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var v=Object.defineProperty;var p=(d,e,t)=>e in d?v(d,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[e]=t;var l=(d,e,t)=>p(d,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./data-path.cjs"),g=require("./path-router.cjs"),m=require("./RaphMeta.cjs"),_=require("./RaphMetaStore.cjs");class b{constructor(e,t,r){l(this,"_facade");l(this,"_store");l(this,"_router");l(this,"_pending");l(this,"_publishing",!1);l(this,"_watcherCount",0);l(this,"_deferredWatcherCount",0);this._kernel=e,this._ownerExists=t,this._publicationDeferred=r}get facade(){return this._facade??(this._facade=new m.RaphMeta(this._kernel))}get size(){var e;return((e=this._store)==null?void 0:e.size)??0}get hasWatchers(){return this._router!==void 0}get hasDeferredWatchers(){return this._deferredWatcherCount!==0}get(e,t){var r;return(r=this._store)==null?void 0:r.get(e,t)}has(e,t){var r;return((r=this._store)==null?void 0:r.has(e,t))??!1}set(e,t,r,i){(this._store??(this._store=new _.RaphMetaStore)).set(e,t,r),this.record("set",e,t,"explicit",i)}merge(e,t,r,i){(this._store??(this._store=new _.RaphMetaStore)).merge(e,t,r),this.record("merge",e,t,"explicit",i)}delete(e,t,r){var i;return(i=this._store)!=null&&i.delete(e,t)?(this.record("delete",e,t??null,"explicit",r),!0):!1}deleteSubtree(e,t){const r=this._store;if(r!==void 0)for(const i of r.deleteSubtree(e))this.record("delete",i,null,t)}pruneMissing(e,t){const r=this._store;if(r===void 0||r.size===0)return;const n=e.segments().findIndex(s=>s.kind==="index"||s.kind==="selector"),c=n===-1?e:f.DataPath.fromPlain({segs:e.toPlain().segs.slice(0,n)});for(const s of r.pruneMissing(c,o=>this._ownerExists(o)))this.record("delete",s,null,t)}watch(e,t,r={},i){const n=Array.isArray(e)?e:[e];if(n.length===0)throw new TypeError("[RaphMeta] watch requires at least one mask.");const c=new Map;for(const a of n){const u=f.DataPath.from(a,r)._asMask();c.set(u.canonical,u)}const s={active:!0,callback:t,afterPublish:i,...r.namespace===void 0?{}:{namespace:r.namespace}},o=this._router??(this._router=new g.PathRouter),h=[...c.values()].map(a=>o.add(a,s));return this._watcherCount++,i!==void 0&&this._deferredWatcherCount++,w(()=>{s.active=!1,s.callback=void 0,s.afterPublish=void 0;for(const a of h)a();this._watcherCount--,i!==void 0&&this._deferredWatcherCount--,this._watcherCount===0&&(this._router=void 0)})}record(e,t,r,i,n){(this._pending??(this._pending=[])).push({event:{kind:e,path:t,namespace:r,cause:i},invalidate:(n==null?void 0:n.invalidate)??!0}),!this._publicationDeferred()&&!this._publishing&&this.publish()}publish(){const e=this._pending;if(e===void 0||e.length===0||this._publishing)return;const t=[],r=new Map;this._publishing=!0;try{for(;e.length!==0;){const i=e.splice(0),n=this._router;if(n===void 0)continue;const c=new Map;for(const s of i){const o=s.event;for(const h of n.match(o.path._asExact().segments)){if(h.namespace!==void 0&&o.namespace!==null&&h.namespace!==o.namespace)continue;const a=c.get(h);a===void 0?c.set(h,{events:[o],invalidate:s.invalidate}):(a.events.push(o),s.invalidate&&(a.invalidate=!0))}}for(const[s,o]of c){if(!s.active||s.callback===void 0)continue;const h=s.afterPublish;h!==void 0&&r.set(h,(r.get(h)??!1)||o.invalidate);try{s.callback({events:o.events})}catch(a){t.push(a)}}}}finally{this._publishing=!1}for(const[i,n]of r)try{i(n)}catch(c){t.push(c)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"[RaphMeta] Multiple watchers failed.")}dispose(){var e;(e=this._store)==null||e.clear(),this._store=void 0,this._facade=void 0,this._router=void 0,this._pending=void 0,this._watcherCount=0,this._deferredWatcherCount=0}}function w(d){let e=d;return()=>{const t=e;e=void 0,t==null||t()}}exports.MetaController=b;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var _=Object.defineProperty;var f=(a,t,e)=>t in a?_(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var c=(a,t,e)=>f(a,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./data-path.cjs"),g=require("./path-router.cjs");class v{constructor(t){c(this,"_router");c(this,"_events");c(this,"_transactionDepth",0);c(this,"_watcherCount",0);c(this,"_publishing",!1);this._transactionErrorMessage=t}get hasWatchers(){return this._watcherCount!==0}get events(){return this._events}get router(){return this._router}get watcherCount(){return this._watcherCount}record(t){this._watcherCount!==0&&((this._events??(this._events=[])).push(t),this._transactionDepth===0&&!this._publishing&&this._publish())}transaction(t){var o;let e=!1,h,n=!1,i,s;this._transactionDepth++;try{s=t()}catch(r){e=!0,h=r}finally{if(this._transactionDepth--,this._transactionDepth===0&&((o=this._events)!=null&&o.length))try{this._publish()}catch(r){n=!0,i=r}}if(e&&n)throw new AggregateError([h,i],this._transactionErrorMessage);if(e)throw h;if(n)throw i;return s}watch(t,e){const h=Array.isArray(t)?t:[t];if(h.length===0)throw new TypeError("[Raph] Path watch requires at least one mask.");const n=new Map;for(const r of h){const u=p.parsePathMask(r);n.set(u.canonical,u)}const i={active:!0,callback:e},s=this._router??(this._router=new g.PathRouter),o=[...n.values()].map(r=>s.add(r,i));return this._watcherCount++,d(()=>{i.active=!1,i.callback=void 0;for(const r of o)r();this._watcherCount--,this._watcherCount===0&&(this._router=void 0)})}_publish(){const t=this._events;if(t===void 0||t.length===0||this._publishing)return;const e=[];this._publishing=!0;try{for(;t.length!==0;){const h=t.splice(0),n=this._router;if(n===void 0)continue;const i=new Map;for(const s of h){const o=p.parseDataPath(s.path),r=o.segments.length===0?n.matchAll():n.match(o.segments);for(const u of r){const l=i.get(u);l===void 0?i.set(u,[s]):l.push(s)}}for(const[s,o]of i)if(!(!s.active||s.callback===void 0))try{s.callback({events:o})}catch(r){e.push(r)}}}finally{this._publishing=!1}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"[Raph] Multiple path watchers failed.")}}function d(a){let t=a;return()=>{const e=t;t=void 0,e==null||e()}}exports.PathEventHub=v;
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
var p = Object.defineProperty;
|
|
2
|
-
var f = (a, t, e) => t in a ? p(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
|
|
3
|
-
var c = (a, t, e) => f(a, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
import { parsePathMask as _, parseDataPath as g } from "./data-path.js";
|
|
5
|
-
import { PathRouter as v } from "./path-router.js";
|
|
6
|
-
class y {
|
|
7
|
-
/**
|
|
8
|
-
* Создаёт общий transaction и publication boundary для path store.
|
|
9
|
-
*/
|
|
10
|
-
constructor(t) {
|
|
11
|
-
// Хранят ленивый routing и текущий batch path events.
|
|
12
|
-
c(this, "_router");
|
|
13
|
-
c(this, "_events");
|
|
14
|
-
// Защищают границы transaction, reentrant publication и snapshot requirements.
|
|
15
|
-
c(this, "_transactionDepth", 0);
|
|
16
|
-
c(this, "_watcherCount", 0);
|
|
17
|
-
c(this, "_publishing", !1);
|
|
18
|
-
this._transactionErrorMessage = t;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Показывает, есть ли watchers, ради которых нужно сохранять значения событий.
|
|
22
|
-
*/
|
|
23
|
-
get hasWatchers() {
|
|
24
|
-
return this._watcherCount !== 0;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Возвращает накопленные события текущей transaction.
|
|
28
|
-
* @internal
|
|
29
|
-
*/
|
|
30
|
-
get events() {
|
|
31
|
-
return this._events;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Возвращает внутренний path router для диагностики store.
|
|
35
|
-
* @internal
|
|
36
|
-
*/
|
|
37
|
-
get router() {
|
|
38
|
-
return this._router;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Возвращает число активных watchers.
|
|
42
|
-
* @internal
|
|
43
|
-
*/
|
|
44
|
-
get watcherCount() {
|
|
45
|
-
return this._watcherCount;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Добавляет событие в текущую transaction либо публикует его сразу.
|
|
49
|
-
*/
|
|
50
|
-
record(t) {
|
|
51
|
-
this._watcherCount !== 0 && ((this._events ?? (this._events = [])).push(t), this._transactionDepth === 0 && !this._publishing && this._publish());
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Выполняет операцию в общей синхронной transaction boundary.
|
|
55
|
-
*/
|
|
56
|
-
transaction(t) {
|
|
57
|
-
var n;
|
|
58
|
-
let e = !1, h, o = !1, i, s;
|
|
59
|
-
this._transactionDepth++;
|
|
60
|
-
try {
|
|
61
|
-
s = t();
|
|
62
|
-
} catch (r) {
|
|
63
|
-
e = !0, h = r;
|
|
64
|
-
} finally {
|
|
65
|
-
if (this._transactionDepth--, this._transactionDepth === 0 && ((n = this._events) != null && n.length))
|
|
66
|
-
try {
|
|
67
|
-
this._publish();
|
|
68
|
-
} catch (r) {
|
|
69
|
-
o = !0, i = r;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (e && o)
|
|
73
|
-
throw new AggregateError(
|
|
74
|
-
[h, i],
|
|
75
|
-
this._transactionErrorMessage
|
|
76
|
-
);
|
|
77
|
-
if (e)
|
|
78
|
-
throw h;
|
|
79
|
-
if (o)
|
|
80
|
-
throw i;
|
|
81
|
-
return s;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Подписывает callback на подходящие изменения и возвращает disposer.
|
|
85
|
-
*/
|
|
86
|
-
watch(t, e) {
|
|
87
|
-
const h = Array.isArray(t) ? t : [t];
|
|
88
|
-
if (h.length === 0)
|
|
89
|
-
throw new TypeError("[Raph] Path watch requires at least one mask.");
|
|
90
|
-
const o = /* @__PURE__ */ new Map();
|
|
91
|
-
for (const r of h) {
|
|
92
|
-
const u = _(r);
|
|
93
|
-
o.set(u.canonical, u);
|
|
94
|
-
}
|
|
95
|
-
const i = { active: !0, callback: e }, s = this._router ?? (this._router = new v()), n = [...o.values()].map((r) => s.add(r, i));
|
|
96
|
-
return this._watcherCount++, w(() => {
|
|
97
|
-
i.active = !1, i.callback = void 0;
|
|
98
|
-
for (const r of n)
|
|
99
|
-
r();
|
|
100
|
-
this._watcherCount--, this._watcherCount === 0 && (this._router = void 0);
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
_publish() {
|
|
104
|
-
const t = this._events;
|
|
105
|
-
if (t === void 0 || t.length === 0 || this._publishing)
|
|
106
|
-
return;
|
|
107
|
-
const e = [];
|
|
108
|
-
this._publishing = !0;
|
|
109
|
-
try {
|
|
110
|
-
for (; t.length !== 0; ) {
|
|
111
|
-
const h = t.splice(0), o = this._router;
|
|
112
|
-
if (o === void 0)
|
|
113
|
-
continue;
|
|
114
|
-
const i = /* @__PURE__ */ new Map();
|
|
115
|
-
for (const s of h) {
|
|
116
|
-
const n = g(s.path), r = n.segments.length === 0 ? o.matchAll() : o.match(n.segments);
|
|
117
|
-
for (const u of r) {
|
|
118
|
-
const l = i.get(u);
|
|
119
|
-
l === void 0 ? i.set(u, [s]) : l.push(s);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
for (const [s, n] of i)
|
|
123
|
-
if (!(!s.active || s.callback === void 0))
|
|
124
|
-
try {
|
|
125
|
-
s.callback({ events: n });
|
|
126
|
-
} catch (r) {
|
|
127
|
-
e.push(r);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
} finally {
|
|
131
|
-
this._publishing = !1;
|
|
132
|
-
}
|
|
133
|
-
if (e.length === 1)
|
|
134
|
-
throw e[0];
|
|
135
|
-
if (e.length > 1)
|
|
136
|
-
throw new AggregateError(e, "[Raph] Multiple path watchers failed.");
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
function w(a) {
|
|
140
|
-
let t = a;
|
|
141
|
-
return () => {
|
|
142
|
-
const e = t;
|
|
143
|
-
t = void 0, e == null || e();
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
export {
|
|
147
|
-
y as PathEventHub
|
|
148
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var R=Object.defineProperty;var P=(r,e,t)=>e in r?R(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var v=(r,e,t)=>P(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./data-path.cjs"),H=require("./PathEventHub.cjs"),u=new WeakMap;class m{constructor(){v(this,"_root");v(this,"_eventHub",new H.PathEventHub("[Raph] Path transaction and publication failed."))}get _router(){return this._eventHub.router}get _events(){return this._eventHub.events}get _watcherCount(){return this._eventHub.watcherCount}get(e,t){const n=f.parseDataPath(e,t),o=this._root;if(o!==void 0)return h(o,n.segments).value}peek(e,t){return this.get(e,t)}has(e,t){const n=f.parseDataPath(e,t),o=this._root;return o!==void 0&&h(o,n.segments).exists}set(e,t,n){const o=f.parseDataPath(e,n);if(o.segments.length===0){this._setRoot(t);return}const s=this._eventHub.hasWatchers,i=s?h(this._root,o.segments).value:void 0;if(this._root??(this._root=Object.create(null)),w(this._root,o,t),!s)return;const c=h(this._root,o.segments).value;this._eventHub.record({kind:"set",path:o.canonical,previous:i,value:c})}merge(e,t,n){const o=f.parseDataPath(e,n);if(o.segments.length===0){this._mergeRoot(t);return}const s=this._eventHub.hasWatchers,i=h(this._root,o.segments).value,c=s&&a(i)&&a(t)?A(i):i;if(a(i)&&a(t)){p(this._root,o.segments);for(const g of Object.keys(t))l(i,g,t[g])}else this._root??(this._root=Object.create(null)),w(this._root,o,t);if(!s)return;const d=h(this._root,o.segments).value;this._eventHub.record({kind:"merge",path:o.canonical,previous:c,value:d})}delete(e,t){const n=f.parseDataPath(e,t);if(n.segments.length===0){this._deleteRoot();return}const o=h(this._root,n.segments);!o.exists||this._root===void 0||(p(this._root,n.segments),E(this._root,n),this._eventHub.hasWatchers&&this._eventHub.record({kind:"delete",path:n.canonical,previous:o.value,value:void 0}))}transaction(e){return this._eventHub.transaction(e)}watch(e,t){return this._eventHub.watch(e,t)}_setRoot(e){const t=x(e),n=this._root;this._root=t,this._recordRootEvent("set",n,t)}_mergeRoot(e){const t=this._root,n=this._eventHub.hasWatchers&&a(t)&&a(e)?A(t):t;if(a(t)&&a(e))for(const o of Object.keys(e))l(t,o,e[o]);else this._root=x(e);this._recordRootEvent("merge",n,this._root)}_deleteRoot(){const e=this._root;e!==void 0&&(this._root=D(),this._recordRootEvent("delete",e,void 0))}_recordRootEvent(e,t,n){this._eventHub.record({kind:e,path:"",previous:t,value:n})}}function h(r,e){let t=r;for(const n of e)if(n.kind==="key"){if(!b(t)||!Object.hasOwn(t,n.key))return{exists:!1,value:void 0};t=t[n.key]}else if(n.kind==="index"){if(!Array.isArray(t)||!Object.hasOwn(t,n.index))return{exists:!1,value:void 0};t=t[n.index]}else{if(!Array.isArray(t))return{exists:!1,value:void 0};const o=_(t,n.key,n.value);if(o===-1)return{exists:!1,value:void 0};t=t[o]}return{exists:!0,value:t}}function p(r,e){let t=r;for(const n of e){if(!b(t))return;const o=j(t,n);Array.isArray(t)&&u.delete(t),t=o}}function w(r,e,t){let n=r,o;for(let i=0;i<e.segments.length-1;i++){const c=e.segments[i],d=e.segments[i+1];c.kind==="selector"&&Array.isArray(n)&&(o=n),c.kind==="index"&&Array.isArray(n)&&(o=n),n=C(n,c,d,e.canonical)}const s=e.segments[e.segments.length-1];if(S(n,s,t,e.canonical),s.kind==="key"&&o!==void 0){const i=u.get(o);i==null||i.delete(s.key),(i==null?void 0:i.size)===0&&u.delete(o)}}function E(r,e){let t=r;for(let s=0;s<e.segments.length-1;s++){const i=e.segments[s],c=j(t,i);if(!b(c))return;t=c}const n=e.segments[e.segments.length-1];if(n.kind==="key"){delete t[n.key];return}if(!Array.isArray(t))return;if(n.kind==="index"){u.delete(t),delete t[n.index];return}const o=_(t,n.key,n.value);o!==-1&&(u.delete(t),delete t[o])}function j(r,e){if(e.kind==="key")return Object.hasOwn(r,e.key)?r[e.key]:void 0;if(!Array.isArray(r))return;if(e.kind==="index")return r[e.index];const t=_(r,e.key,e.value);return t===-1?void 0:r[t]}function C(r,e,t,n){if(e.kind==="key"){const s=r;let i=s[e.key];return(!Object.hasOwn(s,e.key)||i===void 0)&&(i=O(t),l(s,e.key,i)),k(i,n)}if(e.kind==="index"){if(!Array.isArray(r))throw y(n);let s=r[e.index];return(!Object.hasOwn(r,e.index)||s===void 0)&&(u.delete(r),s=O(t),r[e.index]=s),k(s,n)}if(!Array.isArray(r))throw y(n);let o=_(r,e.key,e.value);if(o===-1){u.delete(r);const s=Object.create(null);s[e.key]=e.value,r.push(s),o=r.length-1}return k(r[o],n)}function S(r,e,t,n){if(e.kind==="key"){l(r,e.key,t);return}if(e.kind==="index"){if(!Array.isArray(r))throw y(n);u.delete(r),r[e.index]=t;return}if(!Array.isArray(r))throw y(n);const o=_(r,e.key,e.value);if(o!==-1){u.delete(r),r[o]=t;return}if(!a(t))throw new TypeError(`[Raph] New selector target at "${n}" must be an object.`);const s=t[e.key];if(Object.hasOwn(t,e.key)&&!Object.is(s,e.value))throw new TypeError(`[Raph] Selector target at "${n}" has a conflicting key.`);u.delete(r),r.push(Object.hasOwn(t,e.key)?t:{...t,[e.key]:e.value})}function O(r){return r.kind==="index"||r.kind==="selector"?[]:Object.create(null)}function D(){return Object.create(null)}function x(r){if(b(r))return r;throw new TypeError("[Raph] Root value must be an object or array.")}function k(r,e){if(b(r))return r;throw y(e)}function _(r,e,t){let n=u.get(r);const o=n==null?void 0:n.get(e);if(o)return o.get(t)??-1;const s=new Map;for(let i=0;i<r.length;i++){const c=r[i];if(a(c)&&Object.hasOwn(c,e)){const d=c[e];(d===null||typeof d=="string"||typeof d=="number"||typeof d=="boolean")&&!s.has(d)&&s.set(d,i)}}return n||(n=new Map,u.set(r,n)),n.set(e,s),s.get(t)??-1}function l(r,e,t){if(e==="__proto__"){Object.defineProperty(r,e,{configurable:!0,enumerable:!0,value:t,writable:!0});return}r[e]=t}function A(r){const e=Object.create(Object.getPrototypeOf(r));for(const t of Object.keys(r))l(e,t,r[t]);return e}function a(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}function b(r){return Array.isArray(r)||a(r)}function y(r){return new TypeError(`[Raph] Cannot traverse non-container data at "${r}".`)}exports.PathStore=m;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var o=Object.defineProperty;var d=(r,e,t)=>e in r?o(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var s=(r,e,t)=>d(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class a extends Error{constructor(e){super(`[Raph] Derived target is read-only: "${e}".`),this.name="RaphDerivedTargetWriteError"}}class h{constructor(e,t,i){s(this,"id");s(this,"options");s(this,"_kernel");s(this,"_removeRoutes");s(this,"_paused",!1);s(this,"_disposed",!1);s(this,"_status","idle");s(this,"_lastError",null);this._kernel=e,this.id=t,this.options=i}get paused(){return this._paused}get disposed(){return this._disposed}get status(){return this._status}get lastError(){return this._lastError}_recordSuccess(){this._status="success",this._lastError=null}_recordFailure(e){this._status="error",this._lastError=e instanceof Error?e:new Error(String(e))}pause(){this._assertAlive(),this._paused=!0}resume(){this._assertAlive(),this._paused=!1,this.recompute()}recompute(){this._assertAlive(),this._kernel._recomputeDerived(this)}dispose(){this._disposed||(this._disposed=!0,this._kernel._removeDerived(this),this.options.disposeTarget==="delete"&&this._kernel.delete(this.options.to))}_attachRoutes(e){this._removeRoutes=e}_detachRoutes(){const e=this._removeRoutes;if(this._removeRoutes=void 0,e!==void 0)for(const t of e)t()}_disposeFromKernel(){this._disposed=!0,this._removeRoutes=void 0}_assertAlive(){if(this._disposed)throw new Error(`[Raph] Derived "${this.id}" is disposed.`)}}exports.RaphDerivedHandle=h;exports.RaphDerivedTargetWriteError=a;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class s{constructor(r,a={}){this._kernel=r,this._binding=a}get(r,a,t){var e,i;return(i=(e=this._binding).assertReadable)==null||i.call(e),this._kernel.getMeta(r,a,t)}has(r,a,t){var e,i;return(i=(e=this._binding).assertReadable)==null||i.call(e),this._kernel.hasMeta(r,a,t)}set(r,a,t,e){var i,h;(h=(i=this._binding).assertWritable)==null||h.call(i),this._write(()=>this._kernel.setMeta(r,a,t,e),(e==null?void 0:e.invalidate)??!0)}merge(r,a,t,e){var i,h;(h=(i=this._binding).assertWritable)==null||h.call(i),this._write(()=>this._kernel.mergeMeta(r,a,t,e),(e==null?void 0:e.invalidate)??!0)}delete(r,a,t){var e,i;(i=(e=this._binding).assertWritable)==null||i.call(e),this._write(()=>this._kernel.deleteMeta(r,a,t),(t==null?void 0:t.invalidate)??!0)}watch(r,a,t={}){var e,i;if((i=(e=this._binding).assertReadable)==null||i.call(e),this._binding.watch===void 0)throw new Error("[RaphMeta] watch requires a runtime-bound Meta facade.");return this._binding.watch(r,a,t)}_write(r,a){const t=this._binding.runWrite;t===void 0?r():t(r,a)}}exports.RaphMeta=s;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
class n {
|
|
2
|
-
/**
|
|
3
|
-
* Создаёт metadata facade поверх указанного Kernel.
|
|
4
|
-
*/
|
|
5
|
-
constructor(r, a = {}) {
|
|
6
|
-
this._kernel = r, this._binding = a;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Возвращает значение по пути без создания отсутствующих данных.
|
|
10
|
-
*/
|
|
11
|
-
get(r, a, t) {
|
|
12
|
-
var e, i;
|
|
13
|
-
return (i = (e = this._binding).assertReadable) == null || i.call(e), this._kernel.getMeta(r, a, t);
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Проверяет наличие значения по указанному пути.
|
|
17
|
-
*/
|
|
18
|
-
has(r, a, t) {
|
|
19
|
-
var e, i;
|
|
20
|
-
return (i = (e = this._binding).assertReadable) == null || i.call(e), this._kernel.hasMeta(r, a, t);
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Записывает значение и публикует соответствующее изменение.
|
|
24
|
-
*/
|
|
25
|
-
set(r, a, t, e) {
|
|
26
|
-
var i, h;
|
|
27
|
-
(h = (i = this._binding).assertWritable) == null || h.call(i), this._write(
|
|
28
|
-
() => this._kernel.setMeta(r, a, t, e),
|
|
29
|
-
(e == null ? void 0 : e.invalidate) ?? !0
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Объединяет значение по пути и публикует соответствующее изменение.
|
|
34
|
-
*/
|
|
35
|
-
merge(r, a, t, e) {
|
|
36
|
-
var i, h;
|
|
37
|
-
(h = (i = this._binding).assertWritable) == null || h.call(i), this._write(
|
|
38
|
-
() => this._kernel.mergeMeta(r, a, t, e),
|
|
39
|
-
(e == null ? void 0 : e.invalidate) ?? !0
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Удаляет значение по пути и публикует изменение при наличии данных.
|
|
44
|
-
*/
|
|
45
|
-
delete(r, a, t) {
|
|
46
|
-
var e, i;
|
|
47
|
-
(i = (e = this._binding).assertWritable) == null || i.call(e), this._write(
|
|
48
|
-
() => this._kernel.deleteMeta(r, a, t),
|
|
49
|
-
(t == null ? void 0 : t.invalidate) ?? !0
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Подписывает callback на metadata-изменения и возвращает disposer.
|
|
54
|
-
*/
|
|
55
|
-
watch(r, a, t = {}) {
|
|
56
|
-
var e, i;
|
|
57
|
-
if ((i = (e = this._binding).assertReadable) == null || i.call(e), this._binding.watch === void 0)
|
|
58
|
-
throw new Error("[RaphMeta] watch requires a runtime-bound Meta facade.");
|
|
59
|
-
return this._binding.watch(r, a, t);
|
|
60
|
-
}
|
|
61
|
-
_write(r, a) {
|
|
62
|
-
const t = this._binding.runWrite;
|
|
63
|
-
t === void 0 ? r() : t(r, a);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
export {
|
|
67
|
-
n as RaphMeta
|
|
68
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var p=Object.defineProperty;var _=(n,e,t)=>e in n?p(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var a=(n,e,t)=>_(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./segment-key.cjs");function d(){return{children:new Map,namespaces:new Map,path:void 0}}class g{constructor(){a(this,"_root",d());a(this,"size",0)}get(e,t){const r=this._find(e);if(r!==void 0)return t===void 0?Object.fromEntries(r.namespaces):r.namespaces.get(t)}has(e,t){const r=this._find(e);return r===void 0?!1:t===void 0?r.namespaces.size!==0:r.namespaces.has(t)}set(e,t,r){const s=this._ensure(e);s.namespaces.has(t)||this.size++,s.namespaces.set(t,r),s.path=e}merge(e,t,r){const s=this.get(e,t);if(l(s)&&l(r)){for(const i of Object.keys(r))y(s,i,r[i]);return}this.set(e,t,r)}delete(e,t){var i;const r=this._findStack(e),s=(i=r.at(-1))==null?void 0:i.node;if(s===void 0)return!1;if(t===void 0){if(s.namespaces.size===0)return!1;this.size-=s.namespaces.size,s.namespaces.clear()}else{if(!s.namespaces.delete(t))return!1;this.size--}return this._pruneEmpty(r),!0}deleteSubtree(e){const t=o(e);if(t.length===0)return this.clear();let r=this._root;for(let c=0;c<t.length-1;c++){const u=r.children.get(t[c]);if(u===void 0)return[];r=u}const s=r.children.get(t.at(-1));if(s===void 0)return[];const i=h(s);return this.size-=f(s),r.children.delete(t.at(-1)),i}pruneMissing(e,t){const r=this._find(e);if(r===void 0)return[];const s=[];return this._pruneMissingNode(r,t,s),s}clear(){const e=h(this._root);return this._root.children.clear(),this._root.namespaces.clear(),this._root.path=void 0,this.size=0,e}_find(e){let t=this._root;for(const r of o(e)){const s=t.children.get(r);if(s===void 0)return;t=s}return t}_ensure(e){let t=this._root;for(const r of o(e)){let s=t.children.get(r);s===void 0&&(s=d(),t.children.set(r,s)),t=s}return t}_findStack(e){const t=[{key:void 0,node:this._root}];let r=this._root;for(const s of o(e)){const i=r.children.get(s);if(i===void 0)return[];t.push({key:s,node:i}),r=i}return t}_pruneEmpty(e){for(let t=e.length-1;t>0;t--){const r=e[t];if(r.node.namespaces.size!==0||r.node.children.size!==0)return;e[t-1].node.children.delete(r.key)}}_pruneMissingNode(e,t,r){for(const[s,i]of[...e.children])this._pruneMissingNode(i,t,r)&&e.children.delete(s);return e.path!==void 0&&e.namespaces.size!==0&&!t(e.path)&&(this.size-=e.namespaces.size,e.namespaces.clear(),r.push(e.path)),e!==this._root&&e.namespaces.size===0&&e.children.size===0}}function o(n){return n.segments().map(m.pathSegmentKey)}function h(n){const e=n.path!==void 0&&n.namespaces.size!==0?[n.path]:[];for(const t of n.children.values())e.push(...h(t));return e}function f(n){let e=n.namespaces.size;for(const t of n.children.values())e+=f(t);return e}function l(n){if(typeof n!="object"||n===null||Array.isArray(n))return!1;const e=Object.getPrototypeOf(n);return e===Object.prototype||e===null}function y(n,e,t){if(e!=="__proto__"){n[e]=t;return}Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:t,writable:!0})}exports.RaphMetaStore=g;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var j=Object.defineProperty;var S=(o,e,t)=>e in o?j(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var y=(o,e,t)=>S(o,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("./data-draft.cjs"),h=require("./data-path.cjs");class g{constructor(e=p(),t={}){y(this,"_root");y(this,"_options");y(this,"_indexes");this._root=x(e),this._options={arrayDelete:t.arrayDelete??"unset",autoCreate:t.autoCreate??!0,indexEnabled:t.indexEnabled??!0,indexStrategy:t.indexStrategy??"eager-all-keys"}}root(){return this._root}fork(){const e=new g({},this._options);return e._root=C.createDataDraft(this._root,t=>{var r;return(r=e._indexes)==null?void 0:r.delete(t)}).root,e}replaceRoot(e){this._root=x(e),this._indexes=void 0}options(e){e.arrayDelete!==void 0&&(this._options.arrayDelete=e.arrayDelete),e.autoCreate!==void 0&&(this._options.autoCreate=e.autoCreate),e.indexEnabled!==void 0&&(this._options.indexEnabled=e.indexEnabled),e.indexStrategy!==void 0&&(this._options.indexStrategy=e.indexStrategy),this._indexes=void 0}get(e,t){return this._read(h.parseDataPath(e,t)).value}has(e,t){return this._read(h.parseDataPath(e,t)).exists}set(e,t,r){const i=h.parseDataPath(e,r);if(i.segments.length===0){this.replaceRoot(x(t));return}let s=this._root,n;for(let a=0;a<i.segments.length-1;a++){const d=i.segments[a],c=i.segments[a+1],l=this._readOrCreateChild(s,d,c,i.canonical);s=l.value,n=l.indexedParent}this._writeSegment(s,i.segments[i.segments.length-1],t,i.canonical,n)}merge(e,t,r){const i=this.get(e,r);if(f(i)&&f(t)){for(const s of Object.keys(t))b(i,s,t[s]);this._indexes=void 0;return}this.set(e,t,r)}delete(e,t){const r=h.parseDataPath(e,t);if(r.segments.length===0){this._root=p(),this._indexes=void 0;return}let i=this._root;for(let n=0;n<r.segments.length-1;n++){if(!u(i))return;i=this._readSegment(i,r.segments[n])}if(!u(i))return;const s=r.segments[r.segments.length-1];if(s.kind==="key")delete i[s.key];else if(s.kind==="index"){if(!Array.isArray(i))return;this._options.arrayDelete==="splice"?i.splice(s.index,1):delete i[s.index]}else{if(!Array.isArray(i))return;const n=this._findSelector(i,s.key,s.value);if(n===-1)return;this._options.arrayDelete==="splice"?i.splice(n,1):delete i[n]}this._indexes=void 0}indexOf(e,t){const r=h.parseDataPath(e,t);let i=this._root;for(let s=0;s<r.segments.length;s++){const n=r.segments[s],a=s===r.segments.length-1;if(n.kind==="key"){if(!u(i)||!Object.hasOwn(i,n.key))return-1;i=i[n.key];continue}if(!Array.isArray(i))return-1;if(n.kind==="index"){if(!Object.hasOwn(i,n.index))return-1;if(a)return n.index;i=i[n.index];continue}const d=this._findSelector(i,n.key,n.value);if(d===-1)return-1;if(a)return d;i=i[d]}return-1}_read(e){let t=this._root;for(const r of e.segments)if(r.kind==="key"){if(!u(t)||!Object.hasOwn(t,r.key))return{exists:!1,value:void 0};t=t[r.key]}else if(r.kind==="index"){if(!Array.isArray(t)||!Object.hasOwn(t,r.index))return{exists:!1,value:void 0};t=t[r.index]}else{if(!Array.isArray(t))return{exists:!1,value:void 0};const i=this._findSelector(t,r.key,r.value);if(i===-1)return{exists:!1,value:void 0};t=t[i]}return{exists:!0,value:t}}_readSegment(e,t){if(t.kind==="key")return Object.hasOwn(e,t.key)?e[t.key]:void 0;if(!Array.isArray(e))return;if(t.kind==="index")return e[t.index];const r=this._findSelector(e,t.key,t.value);return r===-1?void 0:e[r]}_readOrCreateChild(e,t,r,i){if(t.kind==="key"){let n=e[t.key];if(!Object.hasOwn(e,t.key)||n===void 0){if(!this._options.autoCreate)throw _(i);n=v(r),b(e,t.key,n)}return{value:k(n,i)}}if(!Array.isArray(e))throw w(i);if(t.kind==="index"){let n=e[t.index];if(!Object.hasOwn(e,t.index)||n===void 0){if(!this._options.autoCreate)throw _(i);n=v(r),e[t.index]=n}return{value:k(n,i),indexedParent:{array:e,index:t.index}}}let s=this._findSelector(e,t.key,t.value);if(s===-1){if(!this._options.autoCreate)throw _(i);const n=Object.create(null);n[t.key]=t.value,e.push(n),s=e.length-1,this._invalidateArray(e)}return{value:k(e[s],i),indexedParent:{array:e,index:s}}}_writeSegment(e,t,r,i,s){if(t.kind==="key"){b(e,t.key,r),s!==void 0&&s.array[s.index]===e&&this._invalidateIndexKey(s.array,t.key);return}if(!Array.isArray(e))throw w(i);if(t.kind==="index"){e[t.index]=r,this._invalidateArray(e);return}if(!f(r))throw new TypeError(`[Raph] New selector target at "${i}" must be an object.`);if(Object.hasOwn(r,t.key)&&!Object.is(r[t.key],t.value))throw new TypeError(`[Raph] Selector target at "${i}" has a conflicting key.`);const n=this._findSelector(e,t.key,t.value);if(n===-1&&!this._options.autoCreate)throw _(i);const a=Object.hasOwn(r,t.key)?r:{...r,[t.key]:t.value};n===-1?e.push(a):e[n]=a,this._invalidateArray(e)}_invalidateArray(e){var t;(t=this._indexes)==null||t.delete(e)}_invalidateIndexKey(e,t){var i;const r=(i=this._indexes)==null?void 0:i.get(e);r!==void 0&&(r.delete(t),r.size===0&&this._indexes.delete(e))}_findSelector(e,t,r){var d;if(!this._options.indexEnabled)return O(e,t,r);const i=(d=this._indexes)==null?void 0:d.get(e);let s=i==null?void 0:i.get(t);s===void 0&&(s=this._createIndex(e,t));const n=s.get(r);if(n!==void 0&&f(e[n])&&Object.is(e[n][t],r))return n;const a=O(e,t,r);return a===-1?s.delete(r):s.set(r,a),a}_createIndex(e,t){const r=this._indexes??(this._indexes=new WeakMap);let i=r.get(e);if(i===void 0&&(i=new Map,r.set(e,i)),this._options.indexStrategy==="eager-all-keys")for(let n=0;n<e.length;n++){const a=e[n];if(f(a))for(const d of Object.keys(a)){const c=a[d];if(!A(c))continue;let l=i.get(d);l===void 0&&(l=new Map,i.set(d,l)),l.has(c)||l.set(c,n)}}let s=i.get(t);if(s!==void 0)return s;s=new Map;for(let n=0;n<e.length;n++){const a=e[n];if(!f(a))continue;const d=a[t];A(d)&&!s.has(d)&&s.set(d,n)}return i.set(t,s),s}}function O(o,e,t){for(let r=0;r<o.length;r++){const i=o[r];if(f(i)&&Object.hasOwn(i,e)&&Object.is(i[e],t))return r}return-1}function v(o){return o.kind==="index"||o.kind==="selector"?[]:p()}function p(){return Object.create(null)}function x(o){if(u(o))return o;throw new TypeError("[Raph] Root value must be an object or array.")}function k(o,e){if(u(o))return o;throw w(e)}function f(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}function u(o){return Array.isArray(o)||f(o)}function A(o){return o===null||typeof o=="string"||typeof o=="number"||typeof o=="boolean"}function b(o,e,t){if(e==="__proto__"){Object.defineProperty(o,e,{configurable:!0,enumerable:!0,value:t,writable:!0});return}o[e]=t}function w(o){return new TypeError(`[Raph] Cannot traverse non-container data at "${o}".`)}function _(o){return new Error(`[Raph] Cannot create missing container at "${o}" (autoCreate=false).`)}exports.DefaultDataAdapter=g;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function y(S,x){const m=new WeakMap,v=new WeakMap,b=(n,u,s=new Set)=>{if(!s.has(n)){s.add(n),n.changed.add(u),Array.isArray(n.source)&&x(n.proxy);for(const[c,l]of n.parents)for(const r of l)b(c,r,s)}},w=(n,u,s)=>{if(!n||typeof n!="object")return n;const c=Object.getPrototypeOf(n);let l=v.get(n)??m.get(n);if(!l){const r=n,g=Array.isArray(r),d=g?[]:Object.create(c);g&&(d.length=r.length),l={source:r,proxy:null,values:new Map,removed:new Set,changed:new Set,parents:new Map};const t=l,O=a=>!t.removed.has(a)&&(t.values.has(a)||Reflect.has(r,a)),i=a=>t.removed.has(a)?void 0:t.values.has(a)?t.values.get(a):Reflect.get(r,a);t.proxy=new Proxy(d,{get:(a,e)=>w(i(e),t,e),has:(a,e)=>O(e),set:(a,e,f)=>{if(g&&e==="length"){const o=Number(f);if(!Number.isInteger(o)||o<0||o>4294967295)throw new RangeError("Invalid array length");for(let h=o;h<Number(i("length"));h++)t.removed.add(String(h)),t.values.delete(String(h));d.length=o}else if(g&&typeof e=="string"&&/^(?:0|[1-9]\d*)$/.test(e)){const o=Number(e);o<4294967295&&o>=Number(i("length"))&&(t.values.set("length",o+1),d.length=o+1)}return t.values.set(e,f),t.removed.delete(e),b(t,e),!0},deleteProperty:(a,e)=>g&&e==="length"?!1:(t.values.delete(e),t.removed.add(e),b(t,e),!0),ownKeys:()=>[...new Set([...Reflect.ownKeys(r),...t.values.keys()])].filter(a=>!t.removed.has(a)),getOwnPropertyDescriptor:(a,e)=>{if(g&&e==="length")return{value:i(e),writable:!0,enumerable:!1,configurable:!1};const f=Object.getOwnPropertyDescriptor(r,e);if(!(t.removed.has(e)||!f&&!t.values.has(e)))return{value:w(i(e),t,e),writable:!0,enumerable:(f==null?void 0:f.enumerable)??!0,configurable:!0}}}),m.set(r,t),v.set(t.proxy,t)}if(u&&s!==void 0){let r=l.parents.get(u);r||(r=new Set,l.parents.set(u,r)),r.add(s)}return l.proxy};return{root:w(S),unchangedArray(n,u){const s=v.get(n);if(!s)return null;for(const c of s.changed){if(s.values.has(c)||s.removed.has(c))return null;const l=m.get(s.source[c]);if(l!=null&&l.changed.has(u))return null}return s.source}}}exports.createDataDraft=y;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var E=Object.defineProperty;var M=(t,e,n)=>e in t?E(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var o=(t,e,n)=>M(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=2e4;let m,w;const h=class h{constructor(e,n){o(this,"_canonical");o(this,"_segments");o(this,"_exact");o(this,"_mask");this._canonical=e,this._segments=Object.freeze(n.map(r=>Object.freeze({...r})))}static from(e,n){return e instanceof h?e:typeof e=="string"?this.fromString(e,n):this.fromPlain(e)}static fromString(e,n){const r=p(e,n==null?void 0:n.vars,!0,(n==null?void 0:n.wildcardDynamic)===!0,!0),i=this._cache??(this._cache=new Map),s=i.get(r.canonical);if(s!==void 0)return s;i.size>=y&&i.clear();const c=new h(r.canonical,r.segments);return i.set(r.canonical,c),c}static fromPlain(e){const r=(Array.isArray(e.segs)?e.segs:[]).map(F);return new h(k(r),r)}toPlain(){return{segs:this._segments.map(e=>e.kind==="key"?{t:"key",k:e.key}:e.kind==="index"?{t:"idx",i:e.index}:e.kind==="selector"?{t:"param",pk:e.key,pv:e.value}:{t:"wc",indexed:e.indexed}),deepOnTail:S(this._segments)}}toStringPath(){return this._canonical}toString(){return this._canonical}segments(){return this._segments}static match(e,n){const r=this.from(e)._segments,i=this.from(n)._segments;let s=0;for(;s<r.length;s++){const c=r[s];if(c.kind==="wildcard"&&!c.indexed&&s===r.length-1)return!0;const a=i[s];if(a===void 0||!W(c,a))return!1}return s===i.length}_asExact(){for(const e of this._segments)if(e.kind==="wildcard")throw $(this._canonical);return this._exact??(this._exact={canonical:this._canonical,segments:this._segments})}_asMask(){for(let n=0;n<this._segments.length-1;n++){const r=this._segments[n];if(r.kind==="wildcard"&&!r.indexed)throw new TypeError(`[Raph] Dot wildcard must be the final mask segment: "${this._canonical}".`)}const e=S(this._segments);return this._mask??(this._mask={canonical:this._canonical,deep:e,segments:e?this._segments.slice(0,-1):this._segments})}};o(h,"_cache");let d=h;function T(t,e){if(!(e!=null&&e.vars)){const i=m==null?void 0:m.get(t);if(i!==void 0)return i}if(typeof t!="string")return O(t,e);const n=p(t,e==null?void 0:e.vars,!1,!1,!0),r={canonical:n.canonical,segments:n.segments};if(!(e!=null&&e.vars)){const i=m??(m=new Map);i.size>=y&&i.clear(),i.set(t,r)}return r}function R(t){const e=w==null?void 0:w.get(t);if(e!==void 0)return e;if(typeof t!="string")return N(t);const n=p(t,void 0,!0,!1,!0);for(let a=0;a<n.segments.length-1;a++){const l=n.segments[a];if(l.kind==="wildcard"&&!l.indexed)throw new TypeError(`[Raph] Dot wildcard must be the final mask segment: "${t}".`)}const r=n.segments[n.segments.length-1],i=(r==null?void 0:r.kind)==="wildcard"&&!r.indexed,s={canonical:n.canonical,deep:i,segments:i?n.segments.slice(0,-1):n.segments},c=w??(w=new Map);return c.size>=y&&c.clear(),c.set(t,s),s}function O(t,e){const n=d.from(t,e)._asExact();if(t instanceof d&&!(e!=null&&e.vars)){const r=m??(m=new Map);r.size>=y&&r.clear(),r.set(t,n)}return n}function N(t){const e=d.from(t)._asMask();if(t instanceof d){const n=w??(w=new Map);n.size>=y&&n.clear(),n.set(t,e)}return e}function j(t){if(t.segments.length===0)return["*"];const e=[`${t.canonical}.*`];for(let n=1;n<t.segments.length;n++)e.push(k(t.segments.slice(0,n)));return e}function p(t,e,n,r=!1,i=!1){const s=t.trim();if(s.length===0){if(i)return{canonical:"",segments:[]};throw new TypeError("[Raph] Data path must not be empty.")}const c=[];let a=0,l=!0;for(;a<s.length;){const _=s[a];if(_==="."){if(l)throw f(t);l=!0,a++;continue}if(_==="["){const v=A(s,a);c.push(z(s.slice(a+1,v),e,n,r)),a=v+1,l=!1;continue}if(!l)throw f(t);let u=a;for(;u<s.length&&s[u]!=="."&&s[u]!=="[";)u++;const g=s.slice(a,u).trim();if(g.length===0)throw f(t);if(g==="*"){if(!n)throw $(t);c.push({kind:"wildcard",indexed:!1})}else r&&g.startsWith("$")&&!x(g.slice(1),e)?c.push({kind:"wildcard",indexed:!1}):c.push({kind:"key",key:V(g,e)});a=u,l=!1}if(l||c.length===0)throw f(t);return{canonical:k(c),segments:c}}function A(t,e){let n,r=1;for(let i=e+1;i<t.length;i++){const s=t[i];if(s==="\\"){i++;continue}if(n!==void 0){s===n&&(n=void 0);continue}if(s==='"'||s==="'"){n=s;continue}if(s==="["){r++;continue}if(s==="]"&&--r===0)return i}throw f(t)}function z(t,e,n,r){const i=t.trim();if(i==="*"){if(!n)throw $(`[${t}]`);return{kind:"wildcard",indexed:!0}}if(/^\d+$/.test(i))return{kind:"index",index:Number(i)};if(/^\$[A-Z_$][\w$]*$/i.test(i)){if(r&&!x(i.slice(1),e))return{kind:"wildcard",indexed:!0};const l=b(i.slice(1),e);if(!Number.isInteger(l)||l<0)throw new TypeError(`[Raph] Index variable "${i}" must be a non-negative integer.`);return{kind:"index",index:l}}const s=D(i);if(s===-1)throw f(`[${t}]`);const c=i.slice(0,s).trim(),a=i.slice(s+1).trim();if(!c||!a)throw f(`[${t}]`);return r&&Z(a,e)?{kind:"wildcard",indexed:!0}:{kind:"selector",key:c,value:I(a,e)}}function D(t){let e;for(let n=0;n<t.length;n++){const r=t[n];if(r==="\\"){n++;continue}if(e!==void 0){r===e&&(e=void 0);continue}if(r==='"'||r==="'")e=r;else if(r==="=")return n}return-1}function I(t,e){if(/^\$[A-Z_$][\w$]*$/i.test(t)){const n=b(t.slice(1),e);if(n===null||typeof n=="string"||typeof n=="boolean"||typeof n=="number"&&Number.isFinite(n))return n;throw new TypeError(`[Raph] Selector variable "${t}" must be scalar.`)}if(t[0]==='"'||t[0]==="'")return q(t);if(/^-?(?:\d+(?:\.\d*)?|\.\d+)$/.test(t)){const n=Number(t);if(Number.isFinite(n))return n}return t==="true"?!0:t==="false"?!1:t==="null"?null:t}function q(t){const e=t[0];if(t.length<2||t[t.length-1]!==e)throw f(t);if(e==='"')try{const r=JSON.parse(t);if(typeof r=="string")return r}catch{throw f(t)}let n="";for(let r=1;r<t.length-1;r++){const i=t[r];if(i==="\\"){if(r++,r>=t.length-1)throw f(t);n+=t[r]}else n+=i}return n}function V(t,e){if(!t.startsWith("$"))return t;const n=b(t.slice(1),e);if(typeof n!="string"&&typeof n!="number")throw new TypeError(`[Raph] Key variable "${t}" must be a string or number.`);const r=String(n);if(!r||r.includes(".")||r.includes("[")||r.includes("]"))throw new TypeError(`[Raph] Key variable "${t}" contains path syntax.`);return r}function b(t,e){if(!x(t,e))throw new TypeError(`[Raph] Missing path variable "${t}".`);return e[t]}function x(t,e){return e!==void 0&&Object.hasOwn(e,t)}function Z(t,e){for(const n of t.matchAll(/\$([A-Z_$][\w$]*)/gi))if(!x(n[1],e))return!0;return!1}function F(t){if(typeof t!="object"||t===null)throw P();const e=t;if(e.t==="key"&&typeof e.k=="string")return{kind:"key",key:e.k};if(e.t==="idx"&&typeof e.i=="number"&&Number.isInteger(e.i)&&e.i>=0)return{kind:"index",index:e.i};if(e.t==="wc")return{kind:"wildcard",indexed:e.indexed===!0};if(e.t==="param"&&typeof e.pk=="string"&&K(e.pv))return{kind:"selector",key:e.pk,value:e.pv};throw P()}function K(t){return t===null||typeof t=="string"||typeof t=="boolean"||typeof t=="number"&&Number.isFinite(t)}function S(t){const e=t[t.length-1];return(e==null?void 0:e.kind)==="wildcard"&&!e.indexed}function W(t,e){return t.kind==="wildcard"?!t.indexed||e.kind==="index"||e.kind==="selector":t.kind!==e.kind?!1:t.kind==="key"?t.key===e.key:t.kind==="index"?t.index===e.index:t.key===e.key&&Object.is(t.value,e.value)}function k(t){let e="";for(const n of t)n.kind==="key"?e+=e?`.${n.key}`:n.key:n.kind==="index"?e+=`[${n.index}]`:n.kind==="selector"?e+=`[${n.key}=${B(n.value)}]`:e+=n.indexed?"[*]":e?".*":"*";return e}function B(t){return typeof t=="string"?JSON.stringify(t):String(t)}function f(t){return new TypeError(`[Raph] Invalid data path "${t}".`)}function P(){return new TypeError("[Raph] Invalid plain DataPath representation.")}function $(t){return new TypeError(`[Raph] Wildcard is only allowed in watch masks: "${t}".`)}exports.DataPath=d;exports.parseDataPath=T;exports.parsePathMask=R;exports.pathRelationMasks=j;
|