@graphrefly/graphrefly 0.25.0 → 0.27.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/ai-CaR_912Q.d.cts +1033 -0
- package/dist/ai-WlRltJV7.d.ts +1033 -0
- package/dist/audit-ClmqGOCx.d.cts +245 -0
- package/dist/audit-DRlSzBu9.d.ts +245 -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-APFNLIRG.js +62 -0
- package/dist/chunk-APFNLIRG.js.map +1 -0
- package/dist/chunk-AT5LKYNL.js +395 -0
- package/dist/chunk-AT5LKYNL.js.map +1 -0
- package/dist/{chunk-IAHGTNOZ.js → chunk-BQ6RQQFF.js} +351 -2095
- package/dist/chunk-BQ6RQQFF.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-EVR6UFUV.js → chunk-DST5DKZS.js} +19 -15
- package/dist/{chunk-EVR6UFUV.js.map → chunk-DST5DKZS.js.map} +1 -1
- package/dist/{chunk-TKE3JGOH.js → chunk-GTE6PWRZ.js} +5 -692
- package/dist/chunk-GTE6PWRZ.js.map +1 -0
- package/dist/chunk-HXZEYDUR.js +94 -0
- package/dist/chunk-HXZEYDUR.js.map +1 -0
- package/dist/chunk-J22W6HV3.js +107 -0
- package/dist/chunk-J22W6HV3.js.map +1 -0
- package/dist/{chunk-PY4XCDLR.js → chunk-J2VBW3DZ.js} +6 -95
- package/dist/chunk-J2VBW3DZ.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-JWBCY4NC.js +330 -0
- package/dist/chunk-JWBCY4NC.js.map +1 -0
- package/dist/chunk-K2AUJHVP.js +2251 -0
- package/dist/chunk-K2AUJHVP.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-NC6S43JJ.js +456 -0
- package/dist/chunk-NC6S43JJ.js.map +1 -0
- package/dist/chunk-OFVJBJXR.js +98 -0
- package/dist/chunk-OFVJBJXR.js.map +1 -0
- package/dist/chunk-OHISZPOJ.js +97 -0
- package/dist/chunk-OHISZPOJ.js.map +1 -0
- package/dist/chunk-OU5CQKNW.js +102 -0
- package/dist/chunk-OU5CQKNW.js.map +1 -0
- package/dist/{chunk-XOFWRC73.js → chunk-PF7GRZMW.js} +316 -21
- package/dist/chunk-PF7GRZMW.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-RNHBMHKA.js +1665 -0
- package/dist/chunk-RNHBMHKA.js.map +1 -0
- package/dist/chunk-SX52TAR4.js +110 -0
- package/dist/chunk-SX52TAR4.js.map +1 -0
- package/dist/{chunk-H4RVA4VE.js → chunk-VYPWMZ6H.js} +2 -2
- package/dist/chunk-WBZOVTYK.js +171 -0
- package/dist/chunk-WBZOVTYK.js.map +1 -0
- package/dist/chunk-WKNUIZOY.js +354 -0
- package/dist/chunk-WKNUIZOY.js.map +1 -0
- package/dist/chunk-X3VMZYBT.js +713 -0
- package/dist/chunk-X3VMZYBT.js.map +1 -0
- package/dist/chunk-X5R3GL6H.js +525 -0
- package/dist/chunk-X5R3GL6H.js.map +1 -0
- package/dist/chunk-XGPU467M.js +136 -0
- package/dist/chunk-XGPU467M.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 +50 -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 +11 -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/composite-C7PcQvcs.d.cts +303 -0
- package/dist/composite-aUCvjZVR.d.ts +303 -0
- package/dist/core/index.cjs +53 -4
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +4 -3
- package/dist/core/index.d.ts +4 -3
- package/dist/core/index.js +26 -24
- package/dist/demo-shell-BDkOptd6.d.ts +102 -0
- package/dist/demo-shell-Crid1WdR.d.cts +102 -0
- package/dist/extra/index.cjs +222 -110
- package/dist/extra/index.cjs.map +1 -1
- package/dist/extra/index.d.cts +6 -4
- package/dist/extra/index.d.ts +6 -4
- package/dist/extra/index.js +72 -65
- 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-CCwGKLCm.d.ts} +195 -4
- package/dist/{graph-B6NFqv3z.d.ts → graph-DNCrvZSn.d.cts} +195 -4
- package/dist/index-3lsddbbS.d.ts +86 -0
- package/dist/index-B1tloyhO.d.cts +34 -0
- package/dist/{index-CYkjxu3s.d.ts → index-B6D3QNSA.d.ts} +33 -4
- package/dist/index-B6EhDnjH.d.cts +37 -0
- package/dist/index-B9B7_HEY.d.ts +37 -0
- package/dist/{index-Ds23Wvou.d.ts → index-BHlKbUwO.d.cts} +131 -883
- package/dist/{index-DiobMNwE.d.ts → index-BPVt8kqc.d.ts} +3 -3
- package/dist/index-BaSM3aYt.d.ts +195 -0
- package/dist/index-BuEoe-Qu.d.ts +121 -0
- package/dist/{index-Ch0IpIO0.d.cts → index-BwfLUNw4.d.ts} +131 -883
- package/dist/index-ByQxazQJ.d.cts +86 -0
- package/dist/index-C0svESO4.d.ts +127 -0
- package/dist/{index-OXImXMq6.d.ts → index-C8oil6M6.d.ts} +18 -196
- package/dist/{index-DKE1EATr.d.cts → index-CI3DprxP.d.cts} +18 -196
- package/dist/{index-AMWewNDe.d.cts → index-CO8uBlUh.d.cts} +33 -4
- package/dist/index-CxFrXH4m.d.ts +45 -0
- package/dist/index-D8wS_PeY.d.cts +121 -0
- package/dist/index-DO_6JN9Z.d.cts +127 -0
- package/dist/index-DVGiGFGT.d.cts +195 -0
- package/dist/index-DYme44FM.d.cts +44 -0
- package/dist/{index-J7Kc0oIQ.d.cts → index-DlLp-2Xn.d.cts} +3 -3
- package/dist/index-Dzk2hrlR.d.ts +44 -0
- package/dist/index-VHqptjhu.d.cts +45 -0
- package/dist/index-VdHQMPy1.d.ts +36 -0
- package/dist/index-Xi3u0HCQ.d.cts +36 -0
- package/dist/index-wEn0eFe8.d.ts +34 -0
- package/dist/index.cjs +1780 -176
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +784 -2082
- package/dist/index.d.ts +784 -2082
- package/dist/index.js +955 -4349
- package/dist/index.js.map +1 -1
- package/dist/memory-C6Z2tGpC.d.cts +139 -0
- package/dist/memory-li6FL5RM.d.ts +139 -0
- package/dist/messaging-Gt4LPbyA.d.cts +269 -0
- package/dist/messaging-XDoYablx.d.ts +269 -0
- package/dist/{meta-DWbkoq1s.d.cts → meta-BxCA7rcr.d.cts} +1 -1
- package/dist/{meta-CnkLA_43.d.ts → meta-CbznRPYJ.d.ts} +1 -1
- package/dist/{node-B-f-Lu-k.d.cts → node-BmerH3kS.d.cts} +26 -1
- package/dist/{node-B-f-Lu-k.d.ts → node-BmerH3kS.d.ts} +26 -1
- package/dist/{observable-uP-wy_uK.d.ts → observable-BgGUwcqp.d.ts} +1 -1
- package/dist/{observable-DBnrwcar.d.cts → observable-DJt_AxzQ.d.cts} +1 -1
- package/dist/patterns/ai.cjs +7930 -0
- package/dist/patterns/ai.cjs.map +1 -0
- package/dist/patterns/ai.d.cts +10 -0
- package/dist/patterns/ai.d.ts +10 -0
- package/dist/patterns/ai.js +71 -0
- package/dist/patterns/ai.js.map +1 -0
- package/dist/patterns/audit.cjs +5805 -0
- package/dist/patterns/audit.cjs.map +1 -0
- package/dist/patterns/audit.d.cts +6 -0
- package/dist/patterns/audit.d.ts +6 -0
- package/dist/patterns/audit.js +29 -0
- package/dist/patterns/audit.js.map +1 -0
- 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/memory.cjs +5283 -0
- package/dist/patterns/memory.cjs.map +1 -0
- package/dist/patterns/memory.d.cts +5 -0
- package/dist/patterns/memory.d.ts +5 -0
- package/dist/patterns/memory.js +20 -0
- package/dist/patterns/memory.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-MQP--J3F.d.cts +183 -0
- package/dist/reactive-layout-u5Ulnqag.d.ts +183 -0
- package/dist/{storage-BuTdpCI1.d.cts → storage-CMjUUuxn.d.ts} +10 -2
- package/dist/{storage-F2X1U1x0.d.ts → storage-DdWlZo6U.d.cts} +10 -2
- package/dist/sugar-CCOxXK1e.d.ts +201 -0
- package/dist/sugar-D02n5JjF.d.cts +201 -0
- package/package.json +63 -3
- 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-PY4XCDLR.js.map +0 -1
- package/dist/chunk-TKE3JGOH.js.map +0 -1
- package/dist/chunk-XOFWRC73.js.map +0 -1
- package/dist/index-BJB7t9gg.d.cts +0 -392
- package/dist/index-C-TXEa7C.d.ts +0 -392
- /package/dist/{chunk-H4RVA4VE.js.map → chunk-VYPWMZ6H.js.map} +0 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/compat/vue/index.ts
|
|
21
|
+
var vue_exports = {};
|
|
22
|
+
__export(vue_exports, {
|
|
23
|
+
useStore: () => useStore,
|
|
24
|
+
useSubscribe: () => useSubscribe,
|
|
25
|
+
useSubscribeRecord: () => useSubscribeRecord
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(vue_exports);
|
|
28
|
+
var import_vue = require("vue");
|
|
29
|
+
|
|
30
|
+
// src/core/messages.ts
|
|
31
|
+
var START = /* @__PURE__ */ Symbol.for("graphrefly/START");
|
|
32
|
+
var DATA = /* @__PURE__ */ Symbol.for("graphrefly/DATA");
|
|
33
|
+
var DIRTY = /* @__PURE__ */ Symbol.for("graphrefly/DIRTY");
|
|
34
|
+
var RESOLVED = /* @__PURE__ */ Symbol.for("graphrefly/RESOLVED");
|
|
35
|
+
var INVALIDATE = /* @__PURE__ */ Symbol.for("graphrefly/INVALIDATE");
|
|
36
|
+
var TEARDOWN = /* @__PURE__ */ Symbol.for("graphrefly/TEARDOWN");
|
|
37
|
+
var COMPLETE = /* @__PURE__ */ Symbol.for("graphrefly/COMPLETE");
|
|
38
|
+
var DIRTY_MSG = Object.freeze([DIRTY]);
|
|
39
|
+
var RESOLVED_MSG = Object.freeze([RESOLVED]);
|
|
40
|
+
var INVALIDATE_MSG = Object.freeze([INVALIDATE]);
|
|
41
|
+
var START_MSG = Object.freeze([START]);
|
|
42
|
+
var COMPLETE_MSG = Object.freeze([COMPLETE]);
|
|
43
|
+
var TEARDOWN_MSG = Object.freeze([TEARDOWN]);
|
|
44
|
+
var DIRTY_ONLY_BATCH = Object.freeze([DIRTY_MSG]);
|
|
45
|
+
var RESOLVED_ONLY_BATCH = Object.freeze([RESOLVED_MSG]);
|
|
46
|
+
var INVALIDATE_ONLY_BATCH = Object.freeze([INVALIDATE_MSG]);
|
|
47
|
+
var COMPLETE_ONLY_BATCH = Object.freeze([COMPLETE_MSG]);
|
|
48
|
+
var TEARDOWN_ONLY_BATCH = Object.freeze([TEARDOWN_MSG]);
|
|
49
|
+
|
|
50
|
+
// src/compat/vue/index.ts
|
|
51
|
+
function useSubscribe(node) {
|
|
52
|
+
const ref = (0, import_vue.shallowRef)(node.cache);
|
|
53
|
+
const unsub = node.subscribe(() => {
|
|
54
|
+
ref.value = node.cache;
|
|
55
|
+
});
|
|
56
|
+
if ((0, import_vue.getCurrentScope)()) {
|
|
57
|
+
(0, import_vue.onScopeDispose)(() => unsub());
|
|
58
|
+
} else if (typeof console !== "undefined") {
|
|
59
|
+
console.warn(
|
|
60
|
+
"[graphrefly-ts] useSubscribe called outside a Vue scope \u2014 subscription will not be auto-disposed."
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
return (0, import_vue.readonly)(ref);
|
|
64
|
+
}
|
|
65
|
+
function useStore(node) {
|
|
66
|
+
const inner = (0, import_vue.shallowRef)(node.cache);
|
|
67
|
+
const unsub = node.subscribe(() => {
|
|
68
|
+
inner.value = node.cache;
|
|
69
|
+
});
|
|
70
|
+
if ((0, import_vue.getCurrentScope)()) {
|
|
71
|
+
(0, import_vue.onScopeDispose)(() => unsub());
|
|
72
|
+
} else if (typeof console !== "undefined") {
|
|
73
|
+
console.warn(
|
|
74
|
+
"[graphrefly-ts] useStore called outside a Vue scope \u2014 subscription will not be auto-disposed."
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
return (0, import_vue.computed)({
|
|
78
|
+
get: () => inner.value,
|
|
79
|
+
set: (v) => {
|
|
80
|
+
node.down([[DIRTY], [DATA, v]]);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function useSubscribeRecord(keys, factory) {
|
|
85
|
+
const result = (0, import_vue.shallowRef)({});
|
|
86
|
+
const activeSubs = /* @__PURE__ */ new Map();
|
|
87
|
+
function flushResult() {
|
|
88
|
+
const snap = {};
|
|
89
|
+
for (const [key, entry] of activeSubs) {
|
|
90
|
+
snap[key] = { ...entry.values };
|
|
91
|
+
}
|
|
92
|
+
result.value = snap;
|
|
93
|
+
}
|
|
94
|
+
function sync(newKeys) {
|
|
95
|
+
for (const entry of activeSubs.values()) {
|
|
96
|
+
for (const unsub of entry.subs) unsub();
|
|
97
|
+
}
|
|
98
|
+
activeSubs.clear();
|
|
99
|
+
for (const key of newKeys) {
|
|
100
|
+
const nodes = factory(key);
|
|
101
|
+
const fields = Object.keys(nodes);
|
|
102
|
+
const values = {};
|
|
103
|
+
const subs = [];
|
|
104
|
+
for (const field of fields) {
|
|
105
|
+
const node = nodes[field];
|
|
106
|
+
values[field] = node.cache;
|
|
107
|
+
const unsub = node.subscribe(() => {
|
|
108
|
+
values[field] = node.cache;
|
|
109
|
+
flushResult();
|
|
110
|
+
});
|
|
111
|
+
subs.push(unsub);
|
|
112
|
+
}
|
|
113
|
+
activeSubs.set(key, { subs, values });
|
|
114
|
+
}
|
|
115
|
+
const snap = {};
|
|
116
|
+
for (const [key, entry] of activeSubs) {
|
|
117
|
+
snap[key] = { ...entry.values };
|
|
118
|
+
}
|
|
119
|
+
result.value = snap;
|
|
120
|
+
}
|
|
121
|
+
const readKeys = () => {
|
|
122
|
+
const current = typeof keys === "function" ? keys() : (0, import_vue.isRef)(keys) ? keys.value : keys;
|
|
123
|
+
return [...current ?? []];
|
|
124
|
+
};
|
|
125
|
+
(0, import_vue.watch)(readKeys, (newKeys) => sync(newKeys ?? []), { immediate: true });
|
|
126
|
+
if ((0, import_vue.getCurrentScope)()) {
|
|
127
|
+
(0, import_vue.onScopeDispose)(() => {
|
|
128
|
+
for (const entry of activeSubs.values()) {
|
|
129
|
+
for (const unsub of entry.subs) unsub();
|
|
130
|
+
}
|
|
131
|
+
activeSubs.clear();
|
|
132
|
+
});
|
|
133
|
+
} else if (typeof console !== "undefined") {
|
|
134
|
+
console.warn(
|
|
135
|
+
"[graphrefly-ts] useSubscribeRecord called outside a Vue scope \u2014 subscription will not be auto-disposed."
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
return (0, import_vue.readonly)(result);
|
|
139
|
+
}
|
|
140
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
141
|
+
0 && (module.exports = {
|
|
142
|
+
useStore,
|
|
143
|
+
useSubscribe,
|
|
144
|
+
useSubscribeRecord
|
|
145
|
+
});
|
|
146
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/compat/vue/index.ts","../../../src/core/messages.ts"],"sourcesContent":["// ---------------------------------------------------------------------------\n// Vue bindings — useStore / useSubscribe\n// ---------------------------------------------------------------------------\n// Bridges GraphReFly nodes into Vue reactivity. Works with any\n// Node<T>, including companion nodes (node.meta.status).\n//\n// Usage:\n// import { useStore, useSubscribe } from '@graphrefly/graphrefly-ts/compat/vue';\n// // Optional peer install (only for this adapter): pnpm add vue\n// const count = useStore(counterNode); // Ref<number | undefined> (read + write)\n// const status = useSubscribe(wsStatusNode); // Readonly<Ref<string | undefined>>\n// ---------------------------------------------------------------------------\n\nimport {\n\tcomputed,\n\tgetCurrentScope,\n\tisRef,\n\tonScopeDispose,\n\ttype Ref,\n\treadonly,\n\tshallowRef,\n\ttype WatchSource,\n\twatch,\n} from \"vue\";\nimport { DATA, DIRTY } from \"../../core/messages.js\";\nimport type { Node } from \"../../core/node.js\";\n\n/**\n * Subscribe to a read-only `Node<T>` as a Vue `Ref<T>`. Auto-unsubscribes on scope disposal.\n * Subscription lifecycle is tied to Vue scope disposal (not node terminal messages).\n */\nexport function useSubscribe<T>(node: Node<T>): Readonly<Ref<T | undefined | null>> {\n\tconst ref = shallowRef(node.cache) as Ref<T | undefined | null>;\n\n\tconst unsub = node.subscribe(() => {\n\t\tref.value = node.cache;\n\t});\n\n\tif (getCurrentScope()) {\n\t\tonScopeDispose(() => unsub());\n\t} else if (typeof console !== \"undefined\") {\n\t\tconsole.warn(\n\t\t\t\"[graphrefly-ts] useSubscribe called outside a Vue scope — subscription will not be auto-disposed.\",\n\t\t);\n\t}\n\n\treturn readonly(ref) as Readonly<Ref<T | undefined | null>>;\n}\n\n/**\n * Bind a writable `Node<T>` as a Vue `Ref<T>`. Reads and writes are bidirectional.\n * Value sets always dispatch `[[DIRTY], [DATA, value]]`, including `value === undefined`.\n * Subscription lifecycle is tied to Vue scope disposal (not node terminal messages).\n */\nexport function useStore<T>(node: Node<T>): Ref<T | undefined | null> {\n\tconst inner = shallowRef(node.cache) as Ref<T | undefined | null>;\n\n\tconst unsub = node.subscribe(() => {\n\t\tinner.value = node.cache;\n\t});\n\n\tif (getCurrentScope()) {\n\t\tonScopeDispose(() => unsub());\n\t} else if (typeof console !== \"undefined\") {\n\t\tconsole.warn(\n\t\t\t\"[graphrefly-ts] useStore called outside a Vue scope — subscription will not be auto-disposed.\",\n\t\t);\n\t}\n\n\treturn computed({\n\t\tget: () => inner.value,\n\t\tset: (v: T | undefined | null) => {\n\t\t\tnode.down([[DIRTY], [DATA, v]]);\n\t\t},\n\t});\n}\n\n/** Maps a key to an object of nodes. Used by `useSubscribeRecord` factory. */\nexport type NodeFactory<K, R extends Record<string, any>> = (key: K) => {\n\t[P in keyof R]: Node<R[P]>;\n};\n\n/**\n * Subscribe to a dynamic set of keyed node records. When keys change,\n * old subscriptions are torn down and new ones created automatically.\n * Must be called during Vue `setup()`.\n */\nexport function useSubscribeRecord<K extends string, R extends Record<string, any>>(\n\tkeys: WatchSource<K[] | undefined>,\n\tfactory: NodeFactory<K, R>,\n): Readonly<Ref<Record<K, R>>> {\n\tconst result = shallowRef<Record<K, R>>({} as Record<K, R>);\n\n\t// Track active subscriptions per key (strictly enclosed memory mapping)\n\tconst activeSubs = new Map<K, { subs: Array<() => void>; values: R }>();\n\tfunction flushResult() {\n\t\tconst snap = {} as Record<K, R>;\n\t\tfor (const [key, entry] of activeSubs) {\n\t\t\tsnap[key] = { ...entry.values };\n\t\t}\n\t\tresult.value = snap;\n\t}\n\n\tfunction sync(newKeys: K[]) {\n\t\tfor (const entry of activeSubs.values()) {\n\t\t\tfor (const unsub of entry.subs) unsub();\n\t\t}\n\t\tactiveSubs.clear();\n\n\t\tfor (const key of newKeys) {\n\t\t\tconst nodes = factory(key);\n\t\t\tconst fields = Object.keys(nodes) as (keyof R)[];\n\t\t\tconst values = {} as R;\n\t\t\tconst subs: Array<() => void> = [];\n\n\t\t\tfor (const field of fields) {\n\t\t\t\tconst node = nodes[field];\n\t\t\t\tvalues[field] = node.cache as R[keyof R];\n\t\t\t\tconst unsub = node.subscribe(() => {\n\t\t\t\t\tvalues[field] = node.cache as R[keyof R];\n\t\t\t\t\tflushResult();\n\t\t\t\t});\n\t\t\t\tsubs.push(unsub);\n\t\t\t}\n\n\t\t\tactiveSubs.set(key, { subs, values });\n\t\t}\n\n\t\tconst snap = {} as Record<K, R>;\n\t\tfor (const [key, entry] of activeSubs) {\n\t\t\tsnap[key] = { ...entry.values };\n\t\t}\n\t\tresult.value = snap;\n\t}\n\n\tconst readKeys = (): K[] => {\n\t\tconst current = typeof keys === \"function\" ? keys() : isRef(keys) ? keys.value : keys;\n\t\treturn [...(current ?? [])];\n\t};\n\n\twatch(readKeys, (newKeys) => sync(newKeys ?? []), { immediate: true });\n\n\tif (getCurrentScope()) {\n\t\tonScopeDispose(() => {\n\t\t\tfor (const entry of activeSubs.values()) {\n\t\t\t\tfor (const unsub of entry.subs) unsub();\n\t\t\t}\n\t\t\tactiveSubs.clear();\n\t\t});\n\t} else if (typeof console !== \"undefined\") {\n\t\tconsole.warn(\n\t\t\t\"[graphrefly-ts] useSubscribeRecord called outside a Vue scope — subscription will not be auto-disposed.\",\n\t\t);\n\t}\n\n\treturn readonly(result) as Readonly<Ref<Record<K, R>>>;\n}\n","/**\n * GraphReFly message protocol — §1 `~/src/graphrefly/GRAPHREFLY-SPEC.md`.\n * Emissions are always `[[Type, Data?], ...]` (no single-tuple shorthand).\n *\n * This file is protocol-pure:\n * - Message type symbols (10 built-ins).\n * - `Message` / `Messages` tuple types.\n * - `MessageTypeRegistration` interface (shape of a registry entry).\n *\n * It does NOT own the registry, tier lookups, or any cross-cutting singleton\n * state — that lives in `GraphReFlyConfig` (see `config.ts`) so custom\n * protocols can build isolated instances. Import this module when you need\n * the symbol constants or the tuple types; import `config.ts` when you need\n * tier / wire-crossing / registry lookups.\n */\n\n/** Subscribe-time handshake. Delivered to each new sink at the top of `subscribe()`. Tier 0. */\nexport const START = Symbol.for(\"graphrefly/START\");\n/** Value delivery (`DATA`, value). Tier 3 — deferred inside `batch()`. */\nexport const DATA = Symbol.for(\"graphrefly/DATA\");\n/** Phase 1: value about to change. Tier 1 — immediate. */\nexport const DIRTY = Symbol.for(\"graphrefly/DIRTY\");\n/** Phase 2: dirty pass completed, value unchanged. Tier 3 — deferred inside `batch()`. */\nexport const RESOLVED = Symbol.for(\"graphrefly/RESOLVED\");\n/** Clear cached state; do not auto-emit. Tier 1 — immediate. */\nexport const INVALIDATE = Symbol.for(\"graphrefly/INVALIDATE\");\n/** Suspend activity. Tier 2 — immediate. */\nexport const PAUSE = Symbol.for(\"graphrefly/PAUSE\");\n/** Resume after pause. Tier 2 — immediate. */\nexport const RESUME = Symbol.for(\"graphrefly/RESUME\");\n/** Permanent cleanup. Tier 5 — deferred to batch phase 4. */\nexport const TEARDOWN = Symbol.for(\"graphrefly/TEARDOWN\");\n/** Clean termination. Tier 4 — deferred to batch phase 3. */\nexport const COMPLETE = Symbol.for(\"graphrefly/COMPLETE\");\n/** Error termination. Tier 4 — deferred to batch phase 3. */\nexport const ERROR = Symbol.for(\"graphrefly/ERROR\");\n\n/** One protocol tuple: `[Type, optional payload]`. */\nexport type Message = readonly [symbol, unknown?];\n\n/** A batch of tuples — the wire shape for `node.down()` / `node.up()`. */\nexport type Messages = readonly Message[];\n\n// ---------------------------------------------------------------------------\n// Interned singletons for payload-free tuples\n// ---------------------------------------------------------------------------\n//\n// Every emission path used to allocate fresh `[[DIRTY]]`, `[[RESOLVED]]`,\n// etc. — two arrays per emit in the hot path. Since none of these tuples\n// carry a payload, one frozen instance is indistinguishable from a\n// fresh one. We intern them at module load and reuse forever. Only\n// `[DATA, v]`, `[ERROR, e]`, `[PAUSE, lockId]`, `[RESUME, lockId]` still\n// allocate per-call because they carry payloads.\n//\n// Downstream code MUST treat these as immutable. `Object.freeze` makes\n// accidental mutation throw in strict mode. Do not `push`, splice, or\n// otherwise mutate a Messages array that came from one of these.\n\n/** Singleton `[DIRTY]` tuple — payload-free, interned. */\nexport const DIRTY_MSG: Message = Object.freeze([DIRTY]) as Message;\n/** Singleton `[RESOLVED]` tuple — payload-free, interned. */\nexport const RESOLVED_MSG: Message = Object.freeze([RESOLVED]) as Message;\n/** Singleton `[INVALIDATE]` tuple — payload-free, interned. */\nexport const INVALIDATE_MSG: Message = Object.freeze([INVALIDATE]) as Message;\n/** Singleton `[START]` tuple — payload-free, interned. */\nexport const START_MSG: Message = Object.freeze([START]) as Message;\n/** Singleton `[COMPLETE]` tuple — payload-free, interned. */\nexport const COMPLETE_MSG: Message = Object.freeze([COMPLETE]) as Message;\n/** Singleton `[TEARDOWN]` tuple — payload-free, interned. */\nexport const TEARDOWN_MSG: Message = Object.freeze([TEARDOWN]) as Message;\n\n/** Pre-wrapped `[[DIRTY]]` for `_emit([DIRTY_ONLY_BATCH])`-style callers. */\nexport const DIRTY_ONLY_BATCH: Messages = Object.freeze([DIRTY_MSG]) as Messages;\n/** Pre-wrapped `[[RESOLVED]]`. */\nexport const RESOLVED_ONLY_BATCH: Messages = Object.freeze([RESOLVED_MSG]) as Messages;\n/** Pre-wrapped `[[INVALIDATE]]`. */\nexport const INVALIDATE_ONLY_BATCH: Messages = Object.freeze([INVALIDATE_MSG]) as Messages;\n/** Pre-wrapped `[[COMPLETE]]`. */\nexport const COMPLETE_ONLY_BATCH: Messages = Object.freeze([COMPLETE_MSG]) as Messages;\n/** Pre-wrapped `[[TEARDOWN]]`. */\nexport const TEARDOWN_ONLY_BATCH: Messages = Object.freeze([TEARDOWN_MSG]) as Messages;\n\n// ---------------------------------------------------------------------------\n// Registry entry shape\n// ---------------------------------------------------------------------------\n\n/**\n * Per-type record stored in a {@link GraphReFlyConfig}'s registry.\n *\n * - `tier` — signal tier (0–5 built-in; custom tiers allowed but should fit\n * the phase model used by `batch.ts`).\n * - `wireCrossing` — when `true`, forwarded across SSE/WebSocket/worker\n * adapters. Defaults to `tier >= 3` if omitted in registration input.\n * - `metaPassthrough` — when `false`, this message type is filtered out of\n * `Graph.signal` deliveries to meta companion nodes (spec §2.3). Meta\n * companions still receive everything via their primary's own cascade.\n * Defaults to `true` (meta receives the message).\n */\nexport interface MessageTypeRegistration {\n\ttier: number;\n\twireCrossing: boolean;\n\tmetaPassthrough: boolean;\n}\n\n/**\n * Input accepted by {@link GraphReFlyConfig.registerMessageType}. Only `tier`\n * is required; `wireCrossing` defaults to `tier >= 3`; `metaPassthrough`\n * defaults to `true`.\n */\nexport interface MessageTypeRegistrationInput {\n\ttier: number;\n\twireCrossing?: boolean;\n\tmetaPassthrough?: boolean;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,iBAUO;;;ACNA,IAAM,QAAQ,uBAAO,IAAI,kBAAkB;AAE3C,IAAM,OAAO,uBAAO,IAAI,iBAAiB;AAEzC,IAAM,QAAQ,uBAAO,IAAI,kBAAkB;AAE3C,IAAM,WAAW,uBAAO,IAAI,qBAAqB;AAEjD,IAAM,aAAa,uBAAO,IAAI,uBAAuB;AAMrD,IAAM,WAAW,uBAAO,IAAI,qBAAqB;AAEjD,IAAM,WAAW,uBAAO,IAAI,qBAAqB;AA0BjD,IAAM,YAAqB,OAAO,OAAO,CAAC,KAAK,CAAC;AAEhD,IAAM,eAAwB,OAAO,OAAO,CAAC,QAAQ,CAAC;AAEtD,IAAM,iBAA0B,OAAO,OAAO,CAAC,UAAU,CAAC;AAE1D,IAAM,YAAqB,OAAO,OAAO,CAAC,KAAK,CAAC;AAEhD,IAAM,eAAwB,OAAO,OAAO,CAAC,QAAQ,CAAC;AAEtD,IAAM,eAAwB,OAAO,OAAO,CAAC,QAAQ,CAAC;AAGtD,IAAM,mBAA6B,OAAO,OAAO,CAAC,SAAS,CAAC;AAE5D,IAAM,sBAAgC,OAAO,OAAO,CAAC,YAAY,CAAC;AAElE,IAAM,wBAAkC,OAAO,OAAO,CAAC,cAAc,C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