@graphrefly/graphrefly 0.25.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-IAHGTNOZ.js → chunk-AMCG74RZ.js} +193 -24
- package/dist/chunk-AMCG74RZ.js.map +1 -0
- package/dist/{chunk-L2GLW2U7.js → chunk-BVZYTZ5H.js} +9 -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-EVR6UFUV.js → chunk-IZYUSJC7.js} +16 -14
- package/dist/{chunk-EVR6UFUV.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-TKE3JGOH.js → chunk-LCE3GF5P.js} +5 -692
- 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-ZQMEI34O.js +713 -0
- 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 +222 -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 +6 -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-B6NFqv3z.d.ts → graph-6tZ5jEzr.d.cts} +195 -4
- package/dist/{graph-D-3JIQme.d.cts → 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-OXImXMq6.d.ts → index-BW1z3BN9.d.ts} +18 -196
- 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-Ds23Wvou.d.ts → index-BeIdBfcb.d.cts} +120 -573
- 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-DKE1EATr.d.cts → index-C8mdwMXc.d.cts} +18 -196
- 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-Ch0IpIO0.d.cts → index-DdD5MVDL.d.ts} +120 -573
- 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 +1780 -176
- 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 +1202 -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 +355 -13
- 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 +15 -12
- 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-IAHGTNOZ.js.map +0 -1
- package/dist/chunk-L2GLW2U7.js.map +0 -1
- package/dist/chunk-MW4VAKAO.js +0 -47
- package/dist/chunk-MW4VAKAO.js.map +0 -1
- package/dist/chunk-TKE3JGOH.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
|
@@ -972,6 +972,12 @@ var NodeImpl = class _NodeImpl {
|
|
|
972
972
|
_autoError;
|
|
973
973
|
_pausable;
|
|
974
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;
|
|
975
981
|
_hashFn;
|
|
976
982
|
_versioning;
|
|
977
983
|
/**
|
|
@@ -1145,18 +1151,61 @@ var NodeImpl = class _NodeImpl {
|
|
|
1145
1151
|
if (this._inspectorHooks?.size === 0) this._inspectorHooks = void 0;
|
|
1146
1152
|
};
|
|
1147
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
|
+
}
|
|
1148
1180
|
allowsObserve(actor) {
|
|
1149
|
-
if (this._guard == null) return true;
|
|
1150
|
-
|
|
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;
|
|
1151
1190
|
}
|
|
1152
1191
|
// --- Guard helper ---
|
|
1153
1192
|
_checkGuard(options) {
|
|
1154
|
-
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;
|
|
1155
1197
|
const actor = normalizeActor(options?.actor);
|
|
1156
1198
|
const action = options?.delivery === "signal" ? "signal" : "write";
|
|
1157
|
-
if (!this._guard(actor, action)) {
|
|
1199
|
+
if (this._guard != null && !this._guard(actor, action)) {
|
|
1158
1200
|
throw new GuardDenied({ actor, action, nodeName: this.name });
|
|
1159
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
|
+
}
|
|
1160
1209
|
this._lastMutation = { actor, timestamp_ns: wallClockNs() };
|
|
1161
1210
|
}
|
|
1162
1211
|
// --- Public transport ---
|
|
@@ -2331,10 +2380,6 @@ function externalBundle(register, channels, opts) {
|
|
|
2331
2380
|
return Object.assign(nodes, { dispose });
|
|
2332
2381
|
}
|
|
2333
2382
|
|
|
2334
|
-
// src/extra/sources.ts
|
|
2335
|
-
var import_node_fs = require("fs");
|
|
2336
|
-
var import_node_path = require("path");
|
|
2337
|
-
|
|
2338
2383
|
// src/extra/cron.ts
|
|
2339
2384
|
function parseField(field, min, max) {
|
|
2340
2385
|
const result = /* @__PURE__ */ new Set();
|
|
@@ -2572,99 +2617,6 @@ function fromEvent(target, type, opts) {
|
|
|
2572
2617
|
return () => target.removeEventListener(type, handler, options);
|
|
2573
2618
|
}, sourceOpts2(rest));
|
|
2574
2619
|
}
|
|
2575
|
-
function fromFSWatch(paths, opts) {
|
|
2576
|
-
const list = Array.isArray(paths) ? paths : [paths];
|
|
2577
|
-
if (list.length === 0) {
|
|
2578
|
-
throw new RangeError("fromFSWatch expects at least one path");
|
|
2579
|
-
}
|
|
2580
|
-
const { recursive = true, debounce: debounce2 = 100, include, exclude, ...rest } = opts ?? {};
|
|
2581
|
-
const includePatterns = include?.map(globToRegExp) ?? [];
|
|
2582
|
-
const excludePatterns = (exclude ?? ["**/node_modules/**", "**/.git/**", "**/dist/**"]).map(
|
|
2583
|
-
globToRegExp
|
|
2584
|
-
);
|
|
2585
|
-
return producer((a) => {
|
|
2586
|
-
const pending = /* @__PURE__ */ new Map();
|
|
2587
|
-
const watchers = [];
|
|
2588
|
-
let stopped = false;
|
|
2589
|
-
let terminalEmitted = false;
|
|
2590
|
-
let generation = 0;
|
|
2591
|
-
const closeWatchers = () => {
|
|
2592
|
-
for (const watcher of watchers.splice(0)) watcher.close();
|
|
2593
|
-
};
|
|
2594
|
-
const emitError = (err) => {
|
|
2595
|
-
if (terminalEmitted) return;
|
|
2596
|
-
terminalEmitted = true;
|
|
2597
|
-
stopped = true;
|
|
2598
|
-
if (timer !== void 0) clearTimeout(timer);
|
|
2599
|
-
timer = void 0;
|
|
2600
|
-
pending.clear();
|
|
2601
|
-
closeWatchers();
|
|
2602
|
-
a.down([[ERROR, err]]);
|
|
2603
|
-
};
|
|
2604
|
-
let timer;
|
|
2605
|
-
const flush = (token) => {
|
|
2606
|
-
timer = void 0;
|
|
2607
|
-
if (stopped || terminalEmitted) return;
|
|
2608
|
-
if (pending.size === 0) return;
|
|
2609
|
-
const batchMessages = [];
|
|
2610
|
-
for (const evt of pending.values()) batchMessages.push([DATA, evt]);
|
|
2611
|
-
pending.clear();
|
|
2612
|
-
if (stopped || terminalEmitted || token !== generation) return;
|
|
2613
|
-
a.down(batchMessages);
|
|
2614
|
-
};
|
|
2615
|
-
try {
|
|
2616
|
-
for (const basePath of list) {
|
|
2617
|
-
const watcher = (0, import_node_fs.watch)(
|
|
2618
|
-
basePath,
|
|
2619
|
-
{ recursive },
|
|
2620
|
-
(eventType, fileName) => {
|
|
2621
|
-
if (stopped || terminalEmitted) return;
|
|
2622
|
-
if (fileName == null) return;
|
|
2623
|
-
const rel = String(fileName).replaceAll("\\", "/");
|
|
2624
|
-
const abs = (0, import_node_path.resolve)(basePath, String(fileName));
|
|
2625
|
-
const normalized = abs.replaceAll("\\", "/");
|
|
2626
|
-
const root = (0, import_node_path.resolve)(basePath).replaceAll("\\", "/");
|
|
2627
|
-
const relForMatch = rel.startsWith("./") ? rel.slice(2) : rel;
|
|
2628
|
-
const included = includePatterns.length === 0 || matchesAnyPattern(normalized, includePatterns) || matchesAnyPattern(relForMatch, includePatterns);
|
|
2629
|
-
if (!included) return;
|
|
2630
|
-
const excluded = matchesAnyPattern(normalized, excludePatterns) || matchesAnyPattern(relForMatch, excludePatterns);
|
|
2631
|
-
if (excluded) return;
|
|
2632
|
-
let kind = "change";
|
|
2633
|
-
if (eventType === "rename") {
|
|
2634
|
-
try {
|
|
2635
|
-
kind = (0, import_node_fs.existsSync)(normalized) ? "create" : "delete";
|
|
2636
|
-
} catch {
|
|
2637
|
-
kind = "rename";
|
|
2638
|
-
}
|
|
2639
|
-
}
|
|
2640
|
-
pending.set(normalized, {
|
|
2641
|
-
type: kind,
|
|
2642
|
-
path: normalized,
|
|
2643
|
-
root,
|
|
2644
|
-
relative_path: relForMatch,
|
|
2645
|
-
timestamp_ns: wallClockNs()
|
|
2646
|
-
});
|
|
2647
|
-
if (timer !== void 0) clearTimeout(timer);
|
|
2648
|
-
const token = generation;
|
|
2649
|
-
timer = setTimeout(() => flush(token), debounce2);
|
|
2650
|
-
}
|
|
2651
|
-
);
|
|
2652
|
-
watcher.on("error", (err) => emitError(err));
|
|
2653
|
-
watchers.push(watcher);
|
|
2654
|
-
}
|
|
2655
|
-
} catch (err) {
|
|
2656
|
-
emitError(err);
|
|
2657
|
-
}
|
|
2658
|
-
return () => {
|
|
2659
|
-
stopped = true;
|
|
2660
|
-
generation += 1;
|
|
2661
|
-
if (timer !== void 0) clearTimeout(timer);
|
|
2662
|
-
timer = void 0;
|
|
2663
|
-
closeWatchers();
|
|
2664
|
-
pending.clear();
|
|
2665
|
-
};
|
|
2666
|
-
}, sourceOpts2(rest));
|
|
2667
|
-
}
|
|
2668
2620
|
function fromIter(iterable, opts) {
|
|
2669
2621
|
return producer((a) => {
|
|
2670
2622
|
let cancelled = false;
|
|
@@ -8916,11 +8868,111 @@ function reactiveLog(initial, options = {}) {
|
|
|
8916
8868
|
};
|
|
8917
8869
|
}
|
|
8918
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
|
+
|
|
8919
8971
|
// src/extra/storage.ts
|
|
8920
|
-
var import_node_crypto = require("crypto");
|
|
8921
|
-
var import_node_fs2 = require("fs");
|
|
8922
|
-
var import_node_path2 = require("path");
|
|
8923
|
-
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");
|
|
8924
8976
|
function sortJsonValue(value) {
|
|
8925
8977
|
if (value === null || typeof value !== "object") return value;
|
|
8926
8978
|
if (Array.isArray(value)) return value.map(sortJsonValue);
|
|
@@ -8945,6 +8997,9 @@ function memoryStorage() {
|
|
|
8945
8997
|
},
|
|
8946
8998
|
clear(key) {
|
|
8947
8999
|
data.delete(key);
|
|
9000
|
+
},
|
|
9001
|
+
list() {
|
|
9002
|
+
return [...data.keys()].sort();
|
|
8948
9003
|
}
|
|
8949
9004
|
};
|
|
8950
9005
|
}
|
|
@@ -8959,16 +9014,54 @@ function dictStorage(storage) {
|
|
|
8959
9014
|
},
|
|
8960
9015
|
clear(key) {
|
|
8961
9016
|
delete storage[key];
|
|
9017
|
+
},
|
|
9018
|
+
list() {
|
|
9019
|
+
return Object.keys(storage).sort();
|
|
8962
9020
|
}
|
|
8963
9021
|
};
|
|
8964
9022
|
}
|
|
8965
9023
|
function fileStorage(dir) {
|
|
9024
|
+
const encoder = new TextEncoder();
|
|
9025
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
8966
9026
|
const pathFor = (key) => {
|
|
8967
|
-
|
|
8968
|
-
|
|
8969
|
-
(
|
|
8970
|
-
|
|
8971
|
-
|
|
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
|
+
}
|
|
8972
9065
|
};
|
|
8973
9066
|
return {
|
|
8974
9067
|
save(key, record) {
|
|
@@ -9005,6 +9098,21 @@ function fileStorage(dir) {
|
|
|
9005
9098
|
} catch (e) {
|
|
9006
9099
|
if (e.code !== "ENOENT") throw e;
|
|
9007
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
|
+
}
|
|
9008
9116
|
}
|
|
9009
9117
|
};
|
|
9010
9118
|
}
|
|
@@ -9027,6 +9135,10 @@ function sqliteStorage(path) {
|
|
|
9027
9135
|
clear(key) {
|
|
9028
9136
|
db.prepare(`DELETE FROM graphrefly_checkpoint WHERE k = ?`).run(key);
|
|
9029
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
|
+
},
|
|
9030
9142
|
close() {
|
|
9031
9143
|
try {
|
|
9032
9144
|
db.close();
|