tempo-sdk 0.0.57 → 0.0.66
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/astro/client.d.ts +4 -0
- package/dist/assets/editor.js +1 -1
- package/dist/assets/index.d.ts +10 -63
- package/dist/assets/index.js +12 -32
- package/dist/assets/index.js.map +1 -1
- package/dist/assets/parser.js +1 -1
- package/dist/astro/asset-preview-client.d.ts +4 -0
- package/dist/astro/asset-preview-client.js +93 -0
- package/dist/astro/asset-preview-client.js.map +1 -0
- package/dist/astro/controls.d.ts +7 -0
- package/dist/astro/controls.js +7 -0
- package/dist/astro/controls.js.map +1 -0
- package/dist/astro/document-client.d.ts +10 -0
- package/dist/astro/document-client.js +78 -0
- package/dist/astro/document-client.js.map +1 -0
- package/dist/astro/runtime.d.ts +15 -0
- package/dist/astro/runtime.js +86 -0
- package/dist/astro/runtime.js.map +1 -0
- package/dist/astro.d.ts +21 -0
- package/dist/astro.js +749 -0
- package/dist/astro.js.map +1 -0
- package/dist/canvas/astro-contract.d.ts +21 -0
- package/dist/canvas/astro-contract.js +9 -0
- package/dist/canvas/astro-contract.js.map +1 -0
- package/dist/canvas/astro.d.ts +18 -0
- package/dist/canvas/astro.js +42 -0
- package/dist/canvas/astro.js.map +1 -0
- package/dist/canvas/editor.d.ts +1 -1
- package/dist/canvas/editor.js +3 -2
- package/dist/canvas/editor.js.map +1 -1
- package/dist/canvas/index.d.ts +4 -2
- package/dist/canvas/index.js +138 -34
- package/dist/canvas/index.js.map +1 -1
- package/dist/canvas/interact-projection.js +4 -4
- package/dist/canvas/parser.d.ts +3 -1
- package/dist/canvas/parser.js +1 -1
- package/dist/canvas/svelte.d.ts +1 -1
- package/dist/canvas/svelte.js +3 -3
- package/dist/{chunk-5BHIHP25.js → chunk-2JRAG36X.js} +37 -11
- package/dist/chunk-2JRAG36X.js.map +1 -0
- package/dist/{chunk-N2TYN3RB.js → chunk-6AAE4LYV.js} +123 -123
- package/dist/chunk-6AAE4LYV.js.map +1 -0
- package/dist/{chunk-U3SLJNRS.js → chunk-6IR5JY6W.js} +106 -7
- package/dist/chunk-6IR5JY6W.js.map +1 -0
- package/dist/{chunk-QXL6GL2P.js → chunk-6W6UKDSY.js} +46 -5
- package/dist/chunk-6W6UKDSY.js.map +1 -0
- package/dist/chunk-77DZCV5Z.js +38 -0
- package/dist/chunk-77DZCV5Z.js.map +1 -0
- package/dist/chunk-DELFOKU3.js +2495 -0
- package/dist/chunk-DELFOKU3.js.map +1 -0
- package/dist/{chunk-U64AHDHZ.js → chunk-EYKOOLPL.js} +380 -34
- package/dist/chunk-EYKOOLPL.js.map +1 -0
- package/dist/chunk-F23JGM4U.js +107 -0
- package/dist/chunk-F23JGM4U.js.map +1 -0
- package/dist/chunk-FE6TYCLF.js +1514 -0
- package/dist/chunk-FE6TYCLF.js.map +1 -0
- package/dist/chunk-H6OZIX2U.js +133 -0
- package/dist/chunk-H6OZIX2U.js.map +1 -0
- package/dist/chunk-JVVHU3A7.js +1077 -0
- package/dist/chunk-JVVHU3A7.js.map +1 -0
- package/dist/{chunk-2IQD2KPS.js → chunk-KOSJXE4G.js} +3 -102
- package/dist/chunk-KOSJXE4G.js.map +1 -0
- package/dist/{chunk-TL4MGN7E.js → chunk-NSKYOKG5.js} +254 -10
- package/dist/chunk-NSKYOKG5.js.map +1 -0
- package/dist/chunk-OX2YKYSL.js +13 -0
- package/dist/chunk-OX2YKYSL.js.map +1 -0
- package/dist/{chunk-RHHVVWAC.js → chunk-PXDTH36X.js} +14 -12
- package/dist/chunk-PXDTH36X.js.map +1 -0
- package/dist/{chunk-XLEKCOB7.js → chunk-PYAJHLXO.js} +56 -1
- package/dist/chunk-PYAJHLXO.js.map +1 -0
- package/dist/{chunk-EMYYTS6D.js → chunk-Q2A46HHW.js} +19 -14
- package/dist/chunk-Q2A46HHW.js.map +1 -0
- package/dist/controls-reader-SNMI2UY7.js +191 -0
- package/dist/controls-reader-SNMI2UY7.js.map +1 -0
- package/dist/controls-uCaQ3CNX.d.ts +61 -0
- package/dist/expo/plugin.cjs +18 -13
- package/dist/expo/plugin.cjs.map +1 -1
- package/dist/expo/plugin.js +1 -1
- package/dist/expo-babel-plugin.cjs +18 -13
- package/dist/expo-babel-plugin.cjs.map +1 -1
- package/dist/expo-babel-plugin.js +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +10 -2294
- package/dist/index.js.map +1 -1
- package/dist/nextjs/plugin.cjs +45 -4
- package/dist/nextjs/plugin.cjs.map +1 -1
- package/dist/nextjs/plugin.js +1 -1
- package/dist/nextjs-loader.cjs +63 -17
- package/dist/nextjs-loader.cjs.map +1 -1
- package/dist/nextjs.cjs +45 -4
- package/dist/nextjs.cjs.map +1 -1
- package/dist/nextjs.d.cts +4 -4
- package/dist/nextjs.d.ts +4 -4
- package/dist/nextjs.js +1 -1
- package/dist/{storyboard-BtQuVGpl.d.ts → storyboard-4YdTYq_e.d.ts} +3 -1
- package/dist/svelte.js +7 -1075
- package/dist/svelte.js.map +1 -1
- package/package.json +45 -4
- package/dist/chunk-2IQD2KPS.js.map +0 -1
- package/dist/chunk-5BHIHP25.js.map +0 -1
- package/dist/chunk-EMYYTS6D.js.map +0 -1
- package/dist/chunk-N2TYN3RB.js.map +0 -1
- package/dist/chunk-QXL6GL2P.js.map +0 -1
- package/dist/chunk-RHHVVWAC.js.map +0 -1
- package/dist/chunk-TL4MGN7E.js.map +0 -1
- package/dist/chunk-U3SLJNRS.js.map +0 -1
- package/dist/chunk-U64AHDHZ.js.map +0 -1
- package/dist/chunk-XLEKCOB7.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
installTempoInteractProjectionSource
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-EYKOOLPL.js";
|
|
4
|
+
import "../chunk-2JRAG36X.js";
|
|
5
|
+
import "../chunk-NSKYOKG5.js";
|
|
6
|
+
import "../chunk-6AAE4LYV.js";
|
|
4
7
|
import "../chunk-65B52AR7.js";
|
|
5
|
-
import "../chunk-TL4MGN7E.js";
|
|
6
|
-
import "../chunk-5BHIHP25.js";
|
|
7
|
-
import "../chunk-N2TYN3RB.js";
|
|
8
8
|
export {
|
|
9
9
|
installTempoInteractProjectionSource
|
|
10
10
|
};
|
package/dist/canvas/parser.d.ts
CHANGED
|
@@ -92,8 +92,10 @@ type ParsedCanvasStoryboard = {
|
|
|
92
92
|
storyboardKey: string;
|
|
93
93
|
displayName?: string;
|
|
94
94
|
kind: "component" | "route" | "html";
|
|
95
|
-
/**
|
|
95
|
+
/** Legacy component-runtime field; its published output union stays stable. */
|
|
96
96
|
uiFramework?: "svelte";
|
|
97
|
+
/** Additional component runtimes, without widening the legacy output field. */
|
|
98
|
+
runtimeFramework?: "astro";
|
|
97
99
|
layout: ParsedCanvasLayout;
|
|
98
100
|
editable: boolean;
|
|
99
101
|
jsxElementSpan: CanvasSourceSpan;
|
package/dist/canvas/parser.js
CHANGED
package/dist/canvas/svelte.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import * as svelte from 'svelte';
|
|
3
|
-
import { a as StoryboardLayout, c as StoryboardVrtConfig } from '../storyboard-
|
|
3
|
+
import { a as StoryboardLayout, c as StoryboardVrtConfig } from '../storyboard-4YdTYq_e.js';
|
|
4
4
|
import '../page-DwLnOM5d.js';
|
|
5
5
|
import '../v1-client-compat-qxaXEDm_.js';
|
|
6
6
|
|
package/dist/canvas/svelte.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
StoryboardSlot
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-6IR5JY6W.js";
|
|
4
|
+
import "../chunk-NSKYOKG5.js";
|
|
5
|
+
import "../chunk-6AAE4LYV.js";
|
|
6
6
|
|
|
7
7
|
// canvas/svelte.tsx
|
|
8
8
|
import { useLayoutEffect, useRef, useState } from "react";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CSS_RUNTIME_MUTATION,
|
|
3
3
|
observeRuntimeMutations
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-6AAE4LYV.js";
|
|
5
5
|
|
|
6
6
|
// ../../modules/iframe-projection/html/watch-head.ts
|
|
7
7
|
var INCLUDE_TAGS = /* @__PURE__ */ new Set(["STYLE", "META", "BASE", "LINK"]);
|
|
@@ -41,6 +41,9 @@ var HeadTrackerImpl = class {
|
|
|
41
41
|
this.docObservers = /* @__PURE__ */ new Map();
|
|
42
42
|
this.activeSubscriptions = 0;
|
|
43
43
|
}
|
|
44
|
+
flushPending(doc) {
|
|
45
|
+
this.docObservers.get(doc)?.flushPending();
|
|
46
|
+
}
|
|
44
47
|
subscribe(doc, onMutation) {
|
|
45
48
|
let docState = this.docObservers.get(doc);
|
|
46
49
|
if (!docState) {
|
|
@@ -69,32 +72,35 @@ var HeadTrackerImpl = class {
|
|
|
69
72
|
stopHooks();
|
|
70
73
|
};
|
|
71
74
|
const observeHead = (head) => {
|
|
72
|
-
const
|
|
75
|
+
const changed = (mutations) => {
|
|
73
76
|
const details = this.readRelevantMutations(mutations, head);
|
|
74
77
|
if (!details) return;
|
|
75
78
|
notify(details);
|
|
76
|
-
}
|
|
79
|
+
};
|
|
80
|
+
const observer = new MutationObserver(changed);
|
|
77
81
|
observer.observe(head, {
|
|
78
82
|
childList: true,
|
|
79
83
|
subtree: true,
|
|
80
84
|
attributes: true,
|
|
81
85
|
characterData: true
|
|
82
86
|
});
|
|
83
|
-
return observer;
|
|
87
|
+
return { observer, flushPending: () => changed(observer.takeRecords()) };
|
|
84
88
|
};
|
|
85
89
|
if (doc.head) {
|
|
86
|
-
return {
|
|
90
|
+
return { ...observeHead(doc.head), subscriptions, stopRuntime };
|
|
87
91
|
}
|
|
88
|
-
const
|
|
92
|
+
const attachHead = () => {
|
|
89
93
|
const head = doc.head;
|
|
90
94
|
if (!head) return;
|
|
91
95
|
bootstrap.disconnect();
|
|
92
|
-
state
|
|
96
|
+
Object.assign(state, observeHead(head));
|
|
93
97
|
notify({ stylesheetPaths: [] });
|
|
94
|
-
}
|
|
98
|
+
};
|
|
99
|
+
const bootstrap = new MutationObserver(attachHead);
|
|
95
100
|
bootstrap.observe(doc, { childList: true, subtree: true });
|
|
96
101
|
const state = {
|
|
97
102
|
observer: bootstrap,
|
|
103
|
+
flushPending: attachHead,
|
|
98
104
|
subscriptions,
|
|
99
105
|
stopRuntime
|
|
100
106
|
};
|
|
@@ -257,11 +263,31 @@ function materializeStylesheetLinkCssom(source, clone) {
|
|
|
257
263
|
style.textContent = absolutifyCssReferences(cssText, link.href);
|
|
258
264
|
return style;
|
|
259
265
|
}
|
|
266
|
+
var styleSourceEvidence = /* @__PURE__ */ new WeakMap();
|
|
260
267
|
function retainStyleSourceEvidence(source, clone) {
|
|
261
268
|
clone.removeAttribute("data-projection-css-source-map");
|
|
262
269
|
clone.removeAttribute("data-projection-css-source-map-url");
|
|
263
270
|
const text = source.textContent ?? "";
|
|
264
|
-
if (text.length > 5 * 1024 * 1024)
|
|
271
|
+
if (text.length > 5 * 1024 * 1024) {
|
|
272
|
+
styleSourceEvidence.delete(source);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
const cached = styleSourceEvidence.get(source);
|
|
276
|
+
if (cached?.text === text) {
|
|
277
|
+
if (cached.inline)
|
|
278
|
+
clone.setAttribute("data-projection-css-source-map", cached.inline);
|
|
279
|
+
if (cached.url)
|
|
280
|
+
clone.setAttribute("data-projection-css-source-map-url", cached.url);
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
captureStyleSourceEvidence(text, clone);
|
|
284
|
+
styleSourceEvidence.set(source, {
|
|
285
|
+
text,
|
|
286
|
+
inline: clone.getAttribute("data-projection-css-source-map"),
|
|
287
|
+
url: clone.getAttribute("data-projection-css-source-map-url")
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
function captureStyleSourceEvidence(text, clone) {
|
|
265
291
|
const reference = [
|
|
266
292
|
...text.matchAll(/\/\*[#@]\s*sourceMappingURL\s*=\s*(\S+?)\s*\*\//g)
|
|
267
293
|
].slice(-1)[0]?.[1];
|
|
@@ -282,7 +308,7 @@ function retainStyleSourceEvidence(source, clone) {
|
|
|
282
308
|
if (!raw || typeof raw !== "object" || depth > 16) return null;
|
|
283
309
|
const map = raw;
|
|
284
310
|
if (map.version !== 3) return null;
|
|
285
|
-
const sources = Array.isArray(map.sources) && map.sources.length <= 4096 && map.sources.every((
|
|
311
|
+
const sources = Array.isArray(map.sources) && map.sources.length <= 4096 && map.sources.every((source) => typeof source === "string") ? map.sources : void 0;
|
|
286
312
|
const sections = Array.isArray(map.sections) && map.sections.length <= 256 ? map.sections.flatMap((section) => {
|
|
287
313
|
const nested = section && typeof section === "object" ? compact(section.map, depth + 1) : null;
|
|
288
314
|
return nested ? [{ map: nested }] : [];
|
|
@@ -407,4 +433,4 @@ export {
|
|
|
407
433
|
getHeadTracker,
|
|
408
434
|
captureHead
|
|
409
435
|
};
|
|
410
|
-
//# sourceMappingURL=chunk-
|
|
436
|
+
//# sourceMappingURL=chunk-2JRAG36X.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../modules/iframe-projection/html/watch-head.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\nimport {\n CSS_RUNTIME_MUTATION,\n observeRuntimeMutations,\n} from \"./runtime-mutations\";\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 /** Publish already queued mutations before synchronous root admission. */\n flushPending?(doc: Document): void;\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 flushPending(): void;\n stopRuntime(): void;\n subscriptions: Set<HeadSubscriptionImpl>;\n}\n\nclass HeadTrackerImpl implements HeadTracker {\n private docObservers = new Map<Document, DocObserverState>();\n private activeSubscriptions = 0;\n\n flushPending(doc: Document): void {\n this.docObservers.get(doc)?.flushPending();\n }\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 const stopHooks = observeRuntimeMutations(doc);\n const cssChanged = () => notify({ stylesheetPaths: [] });\n doc.addEventListener(CSS_RUNTIME_MUTATION, cssChanged);\n const stopRuntime = () => {\n doc.removeEventListener(CSS_RUNTIME_MUTATION, cssChanged);\n stopHooks();\n };\n\n const observeHead = (head: HTMLHeadElement) => {\n const changed = (mutations: MutationRecord[]) => {\n const details = this.readRelevantMutations(mutations, head);\n if (!details) return;\n notify(details);\n };\n const observer = new MutationObserver(changed);\n observer.observe(head, {\n childList: true,\n subtree: true,\n attributes: true,\n characterData: true,\n });\n return { observer, flushPending: () => changed(observer.takeRecords()) };\n };\n\n if (doc.head) {\n return { ...observeHead(doc.head), subscriptions, stopRuntime };\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 attachHead = () => {\n const head = doc.head;\n if (!head) return;\n bootstrap.disconnect();\n Object.assign(state, observeHead(head));\n notify({ stylesheetPaths: [] });\n };\n const bootstrap = new MutationObserver(attachHead);\n bootstrap.observe(doc, { childList: true, subtree: true });\n const state: DocObserverState = {\n observer: bootstrap,\n flushPending: attachHead,\n subscriptions,\n stopRuntime,\n };\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 docState.stopRuntime();\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.stopRuntime();\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 type StyleResource = (css: string) => string | null;\n\nfunction serializeHeadStyle(style: Element, resource?: StyleResource): string {\n const type = style.getAttribute(\"type\")?.trim().toLowerCase();\n const href =\n !type || type === \"text/css\" ? resource?.(style.textContent ?? \"\") : null;\n if (href) {\n const link = style.ownerDocument.createElement(\"link\");\n for (const attribute of Array.from(style.attributes))\n if (\n ![\"type\", \"href\", \"rel\", \"integrity\", \"crossorigin\"].includes(\n attribute.name,\n )\n )\n link.setAttribute(attribute.name, attribute.value);\n link.rel = \"stylesheet\";\n link.href = href;\n return link.outerHTML;\n }\n escapeStyleForHtmlSerialization(style);\n return style.outerHTML;\n}\n\nexport function captureHead(doc: Document, resource?: StyleResource): 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 // The destination stages this head before installing its incoming base.\n // Authored inline/CSSOM styles must not resolve assets against that old\n // document. Materialized links already carry their stylesheet's own base.\n clone.textContent = absolutifyCssReferences(\n clone.textContent ?? \"\",\n baseURI,\n );\n fragments.push(serializeHeadStyle(clone, resource));\n continue;\n }\n\n fragments.push(clone.outerHTML);\n }\n\n fragments.push(...captureAdoptedStyleSheets(doc, resource));\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 === null) {\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\nconst styleSourceEvidence = new WeakMap<\n HTMLStyleElement,\n {\n text: string;\n inline: string | null;\n url: string | null;\n }\n>();\n\n/** Original identity metadata survives CSSOM comment removal; visual CSS stays CSSOM.\n * Decode unchanged authored metadata once per live style. CSSOM serialization\n * still runs on every capture, and a same-task text edit invalidates immediately. */\nfunction retainStyleSourceEvidence(\n source: HTMLStyleElement,\n clone: Element,\n): void {\n clone.removeAttribute(\"data-projection-css-source-map\");\n clone.removeAttribute(\"data-projection-css-source-map-url\");\n const text = source.textContent ?? \"\";\n if (text.length > 5 * 1024 * 1024) {\n styleSourceEvidence.delete(source);\n return;\n }\n const cached = styleSourceEvidence.get(source);\n if (cached?.text === text) {\n if (cached.inline)\n clone.setAttribute(\"data-projection-css-source-map\", cached.inline);\n if (cached.url)\n clone.setAttribute(\"data-projection-css-source-map-url\", cached.url);\n return;\n }\n captureStyleSourceEvidence(text, clone);\n styleSourceEvidence.set(source, {\n text,\n inline: clone.getAttribute(\"data-projection-css-source-map\"),\n url: clone.getAttribute(\"data-projection-css-source-map-url\"),\n });\n}\n\nfunction captureStyleSourceEvidence(text: string, clone: Element): void {\n const reference = [\n ...text.matchAll(/\\/\\*[#@]\\s*sourceMappingURL\\s*=\\s*(\\S+?)\\s*\\*\\//g),\n ].slice(-1)[0]?.[1];\n if (!reference || reference.length > 1024 * 1024) return;\n const inline =\n /^data:application\\/json(?:;charset=[\\w-]+)?(;base64)?,(.*)$/is.exec(\n reference,\n );\n if (!inline) {\n // A detached inline style has no proven relative map base. Absolute URLs\n // can be admitted later against the existing app/server source origin.\n try {\n const url = new URL(reference);\n if (/^https?:$/.test(url.protocol))\n clone.setAttribute(\"data-projection-css-source-map-url\", url.href);\n } catch {}\n return;\n }\n function compact(raw: unknown, depth: number): object | null {\n if (!raw || typeof raw !== \"object\" || depth > 16) return null;\n const map = raw as Record<string, unknown>;\n if (map.version !== 3) return null;\n const sources =\n Array.isArray(map.sources) &&\n map.sources.length <= 4096 &&\n map.sources.every((source) => typeof source === \"string\")\n ? map.sources\n : undefined;\n const sections =\n Array.isArray(map.sections) && map.sections.length <= 256\n ? map.sections.flatMap((section) => {\n const nested =\n section && typeof section === \"object\"\n ? compact(section.map, depth + 1)\n : null;\n return nested ? [{ map: nested }] : [];\n })\n : undefined;\n return {\n version: 3,\n ...(typeof map.file === \"string\" ? { file: map.file } : {}),\n ...(typeof map.sourceRoot === \"string\"\n ? { sourceRoot: map.sourceRoot }\n : {}),\n ...(sources ? { sources } : {}),\n ...(sections ? { sections } : {}),\n };\n }\n try {\n const json = inline[1]\n ? new TextDecoder().decode(\n Uint8Array.from(atob(inline[2]!), (character) =>\n character.charCodeAt(0),\n ),\n )\n : decodeURIComponent(inline[2]!);\n const metadata = compact(JSON.parse(json), 0);\n if (!metadata) return;\n const serialized = JSON.stringify(metadata);\n if (serialized.length <= 64 * 1024)\n clone.setAttribute(\"data-projection-css-source-map\", serialized);\n } catch {}\n}\n\n/**\n * CSSOM is current visual truth even when authored style text is nonempty.\n * A deleted final rule must serialize empty, not revive the original DOM text.\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 retainStyleSourceEvidence(style, clone);\n const cssText = serializeCssRules(style.sheet);\n if (cssText !== null) {\n clone.textContent = cssText;\n }\n}\n\nfunction captureAdoptedStyleSheets(\n doc: Document,\n resource?: StyleResource,\n): 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 = absolutifyCssReferences(cssText, doc.baseURI);\n fragments.push(serializeHeadStyle(style, resource));\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 | null {\n if (!sheet) {\n return null;\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 null;\n }\n}\n\nfunction absolutifyCssReferences(cssText: string, baseHref: string): string {\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 // URL resolution supports retained custom-scheme documents as well as HTTP.\n // This only serializes the source's URLs; protocol authorization remains at\n // the serving boundary. Opaque bases (about:blank, data:) fall through catch.\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"],"mappings":";;;;;;AAmBA,IAAM,eAAe,oBAAI,IAAI,CAAC,SAAS,QAAQ,QAAQ,MAAM,CAAC;AAG9D,IAAM,oBAAoB,oBAAI,IAAI,CAAC,YAAY,CAAC;AA4ChD,IAAI,WAAmC;AAKhC,SAAS,iBAA8B;AAC5C,MAAI,CAAC,UAAU;AACb,eAAW,IAAI,gBAAgB;AAAA,EACjC;AACA,SAAO;AACT;AAYA,IAAM,uBAAN,MAAuD;AAAA,EAMrD,YACE,KACA,UACA,eACA;AATF,wBAAe;AAUb,SAAK,MAAM;AACX,SAAK,WAAW;AAChB,SAAK,gBAAgB;AAAA,EACvB;AAAA,EAEA,MAAM,WAAwC;AAC5C,QAAI,CAAC,aAAa,CAAC,KAAK,cAAc;AACpC,aAAO;AAAA,IACT;AACA,SAAK,eAAe;AACpB,WAAO,YAAY,KAAK,GAAG;AAAA,EAC7B;AAAA,EAEA,cAAoB;AAClB,SAAK,cAAc;AAAA,EACrB;AAAA;AAAA,EAGA,eAAe,SAAoC;AACjD,SAAK,eAAe;AACpB,SAAK,SAAS,OAAO;AAAA,EACvB;AACF;AAUA,IAAM,kBAAN,MAA6C;AAAA,EAA7C;AACE,SAAQ,eAAe,oBAAI,IAAgC;AAC3D,SAAQ,sBAAsB;AAAA;AAAA,EAE9B,aAAa,KAAqB;AAChC,SAAK,aAAa,IAAI,GAAG,GAAG,aAAa;AAAA,EAC3C;AAAA,EAEA,UACE,KACA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aAAa;AACnD;AAKA,SAAS,YAAY,SAAkB,SAAuB;AAK5D,QAAM,OAAO,QAAQ,aAAa,MAAM;AACxC,MAAI,QAAQ,CAAC,cAAc,IAAI,GAAG;AAChC,QAAI;AACF,cAAQ,aAAa,QAAQ,IAAI,IAAI,MAAM,OAAO,EAAE,IAAI;AAAA,IAC1D,QAAQ;AAAA,IAER;AAAA,EACF;AAGA,QAAM,MAAM,QAAQ,aAAa,KAAK;AACtC,MAAI,OAAO,CAAC,cAAc,GAAG,GAAG;AAC9B,QAAI;AACF,cAAQ,aAAa,OAAO,IAAI,IAAI,KAAK,OAAO,EAAE,IAAI;AAAA,IACxD,QAAQ;AAAA,IAER;AAAA,EACF;AACF;AAKA,SAAS,cAAc,KAAsB;AAC3C,SAAO,mBAAmB,KAAK,GAAG,KAAK,IAAI,WAAW,OAAO;AAC/D;","names":[]}
|
|
@@ -1,75 +1,56 @@
|
|
|
1
|
-
// ../../modules/iframe-projection/html/
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (child.tagName === current.tagName) sameTypeSiblings++;
|
|
25
|
-
}
|
|
26
|
-
if (sameTypeSiblings > 1) {
|
|
27
|
-
parts.unshift(`${tagName}:nth-of-type(${index})`);
|
|
28
|
-
} else {
|
|
29
|
-
parts.unshift(tagName);
|
|
30
|
-
}
|
|
31
|
-
current = parent;
|
|
32
|
-
}
|
|
33
|
-
if (parts.length === 0) {
|
|
34
|
-
if (element === document.body) return "body";
|
|
35
|
-
if (element === document.head) return "head";
|
|
36
|
-
return "";
|
|
37
|
-
}
|
|
38
|
-
const path = parts.join(" > ");
|
|
39
|
-
if (root) return `:scope > ${path}`;
|
|
40
|
-
return path;
|
|
41
|
-
}
|
|
42
|
-
function findLowestCommonAncestor(nodes) {
|
|
43
|
-
if (nodes.size === 0) return null;
|
|
44
|
-
const ancestorChains = [];
|
|
45
|
-
for (const node of nodes) {
|
|
46
|
-
const chain = [];
|
|
47
|
-
let current = node instanceof Element ? node : node.parentElement;
|
|
48
|
-
while (current && current !== document) {
|
|
49
|
-
if (current instanceof Element) {
|
|
50
|
-
chain.unshift(current);
|
|
1
|
+
// ../../modules/iframe-projection/html/declared-facts.ts
|
|
2
|
+
var SOURCE_ANNOTATED_SELECTOR = "[data-tempo-filepath]";
|
|
3
|
+
function computeDeclaredFacts(targetElement, captureRoot, scopeSelector, portalElements) {
|
|
4
|
+
const observedVersions = {};
|
|
5
|
+
const observedSourceVersions = {};
|
|
6
|
+
const anchorSet = /* @__PURE__ */ new Set();
|
|
7
|
+
const visit = (element) => {
|
|
8
|
+
const filepath = element.getAttribute("data-tempo-filepath");
|
|
9
|
+
if (filepath == null || filepath.length === 0) return;
|
|
10
|
+
const modifiedTsRaw = element.getAttribute("data-tempo-modifiedts");
|
|
11
|
+
if (modifiedTsRaw != null) {
|
|
12
|
+
const modifiedTs = Number(modifiedTsRaw);
|
|
13
|
+
if (!Number.isNaN(modifiedTs)) {
|
|
14
|
+
const existing = observedVersions[filepath];
|
|
15
|
+
if (existing === void 0 || modifiedTs > existing) {
|
|
16
|
+
observedVersions[filepath] = modifiedTs;
|
|
17
|
+
const version = element.getAttribute("data-tempo-source-version");
|
|
18
|
+
if (version != null && version.length > 0) {
|
|
19
|
+
observedSourceVersions[filepath] = version;
|
|
20
|
+
} else {
|
|
21
|
+
delete observedSourceVersions[filepath];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
51
24
|
}
|
|
52
|
-
current = current.parentNode;
|
|
53
25
|
}
|
|
54
|
-
|
|
55
|
-
|
|
26
|
+
const position = element.getAttribute("data-tempo-position");
|
|
27
|
+
if (position != null && position.length > 0) {
|
|
28
|
+
anchorSet.add(`${filepath} ${position}`);
|
|
56
29
|
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const minLength = Math.min(...ancestorChains.map((c) => c.length));
|
|
64
|
-
for (let i = 0; i < minLength; i++) {
|
|
65
|
-
const candidate = firstChain[i];
|
|
66
|
-
if (candidate && ancestorChains.every((chain) => chain[i] === candidate)) {
|
|
67
|
-
lca = candidate;
|
|
68
|
-
} else {
|
|
69
|
-
break;
|
|
30
|
+
};
|
|
31
|
+
const walkRoots = [targetElement, ...portalElements];
|
|
32
|
+
for (const root of walkRoots) {
|
|
33
|
+
if (root.matches(SOURCE_ANNOTATED_SELECTOR)) visit(root);
|
|
34
|
+
for (const annotated of root.querySelectorAll(SOURCE_ANNOTATED_SELECTOR)) {
|
|
35
|
+
visit(annotated);
|
|
70
36
|
}
|
|
71
37
|
}
|
|
72
|
-
|
|
38
|
+
const complete = targetElement === captureRoot;
|
|
39
|
+
return {
|
|
40
|
+
complete,
|
|
41
|
+
scopeSelector: complete ? null : scopeSelector,
|
|
42
|
+
observedVersions,
|
|
43
|
+
observedSourceVersions,
|
|
44
|
+
containedAnchors: Array.from(anchorSet),
|
|
45
|
+
renderError: computeRenderError(captureRoot)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function computeRenderError(captureRoot) {
|
|
49
|
+
const errorElement = captureRoot.matches('[data-render-error="true"]') ? captureRoot : captureRoot.querySelector('[data-render-error="true"]');
|
|
50
|
+
if (!errorElement) return null;
|
|
51
|
+
return {
|
|
52
|
+
message: errorElement.getAttribute("data-render-error-message")
|
|
53
|
+
};
|
|
73
54
|
}
|
|
74
55
|
|
|
75
56
|
// ../../modules/iframe-projection/shared/capture-perf.ts
|
|
@@ -141,61 +122,6 @@ function readCaptureFlushCounters() {
|
|
|
141
122
|
return { ...counters };
|
|
142
123
|
}
|
|
143
124
|
|
|
144
|
-
// ../../modules/iframe-projection/html/declared-facts.ts
|
|
145
|
-
var SOURCE_ANNOTATED_SELECTOR = "[data-tempo-filepath]";
|
|
146
|
-
function computeDeclaredFacts(targetElement, captureRoot, scopeSelector, portalElements) {
|
|
147
|
-
const observedVersions = {};
|
|
148
|
-
const observedSourceVersions = {};
|
|
149
|
-
const anchorSet = /* @__PURE__ */ new Set();
|
|
150
|
-
const visit = (element) => {
|
|
151
|
-
const filepath = element.getAttribute("data-tempo-filepath");
|
|
152
|
-
if (filepath == null || filepath.length === 0) return;
|
|
153
|
-
const modifiedTsRaw = element.getAttribute("data-tempo-modifiedts");
|
|
154
|
-
if (modifiedTsRaw != null) {
|
|
155
|
-
const modifiedTs = Number(modifiedTsRaw);
|
|
156
|
-
if (!Number.isNaN(modifiedTs)) {
|
|
157
|
-
const existing = observedVersions[filepath];
|
|
158
|
-
if (existing === void 0 || modifiedTs > existing) {
|
|
159
|
-
observedVersions[filepath] = modifiedTs;
|
|
160
|
-
const version = element.getAttribute("data-tempo-source-version");
|
|
161
|
-
if (version != null && version.length > 0) {
|
|
162
|
-
observedSourceVersions[filepath] = version;
|
|
163
|
-
} else {
|
|
164
|
-
delete observedSourceVersions[filepath];
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
const position = element.getAttribute("data-tempo-position");
|
|
170
|
-
if (position != null && position.length > 0) {
|
|
171
|
-
anchorSet.add(`${filepath} ${position}`);
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
const walkRoots = [targetElement, ...portalElements];
|
|
175
|
-
for (const root of walkRoots) {
|
|
176
|
-
if (root.matches(SOURCE_ANNOTATED_SELECTOR)) visit(root);
|
|
177
|
-
for (const annotated of root.querySelectorAll(SOURCE_ANNOTATED_SELECTOR)) {
|
|
178
|
-
visit(annotated);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
const complete = targetElement === captureRoot;
|
|
182
|
-
return {
|
|
183
|
-
complete,
|
|
184
|
-
scopeSelector: complete ? null : scopeSelector,
|
|
185
|
-
observedVersions,
|
|
186
|
-
observedSourceVersions,
|
|
187
|
-
containedAnchors: Array.from(anchorSet),
|
|
188
|
-
renderError: computeRenderError(captureRoot)
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
function computeRenderError(captureRoot) {
|
|
192
|
-
const errorElement = captureRoot.matches('[data-render-error="true"]') ? captureRoot : captureRoot.querySelector('[data-render-error="true"]');
|
|
193
|
-
if (!errorElement) return null;
|
|
194
|
-
return {
|
|
195
|
-
message: errorElement.getAttribute("data-render-error-message")
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
|
|
199
125
|
// ../../modules/iframe-projection/html/displayability.ts
|
|
200
126
|
var IGNORED_CONTENT_TAGS = /* @__PURE__ */ new Set([
|
|
201
127
|
"DATALIST",
|
|
@@ -326,6 +252,80 @@ function elementHasVisibleComputedVisibility(element, view) {
|
|
|
326
252
|
return visibility !== "hidden" && visibility !== "collapse";
|
|
327
253
|
}
|
|
328
254
|
|
|
255
|
+
// ../../modules/iframe-projection/html/selectors.ts
|
|
256
|
+
function generateSelector(element, root) {
|
|
257
|
+
if (!root) {
|
|
258
|
+
if (element === document.documentElement) return ":root";
|
|
259
|
+
if (element === document.head) return "head";
|
|
260
|
+
if (element === document.body) return "body";
|
|
261
|
+
}
|
|
262
|
+
if (root && element === root) return "";
|
|
263
|
+
const parts = [];
|
|
264
|
+
let current = element;
|
|
265
|
+
const stopAt = root ?? document.documentElement;
|
|
266
|
+
while (current && current !== stopAt) {
|
|
267
|
+
const parent = current.parentElement;
|
|
268
|
+
if (!parent) break;
|
|
269
|
+
const tagName = current.tagName.toLowerCase();
|
|
270
|
+
let index = 1;
|
|
271
|
+
let sibling = current.previousElementSibling;
|
|
272
|
+
while (sibling) {
|
|
273
|
+
if (sibling.tagName === current.tagName) index++;
|
|
274
|
+
sibling = sibling.previousElementSibling;
|
|
275
|
+
}
|
|
276
|
+
let sameTypeSiblings = 0;
|
|
277
|
+
for (const child of parent.children) {
|
|
278
|
+
if (child.tagName === current.tagName) sameTypeSiblings++;
|
|
279
|
+
}
|
|
280
|
+
if (sameTypeSiblings > 1) {
|
|
281
|
+
parts.unshift(`${tagName}:nth-of-type(${index})`);
|
|
282
|
+
} else {
|
|
283
|
+
parts.unshift(tagName);
|
|
284
|
+
}
|
|
285
|
+
current = parent;
|
|
286
|
+
}
|
|
287
|
+
if (parts.length === 0) {
|
|
288
|
+
if (element === document.body) return "body";
|
|
289
|
+
if (element === document.head) return "head";
|
|
290
|
+
return "";
|
|
291
|
+
}
|
|
292
|
+
const path = parts.join(" > ");
|
|
293
|
+
if (root) return `:scope > ${path}`;
|
|
294
|
+
return path;
|
|
295
|
+
}
|
|
296
|
+
function findLowestCommonAncestor(nodes) {
|
|
297
|
+
if (nodes.size === 0) return null;
|
|
298
|
+
const ancestorChains = [];
|
|
299
|
+
for (const node of nodes) {
|
|
300
|
+
const chain = [];
|
|
301
|
+
let current = node instanceof Element ? node : node.parentElement;
|
|
302
|
+
while (current && current !== document) {
|
|
303
|
+
if (current instanceof Element) {
|
|
304
|
+
chain.unshift(current);
|
|
305
|
+
}
|
|
306
|
+
current = current.parentNode;
|
|
307
|
+
}
|
|
308
|
+
if (chain.length > 0) {
|
|
309
|
+
ancestorChains.push(chain);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
if (ancestorChains.length === 0) {
|
|
313
|
+
return document.documentElement;
|
|
314
|
+
}
|
|
315
|
+
let lca = document.documentElement;
|
|
316
|
+
const firstChain = ancestorChains[0];
|
|
317
|
+
const minLength = Math.min(...ancestorChains.map((c) => c.length));
|
|
318
|
+
for (let i = 0; i < minLength; i++) {
|
|
319
|
+
const candidate = firstChain[i];
|
|
320
|
+
if (candidate && ancestorChains.every((chain) => chain[i] === candidate)) {
|
|
321
|
+
lca = candidate;
|
|
322
|
+
} else {
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return lca;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
329
|
// ../../modules/iframe-projection/html/capture.ts
|
|
330
330
|
function capture(element) {
|
|
331
331
|
return captureWithSupplementalRoots(element, []);
|
|
@@ -593,4 +593,4 @@ export {
|
|
|
593
593
|
captureAttributes,
|
|
594
594
|
collectElementStates
|
|
595
595
|
};
|
|
596
|
-
//# sourceMappingURL=chunk-
|
|
596
|
+
//# sourceMappingURL=chunk-6AAE4LYV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../modules/iframe-projection/html/declared-facts.ts","../../../modules/iframe-projection/shared/capture-perf.ts","../../../modules/iframe-projection/html/displayability.ts","../../../modules/iframe-projection/html/selectors.ts","../../../modules/iframe-projection/html/capture.ts","../../../modules/iframe-projection/html/runtime-mutations.ts"],"sourcesContent":["/**\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/** Every source kind uses character offsets in the same annotation contract. */\nconst SOURCE_ANNOTATED_SELECTOR = \"[data-tempo-filepath]\";\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 const filepath = element.getAttribute(\"data-tempo-filepath\");\n if (filepath == null || filepath.length === 0) return;\n\n const modifiedTsRaw = element.getAttribute(\"data-tempo-modifiedts\");\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(\"data-tempo-source-version\");\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(\"data-tempo-position\");\n if (position != null && position.length > 0) {\n anchorSet.add(`${filepath} ${position}`);\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","/**\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","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","/** Browser-only mutation hooks shared by ordinary and isolated producers.\n * Notifications carry no values or authority: receivers read the actual DOM.\n * Private events avoid firing application input/change handlers. No polling.\n * The fixed source also installs in an isolated guest's page realm before JS.\n */\nexport const FORM_RUNTIME_MUTATION = \"tempo:form-runtime-mutation\";\nexport const CSS_RUNTIME_MUTATION = \"tempo:css-runtime-mutation\";\n\nexport const RUNTIME_MUTATION_SOURCE = String.raw`(scope => {\n const doc = scope.document;\n const undo = [];\n let active = true;\n const emit = (target, kind, detail) => {\n if (active) target.dispatchEvent(detail\n ? new scope.CustomEvent(kind, { bubbles: true, detail })\n : new scope.Event(kind, { bubbles: true }));\n };\n const form = target => {\n if (target instanceof scope.HTMLOptionElement) target = target.closest('select');\n if (target && target.isConnected) emit(target, 'tempo:form-runtime-mutation');\n };\n const css = target => {\n const sheet = target instanceof scope.CSSStyleSheet ? target : target.parentStyleSheet;\n if (target === doc || sheet && (sheet.ownerNode?.isConnected || doc.adoptedStyleSheets.includes(sheet)))\n emit(doc, 'tempo:css-runtime-mutation', { ownerNode: sheet?.ownerNode ?? null });\n };\n const setter = (proto, key, changed) => {\n if (!proto) return;\n const original = Object.getOwnPropertyDescriptor(proto, key);\n if (!original?.set || !original.configurable) return;\n const set = function(value) {\n const before = original.get?.call(this);\n original.set.call(this, value);\n if (key === 'adoptedStyleSheets' || before !== original.get?.call(this)) changed(this);\n };\n Object.defineProperty(proto, key, { ...original, set });\n undo.push(() => {\n if (Object.getOwnPropertyDescriptor(proto, key)?.set === set)\n Object.defineProperty(proto, key, original);\n });\n };\n const method = (proto, key, changed) => {\n if (!proto) return;\n const original = Object.getOwnPropertyDescriptor(proto, key);\n if (typeof original?.value !== 'function' || !original.configurable) return;\n const value = function(...args) {\n const result = original.value.apply(this, args);\n if (result instanceof scope.Promise) result.then(() => changed(this), () => {});\n else changed(this);\n return result;\n };\n Object.defineProperty(proto, key, { ...original, value });\n undo.push(() => {\n if (Object.getOwnPropertyDescriptor(proto, key)?.value === value)\n Object.defineProperty(proto, key, original);\n });\n };\n for (const [type, keys] of [\n ['HTMLInputElement', ['value', 'checked', 'valueAsNumber', 'valueAsDate']],\n ['HTMLTextAreaElement', ['value']],\n ['HTMLSelectElement', ['value', 'selectedIndex']],\n ['HTMLOptionElement', ['selected']],\n ]) for (const key of keys) setter(scope[type]?.prototype, key, form);\n for (const type of ['HTMLInputElement', 'HTMLTextAreaElement'])\n method(scope[type]?.prototype, 'setRangeText', form);\n for (const key of ['stepUp', 'stepDown']) method(scope.HTMLInputElement?.prototype, key, form);\n // CSSOM edits do not create MutationRecords, including declaration setters.\n for (const key of ['insertRule', 'deleteRule', 'addRule', 'removeRule', 'replace', 'replaceSync'])\n method(scope.CSSStyleSheet?.prototype, key, css);\n for (const key of ['insertRule', 'deleteRule']) method(scope.CSSGroupingRule?.prototype, key, css);\n const declarations = scope.CSSStyleDeclaration?.prototype;\n setter(declarations, 'cssText', target => { if (target.parentRule) css(target.parentRule); });\n for (const key of ['setProperty', 'removeProperty'])\n method(declarations, key, target => { if (target.parentRule) css(target.parentRule); });\n setter(scope.Document?.prototype, 'adoptedStyleSheets', css);\n setter(scope.StyleSheet?.prototype, 'disabled', css);\n method(scope.HTMLFormElement?.prototype, 'reset', target => {\n for (const element of target.elements) form(element);\n });\n const dispose = () => {\n if (!active) return;\n active = false;\n for (const restore of undo.reverse()) restore();\n };\n return dispose;\n})`;\n\ntype RuntimeMutationInstaller = (scope: Window) => () => void;\nlet install: RuntimeMutationInstaller | undefined;\nconst owners = new WeakMap<Document, { count: number; stop(): void }>();\n\n/** Multiple root/head watchers share one set of hooks in their browser realm. */\nexport function observeRuntimeMutations(doc: Document): () => void {\n if (!doc.defaultView) return () => {};\n let owner = owners.get(doc);\n if (!owner) {\n install ??= new Function(\n `return ${RUNTIME_MUTATION_SOURCE}`,\n )() as RuntimeMutationInstaller;\n owner = { count: 0, stop: install(doc.defaultView) };\n owners.set(doc, owner);\n }\n owner.count++;\n let released = false;\n return () => {\n if (released) return;\n released = true;\n if (--owner.count === 0) {\n owner.stop();\n owners.delete(doc);\n }\n };\n}\n"],"mappings":";AAYA,IAAM,4BAA4B;AAkB3B,SAAS,qBACd,eACA,aACA,eACA,gBACsB;AACtB,QAAM,mBAA2C,CAAC;AAClD,QAAM,yBAAiD,CAAC;AACxD,QAAM,YAAY,oBAAI,IAAY;AAElC,QAAM,QAAQ,CAAC,YAA2B;AACxC,UAAM,WAAW,QAAQ,aAAa,qBAAqB;AAC3D,QAAI,YAAY,QAAQ,SAAS,WAAW,EAAG;AAE/C,UAAM,gBAAgB,QAAQ,aAAa,uBAAuB;AAClE,QAAI,iBAAiB,MA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