tempo-sdk 0.0.51 → 0.0.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/editor.d.ts +1 -1
- package/dist/assets/editor.js +1 -1
- package/dist/assets/index.d.ts +3 -3
- package/dist/assets/index.js +4 -2
- package/dist/assets/index.js.map +1 -1
- package/dist/assets/parser.d.ts +10 -4
- package/dist/assets/parser.js +1 -1
- package/dist/canvas/editor.d.ts +11 -16
- package/dist/canvas/editor.js +79 -49
- package/dist/canvas/editor.js.map +1 -1
- package/dist/canvas/index.d.ts +15 -11
- package/dist/canvas/index.js +130 -47
- package/dist/canvas/index.js.map +1 -1
- package/dist/canvas/interact-projection.js +4 -3
- package/dist/canvas/parser.d.ts +10 -5
- package/dist/canvas/parser.js +3 -1
- package/dist/canvas/svelte.d.ts +9 -7
- package/dist/canvas/svelte.js +20 -5
- package/dist/canvas/svelte.js.map +1 -1
- package/dist/chunk-2IQD2KPS.js +219 -0
- package/dist/chunk-2IQD2KPS.js.map +1 -0
- package/dist/chunk-5BHIHP25.js +410 -0
- package/dist/chunk-5BHIHP25.js.map +1 -0
- package/dist/chunk-EMYYTS6D.js +1585 -0
- package/dist/chunk-EMYYTS6D.js.map +1 -0
- package/dist/{chunk-DX6XAXCK.js → chunk-N2TYN3RB.js} +189 -420
- package/dist/chunk-N2TYN3RB.js.map +1 -0
- package/dist/{chunk-LFYKJJC5.js → chunk-QXL6GL2P.js} +18 -3
- package/dist/chunk-QXL6GL2P.js.map +1 -0
- package/dist/{chunk-QP2NTODB.js → chunk-RHHVVWAC.js} +115 -25
- package/dist/chunk-RHHVVWAC.js.map +1 -0
- package/dist/chunk-TL4MGN7E.js +2570 -0
- package/dist/chunk-TL4MGN7E.js.map +1 -0
- package/dist/{chunk-PULSTDX2.js → chunk-U3SLJNRS.js} +284 -46
- package/dist/chunk-U3SLJNRS.js.map +1 -0
- package/dist/{chunk-ZZYNOX24.js → chunk-U64AHDHZ.js} +1708 -2461
- package/dist/chunk-U64AHDHZ.js.map +1 -0
- package/dist/{chunk-O65OD3NA.js → chunk-XLEKCOB7.js} +6 -5
- package/dist/chunk-XLEKCOB7.js.map +1 -0
- package/dist/expo/plugin.cjs +1256 -16
- package/dist/expo/plugin.cjs.map +1 -1
- package/dist/expo/plugin.d.cts +0 -1
- package/dist/expo/plugin.d.ts +0 -1
- package/dist/expo/plugin.js +1 -1
- package/dist/expo-babel-plugin.cjs +1258 -16
- package/dist/expo-babel-plugin.cjs.map +1 -1
- package/dist/expo-babel-plugin.d.cts +8 -5
- package/dist/expo-babel-plugin.d.ts +8 -5
- package/dist/expo-babel-plugin.js +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +464 -154
- package/dist/index.js.map +1 -1
- package/dist/nextjs/plugin.cjs +151 -0
- package/dist/nextjs/plugin.cjs.map +1 -1
- package/dist/nextjs/plugin.d.cts +1 -1
- package/dist/nextjs/plugin.d.ts +1 -1
- package/dist/nextjs/plugin.js +1 -1
- package/dist/nextjs-loader.cjs +1432 -35
- package/dist/nextjs-loader.cjs.map +1 -1
- package/dist/nextjs.cjs +17 -2
- package/dist/nextjs.cjs.map +1 -1
- package/dist/nextjs.d.cts +14 -3
- package/dist/nextjs.d.ts +14 -3
- package/dist/nextjs.js +1 -1
- package/dist/{page-xi1aI5a7.d.ts → page-DwLnOM5d.d.ts} +12 -6
- package/dist/{storyboard-CBHki7Aw.d.ts → storyboard-BtQuVGpl.d.ts} +35 -17
- package/dist/svelte.d.ts +3 -2
- package/dist/svelte.js +103 -29
- package/dist/svelte.js.map +1 -1
- package/dist/{types-C7cvcY6T.d.ts → types-C8OIU-kc.d.ts} +1 -1
- package/dist/v1-client-compat-qxaXEDm_.d.ts +23 -0
- package/package.json +5 -2
- package/dist/chunk-57KAYXHF.js +0 -19
- package/dist/chunk-57KAYXHF.js.map +0 -1
- package/dist/chunk-CB5NJJJT.js +0 -345
- package/dist/chunk-CB5NJJJT.js.map +0 -1
- package/dist/chunk-DX6XAXCK.js.map +0 -1
- package/dist/chunk-F3KJDCMU.js +0 -19
- package/dist/chunk-F3KJDCMU.js.map +0 -1
- package/dist/chunk-LFYKJJC5.js.map +0 -1
- package/dist/chunk-O65OD3NA.js.map +0 -1
- package/dist/chunk-PULSTDX2.js.map +0 -1
- package/dist/chunk-QP2NTODB.js.map +0 -1
- package/dist/chunk-ZZYNOX24.js.map +0 -1
|
@@ -103,4 +103,4 @@ type ParsedAssetFile = {
|
|
|
103
103
|
* tools that surface them (§7.3). */
|
|
104
104
|
type AssetEditFailureCode = "asset_not_found" | "config_not_editable" | "export_not_found" | "already_defined" | "not_definable";
|
|
105
105
|
|
|
106
|
-
export { type AssetEditFailureCode as A, type ParsedAssetReference as P, type StaticValue as S, UNRESOLVED_VALUE as U, type AssetSourceSpan as a, type AssetExportKind as b, type
|
|
106
|
+
export { type AssetEditFailureCode as A, type ParsedAssetReference as P, type StaticValue as S, UNRESOLVED_VALUE as U, type AssetSourceSpan as a, type AssetExportKind as b, type AssetParseError as c, type ParsedAssetFile as d, type AssetParseErrorCode as e, type AssetSpans as f, type ParsedAssetDeclaration as g, type ParsedAssetVariant as h, type UnresolvedValue as i, isUnresolvedValue as j };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated V1 client compat.
|
|
3
|
+
*
|
|
4
|
+
* Everything a released V1 Tempo client (app 0.0.114, driving tempo-sdk
|
|
5
|
+
* 0.0.51 behavior) still expects from this host and that V2 no longer does.
|
|
6
|
+
* A workspace's installed tempo-sdk follows registry `latest` independently
|
|
7
|
+
* of the desktop app's update cadence, so a V1 client keeps loading hosts
|
|
8
|
+
* built from this SDK until the force-upgrade floor ages it out.
|
|
9
|
+
*
|
|
10
|
+
* Every call site gates on `isV1CanvasClient()`, so a V2 client runs today's
|
|
11
|
+
* code paths untouched. Delete this file once no protocol-1 client is
|
|
12
|
+
* supported; the compiler then lists every call site to remove.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** The layout spelling a V1 client still writes and type-checks
|
|
16
|
+
* (`tsc --noEmit` over canvases against `TempoStoryboard`). */
|
|
17
|
+
type V1LayoutCompat = {
|
|
18
|
+
/** @deprecated A legacy responsive marker: the width and height beside it
|
|
19
|
+
* are first-paint hints, not a frame. V2 reads the triple as responsive. */
|
|
20
|
+
intrinsicSizing?: "root-element";
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type { V1LayoutCompat as V };
|
package/package.json
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tempo-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.57",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"tag": "sdk-v2-latest"
|
|
6
|
+
},
|
|
4
7
|
"type": "module",
|
|
5
8
|
"description": "Tempo SDK — Vite, Next.js, and Expo plugins for JSX annotation and shared page/storyboard types",
|
|
6
9
|
"repository": {
|
|
@@ -81,7 +84,7 @@
|
|
|
81
84
|
"demo": "TEMPO=true pnpm --filter @tempo-modules/vite-annotate-plugin-demo dev",
|
|
82
85
|
"demo:nextjs": "TEMPO=true pnpm --filter @tempo-modules/tempo-sdk-nextjs-demo dev",
|
|
83
86
|
"test": "vitest run",
|
|
84
|
-
"test:browser": "vitest run asset-live-preview-browser.test.ts asset-popover-lifecycle-browser.test.ts component-controls-browser.test.ts canvas-controls-browser.test.ts canvas-capture-determinism-browser.test.ts canvas-host-vite-e2e.test.ts canvas-host-packed-sdk-e2e.test.ts error-tracking-e2e.test.ts",
|
|
87
|
+
"test:browser": "vitest run pruned-module-deletion-browser.test.ts asset-live-preview-browser.test.ts asset-popover-lifecycle-browser.test.ts component-controls-browser.test.ts canvas-controls-browser.test.ts canvas-capture-determinism-browser.test.ts canvas-host-vite-e2e.test.ts canvas-host-packed-sdk-e2e.test.ts error-tracking-e2e.test.ts",
|
|
85
88
|
"test:watch": "vitest",
|
|
86
89
|
"test:nextjs:unit": "vitest run nextjs-loader.test.ts nextjs-wrapper.test.ts nextjs-fixtures.test.ts nextjs-published.test.ts",
|
|
87
90
|
"test:nextjs:integration": "vitest run nextjs-e2e-correctness.test.ts",
|
package/dist/chunk-57KAYXHF.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// ../../modules/iframe-projection/combined/projection-pending.ts
|
|
2
|
-
var PROJECTION_PENDING_ATTRIBUTE = "data-tempo-projection-pending";
|
|
3
|
-
function isProjectionPendingOnly(rootElement) {
|
|
4
|
-
const children = rootElement.children;
|
|
5
|
-
if (children.length === 0) return false;
|
|
6
|
-
for (let index = 0; index < children.length; index += 1) {
|
|
7
|
-
const child = children[index];
|
|
8
|
-
if (!child || !child.hasAttribute(PROJECTION_PENDING_ATTRIBUTE)) {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export {
|
|
16
|
-
PROJECTION_PENDING_ATTRIBUTE,
|
|
17
|
-
isProjectionPendingOnly
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=chunk-57KAYXHF.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../modules/iframe-projection/combined/projection-pending.ts"],"sourcesContent":["/**\n * The pending-marker contract, shared between the source app and the producer.\n *\n * A Tempo-owned admission or Suspense boundary renders a single hidden marker\n * element while waiting instead of `null`. That turns \"this subtree is briefly\n * empty because content is loading\" — which is indistinguishable from \"this\n * subtree is now empty\" once it reaches the DOM — into something the producer can\n * recognise without inspecting React internals.\n *\n * This file is imported directly by tempo-sdk and bundled into it, so it must\n * stay dependency-free: no imports, no DOM globals beyond the element passed in.\n */\n\n/** Marks an element as a Tempo-owned boundary's pending placeholder. */\nexport const PROJECTION_PENDING_ATTRIBUTE = \"data-tempo-projection-pending\";\n\n/**\n * Is this root showing a pending marker and nothing else?\n *\n * The rule is deliberately strict — marker-ONLY. A root that still holds real\n * content alongside a marker is a partially-loaded tree, and partial content is\n * exactly what the mirror should show; only a root whose entire visible output\n * is placeholder has nothing worth publishing. An empty root is likewise not\n * pending: emptiness with no marker is a real state (a conditional unmount, a\n * foreign boundary with `fallback={null}`) and stays a real change.\n */\nexport function isProjectionPendingOnly(rootElement: Element): boolean {\n const children = rootElement.children;\n if (children.length === 0) return false;\n for (let index = 0; index < children.length; index += 1) {\n const child = children[index];\n if (!child || !child.hasAttribute(PROJECTION_PENDING_ATTRIBUTE)) {\n return false;\n }\n }\n return true;\n}\n"],"mappings":";AAcO,IAAM,+BAA+B;AAYrC,SAAS,wBAAwB,aAA+B;AACrE,QAAM,WAAW,YAAY;AAC7B,MAAI,SAAS,WAAW,EAAG,QAAO;AAClC,WAAS,QAAQ,GAAG,QAAQ,SAAS,QAAQ,SAAS,GAAG;AACvD,UAAM,QAAQ,SAAS,KAAK;AAC5B,QAAI,CAAC,SAAS,CAAC,MAAM,aAAa,4BAA4B,GAAG;AAC/D,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
package/dist/chunk-CB5NJJJT.js
DELETED
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
// expo-babel-plugin.ts
|
|
2
|
-
import { existsSync } from "fs";
|
|
3
|
-
import { dirname, resolve } from "path";
|
|
4
|
-
import { createFilter } from "@rollup/pluginutils";
|
|
5
|
-
|
|
6
|
-
// annotation-strategy.ts
|
|
7
|
-
import { realpathSync, statSync } from "fs";
|
|
8
|
-
import { relative } from "path";
|
|
9
|
-
|
|
10
|
-
// ../../modules/annotation/source-version.ts
|
|
11
|
-
function sourceVersionHash(content) {
|
|
12
|
-
let djb2 = 5381;
|
|
13
|
-
let sdbm = 0;
|
|
14
|
-
for (let i = 0; i < content.length; i++) {
|
|
15
|
-
const c = content.charCodeAt(i);
|
|
16
|
-
djb2 = (djb2 << 5) + djb2 ^ c;
|
|
17
|
-
sdbm = c + (sdbm << 6) + (sdbm << 16) - sdbm | 0;
|
|
18
|
-
}
|
|
19
|
-
return toHex8(djb2) + toHex8(sdbm);
|
|
20
|
-
}
|
|
21
|
-
function toHex8(n) {
|
|
22
|
-
return (n >>> 0).toString(16).padStart(8, "0");
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// annotation-strategy.ts
|
|
26
|
-
var DEFAULT_EXCLUDE = ["**/node_modules/**"];
|
|
27
|
-
var HTML_VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
28
|
-
"area",
|
|
29
|
-
"base",
|
|
30
|
-
"br",
|
|
31
|
-
"col",
|
|
32
|
-
"embed",
|
|
33
|
-
"hr",
|
|
34
|
-
"img",
|
|
35
|
-
"input",
|
|
36
|
-
"link",
|
|
37
|
-
"meta",
|
|
38
|
-
"param",
|
|
39
|
-
"source",
|
|
40
|
-
"track",
|
|
41
|
-
"wbr"
|
|
42
|
-
]);
|
|
43
|
-
function cleanModuleId(id) {
|
|
44
|
-
return id.replace(/[?#].*$/, "");
|
|
45
|
-
}
|
|
46
|
-
function resolveCanonicalRoot(root) {
|
|
47
|
-
try {
|
|
48
|
-
return realpathSync.native(root);
|
|
49
|
-
} catch {
|
|
50
|
-
return root;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function isIntrinsicElement(tagName) {
|
|
54
|
-
return tagName.length > 0 && tagName[0] === tagName[0].toLowerCase();
|
|
55
|
-
}
|
|
56
|
-
function hasJsxAttribute(info, attrName) {
|
|
57
|
-
for (const attr of info.element.openingElement.attributes) {
|
|
58
|
-
const name = attr.name;
|
|
59
|
-
if (name?.name === attrName) return true;
|
|
60
|
-
}
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
function defaultComputeAnnotatedProps(info, filepath, modifiedtsMs, sourceVersion) {
|
|
64
|
-
return {
|
|
65
|
-
"data-tempo-filepath": filepath,
|
|
66
|
-
"data-tempo-position": info.element.openingElement.start,
|
|
67
|
-
"data-tempo-modifiedts": modifiedtsMs,
|
|
68
|
-
// Content-hash identity of the file this element was annotated from. The
|
|
69
|
-
// canvas reconcile loop equality-compares it against the write pipeline's
|
|
70
|
-
// computed version to decide whether a capture reflects a given edit.
|
|
71
|
-
"data-tempo-source-version": sourceVersion
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
function computeTempoAnnotatedProps(params) {
|
|
75
|
-
const {
|
|
76
|
-
info,
|
|
77
|
-
filepath,
|
|
78
|
-
modifiedtsMs,
|
|
79
|
-
sourceVersion,
|
|
80
|
-
computeAnnotatedProps,
|
|
81
|
-
elementSupportOverrides
|
|
82
|
-
} = params;
|
|
83
|
-
const userProps = computeAnnotatedProps ? computeAnnotatedProps(info, filepath, modifiedtsMs, sourceVersion) : defaultComputeAnnotatedProps(info, filepath, modifiedtsMs, sourceVersion);
|
|
84
|
-
if (isIntrinsicElement(info.tagName)) {
|
|
85
|
-
return {
|
|
86
|
-
...userProps,
|
|
87
|
-
"data-tempo-supports-children": hasJsxAttribute(
|
|
88
|
-
info,
|
|
89
|
-
"data-tempo-supports-children"
|
|
90
|
-
) ? void 0 : !HTML_VOID_ELEMENTS.has(info.tagName)
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
const override = elementSupportOverrides?.get(info.tagName);
|
|
94
|
-
if (override) {
|
|
95
|
-
return {
|
|
96
|
-
...userProps,
|
|
97
|
-
"data-tempo-supports-children": hasJsxAttribute(
|
|
98
|
-
info,
|
|
99
|
-
"data-tempo-supports-children"
|
|
100
|
-
) ? void 0 : override.supportsChildren
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
return userProps;
|
|
104
|
-
}
|
|
105
|
-
function getFileAnnotationContext(params) {
|
|
106
|
-
const rawCleanFilename = cleanModuleId(params.filename);
|
|
107
|
-
let cleanFilename = rawCleanFilename;
|
|
108
|
-
if (params.canonicalizeFilename) {
|
|
109
|
-
try {
|
|
110
|
-
cleanFilename = realpathSync.native(rawCleanFilename);
|
|
111
|
-
} catch {
|
|
112
|
-
cleanFilename = rawCleanFilename;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return {
|
|
116
|
-
cleanFilename,
|
|
117
|
-
filepath: relative(params.root, cleanFilename),
|
|
118
|
-
modifiedtsMs: Math.trunc(statSync(cleanFilename).mtimeMs),
|
|
119
|
-
// Hashed once per file per transform (the context is built once, reused
|
|
120
|
-
// for every element) so the per-element funnel just forwards the token.
|
|
121
|
-
sourceVersion: sourceVersionHash(params.source)
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// expo-babel-plugin.ts
|
|
126
|
-
var EXPO_DEFAULT_INCLUDE = ["**/*.tsx", "**/*.jsx", "**/*.js"];
|
|
127
|
-
var FRAGMENT_TAG_NAMES = /* @__PURE__ */ new Set(["Fragment", "React.Fragment"]);
|
|
128
|
-
var REACT_NATIVE_HOST_COMPONENTS = /* @__PURE__ */ new Set([
|
|
129
|
-
"ActivityIndicator",
|
|
130
|
-
"Button",
|
|
131
|
-
"FlatList",
|
|
132
|
-
"Image",
|
|
133
|
-
"ImageBackground",
|
|
134
|
-
"KeyboardAvoidingView",
|
|
135
|
-
"Modal",
|
|
136
|
-
"Pressable",
|
|
137
|
-
"RefreshControl",
|
|
138
|
-
"SafeAreaView",
|
|
139
|
-
"ScrollView",
|
|
140
|
-
"SectionList",
|
|
141
|
-
"Switch",
|
|
142
|
-
"Text",
|
|
143
|
-
"TextInput",
|
|
144
|
-
"TouchableHighlight",
|
|
145
|
-
"TouchableNativeFeedback",
|
|
146
|
-
"TouchableOpacity",
|
|
147
|
-
"TouchableWithoutFeedback",
|
|
148
|
-
"View",
|
|
149
|
-
"VirtualizedList"
|
|
150
|
-
]);
|
|
151
|
-
var REACT_NATIVE_NO_CHILDREN_COMPONENTS = /* @__PURE__ */ new Set([
|
|
152
|
-
"ActivityIndicator",
|
|
153
|
-
"Image",
|
|
154
|
-
"RefreshControl",
|
|
155
|
-
"Switch"
|
|
156
|
-
]);
|
|
157
|
-
var REACT_NATIVE_SUPPORT_OVERRIDES = new Map(
|
|
158
|
-
[...REACT_NATIVE_HOST_COMPONENTS].map((tagName) => [
|
|
159
|
-
tagName,
|
|
160
|
-
{ supportsChildren: !REACT_NATIVE_NO_CHILDREN_COMPONENTS.has(tagName) }
|
|
161
|
-
])
|
|
162
|
-
);
|
|
163
|
-
function hasParserPlugin(plugins, name) {
|
|
164
|
-
return plugins.some(
|
|
165
|
-
(plugin) => Array.isArray(plugin) ? plugin[0] === name : plugin === name
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
function getBabelTagName(name) {
|
|
169
|
-
switch (name.type) {
|
|
170
|
-
case "JSXIdentifier":
|
|
171
|
-
return name.name;
|
|
172
|
-
case "JSXNamespacedName":
|
|
173
|
-
return `${name.namespace.name}:${name.name.name}`;
|
|
174
|
-
case "JSXMemberExpression":
|
|
175
|
-
return `${getBabelTagName(name.object)}.${name.property.name}`;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
function hasAttribute(node, attrName) {
|
|
179
|
-
return node.attributes.some(
|
|
180
|
-
(attr) => attr.type === "JSXAttribute" && attr.name.name === attrName
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
function propValueToExpression(api, value) {
|
|
184
|
-
if (typeof value === "function") {
|
|
185
|
-
return api.template.expression(value.toString())();
|
|
186
|
-
}
|
|
187
|
-
return api.types.valueToNode(value);
|
|
188
|
-
}
|
|
189
|
-
function dataAttrToDataSetKey(attrName) {
|
|
190
|
-
return attrName.replace(/^data-/, "").replace(/-([a-z])/g, (_, char) => char.toUpperCase());
|
|
191
|
-
}
|
|
192
|
-
function findDataSetAttribute(openingElement) {
|
|
193
|
-
return openingElement.attributes.find(
|
|
194
|
-
(attr) => attr.type === "JSXAttribute" && attr.name.name === "dataSet"
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
function addAnnotations(api, tagName, openingElement, props) {
|
|
198
|
-
const t = api.types;
|
|
199
|
-
if (isIntrinsicElement(tagName)) {
|
|
200
|
-
for (const [key, value] of Object.entries(props)) {
|
|
201
|
-
if (value === void 0 || hasAttribute(openingElement, key)) continue;
|
|
202
|
-
openingElement.attributes.push(
|
|
203
|
-
t.jsxAttribute(
|
|
204
|
-
t.jsxIdentifier(key),
|
|
205
|
-
t.jsxExpressionContainer(propValueToExpression(api, value))
|
|
206
|
-
)
|
|
207
|
-
);
|
|
208
|
-
}
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
const dataSetProps = [];
|
|
212
|
-
for (const [key, value] of Object.entries(props)) {
|
|
213
|
-
if (value === void 0) continue;
|
|
214
|
-
dataSetProps.push(
|
|
215
|
-
t.objectProperty(
|
|
216
|
-
t.identifier(dataAttrToDataSetKey(key)),
|
|
217
|
-
propValueToExpression(api, value)
|
|
218
|
-
)
|
|
219
|
-
);
|
|
220
|
-
}
|
|
221
|
-
if (dataSetProps.length === 0) return;
|
|
222
|
-
const existing = findDataSetAttribute(openingElement);
|
|
223
|
-
if (!existing) {
|
|
224
|
-
openingElement.attributes.push(
|
|
225
|
-
t.jsxAttribute(
|
|
226
|
-
t.jsxIdentifier("dataSet"),
|
|
227
|
-
t.jsxExpressionContainer(t.objectExpression(dataSetProps))
|
|
228
|
-
)
|
|
229
|
-
);
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
if (existing.value?.type === "JSXExpressionContainer" && existing.value.expression.type !== "JSXEmptyExpression") {
|
|
233
|
-
existing.value.expression = t.objectExpression([
|
|
234
|
-
t.spreadElement(existing.value.expression),
|
|
235
|
-
...dataSetProps
|
|
236
|
-
]);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
var ROOT_META_NAME = "tempo-project-root";
|
|
240
|
-
function injectProjectRootMeta(api, programPath, root) {
|
|
241
|
-
const setter = api.template.statement(`
|
|
242
|
-
if (typeof document !== "undefined") {
|
|
243
|
-
var __tempoRootMeta = document.querySelector('meta[name="${ROOT_META_NAME}"]');
|
|
244
|
-
if (!__tempoRootMeta) {
|
|
245
|
-
__tempoRootMeta = document.createElement("meta");
|
|
246
|
-
__tempoRootMeta.setAttribute("name", "${ROOT_META_NAME}");
|
|
247
|
-
document.head.appendChild(__tempoRootMeta);
|
|
248
|
-
}
|
|
249
|
-
__tempoRootMeta.setAttribute("content", ${JSON.stringify(root)});
|
|
250
|
-
}
|
|
251
|
-
`)();
|
|
252
|
-
programPath.pushContainer("body", setter);
|
|
253
|
-
}
|
|
254
|
-
function resolveBabelRoot(state, options, filename) {
|
|
255
|
-
return resolveCanonicalRoot(
|
|
256
|
-
resolve(
|
|
257
|
-
options.root ?? findNearestPackageRoot(filename) ?? state.cwd ?? state.file.opts.cwd ?? state.file.opts.root ?? process.cwd()
|
|
258
|
-
)
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
|
-
function findNearestPackageRoot(filename) {
|
|
262
|
-
let current = dirname(filename);
|
|
263
|
-
while (true) {
|
|
264
|
-
if (existsSync(resolve(current, "package.json"))) return current;
|
|
265
|
-
const parent = dirname(current);
|
|
266
|
-
if (parent === current) return null;
|
|
267
|
-
current = parent;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
function resolveFilename(state) {
|
|
271
|
-
const filename = state.filename ?? state.file.opts.filename;
|
|
272
|
-
if (!filename) return null;
|
|
273
|
-
return resolve(cleanModuleId(filename));
|
|
274
|
-
}
|
|
275
|
-
function tempoExpoBabelPlugin(api, rawOptions = {}) {
|
|
276
|
-
api.assertVersion(7);
|
|
277
|
-
const enabled = rawOptions.enabled ?? !!process.env.TEMPO;
|
|
278
|
-
const include = rawOptions.include === void 0 ? EXPO_DEFAULT_INCLUDE : rawOptions.include;
|
|
279
|
-
const exclude = rawOptions.exclude === void 0 ? DEFAULT_EXCLUDE : rawOptions.exclude;
|
|
280
|
-
const filter = createFilter(include, exclude);
|
|
281
|
-
return {
|
|
282
|
-
name: "tempo-expo-annotate",
|
|
283
|
-
manipulateOptions(opts, parserOpts) {
|
|
284
|
-
parserOpts.plugins ?? (parserOpts.plugins = []);
|
|
285
|
-
if (!hasParserPlugin(parserOpts.plugins, "jsx")) {
|
|
286
|
-
parserOpts.plugins.push("jsx");
|
|
287
|
-
}
|
|
288
|
-
const filename = opts.filename ?? "";
|
|
289
|
-
if (/\.(ts|tsx)$/.test(filename) && !hasParserPlugin(parserOpts.plugins, "typescript")) {
|
|
290
|
-
parserOpts.plugins.push("typescript");
|
|
291
|
-
}
|
|
292
|
-
},
|
|
293
|
-
visitor: {
|
|
294
|
-
Program: {
|
|
295
|
-
enter(path, state) {
|
|
296
|
-
if (!enabled) return;
|
|
297
|
-
const options = { ...rawOptions, ...state.opts };
|
|
298
|
-
const filename = resolveFilename(state);
|
|
299
|
-
if (!filename || !filter(filename)) return;
|
|
300
|
-
const source = state.file.code;
|
|
301
|
-
const root = resolveBabelRoot(state, options, filename);
|
|
302
|
-
let context;
|
|
303
|
-
try {
|
|
304
|
-
context = getFileAnnotationContext({
|
|
305
|
-
source,
|
|
306
|
-
filename,
|
|
307
|
-
root,
|
|
308
|
-
canonicalizeFilename: true
|
|
309
|
-
});
|
|
310
|
-
} catch {
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
if (context.filepath === "index.js") {
|
|
314
|
-
injectProjectRootMeta(api, path, root);
|
|
315
|
-
}
|
|
316
|
-
path.traverse({
|
|
317
|
-
JSXElement(elementPath) {
|
|
318
|
-
const element = elementPath.node;
|
|
319
|
-
const tagName = getBabelTagName(element.openingElement.name);
|
|
320
|
-
if (FRAGMENT_TAG_NAMES.has(tagName)) return;
|
|
321
|
-
const info = {
|
|
322
|
-
element,
|
|
323
|
-
tagName
|
|
324
|
-
};
|
|
325
|
-
const props = computeTempoAnnotatedProps({
|
|
326
|
-
info,
|
|
327
|
-
filepath: context.filepath,
|
|
328
|
-
modifiedtsMs: context.modifiedtsMs,
|
|
329
|
-
sourceVersion: context.sourceVersion,
|
|
330
|
-
computeAnnotatedProps: options.computeAnnotatedProps,
|
|
331
|
-
elementSupportOverrides: REACT_NATIVE_SUPPORT_OVERRIDES
|
|
332
|
-
});
|
|
333
|
-
addAnnotations(api, tagName, element.openingElement, props);
|
|
334
|
-
}
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
};
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
export {
|
|
343
|
-
tempoExpoBabelPlugin
|
|
344
|
-
};
|
|
345
|
-
//# sourceMappingURL=chunk-CB5NJJJT.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../expo-babel-plugin.ts","../annotation-strategy.ts","../../../modules/annotation/source-version.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\n\nimport { createFilter, type FilterPattern } from \"@rollup/pluginutils\";\n\nimport type {\n ElementInfo,\n PropValue,\n} from \"../../modules/annotation/annotate-file.ts\";\nimport {\n cleanModuleId,\n computeTempoAnnotatedProps,\n DEFAULT_EXCLUDE,\n getFileAnnotationContext,\n isIntrinsicElement,\n resolveCanonicalRoot,\n type ComputeAnnotatedProps,\n} from \"./annotation-strategy.ts\";\n\nconst EXPO_DEFAULT_INCLUDE: FilterPattern = [\"**/*.tsx\", \"**/*.jsx\", \"**/*.js\"];\n\nconst FRAGMENT_TAG_NAMES = new Set([\"Fragment\", \"React.Fragment\"]);\n\n// The React Native builtin host components we annotate. Membership decides\n// whether a component is annotated at all; `supports-children` is then keyed\n// off REACT_NATIVE_NO_CHILDREN_COMPONENTS below.\nconst REACT_NATIVE_HOST_COMPONENTS = new Set([\n \"ActivityIndicator\",\n \"Button\",\n \"FlatList\",\n \"Image\",\n \"ImageBackground\",\n \"KeyboardAvoidingView\",\n \"Modal\",\n \"Pressable\",\n \"RefreshControl\",\n \"SafeAreaView\",\n \"ScrollView\",\n \"SectionList\",\n \"Switch\",\n \"Text\",\n \"TextInput\",\n \"TouchableHighlight\",\n \"TouchableNativeFeedback\",\n \"TouchableOpacity\",\n \"TouchableWithoutFeedback\",\n \"View\",\n \"VirtualizedList\",\n]);\n\nconst REACT_NATIVE_NO_CHILDREN_COMPONENTS = new Set([\n \"ActivityIndicator\",\n \"Image\",\n \"RefreshControl\",\n \"Switch\",\n]);\n\nconst REACT_NATIVE_SUPPORT_OVERRIDES = new Map(\n [...REACT_NATIVE_HOST_COMPONENTS].map((tagName) => [\n tagName,\n { supportsChildren: !REACT_NATIVE_NO_CHILDREN_COMPONENTS.has(tagName) },\n ]),\n);\n\nexport interface TempoExpoBabelPluginOptions {\n /**\n * Defaults to `!!process.env.TEMPO`, matching `tempoVitePlugin`.\n * Expo users can pass `{ enabled: true }` in babel.config.js for direct tests.\n */\n enabled?: boolean;\n root?: string;\n include?: FilterPattern;\n exclude?: FilterPattern;\n computeAnnotatedProps?: ComputeAnnotatedProps;\n}\n\ntype BabelApi = {\n assertVersion(version: number): void;\n types: typeof import(\"@babel/types\");\n template: {\n expression(source: string): () => import(\"@babel/types\").Expression;\n statement(source: string): () => import(\"@babel/types\").Statement;\n };\n};\n\ntype BabelPluginState = {\n cwd?: string;\n filename?: string;\n file: {\n code: string;\n opts: {\n cwd?: string;\n filename?: string;\n root?: string;\n };\n };\n opts: TempoExpoBabelPluginOptions;\n};\n\nfunction hasParserPlugin(\n plugins: NonNullable<import(\"@babel/core\").ParserOptions[\"plugins\"]>,\n name: string,\n): boolean {\n return plugins.some((plugin) =>\n Array.isArray(plugin) ? plugin[0] === name : plugin === name,\n );\n}\n\nfunction getBabelTagName(\n name: import(\"@babel/types\").JSXElement[\"openingElement\"][\"name\"],\n): string {\n switch (name.type) {\n case \"JSXIdentifier\":\n return name.name;\n case \"JSXNamespacedName\":\n return `${name.namespace.name}:${name.name.name}`;\n case \"JSXMemberExpression\":\n return `${getBabelTagName(name.object)}.${name.property.name}`;\n }\n}\n\nfunction hasAttribute(\n node: import(\"@babel/types\").JSXOpeningElement,\n attrName: string,\n): boolean {\n return node.attributes.some(\n (attr) => attr.type === \"JSXAttribute\" && attr.name.name === attrName,\n );\n}\n\nfunction propValueToExpression(\n api: BabelApi,\n value: Exclude<PropValue, undefined>,\n): import(\"@babel/types\").Expression {\n if (typeof value === \"function\") {\n return api.template.expression(value.toString())();\n }\n return api.types.valueToNode(value) as import(\"@babel/types\").Expression;\n}\n\n// \"data-tempo-filepath\" -> \"tempoFilepath\". react-native-web hyphenates dataSet\n// keys back to \"data-tempo-filepath\" on the rendered DOM node, so this round-trips.\nfunction dataAttrToDataSetKey(attrName: string): string {\n return attrName\n .replace(/^data-/, \"\")\n .replace(/-([a-z])/g, (_, char: string) => char.toUpperCase());\n}\n\nfunction findDataSetAttribute(\n openingElement: import(\"@babel/types\").JSXOpeningElement,\n): import(\"@babel/types\").JSXAttribute | undefined {\n return openingElement.attributes.find(\n (attr): attr is import(\"@babel/types\").JSXAttribute =>\n attr.type === \"JSXAttribute\" && attr.name.name === \"dataSet\",\n );\n}\n\nfunction addAnnotations(\n api: BabelApi,\n tagName: string,\n openingElement: import(\"@babel/types\").JSXOpeningElement,\n props: Record<string, PropValue>,\n) {\n const t = api.types;\n\n // Intrinsic web elements (lowercase: div/span/...) are real DOM nodes that\n // forward arbitrary `data-*` attributes, so annotate them directly. React\n // Native host components (View, Text, ...) and any other component are NOT\n // DOM nodes: react-native-web only forwards an allow-list of props plus\n // `dataSet` to the rendered element and drops raw `data-*`. For those we emit\n // the annotations through `dataSet` (camelCase keys), which RNW maps back to\n // `data-*` on the host element.\n if (isIntrinsicElement(tagName)) {\n for (const [key, value] of Object.entries(props)) {\n if (value === undefined || hasAttribute(openingElement, key)) continue;\n openingElement.attributes.push(\n t.jsxAttribute(\n t.jsxIdentifier(key),\n t.jsxExpressionContainer(propValueToExpression(api, value)),\n ),\n );\n }\n return;\n }\n\n const dataSetProps: import(\"@babel/types\").ObjectProperty[] = [];\n for (const [key, value] of Object.entries(props)) {\n if (value === undefined) continue;\n dataSetProps.push(\n t.objectProperty(\n t.identifier(dataAttrToDataSetKey(key)),\n propValueToExpression(api, value),\n ),\n );\n }\n if (dataSetProps.length === 0) return;\n\n const existing = findDataSetAttribute(openingElement);\n if (!existing) {\n openingElement.attributes.push(\n t.jsxAttribute(\n t.jsxIdentifier(\"dataSet\"),\n t.jsxExpressionContainer(t.objectExpression(dataSetProps)),\n ),\n );\n return;\n }\n\n // Merge into a user-provided `dataSet={...}` without clobbering their keys:\n // { ...existingDataSet, ...tempoKeys }.\n if (\n existing.value?.type === \"JSXExpressionContainer\" &&\n existing.value.expression.type !== \"JSXEmptyExpression\"\n ) {\n existing.value.expression = t.objectExpression([\n t.spreadElement(existing.value.expression),\n ...dataSetProps,\n ]);\n }\n}\n\nconst ROOT_META_NAME = \"tempo-project-root\";\n\n// Rewrite the sidecar entry to stamp the absolute sidecar root into a\n// `<meta name=\"tempo-project-root\">` at runtime. The canvas reads this meta off\n// the live DOM (`read-source.ts`) to resolve `data-tempo-filepath` annotations —\n// which are relative to this root — back to absolute on-disk paths.\n//\n// Why stamp at runtime instead of writing the path into the committed\n// `public/index.html`: that file is committed to the user's repo, so it must not\n// hold a machine-specific absolute path. `root` here is resolved from the\n// sidecar's `__dirname` when Metro bundles, so it lives only in the built bundle\n// — never in committed source — yet still points at wherever the sidecar lives on\n// the machine running the dev server.\n//\n// Guarded on `typeof document` so it's inert under native/SSR bundles, and\n// idempotent (reuses an existing meta) so the static `public/index.html` marker —\n// kept present-but-empty for dev-server readiness detection — is upgraded in\n// place rather than duplicated.\nfunction injectProjectRootMeta(\n api: BabelApi,\n programPath: import(\"@babel/core\").NodePath<import(\"@babel/types\").Program>,\n root: string,\n) {\n const setter = api.template.statement(`\n if (typeof document !== \"undefined\") {\n var __tempoRootMeta = document.querySelector('meta[name=\"${ROOT_META_NAME}\"]');\n if (!__tempoRootMeta) {\n __tempoRootMeta = document.createElement(\"meta\");\n __tempoRootMeta.setAttribute(\"name\", \"${ROOT_META_NAME}\");\n document.head.appendChild(__tempoRootMeta);\n }\n __tempoRootMeta.setAttribute(\"content\", ${JSON.stringify(root)});\n }\n `)();\n programPath.pushContainer(\"body\", setter);\n}\n\nfunction resolveBabelRoot(\n state: BabelPluginState,\n options: TempoExpoBabelPluginOptions,\n filename: string,\n): string {\n return resolveCanonicalRoot(\n resolve(\n options.root ??\n findNearestPackageRoot(filename) ??\n state.cwd ??\n state.file.opts.cwd ??\n state.file.opts.root ??\n process.cwd(),\n ),\n );\n}\n\nfunction findNearestPackageRoot(filename: string): string | null {\n let current = dirname(filename);\n while (true) {\n if (existsSync(resolve(current, \"package.json\"))) return current;\n const parent = dirname(current);\n if (parent === current) return null;\n current = parent;\n }\n}\n\nfunction resolveFilename(state: BabelPluginState): string | null {\n const filename = state.filename ?? state.file.opts.filename;\n if (!filename) return null;\n return resolve(cleanModuleId(filename));\n}\n\nexport default function tempoExpoBabelPlugin(\n api: BabelApi,\n rawOptions: TempoExpoBabelPluginOptions = {},\n) {\n api.assertVersion(7);\n\n const enabled = rawOptions.enabled ?? !!process.env.TEMPO;\n const include =\n rawOptions.include === undefined\n ? EXPO_DEFAULT_INCLUDE\n : rawOptions.include;\n const exclude =\n rawOptions.exclude === undefined ? DEFAULT_EXCLUDE : rawOptions.exclude;\n const filter = createFilter(include, exclude);\n\n return {\n name: \"tempo-expo-annotate\",\n\n manipulateOptions(\n opts: { filename?: string },\n parserOpts: NonNullable<\n import(\"@babel/core\").TransformOptions[\"parserOpts\"]\n >,\n ) {\n parserOpts.plugins ??= [];\n if (!hasParserPlugin(parserOpts.plugins, \"jsx\")) {\n parserOpts.plugins.push(\"jsx\");\n }\n const filename = opts.filename ?? \"\";\n if (\n /\\.(ts|tsx)$/.test(filename) &&\n !hasParserPlugin(parserOpts.plugins, \"typescript\")\n ) {\n parserOpts.plugins.push(\"typescript\");\n }\n },\n\n visitor: {\n Program: {\n enter(\n path: import(\"@babel/core\").NodePath<import(\"@babel/types\").Program>,\n state: BabelPluginState,\n ) {\n if (!enabled) return;\n const options = { ...rawOptions, ...state.opts };\n const filename = resolveFilename(state);\n if (!filename || !filter(filename)) return;\n\n const source = state.file.code;\n const root = resolveBabelRoot(state, options, filename);\n let context: ReturnType<typeof getFileAnnotationContext>;\n try {\n context = getFileAnnotationContext({\n source,\n filename,\n root,\n canonicalizeFilename: true,\n });\n } catch {\n return;\n }\n\n // The sidecar entry runs once at startup; stamp the project-root meta\n // there so the canvas can resolve annotations off the live DOM. Keyed\n // on the entry's root-relative path (`index.js`), matching the entry\n // scaffolded by tempo-project's `EXPO_INDEX_JS`.\n if (context.filepath === \"index.js\") {\n injectProjectRootMeta(api, path, root);\n }\n\n path.traverse({\n JSXElement(elementPath) {\n const element = elementPath.node;\n const tagName = getBabelTagName(element.openingElement.name);\n if (FRAGMENT_TAG_NAMES.has(tagName)) return;\n\n const info = {\n element,\n tagName,\n } as unknown as ElementInfo;\n const props = computeTempoAnnotatedProps({\n info,\n filepath: context.filepath,\n modifiedtsMs: context.modifiedtsMs,\n sourceVersion: context.sourceVersion,\n computeAnnotatedProps: options.computeAnnotatedProps,\n elementSupportOverrides: REACT_NATIVE_SUPPORT_OVERRIDES,\n });\n\n addAnnotations(api, tagName, element.openingElement, props);\n },\n });\n },\n },\n },\n };\n}\n\nexport { tempoExpoBabelPlugin };\n","import { realpathSync, statSync } from \"node:fs\";\nimport { relative } from \"node:path\";\n\nimport type {\n ElementInfo,\n PropValue,\n} from \"../../modules/annotation/annotate-file.ts\";\nimport { sourceVersionHash } from \"../../modules/annotation/source-version.ts\";\n\nexport const DEFAULT_EXCLUDE = [\"**/node_modules/**\"] as const;\n\n/**\n * Static per-component declaration of whether a custom component accepts\n * `children`. Supplied by callers that know this from a fixed table (e.g. the\n * Expo plugin's React Native host-component overrides). The Vite/Next.js\n * plugins supply no overrides — custom components are left without a\n * `supports-children` flag and consumers treat their support as unknown.\n */\nexport interface ElementTypeSupport {\n supportsChildren: boolean;\n}\n\n/** HTML void elements that cannot have children (self-closing only). */\nexport const HTML_VOID_ELEMENTS = new Set([\n \"area\",\n \"base\",\n \"br\",\n \"col\",\n \"embed\",\n \"hr\",\n \"img\",\n \"input\",\n \"link\",\n \"meta\",\n \"param\",\n \"source\",\n \"track\",\n \"wbr\",\n]);\n\nexport type ComputeAnnotatedProps = (\n info: ElementInfo,\n filepath: string,\n modifiedtsMs: number,\n sourceVersion: string,\n) => Record<string, PropValue>;\n\nexport function cleanModuleId(id: string): string {\n return id.replace(/[?#].*$/, \"\");\n}\n\nexport function resolveCanonicalRoot(root: string): string {\n try {\n return realpathSync.native(root);\n } catch {\n return root;\n }\n}\n\nexport function isIntrinsicElement(tagName: string): boolean {\n return tagName.length > 0 && tagName[0] === tagName[0]!.toLowerCase();\n}\n\nexport function hasJsxAttribute(info: ElementInfo, attrName: string): boolean {\n for (const attr of info.element.openingElement.attributes) {\n const name = (attr as { name?: { name?: unknown } }).name;\n if (name?.name === attrName) return true;\n }\n return false;\n}\n\nexport function defaultComputeAnnotatedProps(\n info: ElementInfo,\n filepath: string,\n modifiedtsMs: number,\n sourceVersion: string,\n): Record<string, PropValue> {\n return {\n \"data-tempo-filepath\": filepath,\n \"data-tempo-position\": info.element.openingElement.start,\n \"data-tempo-modifiedts\": modifiedtsMs,\n // Content-hash identity of the file this element was annotated from. The\n // canvas reconcile loop equality-compares it against the write pipeline's\n // computed version to decide whether a capture reflects a given edit.\n \"data-tempo-source-version\": sourceVersion,\n };\n}\n\nexport function computeTempoAnnotatedProps(params: {\n info: ElementInfo;\n filepath: string;\n modifiedtsMs: number;\n sourceVersion: string;\n computeAnnotatedProps?: ComputeAnnotatedProps;\n elementSupportOverrides?: ReadonlyMap<string, ElementTypeSupport>;\n}): Record<string, PropValue> {\n const {\n info,\n filepath,\n modifiedtsMs,\n sourceVersion,\n computeAnnotatedProps,\n elementSupportOverrides,\n } = params;\n\n const userProps = computeAnnotatedProps\n ? computeAnnotatedProps(info, filepath, modifiedtsMs, sourceVersion)\n : defaultComputeAnnotatedProps(info, filepath, modifiedtsMs, sourceVersion);\n\n if (isIntrinsicElement(info.tagName)) {\n return {\n ...userProps,\n \"data-tempo-supports-children\": hasJsxAttribute(\n info,\n \"data-tempo-supports-children\",\n )\n ? undefined\n : !HTML_VOID_ELEMENTS.has(info.tagName),\n };\n }\n\n const override = elementSupportOverrides?.get(info.tagName);\n if (override) {\n return {\n ...userProps,\n \"data-tempo-supports-children\": hasJsxAttribute(\n info,\n \"data-tempo-supports-children\",\n )\n ? undefined\n : override.supportsChildren,\n };\n }\n\n // Custom component with no static override: emit no `data-tempo-supports-*`\n // flags. Determining them required a per-file TypeScript program, which was\n // removed for being the dominant cost of devserver startup. Consumers treat\n // the absent flags as \"unknown\" and fall back to their own defaults.\n return userProps;\n}\n\nexport function getFileAnnotationContext(params: {\n source: string;\n filename: string;\n root: string;\n canonicalizeFilename?: boolean;\n}): {\n cleanFilename: string;\n filepath: string;\n modifiedtsMs: number;\n sourceVersion: string;\n} {\n const rawCleanFilename = cleanModuleId(params.filename);\n let cleanFilename = rawCleanFilename;\n if (params.canonicalizeFilename) {\n try {\n cleanFilename = realpathSync.native(rawCleanFilename);\n } catch {\n cleanFilename = rawCleanFilename;\n }\n }\n return {\n cleanFilename,\n filepath: relative(params.root, cleanFilename),\n modifiedtsMs: Math.trunc(statSync(cleanFilename).mtimeMs),\n // Hashed once per file per transform (the context is built once, reused\n // for every element) so the per-element funnel just forwards the token.\n sourceVersion: sourceVersionHash(params.source),\n };\n}\n","/**\n * Canvas source-version identity.\n *\n * `sourceVersionHash` maps the exact text of a source file to a 16-hex-character\n * token identifying that content. It is the version stamp the canvas edit/\n * reconcile loop uses to answer \"has the host caught up to write W?\": the SDK\n * JSX transforms stamp `data-tempo-source-version` with the hash of the source\n * they annotate, and the write pipeline (`applyWrites` → `sourceVersionsByFile`)\n * reports the hash of the exact bytes it wrote. A captured element's stamp is\n * compared for EQUALITY against a write's version — never ordered, never\n * subtracted, never used as a high-water mark. Two identical contents MUST\n * produce the same token; two different contents MUST (for identity purposes)\n * produce different tokens.\n *\n * Because coverage is an equality test across independently-computed hashes,\n * every producer of a version — this function's callers in the vite/next/expo\n * transforms and in `applyWrites` — MUST route through THIS function so the\n * tokens are bit-identical. Changing the algorithm requires changing it for all\n * producers in lockstep, or old stamps and new write-versions stop matching.\n *\n * The token concatenates two independent 32-bit rolling hashes over the string's\n * UTF-16 code units — djb2 and sdbm — each rendered as unsigned 8-char hex. Two\n * independent hash families make an accidental collision between distinct source\n * contents vanishingly unlikely for version-identity use, while the function\n * stays dependency-free and single-pass (fast enough to run once per file per\n * transform on the devserver hot path).\n */\nexport function sourceVersionHash(content: string): string {\n let djb2 = 5381;\n let sdbm = 0;\n for (let i = 0; i < content.length; i++) {\n const c = content.charCodeAt(i);\n // djb2: hash * 33 ^ c. The trailing `^ c` keeps the value inside 32-bit\n // signed range every iteration, so no explicit coercion is needed.\n djb2 = ((djb2 << 5) + djb2) ^ c;\n // sdbm: c + hash*65599. The final term is an arithmetic subtraction, so\n // coerce back to a 32-bit int each step to prevent float drift.\n sdbm = (c + (sdbm << 6) + (sdbm << 16) - sdbm) | 0;\n }\n return toHex8(djb2) + toHex8(sdbm);\n}\n\n/** Render a 32-bit value as unsigned, zero-padded 8-char lowercase hex. */\nfunction toHex8(n: number): string {\n return (n >>> 0).toString(16).padStart(8, \"0\");\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAS,SAAS,eAAe;AAEjC,SAAS,oBAAwC;;;ACHjD,SAAS,cAAc,gBAAgB;AACvC,SAAS,gBAAgB;;;AC0BlB,SAAS,kBAAkB,SAAyB;AACzD,MAAI,OAAO;AACX,MAAI,OAAO;AACX,WAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;AACvC,UAAM,IAAI,QAAQ,WAAW,CAAC;AAG9B,YAAS,QAAQ,KAAK,OAAQ;AAG9B,WAAQ,KAAK,QAAQ,MAAM,QAAQ,MAAM,OAAQ;AAAA,EACnD;AACA,SAAO,OAAO,IAAI,IAAI,OAAO,IAAI;AACnC;AAGA,SAAS,OAAO,GAAmB;AACjC,UAAQ,MAAM,GAAG,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG;AAC/C;;;ADp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C/C,gBAAM,WAAW,gBAAgB,KAAK;AACtC,cAAI,CAAC,YAAY,CAAC,OAAO,QAAQ,EAAG;AAEpC,gBAAM,SAAS,MAAM,KAAK;AAC1B,gBAAM,OAAO,iBAAiB,OAAO,SAAS,QAAQ;AACtD,cAAI;AACJ,cAAI;AACF,sBAAU,yBAAyB;AAAA,cACjC;AAAA,cACA;AAAA,cACA;AAAA,cACA,sBAAsB;AAAA,YACxB,CAAC;AAAA,UACH,QAAQ;AACN;AAAA,UACF;AAMA,cAAI,QAAQ,aAAa,YAAY;AACnC,kCAAsB,KAAK,MAAM,IAAI;AAAA,UACvC;AAEA,eAAK,SAAS;AAAA,YACZ,WAAW,aAAa;AACtB,oBAAM,UAAU,YAAY;AAC5B,oBAAM,UAAU,gBAAgB,QAAQ,eAAe,IAAI;AAC3D,kBAAI,mBAAmB,IAAI,OAAO,EAAG;AAErC,oBAAM,OAAO;AAAA,gBACX;AAAA,gBACA;AAAA,cACF;AACA,oBAAM,QAAQ,2BAA2B;AAAA,gBACvC;AAAA,gBACA,UAAU,QAAQ;AAAA,gBAClB,cAAc,QAAQ;AAAA,gBACtB,eAAe,QAAQ;AAAA,gBACvB,uBAAuB,QAAQ;AAAA,gBAC/B,yBAAyB;AAAA,cAC3B,CAAC;AAED,6BAAe,KAAK,SAAS,QAAQ,gBAAgB,KAAK;AAAA,YAC5D;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../modules/iframe-projection/html/watch-head.ts","../../../modules/iframe-projection/shared/capture-perf.ts","../../../modules/iframe-projection/html/declared-facts.ts","../../../modules/iframe-projection/html/displayability.ts","../../../modules/iframe-projection/html/selectors.ts","../../../modules/iframe-projection/html/capture.ts"],"sourcesContent":["/**\n * Head Capture Utility\n *\n * Captures relevant <head> content from a document, excluding scripts\n * and resolving relative URLs to absolute.\n *\n * ## Shared Observer Pattern\n *\n * Uses a singleton HeadTracker that maintains one MutationObserver per document,\n * shared across all subscriptions. This avoids creating 50+ observers when there\n * are many watchers on the same page.\n */\n\n/** Elements to include from <head> */\nconst INCLUDE_TAGS = new Set([\"STYLE\", \"META\", \"BASE\", \"LINK\"]);\n\n/** Link rel values to include (stylesheet-related) */\nconst INCLUDE_LINK_RELS = new Set([\"stylesheet\"]);\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Head Tracker (Shared Observer)\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * A subscription to head changes for a specific document.\n * Each subscription maintains its own hasMutations flag since they flush independently.\n */\nexport interface HeadSubscription {\n /** Whether there have been mutations since last flush */\n hasMutations: boolean;\n /** Flush and get head content. Returns content if isInitial or if mutations occurred. */\n flush(isInitial: boolean): string | undefined;\n /** Unsubscribe from head changes */\n unsubscribe(): void;\n}\n\nexport interface HeadMutationDetails {\n /** Vite stylesheet module ids whose style/link nodes changed in this batch. */\n stylesheetPaths: string[];\n}\n\n/**\n * Singleton tracker that manages shared MutationObservers for head watching.\n * One observer per document, shared across all subscriptions.\n */\nexport interface HeadTracker {\n /** Subscribe to head changes for a document */\n subscribe(\n doc: Document,\n onMutation: (details: HeadMutationDetails) => void,\n ): HeadSubscription;\n /** Clean up all observers */\n destroy(): void;\n /** Cardinality only; reads maintained collection sizes and performs no DOM\n * work. Used by the performance trace attached to an emitted capture. */\n readPerfSnapshot(): { observers: number; subscriptions: number };\n}\n\n/** Module-level singleton */\nlet instance: HeadTrackerImpl | null = null;\n\n/**\n * Get the singleton HeadTracker instance.\n */\nexport function getHeadTracker(): HeadTracker {\n if (!instance) {\n instance = new HeadTrackerImpl();\n }\n return instance;\n}\n\n/**\n * Reset the singleton. For testing only.\n * @internal\n */\nexport function _resetHeadTrackerForTesting(): void {\n instance?.destroy();\n instance = null;\n}\n\n/** Internal subscription implementation */\nclass HeadSubscriptionImpl implements HeadSubscription {\n hasMutations = false;\n private doc: Document;\n private callback: (details: HeadMutationDetails) => void;\n private onUnsubscribe: () => void;\n\n constructor(\n doc: Document,\n callback: (details: HeadMutationDetails) => void,\n onUnsubscribe: () => void,\n ) {\n this.doc = doc;\n this.callback = callback;\n this.onUnsubscribe = onUnsubscribe;\n }\n\n flush(isInitial: boolean): string | undefined {\n if (!isInitial && !this.hasMutations) {\n return undefined;\n }\n this.hasMutations = false;\n return captureHead(this.doc);\n }\n\n unsubscribe(): void {\n this.onUnsubscribe();\n }\n\n /** Called by tracker when relevant mutation detected */\n notifyMutation(details: HeadMutationDetails): void {\n this.hasMutations = true;\n this.callback(details);\n }\n}\n\n/** Per-document observer state */\ninterface DocObserverState {\n observer: MutationObserver;\n subscriptions: Set<HeadSubscriptionImpl>;\n}\n\nclass HeadTrackerImpl implements HeadTracker {\n private docObservers = new Map<Document, DocObserverState>();\n private activeSubscriptions = 0;\n\n subscribe(\n doc: Document,\n onMutation: (details: HeadMutationDetails) => void,\n ): HeadSubscription {\n let docState = this.docObservers.get(doc);\n\n // Create observer for this document if first subscription\n if (!docState) {\n docState = this.createDocObserver(doc);\n this.docObservers.set(doc, docState);\n }\n\n const subscription = new HeadSubscriptionImpl(doc, onMutation, () => {\n this.unsubscribe(doc, subscription);\n });\n docState.subscriptions.add(subscription);\n this.activeSubscriptions += 1;\n\n return subscription;\n }\n\n private createDocObserver(doc: Document): DocObserverState {\n const subscriptions = new Set<HeadSubscriptionImpl>();\n\n const notify = (details: HeadMutationDetails): void => {\n for (const sub of subscriptions) {\n sub.notifyMutation(details);\n }\n };\n\n const observeHead = (head: HTMLHeadElement): MutationObserver => {\n const observer = new MutationObserver((mutations) => {\n const details = this.readRelevantMutations(mutations, head);\n if (!details) return;\n notify(details);\n });\n observer.observe(head, {\n childList: true,\n subtree: true,\n attributes: true,\n characterData: true,\n });\n return observer;\n };\n\n if (doc.head) {\n return { observer: observeHead(doc.head), subscriptions };\n }\n\n // The document has no <head> yet — subscribers can attach before parsing\n // (e.g. a producer created from a frame preload). Watch for the head to\n // appear, then swap in the real observer and report one synthetic\n // mutation so subscribers capture the head they never saw arrive.\n const bootstrap = new MutationObserver(() => {\n const head = doc.head;\n if (!head) return;\n bootstrap.disconnect();\n state.observer = observeHead(head);\n notify({ stylesheetPaths: [] });\n });\n bootstrap.observe(doc, { childList: true, subtree: true });\n const state: DocObserverState = { observer: bootstrap, subscriptions };\n return state;\n }\n\n private unsubscribe(doc: Document, sub: HeadSubscriptionImpl): void {\n const docState = this.docObservers.get(doc);\n if (!docState) return;\n\n if (!docState.subscriptions.delete(sub)) return;\n this.activeSubscriptions = Math.max(0, this.activeSubscriptions - 1);\n\n // Disconnect observer if no more subscriptions for this document\n if (docState.subscriptions.size === 0) {\n docState.observer.disconnect();\n this.docObservers.delete(doc);\n }\n }\n\n /**\n * Check if mutations contain changes to elements we care about.\n * This filtering runs once per mutation batch (not once per subscription).\n */\n private readRelevantMutations(\n mutations: MutationRecord[],\n head: HTMLHeadElement,\n ): HeadMutationDetails | null {\n let relevant = false;\n const stylesheetPaths = new Set<string>();\n const collectStylesheetPath = (node: Node | null): void => {\n const element =\n node instanceof Element ? node : (node?.parentElement ?? null);\n if (!element) return;\n const candidates = [\n element,\n ...element.querySelectorAll(\n \"style[data-vite-dev-id], link[rel~='stylesheet']\",\n ),\n ];\n for (const candidate of candidates) {\n if (candidate instanceof HTMLStyleElement) {\n const id = candidate.getAttribute(\"data-vite-dev-id\")?.trim();\n if (id) stylesheetPaths.add(id);\n } else if (\n candidate instanceof HTMLLinkElement &&\n shouldIncludeLink(candidate)\n ) {\n const href = candidate.getAttribute(\"href\")?.trim() || candidate.href;\n if (href) stylesheetPaths.add(href);\n }\n }\n };\n\n for (const mutation of mutations) {\n const target = mutation.target;\n const element = target instanceof Element ? target : target.parentElement;\n\n if (!element || (!head.contains(element) && target !== head)) continue;\n\n // Check if this is a relevant element (one we would capture)\n const tagName = element.tagName;\n if (INCLUDE_TAGS.has(tagName)) {\n // For LINK, check if it's a stylesheet\n if (tagName === \"LINK\") {\n if (!shouldIncludeLink(element)) continue;\n }\n relevant = true;\n collectStylesheetPath(element);\n }\n\n // Also trigger for childList mutations on head itself (added/removed elements)\n if (mutation.type === \"childList\" && target === head) {\n relevant = true;\n }\n if (mutation.type === \"childList\") {\n for (const node of mutation.addedNodes) collectStylesheetPath(node);\n for (const node of mutation.removedNodes) collectStylesheetPath(node);\n }\n }\n return relevant ? { stylesheetPaths: [...stylesheetPaths] } : null;\n }\n\n destroy(): void {\n for (const docState of this.docObservers.values()) {\n docState.observer.disconnect();\n docState.subscriptions.clear();\n }\n this.docObservers.clear();\n this.activeSubscriptions = 0;\n }\n\n readPerfSnapshot(): { observers: number; subscriptions: number } {\n return {\n observers: this.docObservers.size,\n subscriptions: this.activeSubscriptions,\n };\n }\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Legacy API (Backward Compatibility)\n// These functions delegate to the shared tracker for backward compatibility\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * State for a head watcher instance.\n * @deprecated Use getHeadTracker().subscribe() instead for better performance\n */\nexport interface HeadWatcher {\n /** The document being watched */\n doc: Document;\n /** Whether there have been mutations since last flush */\n hasMutations: boolean;\n /** Stop watching */\n stop: () => void;\n}\n\n/**\n * Starts watching a document's <head> for mutations.\n * @deprecated Use getHeadTracker().subscribe() instead for better performance\n */\nexport function watchHead(doc: Document, onMutation: () => void): HeadWatcher {\n const subscription = getHeadTracker().subscribe(doc, onMutation);\n\n // Wrap subscription in legacy HeadWatcher interface\n return {\n doc,\n get hasMutations() {\n return subscription.hasMutations;\n },\n set hasMutations(value: boolean) {\n subscription.hasMutations = value;\n },\n stop: () => subscription.unsubscribe(),\n };\n}\n\n/**\n * Checks if watcher has any pending head mutations.\n * @deprecated Access subscription.hasMutations directly\n */\nexport function hasPendingHeadChanges(watcher: HeadWatcher): boolean {\n return watcher.hasMutations;\n}\n\n/**\n * Flushes the head watcher, returning captured head content if there were changes.\n * @deprecated Use subscription.flush() directly\n */\nexport function flushHeadWatcher(\n watcher: HeadWatcher,\n isInitial: boolean,\n): string | undefined {\n if (!isInitial && !watcher.hasMutations) {\n return undefined;\n }\n watcher.hasMutations = false;\n return captureHead(watcher.doc);\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Head Capture\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Captures the <head> content from a document.\n *\n * - Includes: <style>, <link rel=\"stylesheet\">, <meta>, <base>\n * - Excludes: <script>, <title>, <link rel=\"icon/preload/etc\">\n * - Resolves relative URLs to absolute using document.baseURI\n *\n * @param doc - The document to capture head from\n * @returns Serialized head content (innerHTML for destination <head>)\n */\nexport function captureHead(doc: Document): string {\n const head = doc.head;\n if (!head) return \"\";\n\n const baseURI = doc.baseURI;\n const fragments: string[] = [];\n\n for (const child of Array.from(head.children)) {\n const tagName = child.tagName;\n\n // Skip non-included tags\n if (!INCLUDE_TAGS.has(tagName)) continue;\n\n // For <link>, only include stylesheets\n if (tagName === \"LINK\") {\n if (!shouldIncludeLink(child)) continue;\n if (isDisabledStylesheet(child)) continue;\n }\n\n // Exclude Content-Security-Policy meta tags (they block srcdoc assets)\n if (tagName === \"META\") {\n const httpEquiv = child.getAttribute(\"http-equiv\")?.toLowerCase();\n const name = child.getAttribute(\"name\")?.toLowerCase();\n if (\n httpEquiv === \"content-security-policy\" ||\n name === \"content-security-policy\"\n ) {\n continue;\n }\n }\n\n // Clone and resolve URLs\n let clone = child.cloneNode(true) as Element;\n materializeStyleElementCssom(child, clone);\n if (tagName === \"LINK\") {\n clone = materializeStylesheetLinkCssom(child, clone);\n }\n resolveUrls(clone, baseURI);\n\n // Strip crossorigin from stylesheet links so they load in no-cors mode\n // in srcdoc projection iframes (which have a null origin that won't\n // match any server's Access-Control-Allow-Origin header)\n if (clone.tagName === \"LINK\") {\n clone.removeAttribute(\"crossorigin\");\n } else if (clone.tagName === \"STYLE\") {\n escapeStyleForHtmlSerialization(clone);\n }\n\n fragments.push(clone.outerHTML);\n }\n\n fragments.push(...captureAdoptedStyleSheets(doc));\n\n return fragments.join(\"\\n\");\n}\n\n/**\n * Same-origin stylesheets are already readable in the source page. Preserve\n * their authored rules as an inline style before the projection crosses into\n * its null-origin document. Opaque cross-origin sheets remain links and may be\n * handled by a consumer-specific, policy-checked fallback later.\n */\nfunction materializeStylesheetLinkCssom(\n source: Element,\n clone: Element,\n): Element {\n const link = source as HTMLLinkElement;\n const cssText = serializeCssRules(link.sheet);\n if (!cssText) {\n return clone;\n }\n\n const style = source.ownerDocument.createElement(\"style\");\n for (const attribute of Array.from(source.attributes)) {\n if (\n [\n \"as\",\n \"crossorigin\",\n \"fetchpriority\",\n \"href\",\n \"integrity\",\n \"referrerpolicy\",\n \"rel\",\n ].includes(attribute.name.toLowerCase())\n ) {\n continue;\n }\n style.setAttribute(attribute.name, attribute.value);\n }\n style.setAttribute(\"data-projection-stylesheet-href\", link.href);\n style.textContent = absolutifyCssReferences(cssText, link.href);\n return style;\n}\n\n/**\n * CSS-in-JS and framework runtimes can insert rules through CSSOM APIs, leaving\n * the DOM <style> text empty. Clone-time materialization preserves those rules\n * without mutating the live host document.\n */\nfunction materializeStyleElementCssom(source: Element, clone: Element): void {\n if (source.tagName !== \"STYLE\" || clone.tagName !== \"STYLE\") {\n return;\n }\n\n const style = source as HTMLStyleElement;\n const text = style.textContent ?? \"\";\n if (text.trim().length > 0) {\n return;\n }\n\n const cssText = serializeCssRules(style.sheet);\n if (cssText) {\n clone.textContent = cssText;\n }\n}\n\nfunction captureAdoptedStyleSheets(doc: Document): string[] {\n const sheets = Array.from(doc.adoptedStyleSheets ?? []);\n if (sheets.length === 0) {\n return [];\n }\n\n const fragments: string[] = [];\n for (const sheet of sheets) {\n const cssText = serializeCssRules(sheet);\n if (!cssText) {\n continue;\n }\n const style = doc.createElement(\"style\");\n style.setAttribute(\"data-projection-adopted-stylesheet\", \"true\");\n style.textContent = cssText;\n escapeStyleForHtmlSerialization(style);\n fragments.push(style.outerHTML);\n }\n return fragments;\n}\n\nfunction escapeStyleForHtmlSerialization(style: Element): void {\n style.textContent = (style.textContent ?? \"\").replace(/<\\//gi, \"<\\\\/\");\n}\n\nfunction serializeCssRules(sheet: CSSStyleSheet | null): string {\n if (!sheet) {\n return \"\";\n }\n\n try {\n return Array.from(sheet.cssRules)\n .map((rule) => rule.cssText)\n .join(\"\\n\");\n } catch {\n // Cross-origin or otherwise unreadable stylesheet.\n return \"\";\n }\n}\n\nfunction absolutifyCssReferences(cssText: string, baseHref: string): string {\n if (!/^https?:/i.test(baseHref)) {\n return cssText;\n }\n\n const resolve = (value: string): string => {\n const trimmed = value.trim();\n if (\n !trimmed ||\n trimmed.startsWith(\"#\") ||\n /^(?:data|blob|javascript):/i.test(trimmed)\n ) {\n return /^javascript:/i.test(trimmed) ? \"\" : trimmed;\n }\n try {\n return new URL(trimmed, baseHref).href;\n } catch {\n return trimmed;\n }\n };\n\n return cssText\n .replace(\n /url\\(\\s*([\"']?)([^\"')]+)\\1\\s*\\)/gi,\n (_match, quote: string, value: string) =>\n `url(${quote}${resolve(value)}${quote})`,\n )\n .replace(\n /@import\\s+([\"'])([^\"']+)\\1/gi,\n (_match, quote: string, value: string) =>\n `@import ${quote}${resolve(value)}${quote}`,\n );\n}\n\nfunction shouldIncludeLink(element: Element): boolean {\n const rel = element.getAttribute(\"rel\");\n if (!rel) {\n return false;\n }\n return rel\n .toLowerCase()\n .split(/\\s+/)\n .some((token) => INCLUDE_LINK_RELS.has(token));\n}\n\nfunction isDisabledStylesheet(element: Element): boolean {\n const link = element as HTMLLinkElement;\n return link.disabled || link.sheet?.disabled === true;\n}\n\n/**\n * Resolves relative URLs in an element to absolute URLs.\n */\nfunction resolveUrls(element: Element, baseURI: string): void {\n // Skip URL resolution if baseURI is not a valid HTTP(S) URL\n // (e.g., in test environments where baseURI is \"about:blank\")\n if (!baseURI || !baseURI.startsWith(\"http\")) {\n return;\n }\n\n // Resolve href attribute (for <link>, <base>)\n const href = element.getAttribute(\"href\");\n if (href && !isAbsoluteUrl(href)) {\n try {\n element.setAttribute(\"href\", new URL(href, baseURI).href);\n } catch {\n // Keep original href if URL resolution fails\n }\n }\n\n // Resolve src attribute (for future-proofing)\n const src = element.getAttribute(\"src\");\n if (src && !isAbsoluteUrl(src)) {\n try {\n element.setAttribute(\"src\", new URL(src, baseURI).href);\n } catch {\n // Keep original src if URL resolution fails\n }\n }\n}\n\n/**\n * Checks if a URL is absolute.\n */\nfunction isAbsoluteUrl(url: string): boolean {\n return /^(https?:)?\\/\\//i.test(url) || url.startsWith(\"data:\");\n}\n","/**\n * Capture-flush perf counters.\n *\n * Module-local mutable counters incremented by the hot paths that run inside\n * a combined-watch flush: the displayability walk's getComputedStyle reads,\n * the layout-kind style read during fiber serialization, and the\n * render-identity declaration walks. The flush resets them before capturing\n * and reads them after, shipping the totals on the emitted capture's `perf`\n * field — so the paths themselves never thread perf parameters through their\n * signatures. Increment-only: no DOM reads, no allocation.\n *\n * The same functions also run outside a flush (one-shot capture APIs); those\n * increments are simply discarded by the next flush's reset.\n */\n\ninterface CaptureFlushCounters {\n styleReadCount: number;\n identityNodesVisited: number;\n sourceVersionDomScanNodes: number;\n sourceVersionFiberSerializeNodes: number;\n sourceVersionFiberReductionNodes: number;\n sourceVersionFallbackScanNodes: number;\n}\n\nconst counters: CaptureFlushCounters = {\n styleReadCount: 0,\n identityNodesVisited: 0,\n sourceVersionDomScanNodes: 0,\n sourceVersionFiberSerializeNodes: 0,\n sourceVersionFiberReductionNodes: 0,\n sourceVersionFallbackScanNodes: 0,\n};\n\nconst producerReferencesByDocument = new Map<Document, number>();\nlet activeDocumentProducers = 0;\nlet activeRootObservers = 0;\nlet activeReactCommitSubscriptions = 0;\n\n/** Register one document producer and its one React commit subscription. */\nexport function registerDocumentCaptureProducer(\n document: Document,\n): () => void {\n const references = producerReferencesByDocument.get(document) ?? 0;\n if (references === 0) activeDocumentProducers += 1;\n producerReferencesByDocument.set(document, references + 1);\n activeReactCommitSubscriptions += 1;\n let active = true;\n return () => {\n if (!active) return;\n active = false;\n const current = producerReferencesByDocument.get(document) ?? 0;\n if (current <= 1) {\n producerReferencesByDocument.delete(document);\n activeDocumentProducers = Math.max(0, activeDocumentProducers - 1);\n } else {\n producerReferencesByDocument.set(document, current - 1);\n }\n activeReactCommitSubscriptions = Math.max(\n 0,\n activeReactCommitSubscriptions - 1,\n );\n };\n}\n\n/** Register one independently observed projection root. */\nexport function registerCaptureRootObserver(): () => void {\n activeRootObservers += 1;\n let active = true;\n return () => {\n if (!active) return;\n active = false;\n activeRootObservers = Math.max(0, activeRootObservers - 1);\n };\n}\n\nexport function readCaptureProducerCardinality(): {\n activeDocumentProducers: number;\n activeRootObservers: number;\n reactCommitSubscriptions: number;\n} {\n return {\n activeDocumentProducers,\n activeRootObservers,\n reactCommitSubscriptions: activeReactCommitSubscriptions,\n };\n}\n\n/** @internal Test isolation for producer ownership counters. */\nexport function _resetCaptureProducerCardinalityForTesting(): void {\n producerReferencesByDocument.clear();\n activeDocumentProducers = 0;\n activeRootObservers = 0;\n activeReactCommitSubscriptions = 0;\n}\n\n/** One getComputedStyle call on the capture path. */\nexport function countCaptureStyleRead(): void {\n counters.styleReadCount += 1;\n}\n\n/** One element/node visited by a render-identity declaration walk. */\nexport function countIdentityNodeVisited(): void {\n counters.identityNodesVisited += 1;\n}\n\nexport function countSourceVersionDomScanNode(): void {\n counters.sourceVersionDomScanNodes += 1;\n}\n\nexport function countSourceVersionFiberSerializeNode(): void {\n counters.sourceVersionFiberSerializeNodes += 1;\n}\n\nexport function countSourceVersionFiberReductionNode(): void {\n counters.sourceVersionFiberReductionNodes += 1;\n}\n\nexport function countSourceVersionFallbackScanNode(): void {\n counters.sourceVersionFallbackScanNodes += 1;\n}\n\nexport function resetCaptureFlushCounters(): void {\n counters.styleReadCount = 0;\n counters.identityNodesVisited = 0;\n counters.sourceVersionDomScanNodes = 0;\n counters.sourceVersionFiberSerializeNodes = 0;\n counters.sourceVersionFiberReductionNodes = 0;\n counters.sourceVersionFallbackScanNodes = 0;\n}\n\nexport function readCaptureFlushCounters(): Readonly<CaptureFlushCounters> {\n return { ...counters };\n}\n","/**\n * Declared Capture Facts (producer-side)\n *\n * Computes the `DeclaredCaptureFacts` a capture producer attaches to its\n * `DomCapture`. Everything here reads the LIVE DOM the producer already\n * holds — never the serialized HTML string — so the facts are ground truth\n * rather than a re-parse of the payload. See specs/canvas-determinism.md §4.\n */\n\nimport type { DeclaredCaptureFacts } from \"./types\";\n\n/**\n * Two annotation namespaces stamp the source-mapped iframe DOM:\n * - JSX: `data-tempo-filepath` + `data-tempo-position` + `data-tempo-modifiedts`\n * - HTML: `data-tempo-html-filepath` + `data-tempo-html-offset` +\n * `data-tempo-html-modifiedts`\n * A single element may carry BOTH (an HTML element nested inside a JSX host\n * that also got source-located), so each namespace is read independently.\n */\nconst SOURCE_ANNOTATED_SELECTOR =\n \"[data-tempo-filepath], [data-tempo-html-filepath]\";\n\ninterface AnnotationNamespace {\n filepathAttr: string;\n positionAttr: string;\n modifiedTsAttr: string;\n sourceVersionAttr: string;\n}\n\nconst NAMESPACES: readonly AnnotationNamespace[] = [\n {\n filepathAttr: \"data-tempo-filepath\",\n positionAttr: \"data-tempo-position\",\n modifiedTsAttr: \"data-tempo-modifiedts\",\n sourceVersionAttr: \"data-tempo-source-version\",\n },\n {\n filepathAttr: \"data-tempo-html-filepath\",\n positionAttr: \"data-tempo-html-offset\",\n modifiedTsAttr: \"data-tempo-html-modifiedts\",\n sourceVersionAttr: \"data-tempo-html-source-version\",\n },\n];\n\n/**\n * Compute the declared facts for a capture.\n *\n * @param targetElement - The element whose subtree is serialized into\n * `dom.html` (the mutation LCA for scoped captures, or the capture root\n * for whole-surface ones).\n * @param captureRoot - The watched root. `complete` is `targetElement ===\n * captureRoot`. The render-error probe searches the WHOLE root (the error\n * overlay is a surface-level fact, not necessarily inside the scoped LCA).\n * @param scopeSelector - The selector the producer already computed for\n * `targetElement` relative to `captureRoot` (\"\" for whole-surface).\n * Surfaced as `scopeSelector` only when the capture is not complete.\n * @param portalElements - Live portal root elements whose content the\n * producer also serializes into `portals`. Their annotations count toward\n * `observedVersions`/`containedAnchors` exactly as the DOM subtree's do.\n */\nexport function computeDeclaredFacts(\n targetElement: Element,\n captureRoot: Element,\n scopeSelector: string,\n portalElements: readonly Element[],\n): DeclaredCaptureFacts {\n const observedVersions: Record<string, number> = {};\n const observedSourceVersions: Record<string, string> = {};\n const anchorSet = new Set<string>();\n\n const visit = (element: Element): void => {\n for (const ns of NAMESPACES) {\n const filepath = element.getAttribute(ns.filepathAttr);\n if (filepath == null || filepath.length === 0) continue;\n\n const modifiedTsRaw = element.getAttribute(ns.modifiedTsAttr);\n if (modifiedTsRaw != null) {\n const modifiedTs = Number(modifiedTsRaw);\n if (!Number.isNaN(modifiedTs)) {\n const existing = observedVersions[filepath];\n if (existing === undefined || modifiedTs > existing) {\n observedVersions[filepath] = modifiedTs;\n // Co-locate the content-version token with the newest render: it\n // rides the same element that just set the file's MAX modifiedts.\n // Clear a stale token from an older render when the newest element\n // carries none (a mid-HMR mixed tree, or an old-SDK element).\n const version = element.getAttribute(ns.sourceVersionAttr);\n if (version != null && version.length > 0) {\n observedSourceVersions[filepath] = version;\n } else {\n delete observedSourceVersions[filepath];\n }\n }\n }\n }\n\n const position = element.getAttribute(ns.positionAttr);\n if (position != null && position.length > 0) {\n anchorSet.add(`${filepath} ${position}`);\n }\n }\n };\n\n // The serialized population: the target subtree (including the target\n // element itself, whose annotations travel in `dom.attributes`) plus every\n // portal root and its descendants.\n const walkRoots: readonly Element[] = [targetElement, ...portalElements];\n for (const root of walkRoots) {\n if (root.matches(SOURCE_ANNOTATED_SELECTOR)) visit(root);\n for (const annotated of root.querySelectorAll(SOURCE_ANNOTATED_SELECTOR)) {\n visit(annotated);\n }\n }\n\n const complete = targetElement === captureRoot;\n\n return {\n complete,\n scopeSelector: complete ? null : scopeSelector,\n observedVersions,\n observedSourceVersions,\n containedAnchors: Array.from(anchorSet),\n renderError: computeRenderError(captureRoot),\n };\n}\n\n/**\n * Render-error boundary state for a capture root. Non-null iff a\n * `[data-render-error=\"true\"]` element exists anywhere in the live root\n * subtree (or is the root itself); its `data-render-error-message` becomes\n * `message` when present.\n */\nfunction computeRenderError(\n captureRoot: Element,\n): DeclaredCaptureFacts[\"renderError\"] {\n const errorElement = captureRoot.matches('[data-render-error=\"true\"]')\n ? captureRoot\n : captureRoot.querySelector('[data-render-error=\"true\"]');\n if (!errorElement) return null;\n return {\n message: errorElement.getAttribute(\"data-render-error-message\"),\n };\n}\n","import { countCaptureStyleRead } from \"../shared/capture-perf\";\nimport type { CaptureDisplayability } from \"./types\";\n\n/** Elements whose descendants do not contribute projected pixels/content. */\nconst IGNORED_CONTENT_TAGS = new Set([\n \"DATALIST\",\n \"LINK\",\n \"META\",\n \"NOSCRIPT\",\n \"SCRIPT\",\n \"STYLE\",\n \"TEMPLATE\",\n]);\n\nconst VISUAL_ASSET_TAGS = new Set([\n \"AUDIO\",\n \"CANVAS\",\n \"EMBED\",\n \"IFRAME\",\n \"IMG\",\n \"INPUT\",\n \"OBJECT\",\n \"SELECT\",\n \"SVG\",\n \"TEXTAREA\",\n \"VIDEO\",\n]);\n\n/**\n * Measures displayable structure in a live, styled document.\n *\n * The capture root itself is excluded because `DomCapture.dom.html` contains\n * its children. Supplemental roots are included because portal updates carry\n * each portal root's `outerHTML`. A null result means no browsing context was\n * available, so callers must omit the proof rather than infer it from markup.\n */\nexport function measureComputedDisplayability(\n captureRoot: Element,\n supplementalRoots: readonly Element[] = [],\n): CaptureDisplayability | null {\n const doc = captureRoot.ownerDocument;\n const view = doc.defaultView;\n if (\n !view ||\n !captureRoot.isConnected ||\n supplementalRoots.some(\n (root) => root.ownerDocument !== doc || !root.isConnected,\n )\n ) {\n return null;\n }\n\n const result: CaptureDisplayability = {\n version: 1,\n elementCount: 0,\n paintedElementCount: 0,\n nonEmptyTextNodeCount: 0,\n visualAssetCount: 0,\n };\n\n try {\n const rootBlocked = hasBlockingElementInChain(captureRoot, view);\n const rootTextVisible =\n !rootBlocked && elementHasVisibleComputedVisibility(captureRoot, view);\n for (const child of Array.from(captureRoot.childNodes)) {\n visitNode(child, rootBlocked, rootTextVisible, view, result);\n }\n\n for (const supplementalRoot of supplementalRoots) {\n visitNode(\n supplementalRoot,\n hasBlockingElementInChain(supplementalRoot.parentElement, view),\n true,\n view,\n result,\n );\n }\n } catch {\n // A producer declaration is proof. If style inspection is unavailable for\n // any part of the render domain, omit the whole profile conservatively.\n return null;\n }\n\n return result;\n}\n\nfunction visitNode(\n node: Node,\n blockedByAncestor: boolean,\n parentTextVisible: boolean,\n view: Window,\n result: CaptureDisplayability,\n): void {\n if (node.nodeType === 3) {\n if (\n !blockedByAncestor &&\n parentTextVisible &&\n (node.textContent?.trim().length ?? 0) > 0\n ) {\n result.nonEmptyTextNodeCount += 1;\n }\n return;\n }\n if (node.nodeType !== 1) return;\n\n const element = node as Element;\n const blocked = blockedByAncestor || elementBlocksSubtree(element, view);\n if (blocked) return;\n\n const visible = elementHasVisibleComputedVisibility(element, view);\n if (visible) {\n result.elementCount += 1;\n if (elementPaintsOwnPixels(element, view)) {\n result.paintedElementCount = (result.paintedElementCount ?? 0) + 1;\n }\n if (VISUAL_ASSET_TAGS.has(element.tagName)) {\n result.visualAssetCount += 1;\n }\n }\n\n for (const child of Array.from(element.childNodes)) {\n visitNode(child, false, visible, view, result);\n }\n}\n\nfunction elementPaintsOwnPixels(element: Element, view: Window): boolean {\n countCaptureStyleRead();\n const style = view.getComputedStyle(element);\n if (colorCanPaint(style.backgroundColor)) return true;\n if (style.backgroundImage && style.backgroundImage !== \"none\") return true;\n if (style.boxShadow && style.boxShadow !== \"none\") return true;\n if (\n style.outlineStyle !== \"none\" &&\n parseFloat(style.outlineWidth) > 0 &&\n colorCanPaint(style.outlineColor)\n ) {\n return true;\n }\n for (const side of [\"Top\", \"Right\", \"Bottom\", \"Left\"] as const) {\n if (\n style[`border${side}Style`] !== \"none\" &&\n parseFloat(style[`border${side}Width`]) > 0 &&\n colorCanPaint(style[`border${side}Color`])\n ) {\n return true;\n }\n }\n return false;\n}\n\nfunction colorCanPaint(value: string): boolean {\n const normalized = value.trim().toLowerCase().replace(/ /g, \"\");\n if (!normalized || normalized === \"transparent\") return false;\n return !(\n /^rgba\\([^)]*,0(?:\\.0+)?\\)$/.test(normalized) ||\n /^rgb\\([^)]*\\/0(?:\\.0+)?\\)$/.test(normalized)\n );\n}\n\nfunction hasBlockingElementInChain(\n start: Element | null,\n view: Window,\n): boolean {\n for (let element = start; element; element = element.parentElement) {\n if (elementBlocksSubtree(element, view)) return true;\n }\n return false;\n}\n\nfunction elementBlocksSubtree(element: Element, view: Window): boolean {\n if (IGNORED_CONTENT_TAGS.has(element.tagName)) return true;\n if (element.hasAttribute(\"hidden\")) return true;\n if (element.tagName === \"DIALOG\" && !element.hasAttribute(\"open\")) {\n return true;\n }\n if (\n element.tagName === \"INPUT\" &&\n element.getAttribute(\"type\")?.trim().toLowerCase() === \"hidden\"\n ) {\n return true;\n }\n\n countCaptureStyleRead();\n const style = view.getComputedStyle(element);\n const opacity = style.opacity.trim();\n return (\n style.display === \"none\" ||\n (opacity.length > 0 && Number(opacity) <= 0) ||\n style.getPropertyValue(\"content-visibility\") === \"hidden\"\n );\n}\n\nfunction elementHasVisibleComputedVisibility(\n element: Element,\n view: Window,\n): boolean {\n countCaptureStyleRead();\n const visibility = view.getComputedStyle(element).visibility;\n return visibility !== \"hidden\" && visibility !== \"collapse\";\n}\n","/**\n * CSS Selector Utilities\n *\n * Pure functions for generating CSS selectors.\n */\n\n/**\n * Generates a unique CSS selector path for an element.\n *\n * Uses nth-of-type notation when needed for uniqueness among siblings.\n *\n * @param element - Element to generate selector for\n * @param root - Optional root element to stop at (selector will be relative to this)\n * @returns CSS selector path (e.g., \"body > div > button:nth-of-type(2)\")\n *\n * @example\n * ```ts\n * generateSelector(document.querySelector('button'));\n * // \"body > div > button\"\n *\n * generateSelector(button, container);\n * // \"div > button\" (relative to container)\n * ```\n */\nexport function generateSelector(element: Element, root?: Element): string {\n // Special cases for well-known elements\n if (!root) {\n if (element === document.documentElement) return \":root\";\n if (element === document.head) return \"head\";\n if (element === document.body) return \"body\";\n }\n\n // If element is the root, return empty string\n if (root && element === root) return \"\";\n\n const parts: string[] = [];\n let current: Element | null = element;\n const stopAt = root ?? document.documentElement;\n\n while (current && current !== stopAt) {\n const parent: Element | null = current.parentElement;\n if (!parent) break;\n\n const tagName = current.tagName.toLowerCase();\n\n // Count same-type siblings to determine if :nth-of-type is needed\n let index = 1;\n let sibling = current.previousElementSibling;\n while (sibling) {\n if (sibling.tagName === current.tagName) index++;\n sibling = sibling.previousElementSibling;\n }\n\n let sameTypeSiblings = 0;\n for (const child of parent.children) {\n if (child.tagName === current.tagName) sameTypeSiblings++;\n }\n\n if (sameTypeSiblings > 1) {\n parts.unshift(`${tagName}:nth-of-type(${index})`);\n } else {\n parts.unshift(tagName);\n }\n\n current = parent;\n }\n\n // Handle edge cases\n if (parts.length === 0) {\n if (element === document.body) return \"body\";\n if (element === document.head) return \"head\";\n return \"\";\n }\n\n const path = parts.join(\" > \");\n\n // Anchor to root with :scope so querySelector matches at the correct depth.\n // Without this, \"div > div > div:nth-of-type(2)\" is ambiguous — it can match\n // any ancestor chain of divs at any depth within the subtree, not just the\n // specific depth from the root. :scope pins the first segment to a direct\n // child of the querySelector target.\n if (root) return `:scope > ${path}`;\n\n return path;\n}\n\n/**\n * Finds the Lowest Common Ancestor (LCA) of a set of nodes.\n *\n * The LCA is the deepest element that is an ancestor of all provided nodes.\n * Useful for determining the minimal subtree that contains all mutations.\n *\n * @param nodes - Set of DOM nodes to find common ancestor for\n * @returns The LCA element, or null if no common ancestor found\n */\nexport function findLowestCommonAncestor(nodes: Set<Node>): Element | null {\n if (nodes.size === 0) return null;\n\n // Build ancestor chains for each node (from root to node)\n const ancestorChains: Element[][] = [];\n\n for (const node of nodes) {\n const chain: Element[] = [];\n let current: Node | null =\n node instanceof Element ? node : node.parentElement;\n\n while (current && current !== document) {\n if (current instanceof Element) {\n chain.unshift(current);\n }\n current = current.parentNode;\n }\n\n if (chain.length > 0) {\n ancestorChains.push(chain);\n }\n }\n\n if (ancestorChains.length === 0) {\n return document.documentElement;\n }\n\n // Find the deepest common ancestor by comparing chains\n let lca: Element = document.documentElement;\n const firstChain = ancestorChains[0]!;\n const minLength = Math.min(...ancestorChains.map((c) => c.length));\n\n for (let i = 0; i < minLength; i++) {\n const candidate = firstChain[i];\n if (candidate && ancestorChains.every((chain) => chain[i] === candidate)) {\n lca = candidate;\n } else {\n break;\n }\n }\n\n return lca;\n}\n","/**\n * DOM Capture\n *\n * One-shot capture of DOM content and element states.\n */\n\nimport { computeDeclaredFacts } from \"./declared-facts\";\nimport { measureComputedDisplayability } from \"./displayability\";\nimport { generateSelector } from \"./selectors\";\nimport type { DomCapture, ElementState } from \"./types\";\n\nexport interface CollectElementStatesOptions {\n /** Whether to include document-level scroll via the :root selector. */\n includeDocumentScroll?: boolean;\n}\n\n/**\n * Captures the current state of an element as a DomCapture.\n *\n * @param element - Element to capture\n * @returns DomCapture containing HTML and element states\n *\n * @example\n * ```ts\n * const snapshot = capture(document.body);\n * // { dom: { selector: \"body\", html: \"...\" }, states: [...] }\n * ```\n */\nexport function capture(element: Element): DomCapture {\n return captureWithSupplementalRoots(element, []);\n}\n\n/** Internal complete-capture primitive used when a higher-level producer also\n * serializes supplemental roots such as owned React portals. */\nexport function captureWithSupplementalRoots(\n element: Element,\n supplementalRoots: readonly Element[],\n): DomCapture {\n // Sync form state to attributes before serializing\n syncFormStateToAttributes(element);\n\n // Selector relative to itself = \"\" (this IS the container)\n const selector = generateSelector(element, element);\n // Use innerHTML - we capture the children, not the container itself\n const html = removeScriptTags(element.innerHTML);\n const attributes = captureAttributes(element);\n const documentElementAttributes = element.ownerDocument\n ? captureAttributes(element.ownerDocument.documentElement)\n : undefined;\n const bodyAttributes = element.ownerDocument?.body\n ? captureAttributes(element.ownerDocument.body)\n : undefined;\n const baseUrl = element.ownerDocument?.baseURI;\n const states = collectElementStates(element);\n const displayability = measureComputedDisplayability(\n element,\n supplementalRoots,\n );\n\n return {\n // Whole-surface one-shot: the element is both the capture root and the\n // serialized scope, so `complete` is true and there is no scope selector.\n declared: computeDeclaredFacts(element, element, \"\", supplementalRoots),\n ...(displayability && { displayability }),\n dom: {\n selector,\n html,\n attributes,\n documentElementAttributes,\n bodyAttributes,\n },\n states,\n baseUrl,\n };\n}\n\n/**\n * Syncs form element state (DOM properties) to HTML attributes.\n *\n * Form elements like checkboxes, selects, and inputs have runtime state\n * that isn't reflected in their HTML attributes. This syncs that state\n * to attributes so it survives serialization.\n */\nfunction syncFormStateToAttributes(root: Element): void {\n // Checkboxes and radios\n for (const input of root.querySelectorAll(\n 'input[type=\"checkbox\"], input[type=\"radio\"]',\n )) {\n const el = input as HTMLInputElement;\n if (el.checked) {\n el.setAttribute(\"checked\", \"\");\n } else {\n el.removeAttribute(\"checked\");\n }\n }\n\n // Text inputs\n for (const input of root.querySelectorAll(\n 'input:not([type=\"checkbox\"]):not([type=\"radio\"])',\n )) {\n const el = input as HTMLInputElement;\n if (el.value !== el.getAttribute(\"value\")) {\n el.setAttribute(\"value\", el.value);\n }\n }\n\n // Textareas\n for (const textarea of root.querySelectorAll(\"textarea\")) {\n const el = textarea as HTMLTextAreaElement;\n if (el.value !== el.textContent) {\n el.textContent = el.value;\n }\n if (el.hasAttribute(\"value\")) {\n el.removeAttribute(\"value\");\n }\n }\n\n // Selects\n for (const select of root.querySelectorAll(\"select\")) {\n const el = select as HTMLSelectElement;\n for (const option of el.options) {\n if (option.selected) {\n option.setAttribute(\"selected\", \"\");\n } else {\n option.removeAttribute(\"selected\");\n }\n }\n }\n}\n\n/**\n * Removes all script tags from HTML string.\n */\nexport function removeScriptTags(html: string): string {\n return html.replace(/<script\\b[^>]*>[\\s\\S]*?<\\/script>/gi, \"\");\n}\n\n/**\n * Captures attributes from an element into a serializable map.\n */\nexport function captureAttributes(element: Element): Record<string, string> {\n const attrs: Record<string, string> = {};\n for (const attr of Array.from(element.attributes)) {\n attrs[attr.name] = attr.value;\n }\n return attrs;\n}\n\n/**\n * Collects current element states from a root element.\n *\n * Walks form elements and scrollable containers to collect their runtime state.\n */\nexport function collectElementStates(\n root: Element,\n options: CollectElementStatesOptions = {},\n): ElementState[] {\n const { includeDocumentScroll = true } = options;\n const states: ElementState[] = [];\n\n // Collect form states\n for (const input of root.querySelectorAll(\"input\")) {\n const el = input as HTMLInputElement;\n const isCheckable = el.type === \"checkbox\" || el.type === \"radio\";\n const hasNonDefault = isCheckable\n ? el.checked !== el.defaultChecked\n : el.value !== el.defaultValue;\n\n if (hasNonDefault) {\n const selector = generateSelector(el, root);\n if (isCheckable) {\n states.push({ selector, checked: el.checked });\n } else {\n states.push({ selector, value: el.value });\n }\n }\n }\n\n for (const textarea of root.querySelectorAll(\"textarea\")) {\n const el = textarea as HTMLTextAreaElement;\n if (el.value !== el.defaultValue) {\n const selector = generateSelector(el, root);\n states.push({ selector, value: el.value });\n }\n }\n\n for (const select of root.querySelectorAll(\"select\")) {\n const el = select as HTMLSelectElement;\n for (const option of el.options) {\n if (option.selected !== option.defaultSelected) {\n const selector = generateSelector(option, root);\n states.push({ selector, selected: option.selected });\n }\n }\n }\n\n // Collect scroll states - always include root and document-level scroll\n // so that scrolling back to 0 is properly communicated.\n states.push({\n selector: \"\",\n scrollTop: root.scrollTop,\n scrollLeft: root.scrollLeft,\n });\n\n // Check document-level scroll (scrollingElement, usually <html>)\n // This handles the common case where scroll is on documentElement, not body\n if (includeDocumentScroll) {\n const scrollingEl = root.ownerDocument?.scrollingElement;\n if (scrollingEl && scrollingEl !== root) {\n states.push({\n selector: \":root\",\n scrollTop: scrollingEl.scrollTop,\n scrollLeft: scrollingEl.scrollLeft,\n });\n }\n }\n\n for (const el of root.querySelectorAll(\"*\")) {\n if (el.scrollTop > 0 || el.scrollLeft > 0) {\n const selector = generateSelector(el, root);\n states.push({\n selector,\n scrollTop: el.scrollTop,\n scrollLeft: el.scrollLeft,\n });\n }\n }\n\n return states;\n}\n"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