@solidjs/web 2.0.0-rc.2 → 2.0.0-rc.20
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/README.md +1 -1
- package/dist/server.dev.js +5065 -0
- package/dist/server.js +1757 -355
- package/dist/{server.cjs → server.observe.js} +1951 -558
- package/dist/{dev.cjs → web.dev.js} +945 -550
- package/dist/web.js +635 -332
- package/dist/{dev.js → web.observe.js} +688 -403
- package/frames/dist/assets.js +92 -0
- package/frames/dist/client.dev.js +1296 -1198
- package/frames/dist/client.js +1128 -1191
- package/frames/dist/client.observe.js +2041 -0
- package/frames/dist/regions.js +171 -0
- package/frames/dist/server.dev.js +2549 -0
- package/frames/dist/server.js +1688 -3005
- package/frames/dist/server.observe.js +2548 -0
- package/frames/dist/trace.js +45 -0
- package/frames/dist/wire.js +594 -0
- package/frames/package.json +2 -25
- package/package.json +244 -256
- package/performance-tracks/dist/performance-tracks.dev.js +679 -0
- package/performance-tracks/dist/performance-tracks.js +6 -0
- package/performance-tracks/dist/performance-tracks.observe.js +667 -0
- package/performance-tracks/package.json +7 -0
- package/performance-tracks/types/index.d.ts +69 -0
- package/serialization/decode/package.json +2 -15
- package/serialization/dist/decode.js +121 -25
- package/serialization/dist/serialization.js +242 -88
- package/serialization/package.json +2 -15
- package/serialization/types/index.d.ts +85 -158
- package/serialization/types/serializer-decode.d.ts +173 -114
- package/serialization/types/serializer.d.ts +109 -0
- package/server-functions/dist/client.dev.js +1462 -0
- package/server-functions/dist/client.js +667 -165
- package/server-functions/dist/client.observe.js +1441 -0
- package/server-functions/dist/rich-args.js +84 -1
- package/server-functions/dist/server.dev.js +2714 -297
- package/server-functions/dist/server.js +2595 -271
- package/server-functions/dist/server.observe.js +3594 -0
- package/server-functions/package.json +2 -35
- package/server-functions/rich-args/package.json +2 -15
- package/skills/server-components/SKILL.md +117 -0
- package/storage/package.json +2 -15
- package/types/client.d.ts +342 -288
- package/types/constants.d.ts +22 -0
- package/types/cookies.d.ts +32 -84
- package/types/diagnostics.d.ts +80 -0
- package/types/frames/assets-tier.d.ts +78 -0
- package/types/frames/client.d.ts +40 -1
- package/types/frames/frame-client.d.ts +443 -280
- package/types/frames/frame-container-plugin.d.ts +64 -0
- package/types/frames/frame-morph.d.ts +29 -0
- package/types/frames/frame-sink.d.ts +141 -161
- package/types/frames/frame-transport.d.ts +263 -184
- package/types/frames/regions-tier.d.ts +60 -0
- package/types/frames/serializer-decode.d.ts +241 -0
- package/types/frames/serializer.d.ts +85 -158
- package/types/frames/server.d.ts +2 -2
- package/types/frames/trace-tier.d.ts +2 -0
- package/types/frames/tree-rewrite.d.ts +39 -0
- package/types/frames/wire-tier.d.ts +169 -0
- package/types/head.d.ts +20 -0
- package/types/index.d.ts +98 -81
- package/types/index.server.d.ts +159 -0
- package/types/jsx.d.ts +49 -44
- package/types/observe.d.ts +535 -0
- package/types/reconcile.d.ts +1 -0
- package/types/render.d.ts +11 -0
- package/types/request-error-hook.d.ts +5 -0
- package/types/response.d.ts +95 -147
- package/types/serializer-decode.d.ts +173 -114
- package/types/serializer.d.ts +85 -158
- package/types/server-functions/argument-codec.d.ts +30 -0
- package/types/server-functions/client.d.ts +238 -223
- package/types/server-functions/flash.d.ts +28 -30
- package/types/server-functions/registry.d.ts +105 -0
- package/types/server-functions/rich-args.d.ts +1 -10
- package/types/server-functions/server.d.ts +539 -531
- package/types/server-functions/shared.d.ts +398 -425
- package/types/server-functions/uploads.d.ts +50 -0
- package/types/server-mock.d.ts +120 -13
- package/types/server-observe.d.ts +86 -0
- package/types/server.d.ts +571 -422
- package/types/trace.d.ts +127 -0
- package/LICENSE +0 -21
- package/dist/web.cjs +0 -2033
- package/frames/dist/client.cjs +0 -2002
- package/frames/dist/client.dev.cjs +0 -2022
- package/frames/dist/server.cjs +0 -3877
- package/serialization/dist/decode.cjs +0 -139
- package/serialization/dist/serialization.cjs +0 -261
- package/serialization/types-cjs/index.d.cts +0 -182
- package/serialization/types-cjs/package.json +0 -3
- package/serialization/types-cjs/serializer-decode.d.cts +0 -182
- package/server-functions/dist/client.cjs +0 -834
- package/server-functions/dist/rich-args.cjs +0 -11
- package/server-functions/dist/server.cjs +0 -1242
- package/server-functions/dist/server.dev.cjs +0 -1242
- package/storage/dist/storage.cjs +0 -12
- package/storage/types-cjs/index.d.cts +0 -28
- package/storage/types-cjs/package.json +0 -3
- package/types/core.d.ts +0 -9
- package/types-cjs/client.d.cts +0 -337
- package/types-cjs/cookies.d.cts +0 -93
- package/types-cjs/core.d.cts +0 -9
- package/types-cjs/frames/client.d.cts +0 -36
- package/types-cjs/frames/frame-client.d.cts +0 -356
- package/types-cjs/frames/frame-sink.d.cts +0 -194
- package/types-cjs/frames/frame-transport.d.cts +0 -222
- package/types-cjs/frames/serializer.d.cts +0 -182
- package/types-cjs/frames/server.d.cts +0 -52
- package/types-cjs/index.d.cts +0 -244
- package/types-cjs/jsx-properties.d.cts +0 -93
- package/types-cjs/jsx.d.cts +0 -4159
- package/types-cjs/package.json +0 -3
- package/types-cjs/response.d.cts +0 -174
- package/types-cjs/serializer-decode.d.cts +0 -182
- package/types-cjs/serializer.d.cts +0 -182
- package/types-cjs/server-functions/client.d.cts +0 -262
- package/types-cjs/server-functions/flash.d.cts +0 -38
- package/types-cjs/server-functions/rich-args.d.cts +0 -10
- package/types-cjs/server-functions/server.d.cts +0 -681
- package/types-cjs/server-functions/shared.d.cts +0 -523
- package/types-cjs/server-mock.d.cts +0 -286
- package/types-cjs/server.d.cts +0 -544
|
@@ -0,0 +1,667 @@
|
|
|
1
|
+
import { OBSERVE } from 'solid-js';
|
|
2
|
+
import { attribution, formatRerun, formatOrigin } from 'solid-js/attribution';
|
|
3
|
+
|
|
4
|
+
const IS_DEV = false;
|
|
5
|
+
const GROUP = "Solid";
|
|
6
|
+
const TRACKS = {
|
|
7
|
+
interactions: "Interactions",
|
|
8
|
+
propagation: "Propagation",
|
|
9
|
+
effects: "Effects",
|
|
10
|
+
memos: "Memos",
|
|
11
|
+
async: "Async",
|
|
12
|
+
holds: "Holds",
|
|
13
|
+
navigations: "Navigations",
|
|
14
|
+
server: "Server"
|
|
15
|
+
};
|
|
16
|
+
const noop = () => {};
|
|
17
|
+
function enablePerformanceTracks(options = {}) {
|
|
18
|
+
if (instance !== null) return instance.join();
|
|
19
|
+
const observe = OBSERVE;
|
|
20
|
+
if (observe === undefined) return noop;
|
|
21
|
+
if (typeof performance !== "object" || typeof performance.now !== "function") return noop;
|
|
22
|
+
const emitter = createEmitter(options.rich ?? IS_DEV);
|
|
23
|
+
if (emitter === undefined) return noop;
|
|
24
|
+
const minMs = options.minMs ?? (0.05);
|
|
25
|
+
const painter = new Painter(emitter, minMs);
|
|
26
|
+
const server = new ServerSpans(emitter);
|
|
27
|
+
server.start();
|
|
28
|
+
const {
|
|
29
|
+
records
|
|
30
|
+
} = observe;
|
|
31
|
+
const releases = [() => server.dispose(), attribution.enable({
|
|
32
|
+
log: false,
|
|
33
|
+
...options.attribution,
|
|
34
|
+
checks: options.attribution?.checks ?? false
|
|
35
|
+
}), records.subscribe("rerun", (e, node) => painter.rerun(e, node)), records.subscribe("create", (e, node) => painter.create(e, node)), records.subscribe("effect", (e, node) => painter.effect(e, node)), records.subscribe("flush", e => painter.flush(e)), records.subscribe("flight", (e, node) => painter.flight(e, node)), records.subscribe("fallback", (e, subtree) => painter.fallback(e, subtree)), records.subscribe("interaction", e => painter.interaction(e)), records.subscribe("hold", e => painter.hold(e)), records.subscribe("navigation", e => painter.navigation(e)), records.subscribe("call", (e, live) => {
|
|
36
|
+
painter.call(e);
|
|
37
|
+
server.call(e, live);
|
|
38
|
+
}), records.subscribe("frame", e => painter.frame(e)), observe.diagnostics.subscribe((e, subject) => painter.diagnostic(e, subject))];
|
|
39
|
+
const active = {
|
|
40
|
+
holders: 0,
|
|
41
|
+
join() {
|
|
42
|
+
active.holders++;
|
|
43
|
+
let held = true;
|
|
44
|
+
return () => {
|
|
45
|
+
if (!held) return;
|
|
46
|
+
held = false;
|
|
47
|
+
if (--active.holders > 0 || instance !== active) return;
|
|
48
|
+
instance = null;
|
|
49
|
+
for (const release of releases) release();
|
|
50
|
+
emitter.dispose();
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
instance = active;
|
|
55
|
+
return active.join();
|
|
56
|
+
}
|
|
57
|
+
let instance = null;
|
|
58
|
+
function createEmitter(rich) {
|
|
59
|
+
const hasMeasure = typeof performance.measure === "function";
|
|
60
|
+
const hasTimeStamp = typeof console !== "undefined" && typeof console.timeStamp === "function";
|
|
61
|
+
let emitter;
|
|
62
|
+
if (rich && hasMeasure || !hasTimeStamp && hasMeasure) {
|
|
63
|
+
const names = new Map();
|
|
64
|
+
const markNames = new Map();
|
|
65
|
+
let pending = 0;
|
|
66
|
+
const clear = () => {
|
|
67
|
+
pending = 0;
|
|
68
|
+
clearOwned(names, "measure", performance.clearMeasures);
|
|
69
|
+
clearOwned(markNames, "mark", performance.clearMarks);
|
|
70
|
+
};
|
|
71
|
+
const hasMark = typeof performance.mark === "function";
|
|
72
|
+
emitter = {
|
|
73
|
+
rich: true,
|
|
74
|
+
span(label, start, end, track, color, tooltip, properties, task) {
|
|
75
|
+
const devtools = {
|
|
76
|
+
dataType: "track-entry",
|
|
77
|
+
track,
|
|
78
|
+
trackGroup: GROUP,
|
|
79
|
+
color
|
|
80
|
+
};
|
|
81
|
+
if (tooltip !== undefined) devtools.tooltipText = tooltip;
|
|
82
|
+
if (properties !== undefined) devtools.properties = properties;
|
|
83
|
+
const measure = () => performance.measure(label, {
|
|
84
|
+
start,
|
|
85
|
+
end,
|
|
86
|
+
detail: {
|
|
87
|
+
devtools
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
if (!guarded(measure, task)) return;
|
|
91
|
+
names.set(label, (names.get(label) ?? 0) + 1);
|
|
92
|
+
if (++pending >= CLEAR_EVERY) clear();
|
|
93
|
+
},
|
|
94
|
+
mark(label, color, tooltip, properties, issue, task) {
|
|
95
|
+
if (!hasMark) return;
|
|
96
|
+
const devtools = {
|
|
97
|
+
dataType: "marker",
|
|
98
|
+
color
|
|
99
|
+
};
|
|
100
|
+
if (tooltip !== undefined) devtools.tooltipText = tooltip;
|
|
101
|
+
if (properties !== undefined) devtools.properties = properties;
|
|
102
|
+
if (issue !== undefined) devtools.performanceIssue = issue;
|
|
103
|
+
const mark = () => performance.mark(label, {
|
|
104
|
+
detail: {
|
|
105
|
+
devtools
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
if (!guarded(mark, task)) return;
|
|
109
|
+
markNames.set(label, (markNames.get(label) ?? 0) + 1);
|
|
110
|
+
if (++pending >= CLEAR_EVERY) clear();
|
|
111
|
+
},
|
|
112
|
+
dispose: clear
|
|
113
|
+
};
|
|
114
|
+
} else if (hasTimeStamp) {
|
|
115
|
+
const timeStamp = console.timeStamp;
|
|
116
|
+
emitter = {
|
|
117
|
+
rich: false,
|
|
118
|
+
span(label, start, end, track, color, _tooltip, _properties, task) {
|
|
119
|
+
guarded(() => timeStamp(label, start, end, track, GROUP, color), task);
|
|
120
|
+
},
|
|
121
|
+
mark(label, _color, _tooltip, _properties, _issue, task) {
|
|
122
|
+
guarded(() => timeStamp(label), task);
|
|
123
|
+
},
|
|
124
|
+
dispose: noop
|
|
125
|
+
};
|
|
126
|
+
} else return undefined;
|
|
127
|
+
for (const track of Object.values(TRACKS)) {
|
|
128
|
+
emitter.span(track, SEED_AT, SEED_AT, track, "primary-light");
|
|
129
|
+
}
|
|
130
|
+
return emitter;
|
|
131
|
+
}
|
|
132
|
+
const SEED_AT = 0.003;
|
|
133
|
+
const CLEAR_EVERY = 500;
|
|
134
|
+
function guarded(fn, task) {
|
|
135
|
+
try {
|
|
136
|
+
task !== undefined ? task.run(fn) : fn();
|
|
137
|
+
return true;
|
|
138
|
+
} catch (error) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function clearOwned(owned, type, clearFn) {
|
|
143
|
+
if (typeof clearFn !== "function" || typeof performance.getEntriesByName !== "function") {
|
|
144
|
+
owned.clear();
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
for (const [name, count] of owned) {
|
|
148
|
+
if (performance.getEntriesByName(name, type).length <= count) {
|
|
149
|
+
clearFn.call(performance, name);
|
|
150
|
+
owned.delete(name);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
class Painter {
|
|
155
|
+
roots = new Set();
|
|
156
|
+
unchanged = 0;
|
|
157
|
+
names = new Map();
|
|
158
|
+
constructor(emit, minMs) {
|
|
159
|
+
this.emit = emit;
|
|
160
|
+
this.minMs = minMs;
|
|
161
|
+
this.rich = emit.rich;
|
|
162
|
+
}
|
|
163
|
+
rerun(event, subject) {
|
|
164
|
+
collectRoots(event.causes, this.roots);
|
|
165
|
+
if (!event.changed) this.unchanged++;
|
|
166
|
+
const node = describe(event.nodeName, OBSERVE.ownerPath(subject));
|
|
167
|
+
this.names.set(event.nodeId, node.short);
|
|
168
|
+
if (event.totalMs < this.minMs) return;
|
|
169
|
+
const track = event.nodeKind === "effect" ? TRACKS.effects : TRACKS.memos;
|
|
170
|
+
const color = event.phase === "optimistic" ? "tertiary" : !event.changed ? "warning" : bySelfTime(event.selfMs);
|
|
171
|
+
let tooltip;
|
|
172
|
+
let properties;
|
|
173
|
+
if (this.rich) {
|
|
174
|
+
tooltip = formatRerun(event);
|
|
175
|
+
properties = [["Run", `${event.run} (run ${event.nodeRuns} of this node)`], ["Self time", ms(event.selfMs)], ["Total time", ms(event.totalMs)], ["Changed", event.changed ? "yes" : "no — unchanged (wasted)"], ["Phase", event.phase + (event.held ? ", held" : "")], ["Deps", String(event.depCount)]];
|
|
176
|
+
this.identity(properties, node, event.nodeId);
|
|
177
|
+
if (event.depsAdded.length > 0) properties.push(["Deps added", event.depsAdded.join(", ")]);
|
|
178
|
+
if (event.depsRemoved.length > 0) properties.push(["Deps removed", event.depsRemoved.join(", ")]);
|
|
179
|
+
if (event.causes.length > 0) properties.push(["Causes", event.causes.map(rootCause).join("; ")]);
|
|
180
|
+
const origin = rootOrigin(event.causes);
|
|
181
|
+
if (origin !== undefined && origin !== event.interaction) properties.push(["Origin", this.origin(origin)]);
|
|
182
|
+
if (event.interaction !== undefined) properties.push(["Interaction", this.origin(event.interaction)]);
|
|
183
|
+
}
|
|
184
|
+
const end = event.at + event.totalMs;
|
|
185
|
+
const task = taskOf();
|
|
186
|
+
this.emit.span(node.label, event.at, end, track, color, tooltip, properties, task);
|
|
187
|
+
this.emit.span(`${node.label} ← ${this.causeLabels(event.causes)}`, event.at, end, TRACKS.propagation, color, tooltip, properties, task);
|
|
188
|
+
}
|
|
189
|
+
create(event, subject) {
|
|
190
|
+
const node = describe(event.nodeName, OBSERVE.ownerPath(subject));
|
|
191
|
+
this.names.set(event.nodeId, node.short);
|
|
192
|
+
if (event.totalMs < this.minMs) return;
|
|
193
|
+
let properties;
|
|
194
|
+
if (this.rich) {
|
|
195
|
+
properties = [["Self time", ms(event.selfMs)], ["Total time", ms(event.totalMs)], ["Phase", event.phase + (event.held ? ", held" : "")], ["Deps", String(event.depCount)]];
|
|
196
|
+
this.identity(properties, node, event.nodeId);
|
|
197
|
+
if (event.interaction !== undefined) properties.push(["Interaction", this.origin(event.interaction)]);
|
|
198
|
+
}
|
|
199
|
+
const label = `${node.label} · create`;
|
|
200
|
+
const end = event.at + event.totalMs;
|
|
201
|
+
const color = event.phase === "optimistic" ? "tertiary" : bySelfTime(event.selfMs);
|
|
202
|
+
const task = taskOf();
|
|
203
|
+
this.emit.span(label, event.at, end, event.nodeKind === "effect" ? TRACKS.effects : TRACKS.memos, color, undefined, properties, task);
|
|
204
|
+
this.emit.span(label, event.at, end, TRACKS.propagation, color, undefined, properties, task);
|
|
205
|
+
}
|
|
206
|
+
effect(event, subject) {
|
|
207
|
+
if (event.durationMs < this.minMs) return;
|
|
208
|
+
const node = describe(event.nodeName, OBSERVE.ownerPath(subject));
|
|
209
|
+
let properties;
|
|
210
|
+
if (this.rich) {
|
|
211
|
+
properties = [["Duration", ms(event.durationMs)]];
|
|
212
|
+
this.identity(properties, node, event.nodeId);
|
|
213
|
+
if (event.run !== undefined) properties.push(["Run", String(event.run)]);
|
|
214
|
+
if (event.interaction !== undefined) properties.push(["Interaction", this.origin(event.interaction)]);
|
|
215
|
+
}
|
|
216
|
+
const label = `${node.label} · callback`;
|
|
217
|
+
const end = event.at + event.durationMs;
|
|
218
|
+
const color = event.durationMs < 10 ? "secondary-light" : event.durationMs < 100 ? "secondary" : "error";
|
|
219
|
+
const task = taskOf();
|
|
220
|
+
this.emit.span(label, event.at, end, TRACKS.effects, color, undefined, properties, task);
|
|
221
|
+
this.emit.span(label, event.at, end, TRACKS.propagation, color, undefined, properties, task);
|
|
222
|
+
}
|
|
223
|
+
diagnostic(event, subject) {
|
|
224
|
+
const owner = event.ownerPath?.join(" › ");
|
|
225
|
+
const label = event.ownerPath !== undefined ? `${event.code} — ${nearest(event.ownerPath).join(" › ")}` : event.code;
|
|
226
|
+
const color = event.severity === "error" ? "error" : event.severity === "warn" ? "warning" : "primary-light";
|
|
227
|
+
let tooltip;
|
|
228
|
+
let properties;
|
|
229
|
+
let issue;
|
|
230
|
+
if (this.rich) {
|
|
231
|
+
tooltip = event.message;
|
|
232
|
+
properties = [["Code", event.code], ["Kind", event.kind], ["Severity", event.severity]];
|
|
233
|
+
if (owner !== undefined) properties.push(["Owner path", owner]);
|
|
234
|
+
if (event.nodeName !== undefined) properties.push(["Node", event.nodeName]);
|
|
235
|
+
properties.push(["Message", event.message]);
|
|
236
|
+
if (event.data !== undefined) {
|
|
237
|
+
for (const [key, value] of Object.entries(event.data)) {
|
|
238
|
+
if (typeof value === "number") properties.push([key, Number.isInteger(value) ? String(value) : value.toFixed(2)]);else if (typeof value === "string" || typeof value === "boolean") properties.push([key, String(value)]);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
const guide = undefined;
|
|
242
|
+
if (event.severity !== "info") {
|
|
243
|
+
issue = {
|
|
244
|
+
name: `Solid: ${event.code}`,
|
|
245
|
+
severity: event.severity === "error" ? "error" : "warning",
|
|
246
|
+
description: tooltip,
|
|
247
|
+
learnMoreUrl: guide
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
this.emit.mark(label, color, tooltip, properties, issue, taskOf());
|
|
252
|
+
}
|
|
253
|
+
identity(properties, node, nodeId) {
|
|
254
|
+
if (node.path !== undefined) properties.push(["Owner path", node.path]);
|
|
255
|
+
if (node.internal !== undefined) properties.push(["Node", node.internal]);
|
|
256
|
+
properties.push(["Node id", String(nodeId)]);
|
|
257
|
+
}
|
|
258
|
+
flush(event) {
|
|
259
|
+
const roots = [...this.roots];
|
|
260
|
+
const unchanged = this.unchanged;
|
|
261
|
+
this.roots.clear();
|
|
262
|
+
this.unchanged = 0;
|
|
263
|
+
this.names.clear();
|
|
264
|
+
let label = roots.length > 0 ? this.writes(roots, 3) : "flush";
|
|
265
|
+
const origin = event.interaction ?? roots.map(r => r.origin).find(o => o !== undefined && o.kind !== "external");
|
|
266
|
+
if (origin !== undefined) label += ` — ${this.origin(origin)}`;
|
|
267
|
+
label += ` · ${event.runs} ${event.runs === 1 ? "run" : "runs"}`;
|
|
268
|
+
if (unchanged > 0) label += `, ${unchanged} unchanged`;
|
|
269
|
+
if (event.created > 0) label += `, ${event.created} created`;
|
|
270
|
+
if (event.held) label += " · held";
|
|
271
|
+
let properties;
|
|
272
|
+
if (this.rich) {
|
|
273
|
+
properties = [["Duration", ms(event.durationMs)], ["Writes", roots.length > 0 ? this.writes(roots, Infinity) : "none"], ["Re-runs", String(event.runs)], ["Unchanged", `${unchanged} (wasted)`], ["Created", String(event.created)], ["Held", event.held ? "yes — a transition parked" : "no"]];
|
|
274
|
+
if (event.interaction !== undefined) properties.push(["Interaction", this.origin(event.interaction)]);
|
|
275
|
+
}
|
|
276
|
+
this.emit.span(label, event.at, event.at + event.durationMs, TRACKS.propagation, event.held ? "tertiary" : unchanged > 0 && unchanged * 2 >= event.runs ? "warning" : event.durationMs < 16 ? "primary" : "primary-dark", undefined, properties);
|
|
277
|
+
}
|
|
278
|
+
flight(event, subject) {
|
|
279
|
+
const node = describe(event.nodeName, event.ownerPath);
|
|
280
|
+
let properties;
|
|
281
|
+
if (this.rich) {
|
|
282
|
+
properties = [["In the air", ms(event.durationMs)], ["Outcome", event.outcome]];
|
|
283
|
+
if (node.path !== undefined) properties.push(["Owner path", node.path]);
|
|
284
|
+
if (node.internal !== undefined) properties.push(["Node", node.internal]);
|
|
285
|
+
if (event.interaction !== undefined) properties.push(["Interaction", this.origin(event.interaction)]);
|
|
286
|
+
}
|
|
287
|
+
this.emit.span(`${node.label}${event.outcome === "abandoned" ? " · abandoned" : ""}`, event.at, event.at + event.durationMs, TRACKS.async, event.outcome === "abandoned" ? "warning" : "secondary", undefined, properties, taskOf());
|
|
288
|
+
}
|
|
289
|
+
fallback(event, subject) {
|
|
290
|
+
const path = event.ownerPath;
|
|
291
|
+
const label = `fallback${path !== undefined ? ` ${nearest(path).join(" › ")}` : ""}`;
|
|
292
|
+
let properties;
|
|
293
|
+
if (this.rich) {
|
|
294
|
+
properties = [["Shown", ms(event.shownMs)]];
|
|
295
|
+
if (path !== undefined && nearest(path).length !== path.length) properties.push(["Owner path", path.join(" › ")]);
|
|
296
|
+
if (event.interaction !== undefined) properties.push(["Interaction", this.origin(event.interaction)]);
|
|
297
|
+
}
|
|
298
|
+
this.emit.span(label, event.at, event.at + event.shownMs, TRACKS.async, "tertiary", undefined, properties, taskOf());
|
|
299
|
+
}
|
|
300
|
+
interaction(event) {
|
|
301
|
+
const label = this.origin(event.origin);
|
|
302
|
+
const handlerStart = event.at + (event.inputDelayMs ?? 0);
|
|
303
|
+
const handlerEnd = handlerStart + event.handlerMs;
|
|
304
|
+
let properties;
|
|
305
|
+
if (this.rich) {
|
|
306
|
+
properties = [["Handler", ms(event.handlerMs)], ["Writes", String(event.writes)], ["Re-runs", `${event.runs} (${ms(event.runMs)} self time)`], ["Created", String(event.created)]];
|
|
307
|
+
if (event.inputDelayMs !== undefined) properties.unshift(["Input delay", ms(event.inputDelayMs)]);
|
|
308
|
+
if (event.settledMs !== undefined) properties.push(["Settled", ms(event.settledMs)]);
|
|
309
|
+
if (event.outcome !== undefined) properties.push(["Outcome", event.outcome]);
|
|
310
|
+
if (event.holds.length > 0) properties.push(["Holds", String(event.holds.length)]);
|
|
311
|
+
if (event.navigations.length > 0) properties.push(["Navigations", event.navigations.map(n => this.origin(n.origin)).join("; ")]);
|
|
312
|
+
}
|
|
313
|
+
if (event.inputDelayMs !== undefined && event.inputDelayMs > 0) {
|
|
314
|
+
this.emit.span("input delay", event.at, handlerStart, TRACKS.interactions, "primary-light");
|
|
315
|
+
}
|
|
316
|
+
this.emit.span(label, handlerStart, handlerEnd, TRACKS.interactions, "primary", undefined, properties);
|
|
317
|
+
const outcome = event.outcome;
|
|
318
|
+
if (event.settledMs === undefined || outcome === undefined || outcome === "idle") return;
|
|
319
|
+
const settleEnd = event.at + event.settledMs;
|
|
320
|
+
if (settleEnd <= handlerEnd) return;
|
|
321
|
+
const silent = outcome === "held" && event.holds.some(h => h.silent);
|
|
322
|
+
this.emit.span(outcome, handlerEnd, settleEnd, TRACKS.interactions, silent ? "warning" : outcome === "held" ? "tertiary" : "secondary-light", undefined, this.rich ? [["Settled", ms(event.settledMs)]] : undefined);
|
|
323
|
+
}
|
|
324
|
+
hold(event) {
|
|
325
|
+
const {
|
|
326
|
+
long,
|
|
327
|
+
silent
|
|
328
|
+
} = event;
|
|
329
|
+
const what = event.blockers.length > 0 ? event.blockers.join(", ") : "a transition";
|
|
330
|
+
const label = event.origin !== undefined ? `${this.origin(event.origin)} — waiting on ${what}` : `waiting on ${what}`;
|
|
331
|
+
let properties;
|
|
332
|
+
if (this.rich) {
|
|
333
|
+
properties = [["Held", ms(event.holdMs)], ["Tail", `${ms(event.tailMs)} (last write → commit)`], ["Flushes", String(event.flushes)], ["Held writes", event.heldWrites.map(heldWrite).join(", ") || "none"], ["Acknowledged by", event.acknowledgements.map(a => `${a.kind}(${a.source})`).join(", ") || "nothing"], ["Painted during hold", String(event.paintedDuringHold)]];
|
|
334
|
+
if (silent) properties.push(["Verdict", "silent hold — no feedback while waiting"]);
|
|
335
|
+
if (long) properties.push(["Verdict", "long hold"]);
|
|
336
|
+
if (event.action) properties.push(["Action", "yes"]);
|
|
337
|
+
if (event.interaction !== undefined) properties.push(["Interaction", this.origin(event.interaction)]);
|
|
338
|
+
}
|
|
339
|
+
this.emit.span(label, event.at, event.at + event.holdMs, TRACKS.holds, long ? "error" : silent ? "warning" : "tertiary", undefined, properties);
|
|
340
|
+
}
|
|
341
|
+
navigation(event) {
|
|
342
|
+
if (event.settledMs === undefined) return;
|
|
343
|
+
let properties;
|
|
344
|
+
if (this.rich) {
|
|
345
|
+
properties = [["Settled", ms(event.settledMs)], ["Writes", String(event.writes)]];
|
|
346
|
+
if (event.to !== undefined) properties.push(["To", event.to]);
|
|
347
|
+
if (event.from !== undefined) properties.push(["From", event.from]);
|
|
348
|
+
if (event.params !== undefined) {
|
|
349
|
+
const params = Object.entries(event.params).filter(([, v]) => v !== undefined).map(([k, v]) => `${k}=${v}`).join(", ");
|
|
350
|
+
if (params) properties.push(["Params", params]);
|
|
351
|
+
}
|
|
352
|
+
if (event.redirects !== undefined) properties.push(["Redirected from", event.redirects.map(hop => hop.to ?? hop.name ?? "?").join(" → ")]);
|
|
353
|
+
if (event.outcome !== undefined) properties.push(["Outcome", event.outcome]);
|
|
354
|
+
if (event.interaction !== undefined) properties.push(["Interaction", this.origin(event.interaction)]);
|
|
355
|
+
}
|
|
356
|
+
this.emit.span(formatOrigin(event.origin), event.at, event.at + event.settledMs, TRACKS.navigations, event.outcome === "superseded" ? "secondary-light" : event.outcome === "held" ? "tertiary" : "secondary", undefined, properties);
|
|
357
|
+
}
|
|
358
|
+
call(event) {
|
|
359
|
+
let label = `${event.method} ${event.id}`;
|
|
360
|
+
if (event.status !== undefined) label += ` · ${event.status}`;
|
|
361
|
+
let properties;
|
|
362
|
+
if (this.rich) {
|
|
363
|
+
properties = [["Duration", ms(event.durationMs)], ["Outcome", event.outcome]];
|
|
364
|
+
if (event.status !== undefined) properties.push(["Status", String(event.status)]);
|
|
365
|
+
if (event.deferred) properties.push(["Deferred", "the body is consumed by the caller"]);
|
|
366
|
+
if (event.origin !== undefined) properties.push(["Origin", this.origin(event.origin)]);
|
|
367
|
+
}
|
|
368
|
+
this.emit.span(label, event.at, event.at + event.durationMs, TRACKS.server, event.outcome === "error" ? "error" : "secondary", undefined, properties);
|
|
369
|
+
}
|
|
370
|
+
frame(event) {
|
|
371
|
+
if (event.side !== "client") return;
|
|
372
|
+
const label = `frame ${event.id || "(unnamed)"}`;
|
|
373
|
+
let properties;
|
|
374
|
+
if (this.rich) {
|
|
375
|
+
properties = [["Duration", ms(event.durationMs)], ["Outcome", event.outcome], ["Chunks", String(event.chunks)], ["Fragments", String(event.fragments)], ["Slots", String(event.slots)], ["Regions", String(event.regions)], ["Errors", String(event.errors)], ["Version", String(event.version)]];
|
|
376
|
+
if (event.shellMs !== undefined) properties.splice(1, 0, ["Shell", ms(event.shellMs)]);
|
|
377
|
+
if (event.address !== undefined) properties.push(["Applied as", event.address]);
|
|
378
|
+
}
|
|
379
|
+
if (event.shellMs !== undefined && event.shellMs > 0) {
|
|
380
|
+
this.emit.span(`${label} · shell`, event.at, event.at + event.shellMs, TRACKS.server, "secondary-light");
|
|
381
|
+
}
|
|
382
|
+
this.emit.span(label, event.at, event.at + event.durationMs, TRACKS.server, event.outcome === "complete" ? "secondary" : "error", undefined, properties);
|
|
383
|
+
}
|
|
384
|
+
causeLabels(causes) {
|
|
385
|
+
const labels = new Set();
|
|
386
|
+
for (const c of causes) {
|
|
387
|
+
const name = (c.kind === "derived" && c.nodeId !== undefined ? this.names.get(c.nodeId) : undefined) ?? c.name;
|
|
388
|
+
labels.add(c.kind === "async" ? `${name} landed` : c.kind === "refresh" ? `refresh ${name}` : name);
|
|
389
|
+
}
|
|
390
|
+
return [...labels].join(", ");
|
|
391
|
+
}
|
|
392
|
+
writes(roots, limit) {
|
|
393
|
+
const shown = roots.slice(0, limit).map(r => {
|
|
394
|
+
let out = r.kind === "async" ? `${r.name} landed` : r.kind === "refresh" ? `refresh ${r.name}` : r.name;
|
|
395
|
+
if (r.prev !== undefined) out += ` ${r.prev} → ${r.value}`;
|
|
396
|
+
return out;
|
|
397
|
+
});
|
|
398
|
+
if (roots.length > limit) shown.push(`+${roots.length - limit} more`);
|
|
399
|
+
return shown.join(", ");
|
|
400
|
+
}
|
|
401
|
+
origin(origin) {
|
|
402
|
+
return formatOrigin(origin);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
const FLOW_INTERNALS = {
|
|
406
|
+
"<Show>": new Set(["condition value", "condition", "value"]),
|
|
407
|
+
"<Switch>": new Set(["children", "conditions", "condition value", "condition", "eval conditions"]),
|
|
408
|
+
"<Loading>": new Set(["children", "boundary", "value"]),
|
|
409
|
+
"<Errored>": new Set(["children", "boundary", "value"]),
|
|
410
|
+
"<Reveal>": new Set(["reveal order"])
|
|
411
|
+
};
|
|
412
|
+
const FLOW_TAGS = new Set(["<Show>", "<For>", "<Repeat>", "<Switch>", "<Match>", "<Errored>", "<Loading>", "<Reveal>", "<Portal>", "<Dynamic>"]);
|
|
413
|
+
function nearest(segments) {
|
|
414
|
+
for (let i = segments.length - 1; i > 0; i--) {
|
|
415
|
+
const s = segments[i];
|
|
416
|
+
if (s.charCodeAt(0) === 60 && !FLOW_TAGS.has(s)) return segments.slice(i);
|
|
417
|
+
}
|
|
418
|
+
return segments;
|
|
419
|
+
}
|
|
420
|
+
function describe(nodeName, path) {
|
|
421
|
+
const full = path === undefined ? [nodeName] : path[path.length - 1] === nodeName ? path : [...path, nodeName];
|
|
422
|
+
const segments = [];
|
|
423
|
+
let flow;
|
|
424
|
+
let internal;
|
|
425
|
+
for (let i = 0; i < full.length; i++) {
|
|
426
|
+
const name = full[i];
|
|
427
|
+
let shown;
|
|
428
|
+
if (flow !== undefined && flow.has(name)) {
|
|
429
|
+
internal = name;
|
|
430
|
+
} else {
|
|
431
|
+
flow = FLOW_INTERNALS[name];
|
|
432
|
+
const dot = name.indexOf(".");
|
|
433
|
+
if (dot > 0 && name.charCodeAt(0) !== 60 ) {
|
|
434
|
+
shown = name.slice(0, dot);
|
|
435
|
+
internal = name.slice(dot + 1);
|
|
436
|
+
} else {
|
|
437
|
+
shown = name;
|
|
438
|
+
internal = undefined;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
if (shown !== undefined && shown !== segments[segments.length - 1]) segments.push(shown);
|
|
442
|
+
}
|
|
443
|
+
const short = segments[segments.length - 1];
|
|
444
|
+
const label = nearest(segments).join(" › ");
|
|
445
|
+
const described = {
|
|
446
|
+
label,
|
|
447
|
+
short
|
|
448
|
+
};
|
|
449
|
+
if (internal !== undefined) described.internal = internal;
|
|
450
|
+
const runtimePath = full.join(" › ");
|
|
451
|
+
if (runtimePath !== label) described.path = runtimePath;
|
|
452
|
+
return described;
|
|
453
|
+
}
|
|
454
|
+
function taskOf(subject) {
|
|
455
|
+
return undefined;
|
|
456
|
+
}
|
|
457
|
+
function rootOrigin(causes) {
|
|
458
|
+
for (const c of causes) {
|
|
459
|
+
let root = c;
|
|
460
|
+
while (root.causes !== undefined && root.causes.length > 0) root = root.causes[0];
|
|
461
|
+
if (root.origin !== undefined && root.origin.kind !== "external") return root.origin;
|
|
462
|
+
}
|
|
463
|
+
return undefined;
|
|
464
|
+
}
|
|
465
|
+
function collectRoots(causes, out) {
|
|
466
|
+
for (const c of causes) {
|
|
467
|
+
if (c.kind === "derived") {
|
|
468
|
+
if (c.causes !== undefined) collectRoots(c.causes, out);
|
|
469
|
+
} else out.add(c);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
function bySelfTime(selfMs) {
|
|
473
|
+
return selfMs < 0.5 ? "primary-light" : selfMs < 10 ? "primary" : selfMs < 100 ? "primary-dark" : "error";
|
|
474
|
+
}
|
|
475
|
+
const SOLID_METRIC = /^solid-(invocation|shell|boundary)$/;
|
|
476
|
+
const PENDING_MS = 30_000;
|
|
477
|
+
class ServerSpans {
|
|
478
|
+
pending = [];
|
|
479
|
+
constructor(emit) {
|
|
480
|
+
this.emit = emit;
|
|
481
|
+
}
|
|
482
|
+
start() {
|
|
483
|
+
this.navigation();
|
|
484
|
+
if (typeof PerformanceObserver !== "function") return;
|
|
485
|
+
try {
|
|
486
|
+
const observer = new PerformanceObserver(list => this.resources(list.getEntries()));
|
|
487
|
+
observer.observe({
|
|
488
|
+
type: "resource",
|
|
489
|
+
buffered: true
|
|
490
|
+
});
|
|
491
|
+
this.observer = observer;
|
|
492
|
+
} catch {
|
|
493
|
+
this.observer = undefined;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
dispose() {
|
|
497
|
+
if (this.observer !== undefined) this.observer.disconnect();
|
|
498
|
+
this.observer = undefined;
|
|
499
|
+
this.pending.length = 0;
|
|
500
|
+
}
|
|
501
|
+
call(event, live) {
|
|
502
|
+
const response = live.response;
|
|
503
|
+
if (response === undefined) return;
|
|
504
|
+
let header;
|
|
505
|
+
try {
|
|
506
|
+
header = response.headers.get("server-timing");
|
|
507
|
+
} catch {
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
if (!header) return;
|
|
511
|
+
const metrics = parseServerTiming(header).filter(m => SOLID_METRIC.test(m.name));
|
|
512
|
+
if (metrics.length === 0) return;
|
|
513
|
+
if (this.observer === undefined) {
|
|
514
|
+
this.paint(metrics, event, undefined);
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
if (typeof performance.getEntriesByName === "function") {
|
|
518
|
+
const entry = findResource(performance.getEntriesByName(response.url, "resource"), event);
|
|
519
|
+
if (entry !== undefined) {
|
|
520
|
+
this.paint(metrics, event, entry);
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
this.pending.push({
|
|
525
|
+
event,
|
|
526
|
+
url: response.url,
|
|
527
|
+
metrics,
|
|
528
|
+
expires: performance.now() + PENDING_MS
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
resources(entries) {
|
|
532
|
+
const pending = this.pending;
|
|
533
|
+
if (pending.length === 0) return;
|
|
534
|
+
const now = performance.now();
|
|
535
|
+
for (let i = pending.length - 1; i >= 0; i--) {
|
|
536
|
+
const call = pending[i];
|
|
537
|
+
if (call.expires <= now) {
|
|
538
|
+
pending.splice(i, 1);
|
|
539
|
+
continue;
|
|
540
|
+
}
|
|
541
|
+
const entry = findResource(entries.filter(e => e.name === call.url), call.event);
|
|
542
|
+
if (entry === undefined) continue;
|
|
543
|
+
pending.splice(i, 1);
|
|
544
|
+
this.paint(call.metrics, call.event, entry);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
navigation() {
|
|
548
|
+
if (typeof performance.getEntriesByType !== "function") return;
|
|
549
|
+
const [nav] = performance.getEntriesByType("navigation");
|
|
550
|
+
if (nav === undefined || !Array.isArray(nav.serverTiming) || !(nav.responseStart > 0)) return;
|
|
551
|
+
const end = nav.responseStart;
|
|
552
|
+
const rich = this.emit.rich;
|
|
553
|
+
for (const metric of nav.serverTiming) {
|
|
554
|
+
if (!SOLID_METRIC.test(metric.name)) continue;
|
|
555
|
+
const kind = metric.name.slice(6);
|
|
556
|
+
const path = kind === "boundary" ? metric.description.split(" > ") : undefined;
|
|
557
|
+
const label = kind === "shell" ? "shell · server" : path !== undefined ? `boundary ${nearest(path).join(" › ")} · server` : `${metric.description} · server`;
|
|
558
|
+
let properties;
|
|
559
|
+
if (rich) {
|
|
560
|
+
properties = [["Duration", ms(metric.duration)], ["Source", "Server-Timing on the document"], ["Placement", kind === "shell" ? "ends at responseStart — the head left when the shell was ready" : "ends with the shell — settled at or before the flush"]];
|
|
561
|
+
if (path !== undefined && nearest(path).length !== path.length) properties.push(["Owner path", path.join(" › ")]);
|
|
562
|
+
}
|
|
563
|
+
this.emit.span(label, end - metric.duration, end, TRACKS.server, kind === "shell" ? "tertiary" : "tertiary-light", undefined, properties);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
paint(metrics, event, entry) {
|
|
567
|
+
const rich = this.emit.rich;
|
|
568
|
+
const end = entry !== undefined && entry.responseStart > 0 ? entry.responseStart : undefined;
|
|
569
|
+
const mid = event.at + event.durationMs / 2;
|
|
570
|
+
for (const metric of metrics) {
|
|
571
|
+
const start = end !== undefined ? end - metric.duration : mid - metric.duration / 2;
|
|
572
|
+
const stop = end !== undefined ? end : mid + metric.duration / 2;
|
|
573
|
+
const label = `${metric.description || event.id} · server`;
|
|
574
|
+
let properties;
|
|
575
|
+
if (rich) {
|
|
576
|
+
properties = [["Duration", ms(metric.duration)], ["Wire", ms(Math.max(0, event.durationMs - metric.duration))], ["Source", "Server-Timing"], ["Placement", end !== undefined ? "ends at the response's responseStart" : "centred in the call — no resource timing for this fetch"]];
|
|
577
|
+
}
|
|
578
|
+
this.emit.span(label, start, stop, TRACKS.server, "tertiary", undefined, properties);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
function findResource(entries, event) {
|
|
583
|
+
const from = event.at - 1;
|
|
584
|
+
const to = event.at + event.durationMs + 1;
|
|
585
|
+
for (const entry of entries) {
|
|
586
|
+
if (entry.startTime >= from && entry.startTime <= to) {
|
|
587
|
+
return entry;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
return undefined;
|
|
591
|
+
}
|
|
592
|
+
function parseServerTiming(value) {
|
|
593
|
+
const out = [];
|
|
594
|
+
let start = 0;
|
|
595
|
+
let quoted = false;
|
|
596
|
+
const take = end => {
|
|
597
|
+
const entry = value.slice(start, end).trim();
|
|
598
|
+
if (entry === "") return;
|
|
599
|
+
const parts = splitParams(entry);
|
|
600
|
+
const name = parts[0].trim().toLowerCase();
|
|
601
|
+
if (name === "") return;
|
|
602
|
+
let duration;
|
|
603
|
+
let description = "";
|
|
604
|
+
for (let i = 1; i < parts.length; i++) {
|
|
605
|
+
const eq = parts[i].indexOf("=");
|
|
606
|
+
if (eq === -1) continue;
|
|
607
|
+
const key = parts[i].slice(0, eq).trim().toLowerCase();
|
|
608
|
+
const raw = parts[i].slice(eq + 1).trim();
|
|
609
|
+
if (key === "dur") duration = Number(raw);else if (key === "desc") description = unquote(raw);
|
|
610
|
+
}
|
|
611
|
+
if (duration === undefined || !(duration >= 0)) return;
|
|
612
|
+
out.push({
|
|
613
|
+
name,
|
|
614
|
+
duration,
|
|
615
|
+
description
|
|
616
|
+
});
|
|
617
|
+
};
|
|
618
|
+
for (let i = 0; i < value.length; i++) {
|
|
619
|
+
const c = value[i];
|
|
620
|
+
if (quoted) {
|
|
621
|
+
if (c === "\\") i++;else if (c === '"') quoted = false;
|
|
622
|
+
} else if (c === '"') quoted = true;else if (c === ",") {
|
|
623
|
+
take(i);
|
|
624
|
+
start = i + 1;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
take(value.length);
|
|
628
|
+
return out;
|
|
629
|
+
}
|
|
630
|
+
function splitParams(entry) {
|
|
631
|
+
const parts = [];
|
|
632
|
+
let start = 0;
|
|
633
|
+
let quoted = false;
|
|
634
|
+
for (let i = 0; i < entry.length; i++) {
|
|
635
|
+
const c = entry[i];
|
|
636
|
+
if (quoted) {
|
|
637
|
+
if (c === "\\") i++;else if (c === '"') quoted = false;
|
|
638
|
+
} else if (c === '"') quoted = true;else if (c === ";") {
|
|
639
|
+
parts.push(entry.slice(start, i));
|
|
640
|
+
start = i + 1;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
parts.push(entry.slice(start));
|
|
644
|
+
return parts;
|
|
645
|
+
}
|
|
646
|
+
function unquote(raw) {
|
|
647
|
+
if (raw.length >= 2 && raw[0] === '"' && raw[raw.length - 1] === '"') {
|
|
648
|
+
return raw.slice(1, -1).replace(/\\(.)/g, "$1");
|
|
649
|
+
}
|
|
650
|
+
return raw;
|
|
651
|
+
}
|
|
652
|
+
function ms(value) {
|
|
653
|
+
return `${value.toFixed(2)}ms`;
|
|
654
|
+
}
|
|
655
|
+
function rootCause(cause) {
|
|
656
|
+
let root = cause;
|
|
657
|
+
while (root.causes !== undefined && root.causes.length > 0) root = root.causes[0];
|
|
658
|
+
let out = `${root.kind === "derived" ? "memo" : "signal"} "${root.name}" ${root.kind}`;
|
|
659
|
+
if (root.prev !== undefined) out += ` ${root.prev} → ${root.value}`;
|
|
660
|
+
if (root.origin !== undefined && root.origin.kind !== "external") out += ` — ${formatOrigin(root.origin)}`;
|
|
661
|
+
return out;
|
|
662
|
+
}
|
|
663
|
+
function heldWrite(write) {
|
|
664
|
+
return write.prev === undefined ? write.name : `${write.name} ${write.prev} → ${write.value}`;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
export { enablePerformanceTracks };
|