@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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
describeNode,
|
|
3
3
|
resolveDescribeFields
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-J7S54G7I.js";
|
|
5
5
|
import {
|
|
6
6
|
COMPLETE,
|
|
7
7
|
DATA,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
messageTier,
|
|
17
17
|
monotonicNs,
|
|
18
18
|
state
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-BV3TPSBK.js";
|
|
20
20
|
|
|
21
21
|
// src/graph/graph.ts
|
|
22
22
|
var PATH_SEP = "::";
|
|
@@ -160,7 +160,7 @@ var RingBuffer = class {
|
|
|
160
160
|
return result;
|
|
161
161
|
}
|
|
162
162
|
};
|
|
163
|
-
var
|
|
163
|
+
var OBSERVE_ANSI_THEME = {
|
|
164
164
|
data: "\x1B[32m",
|
|
165
165
|
dirty: "\x1B[33m",
|
|
166
166
|
resolved: "\x1B[36m",
|
|
@@ -170,7 +170,7 @@ var SPY_ANSI_THEME = {
|
|
|
170
170
|
path: "\x1B[90m",
|
|
171
171
|
reset: "\x1B[0m"
|
|
172
172
|
};
|
|
173
|
-
var
|
|
173
|
+
var OBSERVE_NO_COLOR_THEME = {
|
|
174
174
|
data: "",
|
|
175
175
|
dirty: "",
|
|
176
176
|
resolved: "",
|
|
@@ -190,9 +190,9 @@ function describeData(value) {
|
|
|
190
190
|
return "[unserializable]";
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
|
-
function
|
|
194
|
-
if (theme === "none") return
|
|
195
|
-
if (theme === "ansi" || theme == null) return
|
|
193
|
+
function resolveObserveTheme(theme) {
|
|
194
|
+
if (theme === "none") return OBSERVE_NO_COLOR_THEME;
|
|
195
|
+
if (theme === "ansi" || theme == null) return OBSERVE_ANSI_THEME;
|
|
196
196
|
return {
|
|
197
197
|
data: theme.data ?? "",
|
|
198
198
|
dirty: theme.dirty ?? "",
|
|
@@ -963,9 +963,13 @@ var Graph = class _Graph {
|
|
|
963
963
|
if (actor2 != null && !target.allowsObserve(actor2)) {
|
|
964
964
|
throw new GuardDenied({ actor: actor2, action: "observe", nodeName: path });
|
|
965
965
|
}
|
|
966
|
-
const wantsStructured2 = resolved.structured === true || resolved.timeline === true || resolved.causal === true || resolved.derived === true || resolved.detail === "minimal" || resolved.detail === "full";
|
|
967
|
-
if (wantsStructured2
|
|
968
|
-
|
|
966
|
+
const wantsStructured2 = resolved.structured === true || resolved.timeline === true || resolved.causal === true || resolved.derived === true || resolved.detail === "minimal" || resolved.detail === "full" || resolved.format != null;
|
|
967
|
+
if (wantsStructured2) {
|
|
968
|
+
const result = _Graph.inspectorEnabled ? this._createObserveResult(path, target, resolved) : this._createFallbackObserveResult(path, resolved);
|
|
969
|
+
if (resolved.format != null) {
|
|
970
|
+
this._attachFormatLogger(result, resolved);
|
|
971
|
+
}
|
|
972
|
+
return result;
|
|
969
973
|
}
|
|
970
974
|
return {
|
|
971
975
|
subscribe(sink) {
|
|
@@ -983,9 +987,13 @@ var Graph = class _Graph {
|
|
|
983
987
|
}
|
|
984
988
|
const opts = resolveObserveDetail(pathOrOpts);
|
|
985
989
|
const actor = opts.actor;
|
|
986
|
-
const wantsStructured = opts.structured === true || opts.timeline === true || opts.causal === true || opts.derived === true || opts.detail === "minimal" || opts.detail === "full";
|
|
987
|
-
if (wantsStructured
|
|
988
|
-
|
|
990
|
+
const wantsStructured = opts.structured === true || opts.timeline === true || opts.causal === true || opts.derived === true || opts.detail === "minimal" || opts.detail === "full" || opts.format != null;
|
|
991
|
+
if (wantsStructured) {
|
|
992
|
+
const result = _Graph.inspectorEnabled ? this._createObserveResultForAll(opts) : this._createFallbackObserveResultForAll(opts);
|
|
993
|
+
if (opts.format != null) {
|
|
994
|
+
this._attachFormatLogger(result, opts);
|
|
995
|
+
}
|
|
996
|
+
return result;
|
|
989
997
|
}
|
|
990
998
|
return {
|
|
991
999
|
subscribe: (sink) => {
|
|
@@ -1029,6 +1037,7 @@ var Graph = class _Graph {
|
|
|
1029
1037
|
let lastTriggerDepIndex;
|
|
1030
1038
|
let lastRunDepValues;
|
|
1031
1039
|
let detachInspectorHook;
|
|
1040
|
+
let batchSeq = 0;
|
|
1032
1041
|
if ((causal || derived) && target instanceof NodeImpl) {
|
|
1033
1042
|
detachInspectorHook = target._setInspectorHook((event) => {
|
|
1034
1043
|
if (event.kind === "dep_message") {
|
|
@@ -1041,15 +1050,16 @@ var Graph = class _Graph {
|
|
|
1041
1050
|
type: "derived",
|
|
1042
1051
|
path,
|
|
1043
1052
|
dep_values: [...event.depValues],
|
|
1044
|
-
...timeline ? { timestamp_ns: monotonicNs(), in_batch: isBatching() } : {}
|
|
1053
|
+
...timeline ? { timestamp_ns: monotonicNs(), in_batch: isBatching(), batch_id: batchSeq } : {}
|
|
1045
1054
|
});
|
|
1046
1055
|
}
|
|
1047
1056
|
});
|
|
1048
1057
|
}
|
|
1049
1058
|
const unsub = target.subscribe((msgs) => {
|
|
1059
|
+
batchSeq++;
|
|
1050
1060
|
for (const m of msgs) {
|
|
1051
1061
|
const t = m[0];
|
|
1052
|
-
const base = timeline ? { timestamp_ns: monotonicNs(), in_batch: isBatching() } : {};
|
|
1062
|
+
const base = timeline ? { timestamp_ns: monotonicNs(), in_batch: isBatching(), batch_id: batchSeq } : {};
|
|
1053
1063
|
const withCausal = causal && lastRunDepValues != null ? (() => {
|
|
1054
1064
|
const triggerDep = lastTriggerDepIndex != null && lastTriggerDepIndex >= 0 && target instanceof NodeImpl ? target._deps[lastTriggerDepIndex] : void 0;
|
|
1055
1065
|
const tv = triggerDep?.v;
|
|
@@ -1118,11 +1128,15 @@ var Graph = class _Graph {
|
|
|
1118
1128
|
Object.assign(merged, extra);
|
|
1119
1129
|
}
|
|
1120
1130
|
const resolvedTarget = graph.resolve(basePath);
|
|
1121
|
-
|
|
1131
|
+
const expanded = graph._createObserveResult(
|
|
1122
1132
|
basePath,
|
|
1123
1133
|
resolvedTarget,
|
|
1124
1134
|
resolveObserveDetail(merged)
|
|
1125
1135
|
);
|
|
1136
|
+
if (merged.format != null) {
|
|
1137
|
+
graph._attachFormatLogger(expanded, merged);
|
|
1138
|
+
}
|
|
1139
|
+
return expanded;
|
|
1126
1140
|
}
|
|
1127
1141
|
};
|
|
1128
1142
|
}
|
|
@@ -1142,11 +1156,13 @@ var Graph = class _Graph {
|
|
|
1142
1156
|
this._collectObserveTargets("", targets);
|
|
1143
1157
|
targets.sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
|
|
1144
1158
|
const picked = actor == null ? targets : targets.filter(([, nd]) => nd.allowsObserve(actor));
|
|
1159
|
+
let batchSeq = 0;
|
|
1145
1160
|
const unsubs = picked.map(
|
|
1146
1161
|
([path, nd]) => nd.subscribe((msgs) => {
|
|
1162
|
+
batchSeq++;
|
|
1147
1163
|
for (const m of msgs) {
|
|
1148
1164
|
const t = m[0];
|
|
1149
|
-
const base = timeline ? { timestamp_ns: monotonicNs(), in_batch: isBatching() } : {};
|
|
1165
|
+
const base = timeline ? { timestamp_ns: monotonicNs(), in_batch: isBatching(), batch_id: batchSeq } : {};
|
|
1150
1166
|
if (t === DATA) {
|
|
1151
1167
|
result.values[path] = m[1];
|
|
1152
1168
|
result.events.push({ type: "data", path, data: m[1], ...base });
|
|
@@ -1202,25 +1218,161 @@ var Graph = class _Graph {
|
|
|
1202
1218
|
} else {
|
|
1203
1219
|
Object.assign(merged, extra);
|
|
1204
1220
|
}
|
|
1205
|
-
|
|
1221
|
+
const expanded = graph._createObserveResultForAll(resolveObserveDetail(merged));
|
|
1222
|
+
if (merged.format != null) {
|
|
1223
|
+
graph._attachFormatLogger(expanded, merged);
|
|
1224
|
+
}
|
|
1225
|
+
return expanded;
|
|
1206
1226
|
}
|
|
1207
1227
|
};
|
|
1208
1228
|
}
|
|
1209
1229
|
/**
|
|
1210
|
-
*
|
|
1211
|
-
*
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1230
|
+
* Fallback ObserveResult for single-node when inspector is disabled but `format` is requested.
|
|
1231
|
+
* Subscribes to raw messages and accumulates events with timeline info.
|
|
1232
|
+
*/
|
|
1233
|
+
_createFallbackObserveResult(path, options) {
|
|
1234
|
+
const timeline = options.timeline !== false;
|
|
1235
|
+
const acc = {
|
|
1236
|
+
values: {},
|
|
1237
|
+
dirtyCount: 0,
|
|
1238
|
+
resolvedCount: 0,
|
|
1239
|
+
events: [],
|
|
1240
|
+
completedCleanly: false,
|
|
1241
|
+
errored: false
|
|
1242
|
+
};
|
|
1243
|
+
const target = this.resolve(path);
|
|
1244
|
+
let batchSeq = 0;
|
|
1245
|
+
const unsub = target.subscribe((msgs) => {
|
|
1246
|
+
batchSeq++;
|
|
1247
|
+
for (const m of msgs) {
|
|
1248
|
+
const t = m[0];
|
|
1249
|
+
const base = timeline ? { timestamp_ns: monotonicNs(), in_batch: isBatching(), batch_id: batchSeq } : {};
|
|
1250
|
+
if (t === DATA) {
|
|
1251
|
+
acc.values[path] = m[1];
|
|
1252
|
+
acc.events.push({ type: "data", path, data: m[1], ...base });
|
|
1253
|
+
} else if (t === DIRTY) {
|
|
1254
|
+
acc.dirtyCount++;
|
|
1255
|
+
acc.events.push({ type: "dirty", path, ...base });
|
|
1256
|
+
} else if (t === RESOLVED) {
|
|
1257
|
+
acc.resolvedCount++;
|
|
1258
|
+
acc.events.push({ type: "resolved", path, ...base });
|
|
1259
|
+
} else if (t === COMPLETE) {
|
|
1260
|
+
if (!acc.errored) acc.completedCleanly = true;
|
|
1261
|
+
acc.events.push({ type: "complete", path, ...base });
|
|
1262
|
+
} else if (t === ERROR) {
|
|
1263
|
+
acc.errored = true;
|
|
1264
|
+
acc.events.push({ type: "error", path, data: m[1], ...base });
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
});
|
|
1268
|
+
return {
|
|
1269
|
+
get values() {
|
|
1270
|
+
return acc.values;
|
|
1271
|
+
},
|
|
1272
|
+
get dirtyCount() {
|
|
1273
|
+
return acc.dirtyCount;
|
|
1274
|
+
},
|
|
1275
|
+
get resolvedCount() {
|
|
1276
|
+
return acc.resolvedCount;
|
|
1277
|
+
},
|
|
1278
|
+
get events() {
|
|
1279
|
+
return acc.events;
|
|
1280
|
+
},
|
|
1281
|
+
get completedCleanly() {
|
|
1282
|
+
return acc.completedCleanly;
|
|
1283
|
+
},
|
|
1284
|
+
get errored() {
|
|
1285
|
+
return acc.errored;
|
|
1286
|
+
},
|
|
1287
|
+
dispose() {
|
|
1288
|
+
unsub();
|
|
1289
|
+
},
|
|
1290
|
+
expand() {
|
|
1291
|
+
throw new Error("expand() requires inspector mode (Graph.inspectorEnabled = true)");
|
|
1292
|
+
}
|
|
1293
|
+
};
|
|
1294
|
+
}
|
|
1295
|
+
/**
|
|
1296
|
+
* Fallback ObserveResult for graph-wide when inspector is disabled but `format` is requested.
|
|
1297
|
+
*/
|
|
1298
|
+
_createFallbackObserveResultForAll(options) {
|
|
1299
|
+
const timeline = options.timeline !== false;
|
|
1300
|
+
const actor = options.actor;
|
|
1301
|
+
const acc = {
|
|
1302
|
+
values: {},
|
|
1303
|
+
dirtyCount: 0,
|
|
1304
|
+
resolvedCount: 0,
|
|
1305
|
+
events: [],
|
|
1306
|
+
completedCleanly: false,
|
|
1307
|
+
errored: false
|
|
1308
|
+
};
|
|
1309
|
+
const targets = [];
|
|
1310
|
+
this._collectObserveTargets("", targets);
|
|
1311
|
+
targets.sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
|
|
1312
|
+
const picked = actor == null ? targets : targets.filter(([, nd]) => nd.allowsObserve(actor));
|
|
1313
|
+
let batchSeq = 0;
|
|
1314
|
+
const unsubs = picked.map(
|
|
1315
|
+
([path, nd]) => nd.subscribe((msgs) => {
|
|
1316
|
+
batchSeq++;
|
|
1317
|
+
for (const m of msgs) {
|
|
1318
|
+
const t = m[0];
|
|
1319
|
+
const base = timeline ? { timestamp_ns: monotonicNs(), in_batch: isBatching(), batch_id: batchSeq } : {};
|
|
1320
|
+
if (t === DATA) {
|
|
1321
|
+
acc.values[path] = m[1];
|
|
1322
|
+
acc.events.push({ type: "data", path, data: m[1], ...base });
|
|
1323
|
+
} else if (t === DIRTY) {
|
|
1324
|
+
acc.dirtyCount++;
|
|
1325
|
+
acc.events.push({ type: "dirty", path, ...base });
|
|
1326
|
+
} else if (t === RESOLVED) {
|
|
1327
|
+
acc.resolvedCount++;
|
|
1328
|
+
acc.events.push({ type: "resolved", path, ...base });
|
|
1329
|
+
} else if (t === COMPLETE) {
|
|
1330
|
+
if (!acc.errored) acc.completedCleanly = true;
|
|
1331
|
+
acc.events.push({ type: "complete", path, ...base });
|
|
1332
|
+
} else if (t === ERROR) {
|
|
1333
|
+
acc.errored = true;
|
|
1334
|
+
acc.events.push({ type: "error", path, data: m[1], ...base });
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
})
|
|
1338
|
+
);
|
|
1339
|
+
return {
|
|
1340
|
+
get values() {
|
|
1341
|
+
return acc.values;
|
|
1342
|
+
},
|
|
1343
|
+
get dirtyCount() {
|
|
1344
|
+
return acc.dirtyCount;
|
|
1345
|
+
},
|
|
1346
|
+
get resolvedCount() {
|
|
1347
|
+
return acc.resolvedCount;
|
|
1348
|
+
},
|
|
1349
|
+
get events() {
|
|
1350
|
+
return acc.events;
|
|
1351
|
+
},
|
|
1352
|
+
get completedCleanly() {
|
|
1353
|
+
return acc.completedCleanly;
|
|
1354
|
+
},
|
|
1355
|
+
get errored() {
|
|
1356
|
+
return acc.errored;
|
|
1357
|
+
},
|
|
1358
|
+
dispose() {
|
|
1359
|
+
for (const u of unsubs) u();
|
|
1360
|
+
},
|
|
1361
|
+
expand() {
|
|
1362
|
+
throw new Error("expand() requires inspector mode (Graph.inspectorEnabled = true)");
|
|
1363
|
+
}
|
|
1364
|
+
};
|
|
1365
|
+
}
|
|
1366
|
+
/**
|
|
1367
|
+
* Attaches a format logger to an ObserveResult, rendering events as they arrive.
|
|
1368
|
+
* Wraps the result's dispose to flush pending events.
|
|
1217
1369
|
*/
|
|
1218
|
-
|
|
1370
|
+
_attachFormatLogger(result, options) {
|
|
1371
|
+
const format = options.format;
|
|
1372
|
+
const logger = options.logger ?? ((line) => console.log(line));
|
|
1219
1373
|
const include = options.includeTypes ? new Set(options.includeTypes) : null;
|
|
1220
1374
|
const exclude = options.excludeTypes ? new Set(options.excludeTypes) : null;
|
|
1221
|
-
const theme =
|
|
1222
|
-
const format = options.format ?? "pretty";
|
|
1223
|
-
const logger = options.logger ?? ((line) => console.log(line));
|
|
1375
|
+
const theme = resolveObserveTheme(options.theme);
|
|
1224
1376
|
const shouldLog = (type) => {
|
|
1225
1377
|
if (include?.has(type) === false) return false;
|
|
1226
1378
|
if (exclude?.has(type) === true) return false;
|
|
@@ -1245,133 +1397,26 @@ var Graph = class _Graph {
|
|
|
1245
1397
|
const batchPart = event.in_batch ? " [batch]" : "";
|
|
1246
1398
|
return `${pathPart}${color}${event.type.toUpperCase()}${theme.reset}${dataPart}${triggerPart}${batchPart}`;
|
|
1247
1399
|
};
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
const
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
completedCleanly: false,
|
|
1256
|
-
errored: false
|
|
1257
|
-
};
|
|
1258
|
-
let stop2 = () => {
|
|
1259
|
-
};
|
|
1260
|
-
const result2 = {
|
|
1261
|
-
get values() {
|
|
1262
|
-
return acc.values;
|
|
1263
|
-
},
|
|
1264
|
-
get dirtyCount() {
|
|
1265
|
-
return acc.dirtyCount;
|
|
1266
|
-
},
|
|
1267
|
-
get resolvedCount() {
|
|
1268
|
-
return acc.resolvedCount;
|
|
1269
|
-
},
|
|
1270
|
-
get events() {
|
|
1271
|
-
return acc.events;
|
|
1272
|
-
},
|
|
1273
|
-
get completedCleanly() {
|
|
1274
|
-
return acc.completedCleanly;
|
|
1275
|
-
},
|
|
1276
|
-
get errored() {
|
|
1277
|
-
return acc.errored;
|
|
1278
|
-
},
|
|
1279
|
-
dispose() {
|
|
1280
|
-
stop2();
|
|
1281
|
-
},
|
|
1282
|
-
expand() {
|
|
1283
|
-
throw new Error("expand() requires inspector mode (Graph.inspectorEnabled = true)");
|
|
1284
|
-
}
|
|
1285
|
-
};
|
|
1286
|
-
const pushEvent = (path, message) => {
|
|
1287
|
-
const t = message[0];
|
|
1288
|
-
const base = timeline ? { timestamp_ns: monotonicNs(), in_batch: isBatching() } : {};
|
|
1289
|
-
let event;
|
|
1290
|
-
if (t === DATA) {
|
|
1291
|
-
if (path != null) acc.values[path] = message[1];
|
|
1292
|
-
event = { type: "data", ...path != null ? { path } : {}, data: message[1], ...base };
|
|
1293
|
-
} else if (t === DIRTY) {
|
|
1294
|
-
acc.dirtyCount += 1;
|
|
1295
|
-
event = { type: "dirty", ...path != null ? { path } : {}, ...base };
|
|
1296
|
-
} else if (t === RESOLVED) {
|
|
1297
|
-
acc.resolvedCount += 1;
|
|
1298
|
-
event = { type: "resolved", ...path != null ? { path } : {}, ...base };
|
|
1299
|
-
} else if (t === COMPLETE) {
|
|
1300
|
-
if (!acc.errored) acc.completedCleanly = true;
|
|
1301
|
-
event = { type: "complete", ...path != null ? { path } : {}, ...base };
|
|
1302
|
-
} else if (t === ERROR) {
|
|
1303
|
-
acc.errored = true;
|
|
1304
|
-
event = {
|
|
1305
|
-
type: "error",
|
|
1306
|
-
...path != null ? { path } : {},
|
|
1307
|
-
data: message[1],
|
|
1308
|
-
...base
|
|
1309
|
-
};
|
|
1400
|
+
let cursor = 0;
|
|
1401
|
+
const flush = () => {
|
|
1402
|
+
const events = result.events;
|
|
1403
|
+
while (cursor < events.length) {
|
|
1404
|
+
const event = events[cursor++];
|
|
1405
|
+
if (shouldLog(event.type)) {
|
|
1406
|
+
logger(renderEvent(event), event);
|
|
1310
1407
|
}
|
|
1311
|
-
if (!event) return;
|
|
1312
|
-
acc.events.push(event);
|
|
1313
|
-
if (!shouldLog(event.type)) return;
|
|
1314
|
-
logger(renderEvent(event), event);
|
|
1315
|
-
};
|
|
1316
|
-
if (options.path != null) {
|
|
1317
|
-
const stream2 = this.observe(options.path, {
|
|
1318
|
-
actor: options.actor,
|
|
1319
|
-
structured: false
|
|
1320
|
-
});
|
|
1321
|
-
stop2 = stream2.subscribe((messages) => {
|
|
1322
|
-
for (const m of messages) {
|
|
1323
|
-
pushEvent(options.path, m);
|
|
1324
|
-
}
|
|
1325
|
-
});
|
|
1326
|
-
} else {
|
|
1327
|
-
const stream2 = this.observe({ actor: options.actor, structured: false });
|
|
1328
|
-
stop2 = stream2.subscribe((path, messages) => {
|
|
1329
|
-
for (const m of messages) {
|
|
1330
|
-
pushEvent(path, m);
|
|
1331
|
-
}
|
|
1332
|
-
});
|
|
1333
1408
|
}
|
|
1334
|
-
return {
|
|
1335
|
-
result: result2,
|
|
1336
|
-
dispose() {
|
|
1337
|
-
result2.dispose();
|
|
1338
|
-
}
|
|
1339
|
-
};
|
|
1340
|
-
}
|
|
1341
|
-
const structuredObserveOptions = {
|
|
1342
|
-
actor: options.actor,
|
|
1343
|
-
structured: true,
|
|
1344
|
-
...options.timeline !== false ? { timeline: true } : {},
|
|
1345
|
-
...options.causal ? { causal: true } : {},
|
|
1346
|
-
...options.derived ? { derived: true } : {}
|
|
1347
1409
|
};
|
|
1348
|
-
const
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
for (const event of nextEvents) {
|
|
1354
|
-
if (!shouldLog(event.type)) continue;
|
|
1355
|
-
logger(renderEvent(event), event);
|
|
1356
|
-
}
|
|
1410
|
+
const origPush = result.events.push;
|
|
1411
|
+
result.events.push = function(...items) {
|
|
1412
|
+
const ret = origPush.apply(this, items);
|
|
1413
|
+
flush();
|
|
1414
|
+
return ret;
|
|
1357
1415
|
};
|
|
1358
|
-
const
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
}
|
|
1363
|
-
}) : stream.subscribe((_path, messages) => {
|
|
1364
|
-
if (messages.length > 0) {
|
|
1365
|
-
flushNewEvents();
|
|
1366
|
-
}
|
|
1367
|
-
});
|
|
1368
|
-
return {
|
|
1369
|
-
result,
|
|
1370
|
-
dispose() {
|
|
1371
|
-
stop();
|
|
1372
|
-
flushNewEvents();
|
|
1373
|
-
result.dispose();
|
|
1374
|
-
}
|
|
1416
|
+
const origDispose = result.dispose.bind(result);
|
|
1417
|
+
result.dispose = () => {
|
|
1418
|
+
origDispose();
|
|
1419
|
+
flush();
|
|
1375
1420
|
};
|
|
1376
1421
|
}
|
|
1377
1422
|
/**
|
|
@@ -1766,33 +1811,21 @@ var Graph = class _Graph {
|
|
|
1766
1811
|
// ——————————————————————————————————————————————————————————————
|
|
1767
1812
|
/**
|
|
1768
1813
|
* When `false`, structured observation options (`causal`, `timeline`),
|
|
1769
|
-
*
|
|
1814
|
+
* and `trace()` writes are no-ops. Raw `observe()` always works.
|
|
1770
1815
|
*
|
|
1771
1816
|
* Default: `true` outside production (`process.env.NODE_ENV !== "production"`).
|
|
1772
1817
|
*/
|
|
1773
1818
|
static inspectorEnabled = !(typeof process !== "undefined" && process.env?.NODE_ENV === "production");
|
|
1774
1819
|
_annotations = /* @__PURE__ */ new Map();
|
|
1775
1820
|
_traceRing = new RingBuffer(1e3);
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
annotate(path, reason) {
|
|
1785
|
-
if (!_Graph.inspectorEnabled) return;
|
|
1786
|
-
this.resolve(path);
|
|
1787
|
-
this._annotations.set(path, reason);
|
|
1788
|
-
this._traceRing.push({ path, reason, timestamp_ns: monotonicNs() });
|
|
1789
|
-
}
|
|
1790
|
-
/**
|
|
1791
|
-
* Returns a chronological log of all reasoning annotations (ring buffer).
|
|
1792
|
-
*
|
|
1793
|
-
* @returns `[]` when {@link Graph.inspectorEnabled} is `false`.
|
|
1794
|
-
*/
|
|
1795
|
-
traceLog() {
|
|
1821
|
+
trace(path, reason) {
|
|
1822
|
+
if (path != null && reason != null) {
|
|
1823
|
+
if (!_Graph.inspectorEnabled) return;
|
|
1824
|
+
this.resolve(path);
|
|
1825
|
+
this._annotations.set(path, reason);
|
|
1826
|
+
this._traceRing.push({ path, reason, timestamp_ns: monotonicNs() });
|
|
1827
|
+
return;
|
|
1828
|
+
}
|
|
1796
1829
|
if (!_Graph.inspectorEnabled) return [];
|
|
1797
1830
|
return this._traceRing.toArray();
|
|
1798
1831
|
}
|
|
@@ -1926,4 +1959,4 @@ export {
|
|
|
1926
1959
|
Graph,
|
|
1927
1960
|
reachable
|
|
1928
1961
|
};
|
|
1929
|
-
//# sourceMappingURL=chunk-
|
|
1962
|
+
//# sourceMappingURL=chunk-LB3RYLSC.js.map
|