@fluixi/devtools 1.0.0-alpha.108 → 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.
- package/dist/callsite.mjs +4 -63
- package/dist/change-view.mjs +6 -106
- package/dist/chunk-2VDMQ3VF.mjs +520 -0
- package/dist/chunk-33U2S43X.mjs +121 -0
- package/dist/chunk-4P45Y5EB.mjs +214 -0
- package/dist/chunk-B3SAJ7QG.mjs +72 -0
- package/dist/chunk-CPZWLBCQ.mjs +35 -0
- package/dist/chunk-D25KZZBZ.mjs +212 -0
- package/dist/chunk-EBSROPWJ.mjs +314 -0
- package/dist/chunk-F664XLZL.mjs +743 -0
- package/dist/chunk-FY5K3QVT.mjs +35 -0
- package/dist/chunk-G7Z7CVP5.mjs +184 -0
- package/dist/chunk-GDQXCOQB.mjs +43 -0
- package/dist/chunk-L6XQGNMW.mjs +106 -0
- package/dist/chunk-MN6O673L.mjs +90 -0
- package/dist/chunk-NDUBBBNL.mjs +70 -0
- package/dist/chunk-NT7YMK77.mjs +157 -0
- package/dist/chunk-NVULLJDH.mjs +120 -0
- package/dist/chunk-NWLSDERQ.mjs +68 -0
- package/dist/chunk-OPIGF5XB.mjs +184 -0
- package/dist/chunk-P5I7DWFX.mjs +292 -0
- package/dist/chunk-PKARAAIS.mjs +75 -0
- package/dist/chunk-PSSBFXBD.mjs +155 -0
- package/dist/chunk-PTQ5VCYE.mjs +103 -0
- package/dist/chunk-PU4MJ5RU.mjs +107 -0
- package/dist/chunk-UAEJ3N7F.mjs +76 -0
- package/dist/chunk-V6DKWEYD.mjs +67 -0
- package/dist/chunk-VO2V7AC5.mjs +80 -0
- package/dist/chunk-WGQH7RUW.mjs +25 -0
- package/dist/chunk-Y5OQWBAM.mjs +777 -0
- package/dist/chunk-Z6KYHEKY.mjs +64 -0
- package/dist/copy.mjs +3 -39
- package/dist/describe.mjs +3 -31
- package/dist/detail-panel.mjs +6 -280
- package/dist/diff.mjs +4 -201
- package/dist/dom.mjs +7 -176
- package/dist/export.mjs +6 -207
- package/dist/float.mjs +5 -206
- package/dist/format.mjs +5 -151
- package/dist/graph-view.mjs +9 -875
- package/dist/highlight.mjs +6 -113
- package/dist/history.mjs +4 -70
- package/dist/hook.mjs +16 -1719
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +106 -4673
- package/dist/inspector.mjs +11 -677
- package/dist/instrument.mjs +9 -486
- package/dist/kind-filter.mjs +6 -148
- package/dist/menu.mjs +4 -116
- package/dist/observe.mjs +14 -1510
- package/dist/palette.mjs +6 -28
- package/dist/path.mjs +3 -21
- package/dist/plugin.mjs +9 -57
- package/dist/plugins/context.mjs +6 -71
- package/dist/plugins/directives.mjs +8 -68
- package/dist/plugins/index.cjs +1 -1
- package/dist/plugins/index.mjs +13 -136
- package/dist/source.mjs +12 -93
- package/dist/timeline.mjs +7 -323
- package/dist/tree.mjs +11 -558
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/value-pane.mjs +6 -196
- package/dist/wire.cjs +1 -1
- package/dist/wire.mjs +6 -86
- package/package.json +3 -3
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
floatCard
|
|
3
|
+
} from "./chunk-D25KZZBZ.mjs";
|
|
4
|
+
import {
|
|
5
|
+
indentValue
|
|
6
|
+
} from "./chunk-NT7YMK77.mjs";
|
|
7
|
+
|
|
8
|
+
// src/value-pane.ts
|
|
9
|
+
var escape = (text) => text.replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]);
|
|
10
|
+
function createValuePane(host) {
|
|
11
|
+
const doc = host.ownerDocument;
|
|
12
|
+
let built = null;
|
|
13
|
+
const close = () => {
|
|
14
|
+
built?.remove();
|
|
15
|
+
built = null;
|
|
16
|
+
};
|
|
17
|
+
const onKey = (event) => {
|
|
18
|
+
if (event.key === "Escape") close();
|
|
19
|
+
};
|
|
20
|
+
doc.addEventListener("keydown", onKey);
|
|
21
|
+
return {
|
|
22
|
+
open(title, text) {
|
|
23
|
+
close();
|
|
24
|
+
built = floatCard(doc, title, { x: 80, y: 80, width: 420, height: 320 });
|
|
25
|
+
const shut = doc.createElement("button");
|
|
26
|
+
shut.type = "button";
|
|
27
|
+
shut.className = "vp-close";
|
|
28
|
+
shut.textContent = "✕";
|
|
29
|
+
shut.title = "Close";
|
|
30
|
+
shut.addEventListener("click", close);
|
|
31
|
+
built.bar.append(shut);
|
|
32
|
+
const body = doc.createElement("pre");
|
|
33
|
+
body.className = "vp-body";
|
|
34
|
+
body.innerHTML = escape(indentValue(text));
|
|
35
|
+
built.card.append(body);
|
|
36
|
+
doc.body.appendChild(built.card);
|
|
37
|
+
},
|
|
38
|
+
close,
|
|
39
|
+
get isOpen() {
|
|
40
|
+
return built !== null;
|
|
41
|
+
},
|
|
42
|
+
destroy() {
|
|
43
|
+
doc.removeEventListener("keydown", onKey);
|
|
44
|
+
close();
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
var VALUE_PANE_CSS = `
|
|
49
|
+
.vp-close {
|
|
50
|
+
margin-left: auto; background: none; border: 0; cursor: pointer;
|
|
51
|
+
color: var(--fx-muted, #8a90a2); font-size: 12px; line-height: 1; padding: 2px 4px;
|
|
52
|
+
}
|
|
53
|
+
.vp-close:hover { color: var(--fx-label, #e7e9ee); }
|
|
54
|
+
.vp-body {
|
|
55
|
+
flex: 1; margin: 0; padding: 8px; overflow: auto; white-space: pre;
|
|
56
|
+
font-family: ui-monospace, monospace; font-size: 11.5px; line-height: 1.5;
|
|
57
|
+
color: var(--fx-label, #e7e9ee);
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
|
|
61
|
+
export {
|
|
62
|
+
createValuePane,
|
|
63
|
+
VALUE_PANE_CSS
|
|
64
|
+
};
|
package/dist/copy.mjs
CHANGED
|
@@ -1,42 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const was = button.textContent;
|
|
5
|
-
button.textContent = said;
|
|
6
|
-
setTimeout(() => {
|
|
7
|
-
button.textContent = was;
|
|
8
|
-
}, 1200);
|
|
9
|
-
}
|
|
10
|
-
function fallback(text, button) {
|
|
11
|
-
try {
|
|
12
|
-
const doc = button?.ownerDocument ?? document;
|
|
13
|
-
const area = doc.createElement("textarea");
|
|
14
|
-
area.value = text;
|
|
15
|
-
area.setAttribute("readonly", "");
|
|
16
|
-
area.style.position = "fixed";
|
|
17
|
-
area.style.opacity = "0";
|
|
18
|
-
doc.body.appendChild(area);
|
|
19
|
-
area.select();
|
|
20
|
-
doc.execCommand("copy");
|
|
21
|
-
area.remove();
|
|
22
|
-
confirmOn(button);
|
|
23
|
-
return true;
|
|
24
|
-
} catch {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
async function copyText(text, button) {
|
|
29
|
-
const clipboard = globalThis.navigator?.clipboard;
|
|
30
|
-
if (clipboard?.writeText) {
|
|
31
|
-
try {
|
|
32
|
-
await clipboard.writeText(text);
|
|
33
|
-
confirmOn(button);
|
|
34
|
-
return true;
|
|
35
|
-
} catch {
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return fallback(text, button);
|
|
39
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
copyText
|
|
3
|
+
} from "./chunk-GDQXCOQB.mjs";
|
|
40
4
|
export {
|
|
41
5
|
copyText
|
|
42
6
|
};
|
package/dist/describe.mjs
CHANGED
|
@@ -1,34 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const parent = node.parentElement;
|
|
5
|
-
return parent ? `text in ${describeElement(parent)}` : "text";
|
|
6
|
-
}
|
|
7
|
-
function describeElement(el) {
|
|
8
|
-
const tag = el.tagName.toLowerCase();
|
|
9
|
-
const id = el.id ? `#${el.id}` : "";
|
|
10
|
-
const raw = typeof el.className === "string" ? el.className : el.getAttribute("class") ?? "";
|
|
11
|
-
const classes = raw.split(/\s+/).filter(Boolean).slice(0, MAX_CLASSES).map((c) => `.${c}`).join("");
|
|
12
|
-
return `${tag}${id}${classes}`;
|
|
13
|
-
}
|
|
14
|
-
function describeNode(target) {
|
|
15
|
-
const node = target;
|
|
16
|
-
if (!node || typeof node.nodeType !== "number") return "detached";
|
|
17
|
-
switch (node.nodeType) {
|
|
18
|
-
case 1:
|
|
19
|
-
return describeElement(node);
|
|
20
|
-
case 3:
|
|
21
|
-
return textOwner(node);
|
|
22
|
-
case 8: {
|
|
23
|
-
const parent = node.parentElement;
|
|
24
|
-
return parent ? `slot in ${describeElement(parent)}` : "slot";
|
|
25
|
-
}
|
|
26
|
-
case 11:
|
|
27
|
-
return "fragment";
|
|
28
|
-
default:
|
|
29
|
-
return node.nodeName?.toLowerCase() ?? "node";
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
describeNode
|
|
3
|
+
} from "./chunk-CPZWLBCQ.mjs";
|
|
32
4
|
export {
|
|
33
5
|
describeNode
|
|
34
6
|
};
|
package/dist/detail-panel.mjs
CHANGED
|
@@ -1,283 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
button.textContent = was;
|
|
8
|
-
}, 1200);
|
|
9
|
-
}
|
|
10
|
-
function fallback(text, button) {
|
|
11
|
-
try {
|
|
12
|
-
const doc = button?.ownerDocument ?? document;
|
|
13
|
-
const area = doc.createElement("textarea");
|
|
14
|
-
area.value = text;
|
|
15
|
-
area.setAttribute("readonly", "");
|
|
16
|
-
area.style.position = "fixed";
|
|
17
|
-
area.style.opacity = "0";
|
|
18
|
-
doc.body.appendChild(area);
|
|
19
|
-
area.select();
|
|
20
|
-
doc.execCommand("copy");
|
|
21
|
-
area.remove();
|
|
22
|
-
confirmOn(button);
|
|
23
|
-
return true;
|
|
24
|
-
} catch {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
async function copyText(text, button) {
|
|
29
|
-
const clipboard = globalThis.navigator?.clipboard;
|
|
30
|
-
if (clipboard?.writeText) {
|
|
31
|
-
try {
|
|
32
|
-
await clipboard.writeText(text);
|
|
33
|
-
confirmOn(button);
|
|
34
|
-
return true;
|
|
35
|
-
} catch {
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return fallback(text, button);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// src/change-view.ts
|
|
42
|
-
var escape = (text) => text.replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]);
|
|
43
|
-
var SIGN = { added: "+", removed: "−", changed: "~" };
|
|
44
|
-
function pretty(json) {
|
|
45
|
-
if (!json) return void 0;
|
|
46
|
-
try {
|
|
47
|
-
return JSON.stringify(JSON.parse(json), null, 2);
|
|
48
|
-
} catch {
|
|
49
|
-
return void 0;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function sideOf(text, json, cls) {
|
|
53
|
-
const block = pretty(json);
|
|
54
|
-
if (!block) return `<span class="ch-${cls}">${escape(text ?? "")}</span>`;
|
|
55
|
-
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>`;
|
|
56
|
-
}
|
|
57
|
-
function changeRows(change, limit = Infinity) {
|
|
58
|
-
if (!change?.entries?.length) return "";
|
|
59
|
-
const shown = change.entries.slice(0, limit);
|
|
60
|
-
const hidden = change.entries.length - shown.length + (change.more ?? 0);
|
|
61
|
-
const rows = shown.map((entry) => {
|
|
62
|
-
const from = sideOf(entry.from, entry.fromJson, "from");
|
|
63
|
-
const to = sideOf(entry.to, entry.toJson, "to");
|
|
64
|
-
const sides = entry.op === "changed" ? `${from}<span class="ch-arrow">→</span>${to}` : entry.op === "added" ? to : from;
|
|
65
|
-
const stacked = entry.fromJson || entry.toJson ? " ch-stacked" : "";
|
|
66
|
-
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>`;
|
|
67
|
-
}).join("");
|
|
68
|
-
const size = change.length ? `<div class="ch-size">${change.length.from} → ${change.length.to} items</div>` : "";
|
|
69
|
-
return `<div class="ch-list">${size}${rows}${hidden > 0 ? `<div class="ch-more">and ${hidden} more</div>` : ""}</div>`;
|
|
70
|
-
}
|
|
71
|
-
function handleCopyClick(event) {
|
|
72
|
-
const button = event.target?.closest?.(".ch-copy");
|
|
73
|
-
if (!button) return false;
|
|
74
|
-
void copyText(button.dataset.copy ?? "", button);
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
var CHANGE_CSS = `
|
|
78
|
-
.ch-list { margin-top: 4px; font-family: ui-monospace, monospace; font-size: 11px; }
|
|
79
|
-
.ch-size { color: var(--fx-muted, #8a90a2); margin-bottom: 2px; }
|
|
80
|
-
.ch-row { display: flex; gap: 6px; align-items: baseline; padding: 1px 0; }
|
|
81
|
-
.ch-row.ch-stacked { align-items: flex-start; padding: 3px 0; }
|
|
82
|
-
.ch-sign { flex: none; width: 9px; text-align: center; }
|
|
83
|
-
.ch-added .ch-sign { color: var(--state, #34d399); }
|
|
84
|
-
.ch-removed .ch-sign { color: var(--fx-write, #fb7185); }
|
|
85
|
-
.ch-changed .ch-sign { color: var(--effect, #fbbf24); }
|
|
86
|
-
.ch-key { flex: none; color: var(--fx-muted, #8a90a2); }
|
|
87
|
-
.ch-sides { min-width: 0; flex: 1; overflow-wrap: anywhere; }
|
|
88
|
-
.ch-stacked .ch-sides { display: flex; flex-direction: column; gap: 2px; }
|
|
89
|
-
.ch-from { color: var(--fx-muted, #8a90a2); }
|
|
90
|
-
.ch-row:not(.ch-stacked) .ch-from { text-decoration: line-through; }
|
|
91
|
-
.ch-arrow { color: var(--fx-muted, #8a90a2); margin: 0 4px; }
|
|
92
|
-
.ch-to { color: var(--fx-label, #e7e9ee); }
|
|
93
|
-
.ch-more { color: var(--fx-muted, #8a90a2); margin-top: 2px; }
|
|
94
|
-
/* In the corner: an object can be tall, and a button under it is a scroll away. */
|
|
95
|
-
.ch-block { position: relative; border-radius: 4px; border: 1px solid var(--fx-line, #ffffff14); }
|
|
96
|
-
.ch-block.ch-from { opacity: .72; }
|
|
97
|
-
.ch-json { margin: 0; padding: 5px 7px; overflow-x: auto; white-space: pre; font: inherit; }
|
|
98
|
-
.ch-copy {
|
|
99
|
-
position: absolute; top: 3px; right: 3px; padding: 1px 6px; cursor: pointer;
|
|
100
|
-
font: inherit; font-size: 9.5px; opacity: 0; transition: opacity .12s;
|
|
101
|
-
border: 1px solid var(--fx-line, #ffffff26); border-radius: 3px;
|
|
102
|
-
background: var(--fx-panel, #14161c); color: var(--fx-muted, #8a90a2);
|
|
103
|
-
}
|
|
104
|
-
.ch-block:hover .ch-copy, .ch-copy:focus { opacity: 1; }
|
|
105
|
-
.ch-copy:hover { color: var(--fx-label, #e7e9ee); }
|
|
106
|
-
`;
|
|
107
|
-
|
|
108
|
-
// src/detail-panel.ts
|
|
109
|
-
var escape2 = (text) => text.replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]);
|
|
110
|
-
var clock = (t) => {
|
|
111
|
-
const d = new Date(t);
|
|
112
|
-
const pad = (n, w = 2) => String(n).padStart(w, "0");
|
|
113
|
-
return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
|
|
114
|
-
};
|
|
115
|
-
var VERBS = {
|
|
116
|
-
write: "written",
|
|
117
|
-
ran: "ran",
|
|
118
|
-
created: "made",
|
|
119
|
-
disposed: "gone"
|
|
120
|
-
};
|
|
121
|
-
var MIN_W = 320;
|
|
122
|
-
var MIN_H = 200;
|
|
123
|
-
function draggable(handle, onMove) {
|
|
124
|
-
handle.addEventListener("pointerdown", (event) => {
|
|
125
|
-
if (event.button !== 0) return;
|
|
126
|
-
if (event.target.closest("button")) return;
|
|
127
|
-
event.preventDefault();
|
|
128
|
-
event.stopPropagation();
|
|
129
|
-
handle.setPointerCapture(event.pointerId);
|
|
130
|
-
let lastX = event.clientX;
|
|
131
|
-
let lastY = event.clientY;
|
|
132
|
-
const move = (e) => {
|
|
133
|
-
onMove(e.clientX - lastX, e.clientY - lastY);
|
|
134
|
-
lastX = e.clientX;
|
|
135
|
-
lastY = e.clientY;
|
|
136
|
-
};
|
|
137
|
-
const stop = () => {
|
|
138
|
-
handle.removeEventListener("pointermove", move);
|
|
139
|
-
handle.removeEventListener("pointerup", stop);
|
|
140
|
-
handle.removeEventListener("pointercancel", stop);
|
|
141
|
-
handle.removeEventListener("lostpointercapture", stop);
|
|
142
|
-
if (handle.hasPointerCapture(event.pointerId)) handle.releasePointerCapture(event.pointerId);
|
|
143
|
-
};
|
|
144
|
-
handle.addEventListener("pointermove", move);
|
|
145
|
-
handle.addEventListener("pointerup", stop);
|
|
146
|
-
handle.addEventListener("pointercancel", stop);
|
|
147
|
-
handle.addEventListener("lostpointercapture", stop);
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
function createDetailPanel(host, options = {}) {
|
|
151
|
-
const panel = host.ownerDocument.createElement("div");
|
|
152
|
-
panel.className = "dp-panel";
|
|
153
|
-
panel.hidden = true;
|
|
154
|
-
panel.innerHTML = '<div class="dp-bar"><span class="dp-title"></span><button type="button" class="dp-close" title="Close" aria-label="Close">✕</button></div><div class="dp-body"></div><div class="dp-grip" title="Drag to resize"></div>';
|
|
155
|
-
host.appendChild(panel);
|
|
156
|
-
const title = panel.querySelector(".dp-title");
|
|
157
|
-
const body = panel.querySelector(".dp-body");
|
|
158
|
-
const bar = panel.querySelector(".dp-bar");
|
|
159
|
-
const grip = panel.querySelector(".dp-grip");
|
|
160
|
-
let x = 0;
|
|
161
|
-
let y = 0;
|
|
162
|
-
let width = 520;
|
|
163
|
-
let height = 380;
|
|
164
|
-
let open = false;
|
|
165
|
-
const place = () => {
|
|
166
|
-
panel.style.left = `${Math.round(x)}px`;
|
|
167
|
-
panel.style.top = `${Math.round(y)}px`;
|
|
168
|
-
panel.style.width = `${Math.round(width)}px`;
|
|
169
|
-
panel.style.height = `${Math.round(height)}px`;
|
|
170
|
-
};
|
|
171
|
-
draggable(bar, (dx, dy) => {
|
|
172
|
-
const view = panel.ownerDocument.defaultView;
|
|
173
|
-
x = Math.max(0, Math.min((view?.innerWidth ?? width) - 60, x + dx));
|
|
174
|
-
y = Math.max(0, Math.min((view?.innerHeight ?? height) - 30, y + dy));
|
|
175
|
-
place();
|
|
176
|
-
});
|
|
177
|
-
draggable(grip, (dx, dy) => {
|
|
178
|
-
width = Math.max(MIN_W, width + dx);
|
|
179
|
-
height = Math.max(MIN_H, height + dy);
|
|
180
|
-
place();
|
|
181
|
-
});
|
|
182
|
-
panel.querySelector(".dp-close")?.addEventListener("click", () => close());
|
|
183
|
-
body.addEventListener("click", (e) => {
|
|
184
|
-
if (handleCopyClick(e)) return;
|
|
185
|
-
const row = e.target.closest(".dp-node");
|
|
186
|
-
if (row?.dataset.id) options.onPick?.(Number(row.dataset.id));
|
|
187
|
-
});
|
|
188
|
-
function close() {
|
|
189
|
-
open = false;
|
|
190
|
-
panel.hidden = true;
|
|
191
|
-
}
|
|
192
|
-
return {
|
|
193
|
-
open(commit, graph) {
|
|
194
|
-
const nameOf = (e) => graph.get(e.id)?.label ?? e.label ?? `#${e.id}`;
|
|
195
|
-
const cause = commit.cause;
|
|
196
|
-
title.textContent = cause ? `${nameOf(cause)} · ${clock(commit.t)}` : `${commit.commit === 0 ? "first render" : `commit ${commit.commit}`} · ${clock(commit.t)}`;
|
|
197
|
-
const headline = cause && cause.from !== void 0 && cause.to !== void 0 ? `<div class="dp-change"><span class="ch-from">${escape2(cause.from)}</span><span class="ch-arrow">→</span><span class="ch-to">${escape2(cause.to)}</span></div>` : "";
|
|
198
|
-
const groups = ["write", "ran", "created", "disposed"].map((kind) => {
|
|
199
|
-
const rows = commit.events.filter((e) => e.kind === kind && e !== cause);
|
|
200
|
-
if (!rows.length) return "";
|
|
201
|
-
const seen = /* @__PURE__ */ new Map();
|
|
202
|
-
for (const event of rows) {
|
|
203
|
-
const found = seen.get(event.id);
|
|
204
|
-
if (found) found.count++;
|
|
205
|
-
else seen.set(event.id, { name: nameOf(event), count: 1 });
|
|
206
|
-
}
|
|
207
|
-
const items = [...seen].map(
|
|
208
|
-
([id, { name, count }]) => `<button type="button" class="dp-node" data-id="${id}">${escape2(name)}${count > 1 ? ` ×${count}` : ""}</button>`
|
|
209
|
-
).join("");
|
|
210
|
-
return `<div class="dp-group"><div class="dp-verb">${VERBS[kind]}</div><div class="dp-nodes">${items}</div></div>`;
|
|
211
|
-
}).join("");
|
|
212
|
-
const node = cause ? graph.get(cause.id) : void 0;
|
|
213
|
-
const where = (t) => {
|
|
214
|
-
if (!t.source) return "";
|
|
215
|
-
const file = (t.source.file ?? "").split("/").pop() ?? "";
|
|
216
|
-
const out = t.source.compiled;
|
|
217
|
-
const tail = out && out.line !== t.source.line ? ` · out ${out.line}` : "";
|
|
218
|
-
return ` — ${file}:${t.source.line ?? ""}${tail}`;
|
|
219
|
-
};
|
|
220
|
-
const targets = node?.targets?.length ? `<div class="dp-group"><div class="dp-verb">updates</div><div class="dp-targets">${node.targets.map(
|
|
221
|
-
(t) => `<div>${escape2(t.name ? `${t.name} of ${t.element}` : t.element)}<span class="dp-where">${escape2(where(t))}</span></div>`
|
|
222
|
-
).join("")}</div></div>` : "";
|
|
223
|
-
body.innerHTML = headline + changeRows(cause?.change) + groups + targets;
|
|
224
|
-
if (!open) {
|
|
225
|
-
const view = panel.ownerDocument.defaultView;
|
|
226
|
-
x = Math.max(12, ((view?.innerWidth ?? 900) - width) / 2);
|
|
227
|
-
y = Math.max(12, ((view?.innerHeight ?? 600) - height) / 3);
|
|
228
|
-
place();
|
|
229
|
-
}
|
|
230
|
-
open = true;
|
|
231
|
-
panel.hidden = false;
|
|
232
|
-
},
|
|
233
|
-
close,
|
|
234
|
-
get isOpen() {
|
|
235
|
-
return open;
|
|
236
|
-
},
|
|
237
|
-
destroy() {
|
|
238
|
-
panel.remove();
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
var DETAIL_PANEL_CSS = `
|
|
243
|
-
.dp-panel {
|
|
244
|
-
position: fixed; z-index: 40; display: flex; flex-direction: column;
|
|
245
|
-
border: 1px solid var(--fx-line, #ffffff26); border-radius: 8px;
|
|
246
|
-
background: var(--fx-panel, #14161c); color: var(--fx-label, #e7e9ee);
|
|
247
|
-
box-shadow: 0 12px 40px rgba(0, 0, 0, .45); overflow: hidden;
|
|
248
|
-
}
|
|
249
|
-
.dp-panel[hidden] { display: none; }
|
|
250
|
-
.dp-bar {
|
|
251
|
-
display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px;
|
|
252
|
-
cursor: move; user-select: none;
|
|
253
|
-
border-bottom: 1px solid var(--fx-line, #ffffff1f);
|
|
254
|
-
}
|
|
255
|
-
.dp-title { font-family: ui-monospace, monospace; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
256
|
-
.dp-close {
|
|
257
|
-
margin-left: auto; width: 22px; height: 20px; padding: 0; cursor: pointer; font: inherit; font-size: 11px;
|
|
258
|
-
border: 1px solid var(--fx-line, #ffffff1f); border-radius: 4px;
|
|
259
|
-
background: transparent; color: var(--fx-muted, #8a90a2);
|
|
260
|
-
}
|
|
261
|
-
.dp-close:hover { color: var(--fx-label, #e7e9ee); }
|
|
262
|
-
.dp-body { flex: 1; min-height: 0; overflow: auto; padding: 10px 12px; }
|
|
263
|
-
.dp-change { font-family: ui-monospace, monospace; font-size: 12px; overflow-wrap: anywhere; }
|
|
264
|
-
.dp-group { margin-top: 10px; }
|
|
265
|
-
.dp-verb { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--fx-muted, #8a90a2); }
|
|
266
|
-
.dp-nodes { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
|
|
267
|
-
.dp-node {
|
|
268
|
-
padding: 2px 7px; cursor: pointer; font: inherit; font-family: ui-monospace, monospace; font-size: 11px;
|
|
269
|
-
border: 1px solid var(--fx-line, #ffffff1f); border-radius: 999px;
|
|
270
|
-
background: transparent; color: var(--fx-label, #e7e9ee);
|
|
271
|
-
}
|
|
272
|
-
.dp-node:hover { border-color: var(--fx-accent, #5eead4); }
|
|
273
|
-
.dp-targets { margin-top: 4px; font-family: ui-monospace, monospace; font-size: 11px; color: var(--fx-label, #e7e9ee); }
|
|
274
|
-
.dp-where { color: var(--fx-muted, #8a90a2); }
|
|
275
|
-
/* Bottom-right, where every desktop puts it. */
|
|
276
|
-
.dp-grip {
|
|
277
|
-
position: absolute; right: 0; bottom: 0; width: 16px; height: 16px; cursor: nwse-resize;
|
|
278
|
-
background: linear-gradient(135deg, transparent 50%, var(--fx-line, #ffffff40) 50%);
|
|
279
|
-
}
|
|
280
|
-
${CHANGE_CSS}`;
|
|
1
|
+
import {
|
|
2
|
+
DETAIL_PANEL_CSS,
|
|
3
|
+
createDetailPanel
|
|
4
|
+
} from "./chunk-G7Z7CVP5.mjs";
|
|
5
|
+
import "./chunk-UAEJ3N7F.mjs";
|
|
6
|
+
import "./chunk-GDQXCOQB.mjs";
|
|
281
7
|
export {
|
|
282
8
|
DETAIL_PANEL_CSS,
|
|
283
9
|
createDetailPanel
|
package/dist/diff.mjs
CHANGED
|
@@ -1,204 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (typeof v?.nodeType !== "number" || typeof v.nodeName !== "string") return null;
|
|
6
|
-
return v.tagName ? `<${v.tagName.toLowerCase()}>` : `#${v.nodeName.toLowerCase()}`;
|
|
7
|
-
}
|
|
8
|
-
function fnName(v) {
|
|
9
|
-
return v.name ? `ƒ ${v.name}()` : "ƒ";
|
|
10
|
-
}
|
|
11
|
-
function className(v) {
|
|
12
|
-
const name = v.constructor?.name;
|
|
13
|
-
return name && name !== "Object" ? `${name} ` : "";
|
|
14
|
-
}
|
|
15
|
-
function primitive(v) {
|
|
16
|
-
if (v === null) return "null";
|
|
17
|
-
switch (typeof v) {
|
|
18
|
-
case "undefined":
|
|
19
|
-
return "undefined";
|
|
20
|
-
case "string":
|
|
21
|
-
return JSON.stringify(v);
|
|
22
|
-
case "number":
|
|
23
|
-
case "boolean":
|
|
24
|
-
return String(v);
|
|
25
|
-
case "bigint":
|
|
26
|
-
return `${v}n`;
|
|
27
|
-
case "symbol":
|
|
28
|
-
return v.toString();
|
|
29
|
-
case "function":
|
|
30
|
-
return fnName(v);
|
|
31
|
-
default:
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function walk(value, depth, seen) {
|
|
36
|
-
const simple = primitive(value);
|
|
37
|
-
if (simple !== null) return simple;
|
|
38
|
-
const object = value;
|
|
39
|
-
if (seen.has(object)) return "[circular]";
|
|
40
|
-
const dom = domName(object);
|
|
41
|
-
if (dom) return dom;
|
|
42
|
-
if (object instanceof Date) return Number.isNaN(object.getTime()) ? "Invalid Date" : object.toISOString();
|
|
43
|
-
if (object instanceof RegExp) return String(object);
|
|
44
|
-
if (object instanceof Error) return `${object.name}: ${object.message}`;
|
|
45
|
-
if (object instanceof Promise) return "Promise";
|
|
46
|
-
if (ArrayBuffer.isView(object)) {
|
|
47
|
-
return `${className(object).trim()}(${object.length ?? ""})`;
|
|
48
|
-
}
|
|
49
|
-
if (depth >= MAX_DEPTH) return Array.isArray(object) ? "[…]" : "{…}";
|
|
50
|
-
seen.add(object);
|
|
51
|
-
try {
|
|
52
|
-
if (Array.isArray(object)) {
|
|
53
|
-
const shown2 = object.slice(0, MAX_ENTRIES).map((item) => walk(item, depth + 1, seen));
|
|
54
|
-
if (object.length > MAX_ENTRIES) shown2.push("…");
|
|
55
|
-
return `[${shown2.join(", ")}]`;
|
|
56
|
-
}
|
|
57
|
-
if (object instanceof Map) {
|
|
58
|
-
const shown2 = [];
|
|
59
|
-
for (const [k, v] of object) {
|
|
60
|
-
if (shown2.length === MAX_ENTRIES) {
|
|
61
|
-
shown2.push("…");
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
shown2.push(`${walk(k, depth + 1, seen)} => ${walk(v, depth + 1, seen)}`);
|
|
65
|
-
}
|
|
66
|
-
return `Map(${object.size}) {${shown2.join(", ")}}`;
|
|
67
|
-
}
|
|
68
|
-
if (object instanceof Set) {
|
|
69
|
-
const shown2 = [];
|
|
70
|
-
for (const item of object) {
|
|
71
|
-
if (shown2.length === MAX_ENTRIES) {
|
|
72
|
-
shown2.push("…");
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
shown2.push(walk(item, depth + 1, seen));
|
|
76
|
-
}
|
|
77
|
-
return `Set(${object.size}) {${shown2.join(", ")}}`;
|
|
78
|
-
}
|
|
79
|
-
const keys = Object.keys(object);
|
|
80
|
-
const shown = keys.slice(0, MAX_ENTRIES).map((key) => {
|
|
81
|
-
let read;
|
|
82
|
-
try {
|
|
83
|
-
const descriptor = Object.getOwnPropertyDescriptor(object, key);
|
|
84
|
-
if (descriptor?.get) return `${key}: [getter]`;
|
|
85
|
-
read = walk(object[key], depth + 1, seen);
|
|
86
|
-
} catch {
|
|
87
|
-
read = "[unreadable]";
|
|
88
|
-
}
|
|
89
|
-
return `${key}: ${read}`;
|
|
90
|
-
});
|
|
91
|
-
if (keys.length > MAX_ENTRIES) shown.push("…");
|
|
92
|
-
return `${className(object)}{${shown.join(", ")}}`;
|
|
93
|
-
} finally {
|
|
94
|
-
seen.delete(object);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function formatValue(value, limit = 240) {
|
|
98
|
-
let text;
|
|
99
|
-
try {
|
|
100
|
-
text = walk(value, 0, /* @__PURE__ */ new Set());
|
|
101
|
-
} catch {
|
|
102
|
-
text = "[unreadable]";
|
|
103
|
-
}
|
|
104
|
-
return text.length > limit ? `${text.slice(0, limit - 1)}…` : text;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// src/diff.ts
|
|
108
|
-
var MAX_ENTRIES2 = 24;
|
|
109
|
-
var ENTRY_VALUE = 120;
|
|
110
|
-
var ENTRY_JSON = 4e3;
|
|
111
|
-
var show = (value) => formatValue(value, ENTRY_VALUE);
|
|
112
|
-
function json(value) {
|
|
113
|
-
if (value === null || typeof value !== "object") return void 0;
|
|
114
|
-
try {
|
|
115
|
-
const text = JSON.stringify(value);
|
|
116
|
-
return text && text.length <= ENTRY_JSON ? text : void 0;
|
|
117
|
-
} catch {
|
|
118
|
-
return void 0;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
var side = (value, key) => {
|
|
122
|
-
const text = json(value);
|
|
123
|
-
return { [key]: show(value), ...text ? { [`${key}Json`]: text } : {} };
|
|
124
|
-
};
|
|
125
|
-
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
126
|
-
function same(a, b) {
|
|
127
|
-
if (Object.is(a, b)) return true;
|
|
128
|
-
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
|
|
129
|
-
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
130
|
-
const ka = Object.keys(a);
|
|
131
|
-
const kb = Object.keys(b);
|
|
132
|
-
if (ka.length !== kb.length) return false;
|
|
133
|
-
return ka.every((k) => Object.is(a[k], b[k]));
|
|
134
|
-
}
|
|
135
|
-
function diffArray(before, after) {
|
|
136
|
-
let head = 0;
|
|
137
|
-
while (head < before.length && head < after.length && same(before[head], after[head])) head++;
|
|
138
|
-
let tail = 0;
|
|
139
|
-
while (tail < before.length - head && tail < after.length - head && same(before[before.length - 1 - tail], after[after.length - 1 - tail])) {
|
|
140
|
-
tail++;
|
|
141
|
-
}
|
|
142
|
-
const entries = [];
|
|
143
|
-
let skipped = 0;
|
|
144
|
-
const push = (entry) => {
|
|
145
|
-
if (entries.length < MAX_ENTRIES2) entries.push(entry);
|
|
146
|
-
else skipped++;
|
|
147
|
-
};
|
|
148
|
-
const removedCount = before.length - head - tail;
|
|
149
|
-
const addedCount = after.length - head - tail;
|
|
150
|
-
const overlap = Math.min(removedCount, addedCount);
|
|
151
|
-
for (let i = 0; i < overlap; i++) {
|
|
152
|
-
push({
|
|
153
|
-
key: String(head + i),
|
|
154
|
-
op: "changed",
|
|
155
|
-
...side(before[head + i], "from"),
|
|
156
|
-
...side(after[head + i], "to")
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
for (let i = overlap; i < addedCount; i++) {
|
|
160
|
-
push({ key: String(head + i), op: "added", ...side(after[head + i], "to") });
|
|
161
|
-
}
|
|
162
|
-
for (let i = overlap; i < removedCount; i++) {
|
|
163
|
-
push({ key: String(head + i), op: "removed", ...side(before[head + i], "from") });
|
|
164
|
-
}
|
|
165
|
-
return {
|
|
166
|
-
shape: "array",
|
|
167
|
-
entries,
|
|
168
|
-
...skipped ? { more: skipped } : {},
|
|
169
|
-
...before.length !== after.length ? { length: { from: before.length, to: after.length } } : {}
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
function diffObject(before, after) {
|
|
173
|
-
const entries = [];
|
|
174
|
-
let skipped = 0;
|
|
175
|
-
const push = (entry) => {
|
|
176
|
-
if (entries.length < MAX_ENTRIES2) entries.push(entry);
|
|
177
|
-
else skipped++;
|
|
178
|
-
};
|
|
179
|
-
for (const key of /* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])) {
|
|
180
|
-
const had = key in before;
|
|
181
|
-
const has = key in after;
|
|
182
|
-
if (had && has) {
|
|
183
|
-
if (!same(before[key], after[key])) {
|
|
184
|
-
push({ key, op: "changed", ...side(before[key], "from"), ...side(after[key], "to") });
|
|
185
|
-
}
|
|
186
|
-
} else if (has) push({ key, op: "added", ...side(after[key], "to") });
|
|
187
|
-
else push({ key, op: "removed", ...side(before[key], "from") });
|
|
188
|
-
}
|
|
189
|
-
return { shape: "object", entries, ...skipped ? { more: skipped } : {} };
|
|
190
|
-
}
|
|
191
|
-
function diffValues(before, after) {
|
|
192
|
-
if (Array.isArray(before) && Array.isArray(after)) {
|
|
193
|
-
const change = diffArray(before, after);
|
|
194
|
-
return change.entries?.length || change.length ? change : void 0;
|
|
195
|
-
}
|
|
196
|
-
if (isPlainObject(before) && isPlainObject(after)) {
|
|
197
|
-
const change = diffObject(before, after);
|
|
198
|
-
return change.entries?.length ? change : void 0;
|
|
199
|
-
}
|
|
200
|
-
return void 0;
|
|
201
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
diffValues
|
|
3
|
+
} from "./chunk-PTQ5VCYE.mjs";
|
|
4
|
+
import "./chunk-NT7YMK77.mjs";
|
|
202
5
|
export {
|
|
203
6
|
diffValues
|
|
204
7
|
};
|