@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
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// src/source.ts
|
|
2
|
+
var MARKER = "__fx_source";
|
|
3
|
+
var COMPONENT_MARKER = "__fx_component";
|
|
4
|
+
var CLASS_MARKER = "__fx_class";
|
|
5
|
+
var HOLE_MARKER = "__fx_hole";
|
|
6
|
+
var PROPS_MARKER = "__fx_props";
|
|
7
|
+
var MARKS = "__FLUIXI_DEVTOOLS_MARKS__";
|
|
8
|
+
var host = globalThis;
|
|
9
|
+
var shared = host[MARKS] ?? {
|
|
10
|
+
pending: null,
|
|
11
|
+
expiring: false,
|
|
12
|
+
components: /* @__PURE__ */ new Map()
|
|
13
|
+
};
|
|
14
|
+
host[MARKS] = shared;
|
|
15
|
+
shared.classes ??= /* @__PURE__ */ new WeakMap();
|
|
16
|
+
function markReactiveSource(file, line, column, name, self) {
|
|
17
|
+
const location = locate(file, line, column);
|
|
18
|
+
if (shared.pending && location.external && !shared.pending.location?.external) return;
|
|
19
|
+
shared.pending = self && typeof self === "object" ? { name, location, self } : { name, location };
|
|
20
|
+
shared.expiring = false;
|
|
21
|
+
}
|
|
22
|
+
function dropReactiveSource() {
|
|
23
|
+
shared.pending = null;
|
|
24
|
+
}
|
|
25
|
+
function locate(file, line, column) {
|
|
26
|
+
const external = !!file && (/^([a-zA-Z]:)?[\\/]/.test(file) || file.includes("node_modules/"));
|
|
27
|
+
return external ? { file, line, column, external } : { file, line, column };
|
|
28
|
+
}
|
|
29
|
+
function markComponentSource(name, file, line, column) {
|
|
30
|
+
const seen = shared.components.get(name);
|
|
31
|
+
const next = locate(file, line, column);
|
|
32
|
+
if (seen === void 0) {
|
|
33
|
+
shared.components.set(name, next);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (!seen || seen.file !== file || seen.line !== line) shared.components.set(name, null);
|
|
37
|
+
}
|
|
38
|
+
function markClassSource(constructor, file, line, column) {
|
|
39
|
+
if (typeof constructor === "function") shared.classes.set(constructor, locate(file, line, column));
|
|
40
|
+
}
|
|
41
|
+
function classSource(constructor) {
|
|
42
|
+
return typeof constructor === "function" ? shared.classes.get(constructor) : void 0;
|
|
43
|
+
}
|
|
44
|
+
function componentSource(name) {
|
|
45
|
+
return shared.components.get(name) ?? void 0;
|
|
46
|
+
}
|
|
47
|
+
function takeReactiveSource() {
|
|
48
|
+
const mark = shared.pending;
|
|
49
|
+
if (mark) {
|
|
50
|
+
if (mark.name !== void 0 || mark.self) shared.pending = { location: mark.location };
|
|
51
|
+
if (!shared.expiring) {
|
|
52
|
+
shared.expiring = true;
|
|
53
|
+
queueMicrotask(() => {
|
|
54
|
+
shared.expiring = false;
|
|
55
|
+
shared.pending = null;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return mark;
|
|
60
|
+
}
|
|
61
|
+
var HOLES = /* @__PURE__ */ new WeakMap();
|
|
62
|
+
var HOLE_TAG = "__fx_at";
|
|
63
|
+
function markHole(accessor, line, column, name) {
|
|
64
|
+
if (accessor && (typeof accessor === "object" || typeof accessor === "function")) {
|
|
65
|
+
const at = name === void 0 ? { line, column } : { line, column, name };
|
|
66
|
+
HOLES.set(accessor, at);
|
|
67
|
+
try {
|
|
68
|
+
Object.defineProperty(accessor, HOLE_TAG, { value: at, configurable: true });
|
|
69
|
+
} catch {
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
shared.pending = null;
|
|
73
|
+
return accessor;
|
|
74
|
+
}
|
|
75
|
+
var PROPS = /* @__PURE__ */ new WeakMap();
|
|
76
|
+
function markProps(props, at) {
|
|
77
|
+
if (props && typeof props === "object") PROPS.set(props, at);
|
|
78
|
+
return props;
|
|
79
|
+
}
|
|
80
|
+
function propsLocations(props) {
|
|
81
|
+
return props && typeof props === "object" ? PROPS.get(props) : void 0;
|
|
82
|
+
}
|
|
83
|
+
function holeLocation(accessor) {
|
|
84
|
+
if (!accessor || typeof accessor !== "object" && typeof accessor !== "function") return void 0;
|
|
85
|
+
return HOLES.get(accessor) ?? accessor[HOLE_TAG];
|
|
86
|
+
}
|
|
87
|
+
function installSourceMarker() {
|
|
88
|
+
if (typeof host[MARKER] !== "function") host[MARKER] = markReactiveSource;
|
|
89
|
+
if (typeof host[COMPONENT_MARKER] !== "function") host[COMPONENT_MARKER] = markComponentSource;
|
|
90
|
+
if (typeof host[CLASS_MARKER] !== "function") host[CLASS_MARKER] = markClassSource;
|
|
91
|
+
if (typeof host[HOLE_MARKER] !== "function") host[HOLE_MARKER] = markHole;
|
|
92
|
+
if (typeof host[PROPS_MARKER] !== "function") host[PROPS_MARKER] = markProps;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export {
|
|
96
|
+
markReactiveSource,
|
|
97
|
+
dropReactiveSource,
|
|
98
|
+
markComponentSource,
|
|
99
|
+
markClassSource,
|
|
100
|
+
classSource,
|
|
101
|
+
componentSource,
|
|
102
|
+
takeReactiveSource,
|
|
103
|
+
propsLocations,
|
|
104
|
+
holeLocation,
|
|
105
|
+
installSourceMarker
|
|
106
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// src/wire.ts
|
|
2
|
+
var STATE_NAME = { 0: "clean", 1: "check", 2: "dirty" };
|
|
3
|
+
var STATE_CODE = { clean: 0, check: 1, dirty: 2 };
|
|
4
|
+
function serializeGraph(graph, now = Date.now(), options = {}) {
|
|
5
|
+
const nodes = [];
|
|
6
|
+
const wanted = options.ids ? new Set(options.ids) : null;
|
|
7
|
+
for (const node of graph.values()) {
|
|
8
|
+
if (wanted && !wanted.has(node.id)) continue;
|
|
9
|
+
const state = typeof node.core?.state === "number" ? STATE_NAME[node.core.state] : void 0;
|
|
10
|
+
nodes.push({
|
|
11
|
+
id: node.id,
|
|
12
|
+
label: node.label,
|
|
13
|
+
kind: node.kind,
|
|
14
|
+
authored: node.authored,
|
|
15
|
+
deps: [...node.deps],
|
|
16
|
+
writes: [...node.writes],
|
|
17
|
+
value: node.value,
|
|
18
|
+
detail: node.detail,
|
|
19
|
+
runs: node.runs,
|
|
20
|
+
lastPulse: node.lastPulse,
|
|
21
|
+
order: node.order,
|
|
22
|
+
version: node.core?.version,
|
|
23
|
+
state,
|
|
24
|
+
loading: node.loading,
|
|
25
|
+
lazy: node.lazy,
|
|
26
|
+
props: node.props,
|
|
27
|
+
extra: node.extra,
|
|
28
|
+
source: node.source,
|
|
29
|
+
declaredAt: node.declaredAt,
|
|
30
|
+
usedAt: node.usedAt,
|
|
31
|
+
createdIn: node.createdIn,
|
|
32
|
+
scope: node.scope,
|
|
33
|
+
bindings: node.bindings,
|
|
34
|
+
targets: node.targets,
|
|
35
|
+
setAt: node.setAt,
|
|
36
|
+
// Falls back to what the node already carries, so a relay that re-serialises a
|
|
37
|
+
// snapshot it received does not drop the description.
|
|
38
|
+
dom: options.dom?.(node.id) ?? node.dom
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
const removed = options.removed ? [...options.removed] : void 0;
|
|
42
|
+
const events = options.events?.length ? [...options.events] : void 0;
|
|
43
|
+
const cursor = options.cursor;
|
|
44
|
+
return wanted ? { t: now, nodes, partial: true, removed, events, cursor } : { t: now, nodes, events, cursor };
|
|
45
|
+
}
|
|
46
|
+
function snapshotToRenderMap(snapshot) {
|
|
47
|
+
const map = /* @__PURE__ */ new Map();
|
|
48
|
+
for (const node of snapshot.nodes) {
|
|
49
|
+
map.set(node.id, {
|
|
50
|
+
id: node.id,
|
|
51
|
+
label: node.label,
|
|
52
|
+
kind: node.kind,
|
|
53
|
+
authored: node.authored,
|
|
54
|
+
deps: new Set(node.deps),
|
|
55
|
+
writes: new Set(node.writes),
|
|
56
|
+
value: node.value,
|
|
57
|
+
detail: node.detail,
|
|
58
|
+
runs: node.runs,
|
|
59
|
+
lastPulse: node.lastPulse,
|
|
60
|
+
order: node.order,
|
|
61
|
+
core: { version: node.version, state: node.state ? STATE_CODE[node.state] : void 0 },
|
|
62
|
+
loading: node.loading,
|
|
63
|
+
lazy: node.lazy,
|
|
64
|
+
props: node.props,
|
|
65
|
+
extra: node.extra,
|
|
66
|
+
source: node.source,
|
|
67
|
+
declaredAt: node.declaredAt,
|
|
68
|
+
usedAt: node.usedAt,
|
|
69
|
+
createdIn: node.createdIn,
|
|
70
|
+
scope: node.scope,
|
|
71
|
+
bindings: node.bindings,
|
|
72
|
+
targets: node.targets,
|
|
73
|
+
setAt: node.setAt,
|
|
74
|
+
dom: node.dom
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return map;
|
|
78
|
+
}
|
|
79
|
+
function applySnapshot(graph, snapshot) {
|
|
80
|
+
if (!snapshot.partial) return snapshotToRenderMap(snapshot);
|
|
81
|
+
for (const [id, node] of snapshotToRenderMap(snapshot)) graph.set(id, node);
|
|
82
|
+
for (const id of snapshot.removed ?? []) graph.delete(id);
|
|
83
|
+
return graph;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export {
|
|
87
|
+
serializeGraph,
|
|
88
|
+
snapshotToRenderMap,
|
|
89
|
+
applySnapshot
|
|
90
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
registerDevtoolsPlugin
|
|
3
|
+
} from "./chunk-V6DKWEYD.mjs";
|
|
4
|
+
import {
|
|
5
|
+
shorten
|
|
6
|
+
} from "./chunk-NT7YMK77.mjs";
|
|
7
|
+
|
|
8
|
+
// src/plugins/context.ts
|
|
9
|
+
var NAME = "context";
|
|
10
|
+
var contextPlugin = {
|
|
11
|
+
name: NAME,
|
|
12
|
+
collect(ctx) {
|
|
13
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
14
|
+
ctx.onContext((report) => {
|
|
15
|
+
if (report.owner === void 0) return;
|
|
16
|
+
let node = nodes.get(report.id);
|
|
17
|
+
if (node === void 0) {
|
|
18
|
+
const label = report.name === "context" && report.ownerLabel ? `${report.ownerLabel} context` : report.name;
|
|
19
|
+
node = ctx.add({
|
|
20
|
+
label,
|
|
21
|
+
kind: "context",
|
|
22
|
+
// A context is created at module scope with nothing running, so the only line it
|
|
23
|
+
// can carry is the one that provided or read it.
|
|
24
|
+
...report.at ? { source: report.at } : {},
|
|
25
|
+
// The router's own contexts are the framework's, and belong in its card rather
|
|
26
|
+
// than beside the ones the application wrote.
|
|
27
|
+
authored: report.at?.external !== true,
|
|
28
|
+
// Under whoever provided it. A context read with no provider above it belongs to
|
|
29
|
+
// the reader, which is the honest place for a default value.
|
|
30
|
+
createdIn: report.owner,
|
|
31
|
+
// Short on the card, whole in the inspector, the way every other node works.
|
|
32
|
+
...report.value !== void 0 ? { value: shorten(report.value), detail: report.value } : {}
|
|
33
|
+
});
|
|
34
|
+
nodes.set(report.id, node);
|
|
35
|
+
}
|
|
36
|
+
if (report.kind === "provide") ctx.retype(report.owner, "provider");
|
|
37
|
+
const held = ctx.annotation(report.owner) ?? [];
|
|
38
|
+
const already = held.some((n) => n.name === report.name && n.kind === report.kind);
|
|
39
|
+
if (already) return;
|
|
40
|
+
held.push({
|
|
41
|
+
name: report.name,
|
|
42
|
+
kind: report.kind,
|
|
43
|
+
...report.value !== void 0 ? { value: report.value } : {}
|
|
44
|
+
});
|
|
45
|
+
ctx.annotate(report.owner, held);
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
rows(node) {
|
|
49
|
+
const notes = node.extra?.[NAME];
|
|
50
|
+
if (!notes?.length) return [];
|
|
51
|
+
return notes.map((note) => ({
|
|
52
|
+
label: note.kind === "provide" ? `provides ${note.name}` : `reads ${note.name}`,
|
|
53
|
+
...note.value !== void 0 ? { value: note.value } : {}
|
|
54
|
+
}));
|
|
55
|
+
},
|
|
56
|
+
badge(node) {
|
|
57
|
+
const notes = node.extra?.[NAME];
|
|
58
|
+
if (!notes?.length) return void 0;
|
|
59
|
+
const given = notes.filter((n) => n.kind === "provide");
|
|
60
|
+
if (given.length === 1) return `provides ${given[0].name}`;
|
|
61
|
+
if (given.length > 1) return `provides ${given.length}`;
|
|
62
|
+
return notes.length === 1 ? `reads ${notes[0].name}` : `reads ${notes.length}`;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
registerDevtoolsPlugin(contextPlugin);
|
|
66
|
+
|
|
67
|
+
export {
|
|
68
|
+
NAME,
|
|
69
|
+
contextPlugin
|
|
70
|
+
};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// src/format.ts
|
|
2
|
+
var MAX_DEPTH = 3;
|
|
3
|
+
var MAX_ENTRIES = 8;
|
|
4
|
+
function domName(v) {
|
|
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
|
+
function shorten(text, limit = 18) {
|
|
107
|
+
return text.length > limit ? `${text.slice(0, limit - 1)}…` : text;
|
|
108
|
+
}
|
|
109
|
+
function indentValue(text, pad = " ") {
|
|
110
|
+
const out = [];
|
|
111
|
+
let depth = 0;
|
|
112
|
+
let quote = null;
|
|
113
|
+
let line = "";
|
|
114
|
+
const flush = () => {
|
|
115
|
+
if (line.trim()) out.push(pad.repeat(depth) + line.trim());
|
|
116
|
+
line = "";
|
|
117
|
+
};
|
|
118
|
+
for (let i = 0; i < text.length; i++) {
|
|
119
|
+
const c = text[i];
|
|
120
|
+
if (quote) {
|
|
121
|
+
line += c;
|
|
122
|
+
if (c === quote && text[i - 1] !== "\\") quote = null;
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (c === '"' || c === "'") {
|
|
126
|
+
quote = c;
|
|
127
|
+
line += c;
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
if (c === "{" || c === "[") {
|
|
131
|
+
line += c;
|
|
132
|
+
flush();
|
|
133
|
+
depth++;
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
if (c === "}" || c === "]") {
|
|
137
|
+
flush();
|
|
138
|
+
depth = Math.max(0, depth - 1);
|
|
139
|
+
line = c;
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
if (c === ",") {
|
|
143
|
+
line += c;
|
|
144
|
+
flush();
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
line += c;
|
|
148
|
+
}
|
|
149
|
+
flush();
|
|
150
|
+
return out.join("\n");
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export {
|
|
154
|
+
formatValue,
|
|
155
|
+
shorten,
|
|
156
|
+
indentValue
|
|
157
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// src/highlight.ts
|
|
2
|
+
var LAYER = "fx-highlight-layer";
|
|
3
|
+
var overlay = null;
|
|
4
|
+
function build(doc) {
|
|
5
|
+
const layer = doc.createElement("div");
|
|
6
|
+
layer.id = LAYER;
|
|
7
|
+
layer.style.cssText = "position:fixed;inset:0;z-index:2147483646;pointer-events:none;contain:strict;";
|
|
8
|
+
const label = doc.createElement("div");
|
|
9
|
+
label.style.cssText = "position:absolute;padding:1px 5px;border-radius:3px;background:#5eead4;color:#07131a;font:11px/1.5 ui-monospace,monospace;white-space:nowrap;";
|
|
10
|
+
layer.append(label);
|
|
11
|
+
doc.body.appendChild(layer);
|
|
12
|
+
return { layer, boxes: [], label };
|
|
13
|
+
}
|
|
14
|
+
function boxIn(overlay2, index) {
|
|
15
|
+
const held = overlay2.boxes[index];
|
|
16
|
+
if (held) return held;
|
|
17
|
+
const box = overlay2.layer.ownerDocument.createElement("div");
|
|
18
|
+
box.style.cssText = "position:absolute;border:1px solid #5eead4;background:rgba(94,234,212,.16);border-radius:2px;transition:none;";
|
|
19
|
+
overlay2.layer.append(box);
|
|
20
|
+
overlay2.boxes.push(box);
|
|
21
|
+
return box;
|
|
22
|
+
}
|
|
23
|
+
function showHighlight(target, text) {
|
|
24
|
+
const elements = (Array.isArray(target) ? target : [target]).filter(
|
|
25
|
+
(el) => el?.isConnected
|
|
26
|
+
);
|
|
27
|
+
const first = elements[0];
|
|
28
|
+
const doc = first?.ownerDocument;
|
|
29
|
+
if (!doc?.body) {
|
|
30
|
+
hideHighlight();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (!overlay || overlay.layer.ownerDocument !== doc || !overlay.layer.isConnected) {
|
|
34
|
+
overlay = build(doc);
|
|
35
|
+
}
|
|
36
|
+
const { label, layer } = overlay;
|
|
37
|
+
layer.style.display = "";
|
|
38
|
+
let top = Infinity;
|
|
39
|
+
let left = Infinity;
|
|
40
|
+
let bottom = 0;
|
|
41
|
+
elements.forEach((element, index) => {
|
|
42
|
+
const rect = element.getBoundingClientRect();
|
|
43
|
+
const box = boxIn(overlay, index);
|
|
44
|
+
box.style.display = "";
|
|
45
|
+
box.style.left = `${rect.left}px`;
|
|
46
|
+
box.style.top = `${rect.top}px`;
|
|
47
|
+
box.style.width = `${rect.width}px`;
|
|
48
|
+
box.style.height = `${rect.height}px`;
|
|
49
|
+
top = Math.min(top, rect.top);
|
|
50
|
+
left = Math.min(left, rect.left);
|
|
51
|
+
bottom = Math.max(bottom, rect.bottom);
|
|
52
|
+
});
|
|
53
|
+
for (let i = elements.length; i < overlay.boxes.length; i++) {
|
|
54
|
+
overlay.boxes[i].style.display = "none";
|
|
55
|
+
}
|
|
56
|
+
if (!text) {
|
|
57
|
+
label.style.display = "none";
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
label.style.display = "";
|
|
61
|
+
label.textContent = text;
|
|
62
|
+
label.style.left = `${Math.max(2, left)}px`;
|
|
63
|
+
label.style.top = top >= 20 ? `${top - 18}px` : `${bottom + 4}px`;
|
|
64
|
+
}
|
|
65
|
+
function hideHighlight() {
|
|
66
|
+
if (overlay) overlay.layer.style.display = "none";
|
|
67
|
+
}
|
|
68
|
+
function removeHighlight() {
|
|
69
|
+
overlay?.layer.remove();
|
|
70
|
+
overlay = null;
|
|
71
|
+
}
|
|
72
|
+
function startPicking(options) {
|
|
73
|
+
const doc = options.document ?? globalThis.document;
|
|
74
|
+
if (!doc?.body) return () => {
|
|
75
|
+
};
|
|
76
|
+
const was = doc.body.style.cursor;
|
|
77
|
+
doc.body.style.cursor = "crosshair";
|
|
78
|
+
const under = (event) => {
|
|
79
|
+
const target = event.target;
|
|
80
|
+
return target?.closest?.(`#${LAYER}`) ? null : target;
|
|
81
|
+
};
|
|
82
|
+
const move = (event) => {
|
|
83
|
+
const element = under(event);
|
|
84
|
+
const id = options.nodeAt(element);
|
|
85
|
+
if (element && id !== void 0) showHighlight(element, options.describe?.(id, element));
|
|
86
|
+
else hideHighlight();
|
|
87
|
+
};
|
|
88
|
+
const click = (event) => {
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
event.stopPropagation();
|
|
91
|
+
const target = under(event);
|
|
92
|
+
const id = options.nodeAt(target);
|
|
93
|
+
if (!options.sticky) stop();
|
|
94
|
+
if (id !== void 0) options.onPick(id, target);
|
|
95
|
+
else if (!options.sticky) options.onCancel?.();
|
|
96
|
+
};
|
|
97
|
+
const key = (event) => {
|
|
98
|
+
if (event.key !== "Escape") return;
|
|
99
|
+
stop();
|
|
100
|
+
options.onCancel?.();
|
|
101
|
+
};
|
|
102
|
+
const stop = () => {
|
|
103
|
+
doc.body.style.cursor = was;
|
|
104
|
+
doc.removeEventListener("pointermove", move, true);
|
|
105
|
+
doc.removeEventListener("click", click, true);
|
|
106
|
+
doc.removeEventListener("keydown", key, true);
|
|
107
|
+
hideHighlight();
|
|
108
|
+
};
|
|
109
|
+
doc.addEventListener("pointermove", move, true);
|
|
110
|
+
doc.addEventListener("click", click, true);
|
|
111
|
+
doc.addEventListener("keydown", key, true);
|
|
112
|
+
return stop;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export {
|
|
116
|
+
showHighlight,
|
|
117
|
+
hideHighlight,
|
|
118
|
+
removeHighlight,
|
|
119
|
+
startPicking
|
|
120
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// src/callsite.ts
|
|
2
|
+
var EXTENSION = ["chrome-extension://", "moz-extension://", "safari-web-extension://", "extension://"];
|
|
3
|
+
var INTERNAL = [
|
|
4
|
+
"/packages/reactive/",
|
|
5
|
+
"/packages/dom/",
|
|
6
|
+
"/packages/core/",
|
|
7
|
+
"/packages/devtools/",
|
|
8
|
+
"/packages/web-components/",
|
|
9
|
+
"/packages/auth/",
|
|
10
|
+
"/packages/oauth2/",
|
|
11
|
+
"/packages/session/",
|
|
12
|
+
"/packages/router/",
|
|
13
|
+
"/packages/head/",
|
|
14
|
+
"/packages/start/",
|
|
15
|
+
"/packages/server/",
|
|
16
|
+
"/packages/template-runtime/",
|
|
17
|
+
"/@fluixi/",
|
|
18
|
+
"node_modules",
|
|
19
|
+
"fluixi-devtools",
|
|
20
|
+
...EXTENSION
|
|
21
|
+
];
|
|
22
|
+
var REPORTING = [
|
|
23
|
+
"/packages/reactive/src/lib/signal/graph/",
|
|
24
|
+
"/packages/devtools/",
|
|
25
|
+
"fluixi-devtools",
|
|
26
|
+
// Not a fallback either: naming the agent as where a node came from is worse than nothing.
|
|
27
|
+
...EXTENSION
|
|
28
|
+
];
|
|
29
|
+
var FRAME = /(?:at\s+(?:[^(]*\()?)([^()\s]+):(\d+):(\d+)\)?$/;
|
|
30
|
+
var isInternal = (frame) => INTERNAL.some((part) => frame.includes(part));
|
|
31
|
+
function locate(frame, origin) {
|
|
32
|
+
const match = FRAME.exec(frame);
|
|
33
|
+
if (!match) return void 0;
|
|
34
|
+
let file = match[1];
|
|
35
|
+
if (origin && file.startsWith(origin)) file = file.slice(origin.length);
|
|
36
|
+
file = file.replace(/^\/@fs\//, "/").replace(/\?.*$/, "").replace(/^\//, "");
|
|
37
|
+
return file ? { file, line: Number(match[2]), column: Number(match[3]) } : void 0;
|
|
38
|
+
}
|
|
39
|
+
function callSite(stack, origin) {
|
|
40
|
+
if (!stack) return void 0;
|
|
41
|
+
let fallback;
|
|
42
|
+
for (const line of stack.split("\n")) {
|
|
43
|
+
const frame = line.trim();
|
|
44
|
+
if (!frame.startsWith("at ")) continue;
|
|
45
|
+
if (!isInternal(frame)) {
|
|
46
|
+
const location = locate(frame, origin);
|
|
47
|
+
if (location) return { location, external: false };
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (!fallback && !REPORTING.some((part) => frame.includes(part))) fallback = locate(frame, origin);
|
|
51
|
+
}
|
|
52
|
+
return fallback ? { location: { ...fallback, external: true }, external: true } : void 0;
|
|
53
|
+
}
|
|
54
|
+
function currentCallSite(origin) {
|
|
55
|
+
const errors = Error;
|
|
56
|
+
const limit = errors.stackTraceLimit;
|
|
57
|
+
errors.stackTraceLimit = 50;
|
|
58
|
+
try {
|
|
59
|
+
return callSite(new Error().stack, origin);
|
|
60
|
+
} finally {
|
|
61
|
+
errors.stackTraceLimit = limit;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export {
|
|
66
|
+
callSite,
|
|
67
|
+
currentCallSite
|
|
68
|
+
};
|