@fluixi/devtools 1.0.0-alpha.108 → 1.0.0-alpha.110
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-235BSS43.mjs +185 -0
- package/dist/chunk-2ACSNLS6.mjs +87 -0
- package/dist/chunk-2VDMQ3VF.mjs +520 -0
- package/dist/chunk-33U2S43X.mjs +121 -0
- package/dist/chunk-B3SAJ7QG.mjs +72 -0
- package/dist/chunk-BTCWJTXR.mjs +216 -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-GDQXCOQB.mjs +43 -0
- package/dist/chunk-JLNWT36I.mjs +118 -0
- package/dist/chunk-JTHAZJJZ.mjs +780 -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-PSSBFXBD.mjs +155 -0
- package/dist/chunk-PTQ5VCYE.mjs +103 -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-Z6KYHEKY.mjs +64 -0
- package/dist/copy.mjs +3 -39
- package/dist/describe.mjs +3 -31
- package/dist/detail-panel.cjs +2 -1
- package/dist/detail-panel.d.ts.map +1 -1
- package/dist/detail-panel.js +1 -0
- 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.cjs +14 -2
- package/dist/history.d.ts +8 -1
- package/dist/history.d.ts.map +1 -1
- package/dist/history.js +15 -2
- package/dist/history.mjs +4 -70
- package/dist/hook.cjs +26 -1
- package/dist/hook.d.ts +4 -0
- package/dist/hook.d.ts.map +1 -1
- package/dist/hook.js +13 -0
- package/dist/hook.mjs +16 -1719
- package/dist/index.cjs +34 -5
- 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.cjs +15 -1
- package/dist/observe.d.ts +2 -0
- package/dist/observe.d.ts.map +1 -1
- package/dist/observe.js +3 -0
- 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.cjs +5 -2
- package/dist/timeline.d.ts.map +1 -1
- package/dist/timeline.js +5 -1
- 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
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-235BSS43.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
|
};
|
package/dist/dom.mjs
CHANGED
|
@@ -1,179 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
let out = element.tagName.toLowerCase();
|
|
9
|
-
if (element.id) out += `#${element.id}`;
|
|
10
|
-
const classes = element.classList;
|
|
11
|
-
if (classes.length > 0) {
|
|
12
|
-
out += `.${classes[0]}`;
|
|
13
|
-
if (classes.length > 1) out += `.${classes[1]}`;
|
|
14
|
-
}
|
|
15
|
-
return out;
|
|
16
|
-
}
|
|
17
|
-
function describeAll(graph, roots, writtenBy, kinds, extraFor) {
|
|
18
|
-
const owners = /* @__PURE__ */ new Map();
|
|
19
|
-
const writers = /* @__PURE__ */ new Map();
|
|
20
|
-
const rendered = /* @__PURE__ */ new Map();
|
|
21
|
-
for (const node of graph.values()) {
|
|
22
|
-
if (kinds.has(node.kind)) {
|
|
23
|
-
const found = roots(node.id);
|
|
24
|
-
rendered.set(node.id, found);
|
|
25
|
-
for (const element of found) if (!owners.has(element)) owners.set(element, node.id);
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
for (const element of writtenBy(node.id)) {
|
|
29
|
-
const held = writers.get(element);
|
|
30
|
-
if (held) held.push(node.id);
|
|
31
|
-
else writers.set(element, [node.id]);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
const { claimed, containers } = claimOrphans(graph, rendered, writtenBy, kinds, owners);
|
|
35
|
-
const claims = /* @__PURE__ */ new Map();
|
|
36
|
-
for (const [element, id] of claimed) {
|
|
37
|
-
const held = claims.get(id);
|
|
38
|
-
if (held) held.push(element);
|
|
39
|
-
else claims.set(id, [element]);
|
|
40
|
-
}
|
|
41
|
-
const landing = landings(graph, rendered, writtenBy, kinds, claimed, containers);
|
|
42
|
-
const out = /* @__PURE__ */ new Map();
|
|
43
|
-
for (const node of graph.values()) {
|
|
44
|
-
if (!kinds.has(node.kind)) continue;
|
|
45
|
-
const budget = { left: DOM_BUDGET };
|
|
46
|
-
const walk = (element) => {
|
|
47
|
-
const owner = owners.get(element) ?? claimed.get(element);
|
|
48
|
-
const where = locationOf(element);
|
|
49
|
-
if (owner !== void 0 && owner !== node.id) {
|
|
50
|
-
return { label: describeElement(element), children: [], owner, element, ...where ? { at: where } : {} };
|
|
51
|
-
}
|
|
52
|
-
if (containers.has(element)) {
|
|
53
|
-
return { label: describeElement(element), children: [], container: true, element, ...where ? { at: where } : {} };
|
|
54
|
-
}
|
|
55
|
-
const children = [];
|
|
56
|
-
const kids = element.children;
|
|
57
|
-
for (let i = 0, n = kids.length; i < n && budget.left > 0; i++) {
|
|
58
|
-
budget.left -= 1;
|
|
59
|
-
children.push(walk(kids[i]));
|
|
60
|
-
}
|
|
61
|
-
const writes = writers.get(element);
|
|
62
|
-
const extra = extraFor?.(element);
|
|
63
|
-
const inside = landing.get(element)?.filter((id) => within(graph, id, node.id));
|
|
64
|
-
return {
|
|
65
|
-
label: describeElement(element),
|
|
66
|
-
children,
|
|
67
|
-
element,
|
|
68
|
-
...where ? { at: where } : {},
|
|
69
|
-
...writes?.length ? { writes } : {},
|
|
70
|
-
...inside?.length ? { inside } : {},
|
|
71
|
-
...extra ? { extra } : {}
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
out.set(node.id, [...rendered.get(node.id) ?? [], ...claims.get(node.id) ?? []].map(walk));
|
|
75
|
-
}
|
|
76
|
-
return out;
|
|
77
|
-
}
|
|
78
|
-
function within(graph, id, ancestor) {
|
|
79
|
-
const seen = /* @__PURE__ */ new Set();
|
|
80
|
-
for (let at = graph.get(id)?.createdIn; at !== void 0 && !seen.has(at); at = graph.get(at)?.createdIn) {
|
|
81
|
-
if (at === ancestor) return true;
|
|
82
|
-
seen.add(at);
|
|
83
|
-
}
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
function landings(graph, rendered, writtenBy, kinds, claimed, containers) {
|
|
87
|
-
const claimers = new Set(claimed.values());
|
|
88
|
-
const landing = /* @__PURE__ */ new Map();
|
|
89
|
-
for (const node of graph.values()) {
|
|
90
|
-
if (!kinds.has(node.kind) || (rendered.get(node.id) ?? []).length) continue;
|
|
91
|
-
if (claimers.has(node.id)) continue;
|
|
92
|
-
let shallowest;
|
|
93
|
-
let best = Infinity;
|
|
94
|
-
for (const element of writtenBy(node.id)) {
|
|
95
|
-
if (containers.has(element)) continue;
|
|
96
|
-
const depth = depthInDocument(element);
|
|
97
|
-
if (depth < best) {
|
|
98
|
-
best = depth;
|
|
99
|
-
shallowest = element;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
if (!shallowest) continue;
|
|
103
|
-
const held = landing.get(shallowest);
|
|
104
|
-
if (held) held.push(node.id);
|
|
105
|
-
else landing.set(shallowest, [node.id]);
|
|
106
|
-
}
|
|
107
|
-
for (const [element, ids] of landing) {
|
|
108
|
-
landing.set(element, ids.filter((id) => !ids.some((other) => other !== id && within(graph, id, other))));
|
|
109
|
-
}
|
|
110
|
-
return landing;
|
|
111
|
-
}
|
|
112
|
-
function tagDepths(graph, kinds) {
|
|
113
|
-
const depth = /* @__PURE__ */ new Map();
|
|
114
|
-
const of = (id, seen) => {
|
|
115
|
-
const held = depth.get(id);
|
|
116
|
-
if (held !== void 0) return held;
|
|
117
|
-
if (seen.has(id)) return 0;
|
|
118
|
-
seen.add(id);
|
|
119
|
-
const parent = graph.get(id)?.createdIn;
|
|
120
|
-
const value = parent === void 0 ? 0 : of(parent, seen) + 1;
|
|
121
|
-
depth.set(id, value);
|
|
122
|
-
return value;
|
|
123
|
-
};
|
|
124
|
-
for (const node of graph.values()) if (kinds.has(node.kind)) of(node.id, /* @__PURE__ */ new Set());
|
|
125
|
-
return depth;
|
|
126
|
-
}
|
|
127
|
-
function depthInDocument(element) {
|
|
128
|
-
let steps = 0;
|
|
129
|
-
for (let at = element.parentElement; at; at = at.parentElement) steps++;
|
|
130
|
-
return steps;
|
|
131
|
-
}
|
|
132
|
-
function claimOrphans(graph, rendered, writtenBy, kinds, owners) {
|
|
133
|
-
const depth = tagDepths(graph, kinds);
|
|
134
|
-
const wraps = (element) => {
|
|
135
|
-
for (const owned of owners.keys()) if (element !== owned && element.contains(owned)) return true;
|
|
136
|
-
return false;
|
|
137
|
-
};
|
|
138
|
-
const writing = /* @__PURE__ */ new Map();
|
|
139
|
-
for (const node of graph.values()) {
|
|
140
|
-
if (!kinds.has(node.kind) || (rendered.get(node.id) ?? []).length) continue;
|
|
141
|
-
for (const element of writtenBy(node.id)) {
|
|
142
|
-
if (owners.has(element)) continue;
|
|
143
|
-
const held = writing.get(element);
|
|
144
|
-
if (held) held.push(node.id);
|
|
145
|
-
else writing.set(element, [node.id]);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
const claimed = /* @__PURE__ */ new Map();
|
|
149
|
-
const containers = /* @__PURE__ */ new Set();
|
|
150
|
-
const covered = (element) => {
|
|
151
|
-
for (let at = element.parentElement; at; at = at.parentElement) {
|
|
152
|
-
if (owners.has(at) || claimed.has(at)) return true;
|
|
153
|
-
}
|
|
154
|
-
return false;
|
|
155
|
-
};
|
|
156
|
-
const order = [...writing.keys()].sort((a, b) => depthInDocument(a) - depthInDocument(b));
|
|
157
|
-
for (const element of order) {
|
|
158
|
-
if (covered(element)) continue;
|
|
159
|
-
const ids = writing.get(element);
|
|
160
|
-
const container = wraps(element);
|
|
161
|
-
const pick = ids.reduce((best, id) => {
|
|
162
|
-
const a = depth.get(id) ?? 0;
|
|
163
|
-
const b = depth.get(best) ?? 0;
|
|
164
|
-
return container ? a < b ? id : best : a > b ? id : best;
|
|
165
|
-
});
|
|
166
|
-
claimed.set(element, pick);
|
|
167
|
-
if (container) containers.add(element);
|
|
168
|
-
}
|
|
169
|
-
return { claimed, containers };
|
|
170
|
-
}
|
|
171
|
-
function withoutElements(nodes) {
|
|
172
|
-
return nodes.map(({ element, children, ...rest }) => ({
|
|
173
|
-
...rest,
|
|
174
|
-
children: withoutElements(children)
|
|
175
|
-
}));
|
|
176
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
DOM_BUDGET,
|
|
3
|
+
describeAll,
|
|
4
|
+
describeElement,
|
|
5
|
+
tagDepths,
|
|
6
|
+
withoutElements
|
|
7
|
+
} from "./chunk-OPIGF5XB.mjs";
|
|
177
8
|
export {
|
|
178
9
|
DOM_BUDGET,
|
|
179
10
|
describeAll,
|