@surfaces-ui/devtools 0.0.0-stage → 0.2.0
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/LICENSE +202 -0
- package/NOTICE +4 -0
- package/README.md +35 -2
- package/dist/Panel.d.ts +60 -0
- package/dist/Panel.js +434 -0
- package/dist/Panel.js.map +1 -0
- package/dist/SurfacesDevTools.d.ts +56 -0
- package/dist/SurfacesDevTools.js +379 -0
- package/dist/SurfacesDevTools.js.map +1 -0
- package/dist/appComponents.d.ts +3 -0
- package/dist/appComponents.js +32 -0
- package/dist/appComponents.js.map +1 -0
- package/dist/cause.d.ts +38 -0
- package/dist/cause.js +126 -0
- package/dist/cause.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/replay.d.ts +14 -0
- package/dist/replay.js +28 -0
- package/dist/replay.js.map +1 -0
- package/dist/styles.d.ts +6 -0
- package/dist/styles.js +292 -0
- package/dist/styles.js.map +1 -0
- package/package.json +71 -3
package/dist/cause.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { getPath, surfaceOutline } from "@surfaces-ui/spec";
|
|
2
|
+
const record = (value) => (value && typeof value === "object" && !Array.isArray(value) ? value : {});
|
|
3
|
+
const text = (value) => (typeof value === "string" ? value : "");
|
|
4
|
+
const ORDER = ["refused", "invalid", "unreachable", "container", "binding", "query-failed", "render-failed", "contract", "no-rows", "cancelled", "slow"];
|
|
5
|
+
/** The components a message sent, by id. */
|
|
6
|
+
function sent(event) {
|
|
7
|
+
const message = record(event.detail.message ?? event.detail.raw);
|
|
8
|
+
const list = record(message.updateComponents).components ?? record(message.createSurface).components;
|
|
9
|
+
return Array.isArray(list) ? list.map((item) => text(record(item).id)).filter(Boolean) : [];
|
|
10
|
+
}
|
|
11
|
+
/** Every `{ "@path": … }` in a component's own props, with where it was found. */
|
|
12
|
+
function bindings(value, at = "", out = []) {
|
|
13
|
+
if (Array.isArray(value))
|
|
14
|
+
value.forEach((item, i) => bindings(item, `${at}/${i}`, out));
|
|
15
|
+
else if (value && typeof value === "object") {
|
|
16
|
+
const path = value["@path"];
|
|
17
|
+
if (typeof path === "string")
|
|
18
|
+
out.push({ at, path });
|
|
19
|
+
else
|
|
20
|
+
for (const [key, item] of Object.entries(value))
|
|
21
|
+
if (!key.startsWith("@"))
|
|
22
|
+
bindings(item, `${at}/${key}`, out);
|
|
23
|
+
}
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Why a component is the way it is, worked out from what was recorded by
|
|
28
|
+
* fixed rules, most likely cause first. It reads the trace and the surface
|
|
29
|
+
* and nothing else: it calls no model and runs no query, so it can only say
|
|
30
|
+
* what the recording shows. An empty list means nothing recorded points at a
|
|
31
|
+
* problem, not that there is none.
|
|
32
|
+
*
|
|
33
|
+
* The order follows the chain a component depends on: the message that sent
|
|
34
|
+
* it, the catalog's check, whether anything draws it, what it is bound to,
|
|
35
|
+
* its queries, and only then how it drew.
|
|
36
|
+
*/
|
|
37
|
+
export function componentFindings({ events, surfaceKey, surface, componentId, upTo = Number.POSITIVE_INFINITY, slowMs = 3000 }) {
|
|
38
|
+
const here = events.filter((event) => event.surfaceId === surfaceKey && event.seq <= upTo);
|
|
39
|
+
const mine = here.filter((event) => event.componentId === componentId);
|
|
40
|
+
const out = [];
|
|
41
|
+
const name = (id) => `${String(surface?.components[id]?.component ?? "Component")} "${id}"`;
|
|
42
|
+
// The messages that sent it: one refused, or one the catalog had something to say about.
|
|
43
|
+
const sends = here.filter((event) => event.kind === "message" && sent(event).includes(componentId));
|
|
44
|
+
const last = sends.at(-1);
|
|
45
|
+
if (last && (last.detail.applied === false || last.status === "error")) {
|
|
46
|
+
out.push({ rule: "refused", severity: "error", title: `The last message that sent it was refused, so the page still shows what came before.`, detail: text(record(last.detail.error).message) || undefined, eventId: last.id });
|
|
47
|
+
}
|
|
48
|
+
for (const event of sends) {
|
|
49
|
+
const issues = Array.isArray(event.detail.issues) ? event.detail.issues : [];
|
|
50
|
+
const index = sent(event).indexOf(componentId);
|
|
51
|
+
for (const issue of issues) {
|
|
52
|
+
const path = text(issue.path);
|
|
53
|
+
if (!(path === `/${componentId}` || path.startsWith(`/${componentId}/`) || path.includes(`/components/${index}/`) || path.endsWith(`/components/${index}`)))
|
|
54
|
+
continue;
|
|
55
|
+
out.push({ rule: "invalid", severity: "error", title: "The catalog did not accept it as it was sent.", detail: `${path} ${text(issue.message)}`.trim(), eventId: event.id });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// What the surface reported about it when drawing: a failed check, a component that threw, an event refused.
|
|
59
|
+
for (const event of here.filter((e) => e.kind === "problem")) {
|
|
60
|
+
const path = text(event.detail.path);
|
|
61
|
+
if (!(event.componentId === componentId || path === `/${componentId}` || path.startsWith(`/${componentId}/`)))
|
|
62
|
+
continue;
|
|
63
|
+
const code = text(event.detail.code) || event.name;
|
|
64
|
+
const detail = text(event.detail.message) || undefined;
|
|
65
|
+
if (code === "RENDER_FAILED")
|
|
66
|
+
out.push({ rule: "render-failed", severity: "error", title: "It threw while drawing, and a notice is shown in its place.", detail, eventId: event.id });
|
|
67
|
+
else if (code === "CONTRACT_FAILED")
|
|
68
|
+
out.push({ rule: "contract", severity: "error", title: "An event it sent did not match what the agent said it expects, so it was not sent.", detail, eventId: event.id });
|
|
69
|
+
else if (!out.some((f) => f.rule === "invalid" && f.detail?.includes(detail ?? "\u0000")))
|
|
70
|
+
out.push({ rule: "invalid", severity: "error", title: `The surface reported ${code} for it.`, detail, eventId: event.id });
|
|
71
|
+
}
|
|
72
|
+
if (surface) {
|
|
73
|
+
const component = surface.components[componentId];
|
|
74
|
+
const outline = surfaceOutline(surface);
|
|
75
|
+
if (component && !outline.some((item) => item.id === componentId)) {
|
|
76
|
+
out.push({ rule: "unreachable", severity: "error", title: "Nothing draws it: no component reachable from the root lists it as a child.", detail: sends.length > 0 ? undefined : "No message recorded here sent it either." });
|
|
77
|
+
}
|
|
78
|
+
// A container above it that failed takes it down too.
|
|
79
|
+
const holds = (c, id) => c.child === id || (Array.isArray(c.children) && c.children.includes(id)) || (Array.isArray(c.tabs) && c.tabs.some((tab) => record(tab).child === id));
|
|
80
|
+
const parentOf = (id) => Object.entries(surface.components).find(([, c]) => holds(c, id))?.[0];
|
|
81
|
+
const seen = new Set([componentId]);
|
|
82
|
+
for (let up = parentOf(componentId); up !== undefined && !seen.has(up); up = parentOf(up)) {
|
|
83
|
+
seen.add(up);
|
|
84
|
+
const failed = here.find((event) => event.kind === "problem" && (event.componentId === up || text(event.detail.path) === `/${up}`));
|
|
85
|
+
if (failed)
|
|
86
|
+
out.push({ rule: "container", severity: "error", title: `Its container ${name(up)} has a problem, so what is inside may not be drawn.`, detail: text(failed.detail.message) || undefined, eventId: failed.id });
|
|
87
|
+
}
|
|
88
|
+
// Bound to a place in the data model that holds nothing.
|
|
89
|
+
if (component) {
|
|
90
|
+
const { id: _id, component: _kind, ...own } = component;
|
|
91
|
+
for (const { at, path } of bindings(own)) {
|
|
92
|
+
// A path with no leading slash is relative to a repeated item, which the outline cannot place.
|
|
93
|
+
if (!path.startsWith("/"))
|
|
94
|
+
continue;
|
|
95
|
+
if (getPath(surface.data, path) === undefined)
|
|
96
|
+
out.push({ rule: "binding", severity: "warning", title: `Its ${at.slice(1).split("/")[0]} is bound to ${path}, and the data model holds nothing there.`, detail: "A later updateDataModel may set it; until then the prop is empty." });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// Its calls to a backend. One that failed, came back empty or was cancelled no longer counts once the same
|
|
101
|
+
// method was asked again after it ended and answered: the component moved on. Calls made side by side all count.
|
|
102
|
+
const calls = mine.filter((event) => event.kind === "service" && event.status !== "running");
|
|
103
|
+
const ended = (call) => call.time + (call.durationMs ?? 0);
|
|
104
|
+
const answered = (call) => call.status === "ok" && call.detail.cancelled !== true;
|
|
105
|
+
const standing = calls.filter((call) => !calls.some((later) => later.name === call.name && later.seq > call.seq && later.time >= ended(call) && answered(later) && !(answered(call) && Number(record(call.detail.response).rows) > 0)));
|
|
106
|
+
for (const call of standing) {
|
|
107
|
+
const error = record(call.detail.error);
|
|
108
|
+
const response = record(call.detail.response);
|
|
109
|
+
if (call.status === "error") {
|
|
110
|
+
const where = typeof error.line === "number" ? ` (line ${error.line}${typeof error.column === "number" ? `, column ${error.column}` : ""})` : "";
|
|
111
|
+
out.push({ rule: "query-failed", severity: "error", title: `${call.name} failed.`, detail: `${[error.code, error.message].filter(Boolean).join(" ")}${where}`, eventId: call.id });
|
|
112
|
+
}
|
|
113
|
+
else if (call.detail.cancelled === true) {
|
|
114
|
+
out.push({ rule: "cancelled", severity: "info", title: `${call.name} was cancelled and not asked again.`, detail: "Usual when a component is redrawn before its answer arrives; a problem only if it shows no data.", eventId: call.id });
|
|
115
|
+
}
|
|
116
|
+
else if (typeof response.rows === "number" && response.rows === 0 && Array.isArray(response.columns)) {
|
|
117
|
+
const notices = Array.isArray(response.notices) && response.notices.length > 0 ? ` Notices: ${JSON.stringify(response.notices)}` : "";
|
|
118
|
+
out.push({ rule: "no-rows", severity: "warning", title: `${call.name} came back with no rows.`, detail: `The query ran; check its filters and the SQL the engine ran.${notices}`, eventId: call.id });
|
|
119
|
+
}
|
|
120
|
+
if (call.status !== "error" && typeof call.durationMs === "number" && call.durationMs >= slowMs) {
|
|
121
|
+
out.push({ rule: "slow", severity: "info", title: `${call.name} took ${(call.durationMs / 1000).toFixed(1)} s.`, eventId: call.id });
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return out.map((finding, index) => ({ finding, index })).sort((a, b) => ORDER.indexOf(a.finding.rule) - ORDER.indexOf(b.finding.rule) || a.index - b.index).map(({ finding }) => finding);
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=cause.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cause.js","sourceRoot":"","sources":["../src/cause.ts"],"names":[],"mappings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,UAAU,KAAK,QAAQ,IAAI,IAAI,CAAC,UAAU,IAAI,MAAM,EAAE,CAAC;YAChG,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QACvI,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC;AAC5L,CAAC","sourcesContent":["import { type Surface, getPath, surfaceOutline } from \"@surfaces-ui/spec\";\nimport type { JsonRecord, TraceEvent } from \"@surfaces-ui/trace\";\n\n/** One thing the recording says about why a component is the way it is. */\nexport interface Finding {\n /** Which rule found it. */\n rule: \"refused\" | \"invalid\" | \"unreachable\" | \"container\" | \"binding\" | \"query-failed\" | \"render-failed\" | \"contract\" | \"no-rows\" | \"cancelled\" | \"slow\";\n /** \"error\" explains something broken, \"warning\" something that may be wrong, \"info\" something worth knowing. */\n severity: \"error\" | \"warning\" | \"info\";\n /** One sentence: what happened. */\n title: string;\n /** What the recording holds about it: a message, a path, a code. Never a row value. */\n detail?: string;\n /** The recorded event it was read from, to open. */\n eventId?: string;\n}\n\nexport interface CauseInput {\n events: readonly TraceEvent[];\n /** The key the surface is held under, and the surface as it stands at the step looked at. */\n surfaceKey: string;\n surface: Surface | undefined;\n componentId: string;\n /** Only events up to this number count. Left out, every event. */\n upTo?: number;\n /** A service call slower than this is mentioned. */\n slowMs?: number;\n}\n\nconst record = (value: unknown): JsonRecord => (value && typeof value === \"object\" && !Array.isArray(value) ? (value as JsonRecord) : {});\nconst text = (value: unknown) => (typeof value === \"string\" ? value : \"\");\nconst ORDER: Finding[\"rule\"][] = [\"refused\", \"invalid\", \"unreachable\", \"container\", \"binding\", \"query-failed\", \"render-failed\", \"contract\", \"no-rows\", \"cancelled\", \"slow\"];\n\n/** The components a message sent, by id. */\nfunction sent(event: TraceEvent): string[] {\n const message = record(event.detail.message ?? event.detail.raw);\n const list = record(message.updateComponents).components ?? record(message.createSurface).components;\n return Array.isArray(list) ? list.map((item) => text(record(item).id)).filter(Boolean) : [];\n}\n\n/** Every `{ \"@path\": … }` in a component's own props, with where it was found. */\nfunction bindings(value: unknown, at = \"\", out: { at: string; path: string }[] = []): { at: string; path: string }[] {\n if (Array.isArray(value)) value.forEach((item, i) => bindings(item, `${at}/${i}`, out));\n else if (value && typeof value === \"object\") {\n const path = (value as Record<string, unknown>)[\"@path\"];\n if (typeof path === \"string\") out.push({ at, path });\n else for (const [key, item] of Object.entries(value)) if (!key.startsWith(\"@\")) bindings(item, `${at}/${key}`, out);\n }\n return out;\n}\n\n/**\n * Why a component is the way it is, worked out from what was recorded by\n * fixed rules, most likely cause first. It reads the trace and the surface\n * and nothing else: it calls no model and runs no query, so it can only say\n * what the recording shows. An empty list means nothing recorded points at a\n * problem, not that there is none.\n *\n * The order follows the chain a component depends on: the message that sent\n * it, the catalog's check, whether anything draws it, what it is bound to,\n * its queries, and only then how it drew.\n */\nexport function componentFindings({ events, surfaceKey, surface, componentId, upTo = Number.POSITIVE_INFINITY, slowMs = 3000 }: CauseInput): Finding[] {\n const here = events.filter((event) => event.surfaceId === surfaceKey && event.seq <= upTo);\n const mine = here.filter((event) => event.componentId === componentId);\n const out: Finding[] = [];\n const name = (id: string) => `${String(surface?.components[id]?.component ?? \"Component\")} \"${id}\"`;\n\n // The messages that sent it: one refused, or one the catalog had something to say about.\n const sends = here.filter((event) => event.kind === \"message\" && sent(event).includes(componentId));\n const last = sends.at(-1);\n if (last && (last.detail.applied === false || last.status === \"error\")) {\n out.push({ rule: \"refused\", severity: \"error\", title: `The last message that sent it was refused, so the page still shows what came before.`, detail: text(record(last.detail.error).message) || undefined, eventId: last.id });\n }\n for (const event of sends) {\n const issues = Array.isArray(event.detail.issues) ? (event.detail.issues as { path?: unknown; message?: unknown }[]) : [];\n const index = sent(event).indexOf(componentId);\n for (const issue of issues) {\n const path = text(issue.path);\n if (!(path === `/${componentId}` || path.startsWith(`/${componentId}/`) || path.includes(`/components/${index}/`) || path.endsWith(`/components/${index}`))) continue;\n out.push({ rule: \"invalid\", severity: \"error\", title: \"The catalog did not accept it as it was sent.\", detail: `${path} ${text(issue.message)}`.trim(), eventId: event.id });\n }\n }\n // What the surface reported about it when drawing: a failed check, a component that threw, an event refused.\n for (const event of here.filter((e) => e.kind === \"problem\")) {\n const path = text(event.detail.path);\n if (!(event.componentId === componentId || path === `/${componentId}` || path.startsWith(`/${componentId}/`))) continue;\n const code = text(event.detail.code) || event.name;\n const detail = text(event.detail.message) || undefined;\n if (code === \"RENDER_FAILED\") out.push({ rule: \"render-failed\", severity: \"error\", title: \"It threw while drawing, and a notice is shown in its place.\", detail, eventId: event.id });\n else if (code === \"CONTRACT_FAILED\") out.push({ rule: \"contract\", severity: \"error\", title: \"An event it sent did not match what the agent said it expects, so it was not sent.\", detail, eventId: event.id });\n else if (!out.some((f) => f.rule === \"invalid\" && f.detail?.includes(detail ?? \"\\u0000\"))) out.push({ rule: \"invalid\", severity: \"error\", title: `The surface reported ${code} for it.`, detail, eventId: event.id });\n }\n\n if (surface) {\n const component = surface.components[componentId];\n const outline = surfaceOutline(surface);\n if (component && !outline.some((item) => item.id === componentId)) {\n out.push({ rule: \"unreachable\", severity: \"error\", title: \"Nothing draws it: no component reachable from the root lists it as a child.\", detail: sends.length > 0 ? undefined : \"No message recorded here sent it either.\" });\n }\n // A container above it that failed takes it down too.\n const holds = (c: Record<string, unknown>, id: string) =>\n c.child === id || (Array.isArray(c.children) && c.children.includes(id)) || (Array.isArray(c.tabs) && c.tabs.some((tab) => record(tab).child === id));\n const parentOf = (id: string) => Object.entries(surface.components).find(([, c]) => holds(c as Record<string, unknown>, id))?.[0];\n const seen = new Set([componentId]);\n for (let up = parentOf(componentId); up !== undefined && !seen.has(up); up = parentOf(up)) {\n seen.add(up);\n const failed = here.find((event) => event.kind === \"problem\" && (event.componentId === up || text(event.detail.path) === `/${up}`));\n if (failed) out.push({ rule: \"container\", severity: \"error\", title: `Its container ${name(up)} has a problem, so what is inside may not be drawn.`, detail: text(failed.detail.message) || undefined, eventId: failed.id });\n }\n // Bound to a place in the data model that holds nothing.\n if (component) {\n const { id: _id, component: _kind, ...own } = component;\n for (const { at, path } of bindings(own)) {\n // A path with no leading slash is relative to a repeated item, which the outline cannot place.\n if (!path.startsWith(\"/\")) continue;\n if (getPath(surface.data, path) === undefined) out.push({ rule: \"binding\", severity: \"warning\", title: `Its ${at.slice(1).split(\"/\")[0]} is bound to ${path}, and the data model holds nothing there.`, detail: \"A later updateDataModel may set it; until then the prop is empty.\" });\n }\n }\n }\n\n // Its calls to a backend. One that failed, came back empty or was cancelled no longer counts once the same\n // method was asked again after it ended and answered: the component moved on. Calls made side by side all count.\n const calls = mine.filter((event) => event.kind === \"service\" && event.status !== \"running\");\n const ended = (call: TraceEvent) => call.time + (call.durationMs ?? 0);\n const answered = (call: TraceEvent) => call.status === \"ok\" && call.detail.cancelled !== true;\n const standing = calls.filter((call) => !calls.some((later) => later.name === call.name && later.seq > call.seq && later.time >= ended(call) && answered(later) && !(answered(call) && Number(record(call.detail.response).rows) > 0)));\n for (const call of standing) {\n const error = record(call.detail.error);\n const response = record(call.detail.response);\n if (call.status === \"error\") {\n const where = typeof error.line === \"number\" ? ` (line ${error.line}${typeof error.column === \"number\" ? `, column ${error.column}` : \"\"})` : \"\";\n out.push({ rule: \"query-failed\", severity: \"error\", title: `${call.name} failed.`, detail: `${[error.code, error.message].filter(Boolean).join(\" \")}${where}`, eventId: call.id });\n } else if (call.detail.cancelled === true) {\n out.push({ rule: \"cancelled\", severity: \"info\", title: `${call.name} was cancelled and not asked again.`, detail: \"Usual when a component is redrawn before its answer arrives; a problem only if it shows no data.\", eventId: call.id });\n } else if (typeof response.rows === \"number\" && response.rows === 0 && Array.isArray(response.columns)) {\n const notices = Array.isArray(response.notices) && response.notices.length > 0 ? ` Notices: ${JSON.stringify(response.notices)}` : \"\";\n out.push({ rule: \"no-rows\", severity: \"warning\", title: `${call.name} came back with no rows.`, detail: `The query ran; check its filters and the SQL the engine ran.${notices}`, eventId: call.id });\n }\n if (call.status !== \"error\" && typeof call.durationMs === \"number\" && call.durationMs >= slowMs) {\n out.push({ rule: \"slow\", severity: \"info\", title: `${call.name} took ${(call.durationMs / 1000).toFixed(1)} s.`, eventId: call.id });\n }\n }\n\n return out.map((finding, index) => ({ finding, index })).sort((a, b) => ORDER.indexOf(a.finding.rule) - ORDER.indexOf(b.finding.rule) || a.index - b.index).map(({ finding }) => finding);\n}\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from "./SurfacesDevTools.js";
|
|
2
|
+
export * from "./replay.js";
|
|
3
|
+
export * from "./cause.js";
|
|
4
|
+
export type { DevToolsPanelProps, DevToolsServices } from "./Panel.js";
|
|
5
|
+
export { TraceProvider, useRecorder } from "@surfaces-ui/trace/react";
|
|
6
|
+
export { type Recorder, type TraceEvent, type TraceFeed, createRecorder, traceAgent, traceDataSource, traceService } from "@surfaces-ui/trace";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from "./SurfacesDevTools.js";
|
|
2
|
+
export * from "./replay.js";
|
|
3
|
+
export * from "./cause.js";
|
|
4
|
+
export { TraceProvider, useRecorder } from "@surfaces-ui/trace/react";
|
|
5
|
+
export { createRecorder, traceAgent, traceDataSource, traceService } from "@surfaces-ui/trace";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAkD,cAAc,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export * from \"./SurfacesDevTools.js\";\nexport * from \"./replay.js\";\nexport * from \"./cause.js\";\nexport type { DevToolsPanelProps, DevToolsServices } from \"./Panel.js\";\nexport { TraceProvider, useRecorder } from \"@surfaces-ui/trace/react\";\nexport { type Recorder, type TraceEvent, type TraceFeed, createRecorder, traceAgent, traceDataSource, traceService } from \"@surfaces-ui/trace\";\n"]}
|
package/dist/replay.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Surface } from "@surfaces-ui/spec";
|
|
2
|
+
import { type JsonChange, type ReplayOptions, type ReplayState, type TraceEvent } from "@surfaces-ui/trace";
|
|
3
|
+
/** The surface model's own functions, handed to the replay in `@surfaces-ui/trace`. */
|
|
4
|
+
export declare const SURFACE_REPLAY: ReplayOptions<Surface>;
|
|
5
|
+
/**
|
|
6
|
+
* The surfaces as they stood after the event numbered `seq`, or as they
|
|
7
|
+
* stand now when it is left out: the recorded messages replayed through
|
|
8
|
+
* `applyMessage`, with what a person typed and the controls they set. Pure.
|
|
9
|
+
*/
|
|
10
|
+
export declare const surfacesAt: (events: readonly TraceEvent[], seq?: number) => ReplayState<Surface>;
|
|
11
|
+
/** What the step numbered `seq` changed, against the step before it. */
|
|
12
|
+
export declare const surfaceStepDiff: (events: readonly TraceEvent[], seq: number) => JsonChange[];
|
|
13
|
+
/** A surface with the controls a person set written over its components' props, as the page showed it. */
|
|
14
|
+
export declare function withControls(surface: Surface, controls: Record<string, unknown> | undefined): Surface;
|
package/dist/replay.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { applyMessage, setPath } from "@surfaces-ui/spec";
|
|
2
|
+
import { replay, stepDiff } from "@surfaces-ui/trace";
|
|
3
|
+
/** The surface model's own functions, handed to the replay in `@surfaces-ui/trace`. */
|
|
4
|
+
export const SURFACE_REPLAY = {
|
|
5
|
+
apply: (surfaces, message) => applyMessage(surfaces, message),
|
|
6
|
+
setPath,
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* The surfaces as they stood after the event numbered `seq`, or as they
|
|
10
|
+
* stand now when it is left out: the recorded messages replayed through
|
|
11
|
+
* `applyMessage`, with what a person typed and the controls they set. Pure.
|
|
12
|
+
*/
|
|
13
|
+
export const surfacesAt = (events, seq) => replay(events, seq, SURFACE_REPLAY);
|
|
14
|
+
/** What the step numbered `seq` changed, against the step before it. */
|
|
15
|
+
export const surfaceStepDiff = (events, seq) => stepDiff(events, seq, SURFACE_REPLAY);
|
|
16
|
+
/** A surface with the controls a person set written over its components' props, as the page showed it. */
|
|
17
|
+
export function withControls(surface, controls) {
|
|
18
|
+
if (!controls || Object.keys(controls).length === 0)
|
|
19
|
+
return surface;
|
|
20
|
+
const components = { ...surface.components };
|
|
21
|
+
for (const [id, state] of Object.entries(controls)) {
|
|
22
|
+
const component = components[id];
|
|
23
|
+
if (component && state && typeof state === "object" && !Array.isArray(state))
|
|
24
|
+
components[id] = { ...component, ...state };
|
|
25
|
+
}
|
|
26
|
+
return { ...surface, components };
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=replay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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S,EAAE,GAAI,KAAiC,EAAE,CAAC;IACzJ,CAAC;IACD,OAAO,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,CAAC;AACpC,CAAC","sourcesContent":["import { type Surface, type SurfaceMessage, applyMessage, setPath } from \"@surfaces-ui/spec\";\nimport { type JsonChange, type ReplayOptions, type ReplayState, type TraceEvent, replay, stepDiff } from \"@surfaces-ui/trace\";\n\n/** The surface model's own functions, handed to the replay in `@surfaces-ui/trace`. */\nexport const SURFACE_REPLAY: ReplayOptions<Surface> = {\n apply: (surfaces, message) => applyMessage(surfaces, message as SurfaceMessage),\n setPath,\n};\n\n/**\n * The surfaces as they stood after the event numbered `seq`, or as they\n * stand now when it is left out: the recorded messages replayed through\n * `applyMessage`, with what a person typed and the controls they set. Pure.\n */\nexport const surfacesAt = (events: readonly TraceEvent[], seq?: number): ReplayState<Surface> => replay(events, seq, SURFACE_REPLAY);\n\n/** What the step numbered `seq` changed, against the step before it. */\nexport const surfaceStepDiff = (events: readonly TraceEvent[], seq: number): JsonChange[] => stepDiff(events, seq, SURFACE_REPLAY);\n\n/** A surface with the controls a person set written over its components' props, as the page showed it. */\nexport function withControls(surface: Surface, controls: Record<string, unknown> | undefined): Surface {\n if (!controls || Object.keys(controls).length === 0) return surface;\n const components = { ...surface.components };\n for (const [id, state] of Object.entries(controls)) {\n const component = components[id];\n if (component && state && typeof state === \"object\" && !Array.isArray(state)) components[id] = { ...component, ...(state as Record<string, unknown>) };\n }\n return { ...surface, components };\n}\n"]}
|
package/dist/styles.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** For the floating button and the dock: loaded with the widget. */
|
|
2
|
+
export declare const SHELL_CSS = "\n.sf-devtools-button {\n position: fixed;\n right: var(--sf-space-3);\n bottom: var(--sf-space-3);\n z-index: 2147483000;\n display: inline-flex;\n align-items: center;\n gap: var(--sf-space-1);\n height: max(var(--sf-target-min), var(--sf-control-size));\n min-width: max(var(--sf-target-min), var(--sf-control-size));\n padding: 0 var(--sf-space-2);\n border: 1px solid var(--sf-glass-edge);\n border-radius: var(--sf-radius-full);\n background: var(--sf-glass-regular);\n -webkit-backdrop-filter: var(--sf-glass-filter);\n backdrop-filter: var(--sf-glass-filter);\n box-shadow: inset 0 1px 0 var(--sf-glass-highlight), var(--sf-glass-shadow);\n color: var(--sf-color-text);\n font: inherit;\n font-size: var(--sf-font-size-sm);\n font-weight: var(--sf-font-weight-medium);\n cursor: pointer;\n transition: transform var(--sf-press-time) var(--sf-press-ease);\n}\n.sf-devtools-button:active { transform: scale(var(--sf-press-scale)); }\n.sf-devtools-button:focus-visible,\n.sf-devtools-grip:focus-visible {\n outline: 2px solid var(--sf-color-focus);\n outline-offset: 2px;\n}\n.sf-devtools-button svg { width: 1.1em; height: 1.1em; }\n.sf-devtools-count {\n padding: 0 var(--sf-space-1);\n border-radius: var(--sf-radius-full);\n background: var(--sf-color-danger);\n color: var(--sf-color-bg);\n font-size: var(--sf-font-size-xs);\n font-weight: var(--sf-font-weight-semibold);\n font-variant-numeric: tabular-nums;\n}\n.sf-devtools-inline { position: relative; min-height: 4rem; }\n.sf-devtools-inline > .sf-devtools-button { position: absolute; }\n.sf-devtools-dock {\n position: fixed;\n z-index: 2147483000;\n display: flex;\n border: 1px solid var(--sf-glass-edge);\n background: var(--sf-color-bg-1, var(--sf-color-bg));\n color: var(--sf-color-text);\n box-shadow: var(--sf-glass-shadow);\n font-size: var(--sf-font-size-sm);\n animation: sf-fade var(--sf-duration) var(--sf-ease-out);\n}\n/* Focus is moved here when the tools open, so the next Tab is inside them; the frame itself is not a control. */\n.sf-devtools-dock:focus { outline: none; }\n.sf-devtools-dock[data-dock=\"bottom\"] { left: 0; right: 0; bottom: 0; flex-direction: column; }\n.sf-devtools-dock[data-dock=\"right\"] { top: 0; right: 0; bottom: 0; flex-direction: row; max-width: 100vw; }\n.sf-devtools-inline > .sf-devtools-dock { position: relative; inset: auto; flex-direction: column; margin-top: var(--sf-space-2); border-radius: var(--sf-radius); }\n.sf-devtools-grip {\n flex: none;\n border: 0;\n padding: 0;\n background: var(--sf-color-divider);\n touch-action: none;\n}\n.sf-devtools-dock[data-dock=\"bottom\"] > .sf-devtools-grip { height: var(--sf-space-1); cursor: ns-resize; }\n.sf-devtools-dock[data-dock=\"right\"] > .sf-devtools-grip { width: var(--sf-space-1); cursor: ew-resize; }\n.sf-devtools-grip:hover { background: var(--sf-color-accent); }\n.sf-devtools-host { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }\n.sf-devtools-wait { padding: var(--sf-space-3); color: var(--sf-color-muted); }\n/* Narrow screens: the dock is always along the bottom, full width. */\n@media (max-width: 40rem) {\n /* One edge only on a narrow screen, so no control to change it. */\n .sf-devtools-icon.sf-devtools-dockside { display: none; }\n .sf-devtools-dock[data-dock=\"right\"] { top: auto; left: 0; flex-direction: column; }\n .sf-devtools-dock[data-dock=\"right\"] > .sf-devtools-grip { width: auto; height: var(--sf-space-1); cursor: ns-resize; }\n}\n@media (forced-colors: active) {\n .sf-devtools-button, .sf-devtools-dock { border-color: CanvasText; }\n}\n/* While a person is picking a component on the page. */\n.sf-devtools-picking, .sf-devtools-picking * { cursor: crosshair !important; }\n.sf-devtools-picking .sf-devtools-dock *, .sf-devtools-picking .sf-devtools-button { cursor: revert !important; }\n/* Over the component picked in the panel, on the page. It never takes a press. */\n.sf-devtools-inspect {\n position: fixed;\n top: 0;\n left: 0;\n /* Under the tools' own drawer and button. */\n z-index: 2147482999;\n pointer-events: none;\n box-sizing: border-box;\n outline: 2px solid var(--sf-color-focus);\n outline-offset: 1px;\n border-radius: var(--sf-radius-sm);\n}\n.sf-devtools-inspect::before { content: \"\"; position: absolute; inset: 0; border-radius: inherit; background: var(--sf-color-accent); opacity: 0.14; }\n@media (forced-colors: active) {\n .sf-devtools-inspect { outline-color: Highlight; }\n .sf-devtools-inspect::before { display: none; }\n}\n";
|
|
3
|
+
/** For the panel: loaded with it, only when the tools are opened. */
|
|
4
|
+
export declare const PANEL_CSS = "\n.sf-devtools {\n flex: 1;\n min-height: 0;\n min-width: 0;\n /* A column, not grid rows: the note between the bar and the body is absent when it is empty, and the body must still take what is left. */\n display: flex;\n flex-direction: column;\n container-type: inline-size;\n container-name: sf-devtools;\n background: var(--sf-color-bg-1, var(--sf-color-bg));\n color: var(--sf-color-text);\n font-size: var(--sf-font-size-sm);\n}\n.sf-devtools-bar {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--sf-space-2);\n padding: var(--sf-space-1) var(--sf-space-2);\n border-bottom: 1px solid var(--sf-color-divider);\n}\n.sf-devtools-title { margin: 0; font-size: var(--sf-font-size-sm); font-weight: var(--sf-font-weight-semibold); }\n.sf-devtools-scrub { flex: 1 1 16rem; display: flex; align-items: center; gap: var(--sf-space-1); min-width: 0; }\n.sf-devtools-scrub input[type=\"range\"] { flex: 1; min-width: 4rem; accent-color: var(--sf-color-accent); height: var(--sf-target-min); }\n.sf-devtools-step { min-width: 0; color: var(--sf-color-muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.sf-devtools-actions { display: flex; align-items: center; gap: var(--sf-space-1); margin-left: auto; }\n.sf-devtools-icon {\n display: inline-grid;\n place-items: center;\n width: max(var(--sf-target-min), var(--sf-control-size));\n height: max(var(--sf-target-min), var(--sf-control-size));\n padding: 0;\n border: 1px solid var(--sf-color-edge, transparent);\n border-radius: var(--sf-radius);\n background: var(--sf-color-fill-2);\n color: var(--sf-color-text);\n cursor: pointer;\n transition: background-color var(--sf-duration-fast) var(--sf-ease), transform var(--sf-press-time) var(--sf-press-ease);\n}\n.sf-devtools-icon:hover:not([aria-disabled=\"true\"]) { background: var(--sf-color-fill-1); }\n.sf-devtools-icon:active:not([aria-disabled=\"true\"]) { transform: scale(var(--sf-press-scale)); }\n.sf-devtools-icon[aria-pressed=\"true\"] { background: var(--sf-color-accent-soft); color: var(--sf-color-accent-text); }\n.sf-devtools-icon[aria-disabled=\"true\"] { color: var(--sf-color-label-4, var(--sf-color-muted)); cursor: default; }\n.sf-devtools-icon[aria-pressed=\"true\"] { background: var(--sf-color-accent-soft); color: var(--sf-color-accent-text); }\n.sf-devtools-icon:focus-visible, .sf-devtools-rows:focus-visible, .sf-devtools-tree:focus-visible, .sf-devtools-chip:focus-visible, .sf-devtools-detail:focus-visible, .sf-devtools-preview:focus-visible {\n outline: 2px solid var(--sf-color-focus);\n outline-offset: -2px;\n}\n.sf-devtools-icon svg { width: 1.15em; height: 1.15em; }\n.sf-devtools-note {\n margin: 0;\n padding: var(--sf-space-1) var(--sf-space-2);\n border-bottom: 1px solid var(--sf-color-divider);\n background: var(--sf-color-accent-soft);\n color: var(--sf-color-text);\n}\n.sf-devtools-note:empty { display: none; }\n.sf-devtools-body { position: relative; flex: 1 1 0; min-height: 0; min-width: 0; overflow: auto; padding: var(--sf-space-2); }\n.sf-devtools-workspace { height: 100%; }\n.sf-devtools-pane { display: flex; flex-direction: column; gap: var(--sf-space-2); flex: 1 1 auto; min-height: 0; min-width: 0; }\n.sf-devtools-filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sf-space-1); }\n.sf-devtools-chip {\n min-height: var(--sf-target-min);\n padding: 0 var(--sf-space-2);\n border: 1px solid var(--sf-color-edge, transparent);\n border-radius: var(--sf-radius-full);\n background: var(--sf-color-fill-3);\n color: var(--sf-color-muted);\n font: inherit;\n font-size: var(--sf-font-size-xs);\n cursor: pointer;\n transition: background-color var(--sf-duration-fast) var(--sf-ease);\n}\n.sf-devtools-chip[aria-pressed=\"true\"] { background: var(--sf-color-accent-soft); color: var(--sf-color-accent-text); font-weight: var(--sf-font-weight-semibold); }\n.sf-devtools-only { display: inline-flex; align-items: center; gap: var(--sf-space-1); align-self: flex-start; padding-inline-start: var(--sf-space-2); border-radius: var(--sf-radius-full); background: var(--sf-color-accent-soft); color: var(--sf-color-accent-text); font-size: var(--sf-font-size-xs); font-weight: var(--sf-font-weight-semibold); }\n.sf-devtools-only code { font-family: var(--sf-font-mono); font-weight: var(--sf-font-weight-regular); }\n.sf-devtools-causes { display: flex; flex-direction: column; gap: var(--sf-space-1); flex: none; }\n.sf-devtools-cause { display: grid; grid-template-columns: max-content minmax(0, 1fr) max-content; align-items: start; gap: var(--sf-space-2); }\n.sf-devtools-cause small { color: var(--sf-color-muted); font-family: var(--sf-font-mono); font-size: var(--sf-font-size-xs); overflow-wrap: anywhere; }\n.sf-devtools-cause-mark { font-size: var(--sf-font-size-xs); font-weight: var(--sf-font-weight-semibold); color: var(--sf-color-muted); }\n.sf-devtools-cause[data-severity=\"error\"] .sf-devtools-cause-mark { color: var(--sf-color-danger); }\n.sf-devtools-cause[data-severity=\"warning\"] .sf-devtools-cause-mark { color: var(--sf-color-warning); }\n.sf-devtools-cause-by { margin: 0; color: var(--sf-color-muted); font-size: var(--sf-font-size-xs); }\n.sf-devtools-said { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }\ndiv.sf-devtools-said { display: flex; flex-direction: column; gap: var(--sf-space-2); white-space: normal; }\ndiv.sf-devtools-said > p { margin: 0; white-space: pre-wrap; }\ndiv.sf-devtools-said ul { margin: 0; padding-inline-start: var(--sf-space-4); display: flex; flex-direction: column; gap: var(--sf-space-1); font-family: var(--sf-font-mono); font-size: var(--sf-font-size-xs); }\ndiv.sf-devtools-said summary { padding-block: var(--sf-space-1); color: var(--sf-color-muted); cursor: pointer; }\ndiv.sf-devtools-said details[open] > summary { margin-block-end: var(--sf-space-1); }\n.sf-devtools-filters label { display: inline-flex; align-items: center; gap: var(--sf-space-1); color: var(--sf-color-muted); }\n.sf-devtools-rows, .sf-devtools-tree {\n position: relative;\n flex: 1 1 4.5rem;\n min-height: 4.5rem;\n overflow: auto;\n border-radius: var(--sf-radius-sm);\n background: var(--sf-color-bg-2, var(--sf-color-surface));\n}\n.sf-devtools-row {\n position: absolute;\n left: 0;\n right: 0;\n display: grid;\n grid-template-columns: 6.5em 5.5em minmax(0, 1fr) auto auto;\n align-items: center;\n gap: var(--sf-space-2);\n padding: 0 var(--sf-space-2);\n border-bottom: 1px solid var(--sf-color-divider);\n cursor: default;\n white-space: nowrap;\n}\n.sf-devtools-row > span { overflow: hidden; text-overflow: ellipsis; }\n.sf-devtools-row[aria-selected=\"true\"] { background: var(--sf-color-accent-soft); }\n.sf-devtools-row[data-later] { color: var(--sf-color-muted); }\n.sf-devtools-time, .sf-devtools-ms { color: var(--sf-color-muted); font-family: var(--sf-font-mono); font-size: var(--sf-font-size-xs); font-variant-numeric: tabular-nums; }\n.sf-devtools-kind { font-size: var(--sf-font-size-xs); color: var(--sf-color-muted); }\n.sf-devtools-name { font-family: var(--sf-font-mono); font-size: var(--sf-font-size-xs); }\n.sf-devtools-name small { color: var(--sf-color-muted); font-size: inherit; }\n.sf-devtools-status { font-size: var(--sf-font-size-xs); font-weight: var(--sf-font-weight-semibold); }\n.sf-devtools-status[data-status=\"error\"] { color: var(--sf-color-danger); }\n.sf-devtools-status[data-status=\"warning\"] { color: var(--sf-color-warning); }\n.sf-devtools-status[data-status=\"ok\"] { color: var(--sf-color-success); }\n.sf-devtools-status[data-status=\"running\"] { color: var(--sf-color-muted); }\n.sf-devtools-status[data-status=\"cancelled\"] { color: var(--sf-color-muted); font-weight: var(--sf-font-weight-regular); }\n/* What a row holds in full gets most of a pane: the list above it keeps a few rows, and the pane scrolls when both cannot fit. */\n.sf-devtools-detail { flex: 3 1 9rem; min-height: 9rem; overflow: auto; display: flex; flex-direction: column; gap: var(--sf-space-2); }\n/* A code block hides its overflow, so as a flex item it would shrink to nothing; it keeps its own height and the detail scrolls. */\n.sf-devtools-detail > * { flex: none; }\n.sf-devtools-detail h4, .sf-devtools-pane h4 { margin: 0; font-size: var(--sf-font-size-xs); font-weight: var(--sf-font-weight-semibold); color: var(--sf-color-muted); }\n.sf-devtools-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0 var(--sf-space-2); margin: 0; }\n.sf-devtools-facts dt { color: var(--sf-color-muted); }\n.sf-devtools-facts dd { margin: 0; overflow-wrap: anywhere; font-family: var(--sf-font-mono); font-size: var(--sf-font-size-xs); }\n.sf-devtools-empty { margin: 0; padding: var(--sf-space-2); color: var(--sf-color-muted); }\n.sf-devtools-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--sf-space-1); }\n.sf-devtools-list li { overflow-wrap: anywhere; }\n.sf-devtools-list code { font-family: var(--sf-font-mono); font-size: var(--sf-font-size-xs); }\n.sf-devtools-problem { color: var(--sf-color-danger); }\n.sf-devtools-node {\n display: flex;\n align-items: center;\n gap: var(--sf-space-1);\n min-height: var(--sf-target-min);\n padding: 0 var(--sf-space-2);\n border-bottom: 1px solid var(--sf-color-divider);\n white-space: nowrap;\n}\n.sf-devtools-node[aria-selected=\"true\"] { background: var(--sf-color-accent-soft); }\n.sf-devtools-node small { color: var(--sf-color-muted); }\n.sf-devtools-preview { flex: 1; min-height: 0; overflow: auto; }\n.sf-devtools-select { max-width: 100%; }\n@container sf-devtools (max-width: 40rem) {\n /* The title and the host's controls share the first line; the scrubber takes the second. */\n .sf-devtools-scrub { order: 3; flex-basis: 100%; }\n .sf-devtools-scrub .sf-devtools-step { flex: 0 1 8rem; }\n .sf-devtools-row { grid-template-columns: 6.5em minmax(0, 1fr) auto; }\n .sf-devtools-row .sf-devtools-kind, .sf-devtools-row .sf-devtools-ms { display: none; }\n .sf-devtools-workspace { height: auto; }\n .sf-devtools-pane { flex: none; }\n .sf-devtools-rows, .sf-devtools-tree { flex: none; height: 14rem; }\n .sf-devtools-detail { flex: none; max-height: 20rem; }\n .sf-devtools-preview { flex: none; }\n}\n@media (forced-colors: active) {\n .sf-devtools-row[aria-selected=\"true\"], .sf-devtools-node[aria-selected=\"true\"] { outline: 2px solid Highlight; outline-offset: -2px; }\n}\n";
|
|
5
|
+
/** Adds a stylesheet to a document once, by id. */
|
|
6
|
+
export declare function addStyles(doc: Document, id: string, css: string): void;
|
package/dist/styles.js
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The dev tools' own styles, added to the page (and to a popped-out window)
|
|
3
|
+
* as a <style> element when the tools are on, so a host adds no stylesheet
|
|
4
|
+
* for them. Every colour, size and time is a --sf-* token.
|
|
5
|
+
*/
|
|
6
|
+
/** For the floating button and the dock: loaded with the widget. */
|
|
7
|
+
export const SHELL_CSS = `
|
|
8
|
+
.sf-devtools-button {
|
|
9
|
+
position: fixed;
|
|
10
|
+
right: var(--sf-space-3);
|
|
11
|
+
bottom: var(--sf-space-3);
|
|
12
|
+
z-index: 2147483000;
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
gap: var(--sf-space-1);
|
|
16
|
+
height: max(var(--sf-target-min), var(--sf-control-size));
|
|
17
|
+
min-width: max(var(--sf-target-min), var(--sf-control-size));
|
|
18
|
+
padding: 0 var(--sf-space-2);
|
|
19
|
+
border: 1px solid var(--sf-glass-edge);
|
|
20
|
+
border-radius: var(--sf-radius-full);
|
|
21
|
+
background: var(--sf-glass-regular);
|
|
22
|
+
-webkit-backdrop-filter: var(--sf-glass-filter);
|
|
23
|
+
backdrop-filter: var(--sf-glass-filter);
|
|
24
|
+
box-shadow: inset 0 1px 0 var(--sf-glass-highlight), var(--sf-glass-shadow);
|
|
25
|
+
color: var(--sf-color-text);
|
|
26
|
+
font: inherit;
|
|
27
|
+
font-size: var(--sf-font-size-sm);
|
|
28
|
+
font-weight: var(--sf-font-weight-medium);
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
transition: transform var(--sf-press-time) var(--sf-press-ease);
|
|
31
|
+
}
|
|
32
|
+
.sf-devtools-button:active { transform: scale(var(--sf-press-scale)); }
|
|
33
|
+
.sf-devtools-button:focus-visible,
|
|
34
|
+
.sf-devtools-grip:focus-visible {
|
|
35
|
+
outline: 2px solid var(--sf-color-focus);
|
|
36
|
+
outline-offset: 2px;
|
|
37
|
+
}
|
|
38
|
+
.sf-devtools-button svg { width: 1.1em; height: 1.1em; }
|
|
39
|
+
.sf-devtools-count {
|
|
40
|
+
padding: 0 var(--sf-space-1);
|
|
41
|
+
border-radius: var(--sf-radius-full);
|
|
42
|
+
background: var(--sf-color-danger);
|
|
43
|
+
color: var(--sf-color-bg);
|
|
44
|
+
font-size: var(--sf-font-size-xs);
|
|
45
|
+
font-weight: var(--sf-font-weight-semibold);
|
|
46
|
+
font-variant-numeric: tabular-nums;
|
|
47
|
+
}
|
|
48
|
+
.sf-devtools-inline { position: relative; min-height: 4rem; }
|
|
49
|
+
.sf-devtools-inline > .sf-devtools-button { position: absolute; }
|
|
50
|
+
.sf-devtools-dock {
|
|
51
|
+
position: fixed;
|
|
52
|
+
z-index: 2147483000;
|
|
53
|
+
display: flex;
|
|
54
|
+
border: 1px solid var(--sf-glass-edge);
|
|
55
|
+
background: var(--sf-color-bg-1, var(--sf-color-bg));
|
|
56
|
+
color: var(--sf-color-text);
|
|
57
|
+
box-shadow: var(--sf-glass-shadow);
|
|
58
|
+
font-size: var(--sf-font-size-sm);
|
|
59
|
+
animation: sf-fade var(--sf-duration) var(--sf-ease-out);
|
|
60
|
+
}
|
|
61
|
+
/* Focus is moved here when the tools open, so the next Tab is inside them; the frame itself is not a control. */
|
|
62
|
+
.sf-devtools-dock:focus { outline: none; }
|
|
63
|
+
.sf-devtools-dock[data-dock="bottom"] { left: 0; right: 0; bottom: 0; flex-direction: column; }
|
|
64
|
+
.sf-devtools-dock[data-dock="right"] { top: 0; right: 0; bottom: 0; flex-direction: row; max-width: 100vw; }
|
|
65
|
+
.sf-devtools-inline > .sf-devtools-dock { position: relative; inset: auto; flex-direction: column; margin-top: var(--sf-space-2); border-radius: var(--sf-radius); }
|
|
66
|
+
.sf-devtools-grip {
|
|
67
|
+
flex: none;
|
|
68
|
+
border: 0;
|
|
69
|
+
padding: 0;
|
|
70
|
+
background: var(--sf-color-divider);
|
|
71
|
+
touch-action: none;
|
|
72
|
+
}
|
|
73
|
+
.sf-devtools-dock[data-dock="bottom"] > .sf-devtools-grip { height: var(--sf-space-1); cursor: ns-resize; }
|
|
74
|
+
.sf-devtools-dock[data-dock="right"] > .sf-devtools-grip { width: var(--sf-space-1); cursor: ew-resize; }
|
|
75
|
+
.sf-devtools-grip:hover { background: var(--sf-color-accent); }
|
|
76
|
+
.sf-devtools-host { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
|
|
77
|
+
.sf-devtools-wait { padding: var(--sf-space-3); color: var(--sf-color-muted); }
|
|
78
|
+
/* Narrow screens: the dock is always along the bottom, full width. */
|
|
79
|
+
@media (max-width: 40rem) {
|
|
80
|
+
/* One edge only on a narrow screen, so no control to change it. */
|
|
81
|
+
.sf-devtools-icon.sf-devtools-dockside { display: none; }
|
|
82
|
+
.sf-devtools-dock[data-dock="right"] { top: auto; left: 0; flex-direction: column; }
|
|
83
|
+
.sf-devtools-dock[data-dock="right"] > .sf-devtools-grip { width: auto; height: var(--sf-space-1); cursor: ns-resize; }
|
|
84
|
+
}
|
|
85
|
+
@media (forced-colors: active) {
|
|
86
|
+
.sf-devtools-button, .sf-devtools-dock { border-color: CanvasText; }
|
|
87
|
+
}
|
|
88
|
+
/* While a person is picking a component on the page. */
|
|
89
|
+
.sf-devtools-picking, .sf-devtools-picking * { cursor: crosshair !important; }
|
|
90
|
+
.sf-devtools-picking .sf-devtools-dock *, .sf-devtools-picking .sf-devtools-button { cursor: revert !important; }
|
|
91
|
+
/* Over the component picked in the panel, on the page. It never takes a press. */
|
|
92
|
+
.sf-devtools-inspect {
|
|
93
|
+
position: fixed;
|
|
94
|
+
top: 0;
|
|
95
|
+
left: 0;
|
|
96
|
+
/* Under the tools' own drawer and button. */
|
|
97
|
+
z-index: 2147482999;
|
|
98
|
+
pointer-events: none;
|
|
99
|
+
box-sizing: border-box;
|
|
100
|
+
outline: 2px solid var(--sf-color-focus);
|
|
101
|
+
outline-offset: 1px;
|
|
102
|
+
border-radius: var(--sf-radius-sm);
|
|
103
|
+
}
|
|
104
|
+
.sf-devtools-inspect::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--sf-color-accent); opacity: 0.14; }
|
|
105
|
+
@media (forced-colors: active) {
|
|
106
|
+
.sf-devtools-inspect { outline-color: Highlight; }
|
|
107
|
+
.sf-devtools-inspect::before { display: none; }
|
|
108
|
+
}
|
|
109
|
+
`;
|
|
110
|
+
/** For the panel: loaded with it, only when the tools are opened. */
|
|
111
|
+
export const PANEL_CSS = `
|
|
112
|
+
.sf-devtools {
|
|
113
|
+
flex: 1;
|
|
114
|
+
min-height: 0;
|
|
115
|
+
min-width: 0;
|
|
116
|
+
/* A column, not grid rows: the note between the bar and the body is absent when it is empty, and the body must still take what is left. */
|
|
117
|
+
display: flex;
|
|
118
|
+
flex-direction: column;
|
|
119
|
+
container-type: inline-size;
|
|
120
|
+
container-name: sf-devtools;
|
|
121
|
+
background: var(--sf-color-bg-1, var(--sf-color-bg));
|
|
122
|
+
color: var(--sf-color-text);
|
|
123
|
+
font-size: var(--sf-font-size-sm);
|
|
124
|
+
}
|
|
125
|
+
.sf-devtools-bar {
|
|
126
|
+
display: flex;
|
|
127
|
+
flex-wrap: wrap;
|
|
128
|
+
align-items: center;
|
|
129
|
+
gap: var(--sf-space-2);
|
|
130
|
+
padding: var(--sf-space-1) var(--sf-space-2);
|
|
131
|
+
border-bottom: 1px solid var(--sf-color-divider);
|
|
132
|
+
}
|
|
133
|
+
.sf-devtools-title { margin: 0; font-size: var(--sf-font-size-sm); font-weight: var(--sf-font-weight-semibold); }
|
|
134
|
+
.sf-devtools-scrub { flex: 1 1 16rem; display: flex; align-items: center; gap: var(--sf-space-1); min-width: 0; }
|
|
135
|
+
.sf-devtools-scrub input[type="range"] { flex: 1; min-width: 4rem; accent-color: var(--sf-color-accent); height: var(--sf-target-min); }
|
|
136
|
+
.sf-devtools-step { min-width: 0; color: var(--sf-color-muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
137
|
+
.sf-devtools-actions { display: flex; align-items: center; gap: var(--sf-space-1); margin-left: auto; }
|
|
138
|
+
.sf-devtools-icon {
|
|
139
|
+
display: inline-grid;
|
|
140
|
+
place-items: center;
|
|
141
|
+
width: max(var(--sf-target-min), var(--sf-control-size));
|
|
142
|
+
height: max(var(--sf-target-min), var(--sf-control-size));
|
|
143
|
+
padding: 0;
|
|
144
|
+
border: 1px solid var(--sf-color-edge, transparent);
|
|
145
|
+
border-radius: var(--sf-radius);
|
|
146
|
+
background: var(--sf-color-fill-2);
|
|
147
|
+
color: var(--sf-color-text);
|
|
148
|
+
cursor: pointer;
|
|
149
|
+
transition: background-color var(--sf-duration-fast) var(--sf-ease), transform var(--sf-press-time) var(--sf-press-ease);
|
|
150
|
+
}
|
|
151
|
+
.sf-devtools-icon:hover:not([aria-disabled="true"]) { background: var(--sf-color-fill-1); }
|
|
152
|
+
.sf-devtools-icon:active:not([aria-disabled="true"]) { transform: scale(var(--sf-press-scale)); }
|
|
153
|
+
.sf-devtools-icon[aria-pressed="true"] { background: var(--sf-color-accent-soft); color: var(--sf-color-accent-text); }
|
|
154
|
+
.sf-devtools-icon[aria-disabled="true"] { color: var(--sf-color-label-4, var(--sf-color-muted)); cursor: default; }
|
|
155
|
+
.sf-devtools-icon[aria-pressed="true"] { background: var(--sf-color-accent-soft); color: var(--sf-color-accent-text); }
|
|
156
|
+
.sf-devtools-icon:focus-visible, .sf-devtools-rows:focus-visible, .sf-devtools-tree:focus-visible, .sf-devtools-chip:focus-visible, .sf-devtools-detail:focus-visible, .sf-devtools-preview:focus-visible {
|
|
157
|
+
outline: 2px solid var(--sf-color-focus);
|
|
158
|
+
outline-offset: -2px;
|
|
159
|
+
}
|
|
160
|
+
.sf-devtools-icon svg { width: 1.15em; height: 1.15em; }
|
|
161
|
+
.sf-devtools-note {
|
|
162
|
+
margin: 0;
|
|
163
|
+
padding: var(--sf-space-1) var(--sf-space-2);
|
|
164
|
+
border-bottom: 1px solid var(--sf-color-divider);
|
|
165
|
+
background: var(--sf-color-accent-soft);
|
|
166
|
+
color: var(--sf-color-text);
|
|
167
|
+
}
|
|
168
|
+
.sf-devtools-note:empty { display: none; }
|
|
169
|
+
.sf-devtools-body { position: relative; flex: 1 1 0; min-height: 0; min-width: 0; overflow: auto; padding: var(--sf-space-2); }
|
|
170
|
+
.sf-devtools-workspace { height: 100%; }
|
|
171
|
+
.sf-devtools-pane { display: flex; flex-direction: column; gap: var(--sf-space-2); flex: 1 1 auto; min-height: 0; min-width: 0; }
|
|
172
|
+
.sf-devtools-filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sf-space-1); }
|
|
173
|
+
.sf-devtools-chip {
|
|
174
|
+
min-height: var(--sf-target-min);
|
|
175
|
+
padding: 0 var(--sf-space-2);
|
|
176
|
+
border: 1px solid var(--sf-color-edge, transparent);
|
|
177
|
+
border-radius: var(--sf-radius-full);
|
|
178
|
+
background: var(--sf-color-fill-3);
|
|
179
|
+
color: var(--sf-color-muted);
|
|
180
|
+
font: inherit;
|
|
181
|
+
font-size: var(--sf-font-size-xs);
|
|
182
|
+
cursor: pointer;
|
|
183
|
+
transition: background-color var(--sf-duration-fast) var(--sf-ease);
|
|
184
|
+
}
|
|
185
|
+
.sf-devtools-chip[aria-pressed="true"] { background: var(--sf-color-accent-soft); color: var(--sf-color-accent-text); font-weight: var(--sf-font-weight-semibold); }
|
|
186
|
+
.sf-devtools-only { display: inline-flex; align-items: center; gap: var(--sf-space-1); align-self: flex-start; padding-inline-start: var(--sf-space-2); border-radius: var(--sf-radius-full); background: var(--sf-color-accent-soft); color: var(--sf-color-accent-text); font-size: var(--sf-font-size-xs); font-weight: var(--sf-font-weight-semibold); }
|
|
187
|
+
.sf-devtools-only code { font-family: var(--sf-font-mono); font-weight: var(--sf-font-weight-regular); }
|
|
188
|
+
.sf-devtools-causes { display: flex; flex-direction: column; gap: var(--sf-space-1); flex: none; }
|
|
189
|
+
.sf-devtools-cause { display: grid; grid-template-columns: max-content minmax(0, 1fr) max-content; align-items: start; gap: var(--sf-space-2); }
|
|
190
|
+
.sf-devtools-cause small { color: var(--sf-color-muted); font-family: var(--sf-font-mono); font-size: var(--sf-font-size-xs); overflow-wrap: anywhere; }
|
|
191
|
+
.sf-devtools-cause-mark { font-size: var(--sf-font-size-xs); font-weight: var(--sf-font-weight-semibold); color: var(--sf-color-muted); }
|
|
192
|
+
.sf-devtools-cause[data-severity="error"] .sf-devtools-cause-mark { color: var(--sf-color-danger); }
|
|
193
|
+
.sf-devtools-cause[data-severity="warning"] .sf-devtools-cause-mark { color: var(--sf-color-warning); }
|
|
194
|
+
.sf-devtools-cause-by { margin: 0; color: var(--sf-color-muted); font-size: var(--sf-font-size-xs); }
|
|
195
|
+
.sf-devtools-said { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
196
|
+
div.sf-devtools-said { display: flex; flex-direction: column; gap: var(--sf-space-2); white-space: normal; }
|
|
197
|
+
div.sf-devtools-said > p { margin: 0; white-space: pre-wrap; }
|
|
198
|
+
div.sf-devtools-said ul { margin: 0; padding-inline-start: var(--sf-space-4); display: flex; flex-direction: column; gap: var(--sf-space-1); font-family: var(--sf-font-mono); font-size: var(--sf-font-size-xs); }
|
|
199
|
+
div.sf-devtools-said summary { padding-block: var(--sf-space-1); color: var(--sf-color-muted); cursor: pointer; }
|
|
200
|
+
div.sf-devtools-said details[open] > summary { margin-block-end: var(--sf-space-1); }
|
|
201
|
+
.sf-devtools-filters label { display: inline-flex; align-items: center; gap: var(--sf-space-1); color: var(--sf-color-muted); }
|
|
202
|
+
.sf-devtools-rows, .sf-devtools-tree {
|
|
203
|
+
position: relative;
|
|
204
|
+
flex: 1 1 4.5rem;
|
|
205
|
+
min-height: 4.5rem;
|
|
206
|
+
overflow: auto;
|
|
207
|
+
border-radius: var(--sf-radius-sm);
|
|
208
|
+
background: var(--sf-color-bg-2, var(--sf-color-surface));
|
|
209
|
+
}
|
|
210
|
+
.sf-devtools-row {
|
|
211
|
+
position: absolute;
|
|
212
|
+
left: 0;
|
|
213
|
+
right: 0;
|
|
214
|
+
display: grid;
|
|
215
|
+
grid-template-columns: 6.5em 5.5em minmax(0, 1fr) auto auto;
|
|
216
|
+
align-items: center;
|
|
217
|
+
gap: var(--sf-space-2);
|
|
218
|
+
padding: 0 var(--sf-space-2);
|
|
219
|
+
border-bottom: 1px solid var(--sf-color-divider);
|
|
220
|
+
cursor: default;
|
|
221
|
+
white-space: nowrap;
|
|
222
|
+
}
|
|
223
|
+
.sf-devtools-row > span { overflow: hidden; text-overflow: ellipsis; }
|
|
224
|
+
.sf-devtools-row[aria-selected="true"] { background: var(--sf-color-accent-soft); }
|
|
225
|
+
.sf-devtools-row[data-later] { color: var(--sf-color-muted); }
|
|
226
|
+
.sf-devtools-time, .sf-devtools-ms { color: var(--sf-color-muted); font-family: var(--sf-font-mono); font-size: var(--sf-font-size-xs); font-variant-numeric: tabular-nums; }
|
|
227
|
+
.sf-devtools-kind { font-size: var(--sf-font-size-xs); color: var(--sf-color-muted); }
|
|
228
|
+
.sf-devtools-name { font-family: var(--sf-font-mono); font-size: var(--sf-font-size-xs); }
|
|
229
|
+
.sf-devtools-name small { color: var(--sf-color-muted); font-size: inherit; }
|
|
230
|
+
.sf-devtools-status { font-size: var(--sf-font-size-xs); font-weight: var(--sf-font-weight-semibold); }
|
|
231
|
+
.sf-devtools-status[data-status="error"] { color: var(--sf-color-danger); }
|
|
232
|
+
.sf-devtools-status[data-status="warning"] { color: var(--sf-color-warning); }
|
|
233
|
+
.sf-devtools-status[data-status="ok"] { color: var(--sf-color-success); }
|
|
234
|
+
.sf-devtools-status[data-status="running"] { color: var(--sf-color-muted); }
|
|
235
|
+
.sf-devtools-status[data-status="cancelled"] { color: var(--sf-color-muted); font-weight: var(--sf-font-weight-regular); }
|
|
236
|
+
/* What a row holds in full gets most of a pane: the list above it keeps a few rows, and the pane scrolls when both cannot fit. */
|
|
237
|
+
.sf-devtools-detail { flex: 3 1 9rem; min-height: 9rem; overflow: auto; display: flex; flex-direction: column; gap: var(--sf-space-2); }
|
|
238
|
+
/* A code block hides its overflow, so as a flex item it would shrink to nothing; it keeps its own height and the detail scrolls. */
|
|
239
|
+
.sf-devtools-detail > * { flex: none; }
|
|
240
|
+
.sf-devtools-detail h4, .sf-devtools-pane h4 { margin: 0; font-size: var(--sf-font-size-xs); font-weight: var(--sf-font-weight-semibold); color: var(--sf-color-muted); }
|
|
241
|
+
.sf-devtools-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0 var(--sf-space-2); margin: 0; }
|
|
242
|
+
.sf-devtools-facts dt { color: var(--sf-color-muted); }
|
|
243
|
+
.sf-devtools-facts dd { margin: 0; overflow-wrap: anywhere; font-family: var(--sf-font-mono); font-size: var(--sf-font-size-xs); }
|
|
244
|
+
.sf-devtools-empty { margin: 0; padding: var(--sf-space-2); color: var(--sf-color-muted); }
|
|
245
|
+
.sf-devtools-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--sf-space-1); }
|
|
246
|
+
.sf-devtools-list li { overflow-wrap: anywhere; }
|
|
247
|
+
.sf-devtools-list code { font-family: var(--sf-font-mono); font-size: var(--sf-font-size-xs); }
|
|
248
|
+
.sf-devtools-problem { color: var(--sf-color-danger); }
|
|
249
|
+
.sf-devtools-node {
|
|
250
|
+
display: flex;
|
|
251
|
+
align-items: center;
|
|
252
|
+
gap: var(--sf-space-1);
|
|
253
|
+
min-height: var(--sf-target-min);
|
|
254
|
+
padding: 0 var(--sf-space-2);
|
|
255
|
+
border-bottom: 1px solid var(--sf-color-divider);
|
|
256
|
+
white-space: nowrap;
|
|
257
|
+
}
|
|
258
|
+
.sf-devtools-node[aria-selected="true"] { background: var(--sf-color-accent-soft); }
|
|
259
|
+
.sf-devtools-node small { color: var(--sf-color-muted); }
|
|
260
|
+
.sf-devtools-preview { flex: 1; min-height: 0; overflow: auto; }
|
|
261
|
+
.sf-devtools-select { max-width: 100%; }
|
|
262
|
+
@container sf-devtools (max-width: 40rem) {
|
|
263
|
+
/* The title and the host's controls share the first line; the scrubber takes the second. */
|
|
264
|
+
.sf-devtools-scrub { order: 3; flex-basis: 100%; }
|
|
265
|
+
.sf-devtools-scrub .sf-devtools-step { flex: 0 1 8rem; }
|
|
266
|
+
.sf-devtools-row { grid-template-columns: 6.5em minmax(0, 1fr) auto; }
|
|
267
|
+
.sf-devtools-row .sf-devtools-kind, .sf-devtools-row .sf-devtools-ms { display: none; }
|
|
268
|
+
.sf-devtools-workspace { height: auto; }
|
|
269
|
+
.sf-devtools-pane { flex: none; }
|
|
270
|
+
.sf-devtools-rows, .sf-devtools-tree { flex: none; height: 14rem; }
|
|
271
|
+
.sf-devtools-detail { flex: none; max-height: 20rem; }
|
|
272
|
+
.sf-devtools-preview { flex: none; }
|
|
273
|
+
}
|
|
274
|
+
@media (forced-colors: active) {
|
|
275
|
+
.sf-devtools-row[aria-selected="true"], .sf-devtools-node[aria-selected="true"] { outline: 2px solid Highlight; outline-offset: -2px; }
|
|
276
|
+
}
|
|
277
|
+
`;
|
|
278
|
+
/** Adds a stylesheet to a document once, by id. */
|
|
279
|
+
export function addStyles(doc, id, css) {
|
|
280
|
+
const existing = doc.getElementById(id);
|
|
281
|
+
if (existing) {
|
|
282
|
+
// Kept in step, so a newer copy of the styles (a hot reload, a second version on the page) is not left stale.
|
|
283
|
+
if (existing.textContent !== css)
|
|
284
|
+
existing.textContent = css;
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
const style = doc.createElement("style");
|
|
288
|
+
style.id = id;
|
|
289
|
+
style.textContent = css;
|
|
290
|
+
doc.head.appendChild(style);
|
|
291
|
+
}
|
|
292
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,oEAAoE;AACpE,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsGxB,CAAC;AAEF,qEAAqE;AACrE,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsKxB,CAAC;AAEF,mDAAmD;AACnD,MAAM,UAAU,SAAS,CAAC,GAAa,EAAE,EAAU,EAAE,GAAW;IAC9D,MAAM,QAAQ,GAAG,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;IACxC,IAAI,QAAQ,EAAE,CAAC;QACb,8GAA8G;QAC9G,IAAI,QAAQ,CAAC,WAAW,KAAK,GAAG;YAAE,QAAQ,CAAC,WAAW,GAAG,GAAG,CAAC;QAC7D,OAAO;IACT,CAAC;IACD,MAAM,KAAK,GAAG,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACzC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC;IACd,KAAK,CAAC,WAAW,GAAG,GAAG,CAAC;IACxB,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["/*\n * The dev tools' own styles, added to the page (and to a popped-out window)\n * as a <style> element when the tools are on, so a host adds no stylesheet\n * for them. Every colour, size and time is a --sf-* token.\n */\n\n/** For the floating button and the dock: loaded with the widget. */\nexport const SHELL_CSS = `\n.sf-devtools-button {\n position: fixed;\n right: var(--sf-space-3);\n bottom: var(--sf-space-3);\n z-index: 2147483000;\n display: inline-flex;\n align-items: center;\n gap: var(--sf-space-1);\n height: max(var(--sf-target-min), var(--sf-control-size));\n min-width: max(var(--sf-target-min), var(--sf-control-size));\n padding: 0 var(--sf-space-2);\n border: 1px solid var(--sf-glass-edge);\n border-radius: var(--sf-radius-full);\n background: var(--sf-glass-regular);\n -webkit-backdrop-filter: var(--sf-glass-filter);\n backdrop-filter: var(--sf-glass-filter);\n box-shadow: inset 0 1px 0 var(--sf-glass-highlight), var(--sf-glass-shadow);\n color: var(--sf-color-text);\n font: inherit;\n font-size: var(--sf-font-size-sm);\n font-weight: var(--sf-font-weight-medium);\n cursor: pointer;\n transition: transform var(--sf-press-time) var(--sf-press-ease);\n}\n.sf-devtools-button:active { transform: scale(var(--sf-press-scale)); }\n.sf-devtools-button:focus-visible,\n.sf-devtools-grip:focus-visible {\n outline: 2px solid var(--sf-color-focus);\n outline-offset: 2px;\n}\n.sf-devtools-button svg { width: 1.1em; height: 1.1em; }\n.sf-devtools-count {\n padding: 0 var(--sf-space-1);\n border-radius: var(--sf-radius-full);\n background: var(--sf-color-danger);\n color: var(--sf-color-bg);\n font-size: var(--sf-font-size-xs);\n font-weight: var(--sf-font-weight-semibold);\n font-variant-numeric: tabular-nums;\n}\n.sf-devtools-inline { position: relative; min-height: 4rem; }\n.sf-devtools-inline > .sf-devtools-button { position: absolute; }\n.sf-devtools-dock {\n position: fixed;\n z-index: 2147483000;\n display: flex;\n border: 1px solid var(--sf-glass-edge);\n background: var(--sf-color-bg-1, var(--sf-color-bg));\n color: var(--sf-color-text);\n box-shadow: var(--sf-glass-shadow);\n font-size: var(--sf-font-size-sm);\n animation: sf-fade var(--sf-duration) var(--sf-ease-out);\n}\n/* Focus is moved here when the tools open, so the next Tab is inside them; the frame itself is not a control. */\n.sf-devtools-dock:focus { outline: none; }\n.sf-devtools-dock[data-dock=\"bottom\"] { left: 0; right: 0; bottom: 0; flex-direction: column; }\n.sf-devtools-dock[data-dock=\"right\"] { top: 0; right: 0; bottom: 0; flex-direction: row; max-width: 100vw; }\n.sf-devtools-inline > .sf-devtools-dock { position: relative; inset: auto; flex-direction: column; margin-top: var(--sf-space-2); border-radius: var(--sf-radius); }\n.sf-devtools-grip {\n flex: none;\n border: 0;\n padding: 0;\n background: var(--sf-color-divider);\n touch-action: none;\n}\n.sf-devtools-dock[data-dock=\"bottom\"] > .sf-devtools-grip { height: var(--sf-space-1); cursor: ns-resize; }\n.sf-devtools-dock[data-dock=\"right\"] > .sf-devtools-grip { width: var(--sf-space-1); cursor: ew-resize; }\n.sf-devtools-grip:hover { background: var(--sf-color-accent); }\n.sf-devtools-host { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }\n.sf-devtools-wait { padding: var(--sf-space-3); color: var(--sf-color-muted); }\n/* Narrow screens: the dock is always along the bottom, full width. */\n@media (max-width: 40rem) {\n /* One edge only on a narrow screen, so no control to change it. */\n .sf-devtools-icon.sf-devtools-dockside { display: none; }\n .sf-devtools-dock[data-dock=\"right\"] { top: auto; left: 0; flex-direction: column; }\n .sf-devtools-dock[data-dock=\"right\"] > .sf-devtools-grip { width: auto; height: var(--sf-space-1); cursor: ns-resize; }\n}\n@media (forced-colors: active) {\n .sf-devtools-button, .sf-devtools-dock { border-color: CanvasText; }\n}\n/* While a person is picking a component on the page. */\n.sf-devtools-picking, .sf-devtools-picking * { cursor: crosshair !important; }\n.sf-devtools-picking .sf-devtools-dock *, .sf-devtools-picking .sf-devtools-button { cursor: revert !important; }\n/* Over the component picked in the panel, on the page. It never takes a press. */\n.sf-devtools-inspect {\n position: fixed;\n top: 0;\n left: 0;\n /* Under the tools' own drawer and button. */\n z-index: 2147482999;\n pointer-events: none;\n box-sizing: border-box;\n outline: 2px solid var(--sf-color-focus);\n outline-offset: 1px;\n border-radius: var(--sf-radius-sm);\n}\n.sf-devtools-inspect::before { content: \"\"; position: absolute; inset: 0; border-radius: inherit; background: var(--sf-color-accent); opacity: 0.14; }\n@media (forced-colors: active) {\n .sf-devtools-inspect { outline-color: Highlight; }\n .sf-devtools-inspect::before { display: none; }\n}\n`;\n\n/** For the panel: loaded with it, only when the tools are opened. */\nexport const PANEL_CSS = `\n.sf-devtools {\n flex: 1;\n min-height: 0;\n min-width: 0;\n /* A column, not grid rows: the note between the bar and the body is absent when it is empty, and the body must still take what is left. */\n display: flex;\n flex-direction: column;\n container-type: inline-size;\n container-name: sf-devtools;\n background: var(--sf-color-bg-1, var(--sf-color-bg));\n color: var(--sf-color-text);\n font-size: var(--sf-font-size-sm);\n}\n.sf-devtools-bar {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--sf-space-2);\n padding: var(--sf-space-1) var(--sf-space-2);\n border-bottom: 1px solid var(--sf-color-divider);\n}\n.sf-devtools-title { margin: 0; font-size: var(--sf-font-size-sm); font-weight: var(--sf-font-weight-semibold); }\n.sf-devtools-scrub { flex: 1 1 16rem; display: flex; align-items: center; gap: var(--sf-space-1); min-width: 0; }\n.sf-devtools-scrub input[type=\"range\"] { flex: 1; min-width: 4rem; accent-color: var(--sf-color-accent); height: var(--sf-target-min); }\n.sf-devtools-step { min-width: 0; color: var(--sf-color-muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.sf-devtools-actions { display: flex; align-items: center; gap: var(--sf-space-1); margin-left: auto; }\n.sf-devtools-icon {\n display: inline-grid;\n place-items: center;\n width: max(var(--sf-target-min), var(--sf-control-size));\n height: max(var(--sf-target-min), var(--sf-control-size));\n padding: 0;\n border: 1px solid var(--sf-color-edge, transparent);\n border-radius: var(--sf-radius);\n background: var(--sf-color-fill-2);\n color: var(--sf-color-text);\n cursor: pointer;\n transition: background-color var(--sf-duration-fast) var(--sf-ease), transform var(--sf-press-time) var(--sf-press-ease);\n}\n.sf-devtools-icon:hover:not([aria-disabled=\"true\"]) { background: var(--sf-color-fill-1); }\n.sf-devtools-icon:active:not([aria-disabled=\"true\"]) { transform: scale(var(--sf-press-scale)); }\n.sf-devtools-icon[aria-pressed=\"true\"] { background: var(--sf-color-accent-soft); color: var(--sf-color-accent-text); }\n.sf-devtools-icon[aria-disabled=\"true\"] { color: var(--sf-color-label-4, var(--sf-color-muted)); cursor: default; }\n.sf-devtools-icon[aria-pressed=\"true\"] { background: var(--sf-color-accent-soft); color: var(--sf-color-accent-text); }\n.sf-devtools-icon:focus-visible, .sf-devtools-rows:focus-visible, .sf-devtools-tree:focus-visible, .sf-devtools-chip:focus-visible, .sf-devtools-detail:focus-visible, .sf-devtools-preview:focus-visible {\n outline: 2px solid var(--sf-color-focus);\n outline-offset: -2px;\n}\n.sf-devtools-icon svg { width: 1.15em; height: 1.15em; }\n.sf-devtools-note {\n margin: 0;\n padding: var(--sf-space-1) var(--sf-space-2);\n border-bottom: 1px solid var(--sf-color-divider);\n background: var(--sf-color-accent-soft);\n color: var(--sf-color-text);\n}\n.sf-devtools-note:empty { display: none; }\n.sf-devtools-body { position: relative; flex: 1 1 0; min-height: 0; min-width: 0; overflow: auto; padding: var(--sf-space-2); }\n.sf-devtools-workspace { height: 100%; }\n.sf-devtools-pane { display: flex; flex-direction: column; gap: var(--sf-space-2); flex: 1 1 auto; min-height: 0; min-width: 0; }\n.sf-devtools-filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sf-space-1); }\n.sf-devtools-chip {\n min-height: var(--sf-target-min);\n padding: 0 var(--sf-space-2);\n border: 1px solid var(--sf-color-edge, transparent);\n border-radius: var(--sf-radius-full);\n background: var(--sf-color-fill-3);\n color: var(--sf-color-muted);\n font: inherit;\n font-size: var(--sf-font-size-xs);\n cursor: pointer;\n transition: background-color var(--sf-duration-fast) var(--sf-ease);\n}\n.sf-devtools-chip[aria-pressed=\"true\"] { background: var(--sf-color-accent-soft); color: var(--sf-color-accent-text); font-weight: var(--sf-font-weight-semibold); }\n.sf-devtools-only { display: inline-flex; align-items: center; gap: var(--sf-space-1); align-self: flex-start; padding-inline-start: var(--sf-space-2); border-radius: var(--sf-radius-full); background: var(--sf-color-accent-soft); color: var(--sf-color-accent-text); font-size: var(--sf-font-size-xs); font-weight: var(--sf-font-weight-semibold); }\n.sf-devtools-only code { font-family: var(--sf-font-mono); font-weight: var(--sf-font-weight-regular); }\n.sf-devtools-causes { display: flex; flex-direction: column; gap: var(--sf-space-1); flex: none; }\n.sf-devtools-cause { display: grid; grid-template-columns: max-content minmax(0, 1fr) max-content; align-items: start; gap: var(--sf-space-2); }\n.sf-devtools-cause small { color: var(--sf-color-muted); font-family: var(--sf-font-mono); font-size: var(--sf-font-size-xs); overflow-wrap: anywhere; }\n.sf-devtools-cause-mark { font-size: var(--sf-font-size-xs); font-weight: var(--sf-font-weight-semibold); color: var(--sf-color-muted); }\n.sf-devtools-cause[data-severity=\"error\"] .sf-devtools-cause-mark { color: var(--sf-color-danger); }\n.sf-devtools-cause[data-severity=\"warning\"] .sf-devtools-cause-mark { color: var(--sf-color-warning); }\n.sf-devtools-cause-by { margin: 0; color: var(--sf-color-muted); font-size: var(--sf-font-size-xs); }\n.sf-devtools-said { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }\ndiv.sf-devtools-said { display: flex; flex-direction: column; gap: var(--sf-space-2); white-space: normal; }\ndiv.sf-devtools-said > p { margin: 0; white-space: pre-wrap; }\ndiv.sf-devtools-said ul { margin: 0; padding-inline-start: var(--sf-space-4); display: flex; flex-direction: column; gap: var(--sf-space-1); font-family: var(--sf-font-mono); font-size: var(--sf-font-size-xs); }\ndiv.sf-devtools-said summary { padding-block: var(--sf-space-1); color: var(--sf-color-muted); cursor: pointer; }\ndiv.sf-devtools-said details[open] > summary { margin-block-end: var(--sf-space-1); }\n.sf-devtools-filters label { display: inline-flex; align-items: center; gap: var(--sf-space-1); color: var(--sf-color-muted); }\n.sf-devtools-rows, .sf-devtools-tree {\n position: relative;\n flex: 1 1 4.5rem;\n min-height: 4.5rem;\n overflow: auto;\n border-radius: var(--sf-radius-sm);\n background: var(--sf-color-bg-2, var(--sf-color-surface));\n}\n.sf-devtools-row {\n position: absolute;\n left: 0;\n right: 0;\n display: grid;\n grid-template-columns: 6.5em 5.5em minmax(0, 1fr) auto auto;\n align-items: center;\n gap: var(--sf-space-2);\n padding: 0 var(--sf-space-2);\n border-bottom: 1px solid var(--sf-color-divider);\n cursor: default;\n white-space: nowrap;\n}\n.sf-devtools-row > span { overflow: hidden; text-overflow: ellipsis; }\n.sf-devtools-row[aria-selected=\"true\"] { background: var(--sf-color-accent-soft); }\n.sf-devtools-row[data-later] { color: var(--sf-color-muted); }\n.sf-devtools-time, .sf-devtools-ms { color: var(--sf-color-muted); font-family: var(--sf-font-mono); font-size: var(--sf-font-size-xs); font-variant-numeric: tabular-nums; }\n.sf-devtools-kind { font-size: var(--sf-font-size-xs); color: var(--sf-color-muted); }\n.sf-devtools-name { font-family: var(--sf-font-mono); font-size: var(--sf-font-size-xs); }\n.sf-devtools-name small { color: var(--sf-color-muted); font-size: inherit; }\n.sf-devtools-status { font-size: var(--sf-font-size-xs); font-weight: var(--sf-font-weight-semibold); }\n.sf-devtools-status[data-status=\"error\"] { color: var(--sf-color-danger); }\n.sf-devtools-status[data-status=\"warning\"] { color: var(--sf-color-warning); }\n.sf-devtools-status[data-status=\"ok\"] { color: var(--sf-color-success); }\n.sf-devtools-status[data-status=\"running\"] { color: var(--sf-color-muted); }\n.sf-devtools-status[data-status=\"cancelled\"] { color: var(--sf-color-muted); font-weight: var(--sf-font-weight-regular); }\n/* What a row holds in full gets most of a pane: the list above it keeps a few rows, and the pane scrolls when both cannot fit. */\n.sf-devtools-detail { flex: 3 1 9rem; min-height: 9rem; overflow: auto; display: flex; flex-direction: column; gap: var(--sf-space-2); }\n/* A code block hides its overflow, so as a flex item it would shrink to nothing; it keeps its own height and the detail scrolls. */\n.sf-devtools-detail > * { flex: none; }\n.sf-devtools-detail h4, .sf-devtools-pane h4 { margin: 0; font-size: var(--sf-font-size-xs); font-weight: var(--sf-font-weight-semibold); color: var(--sf-color-muted); }\n.sf-devtools-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0 var(--sf-space-2); margin: 0; }\n.sf-devtools-facts dt { color: var(--sf-color-muted); }\n.sf-devtools-facts dd { margin: 0; overflow-wrap: anywhere; font-family: var(--sf-font-mono); font-size: var(--sf-font-size-xs); }\n.sf-devtools-empty { margin: 0; padding: var(--sf-space-2); color: var(--sf-color-muted); }\n.sf-devtools-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--sf-space-1); }\n.sf-devtools-list li { overflow-wrap: anywhere; }\n.sf-devtools-list code { font-family: var(--sf-font-mono); font-size: var(--sf-font-size-xs); }\n.sf-devtools-problem { color: var(--sf-color-danger); }\n.sf-devtools-node {\n display: flex;\n align-items: center;\n gap: var(--sf-space-1);\n min-height: var(--sf-target-min);\n padding: 0 var(--sf-space-2);\n border-bottom: 1px solid var(--sf-color-divider);\n white-space: nowrap;\n}\n.sf-devtools-node[aria-selected=\"true\"] { background: var(--sf-color-accent-soft); }\n.sf-devtools-node small { color: var(--sf-color-muted); }\n.sf-devtools-preview { flex: 1; min-height: 0; overflow: auto; }\n.sf-devtools-select { max-width: 100%; }\n@container sf-devtools (max-width: 40rem) {\n /* The title and the host's controls share the first line; the scrubber takes the second. */\n .sf-devtools-scrub { order: 3; flex-basis: 100%; }\n .sf-devtools-scrub .sf-devtools-step { flex: 0 1 8rem; }\n .sf-devtools-row { grid-template-columns: 6.5em minmax(0, 1fr) auto; }\n .sf-devtools-row .sf-devtools-kind, .sf-devtools-row .sf-devtools-ms { display: none; }\n .sf-devtools-workspace { height: auto; }\n .sf-devtools-pane { flex: none; }\n .sf-devtools-rows, .sf-devtools-tree { flex: none; height: 14rem; }\n .sf-devtools-detail { flex: none; max-height: 20rem; }\n .sf-devtools-preview { flex: none; }\n}\n@media (forced-colors: active) {\n .sf-devtools-row[aria-selected=\"true\"], .sf-devtools-node[aria-selected=\"true\"] { outline: 2px solid Highlight; outline-offset: -2px; }\n}\n`;\n\n/** Adds a stylesheet to a document once, by id. */\nexport function addStyles(doc: Document, id: string, css: string): void {\n const existing = doc.getElementById(id);\n if (existing) {\n // Kept in step, so a newer copy of the styles (a hot reload, a second version on the page) is not left stale.\n if (existing.textContent !== css) existing.textContent = css;\n return;\n }\n const style = doc.createElement(\"style\");\n style.id = id;\n style.textContent = css;\n doc.head.appendChild(style);\n}\n"]}
|