@graphrefly/graphrefly 0.16.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-RLVFZDCE.js → chunk-76YPZQTW.js} +3 -9
- package/dist/{chunk-RLVFZDCE.js.map → chunk-76YPZQTW.js.map} +1 -1
- package/dist/{chunk-VZY2B2LU.js → chunk-BV3TPSBK.js} +1 -2
- package/dist/chunk-BV3TPSBK.js.map +1 -0
- package/dist/{chunk-YX263TXI.js → chunk-F6ORUNO7.js} +19 -52
- package/dist/chunk-F6ORUNO7.js.map +1 -0
- package/dist/chunk-FCLROC4Q.js +231 -0
- package/dist/chunk-FCLROC4Q.js.map +1 -0
- package/dist/{chunk-ITDVOCFO.js → chunk-J7S54G7I.js} +2 -3
- package/dist/{chunk-26A4E7J7.js → chunk-KJGUP35I.js} +4 -10
- package/dist/chunk-KJGUP35I.js.map +1 -0
- package/dist/{chunk-3BLRREFM.js → chunk-LB3RYLSC.js} +207 -174
- package/dist/chunk-LB3RYLSC.js.map +1 -0
- package/dist/{chunk-LKP7IWRV.js → chunk-TNKODJ6E.js} +3 -7
- package/dist/chunk-TNKODJ6E.js.map +1 -0
- package/dist/{chunk-RZSQ7P2C.js → chunk-UVWEKTYC.js} +3 -3
- package/dist/compat/nestjs/index.cjs +221 -225
- package/dist/compat/nestjs/index.cjs.map +1 -1
- package/dist/compat/nestjs/index.d.cts +4 -4
- package/dist/compat/nestjs/index.d.ts +4 -4
- package/dist/compat/nestjs/index.js +7 -13
- package/dist/core/index.cjs +0 -84
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +3 -7
- package/dist/extra/index.cjs +17 -54
- package/dist/extra/index.cjs.map +1 -1
- package/dist/extra/index.d.cts +4 -4
- package/dist/extra/index.d.ts +4 -4
- package/dist/extra/index.js +3 -9
- package/dist/graph/index.cjs +329 -174
- package/dist/graph/index.cjs.map +1 -1
- package/dist/graph/index.d.cts +3 -3
- package/dist/graph/index.d.ts +3 -3
- package/dist/graph/index.js +10 -6
- package/dist/{graph-fCsaaVIa.d.cts → graph-BYFlyNpX.d.cts} +47 -45
- package/dist/{graph-Dc-P9BVm.d.ts → graph-gISB9n3n.d.ts} +47 -45
- package/dist/{index-N704txAA.d.ts → index-7WnwgjMu.d.ts} +5 -7
- package/dist/{index-DWq0P9T6.d.ts → index-B43mC7uY.d.cts} +5 -7
- package/dist/{index-BmoUvOGN.d.ts → index-B80mMeuf.d.ts} +2 -4
- package/dist/{index-DlGMf_Qe.d.cts → index-BqOWSFhr.d.cts} +2 -2
- package/dist/{index-BBVBYPxr.d.cts → index-CEDaJaYE.d.ts} +5 -7
- package/dist/{index-DhXznWyH.d.ts → index-CgKPpiu8.d.ts} +2 -2
- package/dist/{index-Db27z6Ki.d.cts → index-Ci_vPaVm.d.cts} +90 -7
- package/dist/{index-BR19vQME.d.ts → index-DKaB2x0T.d.ts} +90 -7
- package/dist/{index-ClaKZFPl.d.cts → index-D_tUMcpz.d.cts} +5 -7
- package/dist/{index-YlOH1Gw6.d.cts → index-EmzYk-TG.d.cts} +2 -4
- package/dist/index.cjs +503 -282
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +99 -18
- package/dist/index.d.ts +99 -18
- package/dist/index.js +170 -63
- package/dist/index.js.map +1 -1
- package/dist/{meta-BV4pj9ML.d.cts → meta-npl5b97j.d.cts} +1 -53
- package/dist/{meta-BV4pj9ML.d.ts → meta-npl5b97j.d.ts} +1 -53
- package/dist/observable-DFBCBELR.d.cts +36 -0
- package/dist/observable-oAGygKvc.d.ts +36 -0
- package/dist/patterns/reactive-layout/index.cjs +204 -172
- package/dist/patterns/reactive-layout/index.cjs.map +1 -1
- package/dist/patterns/reactive-layout/index.d.cts +3 -3
- package/dist/patterns/reactive-layout/index.d.ts +3 -3
- package/dist/patterns/reactive-layout/index.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-26A4E7J7.js.map +0 -1
- package/dist/chunk-3BLRREFM.js.map +0 -1
- package/dist/chunk-LKP7IWRV.js.map +0 -1
- package/dist/chunk-SHRJH2DN.js +0 -107
- package/dist/chunk-SHRJH2DN.js.map +0 -1
- package/dist/chunk-VZY2B2LU.js.map +0 -1
- package/dist/chunk-YX263TXI.js.map +0 -1
- package/dist/observable-Cz-AWhwR.d.cts +0 -42
- package/dist/observable-DCqlwGyl.d.ts +0 -42
- /package/dist/{chunk-ITDVOCFO.js.map → chunk-J7S54G7I.js.map} +0 -0
- /package/dist/{chunk-RZSQ7P2C.js.map → chunk-UVWEKTYC.js.map} +0 -0
|
@@ -95,11 +95,8 @@ __export(nestjs_exports, {
|
|
|
95
95
|
getActor: () => getActor,
|
|
96
96
|
getGraphToken: () => getGraphToken,
|
|
97
97
|
getNodeToken: () => getNodeToken,
|
|
98
|
-
observeGraph$: () => observeGraph$,
|
|
99
|
-
observeNode$: () => observeNode$,
|
|
100
98
|
observeSSE: () => observeSSE,
|
|
101
99
|
observeSubscription: () => observeSubscription,
|
|
102
|
-
toMessages$: () => toMessages$,
|
|
103
100
|
toObservable: () => toObservable
|
|
104
101
|
});
|
|
105
102
|
module.exports = __toCommonJS(nestjs_exports);
|
|
@@ -137,48 +134,28 @@ function propagatesToMeta(t) {
|
|
|
137
134
|
}
|
|
138
135
|
|
|
139
136
|
// src/extra/observable.ts
|
|
140
|
-
function toObservable(node2) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
137
|
+
function toObservable(node2, options) {
|
|
138
|
+
if (options?.raw) {
|
|
139
|
+
return new import_rxjs.Observable((subscriber) => {
|
|
140
|
+
const unsub = node2.subscribe((msgs) => {
|
|
144
141
|
if (subscriber.closed) return;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
142
|
+
subscriber.next(msgs);
|
|
143
|
+
for (const m of msgs) {
|
|
144
|
+
if (m[0] === ERROR) {
|
|
145
|
+
subscriber.error(m[1]);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (m[0] === COMPLETE) {
|
|
149
|
+
subscriber.complete();
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
153
152
|
}
|
|
154
|
-
}
|
|
153
|
+
});
|
|
154
|
+
return unsub;
|
|
155
155
|
});
|
|
156
|
-
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
function toMessages$(node2) {
|
|
156
|
+
}
|
|
160
157
|
return new import_rxjs.Observable((subscriber) => {
|
|
161
158
|
const unsub = node2.subscribe((msgs) => {
|
|
162
|
-
if (subscriber.closed) return;
|
|
163
|
-
subscriber.next(msgs);
|
|
164
|
-
for (const m of msgs) {
|
|
165
|
-
if (m[0] === ERROR) {
|
|
166
|
-
subscriber.error(m[1]);
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
if (m[0] === COMPLETE) {
|
|
170
|
-
subscriber.complete();
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
return unsub;
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
function observeNode$(graph, path, options) {
|
|
179
|
-
return new import_rxjs.Observable((subscriber) => {
|
|
180
|
-
const handle = graph.observe(path, options);
|
|
181
|
-
const unsub = handle.subscribe((msgs) => {
|
|
182
159
|
for (const m of msgs) {
|
|
183
160
|
if (subscriber.closed) return;
|
|
184
161
|
if (m[0] === DATA) {
|
|
@@ -195,16 +172,6 @@ function observeNode$(graph, path, options) {
|
|
|
195
172
|
return unsub;
|
|
196
173
|
});
|
|
197
174
|
}
|
|
198
|
-
function observeGraph$(graph, options) {
|
|
199
|
-
return new import_rxjs.Observable((subscriber) => {
|
|
200
|
-
const handle = graph.observe(options);
|
|
201
|
-
const unsub = handle.subscribe((nodePath, messages) => {
|
|
202
|
-
if (subscriber.closed) return;
|
|
203
|
-
subscriber.next({ path: nodePath, messages });
|
|
204
|
-
});
|
|
205
|
-
return unsub;
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
175
|
|
|
209
176
|
// src/compat/nestjs/decorators.ts
|
|
210
177
|
var import_common = require("@nestjs/common");
|
|
@@ -1093,7 +1060,6 @@ var NodeImpl = class {
|
|
|
1093
1060
|
this._downInternal(wasDirty ? [[RESOLVED]] : [[DIRTY], [RESOLVED]]);
|
|
1094
1061
|
return;
|
|
1095
1062
|
}
|
|
1096
|
-
this._cached = value;
|
|
1097
1063
|
this._downInternal(wasDirty ? [[DATA, value]] : [[DIRTY], [DATA, value]]);
|
|
1098
1064
|
}
|
|
1099
1065
|
_runFn() {
|
|
@@ -2828,7 +2794,7 @@ var RingBuffer = class {
|
|
|
2828
2794
|
return result;
|
|
2829
2795
|
}
|
|
2830
2796
|
};
|
|
2831
|
-
var
|
|
2797
|
+
var OBSERVE_ANSI_THEME = {
|
|
2832
2798
|
data: "\x1B[32m",
|
|
2833
2799
|
dirty: "\x1B[33m",
|
|
2834
2800
|
resolved: "\x1B[36m",
|
|
@@ -2838,7 +2804,7 @@ var SPY_ANSI_THEME = {
|
|
|
2838
2804
|
path: "\x1B[90m",
|
|
2839
2805
|
reset: "\x1B[0m"
|
|
2840
2806
|
};
|
|
2841
|
-
var
|
|
2807
|
+
var OBSERVE_NO_COLOR_THEME = {
|
|
2842
2808
|
data: "",
|
|
2843
2809
|
dirty: "",
|
|
2844
2810
|
resolved: "",
|
|
@@ -2858,9 +2824,9 @@ function describeData(value) {
|
|
|
2858
2824
|
return "[unserializable]";
|
|
2859
2825
|
}
|
|
2860
2826
|
}
|
|
2861
|
-
function
|
|
2862
|
-
if (theme === "none") return
|
|
2863
|
-
if (theme === "ansi" || theme == null) return
|
|
2827
|
+
function resolveObserveTheme(theme) {
|
|
2828
|
+
if (theme === "none") return OBSERVE_NO_COLOR_THEME;
|
|
2829
|
+
if (theme === "ansi" || theme == null) return OBSERVE_ANSI_THEME;
|
|
2864
2830
|
return {
|
|
2865
2831
|
data: theme.data ?? "",
|
|
2866
2832
|
dirty: theme.dirty ?? "",
|
|
@@ -3631,9 +3597,13 @@ var Graph = class _Graph {
|
|
|
3631
3597
|
if (actor2 != null && !target.allowsObserve(actor2)) {
|
|
3632
3598
|
throw new GuardDenied({ actor: actor2, action: "observe", nodeName: path });
|
|
3633
3599
|
}
|
|
3634
|
-
const wantsStructured2 = resolved.structured === true || resolved.timeline === true || resolved.causal === true || resolved.derived === true || resolved.detail === "minimal" || resolved.detail === "full";
|
|
3635
|
-
if (wantsStructured2
|
|
3636
|
-
|
|
3600
|
+
const wantsStructured2 = resolved.structured === true || resolved.timeline === true || resolved.causal === true || resolved.derived === true || resolved.detail === "minimal" || resolved.detail === "full" || resolved.format != null;
|
|
3601
|
+
if (wantsStructured2) {
|
|
3602
|
+
const result = _Graph.inspectorEnabled ? this._createObserveResult(path, target, resolved) : this._createFallbackObserveResult(path, resolved);
|
|
3603
|
+
if (resolved.format != null) {
|
|
3604
|
+
this._attachFormatLogger(result, resolved);
|
|
3605
|
+
}
|
|
3606
|
+
return result;
|
|
3637
3607
|
}
|
|
3638
3608
|
return {
|
|
3639
3609
|
subscribe(sink) {
|
|
@@ -3651,9 +3621,13 @@ var Graph = class _Graph {
|
|
|
3651
3621
|
}
|
|
3652
3622
|
const opts = resolveObserveDetail(pathOrOpts);
|
|
3653
3623
|
const actor = opts.actor;
|
|
3654
|
-
const wantsStructured = opts.structured === true || opts.timeline === true || opts.causal === true || opts.derived === true || opts.detail === "minimal" || opts.detail === "full";
|
|
3655
|
-
if (wantsStructured
|
|
3656
|
-
|
|
3624
|
+
const wantsStructured = opts.structured === true || opts.timeline === true || opts.causal === true || opts.derived === true || opts.detail === "minimal" || opts.detail === "full" || opts.format != null;
|
|
3625
|
+
if (wantsStructured) {
|
|
3626
|
+
const result = _Graph.inspectorEnabled ? this._createObserveResultForAll(opts) : this._createFallbackObserveResultForAll(opts);
|
|
3627
|
+
if (opts.format != null) {
|
|
3628
|
+
this._attachFormatLogger(result, opts);
|
|
3629
|
+
}
|
|
3630
|
+
return result;
|
|
3657
3631
|
}
|
|
3658
3632
|
return {
|
|
3659
3633
|
subscribe: (sink) => {
|
|
@@ -3697,6 +3671,7 @@ var Graph = class _Graph {
|
|
|
3697
3671
|
let lastTriggerDepIndex;
|
|
3698
3672
|
let lastRunDepValues;
|
|
3699
3673
|
let detachInspectorHook;
|
|
3674
|
+
let batchSeq = 0;
|
|
3700
3675
|
if ((causal || derived2) && target instanceof NodeImpl) {
|
|
3701
3676
|
detachInspectorHook = target._setInspectorHook((event) => {
|
|
3702
3677
|
if (event.kind === "dep_message") {
|
|
@@ -3709,15 +3684,16 @@ var Graph = class _Graph {
|
|
|
3709
3684
|
type: "derived",
|
|
3710
3685
|
path,
|
|
3711
3686
|
dep_values: [...event.depValues],
|
|
3712
|
-
...timeline ? { timestamp_ns: monotonicNs(), in_batch: isBatching() } : {}
|
|
3687
|
+
...timeline ? { timestamp_ns: monotonicNs(), in_batch: isBatching(), batch_id: batchSeq } : {}
|
|
3713
3688
|
});
|
|
3714
3689
|
}
|
|
3715
3690
|
});
|
|
3716
3691
|
}
|
|
3717
3692
|
const unsub = target.subscribe((msgs) => {
|
|
3693
|
+
batchSeq++;
|
|
3718
3694
|
for (const m of msgs) {
|
|
3719
3695
|
const t = m[0];
|
|
3720
|
-
const base = timeline ? { timestamp_ns: monotonicNs(), in_batch: isBatching() } : {};
|
|
3696
|
+
const base = timeline ? { timestamp_ns: monotonicNs(), in_batch: isBatching(), batch_id: batchSeq } : {};
|
|
3721
3697
|
const withCausal = causal && lastRunDepValues != null ? (() => {
|
|
3722
3698
|
const triggerDep = lastTriggerDepIndex != null && lastTriggerDepIndex >= 0 && target instanceof NodeImpl ? target._deps[lastTriggerDepIndex] : void 0;
|
|
3723
3699
|
const tv = triggerDep?.v;
|
|
@@ -3786,11 +3762,15 @@ var Graph = class _Graph {
|
|
|
3786
3762
|
Object.assign(merged, extra);
|
|
3787
3763
|
}
|
|
3788
3764
|
const resolvedTarget = graph.resolve(basePath);
|
|
3789
|
-
|
|
3765
|
+
const expanded = graph._createObserveResult(
|
|
3790
3766
|
basePath,
|
|
3791
3767
|
resolvedTarget,
|
|
3792
3768
|
resolveObserveDetail(merged)
|
|
3793
3769
|
);
|
|
3770
|
+
if (merged.format != null) {
|
|
3771
|
+
graph._attachFormatLogger(expanded, merged);
|
|
3772
|
+
}
|
|
3773
|
+
return expanded;
|
|
3794
3774
|
}
|
|
3795
3775
|
};
|
|
3796
3776
|
}
|
|
@@ -3810,11 +3790,13 @@ var Graph = class _Graph {
|
|
|
3810
3790
|
this._collectObserveTargets("", targets);
|
|
3811
3791
|
targets.sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
|
|
3812
3792
|
const picked = actor == null ? targets : targets.filter(([, nd]) => nd.allowsObserve(actor));
|
|
3793
|
+
let batchSeq = 0;
|
|
3813
3794
|
const unsubs = picked.map(
|
|
3814
3795
|
([path, nd]) => nd.subscribe((msgs) => {
|
|
3796
|
+
batchSeq++;
|
|
3815
3797
|
for (const m of msgs) {
|
|
3816
3798
|
const t = m[0];
|
|
3817
|
-
const base = timeline ? { timestamp_ns: monotonicNs(), in_batch: isBatching() } : {};
|
|
3799
|
+
const base = timeline ? { timestamp_ns: monotonicNs(), in_batch: isBatching(), batch_id: batchSeq } : {};
|
|
3818
3800
|
if (t === DATA) {
|
|
3819
3801
|
result.values[path] = m[1];
|
|
3820
3802
|
result.events.push({ type: "data", path, data: m[1], ...base });
|
|
@@ -3870,25 +3852,161 @@ var Graph = class _Graph {
|
|
|
3870
3852
|
} else {
|
|
3871
3853
|
Object.assign(merged, extra);
|
|
3872
3854
|
}
|
|
3873
|
-
|
|
3855
|
+
const expanded = graph._createObserveResultForAll(resolveObserveDetail(merged));
|
|
3856
|
+
if (merged.format != null) {
|
|
3857
|
+
graph._attachFormatLogger(expanded, merged);
|
|
3858
|
+
}
|
|
3859
|
+
return expanded;
|
|
3874
3860
|
}
|
|
3875
3861
|
};
|
|
3876
3862
|
}
|
|
3877
3863
|
/**
|
|
3878
|
-
*
|
|
3879
|
-
*
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3864
|
+
* Fallback ObserveResult for single-node when inspector is disabled but `format` is requested.
|
|
3865
|
+
* Subscribes to raw messages and accumulates events with timeline info.
|
|
3866
|
+
*/
|
|
3867
|
+
_createFallbackObserveResult(path, options) {
|
|
3868
|
+
const timeline = options.timeline !== false;
|
|
3869
|
+
const acc = {
|
|
3870
|
+
values: {},
|
|
3871
|
+
dirtyCount: 0,
|
|
3872
|
+
resolvedCount: 0,
|
|
3873
|
+
events: [],
|
|
3874
|
+
completedCleanly: false,
|
|
3875
|
+
errored: false
|
|
3876
|
+
};
|
|
3877
|
+
const target = this.resolve(path);
|
|
3878
|
+
let batchSeq = 0;
|
|
3879
|
+
const unsub = target.subscribe((msgs) => {
|
|
3880
|
+
batchSeq++;
|
|
3881
|
+
for (const m of msgs) {
|
|
3882
|
+
const t = m[0];
|
|
3883
|
+
const base = timeline ? { timestamp_ns: monotonicNs(), in_batch: isBatching(), batch_id: batchSeq } : {};
|
|
3884
|
+
if (t === DATA) {
|
|
3885
|
+
acc.values[path] = m[1];
|
|
3886
|
+
acc.events.push({ type: "data", path, data: m[1], ...base });
|
|
3887
|
+
} else if (t === DIRTY) {
|
|
3888
|
+
acc.dirtyCount++;
|
|
3889
|
+
acc.events.push({ type: "dirty", path, ...base });
|
|
3890
|
+
} else if (t === RESOLVED) {
|
|
3891
|
+
acc.resolvedCount++;
|
|
3892
|
+
acc.events.push({ type: "resolved", path, ...base });
|
|
3893
|
+
} else if (t === COMPLETE) {
|
|
3894
|
+
if (!acc.errored) acc.completedCleanly = true;
|
|
3895
|
+
acc.events.push({ type: "complete", path, ...base });
|
|
3896
|
+
} else if (t === ERROR) {
|
|
3897
|
+
acc.errored = true;
|
|
3898
|
+
acc.events.push({ type: "error", path, data: m[1], ...base });
|
|
3899
|
+
}
|
|
3900
|
+
}
|
|
3901
|
+
});
|
|
3902
|
+
return {
|
|
3903
|
+
get values() {
|
|
3904
|
+
return acc.values;
|
|
3905
|
+
},
|
|
3906
|
+
get dirtyCount() {
|
|
3907
|
+
return acc.dirtyCount;
|
|
3908
|
+
},
|
|
3909
|
+
get resolvedCount() {
|
|
3910
|
+
return acc.resolvedCount;
|
|
3911
|
+
},
|
|
3912
|
+
get events() {
|
|
3913
|
+
return acc.events;
|
|
3914
|
+
},
|
|
3915
|
+
get completedCleanly() {
|
|
3916
|
+
return acc.completedCleanly;
|
|
3917
|
+
},
|
|
3918
|
+
get errored() {
|
|
3919
|
+
return acc.errored;
|
|
3920
|
+
},
|
|
3921
|
+
dispose() {
|
|
3922
|
+
unsub();
|
|
3923
|
+
},
|
|
3924
|
+
expand() {
|
|
3925
|
+
throw new Error("expand() requires inspector mode (Graph.inspectorEnabled = true)");
|
|
3926
|
+
}
|
|
3927
|
+
};
|
|
3928
|
+
}
|
|
3929
|
+
/**
|
|
3930
|
+
* Fallback ObserveResult for graph-wide when inspector is disabled but `format` is requested.
|
|
3931
|
+
*/
|
|
3932
|
+
_createFallbackObserveResultForAll(options) {
|
|
3933
|
+
const timeline = options.timeline !== false;
|
|
3934
|
+
const actor = options.actor;
|
|
3935
|
+
const acc = {
|
|
3936
|
+
values: {},
|
|
3937
|
+
dirtyCount: 0,
|
|
3938
|
+
resolvedCount: 0,
|
|
3939
|
+
events: [],
|
|
3940
|
+
completedCleanly: false,
|
|
3941
|
+
errored: false
|
|
3942
|
+
};
|
|
3943
|
+
const targets = [];
|
|
3944
|
+
this._collectObserveTargets("", targets);
|
|
3945
|
+
targets.sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
|
|
3946
|
+
const picked = actor == null ? targets : targets.filter(([, nd]) => nd.allowsObserve(actor));
|
|
3947
|
+
let batchSeq = 0;
|
|
3948
|
+
const unsubs = picked.map(
|
|
3949
|
+
([path, nd]) => nd.subscribe((msgs) => {
|
|
3950
|
+
batchSeq++;
|
|
3951
|
+
for (const m of msgs) {
|
|
3952
|
+
const t = m[0];
|
|
3953
|
+
const base = timeline ? { timestamp_ns: monotonicNs(), in_batch: isBatching(), batch_id: batchSeq } : {};
|
|
3954
|
+
if (t === DATA) {
|
|
3955
|
+
acc.values[path] = m[1];
|
|
3956
|
+
acc.events.push({ type: "data", path, data: m[1], ...base });
|
|
3957
|
+
} else if (t === DIRTY) {
|
|
3958
|
+
acc.dirtyCount++;
|
|
3959
|
+
acc.events.push({ type: "dirty", path, ...base });
|
|
3960
|
+
} else if (t === RESOLVED) {
|
|
3961
|
+
acc.resolvedCount++;
|
|
3962
|
+
acc.events.push({ type: "resolved", path, ...base });
|
|
3963
|
+
} else if (t === COMPLETE) {
|
|
3964
|
+
if (!acc.errored) acc.completedCleanly = true;
|
|
3965
|
+
acc.events.push({ type: "complete", path, ...base });
|
|
3966
|
+
} else if (t === ERROR) {
|
|
3967
|
+
acc.errored = true;
|
|
3968
|
+
acc.events.push({ type: "error", path, data: m[1], ...base });
|
|
3969
|
+
}
|
|
3970
|
+
}
|
|
3971
|
+
})
|
|
3972
|
+
);
|
|
3973
|
+
return {
|
|
3974
|
+
get values() {
|
|
3975
|
+
return acc.values;
|
|
3976
|
+
},
|
|
3977
|
+
get dirtyCount() {
|
|
3978
|
+
return acc.dirtyCount;
|
|
3979
|
+
},
|
|
3980
|
+
get resolvedCount() {
|
|
3981
|
+
return acc.resolvedCount;
|
|
3982
|
+
},
|
|
3983
|
+
get events() {
|
|
3984
|
+
return acc.events;
|
|
3985
|
+
},
|
|
3986
|
+
get completedCleanly() {
|
|
3987
|
+
return acc.completedCleanly;
|
|
3988
|
+
},
|
|
3989
|
+
get errored() {
|
|
3990
|
+
return acc.errored;
|
|
3991
|
+
},
|
|
3992
|
+
dispose() {
|
|
3993
|
+
for (const u of unsubs) u();
|
|
3994
|
+
},
|
|
3995
|
+
expand() {
|
|
3996
|
+
throw new Error("expand() requires inspector mode (Graph.inspectorEnabled = true)");
|
|
3997
|
+
}
|
|
3998
|
+
};
|
|
3999
|
+
}
|
|
4000
|
+
/**
|
|
4001
|
+
* Attaches a format logger to an ObserveResult, rendering events as they arrive.
|
|
4002
|
+
* Wraps the result's dispose to flush pending events.
|
|
3885
4003
|
*/
|
|
3886
|
-
|
|
4004
|
+
_attachFormatLogger(result, options) {
|
|
4005
|
+
const format = options.format;
|
|
4006
|
+
const logger = options.logger ?? ((line) => console.log(line));
|
|
3887
4007
|
const include = options.includeTypes ? new Set(options.includeTypes) : null;
|
|
3888
4008
|
const exclude = options.excludeTypes ? new Set(options.excludeTypes) : null;
|
|
3889
|
-
const theme =
|
|
3890
|
-
const format = options.format ?? "pretty";
|
|
3891
|
-
const logger = options.logger ?? ((line) => console.log(line));
|
|
4009
|
+
const theme = resolveObserveTheme(options.theme);
|
|
3892
4010
|
const shouldLog = (type) => {
|
|
3893
4011
|
if (include?.has(type) === false) return false;
|
|
3894
4012
|
if (exclude?.has(type) === true) return false;
|
|
@@ -3913,133 +4031,26 @@ var Graph = class _Graph {
|
|
|
3913
4031
|
const batchPart = event.in_batch ? " [batch]" : "";
|
|
3914
4032
|
return `${pathPart}${color}${event.type.toUpperCase()}${theme.reset}${dataPart}${triggerPart}${batchPart}`;
|
|
3915
4033
|
};
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
const
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
completedCleanly: false,
|
|
3924
|
-
errored: false
|
|
3925
|
-
};
|
|
3926
|
-
let stop2 = () => {
|
|
3927
|
-
};
|
|
3928
|
-
const result2 = {
|
|
3929
|
-
get values() {
|
|
3930
|
-
return acc.values;
|
|
3931
|
-
},
|
|
3932
|
-
get dirtyCount() {
|
|
3933
|
-
return acc.dirtyCount;
|
|
3934
|
-
},
|
|
3935
|
-
get resolvedCount() {
|
|
3936
|
-
return acc.resolvedCount;
|
|
3937
|
-
},
|
|
3938
|
-
get events() {
|
|
3939
|
-
return acc.events;
|
|
3940
|
-
},
|
|
3941
|
-
get completedCleanly() {
|
|
3942
|
-
return acc.completedCleanly;
|
|
3943
|
-
},
|
|
3944
|
-
get errored() {
|
|
3945
|
-
return acc.errored;
|
|
3946
|
-
},
|
|
3947
|
-
dispose() {
|
|
3948
|
-
stop2();
|
|
3949
|
-
},
|
|
3950
|
-
expand() {
|
|
3951
|
-
throw new Error("expand() requires inspector mode (Graph.inspectorEnabled = true)");
|
|
3952
|
-
}
|
|
3953
|
-
};
|
|
3954
|
-
const pushEvent = (path, message) => {
|
|
3955
|
-
const t = message[0];
|
|
3956
|
-
const base = timeline ? { timestamp_ns: monotonicNs(), in_batch: isBatching() } : {};
|
|
3957
|
-
let event;
|
|
3958
|
-
if (t === DATA) {
|
|
3959
|
-
if (path != null) acc.values[path] = message[1];
|
|
3960
|
-
event = { type: "data", ...path != null ? { path } : {}, data: message[1], ...base };
|
|
3961
|
-
} else if (t === DIRTY) {
|
|
3962
|
-
acc.dirtyCount += 1;
|
|
3963
|
-
event = { type: "dirty", ...path != null ? { path } : {}, ...base };
|
|
3964
|
-
} else if (t === RESOLVED) {
|
|
3965
|
-
acc.resolvedCount += 1;
|
|
3966
|
-
event = { type: "resolved", ...path != null ? { path } : {}, ...base };
|
|
3967
|
-
} else if (t === COMPLETE) {
|
|
3968
|
-
if (!acc.errored) acc.completedCleanly = true;
|
|
3969
|
-
event = { type: "complete", ...path != null ? { path } : {}, ...base };
|
|
3970
|
-
} else if (t === ERROR) {
|
|
3971
|
-
acc.errored = true;
|
|
3972
|
-
event = {
|
|
3973
|
-
type: "error",
|
|
3974
|
-
...path != null ? { path } : {},
|
|
3975
|
-
data: message[1],
|
|
3976
|
-
...base
|
|
3977
|
-
};
|
|
4034
|
+
let cursor = 0;
|
|
4035
|
+
const flush = () => {
|
|
4036
|
+
const events = result.events;
|
|
4037
|
+
while (cursor < events.length) {
|
|
4038
|
+
const event = events[cursor++];
|
|
4039
|
+
if (shouldLog(event.type)) {
|
|
4040
|
+
logger(renderEvent(event), event);
|
|
3978
4041
|
}
|
|
3979
|
-
if (!event) return;
|
|
3980
|
-
acc.events.push(event);
|
|
3981
|
-
if (!shouldLog(event.type)) return;
|
|
3982
|
-
logger(renderEvent(event), event);
|
|
3983
|
-
};
|
|
3984
|
-
if (options.path != null) {
|
|
3985
|
-
const stream2 = this.observe(options.path, {
|
|
3986
|
-
actor: options.actor,
|
|
3987
|
-
structured: false
|
|
3988
|
-
});
|
|
3989
|
-
stop2 = stream2.subscribe((messages) => {
|
|
3990
|
-
for (const m of messages) {
|
|
3991
|
-
pushEvent(options.path, m);
|
|
3992
|
-
}
|
|
3993
|
-
});
|
|
3994
|
-
} else {
|
|
3995
|
-
const stream2 = this.observe({ actor: options.actor, structured: false });
|
|
3996
|
-
stop2 = stream2.subscribe((path, messages) => {
|
|
3997
|
-
for (const m of messages) {
|
|
3998
|
-
pushEvent(path, m);
|
|
3999
|
-
}
|
|
4000
|
-
});
|
|
4001
4042
|
}
|
|
4002
|
-
return {
|
|
4003
|
-
result: result2,
|
|
4004
|
-
dispose() {
|
|
4005
|
-
result2.dispose();
|
|
4006
|
-
}
|
|
4007
|
-
};
|
|
4008
|
-
}
|
|
4009
|
-
const structuredObserveOptions = {
|
|
4010
|
-
actor: options.actor,
|
|
4011
|
-
structured: true,
|
|
4012
|
-
...options.timeline !== false ? { timeline: true } : {},
|
|
4013
|
-
...options.causal ? { causal: true } : {},
|
|
4014
|
-
...options.derived ? { derived: true } : {}
|
|
4015
4043
|
};
|
|
4016
|
-
const
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
for (const event of nextEvents) {
|
|
4022
|
-
if (!shouldLog(event.type)) continue;
|
|
4023
|
-
logger(renderEvent(event), event);
|
|
4024
|
-
}
|
|
4044
|
+
const origPush = result.events.push;
|
|
4045
|
+
result.events.push = function(...items) {
|
|
4046
|
+
const ret = origPush.apply(this, items);
|
|
4047
|
+
flush();
|
|
4048
|
+
return ret;
|
|
4025
4049
|
};
|
|
4026
|
-
const
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
}
|
|
4031
|
-
}) : stream.subscribe((_path, messages) => {
|
|
4032
|
-
if (messages.length > 0) {
|
|
4033
|
-
flushNewEvents();
|
|
4034
|
-
}
|
|
4035
|
-
});
|
|
4036
|
-
return {
|
|
4037
|
-
result,
|
|
4038
|
-
dispose() {
|
|
4039
|
-
stop();
|
|
4040
|
-
flushNewEvents();
|
|
4041
|
-
result.dispose();
|
|
4042
|
-
}
|
|
4050
|
+
const origDispose = result.dispose.bind(result);
|
|
4051
|
+
result.dispose = () => {
|
|
4052
|
+
origDispose();
|
|
4053
|
+
flush();
|
|
4043
4054
|
};
|
|
4044
4055
|
}
|
|
4045
4056
|
/**
|
|
@@ -4434,33 +4445,21 @@ var Graph = class _Graph {
|
|
|
4434
4445
|
// ——————————————————————————————————————————————————————————————
|
|
4435
4446
|
/**
|
|
4436
4447
|
* When `false`, structured observation options (`causal`, `timeline`),
|
|
4437
|
-
*
|
|
4448
|
+
* and `trace()` writes are no-ops. Raw `observe()` always works.
|
|
4438
4449
|
*
|
|
4439
4450
|
* Default: `true` outside production (`process.env.NODE_ENV !== "production"`).
|
|
4440
4451
|
*/
|
|
4441
4452
|
static inspectorEnabled = !(typeof process !== "undefined" && process.env?.NODE_ENV === "production");
|
|
4442
4453
|
_annotations = /* @__PURE__ */ new Map();
|
|
4443
4454
|
_traceRing = new RingBuffer(1e3);
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
annotate(path, reason) {
|
|
4453
|
-
if (!_Graph.inspectorEnabled) return;
|
|
4454
|
-
this.resolve(path);
|
|
4455
|
-
this._annotations.set(path, reason);
|
|
4456
|
-
this._traceRing.push({ path, reason, timestamp_ns: monotonicNs() });
|
|
4457
|
-
}
|
|
4458
|
-
/**
|
|
4459
|
-
* Returns a chronological log of all reasoning annotations (ring buffer).
|
|
4460
|
-
*
|
|
4461
|
-
* @returns `[]` when {@link Graph.inspectorEnabled} is `false`.
|
|
4462
|
-
*/
|
|
4463
|
-
traceLog() {
|
|
4455
|
+
trace(path, reason) {
|
|
4456
|
+
if (path != null && reason != null) {
|
|
4457
|
+
if (!_Graph.inspectorEnabled) return;
|
|
4458
|
+
this.resolve(path);
|
|
4459
|
+
this._annotations.set(path, reason);
|
|
4460
|
+
this._traceRing.push({ path, reason, timestamp_ns: monotonicNs() });
|
|
4461
|
+
return;
|
|
4462
|
+
}
|
|
4464
4463
|
if (!_Graph.inspectorEnabled) return [];
|
|
4465
4464
|
return this._traceRing.toArray();
|
|
4466
4465
|
}
|
|
@@ -5085,11 +5084,8 @@ var GraphReflyModule = _GraphReflyModule;
|
|
|
5085
5084
|
getActor,
|
|
5086
5085
|
getGraphToken,
|
|
5087
5086
|
getNodeToken,
|
|
5088
|
-
observeGraph$,
|
|
5089
|
-
observeNode$,
|
|
5090
5087
|
observeSSE,
|
|
5091
5088
|
observeSubscription,
|
|
5092
|
-
toMessages$,
|
|
5093
5089
|
toObservable
|
|
5094
5090
|
});
|
|
5095
5091
|
//# sourceMappingURL=index.cjs.map
|