tempo-sdk 0.0.93 → 0.0.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/assets/index.js +3 -3
  2. package/dist/astro/asset-preview-client.js +3 -3
  3. package/dist/astro.js +2 -2
  4. package/dist/canvas/astro.js +3 -3
  5. package/dist/canvas/index.js +36 -7
  6. package/dist/canvas/index.js.map +1 -1
  7. package/dist/canvas/interact-projection.js +4 -4
  8. package/dist/canvas/svelte.js +3 -3
  9. package/dist/canvas/vue.js +3 -3
  10. package/dist/{chunk-Y7EHQREO.js → chunk-27WT3XUG.js} +2 -2
  11. package/dist/{chunk-Y7EHQREO.js.map → chunk-27WT3XUG.js.map} +1 -1
  12. package/dist/{chunk-M7OOVEAR.js → chunk-6HYKKP5N.js} +3 -2
  13. package/dist/{chunk-M7OOVEAR.js.map → chunk-6HYKKP5N.js.map} +1 -1
  14. package/dist/{chunk-N5MWY4H6.js → chunk-CYDF4LYJ.js} +2 -2
  15. package/dist/{chunk-N5MWY4H6.js.map → chunk-CYDF4LYJ.js.map} +1 -1
  16. package/dist/{chunk-XB6GU4CE.js → chunk-I7VF4ZOV.js} +48 -37
  17. package/dist/chunk-I7VF4ZOV.js.map +1 -0
  18. package/dist/{chunk-HNNZM2XM.js → chunk-MIXQVPDH.js} +461 -185
  19. package/dist/chunk-MIXQVPDH.js.map +1 -0
  20. package/dist/{chunk-GHNHPVEI.js → chunk-SGTGDLOX.js} +2 -2
  21. package/dist/{chunk-GHNHPVEI.js.map → chunk-SGTGDLOX.js.map} +1 -1
  22. package/dist/chunk-T364NBR3.js +1440 -0
  23. package/dist/chunk-T364NBR3.js.map +1 -0
  24. package/dist/{chunk-FZVJVL3T.js → chunk-X5DJKVBT.js} +10 -17
  25. package/dist/chunk-X5DJKVBT.js.map +1 -0
  26. package/dist/{chunk-CVUNZBRV.js → chunk-ZT7HJ6YU.js} +3 -3
  27. package/dist/{chunk-3L4RRKC3.js → chunk-ZW26VZHX.js} +42 -3
  28. package/dist/chunk-ZW26VZHX.js.map +1 -0
  29. package/dist/index.js +2 -2
  30. package/dist/nextjs/plugin.cjs +1 -1
  31. package/dist/nextjs/plugin.cjs.map +1 -1
  32. package/dist/nextjs/plugin.js +1 -1
  33. package/dist/nextjs-loader.cjs +1 -1
  34. package/dist/nextjs-loader.cjs.map +1 -1
  35. package/dist/nextjs.cjs +1 -1
  36. package/dist/nextjs.cjs.map +1 -1
  37. package/dist/nextjs.js +1 -1
  38. package/dist/nuxt/runtime/identity.js +1 -1
  39. package/dist/nuxt.js +1 -1
  40. package/dist/vue.js +1 -1
  41. package/package.json +1 -1
  42. package/dist/chunk-3L4RRKC3.js.map +0 -1
  43. package/dist/chunk-FZVJVL3T.js.map +0 -1
  44. package/dist/chunk-HNNZM2XM.js.map +0 -1
  45. package/dist/chunk-LEBVQBDH.js +0 -643
  46. package/dist/chunk-LEBVQBDH.js.map +0 -1
  47. package/dist/chunk-XB6GU4CE.js.map +0 -1
  48. /package/dist/{chunk-CVUNZBRV.js.map → chunk-ZT7HJ6YU.js.map} +0 -0
@@ -1 +0,0 @@
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-runtime.js","../../../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","/** Primary browser runtime; also emitted for isolated page injection. It must\n * stay self-contained. Ordinary producers call it without dynamic evaluation. */\nexport function installRuntimeMutations(scope) {\n const doc = scope.document;\n const undo = [];\n let active = true;\n const emit = (target, kind, detail) => {\n if (active)\n target.dispatchEvent(\n detail\n ? new scope.CustomEvent(kind, { bubbles: true, detail })\n : new scope.Event(kind, { bubbles: true }),\n );\n };\n const form = (target) => {\n if (target instanceof scope.HTMLOptionElement)\n target = target.closest(\"select\");\n if (target && target.isConnected)\n emit(target, \"tempo:form-runtime-mutation\");\n };\n const css = (target, mutable = false) => {\n const sheet =\n target instanceof scope.CSSStyleSheet ? target : target.parentStyleSheet;\n if (\n target === doc ||\n (sheet &&\n (sheet.ownerNode?.isConnected ||\n doc.adoptedStyleSheets.includes(sheet)))\n )\n emit(doc, \"tempo:css-runtime-mutation\", {\n ownerNode: sheet?.ownerNode ?? null,\n sheet: sheet ?? null,\n mutable,\n });\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))\n 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)\n result.then(\n () => changed(this),\n () => {},\n );\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 ])\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\"])\n method(scope.HTMLInputElement?.prototype, key, form);\n // CSSOM edits do not create MutationRecords, including declaration setters.\n for (const key of [\n \"insertRule\",\n \"deleteRule\",\n \"addRule\",\n \"removeRule\",\n \"replace\",\n \"replaceSync\",\n ])\n method(scope.CSSStyleSheet?.prototype, key, css);\n for (const key of [\"insertRule\", \"deleteRule\"])\n method(scope.CSSGroupingRule?.prototype, key, css);\n const declarations = scope.CSSStyleDeclaration?.prototype;\n setter(declarations, \"cssText\", (target) => {\n if (target.parentRule) css(target.parentRule);\n });\n for (const key of [\"setProperty\", \"removeProperty\"])\n method(declarations, key, (target) => {\n if (target.parentRule) css(target.parentRule);\n });\n // Chromium's named declaration properties are own data properties, not\n // prototype setters. Observe exposure without proxying/changing native identity.\n // Receivers conservatively reread exposed sheets on the next head request.\n for (const proto of [\n scope.CSSStyleRule?.prototype,\n scope.CSSKeyframeRule?.prototype,\n ]) {\n const original = proto && Object.getOwnPropertyDescriptor(proto, \"style\");\n if (!original?.get || !original.configurable) continue;\n const get = function () {\n css(this, true);\n return original.get.call(this);\n };\n Object.defineProperty(proto, \"style\", { ...original, get });\n undo.push(() => {\n if (Object.getOwnPropertyDescriptor(proto, \"style\")?.get === get)\n Object.defineProperty(proto, \"style\", original);\n });\n }\n setter(scope.CSSStyleRule?.prototype, \"selectorText\", css);\n setter(scope.CSSKeyframeRule?.prototype, \"keyText\", css);\n for (const key of [\"appendRule\", \"deleteRule\"])\n method(scope.CSSKeyframesRule?.prototype, key, css);\n setter(scope.MediaList?.prototype, \"mediaText\", () => css(doc));\n for (const key of [\"appendMedium\", \"deleteMedium\"])\n method(scope.MediaList?.prototype, key, () => css(doc));\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","import { installRuntimeMutations } from \"./runtime-mutations-runtime.js\";\nexport { RUNTIME_MUTATION_SOURCE } from \"./runtime-mutations-source\";\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\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 owner = { count: 0, stop: installRuntimeMutations(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,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UAAU,WAAW,sBAAsB,GAAG;AAC3D,SAAO,MAAM,YAAY,WAAW,YAAY,GAAG;AACnD,SAAO,MAAM,iBAAiB,WAAW,SAAS,CAAC,WAAW;AAC5D,eAAW,WAAW,OAAO,SAAU,MAAK,OAAO;AAAA,EACrD,CAAC;AACD,QAAM,UAAU,MAAM;AACpB,QAAI,CAAC,OAAQ;AACb,aAAS;AACT,eAAW,WAAW,KAAK,QAAQ,EAAG,SAAQ;AAAA,EAChD;AACA,SAAO;AACT;;;ACnIO,IAAM,wBAAwB;AAC9B,IAAM,uBAAuB;AAEpC,IAAM,SAAS,oBAAI,QAAmD;AAG/D,SAAS,wBAAwB,KAA2B;AACjE,MAAI,CAAC,IAAI,YAAa,QAAO,MAAM;AAAA,EAAC;AACpC,MAAI,QAAQ,OAAO,IAAI,GAAG;AAC1B,MAAI,CAAC,OAAO;AACV,YAAQ,EAAE,OAAO,GAAG,MAAM,wBAAwB,IAAI,WAAW,EAAE;AACnE,WAAO,IAAI,KAAK,KAAK;AAAA,EACvB;AACA,QAAM;AACN,MAAI,WAAW;AACf,SAAO,MAAM;AACX,QAAI,SAAU;AACd,eAAW;AACX,QAAI,EAAE,MAAM,UAAU,GAAG;AACvB,YAAM,KAAK;AACX,aAAO,OAAO,GAAG;AAAA,IACnB;AAAA,EACF;AACF;","names":["document"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../modules/iframe-projection/html/head-text.ts","../../../modules/iframe-projection/html/head-capture-diagnostics.ts","../../../modules/iframe-projection/html/watch-head.ts"],"sourcesContent":["/** Pure stylesheet text processing shared with the source worker. */\nexport function extractStyleSourceEvidence(\n text: string,\n): Record<string, string> {\n const attributes: Record<string, string> = {};\n const clone = {\n setAttribute: (key: string, value: string) => {\n attributes[key] = value;\n },\n };\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 attributes;\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 attributes;\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 attributes;\n const serialized = JSON.stringify(metadata);\n if (serialized.length <= 64 * 1024)\n clone.setAttribute(\"data-projection-css-source-map\", serialized);\n } catch {}\n return attributes;\n}\n\nexport function absolutifyCssReferences(\n cssText: string,\n baseHref: string,\n): 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","/** Optional source-side timing. The observer owns its lifetime; no clocks or\n * retained measurements exist when that document has no observer. */\nexport interface HeadCaptureTiming {\n startedAt: number;\n clockStart: number;\n reason?: string;\n revision?: number;\n cacheHits: number;\n cacheMisses: number;\n readWallMs: number;\n workerWallMs: number;\n /** High-water mark for this document scheduler, including earlier captures. */\n maxSliceSinceDocumentStartMs?: number;\n totalMs: number;\n unaccountedMs: number;\n stages: Record<string, number>;\n sheets: Array<{\n index: number;\n kind: string;\n source?: string;\n rules: number;\n characters: number;\n stages: Record<string, number>;\n }>;\n omittedSheets: number;\n}\nconst observers = new WeakMap<Document, (value: HeadCaptureTiming) => void>();\nexport function observeHeadCaptures(\n doc: Document,\n observer: (value: HeadCaptureTiming) => void,\n): () => void {\n observers.set(doc, observer);\n return () => {\n if (observers.get(doc) === observer) observers.delete(doc);\n };\n}\nexport type HeadTiming = {\n report: HeadCaptureTiming;\n observer: (value: HeadCaptureTiming) => void;\n sheet?: HeadCaptureTiming[\"sheets\"][number];\n};\nexport function measureHead<T>(\n timing: HeadTiming | undefined,\n stage: string,\n work: () => T,\n): T {\n if (!timing) return work();\n const start = performance.now();\n try {\n return work();\n } finally {\n const elapsed = performance.now() - start;\n timing.report.stages[stage] = (timing.report.stages[stage] ?? 0) + elapsed;\n if (timing.sheet)\n timing.sheet.stages[stage] = (timing.sheet.stages[stage] ?? 0) + elapsed;\n }\n}\nexport function beginHeadCapture(doc: Document): HeadTiming | undefined {\n const observer = observers.get(doc);\n if (!observer) return;\n return {\n observer,\n report: {\n startedAt: Date.now(),\n clockStart: performance.now(),\n totalMs: 0,\n unaccountedMs: 0,\n cacheHits: 0,\n cacheMisses: 0,\n readWallMs: 0,\n workerWallMs: 0,\n stages: {},\n sheets: [],\n omittedSheets: 0,\n },\n };\n}\nexport function finishHeadCapture(doc: Document, timing: HeadTiming): void {\n if (observers.get(doc) !== timing.observer) return;\n const report = timing.report;\n report.totalMs = performance.now() - report.clockStart;\n report.unaccountedMs = Math.max(\n 0,\n report.totalMs - Object.values(report.stages).reduce((a, b) => a + b, 0),\n );\n try {\n observers.get(doc)?.(report);\n } catch {\n /* Observation cannot break capture. */\n }\n}\nexport function captureHeadTiming(\n doc: Document,\n capture: (timing?: HeadTiming) => string,\n): string {\n const timing = beginHeadCapture(doc);\n try {\n return capture(timing);\n } finally {\n if (timing) finishHeadCapture(doc, timing);\n }\n}\nexport function beginHeadSheet(\n timing: HeadTiming | undefined,\n kind: string,\n): HeadTiming | undefined {\n if (!timing) return;\n const sheet = {\n index: timing.report.sheets.length + timing.report.omittedSheets,\n kind,\n rules: 0,\n characters: 0,\n stages: {},\n };\n if (timing.report.sheets.length < 64) timing.report.sheets.push(sheet);\n else timing.report.omittedSheets++;\n return { report: timing.report, observer: timing.observer, sheet };\n}\n","import {\n extractStyleSourceEvidence,\n absolutifyCssReferences,\n} from \"./head-text\";\nimport {\n beginHeadSheet,\n captureHeadTiming,\n measureHead,\n type HeadTiming,\n} from \"./head-capture-diagnostics\";\n/**\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 /** Shared identity of the currently observed document head. */\n readonly revision: object;\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 elements?: readonly Element[];\n sheets?: readonly CSSStyleSheet[];\n allStyles?: boolean;\n mutable?: boolean;\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 private getRevision: () => object;\n\n constructor(\n doc: Document,\n callback: (details: HeadMutationDetails) => void,\n onUnsubscribe: () => void,\n getRevision: () => object,\n ) {\n this.doc = doc;\n this.callback = callback;\n this.onUnsubscribe = onUnsubscribe;\n this.getRevision = getRevision;\n }\n\n get revision(): object {\n return this.getRevision();\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 readonly revision: object;\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(\n doc,\n onMutation,\n () => {\n this.unsubscribe(doc, subscription);\n },\n () => docState!.revision,\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 let revision = {};\n\n const notify = (details: HeadMutationDetails): void => {\n revision = {};\n for (const sub of subscriptions) {\n sub.notifyMutation(details);\n }\n };\n const stopHooks = observeRuntimeMutations(doc);\n const cssChanged = (event: Event) => {\n const detail = (event as CustomEvent).detail;\n notify({\n stylesheetPaths: [],\n elements: detail?.ownerNode ? [detail.ownerNode] : [],\n sheets: detail?.sheet ? [detail.sheet] : [],\n allStyles: !detail?.sheet,\n mutable: detail?.mutable === true,\n });\n };\n const loaded = (event: Event) => {\n const target = event.target;\n if (target instanceof HTMLLinkElement && shouldIncludeLink(target))\n notify({ stylesheetPaths: [], elements: [target] });\n };\n doc.addEventListener(\"load\", loaded, true);\n doc.addEventListener(CSS_RUNTIME_MUTATION, cssChanged);\n const stopRuntime = () => {\n doc.removeEventListener(CSS_RUNTIME_MUTATION, cssChanged);\n doc.removeEventListener(\"load\", loaded, true);\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 {\n ...observeHead(doc.head),\n subscriptions,\n stopRuntime,\n get revision() {\n return revision;\n },\n };\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 get revision() {\n return revision;\n },\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 elements = new Set<Element>();\n const collectStylesheetPath = (node: Node | null): void => {\n const element =\n node instanceof Element ? node : (node?.parentElement ?? null);\n if (!element) return;\n elements.add(element);\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 const relChanged =\n mutation.type === \"attributes\" && mutation.attributeName === \"rel\";\n if (!relChanged && !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\n ? { stylesheetPaths: [...stylesheetPaths], elements: [...elements] }\n : 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, hash?: string) => string | null;\n\nfunction serializeHeadStyle(\n style: Element,\n resource?: StyleResource,\n timing?: HeadTiming,\n): string {\n const type = style.getAttribute(\"type\")?.trim().toLowerCase();\n const href =\n !type || type === \"text/css\"\n ? measureHead(timing, \"resourceHash\", () =>\n resource?.(style.textContent ?? \"\"),\n )\n : null;\n if (href) {\n return measureHead(timing, \"serializeMarkup\", () => {\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 }\n return measureHead(timing, \"serializeMarkup\", () => {\n escapeStyleForHtmlSerialization(style);\n return style.outerHTML;\n });\n}\n\nexport function captureHead(doc: Document, resource?: StyleResource): string {\n return captureHeadTiming(doc, (timing) =>\n captureHeadValue(doc, resource, timing),\n );\n}\n\nfunction captureHeadValue(\n doc: Document,\n resource?: StyleResource,\n timing?: HeadTiming,\n): 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 // and theme-color, which tints only the browser's own UI, never the page.\n // Apps rewrite theme-color freely: a Flutter app's Title writes it on\n // every build of every view, into the one document all views share. Kept\n // in the head, views with different colors flipped the head back and\n // forth with no pixel changed, and every flip was a new head revision.\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 name === \"theme-color\"\n ) {\n continue;\n }\n }\n\n const sheetTiming =\n tagName === \"STYLE\" || tagName === \"LINK\"\n ? beginHeadSheet(timing, tagName)\n : timing;\n if (sheetTiming?.sheet) {\n sheetTiming.sheet.source = (\n child.getAttribute(\"data-vite-dev-id\") ??\n child.getAttribute(\"href\") ??\n child.id\n )\n .split(/[?#]/)[0]\n .slice(0, 512);\n }\n // Clone and resolve URLs\n let clone = measureHead(\n sheetTiming,\n \"cloneNodes\",\n () => child.cloneNode(true) as Element,\n );\n materializeStyleElementCssom(child, clone, sheetTiming);\n if (tagName === \"LINK\") {\n clone = materializeStylesheetLinkCssom(child, clone, sheetTiming);\n }\n measureHead(sheetTiming, \"resolveUrls\", () => 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 measureHead(sheetTiming, \"resolveUrls\", () => {\n clone.textContent = absolutifyCssReferences(\n clone.textContent ?? \"\",\n baseURI,\n );\n });\n fragments.push(serializeHeadStyle(clone, resource, sheetTiming));\n continue;\n }\n\n fragments.push(\n measureHead(sheetTiming, \"serializeMarkup\", () => clone.outerHTML),\n );\n }\n\n fragments.push(...captureAdoptedStyleSheets(doc, resource, timing));\n\n return measureHead(timing, \"joinMarkup\", () => 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 timing?: HeadTiming,\n): Element {\n const link = source as HTMLLinkElement;\n const cssText = serializeCssRules(link.sheet, timing);\n if (cssText === null) {\n return clone;\n }\n\n const resolvedCss = measureHead(timing, \"resolveUrls\", () =>\n absolutifyCssReferences(cssText, link.href),\n );\n return measureHead(timing, \"materializeNodes\", () => {\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 = resolvedCss;\n return style;\n });\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 for (const [key, value] of Object.entries(extractStyleSourceEvidence(text)))\n clone.setAttribute(key, value);\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(\n source: Element,\n clone: Element,\n timing?: HeadTiming,\n): void {\n if (source.tagName !== \"STYLE\" || clone.tagName !== \"STYLE\") {\n return;\n }\n\n const style = source as HTMLStyleElement;\n measureHead(timing, \"sourceMetadata\", () =>\n retainStyleSourceEvidence(style, clone),\n );\n const cssText = serializeCssRules(style.sheet, timing);\n if (cssText !== null) {\n measureHead(timing, \"materializeNodes\", () => {\n clone.textContent = cssText;\n });\n }\n}\n\nfunction captureAdoptedStyleSheets(\n doc: Document,\n resource?: StyleResource,\n timing?: HeadTiming,\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 sheetTiming = beginHeadSheet(timing, \"adopted\");\n const cssText = serializeCssRules(sheet, sheetTiming);\n if (!cssText) {\n continue;\n }\n const style = measureHead(sheetTiming, \"materializeNodes\", () => {\n const node = doc.createElement(\"style\");\n node.setAttribute(\"data-projection-adopted-stylesheet\", \"true\");\n return node;\n });\n measureHead(sheetTiming, \"resolveUrls\", () => {\n style.textContent = absolutifyCssReferences(cssText, doc.baseURI);\n });\n fragments.push(serializeHeadStyle(style, resource, sheetTiming));\n }\n return fragments;\n}\n\nfunction escapeStyleForHtmlSerialization(style: Element): void {\n style.textContent = (style.textContent ?? \"\").replace(/<\\//gi, \"<\\\\/\");\n}\n\nfunction serializeCssRules(\n sheet: CSSStyleSheet | null,\n timing?: HeadTiming,\n): string | null {\n if (!sheet) {\n return null;\n }\n\n try {\n return measureHead(timing, \"readCssRules\", () => {\n const rules = Array.from(sheet.cssRules);\n const text = rules.map((rule) => rule.cssText).join(\"\\n\");\n if (timing?.sheet) {\n timing.sheet.rules = rules.length;\n timing.sheet.characters = text.length;\n }\n return text;\n });\n } catch {\n // Cross-origin or otherwise unreadable stylesheet.\n return null;\n }\n}\n\nexport function 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\nexport function 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 */\nexport function 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":";;;;;;AACO,SAAS,2BACd,MACwB;AACxB,QAAM,aAAqC,CAAC;AAC5C,QAAM,QAAQ;AAAA,IACZ,cAAc,CAAC,KAAa,UAAkB;AAC5C,iBAAW,GAAG,IAAI;AAAA,IACpB;AAAA,EACF;AACA,QAAM,YAAY;AAAA,IAChB,GAAG,KAAK,SAAS,kDAAkD;AAAA,EACrE,EAAE,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC;AAClB,MAAI,CAAC,aAAa,UAAU,SAAS,OAAO,KAAM,QAAO;AACzD,QAAM,SACJ,gEAAgE;AAAA,IAC9D;AAAA,EACF;AACF,MAAI,CAAC,QAAQ;AAGX,QAAI;AACF,YAAM,MAAM,IAAI,IAAI,SAA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