@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,42 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { parseDataPath as p } from "./data-path.utils.js";
|
|
2
|
+
import { DataPath as B } from "./DataPath.js";
|
|
3
|
+
import { validateFullFilter as I, cloneMaterializedValue as M, validateFullCollection as E, collectionIndex as w, collectionError as D, indexesAreStale as x, validateIncrementalCollection as F, collectionKeys as b, keyedPath as C, filterError as R, validateIncrementalFilter as K } from "./derived/derived-collection.utils.js";
|
|
4
|
+
import { DerivedRegistry as O } from "./derived/DerivedRegistry.js";
|
|
5
|
+
import { RaphDerivedHandle as S, RaphDerivedTargetWriteError as T } from "./derived/RaphDerivedHandle.js";
|
|
6
|
+
import { MetaController as W } from "./meta/MetaController.js";
|
|
7
|
+
import { AdapterPathStore as z } from "./storage/AdapterPathStore.js";
|
|
8
|
+
import { DefaultDataAdapter as q } from "./storage/DefaultDataAdapter.js";
|
|
9
|
+
import { PathStore as N } from "./storage/PathStore.js";
|
|
10
|
+
class P {
|
|
11
|
+
// Формирует локальный id для Kernel без явно заданного имени.
|
|
12
|
+
static _kernelCounter = 0;
|
|
13
|
+
// Публикует стабильную identity data/meta owner.
|
|
14
|
+
id;
|
|
15
|
+
// Лениво создают независимые data, derived, runtime и metadata controllers.
|
|
16
|
+
_paths;
|
|
17
|
+
_derivedController;
|
|
18
|
+
_runtimes;
|
|
19
|
+
_metaController;
|
|
20
|
+
// Что читает `_openSoleRuntimeBatch()`: единственный присоединённый Runtime
|
|
21
|
+
// и владелец batch boundary встроенного store. Первое пусто, пока Runtime
|
|
22
|
+
// нет либо их несколько; второе — у store над adapter и после dispose.
|
|
23
|
+
_soleRuntime;
|
|
24
|
+
_pathBatch;
|
|
25
|
+
// Защищают batch stabilization и записи в derived targets.
|
|
26
|
+
_batchDepth = 0;
|
|
27
|
+
_runtimeMutationDepth = 0;
|
|
28
|
+
_stabilizing = !1;
|
|
29
|
+
_derivedWriteDepth = 0;
|
|
13
30
|
/**
|
|
14
31
|
* Создаёт data/meta owner с независимым lifecycle и derived registry.
|
|
15
32
|
*/
|
|
16
33
|
constructor(e = {}) {
|
|
17
|
-
|
|
18
|
-
p(this, "id");
|
|
19
|
-
// Лениво создают независимые data, derived, runtime и metadata controllers.
|
|
20
|
-
p(this, "_paths");
|
|
21
|
-
p(this, "_derivedController");
|
|
22
|
-
p(this, "_runtimes");
|
|
23
|
-
p(this, "_metaController");
|
|
24
|
-
// Защищают transaction stabilization и записи в derived targets.
|
|
25
|
-
p(this, "_transactionDepth", 0);
|
|
26
|
-
p(this, "_stabilizing", !1);
|
|
27
|
-
p(this, "_derivedWriteDepth", 0);
|
|
28
|
-
if (this.id = e.id ?? `kernel-${x._kernelCounter++}`, e.adapter !== void 0) {
|
|
34
|
+
if (this.id = e.id ?? `kernel-${P._kernelCounter++}`, e.adapter !== void 0) {
|
|
29
35
|
if (e.initial !== void 0 || e.adapterOptions !== void 0)
|
|
30
36
|
throw new TypeError("[Raph] A custom adapter cannot be combined with initial or adapterOptions.");
|
|
31
|
-
this._paths = new
|
|
37
|
+
this._paths = new z(e.adapter);
|
|
32
38
|
} else if (e.adapterOptions !== void 0)
|
|
33
|
-
this._paths = new
|
|
39
|
+
this._paths = new z(new q(
|
|
34
40
|
e.initial,
|
|
35
41
|
e.adapterOptions
|
|
36
42
|
));
|
|
37
43
|
else {
|
|
38
|
-
const t = this._paths = new
|
|
39
|
-
e.initial !== void 0 && t.set("", e.initial);
|
|
44
|
+
const t = this._paths = new N();
|
|
45
|
+
this._pathBatch = t._batchHub, e.initial !== void 0 && t.set("", e.initial);
|
|
40
46
|
}
|
|
41
47
|
}
|
|
42
48
|
/**
|
|
@@ -49,12 +55,11 @@ const x = class x {
|
|
|
49
55
|
* Формирует диагностический снимок materialized derived registry.
|
|
50
56
|
*/
|
|
51
57
|
getDerivedSnapshot() {
|
|
52
|
-
var t;
|
|
53
58
|
const e = this._derivedController;
|
|
54
59
|
return {
|
|
55
|
-
registrations:
|
|
56
|
-
errors: [...
|
|
57
|
-
pending:
|
|
60
|
+
registrations: e?.size ?? 0,
|
|
61
|
+
errors: [...e?.values() ?? []].filter((t) => t.status === "error").length,
|
|
62
|
+
pending: e?.pending?.size ?? 0,
|
|
58
63
|
stabilizing: this._stabilizing
|
|
59
64
|
};
|
|
60
65
|
}
|
|
@@ -80,10 +85,13 @@ const x = class x {
|
|
|
80
85
|
* Записывает значение и публикует соответствующее изменение.
|
|
81
86
|
*/
|
|
82
87
|
set(e, t, r) {
|
|
83
|
-
|
|
88
|
+
if (this._runtimeMutationDepth === 0 && this._runtimes !== void 0) {
|
|
89
|
+
this._withAttachedRuntimeBoundary(() => this.set(e, t, r));
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
84
92
|
this._assertWritablePath("set", e, t, r);
|
|
85
93
|
const i = this._store;
|
|
86
|
-
if ((
|
|
94
|
+
if ((this._metaController?.size ?? 0) === 0) {
|
|
87
95
|
if (this._derivedController === void 0) {
|
|
88
96
|
i.set(e, t, r);
|
|
89
97
|
return;
|
|
@@ -99,10 +107,13 @@ const x = class x {
|
|
|
99
107
|
* Объединяет значение по пути и публикует соответствующее изменение.
|
|
100
108
|
*/
|
|
101
109
|
merge(e, t, r) {
|
|
102
|
-
|
|
110
|
+
if (this._runtimeMutationDepth === 0 && this._runtimes !== void 0) {
|
|
111
|
+
this._withAttachedRuntimeBoundary(() => this.merge(e, t, r));
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
103
114
|
this._assertWritablePath("merge", e, t, r);
|
|
104
115
|
const i = this._store;
|
|
105
|
-
if ((
|
|
116
|
+
if ((this._metaController?.size ?? 0) === 0) {
|
|
106
117
|
if (this._derivedController === void 0) {
|
|
107
118
|
i.merge(e, t, r);
|
|
108
119
|
return;
|
|
@@ -118,10 +129,13 @@ const x = class x {
|
|
|
118
129
|
* Удаляет значение по пути и публикует изменение при наличии данных.
|
|
119
130
|
*/
|
|
120
131
|
delete(e, t) {
|
|
121
|
-
|
|
132
|
+
if (this._runtimeMutationDepth === 0 && this._runtimes !== void 0) {
|
|
133
|
+
this._withAttachedRuntimeBoundary(() => this.delete(e, t));
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
122
136
|
this._assertWritablePath("delete", e, void 0, t);
|
|
123
137
|
const r = this._store;
|
|
124
|
-
if ((
|
|
138
|
+
if ((this._metaController?.size ?? 0) === 0) {
|
|
125
139
|
if (this._derivedController === void 0) {
|
|
126
140
|
r.delete(e, t);
|
|
127
141
|
return;
|
|
@@ -131,41 +145,71 @@ const x = class x {
|
|
|
131
145
|
}
|
|
132
146
|
r.has(e, t) && this._mutateWithMetaLifecycle(() => {
|
|
133
147
|
this._derivedController === void 0 ? r.delete(e, t) : this._mutateDerived(r, "delete", e, void 0, t);
|
|
134
|
-
const
|
|
135
|
-
this._metaController.deleteSubtree(
|
|
148
|
+
const i = this._metaPath(e, t);
|
|
149
|
+
this._metaController.deleteSubtree(i, "owner-delete"), this._pruneMissingMetaOwners(i, "owner-delete");
|
|
136
150
|
});
|
|
137
151
|
}
|
|
138
152
|
/**
|
|
139
|
-
* Выполняет операцию в общей синхронной
|
|
153
|
+
* Выполняет операцию в общей синхронной batch boundary.
|
|
140
154
|
*/
|
|
141
|
-
|
|
142
|
-
|
|
155
|
+
batch(e) {
|
|
156
|
+
if (this._runtimeMutationDepth === 0 && this._runtimes !== void 0)
|
|
157
|
+
return this._withAttachedRuntimeBoundary(() => this.batch(e));
|
|
143
158
|
const t = this._store;
|
|
144
|
-
if (this._derivedController === void 0 && !
|
|
145
|
-
return t.
|
|
146
|
-
|
|
147
|
-
if (r !== void 0)
|
|
148
|
-
for (const o of r)
|
|
149
|
-
(v = o._beginKernelTransaction) == null || v.call(o);
|
|
150
|
-
let i, s, a = !1;
|
|
159
|
+
if (this._derivedController === void 0 && !this._metaController?.hasWatchers)
|
|
160
|
+
return t.batch(e);
|
|
161
|
+
let r, i, s = !1;
|
|
151
162
|
try {
|
|
152
|
-
|
|
163
|
+
r = t.batch(() => this._runDerivedBatch(e));
|
|
153
164
|
} catch (o) {
|
|
154
|
-
|
|
165
|
+
s = !0, i = o;
|
|
155
166
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
if (s)
|
|
168
|
+
throw i;
|
|
169
|
+
return r;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Открывает то же, что `batch()`, для единственного присоединённого Runtime
|
|
173
|
+
* без closure операции и без массивов: границу этого Runtime и path batch.
|
|
174
|
+
* Возвращает владельца path batch, которого вызывающий передаёт в
|
|
175
|
+
* `_closeSoleRuntimeBatch()` после операции.
|
|
176
|
+
*
|
|
177
|
+
* Возвращает `undefined` и ничего не открывает в любом другом состоянии:
|
|
178
|
+
* Kernel разделяют несколько Runtime, граница Runtime уже открыта, есть
|
|
179
|
+
* derived handles либо metadata watchers, store построен над adapter. Тогда
|
|
180
|
+
* вызывающий исполняет `batch()`. Состояние читается при входе, как в
|
|
181
|
+
* `batch()`: то, что появилось во время операции, выход не меняет.
|
|
182
|
+
* @internal
|
|
183
|
+
*/
|
|
184
|
+
_openSoleRuntimeBatch(e) {
|
|
185
|
+
const t = this._pathBatch;
|
|
186
|
+
if (!(this._soleRuntime !== e || t === void 0 || this._runtimeMutationDepth !== 0 || this._derivedController !== void 0 || this._metaController?.hasWatchers === !0))
|
|
187
|
+
return this._runtimeMutationDepth++, e._beginKernelBatch?.(), t._openBatch(), t;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Закрывает границу, открытую `_openSoleRuntimeBatch()`, в порядке `batch()`:
|
|
191
|
+
* публикация path events, затем граница Runtime. Бросает то же, что бросил бы
|
|
192
|
+
* `batch()` с этой операцией; после успешного выхода возвращает управление.
|
|
193
|
+
* @internal
|
|
194
|
+
*/
|
|
195
|
+
_closeSoleRuntimeBatch(e, t, r, i) {
|
|
196
|
+
let s = r, o = i;
|
|
197
|
+
try {
|
|
198
|
+
t._closeBatch(r, i);
|
|
199
|
+
} catch (n) {
|
|
200
|
+
s = !0, o = n;
|
|
201
|
+
}
|
|
202
|
+
this._runtimeMutationDepth--;
|
|
203
|
+
try {
|
|
204
|
+
e._endKernelBatch?.();
|
|
205
|
+
} catch (n) {
|
|
206
|
+
throw s ? new AggregateError(
|
|
207
|
+
[o, n],
|
|
208
|
+
"[Raph] Kernel mutation and Runtime publication failed."
|
|
209
|
+
) : n;
|
|
210
|
+
}
|
|
211
|
+
if (s)
|
|
212
|
+
throw o;
|
|
169
213
|
}
|
|
170
214
|
/**
|
|
171
215
|
* Подписывает callback на подходящие изменения и возвращает disposer.
|
|
@@ -177,20 +221,22 @@ const x = class x {
|
|
|
177
221
|
* Возвращает metadata указанного data-owner.
|
|
178
222
|
*/
|
|
179
223
|
getMeta(e, t, r) {
|
|
180
|
-
|
|
181
|
-
return this._store, t !== void 0 && this._assertMetaNamespace(t), (i = this._metaController) == null ? void 0 : i.get(this._metaPath(e, r), t);
|
|
224
|
+
return this._store, t !== void 0 && this._assertMetaNamespace(t), this._metaController?.get(this._metaPath(e, r), t);
|
|
182
225
|
}
|
|
183
226
|
/**
|
|
184
227
|
* Проверяет наличие metadata у указанного data-owner.
|
|
185
228
|
*/
|
|
186
229
|
hasMeta(e, t, r) {
|
|
187
|
-
|
|
188
|
-
return this._store, t !== void 0 && this._assertMetaNamespace(t), ((i = this._metaController) == null ? void 0 : i.has(this._metaPath(e, r), t)) ?? !1;
|
|
230
|
+
return this._store, t !== void 0 && this._assertMetaNamespace(t), this._metaController?.has(this._metaPath(e, r), t) ?? !1;
|
|
189
231
|
}
|
|
190
232
|
/**
|
|
191
233
|
* Записывает metadata указанного data-owner.
|
|
192
234
|
*/
|
|
193
235
|
setMeta(e, t, r, i) {
|
|
236
|
+
if (this._runtimeMutationDepth === 0 && this._runtimes !== void 0) {
|
|
237
|
+
this._withAttachedRuntimeBoundary(() => this.setMeta(e, t, r, i));
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
194
240
|
this._assertMetaNamespace(t);
|
|
195
241
|
const s = this._exactMetaPath(e, i);
|
|
196
242
|
this._assertMetaOwner(s), this._metadata.set(s, t, r, i);
|
|
@@ -199,6 +245,10 @@ const x = class x {
|
|
|
199
245
|
* Объединяет metadata указанного data-owner.
|
|
200
246
|
*/
|
|
201
247
|
mergeMeta(e, t, r, i) {
|
|
248
|
+
if (this._runtimeMutationDepth === 0 && this._runtimes !== void 0) {
|
|
249
|
+
this._withAttachedRuntimeBoundary(() => this.mergeMeta(e, t, r, i));
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
202
252
|
this._assertMetaNamespace(t);
|
|
203
253
|
const s = this._exactMetaPath(e, i);
|
|
204
254
|
this._assertMetaOwner(s), this._metadata.merge(s, t, r, i);
|
|
@@ -207,10 +257,13 @@ const x = class x {
|
|
|
207
257
|
* Удаляет metadata указанного data-owner.
|
|
208
258
|
*/
|
|
209
259
|
deleteMeta(e, t, r) {
|
|
210
|
-
|
|
260
|
+
if (this._runtimeMutationDepth === 0 && this._runtimes !== void 0) {
|
|
261
|
+
this._withAttachedRuntimeBoundary(() => this.deleteMeta(e, t, r));
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
211
264
|
t !== void 0 && this._assertMetaNamespace(t);
|
|
212
265
|
const i = this._exactMetaPath(e, r);
|
|
213
|
-
|
|
266
|
+
this._metaController?.delete(i, t, r);
|
|
214
267
|
}
|
|
215
268
|
/**
|
|
216
269
|
* Подписывает runtime adapter на metadata-события Kernel.
|
|
@@ -223,33 +276,34 @@ const x = class x {
|
|
|
223
276
|
* Создаёт управляемое derived-представление source path в target path.
|
|
224
277
|
*/
|
|
225
278
|
derive(e) {
|
|
226
|
-
var l, v, _;
|
|
227
279
|
if (this._store, e.strategy !== void 0 && e.strategy.kind !== "full" && e.strategy.kind !== "collection-by-key" && e.strategy.kind !== "filter-by-key")
|
|
228
280
|
throw new Error(`[Raph] Unsupported derived strategy "${String(e.strategy.kind)}".`);
|
|
229
|
-
if (e.id !== void 0 &&
|
|
281
|
+
if (e.id !== void 0 && this._derivedController?.has(e.id))
|
|
230
282
|
throw new Error(`[Raph] Duplicate derived id "${e.id}".`);
|
|
231
|
-
const t =
|
|
232
|
-
if (
|
|
283
|
+
const t = p(e.from), r = p(e.to);
|
|
284
|
+
if (A(t, r))
|
|
233
285
|
throw new Error("[Raph] Derived source and target must not overlap.");
|
|
234
|
-
const i = this._derivedController ?? new
|
|
286
|
+
const i = this._derivedController ?? new O(), s = e.id ?? i.nextId(), o = {
|
|
235
287
|
...e,
|
|
236
288
|
from: t.canonical,
|
|
237
289
|
to: r.canonical
|
|
238
|
-
},
|
|
239
|
-
this._derivedController = i, i.register(
|
|
290
|
+
}, n = new S(this, s, o), c = e.strategy?.kind === "collection-by-key" || e.strategy?.kind === "filter-by-key" ? e.strategy : void 0;
|
|
291
|
+
this._derivedController = i, i.register(n, t, c);
|
|
240
292
|
try {
|
|
241
|
-
e.immediate !== !1 &&
|
|
242
|
-
} catch (
|
|
243
|
-
throw this._removeDerived(
|
|
293
|
+
e.immediate !== !1 && n.recompute();
|
|
294
|
+
} catch (l) {
|
|
295
|
+
throw this._removeDerived(n), n._disposeFromKernel(), l;
|
|
244
296
|
}
|
|
245
|
-
return
|
|
297
|
+
return n;
|
|
246
298
|
}
|
|
247
299
|
/**
|
|
248
300
|
* Регистрирует runtime, разделяющий этот Kernel.
|
|
249
301
|
* @internal
|
|
250
302
|
*/
|
|
251
303
|
_attachRuntime(e) {
|
|
252
|
-
this._store
|
|
304
|
+
this._store;
|
|
305
|
+
const t = this._runtimes ??= /* @__PURE__ */ new Set();
|
|
306
|
+
t.add(e), this._soleRuntime = t.size === 1 ? e : void 0;
|
|
253
307
|
}
|
|
254
308
|
/**
|
|
255
309
|
* Удаляет runtime из shared Kernel registry.
|
|
@@ -257,24 +311,23 @@ const x = class x {
|
|
|
257
311
|
*/
|
|
258
312
|
_detachRuntime(e) {
|
|
259
313
|
const t = this._runtimes;
|
|
260
|
-
t !== void 0 && (t.delete(e), t.size === 0 && (this._runtimes = void 0));
|
|
314
|
+
t !== void 0 && (t.delete(e), t.size === 0 && (this._runtimes = void 0), this._soleRuntime = t.size === 1 ? t.values().next().value : void 0);
|
|
261
315
|
}
|
|
262
316
|
/**
|
|
263
317
|
* Освобождает shared runtimes, derived handles и data/meta state Kernel.
|
|
264
318
|
*/
|
|
265
319
|
dispose() {
|
|
266
|
-
var t, r;
|
|
267
320
|
if (this._paths === void 0)
|
|
268
321
|
return;
|
|
269
322
|
const e = [];
|
|
270
323
|
if (this._runtimes !== void 0)
|
|
271
|
-
for (const
|
|
324
|
+
for (const t of [...this._runtimes])
|
|
272
325
|
try {
|
|
273
|
-
|
|
274
|
-
} catch (
|
|
275
|
-
e.push(
|
|
326
|
+
t.dispose();
|
|
327
|
+
} catch (r) {
|
|
328
|
+
e.push(r);
|
|
276
329
|
}
|
|
277
|
-
if (this._runtimes = void 0,
|
|
330
|
+
if (this._runtimes = void 0, this._soleRuntime = void 0, this._derivedController?.dispose(), this._derivedController = void 0, this._metaController?.dispose(), this._metaController = void 0, this._paths = void 0, this._pathBatch = void 0, e.length === 1)
|
|
278
331
|
throw e[0];
|
|
279
332
|
if (e.length > 1)
|
|
280
333
|
throw new AggregateError(e, `[Raph] Kernel "${this.id}" disposal failed.`);
|
|
@@ -306,24 +359,60 @@ const x = class x {
|
|
|
306
359
|
throw new Error(`[Raph] Kernel "${this.id}" is disposed.`);
|
|
307
360
|
}
|
|
308
361
|
get _metadata() {
|
|
309
|
-
return this._store, this._metaController
|
|
362
|
+
return this._store, this._metaController ??= new W(
|
|
310
363
|
this,
|
|
311
364
|
(e) => this.has(e),
|
|
312
|
-
() => this.
|
|
313
|
-
)
|
|
365
|
+
() => this._batchDepth !== 0 || this._stabilizing
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
/** Keeps every attached Runtime quiescent until one Kernel publication completes. */
|
|
369
|
+
_withAttachedRuntimeBoundary(e) {
|
|
370
|
+
const t = this._runtimes === void 0 ? [] : [...this._runtimes];
|
|
371
|
+
if (t.length === 0)
|
|
372
|
+
return e();
|
|
373
|
+
const r = [], i = [];
|
|
374
|
+
let s, o = !1;
|
|
375
|
+
this._runtimeMutationDepth++;
|
|
376
|
+
try {
|
|
377
|
+
for (const n of t)
|
|
378
|
+
n._beginKernelBatch?.(), r.push(n);
|
|
379
|
+
try {
|
|
380
|
+
s = e();
|
|
381
|
+
} catch (n) {
|
|
382
|
+
o = !0, i.push(n);
|
|
383
|
+
}
|
|
384
|
+
} catch (n) {
|
|
385
|
+
o = !0, i.push(n);
|
|
386
|
+
} finally {
|
|
387
|
+
this._runtimeMutationDepth--;
|
|
388
|
+
for (let n = r.length - 1; n >= 0; n--)
|
|
389
|
+
try {
|
|
390
|
+
r[n]._endKernelBatch?.();
|
|
391
|
+
} catch (c) {
|
|
392
|
+
i.push(c);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
if (i.length === 1)
|
|
396
|
+
throw i[0];
|
|
397
|
+
if (i.length > 1)
|
|
398
|
+
throw new AggregateError(
|
|
399
|
+
i,
|
|
400
|
+
o ? "[Raph] Kernel mutation and Runtime publication failed." : "[Raph] Runtime publication failed after a Kernel mutation."
|
|
401
|
+
);
|
|
402
|
+
return s;
|
|
314
403
|
}
|
|
315
404
|
_assertWritablePath(e, t, r, i) {
|
|
316
405
|
const s = this._derivedController;
|
|
317
406
|
if (s === void 0 || this._derivedWriteDepth !== 0)
|
|
318
407
|
return;
|
|
319
|
-
const
|
|
320
|
-
for (const
|
|
321
|
-
const c =
|
|
322
|
-
if (!
|
|
408
|
+
const o = p(t, i);
|
|
409
|
+
for (const n of s.values()) {
|
|
410
|
+
const c = p(n.options.to);
|
|
411
|
+
if (!A(o, c))
|
|
323
412
|
continue;
|
|
324
|
-
const l =
|
|
325
|
-
if (!(e === "merge" && l &&
|
|
326
|
-
throw new
|
|
413
|
+
const l = o.segments.length < c.segments.length;
|
|
414
|
+
if (!(e === "merge" && l && !$(r, c.segments[o.segments.length])))
|
|
415
|
+
throw new T(o.canonical);
|
|
327
416
|
}
|
|
328
417
|
}
|
|
329
418
|
_writeDerivedTarget(e, t) {
|
|
@@ -335,57 +424,55 @@ const x = class x {
|
|
|
335
424
|
}
|
|
336
425
|
}
|
|
337
426
|
_mutateDerived(e, t, r, i, s) {
|
|
338
|
-
const
|
|
339
|
-
t === "delete" && !e.has(r, s) || e.
|
|
340
|
-
t === "set" ? e.set(r, i, s) : t === "merge" ? e.merge(r, i, s) : e.delete(r, s), this._queueDerived(
|
|
427
|
+
const o = p(r, s);
|
|
428
|
+
t === "delete" && !e.has(r, s) || e.batch(() => {
|
|
429
|
+
t === "set" ? e.set(r, i, s) : t === "merge" ? e.merge(r, i, s) : e.delete(r, s), this._queueDerived(o), this._batchDepth === 0 && !this._stabilizing && this._stabilizeDerived();
|
|
341
430
|
});
|
|
342
431
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
this._transactionDepth++;
|
|
432
|
+
_runDerivedBatch(e) {
|
|
433
|
+
let t = !1, r, i = !1, s, o = !1, n, c;
|
|
434
|
+
this._batchDepth++;
|
|
347
435
|
try {
|
|
348
436
|
c = e();
|
|
349
|
-
} catch (
|
|
350
|
-
t = !0, r =
|
|
437
|
+
} catch (m) {
|
|
438
|
+
t = !0, r = m;
|
|
351
439
|
} finally {
|
|
352
|
-
if (this.
|
|
440
|
+
if (this._batchDepth--, this._batchDepth === 0) {
|
|
353
441
|
if (!this._stabilizing)
|
|
354
442
|
try {
|
|
355
443
|
this._stabilizeDerived();
|
|
356
|
-
} catch (
|
|
357
|
-
i = !0, s =
|
|
444
|
+
} catch (m) {
|
|
445
|
+
i = !0, s = m;
|
|
358
446
|
}
|
|
359
447
|
try {
|
|
360
|
-
|
|
361
|
-
} catch (
|
|
362
|
-
|
|
448
|
+
this._metaController?.publish();
|
|
449
|
+
} catch (m) {
|
|
450
|
+
o = !0, n = m;
|
|
363
451
|
}
|
|
364
452
|
}
|
|
365
453
|
}
|
|
366
454
|
const l = [];
|
|
367
|
-
if (t && l.push(r), i && l.push(s),
|
|
455
|
+
if (t && l.push(r), i && l.push(s), o && l.push(n), l.length > 1)
|
|
368
456
|
throw new AggregateError(
|
|
369
457
|
l,
|
|
370
|
-
"[Raph] Kernel
|
|
458
|
+
"[Raph] Kernel batch publication failed."
|
|
371
459
|
);
|
|
372
460
|
if (l.length === 1)
|
|
373
461
|
throw l[0];
|
|
374
462
|
return c;
|
|
375
463
|
}
|
|
376
464
|
_mutateWithMetaLifecycle(e) {
|
|
377
|
-
if (this.
|
|
465
|
+
if (this._batchDepth !== 0 || this._stabilizing) {
|
|
378
466
|
e();
|
|
379
467
|
return;
|
|
380
468
|
}
|
|
381
|
-
this.
|
|
469
|
+
this.batch(e);
|
|
382
470
|
}
|
|
383
471
|
_pruneMissingMetaOwners(e, t, r) {
|
|
384
|
-
|
|
385
|
-
(i = this._metaController) == null || i.pruneMissing(this._metaPath(e, r), t);
|
|
472
|
+
this._metaController?.pruneMissing(this._metaPath(e, r), t);
|
|
386
473
|
}
|
|
387
474
|
_metaPath(e, t) {
|
|
388
|
-
return
|
|
475
|
+
return B.from(e, t);
|
|
389
476
|
}
|
|
390
477
|
_exactMetaPath(e, t) {
|
|
391
478
|
const r = this._metaPath(e, t);
|
|
@@ -402,19 +489,17 @@ const x = class x {
|
|
|
402
489
|
throw new Error(`[RaphMeta] Owner data path does not exist: "${e}".`);
|
|
403
490
|
}
|
|
404
491
|
_queueDerived(e) {
|
|
405
|
-
|
|
406
|
-
(t = this._derivedController) == null || t.queue(e);
|
|
492
|
+
this._derivedController?.queue(e);
|
|
407
493
|
}
|
|
408
494
|
_queueDerivedReplacement(e, t) {
|
|
409
|
-
|
|
410
|
-
(r = this._derivedController) == null || r.queueReplacement(e, t);
|
|
495
|
+
this._derivedController?.queueReplacement(e, t);
|
|
411
496
|
}
|
|
412
497
|
_replaceDerivedTarget(e, t, r) {
|
|
413
|
-
const i =
|
|
498
|
+
const i = p(e);
|
|
414
499
|
this._store.set(i.canonical, t), this._queueDerivedReplacement(i, r);
|
|
415
500
|
}
|
|
416
501
|
_stabilizeDerived() {
|
|
417
|
-
const e = this._derivedController, t = e
|
|
502
|
+
const e = this._derivedController, t = e?.pending;
|
|
418
503
|
if (t === void 0 || t.size === 0)
|
|
419
504
|
return;
|
|
420
505
|
this._stabilizing = !0;
|
|
@@ -435,12 +520,11 @@ const x = class x {
|
|
|
435
520
|
} catch (i) {
|
|
436
521
|
throw t.clear(), i;
|
|
437
522
|
} finally {
|
|
438
|
-
this._stabilizing = !1, e
|
|
523
|
+
this._stabilizing = !1, e?.clearPendingIfEmpty();
|
|
439
524
|
}
|
|
440
525
|
}
|
|
441
526
|
_recomputePendingDerived(e) {
|
|
442
|
-
|
|
443
|
-
const t = (r = this._derivedController) == null ? void 0 : r.state(e);
|
|
527
|
+
const t = this._derivedController?.state(e);
|
|
444
528
|
if (t === void 0 || !t.initialized || t.full) {
|
|
445
529
|
this._recomputeDerivedFull(e);
|
|
446
530
|
return;
|
|
@@ -448,61 +532,60 @@ const x = class x {
|
|
|
448
532
|
t.kind === "filter-by-key" ? this._recomputeDerivedFilter(e, t) : this._recomputeDerivedCollection(e, t);
|
|
449
533
|
}
|
|
450
534
|
_recomputeDerivedFull(e) {
|
|
451
|
-
|
|
452
|
-
const t = (c = this._derivedController) == null ? void 0 : c.state(e);
|
|
535
|
+
const t = this._derivedController?.state(e);
|
|
453
536
|
t !== void 0 && (t.full = !0);
|
|
454
537
|
const r = this.get(e.options.from), i = e.options.compute(r);
|
|
455
|
-
let s = i,
|
|
456
|
-
t !== void 0 && (r === void 0 && (i === void 0 || Array.isArray(i) && i.length === 0) ? (
|
|
538
|
+
let s = i, o, n;
|
|
539
|
+
t !== void 0 && (r === void 0 && (i === void 0 || Array.isArray(i) && i.length === 0) ? (o = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map()) : (t.kind === "filter-by-key" ? (I(e.id, t.key, r, i), s = M(i)) : E(e.id, t.key, r, i), o = w(r, t.key, "source"), n = w(s, t.key, "output"))), this._writeDerivedTarget(e.options.to, s), t !== void 0 && (t.sourceIndex = o, t.targetIndex = n, t.initialized = !0, t.full = !1, t.keys.clear());
|
|
457
540
|
}
|
|
458
541
|
_recomputeDerivedCollection(e, t) {
|
|
459
542
|
t.full = !0;
|
|
460
543
|
const r = this.get(e.options.from), i = this.get(e.options.to);
|
|
461
544
|
if (!Array.isArray(r) || !Array.isArray(i))
|
|
462
|
-
throw
|
|
463
|
-
(t.sourceIndex === void 0 ||
|
|
545
|
+
throw D(e.id, "requires array source and target");
|
|
546
|
+
(t.sourceIndex === void 0 || x(r, t.key, t.sourceIndex, t.keys)) && (t.sourceIndex = w(r, t.key, "source"));
|
|
464
547
|
const s = t.targetIndex;
|
|
465
548
|
if (s === void 0)
|
|
466
|
-
throw
|
|
467
|
-
const
|
|
468
|
-
for (const
|
|
469
|
-
const
|
|
470
|
-
|
|
549
|
+
throw D(e.id, "has no materialized target index");
|
|
550
|
+
const o = [], n = [];
|
|
551
|
+
for (const h of t.keys) {
|
|
552
|
+
const _ = t.sourceIndex.get(h);
|
|
553
|
+
_ === void 0 ? n.push(h) : o.push({ key: h, index: _, item: r[_] });
|
|
471
554
|
}
|
|
472
|
-
|
|
473
|
-
const c =
|
|
474
|
-
|
|
555
|
+
o.sort((h, _) => h.index - _.index);
|
|
556
|
+
const c = o.map((h) => h.item), l = c.length === 0 ? [] : e.options.compute(c);
|
|
557
|
+
F(
|
|
475
558
|
e.id,
|
|
476
559
|
t.key,
|
|
477
|
-
|
|
560
|
+
o.map((h) => h.key),
|
|
478
561
|
l
|
|
479
562
|
);
|
|
480
|
-
const
|
|
481
|
-
if (
|
|
482
|
-
const
|
|
483
|
-
for (let u = 0; u <
|
|
484
|
-
|
|
485
|
-
const
|
|
486
|
-
for (const [u,
|
|
487
|
-
|
|
488
|
-
const
|
|
489
|
-
|
|
490
|
-
for (let u = 0; u <
|
|
491
|
-
const
|
|
492
|
-
if (
|
|
563
|
+
const m = l;
|
|
564
|
+
if (n.length !== 0 || o.some((h) => !s.has(h.key))) {
|
|
565
|
+
const h = /* @__PURE__ */ new Map();
|
|
566
|
+
for (let u = 0; u < o.length; u++)
|
|
567
|
+
h.set(o[u].key, m[u]);
|
|
568
|
+
const _ = /* @__PURE__ */ new Map();
|
|
569
|
+
for (const [u, v] of s)
|
|
570
|
+
_.set(u, i[v]);
|
|
571
|
+
const a = b(r, t.key, "source"), d = [];
|
|
572
|
+
d.length = a.length;
|
|
573
|
+
for (let u = 0; u < a.length; u++) {
|
|
574
|
+
const v = a[u];
|
|
575
|
+
if (v === void 0)
|
|
493
576
|
continue;
|
|
494
|
-
const
|
|
495
|
-
if (
|
|
496
|
-
throw
|
|
497
|
-
|
|
577
|
+
const k = h.has(v) ? h.get(v) : _.get(v);
|
|
578
|
+
if (k === void 0)
|
|
579
|
+
throw D(e.id, `is missing target item for key "${String(v)}"`);
|
|
580
|
+
d[u] = k;
|
|
498
581
|
}
|
|
499
|
-
const
|
|
500
|
-
this._replaceDerivedTarget(e.options.to,
|
|
582
|
+
const g = w(d, t.key, "target");
|
|
583
|
+
this._replaceDerivedTarget(e.options.to, d, t.keys), t.targetIndex = g;
|
|
501
584
|
} else
|
|
502
|
-
for (let
|
|
585
|
+
for (let h = 0; h < o.length; h++)
|
|
503
586
|
this._writeDerivedTarget(
|
|
504
|
-
|
|
505
|
-
|
|
587
|
+
C(e.options.to, t.key, o[h].key),
|
|
588
|
+
m[h]
|
|
506
589
|
);
|
|
507
590
|
t.keys.clear(), t.full = !1;
|
|
508
591
|
}
|
|
@@ -510,127 +593,124 @@ const x = class x {
|
|
|
510
593
|
t.full = !0;
|
|
511
594
|
const r = this.get(e.options.from), i = this.get(e.options.to);
|
|
512
595
|
if (!Array.isArray(r) || !Array.isArray(i))
|
|
513
|
-
throw
|
|
514
|
-
(t.sourceIndex === void 0 ||
|
|
596
|
+
throw R(e.id, "requires array source and target");
|
|
597
|
+
(t.sourceIndex === void 0 || x(r, t.key, t.sourceIndex, t.keys)) && (t.sourceIndex = w(r, t.key, "source"));
|
|
515
598
|
const s = t.targetIndex;
|
|
516
599
|
if (s === void 0)
|
|
517
|
-
throw
|
|
518
|
-
const
|
|
519
|
-
for (const
|
|
520
|
-
const
|
|
521
|
-
|
|
600
|
+
throw R(e.id, "has no materialized target index");
|
|
601
|
+
const o = [];
|
|
602
|
+
for (const a of t.keys) {
|
|
603
|
+
const d = t.sourceIndex.get(a);
|
|
604
|
+
d !== void 0 && o.push({ key: a, index: d, item: r[d] });
|
|
522
605
|
}
|
|
523
|
-
|
|
524
|
-
const
|
|
525
|
-
|
|
606
|
+
o.sort((a, d) => a.index - d.index);
|
|
607
|
+
const n = o.map((a) => a.item), c = n.length === 0 ? [] : e.options.compute(n);
|
|
608
|
+
K(
|
|
526
609
|
e.id,
|
|
527
610
|
t.key,
|
|
528
|
-
|
|
611
|
+
o.map((a) => a.key),
|
|
529
612
|
c
|
|
530
613
|
);
|
|
531
|
-
const l = /* @__PURE__ */ new Map(),
|
|
532
|
-
for (let
|
|
533
|
-
const
|
|
534
|
-
|
|
614
|
+
const l = /* @__PURE__ */ new Map(), m = c, y = b(m, t.key, "output");
|
|
615
|
+
for (let a = 0; a < y.length; a++) {
|
|
616
|
+
const d = y[a];
|
|
617
|
+
d !== void 0 && l.set(d, M(m[a]));
|
|
535
618
|
}
|
|
536
|
-
const
|
|
537
|
-
let
|
|
538
|
-
for (const
|
|
539
|
-
const
|
|
540
|
-
!
|
|
619
|
+
const h = /* @__PURE__ */ new Set();
|
|
620
|
+
let _ = !1;
|
|
621
|
+
for (const a of t.keys) {
|
|
622
|
+
const d = s.has(a), g = l.has(a);
|
|
623
|
+
!d && !g || (h.add(a), d !== g && (_ = !0));
|
|
541
624
|
}
|
|
542
|
-
if (
|
|
625
|
+
if (_ && t.keys.size === 1 && i.length === s.size && this._patchSingleFilterMembership(
|
|
543
626
|
e,
|
|
544
627
|
t,
|
|
545
628
|
i,
|
|
546
629
|
s,
|
|
547
630
|
l,
|
|
548
|
-
|
|
631
|
+
h
|
|
549
632
|
)) {
|
|
550
633
|
t.keys.clear(), t.full = !1;
|
|
551
634
|
return;
|
|
552
635
|
}
|
|
553
|
-
if (
|
|
554
|
-
const
|
|
555
|
-
for (const [u,
|
|
556
|
-
|
|
557
|
-
const
|
|
558
|
-
for (const u of
|
|
636
|
+
if (_) {
|
|
637
|
+
const a = /* @__PURE__ */ new Map();
|
|
638
|
+
for (const [u, v] of s)
|
|
639
|
+
a.set(u, i[v]);
|
|
640
|
+
const d = [];
|
|
641
|
+
for (const u of b(r, t.key, "source"))
|
|
559
642
|
if (u !== void 0) {
|
|
560
643
|
if (t.keys.has(u)) {
|
|
561
|
-
l.has(u) &&
|
|
644
|
+
l.has(u) && d.push(l.get(u));
|
|
562
645
|
continue;
|
|
563
646
|
}
|
|
564
|
-
|
|
647
|
+
a.has(u) && d.push(a.get(u));
|
|
565
648
|
}
|
|
566
|
-
const
|
|
567
|
-
this._replaceDerivedTarget(e.options.to,
|
|
649
|
+
const g = w(d, t.key, "target");
|
|
650
|
+
this._replaceDerivedTarget(e.options.to, d, h), t.targetIndex = g;
|
|
568
651
|
} else
|
|
569
|
-
for (const [
|
|
570
|
-
this._writeDerivedTarget(
|
|
652
|
+
for (const [a, d] of l)
|
|
653
|
+
this._writeDerivedTarget(C(e.options.to, t.key, a), d);
|
|
571
654
|
t.keys.clear(), t.full = !1;
|
|
572
655
|
}
|
|
573
|
-
_patchSingleFilterMembership(e, t, r, i, s,
|
|
574
|
-
const
|
|
575
|
-
if (
|
|
656
|
+
_patchSingleFilterMembership(e, t, r, i, s, o) {
|
|
657
|
+
const n = t.sourceIndex;
|
|
658
|
+
if (n === void 0)
|
|
576
659
|
return !1;
|
|
577
660
|
const c = t.keys.values().next().value;
|
|
578
661
|
if (c === void 0)
|
|
579
662
|
return !1;
|
|
580
|
-
const l = i.get(c),
|
|
581
|
-
if (l !== void 0 ===
|
|
663
|
+
const l = i.get(c), m = s.has(c);
|
|
664
|
+
if (l !== void 0 === m)
|
|
582
665
|
return !1;
|
|
583
|
-
const
|
|
584
|
-
let
|
|
666
|
+
const y = r.slice();
|
|
667
|
+
let h;
|
|
585
668
|
if (l !== void 0)
|
|
586
|
-
|
|
669
|
+
h = l, y.splice(h, 1);
|
|
587
670
|
else {
|
|
588
|
-
const
|
|
589
|
-
if (
|
|
671
|
+
const _ = n.get(c);
|
|
672
|
+
if (_ === void 0)
|
|
590
673
|
return !1;
|
|
591
|
-
let
|
|
592
|
-
for (;
|
|
593
|
-
const
|
|
674
|
+
let a = 0, d = y.length;
|
|
675
|
+
for (; a < d; ) {
|
|
676
|
+
const g = a + d >>> 1, u = y[g];
|
|
594
677
|
if (typeof u != "object" || u === null || Array.isArray(u))
|
|
595
678
|
return !1;
|
|
596
|
-
const
|
|
597
|
-
if (typeof
|
|
679
|
+
const v = u[t.key];
|
|
680
|
+
if (typeof v != "string" && typeof v != "number")
|
|
598
681
|
return !1;
|
|
599
|
-
const
|
|
600
|
-
if (
|
|
682
|
+
const k = n.get(v);
|
|
683
|
+
if (k === void 0)
|
|
601
684
|
return !1;
|
|
602
|
-
|
|
685
|
+
k < _ ? a = g + 1 : d = g;
|
|
603
686
|
}
|
|
604
|
-
|
|
687
|
+
h = a, y.splice(h, 0, s.get(c));
|
|
605
688
|
}
|
|
606
|
-
if (this._replaceDerivedTarget(e.options.to,
|
|
689
|
+
if (this._replaceDerivedTarget(e.options.to, y, o), l !== void 0) {
|
|
607
690
|
i.delete(c);
|
|
608
|
-
for (const [
|
|
609
|
-
|
|
691
|
+
for (const [_, a] of i)
|
|
692
|
+
a > h && i.set(_, a - 1);
|
|
610
693
|
} else {
|
|
611
|
-
for (const [
|
|
612
|
-
|
|
613
|
-
i.set(c,
|
|
694
|
+
for (const [_, a] of i)
|
|
695
|
+
a >= h && i.set(_, a + 1);
|
|
696
|
+
i.set(c, h);
|
|
614
697
|
}
|
|
615
698
|
return !0;
|
|
616
699
|
}
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
p(x, "_kernelCounter", 0);
|
|
620
|
-
let E = x;
|
|
621
|
-
function T(f, e) {
|
|
700
|
+
}
|
|
701
|
+
function A(f, e) {
|
|
622
702
|
const t = Math.min(f.segments.length, e.segments.length);
|
|
623
703
|
for (let r = 0; r < t; r++)
|
|
624
|
-
if (!
|
|
704
|
+
if (!j(f.segments[r], e.segments[r]))
|
|
625
705
|
return !1;
|
|
626
706
|
return !0;
|
|
627
707
|
}
|
|
628
|
-
function
|
|
708
|
+
function $(f, e) {
|
|
629
709
|
return typeof f != "object" || f === null || Array.isArray(f) || e.kind !== "key" ? !0 : Object.hasOwn(f, e.key);
|
|
630
710
|
}
|
|
631
|
-
function
|
|
711
|
+
function j(f, e) {
|
|
632
712
|
return f.kind !== e.kind ? !1 : f.kind === "key" && e.kind === "key" ? f.key === e.key : f.kind === "index" && e.kind === "index" ? f.index === e.index : f.kind === "selector" && e.kind === "selector" && f.key === e.key && Object.is(f.value, e.value);
|
|
633
713
|
}
|
|
634
714
|
export {
|
|
635
|
-
|
|
715
|
+
P as RaphKernel
|
|
636
716
|
};
|