@fluixi/devtools 0.2.0-alpha.5 → 0.2.0-alpha.7
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 +9 -0
- package/dist/callsite.d.ts.map +1 -1
- package/dist/callsite.js +9 -0
- package/dist/callsite.mjs +9 -0
- package/dist/export.cjs +1 -0
- package/dist/export.mjs +1 -0
- package/dist/graph-view.cjs +12 -3
- package/dist/graph-view.d.ts.map +1 -1
- package/dist/graph-view.js +11 -2
- package/dist/graph-view.mjs +12 -3
- package/dist/hook.cjs +173 -21
- package/dist/hook.mjs +174 -21
- package/dist/index.cjs +199 -29
- package/dist/index.mjs +200 -29
- package/dist/inspector.cjs +6 -2
- package/dist/inspector.js +1 -1
- package/dist/inspector.mjs +6 -2
- package/dist/instrument.cjs +9 -3
- package/dist/instrument.d.ts +16 -1
- package/dist/instrument.d.ts.map +1 -1
- package/dist/instrument.mjs +9 -3
- package/dist/kind-filter.cjs +5 -2
- package/dist/kind-filter.js +3 -3
- package/dist/kind-filter.mjs +5 -2
- package/dist/observe.cjs +172 -21
- package/dist/observe.d.ts.map +1 -1
- package/dist/observe.js +191 -22
- package/dist/observe.mjs +173 -21
- package/dist/palette.cjs +4 -1
- package/dist/palette.d.ts.map +1 -1
- package/dist/palette.js +3 -0
- package/dist/palette.mjs +4 -1
- package/dist/plugins/index.cjs +1 -1
- package/dist/plugins/index.mjs +1 -1
- package/dist/source.cjs +18 -3
- package/dist/source.d.ts +16 -1
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +25 -3
- package/dist/source.mjs +18 -3
- package/dist/tree.cjs +19 -4
- package/dist/tree.d.ts.map +1 -1
- package/dist/tree.js +21 -2
- package/dist/tree.mjs +19 -4
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/wire.cjs +3 -1
- package/dist/wire.d.ts +2 -0
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +2 -0
- package/dist/wire.mjs +3 -1
- package/package.json +2 -2
package/dist/observe.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/observe.ts
|
|
2
2
|
import {
|
|
3
|
+
createRoot as createRoot2,
|
|
3
4
|
observeReactiveNodes,
|
|
4
5
|
untrack as untrack2
|
|
5
6
|
} from "@fluixi/reactive/signal";
|
|
@@ -7,6 +8,7 @@ import {
|
|
|
7
8
|
// src/source.ts
|
|
8
9
|
var MARKER = "__fx_source";
|
|
9
10
|
var COMPONENT_MARKER = "__fx_component";
|
|
11
|
+
var CLASS_MARKER = "__fx_class";
|
|
10
12
|
var HOLE_MARKER = "__fx_hole";
|
|
11
13
|
var PROPS_MARKER = "__fx_props";
|
|
12
14
|
var MARKS = "__FLUIXI_DEVTOOLS_MARKS__";
|
|
@@ -17,12 +19,16 @@ var shared = host[MARKS] ?? {
|
|
|
17
19
|
components: /* @__PURE__ */ new Map()
|
|
18
20
|
};
|
|
19
21
|
host[MARKS] = shared;
|
|
20
|
-
|
|
22
|
+
shared.classes ??= /* @__PURE__ */ new WeakMap();
|
|
23
|
+
function markReactiveSource(file, line, column, name, self) {
|
|
21
24
|
const location2 = locate(file, line, column);
|
|
22
25
|
if (shared.pending && location2.external && !shared.pending.location?.external) return;
|
|
23
|
-
shared.pending = { name, location: location2 };
|
|
26
|
+
shared.pending = self && typeof self === "object" ? { name, location: location2, self } : { name, location: location2 };
|
|
24
27
|
shared.expiring = false;
|
|
25
28
|
}
|
|
29
|
+
function dropReactiveSource() {
|
|
30
|
+
shared.pending = null;
|
|
31
|
+
}
|
|
26
32
|
function locate(file, line, column) {
|
|
27
33
|
const external = !!file && (/^([a-zA-Z]:)?[\\/]/.test(file) || file.includes("node_modules/"));
|
|
28
34
|
return external ? { file, line, column, external } : { file, line, column };
|
|
@@ -36,13 +42,19 @@ function markComponentSource(name, file, line, column) {
|
|
|
36
42
|
}
|
|
37
43
|
if (!seen || seen.file !== file || seen.line !== line) shared.components.set(name, null);
|
|
38
44
|
}
|
|
45
|
+
function markClassSource(constructor, file, line, column) {
|
|
46
|
+
if (typeof constructor === "function") shared.classes.set(constructor, locate(file, line, column));
|
|
47
|
+
}
|
|
48
|
+
function classSource(constructor) {
|
|
49
|
+
return typeof constructor === "function" ? shared.classes.get(constructor) : void 0;
|
|
50
|
+
}
|
|
39
51
|
function componentSource(name) {
|
|
40
52
|
return shared.components.get(name) ?? void 0;
|
|
41
53
|
}
|
|
42
54
|
function takeReactiveSource() {
|
|
43
55
|
const mark = shared.pending;
|
|
44
56
|
if (mark) {
|
|
45
|
-
if (mark.name !== void 0) shared.pending = { location: mark.location };
|
|
57
|
+
if (mark.name !== void 0 || mark.self) shared.pending = { location: mark.location };
|
|
46
58
|
if (!shared.expiring) {
|
|
47
59
|
shared.expiring = true;
|
|
48
60
|
queueMicrotask(() => {
|
|
@@ -82,6 +94,7 @@ function holeLocation(accessor) {
|
|
|
82
94
|
function installSourceMarker() {
|
|
83
95
|
if (typeof host[MARKER] !== "function") host[MARKER] = markReactiveSource;
|
|
84
96
|
if (typeof host[COMPONENT_MARKER] !== "function") host[COMPONENT_MARKER] = markComponentSource;
|
|
97
|
+
if (typeof host[CLASS_MARKER] !== "function") host[CLASS_MARKER] = markClassSource;
|
|
85
98
|
if (typeof host[HOLE_MARKER] !== "function") host[HOLE_MARKER] = markHole;
|
|
86
99
|
if (typeof host[PROPS_MARKER] !== "function") host[PROPS_MARKER] = markProps;
|
|
87
100
|
}
|
|
@@ -93,6 +106,15 @@ var INTERNAL = [
|
|
|
93
106
|
"/packages/dom/",
|
|
94
107
|
"/packages/core/",
|
|
95
108
|
"/packages/devtools/",
|
|
109
|
+
"/packages/web-components/",
|
|
110
|
+
"/packages/auth/",
|
|
111
|
+
"/packages/oauth2/",
|
|
112
|
+
"/packages/session/",
|
|
113
|
+
"/packages/router/",
|
|
114
|
+
"/packages/head/",
|
|
115
|
+
"/packages/start/",
|
|
116
|
+
"/packages/server/",
|
|
117
|
+
"/packages/template-runtime/",
|
|
96
118
|
"/@fluixi/",
|
|
97
119
|
"node_modules",
|
|
98
120
|
"fluixi-devtools",
|
|
@@ -654,7 +676,10 @@ var KIND_COLOR = {
|
|
|
654
676
|
binding: "#5eead4",
|
|
655
677
|
setter: "#fb7185",
|
|
656
678
|
group: "#8a90a2",
|
|
657
|
-
element: "#8a90a2"
|
|
679
|
+
element: "#8a90a2",
|
|
680
|
+
"custom-element": "#2dd4bf",
|
|
681
|
+
module: "#facc15",
|
|
682
|
+
service: "#60a5fa"
|
|
658
683
|
};
|
|
659
684
|
var kindVar = (kind) => `--fx-kind-${kind}`;
|
|
660
685
|
var kindColor = (kind) => `var(${kindVar(kind)}, ${KIND_COLOR[kind]})`;
|
|
@@ -671,7 +696,11 @@ var TREE_KINDS = /* @__PURE__ */ new Set([
|
|
|
671
696
|
"handler",
|
|
672
697
|
// A component a plugin recognised as providing a context. Still a tag the author wrote,
|
|
673
698
|
// so leaving it out took it and everything it rendered out of the tree.
|
|
674
|
-
"provider"
|
|
699
|
+
"provider",
|
|
700
|
+
// Scopes the runtime reported: what their signals and memos belong to.
|
|
701
|
+
"custom-element",
|
|
702
|
+
"module",
|
|
703
|
+
"service"
|
|
675
704
|
]);
|
|
676
705
|
var TREE_CSS = `
|
|
677
706
|
.fx-tree-row {
|
|
@@ -787,9 +816,14 @@ var PREFIX = {
|
|
|
787
816
|
// A plugin's, and it names them itself.
|
|
788
817
|
directive: "d",
|
|
789
818
|
context: "ctx",
|
|
790
|
-
provider: "p"
|
|
819
|
+
provider: "p",
|
|
820
|
+
// Scopes are always named by what opened them.
|
|
821
|
+
"custom-element": "el",
|
|
822
|
+
module: "mod",
|
|
823
|
+
service: "svc"
|
|
791
824
|
};
|
|
792
825
|
function readProps(props) {
|
|
826
|
+
if (readOnce.has(props)) return readOnce.get(props);
|
|
793
827
|
const at = propsLocations(props);
|
|
794
828
|
const out = [];
|
|
795
829
|
for (const name of Object.keys(props)) {
|
|
@@ -800,13 +834,25 @@ function readProps(props) {
|
|
|
800
834
|
...where ? { at: { line: where[0], column: where[1] } } : {}
|
|
801
835
|
};
|
|
802
836
|
try {
|
|
803
|
-
report.value = formatValue(
|
|
837
|
+
report.value = formatValue(
|
|
838
|
+
createRoot2((dispose) => {
|
|
839
|
+
try {
|
|
840
|
+
return untrack2(() => props[name]);
|
|
841
|
+
} finally {
|
|
842
|
+
dispose();
|
|
843
|
+
}
|
|
844
|
+
}),
|
|
845
|
+
200
|
|
846
|
+
);
|
|
804
847
|
} catch {
|
|
805
848
|
}
|
|
806
849
|
out.push(report);
|
|
807
850
|
}
|
|
808
|
-
|
|
851
|
+
const reports = out.length ? out : void 0;
|
|
852
|
+
readOnce.set(props, reports);
|
|
853
|
+
return reports;
|
|
809
854
|
}
|
|
855
|
+
var readOnce = /* @__PURE__ */ new WeakMap();
|
|
810
856
|
function observeGraph(options = {}) {
|
|
811
857
|
installSourceMarker();
|
|
812
858
|
const origin = options.origin ?? (typeof location === "object" ? location.origin : void 0);
|
|
@@ -827,6 +873,10 @@ function observeGraph(options = {}) {
|
|
|
827
873
|
const boundTo = /* @__PURE__ */ new WeakMap();
|
|
828
874
|
const drivenBy = /* @__PURE__ */ new WeakMap();
|
|
829
875
|
let reaches = /* @__PURE__ */ new Map();
|
|
876
|
+
const SCOPE_KINDS = /* @__PURE__ */ new Set(["custom-element", "module", "service"]);
|
|
877
|
+
const scopeIds = /* @__PURE__ */ new WeakMap();
|
|
878
|
+
const scopeOfTarget = /* @__PURE__ */ new WeakMap();
|
|
879
|
+
const fieldsOf = /* @__PURE__ */ new WeakMap();
|
|
830
880
|
let described = null;
|
|
831
881
|
const rendered = /* @__PURE__ */ new Map();
|
|
832
882
|
const elementsIn = (value) => {
|
|
@@ -923,7 +973,9 @@ function observeGraph(options = {}) {
|
|
|
923
973
|
// Mapped, unlike `mark`: these two came off a stack, so they are positions in the
|
|
924
974
|
// compiled file until a host translates them.
|
|
925
975
|
...site && !site.external ? { usedAt: mapped(site.location) } : {},
|
|
926
|
-
|
|
976
|
+
// Not inside a scope: an element's prop is made by the package for the element, and
|
|
977
|
+
// the package's line says less than the scope it sits in already does.
|
|
978
|
+
...site && site.external && !mark?.location && !report.scope ? { source: mapped(site.location) } : {}
|
|
927
979
|
};
|
|
928
980
|
const owner = ancestor(report.parents);
|
|
929
981
|
if (owner !== void 0) node.createdIn = owner;
|
|
@@ -933,6 +985,28 @@ function observeGraph(options = {}) {
|
|
|
933
985
|
node.createdIn = originId;
|
|
934
986
|
if (from.source) node.source = from.source;
|
|
935
987
|
}
|
|
988
|
+
const scopeId = report.scope ? scopeIds.get(report.scope) : void 0;
|
|
989
|
+
if (scopeId !== void 0) {
|
|
990
|
+
node.scope = scopeId;
|
|
991
|
+
const creator = node.createdIn !== void 0 ? graph.get(node.createdIn) : void 0;
|
|
992
|
+
const insideAlready = node.createdIn === scopeId || creator?.scope === scopeId;
|
|
993
|
+
if (!insideAlready) node.createdIn = scopeId;
|
|
994
|
+
} else if (node.createdIn !== void 0) {
|
|
995
|
+
const creator = graph.get(node.createdIn);
|
|
996
|
+
const inherited = creator && SCOPE_KINDS.has(creator.kind) ? creator.id : creator?.scope;
|
|
997
|
+
if (inherited !== void 0) node.scope = inherited;
|
|
998
|
+
}
|
|
999
|
+
const self = mark?.self;
|
|
1000
|
+
if (self) {
|
|
1001
|
+
const list = fieldsOf.get(self);
|
|
1002
|
+
if (list) list.push(id);
|
|
1003
|
+
else fieldsOf.set(self, [id]);
|
|
1004
|
+
const open = scopeOfTarget.get(self);
|
|
1005
|
+
if (open !== void 0 && graph.has(open)) {
|
|
1006
|
+
node.scope = open;
|
|
1007
|
+
node.createdIn = open;
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
936
1010
|
if (kind !== "effect" && typeof handle === "function") {
|
|
937
1011
|
const read = handle;
|
|
938
1012
|
node.read = () => untrack2(read);
|
|
@@ -1068,20 +1142,90 @@ function observeGraph(options = {}) {
|
|
|
1068
1142
|
internals.delete(target);
|
|
1069
1143
|
const id = ids.get(target);
|
|
1070
1144
|
if (id === void 0) return;
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1145
|
+
forget(id);
|
|
1146
|
+
},
|
|
1147
|
+
scope(scope, info, parent) {
|
|
1148
|
+
dropReactiveSource();
|
|
1149
|
+
const id = seq++;
|
|
1150
|
+
const kind = info.kind === "element" ? "custom-element" : info.kind;
|
|
1151
|
+
const parentId = parent ? scopeIds.get(parent) : void 0;
|
|
1152
|
+
const found = currentCallSite(origin);
|
|
1153
|
+
const site = found && !/\0|__x00__|^virtual:/.test(found.location.file ?? "") ? found : void 0;
|
|
1154
|
+
const node = {
|
|
1155
|
+
id,
|
|
1156
|
+
label: info.name,
|
|
1157
|
+
kind,
|
|
1158
|
+
// The author named the element, the module and the service; none of them is plumbing.
|
|
1159
|
+
authored: true,
|
|
1160
|
+
deps: /* @__PURE__ */ new Set(),
|
|
1161
|
+
writes: /* @__PURE__ */ new Set(),
|
|
1162
|
+
runs: 0,
|
|
1163
|
+
lastPulse: 0,
|
|
1164
|
+
...info.detail ? { value: info.detail, detail: info.detail } : {},
|
|
1165
|
+
...parentId !== void 0 ? { scope: parentId, createdIn: parentId } : {}
|
|
1166
|
+
};
|
|
1167
|
+
const target = info.target;
|
|
1168
|
+
if (kind === "custom-element") {
|
|
1169
|
+
const defined = target ? classSource(target.constructor) : void 0;
|
|
1170
|
+
if (defined) node.declaredAt = defined;
|
|
1171
|
+
} else if (site && !site.external) {
|
|
1172
|
+
node.usedAt = mapped(site.location);
|
|
1173
|
+
}
|
|
1174
|
+
scopeIds.set(scope, id);
|
|
1175
|
+
if (target && typeof target === "object" && target.nodeType === 1) {
|
|
1176
|
+
rendered.set(id, [new WeakRef(target)]);
|
|
1177
|
+
}
|
|
1178
|
+
graph.set(id, node);
|
|
1179
|
+
history.created(id, node.createdIn, node.label);
|
|
1180
|
+
if (target && typeof target === "object") {
|
|
1181
|
+
scopeOfTarget.set(target, id);
|
|
1182
|
+
for (const field of fieldsOf.get(target) ?? []) {
|
|
1183
|
+
const made = graph.get(field);
|
|
1184
|
+
if (!made) continue;
|
|
1185
|
+
made.scope = id;
|
|
1186
|
+
made.createdIn = id;
|
|
1187
|
+
revs.set(field, ++revision);
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
},
|
|
1191
|
+
scopeEnded(scope) {
|
|
1192
|
+
const id = scopeIds.get(scope);
|
|
1193
|
+
if (id === void 0) return;
|
|
1194
|
+
const ended = /* @__PURE__ */ new Set([id]);
|
|
1195
|
+
for (let grew = true; grew; ) {
|
|
1196
|
+
grew = false;
|
|
1197
|
+
for (const [other, node] of graph) {
|
|
1198
|
+
if (!ended.has(other) && node.scope !== void 0 && ended.has(node.scope)) {
|
|
1199
|
+
ended.add(other);
|
|
1200
|
+
grew = true;
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
for (const gone of ended) forget(gone);
|
|
1205
|
+
},
|
|
1206
|
+
scopeAdopted(scope, parent) {
|
|
1207
|
+
const node = graph.get(scopeIds.get(scope) ?? -1);
|
|
1208
|
+
const parentId = scopeIds.get(parent);
|
|
1209
|
+
if (!node || parentId === void 0 || parentId === node.id) return;
|
|
1210
|
+
node.scope = parentId;
|
|
1211
|
+
node.createdIn = parentId;
|
|
1212
|
+
revs.set(node.id, ++revision);
|
|
1083
1213
|
}
|
|
1084
1214
|
});
|
|
1215
|
+
function forget(id) {
|
|
1216
|
+
removed.push({ id, rev: ++revision });
|
|
1217
|
+
revs.delete(id);
|
|
1218
|
+
if (removed.length > REMOVED_LOG) removed.splice(0, removed.length - REMOVED_LOG);
|
|
1219
|
+
history.disposed(id, graph.get(id)?.label);
|
|
1220
|
+
graph.delete(id);
|
|
1221
|
+
handed.delete(id);
|
|
1222
|
+
raws.delete(id);
|
|
1223
|
+
cores.delete(id);
|
|
1224
|
+
rendered.delete(id);
|
|
1225
|
+
setters.delete(id);
|
|
1226
|
+
runsAtLastSample.delete(id);
|
|
1227
|
+
unnamed.delete(id);
|
|
1228
|
+
}
|
|
1085
1229
|
const edges = (id, node) => {
|
|
1086
1230
|
const sources = cores.get(id)?.sources;
|
|
1087
1231
|
node.deps.clear();
|
|
@@ -1101,6 +1245,14 @@ function observeGraph(options = {}) {
|
|
|
1101
1245
|
revs.set(id, ++revision);
|
|
1102
1246
|
};
|
|
1103
1247
|
const now = Date.now();
|
|
1248
|
+
for (const [id, node] of graph) {
|
|
1249
|
+
if (node.kind !== "custom-element" || node.usedAt) continue;
|
|
1250
|
+
const element = rendered.get(id)?.[0]?.deref();
|
|
1251
|
+
const written = element ? element.__fx_loc : void 0;
|
|
1252
|
+
if (!written?.file) continue;
|
|
1253
|
+
node.usedAt = { file: written.file, line: written.line, column: written.column };
|
|
1254
|
+
revs.set(id, ++revision);
|
|
1255
|
+
}
|
|
1104
1256
|
const bindings = /* @__PURE__ */ new Map();
|
|
1105
1257
|
const drives = /* @__PURE__ */ new Map();
|
|
1106
1258
|
const seen = /* @__PURE__ */ new Map();
|
package/dist/palette.cjs
CHANGED
|
@@ -42,7 +42,10 @@ var KIND_COLOR = {
|
|
|
42
42
|
binding: "#5eead4",
|
|
43
43
|
setter: "#fb7185",
|
|
44
44
|
group: "#8a90a2",
|
|
45
|
-
element: "#8a90a2"
|
|
45
|
+
element: "#8a90a2",
|
|
46
|
+
"custom-element": "#2dd4bf",
|
|
47
|
+
module: "#facc15",
|
|
48
|
+
service: "#60a5fa"
|
|
46
49
|
};
|
|
47
50
|
var kindVar = (kind) => `--fx-kind-${kind}`;
|
|
48
51
|
var kindColor = (kind) => `var(${kindVar(kind)}, ${KIND_COLOR[kind]})`;
|
package/dist/palette.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../src/palette.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD,qFAAqF;AACrF,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEhD,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../src/palette.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD,qFAAqF;AACrF,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEhD,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAoBnD,CAAC;AAEF,6DAA6D;AAC7D,eAAO,MAAM,OAAO,GAAI,MAAM,YAAY,KAAG,MAA6B,CAAC;AAE3E,gGAAgG;AAChG,eAAO,MAAM,SAAS,GAAI,MAAM,YAAY,KAAG,MACD,CAAC;AAI/C,0FAA0F;AAC1F,wBAAgB,SAAS,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE5F"}
|
package/dist/palette.js
CHANGED
|
@@ -15,6 +15,9 @@ export const KIND_COLOR = {
|
|
|
15
15
|
setter: '#fb7185',
|
|
16
16
|
group: '#8a90a2',
|
|
17
17
|
element: '#8a90a2',
|
|
18
|
+
'custom-element': '#2dd4bf',
|
|
19
|
+
module: '#facc15',
|
|
20
|
+
service: '#60a5fa',
|
|
18
21
|
};
|
|
19
22
|
/** The variable a host can set to override one, per kind. */
|
|
20
23
|
export const kindVar = (kind) => `--fx-kind-${kind}`;
|
package/dist/palette.mjs
CHANGED
|
@@ -15,7 +15,10 @@ var KIND_COLOR = {
|
|
|
15
15
|
binding: "#5eead4",
|
|
16
16
|
setter: "#fb7185",
|
|
17
17
|
group: "#8a90a2",
|
|
18
|
-
element: "#8a90a2"
|
|
18
|
+
element: "#8a90a2",
|
|
19
|
+
"custom-element": "#2dd4bf",
|
|
20
|
+
module: "#facc15",
|
|
21
|
+
service: "#60a5fa"
|
|
19
22
|
};
|
|
20
23
|
var kindVar = (kind) => `--fx-kind-${kind}`;
|
|
21
24
|
var kindColor = (kind) => `var(${kindVar(kind)}, ${KIND_COLOR[kind]})`;
|
package/dist/plugins/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @fluixi/devtools v0.2.0-alpha.
|
|
1
|
+
/*! @fluixi/devtools v0.2.0-alpha.7 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
2
|
"use strict";
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
package/dist/plugins/index.mjs
CHANGED
package/dist/source.cjs
CHANGED
|
@@ -20,9 +20,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/source.ts
|
|
21
21
|
var source_exports = {};
|
|
22
22
|
__export(source_exports, {
|
|
23
|
+
classSource: () => classSource,
|
|
23
24
|
componentSource: () => componentSource,
|
|
25
|
+
dropReactiveSource: () => dropReactiveSource,
|
|
24
26
|
holeLocation: () => holeLocation,
|
|
25
27
|
installSourceMarker: () => installSourceMarker,
|
|
28
|
+
markClassSource: () => markClassSource,
|
|
26
29
|
markComponentSource: () => markComponentSource,
|
|
27
30
|
markReactiveSource: () => markReactiveSource,
|
|
28
31
|
propsLocations: () => propsLocations,
|
|
@@ -31,6 +34,7 @@ __export(source_exports, {
|
|
|
31
34
|
module.exports = __toCommonJS(source_exports);
|
|
32
35
|
var MARKER = "__fx_source";
|
|
33
36
|
var COMPONENT_MARKER = "__fx_component";
|
|
37
|
+
var CLASS_MARKER = "__fx_class";
|
|
34
38
|
var HOLE_MARKER = "__fx_hole";
|
|
35
39
|
var PROPS_MARKER = "__fx_props";
|
|
36
40
|
var MARKS = "__FLUIXI_DEVTOOLS_MARKS__";
|
|
@@ -41,12 +45,16 @@ var shared = host[MARKS] ?? {
|
|
|
41
45
|
components: /* @__PURE__ */ new Map()
|
|
42
46
|
};
|
|
43
47
|
host[MARKS] = shared;
|
|
44
|
-
|
|
48
|
+
shared.classes ??= /* @__PURE__ */ new WeakMap();
|
|
49
|
+
function markReactiveSource(file, line, column, name, self) {
|
|
45
50
|
const location = locate(file, line, column);
|
|
46
51
|
if (shared.pending && location.external && !shared.pending.location?.external) return;
|
|
47
|
-
shared.pending = { name, location };
|
|
52
|
+
shared.pending = self && typeof self === "object" ? { name, location, self } : { name, location };
|
|
48
53
|
shared.expiring = false;
|
|
49
54
|
}
|
|
55
|
+
function dropReactiveSource() {
|
|
56
|
+
shared.pending = null;
|
|
57
|
+
}
|
|
50
58
|
function locate(file, line, column) {
|
|
51
59
|
const external = !!file && (/^([a-zA-Z]:)?[\\/]/.test(file) || file.includes("node_modules/"));
|
|
52
60
|
return external ? { file, line, column, external } : { file, line, column };
|
|
@@ -60,13 +68,19 @@ function markComponentSource(name, file, line, column) {
|
|
|
60
68
|
}
|
|
61
69
|
if (!seen || seen.file !== file || seen.line !== line) shared.components.set(name, null);
|
|
62
70
|
}
|
|
71
|
+
function markClassSource(constructor, file, line, column) {
|
|
72
|
+
if (typeof constructor === "function") shared.classes.set(constructor, locate(file, line, column));
|
|
73
|
+
}
|
|
74
|
+
function classSource(constructor) {
|
|
75
|
+
return typeof constructor === "function" ? shared.classes.get(constructor) : void 0;
|
|
76
|
+
}
|
|
63
77
|
function componentSource(name) {
|
|
64
78
|
return shared.components.get(name) ?? void 0;
|
|
65
79
|
}
|
|
66
80
|
function takeReactiveSource() {
|
|
67
81
|
const mark = shared.pending;
|
|
68
82
|
if (mark) {
|
|
69
|
-
if (mark.name !== void 0) shared.pending = { location: mark.location };
|
|
83
|
+
if (mark.name !== void 0 || mark.self) shared.pending = { location: mark.location };
|
|
70
84
|
if (!shared.expiring) {
|
|
71
85
|
shared.expiring = true;
|
|
72
86
|
queueMicrotask(() => {
|
|
@@ -106,6 +120,7 @@ function holeLocation(accessor) {
|
|
|
106
120
|
function installSourceMarker() {
|
|
107
121
|
if (typeof host[MARKER] !== "function") host[MARKER] = markReactiveSource;
|
|
108
122
|
if (typeof host[COMPONENT_MARKER] !== "function") host[COMPONENT_MARKER] = markComponentSource;
|
|
123
|
+
if (typeof host[CLASS_MARKER] !== "function") host[CLASS_MARKER] = markClassSource;
|
|
109
124
|
if (typeof host[HOLE_MARKER] !== "function") host[HOLE_MARKER] = markHole;
|
|
110
125
|
if (typeof host[PROPS_MARKER] !== "function") host[PROPS_MARKER] = markProps;
|
|
111
126
|
}
|
package/dist/source.d.ts
CHANGED
|
@@ -37,6 +37,11 @@ export interface ReactiveSourceLocation {
|
|
|
37
37
|
export interface ReactiveSourceMetadata {
|
|
38
38
|
name?: string;
|
|
39
39
|
location?: ReactiveSourceLocation;
|
|
40
|
+
/**
|
|
41
|
+
* The instance a class field belongs to. A field initializer runs in the constructor, before
|
|
42
|
+
* a custom element has opened its scope, so this is what ties `#count = signal(0)` to it.
|
|
43
|
+
*/
|
|
44
|
+
self?: object;
|
|
40
45
|
}
|
|
41
46
|
/**
|
|
42
47
|
* Where each component was declared, by name.
|
|
@@ -50,9 +55,19 @@ export interface ReactiveSourceMetadata {
|
|
|
50
55
|
* Record where the next node is about to be created. The compiler calls this; call it
|
|
51
56
|
* yourself only for a node the compiler cannot see, immediately before the primitive.
|
|
52
57
|
*/
|
|
53
|
-
export declare function markReactiveSource(file?: string, line?: number, column?: number, name?: string): void;
|
|
58
|
+
export declare function markReactiveSource(file?: string, line?: number, column?: number, name?: string, self?: object): void;
|
|
59
|
+
/**
|
|
60
|
+
* Forget the mark. A scope opening is the end of whatever statement left it: an element's
|
|
61
|
+
* props are made in its own scope, and without this they claimed the line of the last class
|
|
62
|
+
* field or effect the same turn happened to run.
|
|
63
|
+
*/
|
|
64
|
+
export declare function dropReactiveSource(): void;
|
|
54
65
|
/** Record where a component was declared. The compiler calls this. */
|
|
55
66
|
export declare function markComponentSource(name: string, file?: string, line?: number, column?: number): void;
|
|
67
|
+
/** Record where a class was declared. The compiler calls this from the class's static block. */
|
|
68
|
+
export declare function markClassSource(constructor: unknown, file?: string, line?: number, column?: number): void;
|
|
69
|
+
/** Where a class was declared, when the compiler marked it: a custom element's definition. */
|
|
70
|
+
export declare function classSource(constructor: unknown): ReactiveSourceLocation | undefined;
|
|
56
71
|
/** Where a component of this name was declared, when exactly one was. */
|
|
57
72
|
export declare function componentSource(name: string): ReactiveSourceLocation | undefined;
|
|
58
73
|
/**
|
package/dist/source.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,gFAAgF;AAChF,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oFAAoF;IACpF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/C;AAED,gFAAgF;AAChF,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,gFAAgF;AAChF,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oFAAoF;IACpF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/C;AAED,gFAAgF;AAChF,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,sBAAsB,CAAC;IAClC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAoCD;;;;;;;GAOG;AAGH;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAQpH;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AAYD,sEAAsE;AACtE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAQrG;AAED,gGAAgG;AAChG,wBAAgB,eAAe,CAAC,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAEzG;AAED,8FAA8F;AAC9F,wBAAgB,WAAW,CAAC,WAAW,EAAE,OAAO,GAAG,sBAAsB,GAAG,SAAS,CAEpF;AAED,yEAAyE;AACzE,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,sBAAsB,GAAG,SAAS,CAEhF;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,IAAI,sBAAsB,GAAG,IAAI,CAgBlE;AA4CD,oFAAoF;AACpF,wBAAgB,cAAc,CAC5B,KAAK,EAAE,OAAO,GACb,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAE9C;AAED,mEAAmE;AACnE,wBAAgB,YAAY,CAAC,QAAQ,EAAE,OAAO,GAAG,sBAAsB,GAAG,SAAS,CAGlF;AAED,wBAAgB,mBAAmB,IAAI,IAAI,CAM1C"}
|
package/dist/source.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
/** Kept in step with SOURCE_MARKER and COMPONENT_MARKER in the compiler. */
|
|
12
12
|
const MARKER = '__fx_source';
|
|
13
13
|
const COMPONENT_MARKER = '__fx_component';
|
|
14
|
+
const CLASS_MARKER = '__fx_class';
|
|
14
15
|
const HOLE_MARKER = '__fx_hole';
|
|
15
16
|
const PROPS_MARKER = '__fx_props';
|
|
16
17
|
const MARKS = '__FLUIXI_DEVTOOLS_MARKS__';
|
|
@@ -21,6 +22,7 @@ const shared = host[MARKS] ?? {
|
|
|
21
22
|
components: new Map(),
|
|
22
23
|
};
|
|
23
24
|
host[MARKS] = shared;
|
|
25
|
+
shared.classes ??= new WeakMap();
|
|
24
26
|
/**
|
|
25
27
|
* Where each component was declared, by name.
|
|
26
28
|
*
|
|
@@ -33,16 +35,24 @@ host[MARKS] = shared;
|
|
|
33
35
|
* Record where the next node is about to be created. The compiler calls this; call it
|
|
34
36
|
* yourself only for a node the compiler cannot see, immediately before the primitive.
|
|
35
37
|
*/
|
|
36
|
-
export function markReactiveSource(file, line, column, name) {
|
|
38
|
+
export function markReactiveSource(file, line, column, name, self) {
|
|
37
39
|
const location = locate(file, line, column);
|
|
38
40
|
// With dependencies marked, `signal()` in the framework marks its own `createSignal` line
|
|
39
41
|
// in between the application's mark and the node it asked for. The call site is the useful
|
|
40
42
|
// location, so a dependency never takes a mark the project has already left unclaimed.
|
|
41
43
|
if (shared.pending && location.external && !shared.pending.location?.external)
|
|
42
44
|
return;
|
|
43
|
-
shared.pending = { name, location };
|
|
45
|
+
shared.pending = self && typeof self === 'object' ? { name, location, self } : { name, location };
|
|
44
46
|
shared.expiring = false;
|
|
45
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Forget the mark. A scope opening is the end of whatever statement left it: an element's
|
|
50
|
+
* props are made in its own scope, and without this they claimed the line of the last class
|
|
51
|
+
* field or effect the same turn happened to run.
|
|
52
|
+
*/
|
|
53
|
+
export function dropReactiveSource() {
|
|
54
|
+
shared.pending = null;
|
|
55
|
+
}
|
|
46
56
|
/**
|
|
47
57
|
* A project file is named relative to the project root, so anything absolute or under
|
|
48
58
|
* node_modules came from a dependency. Derived here rather than sent, so the mark the
|
|
@@ -63,6 +73,15 @@ export function markComponentSource(name, file, line, column) {
|
|
|
63
73
|
if (!seen || seen.file !== file || seen.line !== line)
|
|
64
74
|
shared.components.set(name, null);
|
|
65
75
|
}
|
|
76
|
+
/** Record where a class was declared. The compiler calls this from the class's static block. */
|
|
77
|
+
export function markClassSource(constructor, file, line, column) {
|
|
78
|
+
if (typeof constructor === 'function')
|
|
79
|
+
shared.classes.set(constructor, locate(file, line, column));
|
|
80
|
+
}
|
|
81
|
+
/** Where a class was declared, when the compiler marked it: a custom element's definition. */
|
|
82
|
+
export function classSource(constructor) {
|
|
83
|
+
return typeof constructor === 'function' ? shared.classes.get(constructor) : undefined;
|
|
84
|
+
}
|
|
66
85
|
/** Where a component of this name was declared, when exactly one was. */
|
|
67
86
|
export function componentSource(name) {
|
|
68
87
|
return shared.components.get(name) ?? undefined;
|
|
@@ -80,7 +99,8 @@ export function takeReactiveSource() {
|
|
|
80
99
|
if (mark) {
|
|
81
100
|
// The variable name belongs to the node the author was declaring, not to the ones the
|
|
82
101
|
// framework built underneath it: `cart`, then two unnamed signals at the same line.
|
|
83
|
-
|
|
102
|
+
// The instance goes with the name: it says whose field this one node is.
|
|
103
|
+
if (mark.name !== undefined || mark.self)
|
|
84
104
|
shared.pending = { location: mark.location };
|
|
85
105
|
if (!shared.expiring) {
|
|
86
106
|
shared.expiring = true;
|
|
@@ -146,6 +166,8 @@ export function installSourceMarker() {
|
|
|
146
166
|
host[MARKER] = markReactiveSource;
|
|
147
167
|
if (typeof host[COMPONENT_MARKER] !== 'function')
|
|
148
168
|
host[COMPONENT_MARKER] = markComponentSource;
|
|
169
|
+
if (typeof host[CLASS_MARKER] !== 'function')
|
|
170
|
+
host[CLASS_MARKER] = markClassSource;
|
|
149
171
|
if (typeof host[HOLE_MARKER] !== 'function')
|
|
150
172
|
host[HOLE_MARKER] = markHole;
|
|
151
173
|
if (typeof host[PROPS_MARKER] !== 'function')
|
package/dist/source.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/source.ts
|
|
2
2
|
var MARKER = "__fx_source";
|
|
3
3
|
var COMPONENT_MARKER = "__fx_component";
|
|
4
|
+
var CLASS_MARKER = "__fx_class";
|
|
4
5
|
var HOLE_MARKER = "__fx_hole";
|
|
5
6
|
var PROPS_MARKER = "__fx_props";
|
|
6
7
|
var MARKS = "__FLUIXI_DEVTOOLS_MARKS__";
|
|
@@ -11,12 +12,16 @@ var shared = host[MARKS] ?? {
|
|
|
11
12
|
components: /* @__PURE__ */ new Map()
|
|
12
13
|
};
|
|
13
14
|
host[MARKS] = shared;
|
|
14
|
-
|
|
15
|
+
shared.classes ??= /* @__PURE__ */ new WeakMap();
|
|
16
|
+
function markReactiveSource(file, line, column, name, self) {
|
|
15
17
|
const location = locate(file, line, column);
|
|
16
18
|
if (shared.pending && location.external && !shared.pending.location?.external) return;
|
|
17
|
-
shared.pending = { name, location };
|
|
19
|
+
shared.pending = self && typeof self === "object" ? { name, location, self } : { name, location };
|
|
18
20
|
shared.expiring = false;
|
|
19
21
|
}
|
|
22
|
+
function dropReactiveSource() {
|
|
23
|
+
shared.pending = null;
|
|
24
|
+
}
|
|
20
25
|
function locate(file, line, column) {
|
|
21
26
|
const external = !!file && (/^([a-zA-Z]:)?[\\/]/.test(file) || file.includes("node_modules/"));
|
|
22
27
|
return external ? { file, line, column, external } : { file, line, column };
|
|
@@ -30,13 +35,19 @@ function markComponentSource(name, file, line, column) {
|
|
|
30
35
|
}
|
|
31
36
|
if (!seen || seen.file !== file || seen.line !== line) shared.components.set(name, null);
|
|
32
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
|
+
}
|
|
33
44
|
function componentSource(name) {
|
|
34
45
|
return shared.components.get(name) ?? void 0;
|
|
35
46
|
}
|
|
36
47
|
function takeReactiveSource() {
|
|
37
48
|
const mark = shared.pending;
|
|
38
49
|
if (mark) {
|
|
39
|
-
if (mark.name !== void 0) shared.pending = { location: mark.location };
|
|
50
|
+
if (mark.name !== void 0 || mark.self) shared.pending = { location: mark.location };
|
|
40
51
|
if (!shared.expiring) {
|
|
41
52
|
shared.expiring = true;
|
|
42
53
|
queueMicrotask(() => {
|
|
@@ -76,13 +87,17 @@ function holeLocation(accessor) {
|
|
|
76
87
|
function installSourceMarker() {
|
|
77
88
|
if (typeof host[MARKER] !== "function") host[MARKER] = markReactiveSource;
|
|
78
89
|
if (typeof host[COMPONENT_MARKER] !== "function") host[COMPONENT_MARKER] = markComponentSource;
|
|
90
|
+
if (typeof host[CLASS_MARKER] !== "function") host[CLASS_MARKER] = markClassSource;
|
|
79
91
|
if (typeof host[HOLE_MARKER] !== "function") host[HOLE_MARKER] = markHole;
|
|
80
92
|
if (typeof host[PROPS_MARKER] !== "function") host[PROPS_MARKER] = markProps;
|
|
81
93
|
}
|
|
82
94
|
export {
|
|
95
|
+
classSource,
|
|
83
96
|
componentSource,
|
|
97
|
+
dropReactiveSource,
|
|
84
98
|
holeLocation,
|
|
85
99
|
installSourceMarker,
|
|
100
|
+
markClassSource,
|
|
86
101
|
markComponentSource,
|
|
87
102
|
markReactiveSource,
|
|
88
103
|
propsLocations,
|