@fluixi/devtools 0.2.0-alpha.3 → 0.2.0-alpha.4
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.cjs +72 -0
- package/dist/callsite.mjs +51 -0
- package/dist/change-view.cjs +134 -0
- package/dist/change-view.mjs +111 -0
- package/dist/copy.cjs +63 -0
- package/dist/copy.mjs +42 -0
- package/dist/describe.cjs +55 -0
- package/dist/describe.mjs +34 -0
- package/dist/detail-panel.cjs +307 -0
- package/dist/detail-panel.mjs +284 -0
- package/dist/diff.cjs +225 -0
- package/dist/diff.mjs +202 -0
- package/dist/dom.cjs +204 -0
- package/dist/dom.mjs +183 -0
- package/dist/export.cjs +221 -0
- package/dist/export.mjs +209 -0
- package/dist/float.cjs +232 -0
- package/dist/float.mjs +211 -0
- package/dist/format.cjs +175 -0
- package/dist/format.mjs +154 -0
- package/dist/graph-view.cjs +893 -0
- package/dist/graph-view.mjs +870 -0
- package/dist/highlight.cjs +140 -0
- package/dist/highlight.mjs +119 -0
- package/dist/history.cjs +95 -0
- package/dist/history.mjs +74 -0
- package/dist/hook.cjs +1562 -0
- package/dist/hook.mjs +1553 -0
- package/dist/index.cjs +4552 -0
- package/dist/index.mjs +4544 -0
- package/dist/inspector.cjs +688 -0
- package/dist/inspector.mjs +676 -0
- package/dist/instrument.cjs +497 -0
- package/dist/instrument.mjs +487 -0
- package/dist/kind-filter.cjs +172 -0
- package/dist/kind-filter.mjs +151 -0
- package/dist/menu.cjs +141 -0
- package/dist/menu.mjs +120 -0
- package/dist/observe.cjs +1352 -0
- package/dist/observe.mjs +1345 -0
- package/dist/palette.cjs +52 -0
- package/dist/palette.mjs +31 -0
- package/dist/path.cjs +45 -0
- package/dist/path.mjs +24 -0
- package/dist/plugin.cjs +87 -0
- package/dist/plugin.mjs +66 -0
- package/dist/plugins/context.cjs +98 -0
- package/dist/plugins/context.mjs +75 -0
- package/dist/plugins/directives.cjs +98 -0
- package/dist/plugins/directives.mjs +75 -0
- package/dist/plugins/index.cjs +162 -0
- package/dist/plugins/index.mjs +140 -0
- package/dist/source.cjs +111 -0
- package/dist/source.mjs +90 -0
- package/dist/timeline.cjs +350 -0
- package/dist/timeline.mjs +327 -0
- package/dist/tree.cjs +574 -0
- package/dist/tree.mjs +551 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/value-pane.cjs +223 -0
- package/dist/value-pane.mjs +200 -0
- package/dist/wire.cjs +109 -0
- package/dist/wire.mjs +89 -0
- package/package.json +13 -6
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/*! @fluixi/devtools v0.2.0-alpha.4 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/plugins/index.ts
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
|
+
CONTEXT: () => NAME2,
|
|
25
|
+
DIRECTIVES: () => NAME,
|
|
26
|
+
contextPlugin: () => contextPlugin,
|
|
27
|
+
directivesPlugin: () => directivesPlugin
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(index_exports);
|
|
30
|
+
|
|
31
|
+
// src/plugin.ts
|
|
32
|
+
var plugins = [];
|
|
33
|
+
function registerDevtoolsPlugin(plugin) {
|
|
34
|
+
const at = plugins.findIndex((p) => p.name === plugin.name);
|
|
35
|
+
if (at === -1) plugins.push(plugin);
|
|
36
|
+
else plugins[at] = plugin;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/plugins/directives.ts
|
|
40
|
+
var NAME = "directives";
|
|
41
|
+
function directivesOn(extra) {
|
|
42
|
+
return extra?.[NAME] ?? [];
|
|
43
|
+
}
|
|
44
|
+
function directiveBadge(notes) {
|
|
45
|
+
if (!notes.length) return void 0;
|
|
46
|
+
const first = notes[0];
|
|
47
|
+
const short = first.kind === "ref" ? "ref" : label(first);
|
|
48
|
+
return notes.length > 1 ? `${short} +${notes.length - 1}` : short;
|
|
49
|
+
}
|
|
50
|
+
function directiveRows(notes) {
|
|
51
|
+
return notes.map((note) => ({
|
|
52
|
+
label: label(note),
|
|
53
|
+
value: note.element,
|
|
54
|
+
...note.at ? { at: note.at } : {}
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
var label = (note) => note.kind === "ref" ? `ref ${note.name}` : `${note.kind}:${note.name}`;
|
|
58
|
+
var directivesPlugin = {
|
|
59
|
+
name: NAME,
|
|
60
|
+
collect(ctx) {
|
|
61
|
+
ctx.onDirective((report) => {
|
|
62
|
+
if (!report.target) return;
|
|
63
|
+
const held = ctx.elementAnnotation(report.target) ?? [];
|
|
64
|
+
const already = held.some((n) => n.kind === report.kind && n.name === report.name);
|
|
65
|
+
if (already) return;
|
|
66
|
+
held.push({
|
|
67
|
+
kind: report.kind,
|
|
68
|
+
name: report.name,
|
|
69
|
+
element: report.element,
|
|
70
|
+
...report.at ? { at: report.at } : {}
|
|
71
|
+
});
|
|
72
|
+
ctx.annotateElement(report.target, held);
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
rows(node) {
|
|
76
|
+
const notes = node.extra?.[NAME];
|
|
77
|
+
if (!notes?.length) return [];
|
|
78
|
+
return notes.map((note) => ({
|
|
79
|
+
label: label(note),
|
|
80
|
+
value: note.element,
|
|
81
|
+
...note.at ? { at: note.at } : {}
|
|
82
|
+
}));
|
|
83
|
+
},
|
|
84
|
+
elementRows(extra) {
|
|
85
|
+
return directiveRows(directivesOn(extra));
|
|
86
|
+
},
|
|
87
|
+
elementBadge(extra) {
|
|
88
|
+
return directiveBadge(directivesOn(extra));
|
|
89
|
+
},
|
|
90
|
+
badge(node) {
|
|
91
|
+
const notes = node.extra?.[NAME];
|
|
92
|
+
if (!notes?.length) return void 0;
|
|
93
|
+
const first = notes[0];
|
|
94
|
+
const short = first.kind === "ref" ? "ref" : label(first);
|
|
95
|
+
return notes.length > 1 ? `${short} +${notes.length - 1}` : short;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
registerDevtoolsPlugin(directivesPlugin);
|
|
99
|
+
|
|
100
|
+
// src/format.ts
|
|
101
|
+
function shorten(text, limit = 18) {
|
|
102
|
+
return text.length > limit ? `${text.slice(0, limit - 1)}…` : text;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// src/plugins/context.ts
|
|
106
|
+
var NAME2 = "context";
|
|
107
|
+
var contextPlugin = {
|
|
108
|
+
name: NAME2,
|
|
109
|
+
collect(ctx) {
|
|
110
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
111
|
+
ctx.onContext((report) => {
|
|
112
|
+
if (report.owner === void 0) return;
|
|
113
|
+
let node = nodes.get(report.id);
|
|
114
|
+
if (node === void 0) {
|
|
115
|
+
const label2 = report.name === "context" && report.ownerLabel ? `${report.ownerLabel} context` : report.name;
|
|
116
|
+
node = ctx.add({
|
|
117
|
+
label: label2,
|
|
118
|
+
kind: "context",
|
|
119
|
+
// A context is created at module scope with nothing running, so the only line it
|
|
120
|
+
// can carry is the one that provided or read it.
|
|
121
|
+
...report.at ? { source: report.at } : {},
|
|
122
|
+
// The router's own contexts are the framework's, and belong in its card rather
|
|
123
|
+
// than beside the ones the application wrote.
|
|
124
|
+
authored: report.at?.external !== true,
|
|
125
|
+
// Under whoever provided it. A context read with no provider above it belongs to
|
|
126
|
+
// the reader, which is the honest place for a default value.
|
|
127
|
+
createdIn: report.owner,
|
|
128
|
+
// Short on the card, whole in the inspector, the way every other node works.
|
|
129
|
+
...report.value !== void 0 ? { value: shorten(report.value), detail: report.value } : {}
|
|
130
|
+
});
|
|
131
|
+
nodes.set(report.id, node);
|
|
132
|
+
}
|
|
133
|
+
if (report.kind === "provide") ctx.retype(report.owner, "provider");
|
|
134
|
+
const held = ctx.annotation(report.owner) ?? [];
|
|
135
|
+
const already = held.some((n) => n.name === report.name && n.kind === report.kind);
|
|
136
|
+
if (already) return;
|
|
137
|
+
held.push({
|
|
138
|
+
name: report.name,
|
|
139
|
+
kind: report.kind,
|
|
140
|
+
...report.value !== void 0 ? { value: report.value } : {}
|
|
141
|
+
});
|
|
142
|
+
ctx.annotate(report.owner, held);
|
|
143
|
+
});
|
|
144
|
+
},
|
|
145
|
+
rows(node) {
|
|
146
|
+
const notes = node.extra?.[NAME2];
|
|
147
|
+
if (!notes?.length) return [];
|
|
148
|
+
return notes.map((note) => ({
|
|
149
|
+
label: note.kind === "provide" ? `provides ${note.name}` : `reads ${note.name}`,
|
|
150
|
+
...note.value !== void 0 ? { value: note.value } : {}
|
|
151
|
+
}));
|
|
152
|
+
},
|
|
153
|
+
badge(node) {
|
|
154
|
+
const notes = node.extra?.[NAME2];
|
|
155
|
+
if (!notes?.length) return void 0;
|
|
156
|
+
const given = notes.filter((n) => n.kind === "provide");
|
|
157
|
+
if (given.length === 1) return `provides ${given[0].name}`;
|
|
158
|
+
if (given.length > 1) return `provides ${given.length}`;
|
|
159
|
+
return notes.length === 1 ? `reads ${notes[0].name}` : `reads ${notes.length}`;
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
registerDevtoolsPlugin(contextPlugin);
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/*! @fluixi/devtools v0.2.0-alpha.4 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
|
+
|
|
3
|
+
// src/plugin.ts
|
|
4
|
+
var plugins = [];
|
|
5
|
+
function registerDevtoolsPlugin(plugin) {
|
|
6
|
+
const at = plugins.findIndex((p) => p.name === plugin.name);
|
|
7
|
+
if (at === -1) plugins.push(plugin);
|
|
8
|
+
else plugins[at] = plugin;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// src/plugins/directives.ts
|
|
12
|
+
var NAME = "directives";
|
|
13
|
+
function directivesOn(extra) {
|
|
14
|
+
return extra?.[NAME] ?? [];
|
|
15
|
+
}
|
|
16
|
+
function directiveBadge(notes) {
|
|
17
|
+
if (!notes.length) return void 0;
|
|
18
|
+
const first = notes[0];
|
|
19
|
+
const short = first.kind === "ref" ? "ref" : label(first);
|
|
20
|
+
return notes.length > 1 ? `${short} +${notes.length - 1}` : short;
|
|
21
|
+
}
|
|
22
|
+
function directiveRows(notes) {
|
|
23
|
+
return notes.map((note) => ({
|
|
24
|
+
label: label(note),
|
|
25
|
+
value: note.element,
|
|
26
|
+
...note.at ? { at: note.at } : {}
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
var label = (note) => note.kind === "ref" ? `ref ${note.name}` : `${note.kind}:${note.name}`;
|
|
30
|
+
var directivesPlugin = {
|
|
31
|
+
name: NAME,
|
|
32
|
+
collect(ctx) {
|
|
33
|
+
ctx.onDirective((report) => {
|
|
34
|
+
if (!report.target) return;
|
|
35
|
+
const held = ctx.elementAnnotation(report.target) ?? [];
|
|
36
|
+
const already = held.some((n) => n.kind === report.kind && n.name === report.name);
|
|
37
|
+
if (already) return;
|
|
38
|
+
held.push({
|
|
39
|
+
kind: report.kind,
|
|
40
|
+
name: report.name,
|
|
41
|
+
element: report.element,
|
|
42
|
+
...report.at ? { at: report.at } : {}
|
|
43
|
+
});
|
|
44
|
+
ctx.annotateElement(report.target, held);
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
rows(node) {
|
|
48
|
+
const notes = node.extra?.[NAME];
|
|
49
|
+
if (!notes?.length) return [];
|
|
50
|
+
return notes.map((note) => ({
|
|
51
|
+
label: label(note),
|
|
52
|
+
value: note.element,
|
|
53
|
+
...note.at ? { at: note.at } : {}
|
|
54
|
+
}));
|
|
55
|
+
},
|
|
56
|
+
elementRows(extra) {
|
|
57
|
+
return directiveRows(directivesOn(extra));
|
|
58
|
+
},
|
|
59
|
+
elementBadge(extra) {
|
|
60
|
+
return directiveBadge(directivesOn(extra));
|
|
61
|
+
},
|
|
62
|
+
badge(node) {
|
|
63
|
+
const notes = node.extra?.[NAME];
|
|
64
|
+
if (!notes?.length) return void 0;
|
|
65
|
+
const first = notes[0];
|
|
66
|
+
const short = first.kind === "ref" ? "ref" : label(first);
|
|
67
|
+
return notes.length > 1 ? `${short} +${notes.length - 1}` : short;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
registerDevtoolsPlugin(directivesPlugin);
|
|
71
|
+
|
|
72
|
+
// src/format.ts
|
|
73
|
+
function shorten(text, limit = 18) {
|
|
74
|
+
return text.length > limit ? `${text.slice(0, limit - 1)}…` : text;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// src/plugins/context.ts
|
|
78
|
+
var NAME2 = "context";
|
|
79
|
+
var contextPlugin = {
|
|
80
|
+
name: NAME2,
|
|
81
|
+
collect(ctx) {
|
|
82
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
83
|
+
ctx.onContext((report) => {
|
|
84
|
+
if (report.owner === void 0) return;
|
|
85
|
+
let node = nodes.get(report.id);
|
|
86
|
+
if (node === void 0) {
|
|
87
|
+
const label2 = report.name === "context" && report.ownerLabel ? `${report.ownerLabel} context` : report.name;
|
|
88
|
+
node = ctx.add({
|
|
89
|
+
label: label2,
|
|
90
|
+
kind: "context",
|
|
91
|
+
// A context is created at module scope with nothing running, so the only line it
|
|
92
|
+
// can carry is the one that provided or read it.
|
|
93
|
+
...report.at ? { source: report.at } : {},
|
|
94
|
+
// The router's own contexts are the framework's, and belong in its card rather
|
|
95
|
+
// than beside the ones the application wrote.
|
|
96
|
+
authored: report.at?.external !== true,
|
|
97
|
+
// Under whoever provided it. A context read with no provider above it belongs to
|
|
98
|
+
// the reader, which is the honest place for a default value.
|
|
99
|
+
createdIn: report.owner,
|
|
100
|
+
// Short on the card, whole in the inspector, the way every other node works.
|
|
101
|
+
...report.value !== void 0 ? { value: shorten(report.value), detail: report.value } : {}
|
|
102
|
+
});
|
|
103
|
+
nodes.set(report.id, node);
|
|
104
|
+
}
|
|
105
|
+
if (report.kind === "provide") ctx.retype(report.owner, "provider");
|
|
106
|
+
const held = ctx.annotation(report.owner) ?? [];
|
|
107
|
+
const already = held.some((n) => n.name === report.name && n.kind === report.kind);
|
|
108
|
+
if (already) return;
|
|
109
|
+
held.push({
|
|
110
|
+
name: report.name,
|
|
111
|
+
kind: report.kind,
|
|
112
|
+
...report.value !== void 0 ? { value: report.value } : {}
|
|
113
|
+
});
|
|
114
|
+
ctx.annotate(report.owner, held);
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
rows(node) {
|
|
118
|
+
const notes = node.extra?.[NAME2];
|
|
119
|
+
if (!notes?.length) return [];
|
|
120
|
+
return notes.map((note) => ({
|
|
121
|
+
label: note.kind === "provide" ? `provides ${note.name}` : `reads ${note.name}`,
|
|
122
|
+
...note.value !== void 0 ? { value: note.value } : {}
|
|
123
|
+
}));
|
|
124
|
+
},
|
|
125
|
+
badge(node) {
|
|
126
|
+
const notes = node.extra?.[NAME2];
|
|
127
|
+
if (!notes?.length) return void 0;
|
|
128
|
+
const given = notes.filter((n) => n.kind === "provide");
|
|
129
|
+
if (given.length === 1) return `provides ${given[0].name}`;
|
|
130
|
+
if (given.length > 1) return `provides ${given.length}`;
|
|
131
|
+
return notes.length === 1 ? `reads ${notes[0].name}` : `reads ${notes.length}`;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
registerDevtoolsPlugin(contextPlugin);
|
|
135
|
+
export {
|
|
136
|
+
NAME2 as CONTEXT,
|
|
137
|
+
NAME as DIRECTIVES,
|
|
138
|
+
contextPlugin,
|
|
139
|
+
directivesPlugin
|
|
140
|
+
};
|
package/dist/source.cjs
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/source.ts
|
|
21
|
+
var source_exports = {};
|
|
22
|
+
__export(source_exports, {
|
|
23
|
+
componentSource: () => componentSource,
|
|
24
|
+
holeLocation: () => holeLocation,
|
|
25
|
+
installSourceMarker: () => installSourceMarker,
|
|
26
|
+
markComponentSource: () => markComponentSource,
|
|
27
|
+
markReactiveSource: () => markReactiveSource,
|
|
28
|
+
propsLocations: () => propsLocations,
|
|
29
|
+
takeReactiveSource: () => takeReactiveSource
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(source_exports);
|
|
32
|
+
var MARKER = "__fx_source";
|
|
33
|
+
var COMPONENT_MARKER = "__fx_component";
|
|
34
|
+
var HOLE_MARKER = "__fx_hole";
|
|
35
|
+
var PROPS_MARKER = "__fx_props";
|
|
36
|
+
var MARKS = "__FLUIXI_DEVTOOLS_MARKS__";
|
|
37
|
+
var host = globalThis;
|
|
38
|
+
var shared = host[MARKS] ?? {
|
|
39
|
+
pending: null,
|
|
40
|
+
expiring: false,
|
|
41
|
+
components: /* @__PURE__ */ new Map()
|
|
42
|
+
};
|
|
43
|
+
host[MARKS] = shared;
|
|
44
|
+
function markReactiveSource(file, line, column, name) {
|
|
45
|
+
const location = locate(file, line, column);
|
|
46
|
+
if (shared.pending && location.external && !shared.pending.location?.external) return;
|
|
47
|
+
shared.pending = { name, location };
|
|
48
|
+
shared.expiring = false;
|
|
49
|
+
}
|
|
50
|
+
function locate(file, line, column) {
|
|
51
|
+
const external = !!file && (/^([a-zA-Z]:)?[\\/]/.test(file) || file.includes("node_modules/"));
|
|
52
|
+
return external ? { file, line, column, external } : { file, line, column };
|
|
53
|
+
}
|
|
54
|
+
function markComponentSource(name, file, line, column) {
|
|
55
|
+
const seen = shared.components.get(name);
|
|
56
|
+
const next = locate(file, line, column);
|
|
57
|
+
if (seen === void 0) {
|
|
58
|
+
shared.components.set(name, next);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (!seen || seen.file !== file || seen.line !== line) shared.components.set(name, null);
|
|
62
|
+
}
|
|
63
|
+
function componentSource(name) {
|
|
64
|
+
return shared.components.get(name) ?? void 0;
|
|
65
|
+
}
|
|
66
|
+
function takeReactiveSource() {
|
|
67
|
+
const mark = shared.pending;
|
|
68
|
+
if (mark) {
|
|
69
|
+
if (mark.name !== void 0) shared.pending = { location: mark.location };
|
|
70
|
+
if (!shared.expiring) {
|
|
71
|
+
shared.expiring = true;
|
|
72
|
+
queueMicrotask(() => {
|
|
73
|
+
shared.expiring = false;
|
|
74
|
+
shared.pending = null;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return mark;
|
|
79
|
+
}
|
|
80
|
+
var HOLES = /* @__PURE__ */ new WeakMap();
|
|
81
|
+
var HOLE_TAG = "__fx_at";
|
|
82
|
+
function markHole(accessor, line, column, name) {
|
|
83
|
+
if (accessor && (typeof accessor === "object" || typeof accessor === "function")) {
|
|
84
|
+
const at = name === void 0 ? { line, column } : { line, column, name };
|
|
85
|
+
HOLES.set(accessor, at);
|
|
86
|
+
try {
|
|
87
|
+
Object.defineProperty(accessor, HOLE_TAG, { value: at, configurable: true });
|
|
88
|
+
} catch {
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
shared.pending = null;
|
|
92
|
+
return accessor;
|
|
93
|
+
}
|
|
94
|
+
var PROPS = /* @__PURE__ */ new WeakMap();
|
|
95
|
+
function markProps(props, at) {
|
|
96
|
+
if (props && typeof props === "object") PROPS.set(props, at);
|
|
97
|
+
return props;
|
|
98
|
+
}
|
|
99
|
+
function propsLocations(props) {
|
|
100
|
+
return props && typeof props === "object" ? PROPS.get(props) : void 0;
|
|
101
|
+
}
|
|
102
|
+
function holeLocation(accessor) {
|
|
103
|
+
if (!accessor || typeof accessor !== "object" && typeof accessor !== "function") return void 0;
|
|
104
|
+
return HOLES.get(accessor) ?? accessor[HOLE_TAG];
|
|
105
|
+
}
|
|
106
|
+
function installSourceMarker() {
|
|
107
|
+
if (typeof host[MARKER] !== "function") host[MARKER] = markReactiveSource;
|
|
108
|
+
if (typeof host[COMPONENT_MARKER] !== "function") host[COMPONENT_MARKER] = markComponentSource;
|
|
109
|
+
if (typeof host[HOLE_MARKER] !== "function") host[HOLE_MARKER] = markHole;
|
|
110
|
+
if (typeof host[PROPS_MARKER] !== "function") host[PROPS_MARKER] = markProps;
|
|
111
|
+
}
|
package/dist/source.mjs
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// src/source.ts
|
|
2
|
+
var MARKER = "__fx_source";
|
|
3
|
+
var COMPONENT_MARKER = "__fx_component";
|
|
4
|
+
var HOLE_MARKER = "__fx_hole";
|
|
5
|
+
var PROPS_MARKER = "__fx_props";
|
|
6
|
+
var MARKS = "__FLUIXI_DEVTOOLS_MARKS__";
|
|
7
|
+
var host = globalThis;
|
|
8
|
+
var shared = host[MARKS] ?? {
|
|
9
|
+
pending: null,
|
|
10
|
+
expiring: false,
|
|
11
|
+
components: /* @__PURE__ */ new Map()
|
|
12
|
+
};
|
|
13
|
+
host[MARKS] = shared;
|
|
14
|
+
function markReactiveSource(file, line, column, name) {
|
|
15
|
+
const location = locate(file, line, column);
|
|
16
|
+
if (shared.pending && location.external && !shared.pending.location?.external) return;
|
|
17
|
+
shared.pending = { name, location };
|
|
18
|
+
shared.expiring = false;
|
|
19
|
+
}
|
|
20
|
+
function locate(file, line, column) {
|
|
21
|
+
const external = !!file && (/^([a-zA-Z]:)?[\\/]/.test(file) || file.includes("node_modules/"));
|
|
22
|
+
return external ? { file, line, column, external } : { file, line, column };
|
|
23
|
+
}
|
|
24
|
+
function markComponentSource(name, file, line, column) {
|
|
25
|
+
const seen = shared.components.get(name);
|
|
26
|
+
const next = locate(file, line, column);
|
|
27
|
+
if (seen === void 0) {
|
|
28
|
+
shared.components.set(name, next);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (!seen || seen.file !== file || seen.line !== line) shared.components.set(name, null);
|
|
32
|
+
}
|
|
33
|
+
function componentSource(name) {
|
|
34
|
+
return shared.components.get(name) ?? void 0;
|
|
35
|
+
}
|
|
36
|
+
function takeReactiveSource() {
|
|
37
|
+
const mark = shared.pending;
|
|
38
|
+
if (mark) {
|
|
39
|
+
if (mark.name !== void 0) shared.pending = { location: mark.location };
|
|
40
|
+
if (!shared.expiring) {
|
|
41
|
+
shared.expiring = true;
|
|
42
|
+
queueMicrotask(() => {
|
|
43
|
+
shared.expiring = false;
|
|
44
|
+
shared.pending = null;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return mark;
|
|
49
|
+
}
|
|
50
|
+
var HOLES = /* @__PURE__ */ new WeakMap();
|
|
51
|
+
var HOLE_TAG = "__fx_at";
|
|
52
|
+
function markHole(accessor, line, column, name) {
|
|
53
|
+
if (accessor && (typeof accessor === "object" || typeof accessor === "function")) {
|
|
54
|
+
const at = name === void 0 ? { line, column } : { line, column, name };
|
|
55
|
+
HOLES.set(accessor, at);
|
|
56
|
+
try {
|
|
57
|
+
Object.defineProperty(accessor, HOLE_TAG, { value: at, configurable: true });
|
|
58
|
+
} catch {
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
shared.pending = null;
|
|
62
|
+
return accessor;
|
|
63
|
+
}
|
|
64
|
+
var PROPS = /* @__PURE__ */ new WeakMap();
|
|
65
|
+
function markProps(props, at) {
|
|
66
|
+
if (props && typeof props === "object") PROPS.set(props, at);
|
|
67
|
+
return props;
|
|
68
|
+
}
|
|
69
|
+
function propsLocations(props) {
|
|
70
|
+
return props && typeof props === "object" ? PROPS.get(props) : void 0;
|
|
71
|
+
}
|
|
72
|
+
function holeLocation(accessor) {
|
|
73
|
+
if (!accessor || typeof accessor !== "object" && typeof accessor !== "function") return void 0;
|
|
74
|
+
return HOLES.get(accessor) ?? accessor[HOLE_TAG];
|
|
75
|
+
}
|
|
76
|
+
function installSourceMarker() {
|
|
77
|
+
if (typeof host[MARKER] !== "function") host[MARKER] = markReactiveSource;
|
|
78
|
+
if (typeof host[COMPONENT_MARKER] !== "function") host[COMPONENT_MARKER] = markComponentSource;
|
|
79
|
+
if (typeof host[HOLE_MARKER] !== "function") host[HOLE_MARKER] = markHole;
|
|
80
|
+
if (typeof host[PROPS_MARKER] !== "function") host[PROPS_MARKER] = markProps;
|
|
81
|
+
}
|
|
82
|
+
export {
|
|
83
|
+
componentSource,
|
|
84
|
+
holeLocation,
|
|
85
|
+
installSourceMarker,
|
|
86
|
+
markComponentSource,
|
|
87
|
+
markReactiveSource,
|
|
88
|
+
propsLocations,
|
|
89
|
+
takeReactiveSource
|
|
90
|
+
};
|