@graphrefly/graphrefly 0.24.0 → 0.26.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/README.md +8 -0
- package/dist/{chunk-QOWVNWOC.js → chunk-3ZWCKRHX.js} +27 -25
- package/dist/{chunk-QOWVNWOC.js.map → chunk-3ZWCKRHX.js.map} +1 -1
- package/dist/chunk-6LDQFTYS.js +102 -0
- package/dist/chunk-6LDQFTYS.js.map +1 -0
- package/dist/{chunk-5WGT55R4.js → chunk-AMCG74RZ.js} +195 -24
- package/dist/chunk-AMCG74RZ.js.map +1 -0
- package/dist/{chunk-AOCBDH4T.js → chunk-BVZYTZ5H.js} +76 -103
- package/dist/chunk-BVZYTZ5H.js.map +1 -0
- package/dist/chunk-FQMKGR6L.js +330 -0
- package/dist/chunk-FQMKGR6L.js.map +1 -0
- package/dist/chunk-HXZEYDUR.js +94 -0
- package/dist/chunk-HXZEYDUR.js.map +1 -0
- package/dist/{chunk-IPLKX3L2.js → chunk-IZYUSJC7.js} +16 -14
- package/dist/{chunk-IPLKX3L2.js.map → chunk-IZYUSJC7.js.map} +1 -1
- package/dist/chunk-J22W6HV3.js +107 -0
- package/dist/chunk-J22W6HV3.js.map +1 -0
- package/dist/{chunk-HWPIFSW2.js → chunk-JSCT3CR4.js} +6 -4
- package/dist/{chunk-HWPIFSW2.js.map → chunk-JSCT3CR4.js.map} +1 -1
- package/dist/chunk-JYXEWPH4.js +62 -0
- package/dist/chunk-JYXEWPH4.js.map +1 -0
- package/dist/chunk-LCE3GF5P.js +866 -0
- package/dist/chunk-LCE3GF5P.js.map +1 -0
- package/dist/chunk-MJ2NKQQL.js +119 -0
- package/dist/chunk-MJ2NKQQL.js.map +1 -0
- package/dist/chunk-N6UR7YVY.js +198 -0
- package/dist/chunk-N6UR7YVY.js.map +1 -0
- package/dist/chunk-OHISZPOJ.js +97 -0
- package/dist/chunk-OHISZPOJ.js.map +1 -0
- package/dist/{chunk-5DJTTKX3.js → chunk-PHOUUNK7.js} +74 -111
- package/dist/chunk-PHOUUNK7.js.map +1 -0
- package/dist/{chunk-PY4XCDLR.js → chunk-RB6QPHJ7.js} +8 -6
- package/dist/{chunk-PY4XCDLR.js.map → chunk-RB6QPHJ7.js.map} +1 -1
- package/dist/chunk-SN4YWWYO.js +171 -0
- package/dist/chunk-SN4YWWYO.js.map +1 -0
- package/dist/chunk-SX52TAR4.js +110 -0
- package/dist/chunk-SX52TAR4.js.map +1 -0
- package/dist/{chunk-XOFWRC73.js → chunk-THTWHNU4.js} +319 -24
- package/dist/chunk-THTWHNU4.js.map +1 -0
- package/dist/{chunk-H4RVA4VE.js → chunk-VYPWMZ6H.js} +2 -2
- package/dist/chunk-XGPU467M.js +136 -0
- package/dist/chunk-XGPU467M.js.map +1 -0
- package/dist/{chunk-TDEXAMGO.js → chunk-ZQMEI34O.js} +206 -574
- package/dist/chunk-ZQMEI34O.js.map +1 -0
- package/dist/compat/index.cjs +7656 -0
- package/dist/compat/index.cjs.map +1 -0
- package/dist/compat/index.d.cts +18 -0
- package/dist/compat/index.d.ts +18 -0
- package/dist/compat/index.js +49 -0
- package/dist/compat/index.js.map +1 -0
- package/dist/compat/jotai/index.cjs +2048 -0
- package/dist/compat/jotai/index.cjs.map +1 -0
- package/dist/compat/jotai/index.d.cts +2 -0
- package/dist/compat/jotai/index.d.ts +2 -0
- package/dist/compat/jotai/index.js +9 -0
- package/dist/compat/jotai/index.js.map +1 -0
- package/dist/compat/nanostores/index.cjs +2175 -0
- package/dist/compat/nanostores/index.cjs.map +1 -0
- package/dist/compat/nanostores/index.d.cts +2 -0
- package/dist/compat/nanostores/index.d.ts +2 -0
- package/dist/compat/nanostores/index.js +23 -0
- package/dist/compat/nanostores/index.js.map +1 -0
- package/dist/compat/nestjs/index.cjs +350 -16
- package/dist/compat/nestjs/index.cjs.map +1 -1
- package/dist/compat/nestjs/index.d.cts +6 -6
- package/dist/compat/nestjs/index.d.ts +6 -6
- package/dist/compat/nestjs/index.js +10 -9
- package/dist/compat/react/index.cjs +141 -0
- package/dist/compat/react/index.cjs.map +1 -0
- package/dist/compat/react/index.d.cts +2 -0
- package/dist/compat/react/index.d.ts +2 -0
- package/dist/compat/react/index.js +12 -0
- package/dist/compat/react/index.js.map +1 -0
- package/dist/compat/solid/index.cjs +128 -0
- package/dist/compat/solid/index.cjs.map +1 -0
- package/dist/compat/solid/index.d.cts +2 -0
- package/dist/compat/solid/index.d.ts +2 -0
- package/dist/compat/solid/index.js +12 -0
- package/dist/compat/solid/index.js.map +1 -0
- package/dist/compat/svelte/index.cjs +131 -0
- package/dist/compat/svelte/index.cjs.map +1 -0
- package/dist/compat/svelte/index.d.cts +2 -0
- package/dist/compat/svelte/index.d.ts +2 -0
- package/dist/compat/svelte/index.js +12 -0
- package/dist/compat/svelte/index.js.map +1 -0
- package/dist/compat/vue/index.cjs +146 -0
- package/dist/compat/vue/index.cjs.map +1 -0
- package/dist/compat/vue/index.d.cts +3 -0
- package/dist/compat/vue/index.d.ts +3 -0
- package/dist/compat/vue/index.js +12 -0
- package/dist/compat/vue/index.js.map +1 -0
- package/dist/compat/zustand/index.cjs +4931 -0
- package/dist/compat/zustand/index.cjs.map +1 -0
- package/dist/compat/zustand/index.d.cts +5 -0
- package/dist/compat/zustand/index.d.ts +5 -0
- package/dist/compat/zustand/index.js +12 -0
- package/dist/compat/zustand/index.js.map +1 -0
- package/dist/core/index.cjs +53 -4
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +3 -3
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js +26 -24
- package/dist/demo-shell-26p5fVxn.d.cts +102 -0
- package/dist/demo-shell-DEp-nMTl.d.ts +102 -0
- package/dist/extra/index.cjs +290 -110
- package/dist/extra/index.cjs.map +1 -1
- package/dist/extra/index.d.cts +5 -4
- package/dist/extra/index.d.ts +5 -4
- package/dist/extra/index.js +8 -5
- package/dist/extra/sources.cjs +2486 -0
- package/dist/extra/sources.cjs.map +1 -0
- package/dist/extra/sources.d.cts +465 -0
- package/dist/extra/sources.d.ts +465 -0
- package/dist/extra/sources.js +57 -0
- package/dist/extra/sources.js.map +1 -0
- package/dist/graph/index.cjs +408 -14
- package/dist/graph/index.cjs.map +1 -1
- package/dist/graph/index.d.cts +5 -5
- package/dist/graph/index.d.ts +5 -5
- package/dist/graph/index.js +13 -5
- package/dist/{graph-D-3JIQme.d.cts → graph-6tZ5jEzr.d.cts} +195 -4
- package/dist/{graph-B6NFqv3z.d.ts → graph-DQ69XU0g.d.ts} +195 -4
- package/dist/index-B4MP_8V_.d.cts +37 -0
- package/dist/index-BEfE8H_G.d.cts +121 -0
- package/dist/{index-D7XgsUt7.d.ts → index-BW1z3BN9.d.ts} +169 -127
- package/dist/index-BYOHF0zP.d.ts +34 -0
- package/dist/index-B_IP40nB.d.cts +36 -0
- package/dist/index-Bd_fwmLf.d.cts +45 -0
- package/dist/{index-BysCTzJz.d.ts → index-BeIdBfcb.d.cts} +121 -547
- package/dist/index-BjI6ty9z.d.ts +121 -0
- package/dist/index-Bxb5ZYc9.d.cts +34 -0
- package/dist/{index-BJB7t9gg.d.cts → index-C0ZXMaXO.d.cts} +2 -2
- package/dist/{index-b5BYtczN.d.cts → index-C8mdwMXc.d.cts} +169 -127
- package/dist/index-CDAjUFIv.d.ts +36 -0
- package/dist/index-CPgZ5wRl.d.ts +44 -0
- package/dist/{index-AMWewNDe.d.cts → index-CUwyr1Kk.d.cts} +33 -4
- package/dist/index-CUyrtuOf.d.cts +127 -0
- package/dist/{index-C-TXEa7C.d.ts → index-CY2TljO4.d.ts} +2 -2
- package/dist/index-CmnuOibw.d.ts +37 -0
- package/dist/{index-DiobMNwE.d.ts → index-CuYwdKO-.d.ts} +3 -3
- package/dist/index-DFhjO4Gg.d.cts +44 -0
- package/dist/{index-1z8vRTCt.d.cts → index-DdD5MVDL.d.ts} +121 -547
- package/dist/index-DrISNAOm.d.ts +45 -0
- package/dist/index-QBpffFW-.d.cts +86 -0
- package/dist/{index-J7Kc0oIQ.d.cts → index-_oMEWlDq.d.cts} +3 -3
- package/dist/{index-CYkjxu3s.d.ts → index-eJ6T_qGM.d.ts} +33 -4
- package/dist/index-qldRdbQw.d.ts +86 -0
- package/dist/index-xdGjv0nO.d.ts +127 -0
- package/dist/index.cjs +2334 -195
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1007 -648
- package/dist/index.d.ts +1007 -648
- package/dist/index.js +1204 -1172
- package/dist/index.js.map +1 -1
- package/dist/{meta-CnkLA_43.d.ts → meta-BGqSZ7mt.d.ts} +1 -1
- package/dist/{meta-DWbkoq1s.d.cts → meta-C0-8XW6Q.d.cts} +1 -1
- package/dist/{node-B-f-Lu-k.d.cts → node-C_IBuvX2.d.cts} +26 -1
- package/dist/{node-B-f-Lu-k.d.ts → node-C_IBuvX2.d.ts} +26 -1
- package/dist/{observable-DBnrwcar.d.cts → observable-Crr1jgzx.d.cts} +1 -1
- package/dist/{observable-uP-wy_uK.d.ts → observable-DCk45RH5.d.ts} +1 -1
- package/dist/patterns/demo-shell.cjs +5604 -0
- package/dist/patterns/demo-shell.cjs.map +1 -0
- package/dist/patterns/demo-shell.d.cts +6 -0
- package/dist/patterns/demo-shell.d.ts +6 -0
- package/dist/patterns/demo-shell.js +15 -0
- package/dist/patterns/demo-shell.js.map +1 -0
- package/dist/patterns/reactive-layout/index.cjs +843 -29
- package/dist/patterns/reactive-layout/index.cjs.map +1 -1
- package/dist/patterns/reactive-layout/index.d.cts +6 -5
- package/dist/patterns/reactive-layout/index.d.ts +6 -5
- package/dist/patterns/reactive-layout/index.js +25 -10
- package/dist/reactive-layout-BaOQefHu.d.cts +183 -0
- package/dist/reactive-layout-D9gejYXE.d.ts +183 -0
- package/dist/{storage-BuTdpCI1.d.cts → storage-BMycWEh2.d.ts} +9 -1
- package/dist/{storage-F2X1U1x0.d.ts → storage-DiqWHzVI.d.cts} +9 -1
- package/package.json +32 -2
- package/dist/chunk-5DJTTKX3.js.map +0 -1
- package/dist/chunk-5WGT55R4.js.map +0 -1
- package/dist/chunk-AOCBDH4T.js.map +0 -1
- package/dist/chunk-MW4VAKAO.js +0 -47
- package/dist/chunk-MW4VAKAO.js.map +0 -1
- package/dist/chunk-TDEXAMGO.js.map +0 -1
- package/dist/chunk-XOFWRC73.js.map +0 -1
- /package/dist/{chunk-H4RVA4VE.js.map → chunk-VYPWMZ6H.js.map} +0 -0
package/dist/extra/index.cjs
CHANGED
|
@@ -100,6 +100,7 @@ __export(extra_exports, {
|
|
|
100
100
|
fromPromise: () => fromPromise,
|
|
101
101
|
fromPulsar: () => fromPulsar,
|
|
102
102
|
fromRabbitMQ: () => fromRabbitMQ,
|
|
103
|
+
fromRaf: () => fromRaf,
|
|
103
104
|
fromRedisStream: () => fromRedisStream,
|
|
104
105
|
fromSSE: () => fromSSE,
|
|
105
106
|
fromSqlite: () => fromSqlite,
|
|
@@ -971,6 +972,12 @@ var NodeImpl = class _NodeImpl {
|
|
|
971
972
|
_autoError;
|
|
972
973
|
_pausable;
|
|
973
974
|
_guard;
|
|
975
|
+
/**
|
|
976
|
+
* @internal Additional guards stacked at runtime via {@link NodeImpl._pushGuard}
|
|
977
|
+
* (e.g. by `policyEnforcer({ mode: "enforce" })`, roadmap §9.2). Effective
|
|
978
|
+
* write/signal/observe checks AND the original `_guard` with every entry here.
|
|
979
|
+
*/
|
|
980
|
+
_extraGuards;
|
|
974
981
|
_hashFn;
|
|
975
982
|
_versioning;
|
|
976
983
|
/**
|
|
@@ -1144,18 +1151,61 @@ var NodeImpl = class _NodeImpl {
|
|
|
1144
1151
|
if (this._inspectorHooks?.size === 0) this._inspectorHooks = void 0;
|
|
1145
1152
|
};
|
|
1146
1153
|
}
|
|
1154
|
+
/**
|
|
1155
|
+
* @internal Push an additional guard onto this node. Effective enforcement
|
|
1156
|
+
* is the AND of `_guard` and every guard pushed via this hook — any one
|
|
1157
|
+
* rejecting throws {@link GuardDenied}. Returns a disposer that removes
|
|
1158
|
+
* the pushed guard. Multiple guards may be stacked simultaneously.
|
|
1159
|
+
*
|
|
1160
|
+
* Used by `policyEnforcer({ mode: "enforce" })` (roadmap §9.2) to overlay
|
|
1161
|
+
* runtime constraint enforcement onto an existing graph without rebuilding
|
|
1162
|
+
* its nodes. Pre-1.0 internal API; not part of the public surface.
|
|
1163
|
+
*
|
|
1164
|
+
* **Identity semantics:** guards are tracked in a `Set`, so pushing the
|
|
1165
|
+
* same `NodeGuard` reference twice is a single registration. Wrap each
|
|
1166
|
+
* push in a unique closure if independent stacking is needed.
|
|
1167
|
+
*
|
|
1168
|
+
* **Iteration order:** insertion-ordered (`Set` semantics). Determinism
|
|
1169
|
+
* follows from single-threaded JS execution; nested re-entry from inside
|
|
1170
|
+
* a guard body (push/pop while iterating) is undefined-but-survivable.
|
|
1171
|
+
*/
|
|
1172
|
+
_pushGuard(guard) {
|
|
1173
|
+
if (this._extraGuards == null) this._extraGuards = /* @__PURE__ */ new Set();
|
|
1174
|
+
this._extraGuards.add(guard);
|
|
1175
|
+
return () => {
|
|
1176
|
+
this._extraGuards?.delete(guard);
|
|
1177
|
+
if (this._extraGuards?.size === 0) this._extraGuards = void 0;
|
|
1178
|
+
};
|
|
1179
|
+
}
|
|
1147
1180
|
allowsObserve(actor) {
|
|
1148
|
-
if (this._guard == null) return true;
|
|
1149
|
-
|
|
1181
|
+
if (this._guard == null && this._extraGuards == null) return true;
|
|
1182
|
+
const a = normalizeActor(actor);
|
|
1183
|
+
if (this._guard != null && !this._guard(a, "observe")) return false;
|
|
1184
|
+
if (this._extraGuards != null) {
|
|
1185
|
+
for (const eg of this._extraGuards) {
|
|
1186
|
+
if (!eg(a, "observe")) return false;
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
return true;
|
|
1150
1190
|
}
|
|
1151
1191
|
// --- Guard helper ---
|
|
1152
1192
|
_checkGuard(options) {
|
|
1153
|
-
if (options?.internal
|
|
1193
|
+
if (options?.internal) return;
|
|
1194
|
+
const hasGuard = this._guard != null || this._extraGuards != null;
|
|
1195
|
+
const hasActor = options?.actor != null;
|
|
1196
|
+
if (!hasGuard && !hasActor) return;
|
|
1154
1197
|
const actor = normalizeActor(options?.actor);
|
|
1155
1198
|
const action = options?.delivery === "signal" ? "signal" : "write";
|
|
1156
|
-
if (!this._guard(actor, action)) {
|
|
1199
|
+
if (this._guard != null && !this._guard(actor, action)) {
|
|
1157
1200
|
throw new GuardDenied({ actor, action, nodeName: this.name });
|
|
1158
1201
|
}
|
|
1202
|
+
if (this._extraGuards != null) {
|
|
1203
|
+
for (const eg of this._extraGuards) {
|
|
1204
|
+
if (!eg(actor, action)) {
|
|
1205
|
+
throw new GuardDenied({ actor, action, nodeName: this.name });
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1159
1209
|
this._lastMutation = { actor, timestamp_ns: wallClockNs() };
|
|
1160
1210
|
}
|
|
1161
1211
|
// --- Public transport ---
|
|
@@ -2330,10 +2380,6 @@ function externalBundle(register, channels, opts) {
|
|
|
2330
2380
|
return Object.assign(nodes, { dispose });
|
|
2331
2381
|
}
|
|
2332
2382
|
|
|
2333
|
-
// src/extra/sources.ts
|
|
2334
|
-
var import_node_fs = require("fs");
|
|
2335
|
-
var import_node_path = require("path");
|
|
2336
|
-
|
|
2337
2383
|
// src/extra/cron.ts
|
|
2338
2384
|
function parseField(field, min, max) {
|
|
2339
2385
|
const result = /* @__PURE__ */ new Set();
|
|
@@ -2471,6 +2517,72 @@ function fromTimer(ms, opts) {
|
|
|
2471
2517
|
return cleanup;
|
|
2472
2518
|
}, sourceOpts2(rest));
|
|
2473
2519
|
}
|
|
2520
|
+
function fromRaf(opts) {
|
|
2521
|
+
const { signal, ...rest } = opts ?? {};
|
|
2522
|
+
return producer((a) => {
|
|
2523
|
+
let done = false;
|
|
2524
|
+
let rafId;
|
|
2525
|
+
let fallbackTimer;
|
|
2526
|
+
let abortListenerAdded = false;
|
|
2527
|
+
let visibilityListenerAdded = false;
|
|
2528
|
+
const raf = typeof requestAnimationFrame === "function" ? requestAnimationFrame : void 0;
|
|
2529
|
+
const caf = typeof cancelAnimationFrame === "function" ? cancelAnimationFrame : void 0;
|
|
2530
|
+
const doc = typeof document !== "undefined" ? document : void 0;
|
|
2531
|
+
const clearPending = () => {
|
|
2532
|
+
if (rafId !== void 0 && caf) caf(rafId);
|
|
2533
|
+
if (fallbackTimer !== void 0) clearTimeout(fallbackTimer);
|
|
2534
|
+
rafId = void 0;
|
|
2535
|
+
fallbackTimer = void 0;
|
|
2536
|
+
};
|
|
2537
|
+
const cleanup = () => {
|
|
2538
|
+
done = true;
|
|
2539
|
+
clearPending();
|
|
2540
|
+
if (abortListenerAdded) {
|
|
2541
|
+
signal?.removeEventListener("abort", onAbort);
|
|
2542
|
+
abortListenerAdded = false;
|
|
2543
|
+
}
|
|
2544
|
+
if (visibilityListenerAdded && doc) {
|
|
2545
|
+
doc.removeEventListener("visibilitychange", onVisibilityChange);
|
|
2546
|
+
visibilityListenerAdded = false;
|
|
2547
|
+
}
|
|
2548
|
+
};
|
|
2549
|
+
const onAbort = () => {
|
|
2550
|
+
if (done) return;
|
|
2551
|
+
cleanup();
|
|
2552
|
+
a.down([[ERROR, signal.reason]]);
|
|
2553
|
+
};
|
|
2554
|
+
const tick = (now) => {
|
|
2555
|
+
if (done) return;
|
|
2556
|
+
a.emit(now);
|
|
2557
|
+
scheduleNext();
|
|
2558
|
+
};
|
|
2559
|
+
const scheduleNext = () => {
|
|
2560
|
+
if (done) return;
|
|
2561
|
+
if (raf && (!doc || doc.visibilityState !== "hidden")) {
|
|
2562
|
+
rafId = raf(tick);
|
|
2563
|
+
} else {
|
|
2564
|
+
fallbackTimer = setTimeout(() => tick(performance.now()), 16);
|
|
2565
|
+
}
|
|
2566
|
+
};
|
|
2567
|
+
const onVisibilityChange = () => {
|
|
2568
|
+
if (done) return;
|
|
2569
|
+
clearPending();
|
|
2570
|
+
scheduleNext();
|
|
2571
|
+
};
|
|
2572
|
+
if (signal?.aborted) {
|
|
2573
|
+
onAbort();
|
|
2574
|
+
return cleanup;
|
|
2575
|
+
}
|
|
2576
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
2577
|
+
abortListenerAdded = signal !== void 0;
|
|
2578
|
+
if (doc && raf) {
|
|
2579
|
+
doc.addEventListener("visibilitychange", onVisibilityChange);
|
|
2580
|
+
visibilityListenerAdded = true;
|
|
2581
|
+
}
|
|
2582
|
+
scheduleNext();
|
|
2583
|
+
return cleanup;
|
|
2584
|
+
}, sourceOpts2(rest));
|
|
2585
|
+
}
|
|
2474
2586
|
function fromCron(expr, opts) {
|
|
2475
2587
|
const schedule = parseCron(expr);
|
|
2476
2588
|
const { tickMs: tickOpt, output, ...rest } = opts ?? {};
|
|
@@ -2505,99 +2617,6 @@ function fromEvent(target, type, opts) {
|
|
|
2505
2617
|
return () => target.removeEventListener(type, handler, options);
|
|
2506
2618
|
}, sourceOpts2(rest));
|
|
2507
2619
|
}
|
|
2508
|
-
function fromFSWatch(paths, opts) {
|
|
2509
|
-
const list = Array.isArray(paths) ? paths : [paths];
|
|
2510
|
-
if (list.length === 0) {
|
|
2511
|
-
throw new RangeError("fromFSWatch expects at least one path");
|
|
2512
|
-
}
|
|
2513
|
-
const { recursive = true, debounce: debounce2 = 100, include, exclude, ...rest } = opts ?? {};
|
|
2514
|
-
const includePatterns = include?.map(globToRegExp) ?? [];
|
|
2515
|
-
const excludePatterns = (exclude ?? ["**/node_modules/**", "**/.git/**", "**/dist/**"]).map(
|
|
2516
|
-
globToRegExp
|
|
2517
|
-
);
|
|
2518
|
-
return producer((a) => {
|
|
2519
|
-
const pending = /* @__PURE__ */ new Map();
|
|
2520
|
-
const watchers = [];
|
|
2521
|
-
let stopped = false;
|
|
2522
|
-
let terminalEmitted = false;
|
|
2523
|
-
let generation = 0;
|
|
2524
|
-
const closeWatchers = () => {
|
|
2525
|
-
for (const watcher of watchers.splice(0)) watcher.close();
|
|
2526
|
-
};
|
|
2527
|
-
const emitError = (err) => {
|
|
2528
|
-
if (terminalEmitted) return;
|
|
2529
|
-
terminalEmitted = true;
|
|
2530
|
-
stopped = true;
|
|
2531
|
-
if (timer !== void 0) clearTimeout(timer);
|
|
2532
|
-
timer = void 0;
|
|
2533
|
-
pending.clear();
|
|
2534
|
-
closeWatchers();
|
|
2535
|
-
a.down([[ERROR, err]]);
|
|
2536
|
-
};
|
|
2537
|
-
let timer;
|
|
2538
|
-
const flush = (token) => {
|
|
2539
|
-
timer = void 0;
|
|
2540
|
-
if (stopped || terminalEmitted) return;
|
|
2541
|
-
if (pending.size === 0) return;
|
|
2542
|
-
const batchMessages = [];
|
|
2543
|
-
for (const evt of pending.values()) batchMessages.push([DATA, evt]);
|
|
2544
|
-
pending.clear();
|
|
2545
|
-
if (stopped || terminalEmitted || token !== generation) return;
|
|
2546
|
-
a.down(batchMessages);
|
|
2547
|
-
};
|
|
2548
|
-
try {
|
|
2549
|
-
for (const basePath of list) {
|
|
2550
|
-
const watcher = (0, import_node_fs.watch)(
|
|
2551
|
-
basePath,
|
|
2552
|
-
{ recursive },
|
|
2553
|
-
(eventType, fileName) => {
|
|
2554
|
-
if (stopped || terminalEmitted) return;
|
|
2555
|
-
if (fileName == null) return;
|
|
2556
|
-
const rel = String(fileName).replaceAll("\\", "/");
|
|
2557
|
-
const abs = (0, import_node_path.resolve)(basePath, String(fileName));
|
|
2558
|
-
const normalized = abs.replaceAll("\\", "/");
|
|
2559
|
-
const root = (0, import_node_path.resolve)(basePath).replaceAll("\\", "/");
|
|
2560
|
-
const relForMatch = rel.startsWith("./") ? rel.slice(2) : rel;
|
|
2561
|
-
const included = includePatterns.length === 0 || matchesAnyPattern(normalized, includePatterns) || matchesAnyPattern(relForMatch, includePatterns);
|
|
2562
|
-
if (!included) return;
|
|
2563
|
-
const excluded = matchesAnyPattern(normalized, excludePatterns) || matchesAnyPattern(relForMatch, excludePatterns);
|
|
2564
|
-
if (excluded) return;
|
|
2565
|
-
let kind = "change";
|
|
2566
|
-
if (eventType === "rename") {
|
|
2567
|
-
try {
|
|
2568
|
-
kind = (0, import_node_fs.existsSync)(normalized) ? "create" : "delete";
|
|
2569
|
-
} catch {
|
|
2570
|
-
kind = "rename";
|
|
2571
|
-
}
|
|
2572
|
-
}
|
|
2573
|
-
pending.set(normalized, {
|
|
2574
|
-
type: kind,
|
|
2575
|
-
path: normalized,
|
|
2576
|
-
root,
|
|
2577
|
-
relative_path: relForMatch,
|
|
2578
|
-
timestamp_ns: wallClockNs()
|
|
2579
|
-
});
|
|
2580
|
-
if (timer !== void 0) clearTimeout(timer);
|
|
2581
|
-
const token = generation;
|
|
2582
|
-
timer = setTimeout(() => flush(token), debounce2);
|
|
2583
|
-
}
|
|
2584
|
-
);
|
|
2585
|
-
watcher.on("error", (err) => emitError(err));
|
|
2586
|
-
watchers.push(watcher);
|
|
2587
|
-
}
|
|
2588
|
-
} catch (err) {
|
|
2589
|
-
emitError(err);
|
|
2590
|
-
}
|
|
2591
|
-
return () => {
|
|
2592
|
-
stopped = true;
|
|
2593
|
-
generation += 1;
|
|
2594
|
-
if (timer !== void 0) clearTimeout(timer);
|
|
2595
|
-
timer = void 0;
|
|
2596
|
-
closeWatchers();
|
|
2597
|
-
pending.clear();
|
|
2598
|
-
};
|
|
2599
|
-
}, sourceOpts2(rest));
|
|
2600
|
-
}
|
|
2601
2620
|
function fromIter(iterable, opts) {
|
|
2602
2621
|
return producer((a) => {
|
|
2603
2622
|
let cancelled = false;
|
|
@@ -8849,11 +8868,111 @@ function reactiveLog(initial, options = {}) {
|
|
|
8849
8868
|
};
|
|
8850
8869
|
}
|
|
8851
8870
|
|
|
8871
|
+
// src/extra/sources-fs.ts
|
|
8872
|
+
var import_node_fs = require("node:fs");
|
|
8873
|
+
var import_node_path = require("node:path");
|
|
8874
|
+
function sourceOpts4(opts) {
|
|
8875
|
+
return { describeKind: "producer", ...opts };
|
|
8876
|
+
}
|
|
8877
|
+
function fromFSWatch(paths, opts) {
|
|
8878
|
+
const list = Array.isArray(paths) ? paths : [paths];
|
|
8879
|
+
if (list.length === 0) {
|
|
8880
|
+
throw new RangeError("fromFSWatch expects at least one path");
|
|
8881
|
+
}
|
|
8882
|
+
const { recursive = true, debounce: debounce2 = 100, include, exclude, ...rest } = opts ?? {};
|
|
8883
|
+
const includePatterns = include?.map(globToRegExp) ?? [];
|
|
8884
|
+
const excludePatterns = (exclude ?? ["**/node_modules/**", "**/.git/**", "**/dist/**"]).map(
|
|
8885
|
+
globToRegExp
|
|
8886
|
+
);
|
|
8887
|
+
return producer((a) => {
|
|
8888
|
+
const pending = /* @__PURE__ */ new Map();
|
|
8889
|
+
const watchers = [];
|
|
8890
|
+
let stopped = false;
|
|
8891
|
+
let terminalEmitted = false;
|
|
8892
|
+
let generation = 0;
|
|
8893
|
+
const closeWatchers = () => {
|
|
8894
|
+
for (const watcher of watchers.splice(0)) watcher.close();
|
|
8895
|
+
};
|
|
8896
|
+
const emitError = (err) => {
|
|
8897
|
+
if (terminalEmitted) return;
|
|
8898
|
+
terminalEmitted = true;
|
|
8899
|
+
stopped = true;
|
|
8900
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
8901
|
+
timer = void 0;
|
|
8902
|
+
pending.clear();
|
|
8903
|
+
closeWatchers();
|
|
8904
|
+
a.down([[ERROR, err]]);
|
|
8905
|
+
};
|
|
8906
|
+
let timer;
|
|
8907
|
+
const flush = (token) => {
|
|
8908
|
+
timer = void 0;
|
|
8909
|
+
if (stopped || terminalEmitted) return;
|
|
8910
|
+
if (pending.size === 0) return;
|
|
8911
|
+
const batchMessages = [];
|
|
8912
|
+
for (const evt of pending.values()) batchMessages.push([DATA, evt]);
|
|
8913
|
+
pending.clear();
|
|
8914
|
+
if (stopped || terminalEmitted || token !== generation) return;
|
|
8915
|
+
a.down(batchMessages);
|
|
8916
|
+
};
|
|
8917
|
+
try {
|
|
8918
|
+
for (const basePath of list) {
|
|
8919
|
+
const watcher = (0, import_node_fs.watch)(
|
|
8920
|
+
basePath,
|
|
8921
|
+
{ recursive },
|
|
8922
|
+
(eventType, fileName) => {
|
|
8923
|
+
if (stopped || terminalEmitted) return;
|
|
8924
|
+
if (fileName == null) return;
|
|
8925
|
+
const rel = String(fileName).replaceAll("\\", "/");
|
|
8926
|
+
const abs = (0, import_node_path.resolve)(basePath, String(fileName));
|
|
8927
|
+
const normalized = abs.replaceAll("\\", "/");
|
|
8928
|
+
const root = (0, import_node_path.resolve)(basePath).replaceAll("\\", "/");
|
|
8929
|
+
const relForMatch = rel.startsWith("./") ? rel.slice(2) : rel;
|
|
8930
|
+
const included = includePatterns.length === 0 || matchesAnyPattern(normalized, includePatterns) || matchesAnyPattern(relForMatch, includePatterns);
|
|
8931
|
+
if (!included) return;
|
|
8932
|
+
const excluded = matchesAnyPattern(normalized, excludePatterns) || matchesAnyPattern(relForMatch, excludePatterns);
|
|
8933
|
+
if (excluded) return;
|
|
8934
|
+
let kind = "change";
|
|
8935
|
+
if (eventType === "rename") {
|
|
8936
|
+
try {
|
|
8937
|
+
kind = (0, import_node_fs.existsSync)(normalized) ? "create" : "delete";
|
|
8938
|
+
} catch {
|
|
8939
|
+
kind = "rename";
|
|
8940
|
+
}
|
|
8941
|
+
}
|
|
8942
|
+
pending.set(normalized, {
|
|
8943
|
+
type: kind,
|
|
8944
|
+
path: normalized,
|
|
8945
|
+
root,
|
|
8946
|
+
relative_path: relForMatch,
|
|
8947
|
+
timestamp_ns: wallClockNs()
|
|
8948
|
+
});
|
|
8949
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
8950
|
+
const token = generation;
|
|
8951
|
+
timer = setTimeout(() => flush(token), debounce2);
|
|
8952
|
+
}
|
|
8953
|
+
);
|
|
8954
|
+
watcher.on("error", (err) => emitError(err));
|
|
8955
|
+
watchers.push(watcher);
|
|
8956
|
+
}
|
|
8957
|
+
} catch (err) {
|
|
8958
|
+
emitError(err);
|
|
8959
|
+
}
|
|
8960
|
+
return () => {
|
|
8961
|
+
stopped = true;
|
|
8962
|
+
generation += 1;
|
|
8963
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
8964
|
+
timer = void 0;
|
|
8965
|
+
closeWatchers();
|
|
8966
|
+
pending.clear();
|
|
8967
|
+
};
|
|
8968
|
+
}, sourceOpts4(rest));
|
|
8969
|
+
}
|
|
8970
|
+
|
|
8852
8971
|
// src/extra/storage.ts
|
|
8853
|
-
var import_node_crypto = require("crypto");
|
|
8854
|
-
var import_node_fs2 = require("fs");
|
|
8855
|
-
var import_node_path2 = require("path");
|
|
8856
|
-
var import_node_sqlite = require("sqlite");
|
|
8972
|
+
var import_node_crypto = require("node:crypto");
|
|
8973
|
+
var import_node_fs2 = require("node:fs");
|
|
8974
|
+
var import_node_path2 = require("node:path");
|
|
8975
|
+
var import_node_sqlite = require("node:sqlite");
|
|
8857
8976
|
function sortJsonValue(value) {
|
|
8858
8977
|
if (value === null || typeof value !== "object") return value;
|
|
8859
8978
|
if (Array.isArray(value)) return value.map(sortJsonValue);
|
|
@@ -8878,6 +8997,9 @@ function memoryStorage() {
|
|
|
8878
8997
|
},
|
|
8879
8998
|
clear(key) {
|
|
8880
8999
|
data.delete(key);
|
|
9000
|
+
},
|
|
9001
|
+
list() {
|
|
9002
|
+
return [...data.keys()].sort();
|
|
8881
9003
|
}
|
|
8882
9004
|
};
|
|
8883
9005
|
}
|
|
@@ -8892,16 +9014,54 @@ function dictStorage(storage) {
|
|
|
8892
9014
|
},
|
|
8893
9015
|
clear(key) {
|
|
8894
9016
|
delete storage[key];
|
|
9017
|
+
},
|
|
9018
|
+
list() {
|
|
9019
|
+
return Object.keys(storage).sort();
|
|
8895
9020
|
}
|
|
8896
9021
|
};
|
|
8897
9022
|
}
|
|
8898
9023
|
function fileStorage(dir) {
|
|
9024
|
+
const encoder = new TextEncoder();
|
|
9025
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
8899
9026
|
const pathFor = (key) => {
|
|
8900
|
-
|
|
8901
|
-
|
|
8902
|
-
(
|
|
8903
|
-
|
|
8904
|
-
|
|
9027
|
+
let out = "";
|
|
9028
|
+
for (const ch of key) {
|
|
9029
|
+
if (ch.length === 1 && /[a-zA-Z0-9_-]/.test(ch)) {
|
|
9030
|
+
out += ch;
|
|
9031
|
+
continue;
|
|
9032
|
+
}
|
|
9033
|
+
for (const byte of encoder.encode(ch)) {
|
|
9034
|
+
out += `%${byte.toString(16).padStart(2, "0")}`;
|
|
9035
|
+
}
|
|
9036
|
+
}
|
|
9037
|
+
return (0, import_node_path2.join)(dir, `${out}.json`);
|
|
9038
|
+
};
|
|
9039
|
+
const keyFromFilename = (filename) => {
|
|
9040
|
+
if (!filename.endsWith(".json")) return null;
|
|
9041
|
+
const stem = filename.slice(0, -".json".length);
|
|
9042
|
+
const bytes = [];
|
|
9043
|
+
const encodeAscii = (s) => {
|
|
9044
|
+
for (let i2 = 0; i2 < s.length; i2++) bytes.push(s.charCodeAt(i2));
|
|
9045
|
+
};
|
|
9046
|
+
let i = 0;
|
|
9047
|
+
while (i < stem.length) {
|
|
9048
|
+
const ch = stem[i];
|
|
9049
|
+
if (ch === "%" && i + 2 < stem.length) {
|
|
9050
|
+
const hex = stem.slice(i + 1, i + 3);
|
|
9051
|
+
if (/^[0-9a-f]{2}$/i.test(hex)) {
|
|
9052
|
+
bytes.push(Number.parseInt(hex, 16));
|
|
9053
|
+
i += 3;
|
|
9054
|
+
continue;
|
|
9055
|
+
}
|
|
9056
|
+
}
|
|
9057
|
+
encodeAscii(ch);
|
|
9058
|
+
i += 1;
|
|
9059
|
+
}
|
|
9060
|
+
try {
|
|
9061
|
+
return decoder.decode(new Uint8Array(bytes));
|
|
9062
|
+
} catch {
|
|
9063
|
+
return null;
|
|
9064
|
+
}
|
|
8905
9065
|
};
|
|
8906
9066
|
return {
|
|
8907
9067
|
save(key, record) {
|
|
@@ -8938,6 +9098,21 @@ function fileStorage(dir) {
|
|
|
8938
9098
|
} catch (e) {
|
|
8939
9099
|
if (e.code !== "ENOENT") throw e;
|
|
8940
9100
|
}
|
|
9101
|
+
},
|
|
9102
|
+
list() {
|
|
9103
|
+
try {
|
|
9104
|
+
const entries = (0, import_node_fs2.readdirSync)(dir);
|
|
9105
|
+
const keys = [];
|
|
9106
|
+
for (const entry of entries) {
|
|
9107
|
+
if (entry.startsWith(".")) continue;
|
|
9108
|
+
const k = keyFromFilename(entry);
|
|
9109
|
+
if (k !== null) keys.push(k);
|
|
9110
|
+
}
|
|
9111
|
+
return keys.sort();
|
|
9112
|
+
} catch (e) {
|
|
9113
|
+
if (e.code === "ENOENT") return [];
|
|
9114
|
+
throw e;
|
|
9115
|
+
}
|
|
8941
9116
|
}
|
|
8942
9117
|
};
|
|
8943
9118
|
}
|
|
@@ -8960,6 +9135,10 @@ function sqliteStorage(path) {
|
|
|
8960
9135
|
clear(key) {
|
|
8961
9136
|
db.prepare(`DELETE FROM graphrefly_checkpoint WHERE k = ?`).run(key);
|
|
8962
9137
|
},
|
|
9138
|
+
list() {
|
|
9139
|
+
const rows = db.prepare(`SELECT k FROM graphrefly_checkpoint ORDER BY k`).all();
|
|
9140
|
+
return rows.map((r) => r.k);
|
|
9141
|
+
},
|
|
8963
9142
|
close() {
|
|
8964
9143
|
try {
|
|
8965
9144
|
db.close();
|
|
@@ -9687,6 +9866,7 @@ function workerSelf(target, opts) {
|
|
|
9687
9866
|
fromPromise,
|
|
9688
9867
|
fromPulsar,
|
|
9689
9868
|
fromRabbitMQ,
|
|
9869
|
+
fromRaf,
|
|
9690
9870
|
fromRedisStream,
|
|
9691
9871
|
fromSSE,
|
|
9692
9872
|
fromSqlite,
|