@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.
Files changed (83) hide show
  1. package/dist/callsite.mjs +4 -63
  2. package/dist/change-view.mjs +6 -106
  3. package/dist/chunk-235BSS43.mjs +185 -0
  4. package/dist/chunk-2ACSNLS6.mjs +87 -0
  5. package/dist/chunk-2VDMQ3VF.mjs +520 -0
  6. package/dist/chunk-33U2S43X.mjs +121 -0
  7. package/dist/chunk-B3SAJ7QG.mjs +72 -0
  8. package/dist/chunk-BTCWJTXR.mjs +216 -0
  9. package/dist/chunk-CPZWLBCQ.mjs +35 -0
  10. package/dist/chunk-D25KZZBZ.mjs +212 -0
  11. package/dist/chunk-EBSROPWJ.mjs +314 -0
  12. package/dist/chunk-F664XLZL.mjs +743 -0
  13. package/dist/chunk-FY5K3QVT.mjs +35 -0
  14. package/dist/chunk-GDQXCOQB.mjs +43 -0
  15. package/dist/chunk-JLNWT36I.mjs +118 -0
  16. package/dist/chunk-JTHAZJJZ.mjs +780 -0
  17. package/dist/chunk-L6XQGNMW.mjs +106 -0
  18. package/dist/chunk-MN6O673L.mjs +90 -0
  19. package/dist/chunk-NDUBBBNL.mjs +70 -0
  20. package/dist/chunk-NT7YMK77.mjs +157 -0
  21. package/dist/chunk-NVULLJDH.mjs +120 -0
  22. package/dist/chunk-NWLSDERQ.mjs +68 -0
  23. package/dist/chunk-OPIGF5XB.mjs +184 -0
  24. package/dist/chunk-P5I7DWFX.mjs +292 -0
  25. package/dist/chunk-PSSBFXBD.mjs +155 -0
  26. package/dist/chunk-PTQ5VCYE.mjs +103 -0
  27. package/dist/chunk-UAEJ3N7F.mjs +76 -0
  28. package/dist/chunk-V6DKWEYD.mjs +67 -0
  29. package/dist/chunk-VO2V7AC5.mjs +80 -0
  30. package/dist/chunk-WGQH7RUW.mjs +25 -0
  31. package/dist/chunk-Z6KYHEKY.mjs +64 -0
  32. package/dist/copy.mjs +3 -39
  33. package/dist/describe.mjs +3 -31
  34. package/dist/detail-panel.cjs +2 -1
  35. package/dist/detail-panel.d.ts.map +1 -1
  36. package/dist/detail-panel.js +1 -0
  37. package/dist/detail-panel.mjs +6 -280
  38. package/dist/diff.mjs +4 -201
  39. package/dist/dom.mjs +7 -176
  40. package/dist/export.mjs +6 -207
  41. package/dist/float.mjs +5 -206
  42. package/dist/format.mjs +5 -151
  43. package/dist/graph-view.mjs +9 -875
  44. package/dist/highlight.mjs +6 -113
  45. package/dist/history.cjs +14 -2
  46. package/dist/history.d.ts +8 -1
  47. package/dist/history.d.ts.map +1 -1
  48. package/dist/history.js +15 -2
  49. package/dist/history.mjs +4 -70
  50. package/dist/hook.cjs +26 -1
  51. package/dist/hook.d.ts +4 -0
  52. package/dist/hook.d.ts.map +1 -1
  53. package/dist/hook.js +13 -0
  54. package/dist/hook.mjs +16 -1719
  55. package/dist/index.cjs +34 -5
  56. package/dist/index.mjs +106 -4673
  57. package/dist/inspector.mjs +11 -677
  58. package/dist/instrument.mjs +9 -486
  59. package/dist/kind-filter.mjs +6 -148
  60. package/dist/menu.mjs +4 -116
  61. package/dist/observe.cjs +15 -1
  62. package/dist/observe.d.ts +2 -0
  63. package/dist/observe.d.ts.map +1 -1
  64. package/dist/observe.js +3 -0
  65. package/dist/observe.mjs +14 -1510
  66. package/dist/palette.mjs +6 -28
  67. package/dist/path.mjs +3 -21
  68. package/dist/plugin.mjs +9 -57
  69. package/dist/plugins/context.mjs +6 -71
  70. package/dist/plugins/directives.mjs +8 -68
  71. package/dist/plugins/index.cjs +1 -1
  72. package/dist/plugins/index.mjs +13 -136
  73. package/dist/source.mjs +12 -93
  74. package/dist/timeline.cjs +5 -2
  75. package/dist/timeline.d.ts.map +1 -1
  76. package/dist/timeline.js +5 -1
  77. package/dist/timeline.mjs +7 -323
  78. package/dist/tree.mjs +11 -558
  79. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  80. package/dist/value-pane.mjs +6 -196
  81. package/dist/wire.cjs +1 -1
  82. package/dist/wire.mjs +6 -86
  83. package/package.json +3 -3
@@ -0,0 +1,314 @@
1
+ import {
2
+ componentSource,
3
+ installSourceMarker,
4
+ takeReactiveSource
5
+ } from "./chunk-L6XQGNMW.mjs";
6
+ import {
7
+ formatValue,
8
+ shorten
9
+ } from "./chunk-NT7YMK77.mjs";
10
+
11
+ // src/instrument.ts
12
+ import {
13
+ createSignal,
14
+ createMemo,
15
+ createEffect,
16
+ createResource,
17
+ createRoot,
18
+ untrack,
19
+ onCleanup,
20
+ getOwner,
21
+ runWithOwner,
22
+ Signal
23
+ } from "@fluixi/reactive/signal";
24
+ import { createStore } from "@fluixi/reactive/store";
25
+ var $NODE = /* @__PURE__ */ Symbol.for("signal-node");
26
+ var KIND_OF_BUILTIN = {
27
+ Show: "control",
28
+ For: "control",
29
+ Index: "control",
30
+ Switch: "control",
31
+ Match: "control",
32
+ Portal: "control",
33
+ Dynamic: "control",
34
+ ErrorBoundary: "control",
35
+ Suspense: "control",
36
+ SuspenseList: "control",
37
+ Await: "control",
38
+ Router: "router",
39
+ Outlet: "router",
40
+ Redirect: "router",
41
+ Link: "router"
42
+ };
43
+ var CORE_STATE = { 0: "clean", 1: "check", 2: "dirty" };
44
+ function nodeVersion(n) {
45
+ return n.core && typeof n.core.version === "number" ? n.core.version : n.runs;
46
+ }
47
+ function nodeState(n) {
48
+ return n.core && typeof n.core.state === "number" ? CORE_STATE[n.core.state] : void 0;
49
+ }
50
+ var fmt = (v) => formatValue(v);
51
+ var short = (s, n = 18) => shorten(s, n);
52
+ function createReactor() {
53
+ installSourceMarker();
54
+ const graph = /* @__PURE__ */ new Map();
55
+ const runsAtLastSample = /* @__PURE__ */ new Map();
56
+ const unnamed = /* @__PURE__ */ new Set();
57
+ const consumerStack = [];
58
+ let seq = 0;
59
+ let dispose = () => {
60
+ };
61
+ let rootOwner = null;
62
+ const claims = (node, value) => {
63
+ for (const dep of node.deps) {
64
+ const other = graph.get(dep);
65
+ if (other?.read && other.read() === value) return false;
66
+ }
67
+ return true;
68
+ };
69
+ const forget = (id) => {
70
+ const owner = getOwner() ?? rootOwner;
71
+ if (owner) {
72
+ runWithOwner(
73
+ owner,
74
+ () => onCleanup(() => {
75
+ graph.delete(id);
76
+ runsAtLastSample.delete(id);
77
+ unnamed.delete(id);
78
+ })
79
+ );
80
+ }
81
+ };
82
+ const recordRead = (sourceId) => {
83
+ const c = consumerStack[consumerStack.length - 1];
84
+ if (c != null) graph.get(c)?.deps.add(sourceId);
85
+ };
86
+ const recordWrite = (targetId) => {
87
+ const c = consumerStack[consumerStack.length - 1];
88
+ if (c != null && c !== targetId) graph.get(c)?.writes.add(targetId);
89
+ };
90
+ const base = (id, named, kind, fallback) => {
91
+ const mark = takeReactiveSource();
92
+ if (!named && !mark?.name) unnamed.add(id);
93
+ return {
94
+ id,
95
+ label: named ?? mark?.name ?? fallback,
96
+ kind,
97
+ deps: /* @__PURE__ */ new Set(),
98
+ writes: /* @__PURE__ */ new Set(),
99
+ runs: 0,
100
+ lastPulse: 0,
101
+ ...mark?.location ? { source: mark.location } : {}
102
+ };
103
+ };
104
+ const trackedCreateSignal = (value, options) => {
105
+ const id = seq++;
106
+ const [get, set] = createSignal(value, options);
107
+ const node = base(id, options?.name, "state", `s${id}`);
108
+ node.read = () => untrack(get);
109
+ node.detail = formatValue(value);
110
+ node.value = shorten(node.detail);
111
+ node.core = get[$NODE] ?? null;
112
+ graph.set(id, node);
113
+ forget(id);
114
+ const read = () => {
115
+ recordRead(id);
116
+ return get();
117
+ };
118
+ const write = (v) => {
119
+ recordWrite(id);
120
+ return set(typeof v === "function" ? v(untrack(get)) : v);
121
+ };
122
+ return [read, write];
123
+ };
124
+ const trackedCreateMemo = (fn, value, options) => {
125
+ const id = seq++;
126
+ const node = base(id, options?.name, "memo", `m${id}`);
127
+ graph.set(id, node);
128
+ forget(id);
129
+ const m = createMemo(() => {
130
+ node.core ??= Signal.subtle.currentComputed();
131
+ node.deps.clear();
132
+ node.writes.clear();
133
+ node.runs++;
134
+ consumerStack.push(id);
135
+ try {
136
+ return fn();
137
+ } finally {
138
+ consumerStack.pop();
139
+ }
140
+ }, value, options);
141
+ node.read = () => untrack(m);
142
+ return () => {
143
+ recordRead(id);
144
+ return m();
145
+ };
146
+ };
147
+ const trackedCreateEffect = (fn, options) => {
148
+ const id = seq++;
149
+ const node = base(id, options?.name, "effect", `e${id}`);
150
+ graph.set(id, node);
151
+ forget(id);
152
+ createEffect(() => {
153
+ node.core ??= Signal.subtle.currentComputed();
154
+ node.deps.clear();
155
+ node.writes.clear();
156
+ node.runs++;
157
+ node.lastPulse = performance.now();
158
+ consumerStack.push(id);
159
+ try {
160
+ fn();
161
+ } finally {
162
+ consumerStack.pop();
163
+ }
164
+ });
165
+ };
166
+ const trackedCreateStore = (initial, options) => {
167
+ const id = seq++;
168
+ const [proxy, setter] = createStore(initial, { immutable: true, ...options });
169
+ const node = base(id, options?.name, "store", `store${id}`);
170
+ node.read = () => {
171
+ try {
172
+ return untrack(() => JSON.stringify(proxy));
173
+ } catch {
174
+ return "{…}";
175
+ }
176
+ };
177
+ node.value = "{…}";
178
+ graph.set(id, node);
179
+ forget(id);
180
+ const recording = new Proxy(proxy, {
181
+ get(t, p, r) {
182
+ recordRead(id);
183
+ return Reflect.get(t, p, r);
184
+ }
185
+ });
186
+ const write = (...args) => {
187
+ recordWrite(id);
188
+ return setter(...args);
189
+ };
190
+ return [recording, write];
191
+ };
192
+ const trackedCreateResource = (...args) => {
193
+ const id = seq++;
194
+ const last = args[args.length - 1];
195
+ const name = last && typeof last === "object" && !Array.isArray(last) && typeof last !== "function" ? last.name : void 0;
196
+ const node = base(id, name, "resource", `res${id}`);
197
+ const [data, actions] = createResource(...args);
198
+ node.read = () => {
199
+ try {
200
+ return untrack(() => data.loading ? "⏳ loading" : JSON.stringify(data.latest));
201
+ } catch {
202
+ return "?";
203
+ }
204
+ };
205
+ node.value = "⏳ loading";
206
+ graph.set(id, node);
207
+ forget(id);
208
+ const accessor = (() => {
209
+ recordRead(id);
210
+ return data();
211
+ });
212
+ for (const k of ["loading", "error", "latest", "state"]) {
213
+ Object.defineProperty(accessor, k, { get: () => data[k] });
214
+ }
215
+ return [accessor, actions];
216
+ };
217
+ const trackedSignal = (value, options) => {
218
+ const [read, write] = trackedCreateSignal(value, options);
219
+ Object.defineProperty(read, "set", { value: write });
220
+ return read;
221
+ };
222
+ const trackedMemo = trackedCreateMemo;
223
+ const trackedEffect = trackedCreateEffect;
224
+ const trackedStore = (initial, options) => {
225
+ const [state, set] = trackedCreateStore(initial, options);
226
+ return new Proxy(state, {
227
+ get: (target, key) => key === "set" ? set : target[key],
228
+ has: (target, key) => key === "set" || Reflect.has(target, key)
229
+ });
230
+ };
231
+ const trackedResource = (...args) => {
232
+ const [accessor, controls] = trackedCreateResource(...args);
233
+ return Object.assign(accessor, controls);
234
+ };
235
+ const api = {
236
+ createSignal: trackedCreateSignal,
237
+ createMemo: trackedCreateMemo,
238
+ createEffect: trackedCreateEffect,
239
+ createStore: trackedCreateStore,
240
+ createResource: trackedCreateResource,
241
+ signal: trackedSignal,
242
+ memo: trackedMemo,
243
+ store: trackedStore,
244
+ effect: trackedEffect,
245
+ resource: trackedResource
246
+ };
247
+ return {
248
+ graph,
249
+ run(setup) {
250
+ dispose();
251
+ graph.clear();
252
+ runsAtLastSample.clear();
253
+ unnamed.clear();
254
+ seq = 0;
255
+ consumerStack.length = 0;
256
+ createRoot((d) => {
257
+ dispose = d;
258
+ rootOwner = getOwner();
259
+ setup(api);
260
+ });
261
+ },
262
+ sample() {
263
+ const changed = [];
264
+ const now = Date.now();
265
+ for (const node of graph.values()) {
266
+ if (!node.read) {
267
+ const seen = runsAtLastSample.get(node.id);
268
+ if (seen !== void 0 && node.runs > seen) {
269
+ node.lastPulse = now;
270
+ changed.push(node.id);
271
+ }
272
+ runsAtLastSample.set(node.id, node.runs);
273
+ continue;
274
+ }
275
+ const raw = node.read();
276
+ const stamped = raw?.$name;
277
+ if (node.kind === "memo" && typeof stamped === "string" && stamped && claims(node, raw)) {
278
+ node.kind = KIND_OF_BUILTIN[stamped] ?? "component";
279
+ node.declaredAt = componentSource(stamped);
280
+ node.source ??= node.declaredAt;
281
+ if (unnamed.has(node.id)) {
282
+ node.label = stamped;
283
+ unnamed.delete(node.id);
284
+ }
285
+ }
286
+ const detail = formatValue(raw);
287
+ const next = shorten(detail);
288
+ if (next !== node.value || detail !== node.detail) {
289
+ node.detail = detail;
290
+ node.value = next;
291
+ node.runs++;
292
+ node.lastPulse = now;
293
+ changed.push(node.id);
294
+ }
295
+ runsAtLastSample.set(node.id, node.runs);
296
+ }
297
+ return changed;
298
+ },
299
+ dispose() {
300
+ dispose();
301
+ dispose = () => {
302
+ };
303
+ }
304
+ };
305
+ }
306
+
307
+ export {
308
+ KIND_OF_BUILTIN,
309
+ nodeVersion,
310
+ nodeState,
311
+ fmt,
312
+ short,
313
+ createReactor
314
+ };