@fluixi/devtools 1.0.0-alpha.107 → 1.0.0-alpha.109

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.
Files changed (65) hide show
  1. package/dist/callsite.mjs +4 -63
  2. package/dist/change-view.mjs +6 -106
  3. package/dist/chunk-2VDMQ3VF.mjs +520 -0
  4. package/dist/chunk-33U2S43X.mjs +121 -0
  5. package/dist/chunk-4P45Y5EB.mjs +214 -0
  6. package/dist/chunk-B3SAJ7QG.mjs +72 -0
  7. package/dist/chunk-CPZWLBCQ.mjs +35 -0
  8. package/dist/chunk-D25KZZBZ.mjs +212 -0
  9. package/dist/chunk-EBSROPWJ.mjs +314 -0
  10. package/dist/chunk-F664XLZL.mjs +743 -0
  11. package/dist/chunk-FY5K3QVT.mjs +35 -0
  12. package/dist/chunk-G7Z7CVP5.mjs +184 -0
  13. package/dist/chunk-GDQXCOQB.mjs +43 -0
  14. package/dist/chunk-L6XQGNMW.mjs +106 -0
  15. package/dist/chunk-MN6O673L.mjs +90 -0
  16. package/dist/chunk-NDUBBBNL.mjs +70 -0
  17. package/dist/chunk-NT7YMK77.mjs +157 -0
  18. package/dist/chunk-NVULLJDH.mjs +120 -0
  19. package/dist/chunk-NWLSDERQ.mjs +68 -0
  20. package/dist/chunk-OPIGF5XB.mjs +184 -0
  21. package/dist/chunk-P5I7DWFX.mjs +292 -0
  22. package/dist/chunk-PKARAAIS.mjs +75 -0
  23. package/dist/chunk-PSSBFXBD.mjs +155 -0
  24. package/dist/chunk-PTQ5VCYE.mjs +103 -0
  25. package/dist/chunk-PU4MJ5RU.mjs +107 -0
  26. package/dist/chunk-UAEJ3N7F.mjs +76 -0
  27. package/dist/chunk-V6DKWEYD.mjs +67 -0
  28. package/dist/chunk-VO2V7AC5.mjs +80 -0
  29. package/dist/chunk-WGQH7RUW.mjs +25 -0
  30. package/dist/chunk-Y5OQWBAM.mjs +777 -0
  31. package/dist/chunk-Z6KYHEKY.mjs +64 -0
  32. package/dist/copy.mjs +3 -39
  33. package/dist/describe.mjs +3 -31
  34. package/dist/detail-panel.mjs +6 -280
  35. package/dist/diff.mjs +4 -201
  36. package/dist/dom.mjs +7 -176
  37. package/dist/export.mjs +6 -207
  38. package/dist/float.mjs +5 -206
  39. package/dist/format.mjs +5 -151
  40. package/dist/graph-view.mjs +9 -875
  41. package/dist/highlight.mjs +6 -113
  42. package/dist/history.mjs +4 -70
  43. package/dist/hook.mjs +16 -1719
  44. package/dist/index.cjs +1 -1
  45. package/dist/index.mjs +106 -4673
  46. package/dist/inspector.mjs +11 -677
  47. package/dist/instrument.mjs +9 -486
  48. package/dist/kind-filter.mjs +6 -148
  49. package/dist/menu.mjs +4 -116
  50. package/dist/observe.mjs +14 -1510
  51. package/dist/palette.mjs +6 -28
  52. package/dist/path.mjs +3 -21
  53. package/dist/plugin.mjs +9 -57
  54. package/dist/plugins/context.mjs +6 -71
  55. package/dist/plugins/directives.mjs +8 -68
  56. package/dist/plugins/index.cjs +1 -1
  57. package/dist/plugins/index.mjs +13 -136
  58. package/dist/source.mjs +12 -93
  59. package/dist/timeline.mjs +7 -323
  60. package/dist/tree.mjs +11 -558
  61. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  62. package/dist/value-pane.mjs +6 -196
  63. package/dist/wire.cjs +1 -1
  64. package/dist/wire.mjs +6 -86
  65. package/package.json +3 -3
@@ -0,0 +1,75 @@
1
+ // src/history.ts
2
+ var OFF = {
3
+ wrote() {
4
+ },
5
+ ran() {
6
+ },
7
+ created() {
8
+ },
9
+ disposed() {
10
+ },
11
+ take: () => [],
12
+ dropped: 0,
13
+ clear() {
14
+ }
15
+ };
16
+ function createHistory(limit) {
17
+ if (limit <= 0) return OFF;
18
+ let events = [];
19
+ let seq = 0;
20
+ let commit = 0;
21
+ let dropped = 0;
22
+ const push = (event) => {
23
+ events.push({ ...event, seq: seq++, t: Date.now(), commit });
24
+ if (events.length > limit) {
25
+ dropped += events.length - limit;
26
+ events = events.slice(-limit);
27
+ }
28
+ };
29
+ return {
30
+ wrote(id, by, detail) {
31
+ if (by === void 0) commit++;
32
+ push({ kind: "write", id, by, ...detail });
33
+ },
34
+ ran(id, by) {
35
+ push({ kind: "ran", id, by });
36
+ },
37
+ created(id, by, label) {
38
+ push({ kind: "created", id, by, label });
39
+ },
40
+ disposed(id, label) {
41
+ push({ kind: "disposed", id, label });
42
+ },
43
+ take() {
44
+ const taken = events;
45
+ events = [];
46
+ return taken;
47
+ },
48
+ get dropped() {
49
+ return dropped;
50
+ },
51
+ clear() {
52
+ events = [];
53
+ dropped = 0;
54
+ }
55
+ };
56
+ }
57
+ function toCommits(events) {
58
+ const byNumber = /* @__PURE__ */ new Map();
59
+ for (const event of events) {
60
+ const bucket = byNumber.get(event.commit);
61
+ if (bucket) bucket.push(event);
62
+ else byNumber.set(event.commit, [event]);
63
+ }
64
+ return [...byNumber.entries()].sort((a, b) => a[0] - b[0]).map(([commit, group]) => ({
65
+ commit,
66
+ t: group[0].t,
67
+ events: group,
68
+ cause: group.find((e) => e.kind === "write" && e.by === void 0)
69
+ }));
70
+ }
71
+
72
+ export {
73
+ createHistory,
74
+ toCommits
75
+ };
@@ -0,0 +1,155 @@
1
+ // src/kind-filter.ts
2
+ var FILTERABLE_KINDS = [
3
+ "state",
4
+ "memo",
5
+ "effect",
6
+ "store",
7
+ "resource",
8
+ "component",
9
+ "provider",
10
+ "control",
11
+ "router",
12
+ "handler",
13
+ "context",
14
+ "directive",
15
+ "custom-element",
16
+ "module",
17
+ "service"
18
+ ];
19
+ var LABEL = { handler: "route", "custom-element": "custom element" };
20
+ function createKindFilter(host, options) {
21
+ const doc = host.ownerDocument;
22
+ const kinds = options.kinds ?? FILTERABLE_KINDS;
23
+ const on = new Set(kinds);
24
+ const root = doc.createElement("div");
25
+ root.className = "fx-kinds";
26
+ const button = doc.createElement("button");
27
+ button.type = "button";
28
+ button.className = "fx-kinds-button fx-dropdown-btn";
29
+ button.setAttribute("aria-haspopup", "true");
30
+ button.setAttribute("aria-expanded", "false");
31
+ button.title = "Choose which kinds of node the graph draws";
32
+ const caret = doc.createElement("div");
33
+ caret.className = "fx-dropdown-caret";
34
+ const panel = doc.createElement("div");
35
+ panel.className = "fx-kinds-panel";
36
+ if (options.panelClass) {
37
+ panel.classList.add(...options.panelClass.split(/\s+/).filter((c) => c));
38
+ }
39
+ panel.hidden = true;
40
+ const all = doc.createElement("input");
41
+ all.type = "checkbox";
42
+ const allRow = doc.createElement("label");
43
+ allRow.className = "fx-kinds-all";
44
+ allRow.append(all, doc.createTextNode("all"));
45
+ const boxes = /* @__PURE__ */ new Map();
46
+ for (const kind of kinds) {
47
+ const box = doc.createElement("input");
48
+ box.type = "checkbox";
49
+ box.checked = true;
50
+ const row = doc.createElement("label");
51
+ row.append(box, doc.createTextNode(LABEL[kind] ?? kind));
52
+ panel.append(row);
53
+ boxes.set(kind, box);
54
+ }
55
+ panel.prepend(allRow);
56
+ root.append(button, panel);
57
+ host.append(root);
58
+ const everything = () => on.size === kinds.length;
59
+ const chosen = () => kinds.filter((kind) => on.has(kind));
60
+ function paint() {
61
+ const name = options.label ?? "Kinds";
62
+ button.textContent = everything() ? name : `${name} · ${on.size}`;
63
+ button.classList.toggle("on", !everything());
64
+ all.checked = everything();
65
+ button.appendChild(caret);
66
+ all.indeterminate = on.size > 0 && !everything();
67
+ for (const [kind, box] of boxes) box.checked = on.has(kind);
68
+ }
69
+ function report() {
70
+ options.onChange(everything() ? null : chosen());
71
+ }
72
+ for (const [kind, box] of boxes) {
73
+ box.addEventListener("change", () => {
74
+ if (box.checked) on.add(kind);
75
+ else on.delete(kind);
76
+ paint();
77
+ report();
78
+ });
79
+ }
80
+ all.addEventListener("change", () => {
81
+ for (const kind of kinds) on.add(kind);
82
+ paint();
83
+ report();
84
+ });
85
+ const close = () => {
86
+ panel.hidden = true;
87
+ button.setAttribute("aria-expanded", "false");
88
+ };
89
+ button.addEventListener("click", (event) => {
90
+ event.stopPropagation();
91
+ panel.hidden = !panel.hidden;
92
+ button.setAttribute("aria-expanded", String(!panel.hidden));
93
+ });
94
+ panel.addEventListener("click", (event) => event.stopPropagation());
95
+ const away = () => close();
96
+ const key = (event) => {
97
+ if (event.key === "Escape") close();
98
+ };
99
+ doc.addEventListener("click", away);
100
+ doc.addEventListener("keydown", key);
101
+ paint();
102
+ return {
103
+ get selected() {
104
+ return chosen();
105
+ },
106
+ select(next) {
107
+ on.clear();
108
+ for (const kind of next ?? kinds) on.add(kind);
109
+ paint();
110
+ },
111
+ destroy() {
112
+ doc.removeEventListener("click", away);
113
+ doc.removeEventListener("keydown", key);
114
+ root.remove();
115
+ }
116
+ };
117
+ }
118
+ var KIND_FILTER_CSS = `
119
+ .fx-kinds { position: relative; display: inline-flex; }
120
+ .fx-kinds-button { white-space: nowrap; }
121
+ /* The hidden attribute is display:none from the user agent, which a class setting display outranks. */
122
+ .fx-kinds-panel[hidden] { display: none; }
123
+ .fx-kinds-panel {
124
+ position: absolute; top: calc(100% + 4px); z-index: 40;
125
+ display: grid; gap: 2px; padding: 6px 8px; min-width: 132px;
126
+ background: var(--fx-panel, #14161c);
127
+ border: 1px solid var(--fx-line, #262a35); border-radius: 6px;
128
+ box-shadow: 0 6px 18px rgba(0, 0, 0, .38);
129
+ }
130
+ .fx-kinds-panel:not(.fx-panel-left){ right: 0; }
131
+ .fx-kinds-panel.fx-panel-left { left: 0; }
132
+ .fx-kinds-panel label {
133
+ display: flex; align-items: center; gap: 6px;
134
+ font-size: 11px; color: var(--fx-muted, #8a90a2); cursor: pointer; user-select: none;
135
+ }
136
+ .fx-kinds-panel label:hover { color: var(--fx-label, #e7e9ee); }
137
+ .fx-kinds-panel input { width: 11px; height: 11px; margin: 0; accent-color: var(--fx-accent, #5eead4); }
138
+ .fx-kinds-all {
139
+ padding-bottom: 4px; margin-bottom: 2px;
140
+ border-bottom: 1px solid var(--fx-line, #262a35);
141
+ color: var(--fx-label, #e7e9ee) !important;
142
+ }
143
+ `;
144
+ var DROPDOWN_FILTER_CSS = `
145
+ .fx-dropdown-btn { background-color: transparent; appearance: none; border: 1px solid var(--line-strong); outline: none; border-radius: .25rem; padding-block: .25rem; padding-inline: .875rem; font-size: .75rem; cursor: pointer }
146
+ .fx-dropdown-btn:hover { border-color: color-mix(in oklab, var(--accent) 50%, transparent); background-color: var(--bg); }
147
+ .fx-dropdown-caret { width: 0;height: 0;border-left: .15rem solid transparent; border-right: .15rem solid transparent; border-top: .15rem solid currentColor; transition: transform 0.2s ease; right: .4rem; top: 50%; color: color-mix(in oklab, var(--muted) 50%, transparent); position: absolute; }
148
+ `;
149
+
150
+ export {
151
+ FILTERABLE_KINDS,
152
+ createKindFilter,
153
+ KIND_FILTER_CSS,
154
+ DROPDOWN_FILTER_CSS
155
+ };
@@ -0,0 +1,103 @@
1
+ import {
2
+ formatValue
3
+ } from "./chunk-NT7YMK77.mjs";
4
+
5
+ // src/diff.ts
6
+ var MAX_ENTRIES = 24;
7
+ var ENTRY_VALUE = 120;
8
+ var ENTRY_JSON = 4e3;
9
+ var show = (value) => formatValue(value, ENTRY_VALUE);
10
+ function json(value) {
11
+ if (value === null || typeof value !== "object") return void 0;
12
+ try {
13
+ const text = JSON.stringify(value);
14
+ return text && text.length <= ENTRY_JSON ? text : void 0;
15
+ } catch {
16
+ return void 0;
17
+ }
18
+ }
19
+ var side = (value, key) => {
20
+ const text = json(value);
21
+ return { [key]: show(value), ...text ? { [`${key}Json`]: text } : {} };
22
+ };
23
+ var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
24
+ function same(a, b) {
25
+ if (Object.is(a, b)) return true;
26
+ if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
27
+ if (Array.isArray(a) !== Array.isArray(b)) return false;
28
+ const ka = Object.keys(a);
29
+ const kb = Object.keys(b);
30
+ if (ka.length !== kb.length) return false;
31
+ return ka.every((k) => Object.is(a[k], b[k]));
32
+ }
33
+ function diffArray(before, after) {
34
+ let head = 0;
35
+ while (head < before.length && head < after.length && same(before[head], after[head])) head++;
36
+ let tail = 0;
37
+ while (tail < before.length - head && tail < after.length - head && same(before[before.length - 1 - tail], after[after.length - 1 - tail])) {
38
+ tail++;
39
+ }
40
+ const entries = [];
41
+ let skipped = 0;
42
+ const push = (entry) => {
43
+ if (entries.length < MAX_ENTRIES) entries.push(entry);
44
+ else skipped++;
45
+ };
46
+ const removedCount = before.length - head - tail;
47
+ const addedCount = after.length - head - tail;
48
+ const overlap = Math.min(removedCount, addedCount);
49
+ for (let i = 0; i < overlap; i++) {
50
+ push({
51
+ key: String(head + i),
52
+ op: "changed",
53
+ ...side(before[head + i], "from"),
54
+ ...side(after[head + i], "to")
55
+ });
56
+ }
57
+ for (let i = overlap; i < addedCount; i++) {
58
+ push({ key: String(head + i), op: "added", ...side(after[head + i], "to") });
59
+ }
60
+ for (let i = overlap; i < removedCount; i++) {
61
+ push({ key: String(head + i), op: "removed", ...side(before[head + i], "from") });
62
+ }
63
+ return {
64
+ shape: "array",
65
+ entries,
66
+ ...skipped ? { more: skipped } : {},
67
+ ...before.length !== after.length ? { length: { from: before.length, to: after.length } } : {}
68
+ };
69
+ }
70
+ function diffObject(before, after) {
71
+ const entries = [];
72
+ let skipped = 0;
73
+ const push = (entry) => {
74
+ if (entries.length < MAX_ENTRIES) entries.push(entry);
75
+ else skipped++;
76
+ };
77
+ for (const key of /* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])) {
78
+ const had = key in before;
79
+ const has = key in after;
80
+ if (had && has) {
81
+ if (!same(before[key], after[key])) {
82
+ push({ key, op: "changed", ...side(before[key], "from"), ...side(after[key], "to") });
83
+ }
84
+ } else if (has) push({ key, op: "added", ...side(after[key], "to") });
85
+ else push({ key, op: "removed", ...side(before[key], "from") });
86
+ }
87
+ return { shape: "object", entries, ...skipped ? { more: skipped } : {} };
88
+ }
89
+ function diffValues(before, after) {
90
+ if (Array.isArray(before) && Array.isArray(after)) {
91
+ const change = diffArray(before, after);
92
+ return change.entries?.length || change.length ? change : void 0;
93
+ }
94
+ if (isPlainObject(before) && isPlainObject(after)) {
95
+ const change = diffObject(before, after);
96
+ return change.entries?.length ? change : void 0;
97
+ }
98
+ return void 0;
99
+ }
100
+
101
+ export {
102
+ diffValues
103
+ };
@@ -0,0 +1,107 @@
1
+ import {
2
+ serializeGraph
3
+ } from "./chunk-MN6O673L.mjs";
4
+ import {
5
+ observeGraph
6
+ } from "./chunk-Y5OQWBAM.mjs";
7
+ import {
8
+ hideHighlight,
9
+ showHighlight
10
+ } from "./chunk-NVULLJDH.mjs";
11
+ import {
12
+ withoutElements
13
+ } from "./chunk-OPIGF5XB.mjs";
14
+
15
+ // src/hook.ts
16
+ var HISTORY = 500;
17
+ var HOOK = "__FLUIXI_DEVTOOLS_HOOK__";
18
+ function installDevtoolsHook() {
19
+ const host = globalThis;
20
+ const existing = host[HOOK];
21
+ if (existing) {
22
+ existing.copies = (existing.copies ?? 1) + 1;
23
+ return existing;
24
+ }
25
+ let observed = null;
26
+ let owned = false;
27
+ let version = null;
28
+ const history = [];
29
+ const hook = {
30
+ copies: 1,
31
+ inject(runtime) {
32
+ version = runtime.version;
33
+ if (!observed) {
34
+ observed = (runtime.watch ?? observeGraph)({ observe: runtime.observeReactiveNodes });
35
+ owned = runtime.watch !== void 0;
36
+ return;
37
+ }
38
+ if (owned || !runtime.watch) return;
39
+ observed.detach();
40
+ observed = runtime.watch({ observe: runtime.observeReactiveNodes });
41
+ owned = true;
42
+ },
43
+ get observed() {
44
+ return observed;
45
+ },
46
+ get version() {
47
+ return version;
48
+ },
49
+ highlight(target) {
50
+ if (!observed || target === null) {
51
+ hideHighlight();
52
+ return;
53
+ }
54
+ if (typeof target === "number") {
55
+ const found = observed.elementsFor(target);
56
+ if (found.length) showHighlight(found, observed.graph.get(target)?.label);
57
+ else hideHighlight();
58
+ return;
59
+ }
60
+ const [head, ...steps] = target.split("/");
61
+ const [tag, root] = (head ?? "").split(":");
62
+ let node = observed.domFor(Number(tag))[Number(root)];
63
+ for (const step of steps) node = node?.children[Number(step)];
64
+ const element = node?.element;
65
+ if (element) showHighlight(element, element.tagName.toLowerCase());
66
+ else hideHighlight();
67
+ },
68
+ snapshot({ partial = false, since } = {}) {
69
+ if (!observed) return null;
70
+ const changed = observed.sample();
71
+ const cursor = observed.revision;
72
+ history.push(...observed.takeEvents());
73
+ if (history.length > HISTORY) history.splice(0, history.length - HISTORY);
74
+ const events = history.slice();
75
+ const dom = (id) => {
76
+ const described = observed.domFor(id);
77
+ return described.length ? withoutElements(described) : void 0;
78
+ };
79
+ const cursors = typeof observed.changedSince === "function";
80
+ const whole = partial === false || since === void 0 || !cursors || observed.outrun(since);
81
+ if (whole) {
82
+ if (partial && !cursors) {
83
+ return serializeGraph(observed.graph, Date.now(), {
84
+ ids: changed,
85
+ removed: observed.takeRemoved(),
86
+ events,
87
+ dom
88
+ });
89
+ }
90
+ return serializeGraph(observed.graph, Date.now(), { events, dom, cursor });
91
+ }
92
+ return serializeGraph(observed.graph, Date.now(), {
93
+ ids: observed.changedSince(since),
94
+ removed: observed.removedSince(since),
95
+ events,
96
+ dom,
97
+ cursor
98
+ });
99
+ }
100
+ };
101
+ host[HOOK] = hook;
102
+ return hook;
103
+ }
104
+
105
+ export {
106
+ installDevtoolsHook
107
+ };
@@ -0,0 +1,76 @@
1
+ import {
2
+ copyText
3
+ } from "./chunk-GDQXCOQB.mjs";
4
+
5
+ // src/change-view.ts
6
+ var escape = (text) => text.replace(/[&<>"]/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[c]);
7
+ var SIGN = { added: "+", removed: "−", changed: "~" };
8
+ function pretty(json) {
9
+ if (!json) return void 0;
10
+ try {
11
+ return JSON.stringify(JSON.parse(json), null, 2);
12
+ } catch {
13
+ return void 0;
14
+ }
15
+ }
16
+ function sideOf(text, json, cls) {
17
+ const block = pretty(json);
18
+ if (!block) return `<span class="ch-${cls}">${escape(text ?? "")}</span>`;
19
+ return `<div class="ch-block ch-${cls}"><button type="button" class="ch-copy" title="Copy" data-copy="${escape(block)}">copy</button><pre class="ch-json">${escape(block)}</pre></div>`;
20
+ }
21
+ function changeRows(change, limit = Infinity) {
22
+ if (!change?.entries?.length) return "";
23
+ const shown = change.entries.slice(0, limit);
24
+ const hidden = change.entries.length - shown.length + (change.more ?? 0);
25
+ const rows = shown.map((entry) => {
26
+ const from = sideOf(entry.from, entry.fromJson, "from");
27
+ const to = sideOf(entry.to, entry.toJson, "to");
28
+ const sides = entry.op === "changed" ? `${from}<span class="ch-arrow">→</span>${to}` : entry.op === "added" ? to : from;
29
+ const stacked = entry.fromJson || entry.toJson ? " ch-stacked" : "";
30
+ return `<div class="ch-row ch-${entry.op}${stacked}"><span class="ch-sign">${SIGN[entry.op] ?? "·"}</span><span class="ch-key">${escape(entry.key)}</span><span class="ch-sides">${sides}</span></div>`;
31
+ }).join("");
32
+ const size = change.length ? `<div class="ch-size">${change.length.from} → ${change.length.to} items</div>` : "";
33
+ return `<div class="ch-list">${size}${rows}${hidden > 0 ? `<div class="ch-more">and ${hidden} more</div>` : ""}</div>`;
34
+ }
35
+ function handleCopyClick(event) {
36
+ const button = event.target?.closest?.(".ch-copy");
37
+ if (!button) return false;
38
+ void copyText(button.dataset.copy ?? "", button);
39
+ return true;
40
+ }
41
+ var CHANGE_CSS = `
42
+ .ch-list { margin-top: 4px; font-family: ui-monospace, monospace; font-size: 11px; }
43
+ .ch-size { color: var(--fx-muted, #8a90a2); margin-bottom: 2px; }
44
+ .ch-row { display: flex; gap: 6px; align-items: baseline; padding: 1px 0; }
45
+ .ch-row.ch-stacked { align-items: flex-start; padding: 3px 0; }
46
+ .ch-sign { flex: none; width: 9px; text-align: center; }
47
+ .ch-added .ch-sign { color: var(--state, #34d399); }
48
+ .ch-removed .ch-sign { color: var(--fx-write, #fb7185); }
49
+ .ch-changed .ch-sign { color: var(--effect, #fbbf24); }
50
+ .ch-key { flex: none; color: var(--fx-muted, #8a90a2); }
51
+ .ch-sides { min-width: 0; flex: 1; overflow-wrap: anywhere; }
52
+ .ch-stacked .ch-sides { display: flex; flex-direction: column; gap: 2px; }
53
+ .ch-from { color: var(--fx-muted, #8a90a2); }
54
+ .ch-row:not(.ch-stacked) .ch-from { text-decoration: line-through; }
55
+ .ch-arrow { color: var(--fx-muted, #8a90a2); margin: 0 4px; }
56
+ .ch-to { color: var(--fx-label, #e7e9ee); }
57
+ .ch-more { color: var(--fx-muted, #8a90a2); margin-top: 2px; }
58
+ /* In the corner: an object can be tall, and a button under it is a scroll away. */
59
+ .ch-block { position: relative; border-radius: 4px; border: 1px solid var(--fx-line, #ffffff14); }
60
+ .ch-block.ch-from { opacity: .72; }
61
+ .ch-json { margin: 0; padding: 5px 7px; overflow-x: auto; white-space: pre; font: inherit; }
62
+ .ch-copy {
63
+ position: absolute; top: 3px; right: 3px; padding: 1px 6px; cursor: pointer;
64
+ font: inherit; font-size: 9.5px; opacity: 0; transition: opacity .12s;
65
+ border: 1px solid var(--fx-line, #ffffff26); border-radius: 3px;
66
+ background: var(--fx-panel, #14161c); color: var(--fx-muted, #8a90a2);
67
+ }
68
+ .ch-block:hover .ch-copy, .ch-copy:focus { opacity: 1; }
69
+ .ch-copy:hover { color: var(--fx-label, #e7e9ee); }
70
+ `;
71
+
72
+ export {
73
+ changeRows,
74
+ handleCopyClick,
75
+ CHANGE_CSS
76
+ };
@@ -0,0 +1,67 @@
1
+ // src/plugin.ts
2
+ var plugins = [];
3
+ function registerDevtoolsPlugin(plugin) {
4
+ const at = plugins.findIndex((p) => p.name === plugin.name);
5
+ if (at === -1) plugins.push(plugin);
6
+ else plugins[at] = plugin;
7
+ }
8
+ function devtoolsPlugins() {
9
+ return plugins;
10
+ }
11
+ function annotationOf(node, name) {
12
+ return node.extra?.[name];
13
+ }
14
+ function pluginRows(node, graph) {
15
+ const out = [];
16
+ for (const plugin of plugins) {
17
+ if (!plugin.rows) continue;
18
+ try {
19
+ out.push(...plugin.rows(node, graph));
20
+ } catch {
21
+ }
22
+ }
23
+ return out;
24
+ }
25
+ function pluginElementRows(extra) {
26
+ if (!extra) return [];
27
+ const out = [];
28
+ for (const plugin of plugins) {
29
+ if (!plugin.elementRows) continue;
30
+ try {
31
+ out.push(...plugin.elementRows(extra));
32
+ } catch {
33
+ }
34
+ }
35
+ return out;
36
+ }
37
+ function pluginElementBadge(extra) {
38
+ if (!extra) return void 0;
39
+ for (const plugin of plugins) {
40
+ try {
41
+ const badge = plugin.elementBadge?.(extra);
42
+ if (badge) return badge;
43
+ } catch {
44
+ }
45
+ }
46
+ return void 0;
47
+ }
48
+ function pluginBadge(node) {
49
+ for (const plugin of plugins) {
50
+ try {
51
+ const badge = plugin.badge?.(node);
52
+ if (badge) return badge;
53
+ } catch {
54
+ }
55
+ }
56
+ return void 0;
57
+ }
58
+
59
+ export {
60
+ registerDevtoolsPlugin,
61
+ devtoolsPlugins,
62
+ annotationOf,
63
+ pluginRows,
64
+ pluginElementRows,
65
+ pluginElementBadge,
66
+ pluginBadge
67
+ };
@@ -0,0 +1,80 @@
1
+ import {
2
+ nodeState,
3
+ nodeVersion
4
+ } from "./chunk-EBSROPWJ.mjs";
5
+ import {
6
+ formatValue
7
+ } from "./chunk-NT7YMK77.mjs";
8
+
9
+ // src/export.ts
10
+ var at = (source) => {
11
+ if (!source) return void 0;
12
+ const where = `${source.file ?? ""}:${source.line ?? ""}:${source.column ?? ""}`;
13
+ const out = source.compiled;
14
+ const same = out?.line === source.line && out?.column === source.column;
15
+ return out && !same ? `${where} (out ${out.line ?? ""}:${out.column ?? ""})` : where;
16
+ };
17
+ function naming(graph) {
18
+ const seen = /* @__PURE__ */ new Map();
19
+ for (const node of graph.values()) seen.set(node.label, (seen.get(node.label) ?? 0) + 1);
20
+ return (id) => {
21
+ const node = graph.get(id);
22
+ if (!node) return `#${id}`;
23
+ return (seen.get(node.label) ?? 0) > 1 ? `${node.label}#${node.id}` : node.label;
24
+ };
25
+ }
26
+ function exportGraph(graph, options = {}) {
27
+ const limit = options.limit ?? 400;
28
+ const name = naming(graph);
29
+ const nodes = [...graph.values()].map((node) => {
30
+ let value = node.detail ?? node.value;
31
+ if (node.read) {
32
+ try {
33
+ value = formatValue(node.read(), limit);
34
+ } catch {
35
+ }
36
+ }
37
+ const feeds = [...node.deps].map(name);
38
+ const wrote = [...node.writes].map(name);
39
+ const state = nodeState(node);
40
+ return {
41
+ id: node.id,
42
+ label: node.label,
43
+ kind: node.kind,
44
+ ...node.authored === false ? { authored: false } : {},
45
+ ...value ? { value } : {},
46
+ ...node.runs ? { runs: node.runs } : {},
47
+ // Only a node with a core has one; a static node would report a version of 0.
48
+ ...node.core?.version !== void 0 ? { version: nodeVersion(node) } : {},
49
+ ...state ? { state } : {},
50
+ ...feeds.length ? { reads: feeds } : {},
51
+ ...wrote.length ? { writes: wrote } : {},
52
+ ...node.createdIn !== void 0 ? { madeIn: name(node.createdIn) } : {},
53
+ ...at(node.source) ? { source: at(node.source) } : {},
54
+ ...at(node.declaredAt) ? { declaredAt: at(node.declaredAt) } : {},
55
+ ...at(node.usedAt) ? { usedAt: at(node.usedAt) } : {},
56
+ ...node.targets?.length ? {
57
+ updates: node.targets.map((target) => {
58
+ const what = target.name ? `${target.name} of ${target.element}` : target.element;
59
+ const where = at(target.source);
60
+ return where ? `${what} — ${where}` : what;
61
+ })
62
+ } : {},
63
+ ...node.setAt?.length ? { setAt: node.setAt.map((s) => at(s)).filter(Boolean) } : {}
64
+ };
65
+ });
66
+ return {
67
+ t: Date.now(),
68
+ from: options.fromSource ? "source" : "running application",
69
+ nodes,
70
+ ...options.events?.length ? { events: [...options.events] } : {}
71
+ };
72
+ }
73
+ function graphToJson(graph, options = {}) {
74
+ return JSON.stringify(exportGraph(graph, options), null, 2);
75
+ }
76
+
77
+ export {
78
+ exportGraph,
79
+ graphToJson
80
+ };
@@ -0,0 +1,25 @@
1
+ // src/path.ts
2
+ var normalize = (file) => file.replace(/\\/g, "/");
3
+ var ROOTED = /^\/|^(Users|home|var|opt|private|tmp|mnt|srv)\//;
4
+ var WORKSPACE_DIRS = /* @__PURE__ */ new Set(["packages", "apps", "libs", "examples"]);
5
+ function shortenPath(file, root) {
6
+ const path = normalize(file);
7
+ if (root) {
8
+ const base = normalize(root).replace(/\/+$/, "");
9
+ if (base && path.startsWith(`${base}/`)) return path.slice(base.length + 1);
10
+ if (base.startsWith("/") && path.startsWith(`${base.slice(1)}/`)) return path.slice(base.length);
11
+ }
12
+ const installed = path.lastIndexOf("node_modules/");
13
+ if (installed >= 0) return path.slice(installed + "node_modules/".length);
14
+ if (ROOTED.test(path)) {
15
+ const segments = path.split("/");
16
+ for (let i = segments.length - 2; i > 0; i--) {
17
+ if (WORKSPACE_DIRS.has(segments[i])) return segments.slice(i).join("/");
18
+ }
19
+ }
20
+ return path;
21
+ }
22
+
23
+ export {
24
+ shortenPath
25
+ };