tempo-sdk 0.0.92 → 0.0.94

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 (47) 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 +157 -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-FENUT2N2.js → chunk-3W6B75UK.js} +2 -2
  11. package/dist/{chunk-FENUT2N2.js.map → chunk-3W6B75UK.js.map} +1 -1
  12. package/dist/{chunk-3XEEVCM3.js → chunk-6QGMLNO3.js} +137 -69
  13. package/dist/chunk-6QGMLNO3.js.map +1 -0
  14. package/dist/{chunk-DNERBE7A.js → chunk-KY52JZZL.js} +17 -11
  15. package/dist/chunk-KY52JZZL.js.map +1 -0
  16. package/dist/{chunk-NXPP3CSM.js → chunk-LEW24RRZ.js} +2 -2
  17. package/dist/{chunk-TWW2DL7E.js → chunk-OYNR6D7K.js} +2 -2
  18. package/dist/{chunk-TWW2DL7E.js.map → chunk-OYNR6D7K.js.map} +1 -1
  19. package/dist/{chunk-RZ3TG6MV.js → chunk-REYOX4JT.js} +2 -2
  20. package/dist/{chunk-RZ3TG6MV.js.map → chunk-REYOX4JT.js.map} +1 -1
  21. package/dist/chunk-T364NBR3.js +1440 -0
  22. package/dist/chunk-T364NBR3.js.map +1 -0
  23. package/dist/{chunk-KQSOE4KZ.js → chunk-VRNJI4Y6.js} +2 -2
  24. package/dist/{chunk-I5MJ342V.js → chunk-WRILG6GR.js} +3 -3
  25. package/dist/{chunk-XN2K7GED.js → chunk-YHGUAOBM.js} +45 -19
  26. package/dist/chunk-YHGUAOBM.js.map +1 -0
  27. package/dist/index.js +2 -2
  28. package/dist/nextjs/plugin.cjs +1 -1
  29. package/dist/nextjs/plugin.cjs.map +1 -1
  30. package/dist/nextjs/plugin.js +1 -1
  31. package/dist/nextjs-loader.cjs +1 -1
  32. package/dist/nextjs-loader.cjs.map +1 -1
  33. package/dist/nextjs.cjs +1 -1
  34. package/dist/nextjs.cjs.map +1 -1
  35. package/dist/nextjs.js +1 -1
  36. package/dist/nuxt/runtime/identity.js +1 -1
  37. package/dist/nuxt.js +1 -1
  38. package/dist/vue.js +1 -1
  39. package/package.json +1 -1
  40. package/dist/chunk-3XEEVCM3.js.map +0 -1
  41. package/dist/chunk-5M45Z7K6.js +0 -611
  42. package/dist/chunk-5M45Z7K6.js.map +0 -1
  43. package/dist/chunk-DNERBE7A.js.map +0 -1
  44. package/dist/chunk-XN2K7GED.js.map +0 -1
  45. /package/dist/{chunk-NXPP3CSM.js.map → chunk-LEW24RRZ.js.map} +0 -0
  46. /package/dist/{chunk-KQSOE4KZ.js.map → chunk-VRNJI4Y6.js.map} +0 -0
  47. /package/dist/{chunk-I5MJ342V.js.map → chunk-WRILG6GR.js.map} +0 -0
@@ -3,15 +3,17 @@ import {
3
3
  readTempoVueInvocationMarker
4
4
  } from "./chunk-SGN7BDRE.js";
5
5
  import {
6
+ absolutifyCssReferences,
6
7
  beginHeadCapture,
7
8
  beginHeadSheet,
8
9
  captureHead,
10
+ extractStyleSourceEvidence,
9
11
  finishHeadCapture,
10
12
  getHeadTracker,
11
13
  isDisabledStylesheet,
12
14
  resolveUrls,
13
15
  shouldIncludeLink
14
- } from "./chunk-XN2K7GED.js";
16
+ } from "./chunk-YHGUAOBM.js";
15
17
  import {
16
18
  isTempoInteractFrameName
17
19
  } from "./chunk-65B52AR7.js";
@@ -81,21 +83,23 @@ import {
81
83
  watchDom,
82
84
  watchPortal,
83
85
  watchState
84
- } from "./chunk-DNERBE7A.js";
86
+ } from "./chunk-KY52JZZL.js";
85
87
  import {
86
88
  captureAttributes,
87
89
  captureWithSupplementalRoots,
88
90
  collectElementStates,
89
91
  countCaptureStyleRead,
90
92
  countIdentityNodeVisited,
93
+ cssSourcesFor,
91
94
  findLowestCommonAncestor,
95
+ observeCssInputs,
92
96
  readCaptureFlushCounters,
93
97
  readCaptureProducerCardinality,
94
98
  registerCaptureRootObserver,
95
99
  registerDocumentCaptureProducer,
96
100
  removeScriptTags,
97
101
  resetCaptureFlushCounters
98
- } from "./chunk-5M45Z7K6.js";
102
+ } from "./chunk-T364NBR3.js";
99
103
 
100
104
  // ../../modules/iframe-projection/combined/projection-repair-paths.ts
101
105
  function isProjectionRepairPaths(value) {
@@ -505,8 +509,40 @@ function createWorkScheduler(options = {}) {
505
509
  return scheduler;
506
510
  }
507
511
 
512
+ // ../../modules/iframe-projection/html/head-text-process.ts
513
+ async function processHeadText(input) {
514
+ const stages = {};
515
+ const measure = (name, work) => {
516
+ if (!input.measure) return work();
517
+ const start2 = performance.now();
518
+ const value = work();
519
+ stages[name] = performance.now() - start2;
520
+ return value;
521
+ };
522
+ const metadata = input.metadata ?? measure(
523
+ "sourceMetadata",
524
+ () => extractStyleSourceEvidence(input.authored ?? "")
525
+ );
526
+ const rawCss = measure("joinRules", () => input.rules.join("\n"));
527
+ const css = measure(
528
+ "resolveUrls",
529
+ () => absolutifyCssReferences(rawCss, input.base)
530
+ );
531
+ const start = input.measure ? performance.now() : 0;
532
+ const digest = await crypto.subtle.digest(
533
+ "SHA-256",
534
+ new TextEncoder().encode(css)
535
+ );
536
+ const hash = Array.from(
537
+ new Uint8Array(digest),
538
+ (byte) => byte.toString(16).padStart(2, "0")
539
+ ).join("");
540
+ if (input.measure) stages.resourceHash = performance.now() - start;
541
+ return { css, hash, metadata, stages };
542
+ }
543
+
508
544
  // ../../modules/iframe-projection/html/head-worker-source.ts
509
- var HEAD_WORKER_SOURCE = '(function() {\n "use strict";\n function extractStyleSourceEvidence(text) {\n const attributes = {};\n const clone = {\n setAttribute: (key, value) => {\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 = /^data:application\\/json(?:;charset=[\\w-]+)?(;base64)?,(.*)$/is.exec(\n reference\n );\n if (!inline) {\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 }\n return attributes;\n }\n function compact(raw, depth) {\n if (!raw || typeof raw !== "object" || depth > 16) return null;\n const map = raw;\n if (map.version !== 3) return null;\n const sources = Array.isArray(map.sources) && map.sources.length <= 4096 && map.sources.every((source) => typeof source === "string") ? map.sources : void 0;\n const sections = Array.isArray(map.sections) && map.sections.length <= 256 ? map.sections.flatMap((section) => {\n const nested = section && typeof section === "object" ? compact(section.map, depth + 1) : null;\n return nested ? [{ map: nested }] : [];\n }) : void 0;\n return {\n version: 3,\n ...typeof map.file === "string" ? { file: map.file } : {},\n ...typeof map.sourceRoot === "string" ? { sourceRoot: map.sourceRoot } : {},\n ...sources ? { sources } : {},\n ...sections ? { sections } : {}\n };\n }\n try {\n const json = inline[1] ? new TextDecoder().decode(\n Uint8Array.from(\n atob(inline[2]),\n (character) => character.charCodeAt(0)\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 }\n return attributes;\n }\n function absolutifyCssReferences(cssText, baseHref) {\n const resolve = (value) => {\n const trimmed = value.trim();\n if (!trimmed || trimmed.startsWith("#") || /^(?:data|blob|javascript):/i.test(trimmed)) {\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 return cssText.replace(\n /url\\(\\s*(["\']?)([^"\')]+)\\1\\s*\\)/gi,\n (_match, quote, value) => `url(${quote}${resolve(value)}${quote})`\n ).replace(\n /@import\\s+(["\'])([^"\']+)\\1/gi,\n (_match, quote, value) => `@import ${quote}${resolve(value)}${quote}`\n );\n }\n const scope = globalThis;\n scope.onmessage = async ({ data }) => {\n const stages = {};\n const measure = (name, work) => {\n if (!data.measure) return work();\n const start = performance.now();\n const value = work();\n stages[name] = performance.now() - start;\n return value;\n };\n try {\n const metadata = data.metadata ?? measure(\n "sourceMetadata",\n () => extractStyleSourceEvidence(data.authored ?? "")\n );\n const rawCss = measure("joinRules", () => data.rules.join("\\n"));\n const css = measure(\n "resolveUrls",\n () => absolutifyCssReferences(rawCss, data.base)\n );\n const start = data.measure ? performance.now() : 0;\n const digest = await crypto.subtle.digest(\n "SHA-256",\n new TextEncoder().encode(css)\n );\n const hash = Array.from(\n new Uint8Array(digest),\n (byte) => byte.toString(16).padStart(2, "0")\n ).join("");\n if (data.measure) stages.resourceHash = performance.now() - start;\n scope.postMessage({\n id: data.id,\n result: { css, hash, metadata, stages }\n });\n } catch (error) {\n scope.postMessage({ id: data.id, error: String(error) });\n }\n };\n})();\n';
545
+ var HEAD_WORKER_SOURCE = '(function() {\n "use strict";\n function extractStyleSourceEvidence(text) {\n const attributes = {};\n const clone = {\n setAttribute: (key, value) => {\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 = /^data:application\\/json(?:;charset=[\\w-]+)?(;base64)?,(.*)$/is.exec(\n reference\n );\n if (!inline) {\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 }\n return attributes;\n }\n function compact(raw, depth) {\n if (!raw || typeof raw !== "object" || depth > 16) return null;\n const map = raw;\n if (map.version !== 3) return null;\n const sources = Array.isArray(map.sources) && map.sources.length <= 4096 && map.sources.every((source) => typeof source === "string") ? map.sources : void 0;\n const sections = Array.isArray(map.sections) && map.sections.length <= 256 ? map.sections.flatMap((section) => {\n const nested = section && typeof section === "object" ? compact(section.map, depth + 1) : null;\n return nested ? [{ map: nested }] : [];\n }) : void 0;\n return {\n version: 3,\n ...typeof map.file === "string" ? { file: map.file } : {},\n ...typeof map.sourceRoot === "string" ? { sourceRoot: map.sourceRoot } : {},\n ...sources ? { sources } : {},\n ...sections ? { sections } : {}\n };\n }\n try {\n const json = inline[1] ? new TextDecoder().decode(\n Uint8Array.from(\n atob(inline[2]),\n (character) => character.charCodeAt(0)\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 }\n return attributes;\n }\n function absolutifyCssReferences(cssText, baseHref) {\n const resolve = (value) => {\n const trimmed = value.trim();\n if (!trimmed || trimmed.startsWith("#") || /^(?:data|blob|javascript):/i.test(trimmed)) {\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 return cssText.replace(\n /url\\(\\s*(["\']?)([^"\')]+)\\1\\s*\\)/gi,\n (_match, quote, value) => `url(${quote}${resolve(value)}${quote})`\n ).replace(\n /@import\\s+(["\'])([^"\']+)\\1/gi,\n (_match, quote, value) => `@import ${quote}${resolve(value)}${quote}`\n );\n }\n async function processHeadText(input) {\n const stages = {};\n const measure = (name, work) => {\n if (!input.measure) return work();\n const start2 = performance.now();\n const value = work();\n stages[name] = performance.now() - start2;\n return value;\n };\n const metadata = input.metadata ?? measure(\n "sourceMetadata",\n () => extractStyleSourceEvidence(input.authored ?? "")\n );\n const rawCss = measure("joinRules", () => input.rules.join("\\n"));\n const css = measure(\n "resolveUrls",\n () => absolutifyCssReferences(rawCss, input.base)\n );\n const start = input.measure ? performance.now() : 0;\n const digest = await crypto.subtle.digest(\n "SHA-256",\n new TextEncoder().encode(css)\n );\n const hash = Array.from(\n new Uint8Array(digest),\n (byte) => byte.toString(16).padStart(2, "0")\n ).join("");\n if (input.measure) stages.resourceHash = performance.now() - start;\n return { css, hash, metadata, stages };\n }\n const scope = globalThis;\n scope.onmessage = async ({ data }) => {\n try {\n scope.postMessage({ id: data.id, result: await processHeadText(data) });\n } catch (error) {\n scope.postMessage({ id: data.id, error: String(error) });\n }\n };\n})();\n';
510
546
 
511
547
  // ../../modules/iframe-projection/html/head-worker.ts
512
548
  var WORKER_TIMEOUT_MS = 3e4;
@@ -515,6 +551,8 @@ function createHeadWorker() {
515
551
  let url;
516
552
  let sequence = 0;
517
553
  const pending = /* @__PURE__ */ new Map();
554
+ let refused = false;
555
+ const runInline = (input) => processHeadText(input);
518
556
  const dispose = (error = new Error("Head worker stopped")) => {
519
557
  if (worker) {
520
558
  worker.onmessage = null;
@@ -531,17 +569,29 @@ function createHeadWorker() {
531
569
  }
532
570
  pending.clear();
533
571
  };
572
+ const fallBack = () => {
573
+ refused = true;
574
+ const owed = [...pending.values()];
575
+ pending.clear();
576
+ for (const job of owed) {
577
+ clearTimeout(job.timer);
578
+ void runInline(job.input).then(job.resolve, job.reject);
579
+ }
580
+ dispose();
581
+ };
534
582
  return {
535
583
  process(input) {
584
+ if (refused) return runInline(input);
536
585
  if (!worker) {
537
- url = URL.createObjectURL(
538
- new Blob([HEAD_WORKER_SOURCE], { type: "text/javascript" })
539
- );
540
586
  try {
587
+ url = URL.createObjectURL(
588
+ new Blob([HEAD_WORKER_SOURCE], { type: "text/javascript" })
589
+ );
541
590
  worker = new Worker(url);
542
- } catch (error) {
591
+ } catch {
592
+ refused = true;
543
593
  dispose();
544
- return Promise.reject(error);
594
+ return runInline(input);
545
595
  }
546
596
  worker.onmessage = ({ data }) => {
547
597
  const job = pending.get(data.id);
@@ -551,15 +601,18 @@ function createHeadWorker() {
551
601
  if (data.error) job.reject(new Error(data.error));
552
602
  else job.resolve(data.result);
553
603
  };
554
- worker.onerror = () => dispose();
555
- worker.onmessageerror = () => dispose();
604
+ worker.onerror = (event) => {
605
+ event?.preventDefault?.();
606
+ fallBack();
607
+ };
608
+ worker.onmessageerror = fallBack;
556
609
  }
557
610
  return new Promise((resolve, reject) => {
558
611
  const id = ++sequence;
559
612
  const timer = setTimeout(() => {
560
613
  dispose(new Error("Head worker timed out after 30000ms"));
561
614
  }, WORKER_TIMEOUT_MS);
562
- pending.set(id, { resolve, reject, timer });
615
+ pending.set(id, { resolve, reject, timer, input });
563
616
  try {
564
617
  worker.postMessage({ ...input, id });
565
618
  } catch (error) {
@@ -599,6 +652,7 @@ function createPreparedHead(doc, clock) {
599
652
  function buildPreparedHead(doc, clock) {
600
653
  const work = createWorkScheduler({ clock });
601
654
  const worker = createHeadWorker();
655
+ const cssSources = cssSourcesFor(doc);
602
656
  const abort = new AbortController();
603
657
  const cache = /* @__PURE__ */ new Map();
604
658
  const versions = /* @__PURE__ */ new Map();
@@ -684,7 +738,8 @@ function buildPreparedHead(doc, clock) {
684
738
  for (let offset = 0; offset < list.length; ) {
685
739
  const start = timing ? performance.now() : 0;
686
740
  const end = Math.min(offset + 32, list.length);
687
- for (; offset < end; offset++) rules.push(list[offset].cssText);
741
+ for (; offset < end; offset++)
742
+ rules.push(cssSources.ruleText(list[offset]));
688
743
  if (timing) {
689
744
  const elapsed = performance.now() - start;
690
745
  timing.report.stages.readCssRules = (timing.report.stages.readCssRules ?? 0) + elapsed;
@@ -705,13 +760,14 @@ function buildPreparedHead(doc, clock) {
705
760
  ...Array.from(doc.head?.children ?? []).filter((node) => {
706
761
  if (node.tagName === "LINK")
707
762
  return shouldIncludeLink(node) && !isDisabledStylesheet(node);
763
+ if (node.tagName === "STYLE") return !isDisabledStylesheet(node);
708
764
  if (node.tagName === "META") {
709
765
  const name = node.getAttribute("name")?.toLowerCase();
710
766
  return node.getAttribute("http-equiv")?.toLowerCase() !== "content-security-policy" && name !== "content-security-policy" && name !== "theme-color";
711
767
  }
712
- return node.tagName === "STYLE" || node.tagName === "BASE";
768
+ return node.tagName === "BASE";
713
769
  }),
714
- ...adopted
770
+ ...adopted.filter((sheet) => !sheet.disabled)
715
771
  ];
716
772
  const next = [];
717
773
  for (const source of sources) {
@@ -1022,6 +1078,10 @@ function buildProjectionCapturePerf(input) {
1022
1078
 
1023
1079
  // ../../modules/iframe-projection/html/root-coordinates.ts
1024
1080
  var ROOT_COORDINATES_ATTRIBUTE = "data-projection-root-coordinates";
1081
+ function changesFixedCoordinates(css) {
1082
+ const active = (value) => Boolean(value && value !== "none");
1083
+ return active(css.transform) || active(css.translate) || active(css.rotate) || active(css.scale) || active(css.perspective) || active(css.filter) || active(css.backdropFilter) || /layout|paint|strict|content/.test(css.contain) || /transform|perspective|filter/.test(css.willChange);
1084
+ }
1025
1085
  function captureRootCoordinates(root, portals = []) {
1026
1086
  const doc = root.ownerDocument, view = doc.defaultView;
1027
1087
  if (!view || root === doc.body || root === doc.documentElement) return;
@@ -1034,12 +1094,9 @@ function captureRootCoordinates(root, portals = []) {
1034
1094
  }
1035
1095
  const rect = root.getBoundingClientRect();
1036
1096
  if (!rect.width || !rect.height) return;
1037
- const containingBlock = [doc.body, doc.documentElement].find((element) => {
1038
- if (!element) return false;
1039
- const css = view.getComputedStyle(element);
1040
- const active = (value) => Boolean(value && value !== "none");
1041
- return active(css.transform) || active(css.translate) || active(css.rotate) || active(css.scale) || active(css.perspective) || active(css.filter) || active(css.backdropFilter) || /layout|paint|strict|content/.test(css.contain) || /transform|perspective|filter/.test(css.willChange);
1042
- });
1097
+ const containingBlock = [doc.body, doc.documentElement].find(
1098
+ (element) => element && changesFixedCoordinates(view.getComputedStyle(element))
1099
+ );
1043
1100
  let layout;
1044
1101
  if (containingBlock) {
1045
1102
  let element = root, left = 0, top = 0;
@@ -1107,14 +1164,17 @@ function captureProjectionFullSnapshot(options) {
1107
1164
  hostDomIdCount
1108
1165
  };
1109
1166
  }
1110
- function captureFullDom(root, portals, observedFiles) {
1167
+ function captureFullDom(root, portals, observedFiles, identity = {
1168
+ readId: (element) => ensureProjectionDomId(element),
1169
+ syncClone: syncProjectionDomIdsToClone
1170
+ }) {
1111
1171
  for (const scope of [root, ...portals]) {
1112
1172
  for (const element of projectedElements(scope)) {
1113
- ensureProjectionDomId(element);
1173
+ identity.readId(element);
1114
1174
  }
1115
1175
  }
1116
1176
  const clone = cloneProjectionDom(root);
1117
- syncProjectionDomIdsToClone(root, clone);
1177
+ identity.syncClone(root, clone);
1118
1178
  for (const script of clone.querySelectorAll("script")) script.remove();
1119
1179
  const hostDomIds = stripSourceAnnotations(clone, observedFiles, false);
1120
1180
  const portalPatches = [];
@@ -1123,7 +1183,7 @@ function captureFullDom(root, portals, observedFiles) {
1123
1183
  const portalId = portal.getAttribute(PORTAL_ID_ATTR);
1124
1184
  if (!portalId) continue;
1125
1185
  const portalClone = cloneProjectionDom(portal);
1126
- syncProjectionDomIdsToClone(portal, portalClone);
1186
+ identity.syncClone(portal, portalClone);
1127
1187
  for (const script of portalClone.querySelectorAll("script"))
1128
1188
  script.remove();
1129
1189
  for (const domId of stripSourceAnnotations(
@@ -1142,7 +1202,7 @@ function captureFullDom(root, portals, observedFiles) {
1142
1202
  });
1143
1203
  }
1144
1204
  const body = root.ownerDocument.body;
1145
- const rootDomId = ensureProjectionDomId(root);
1205
+ const rootDomId = identity.readId(root);
1146
1206
  const coordinates = captureRootCoordinates(root, portals);
1147
1207
  const dom = {
1148
1208
  ...coordinates ? { coordinates } : {},
@@ -1154,18 +1214,18 @@ function captureFullDom(root, portals, observedFiles) {
1154
1214
  },
1155
1215
  ...body ? { bodyAttributes: captureAttributes(body) } : {},
1156
1216
  baseUrl: root.ownerDocument.baseURI,
1157
- state: collectFullRuntimeState(root, portals),
1217
+ state: collectFullRuntimeState(root, portals, identity.readId),
1158
1218
  portals: portalPatches
1159
1219
  };
1160
1220
  return { dom, hostDomIdCount: hostDomIds.size };
1161
1221
  }
1162
- function collectFullRuntimeState(root, portals) {
1222
+ function collectFullRuntimeState(root, portals, readId = (element) => ensureProjectionDomId(element)) {
1163
1223
  const states = [];
1164
1224
  for (const scope of [root, ...portals]) {
1165
1225
  for (const element of projectedElements(scope)) {
1166
1226
  if (element !== scope && element.hasAttribute(PROJECTION_ROOT_ATTRIBUTE))
1167
1227
  continue;
1168
- const targetId = ensureProjectionDomId(element);
1228
+ const targetId = readId(element);
1169
1229
  if (!targetId) continue;
1170
1230
  if (element.scrollTop !== 0 || element.scrollLeft !== 0) {
1171
1231
  states.push({
@@ -1175,25 +1235,27 @@ function collectFullRuntimeState(root, portals) {
1175
1235
  scrollLeft: element.scrollLeft
1176
1236
  });
1177
1237
  }
1178
- if (element instanceof HTMLInputElement) {
1179
- if (element.type === "checkbox" || element.type === "radio") {
1180
- if (element.checked !== element.defaultChecked) {
1238
+ if (element.namespaceURI !== "http://www.w3.org/1999/xhtml") continue;
1239
+ if (element.localName === "input") {
1240
+ const input = element;
1241
+ if (input.type === "checkbox" || input.type === "radio") {
1242
+ if (input.checked !== input.defaultChecked) {
1181
1243
  states.push({
1182
1244
  targetId,
1183
1245
  kind: "checked",
1184
- checked: element.checked
1246
+ checked: input.checked
1185
1247
  });
1186
1248
  }
1187
- } else if (element.value !== element.defaultValue) {
1249
+ } else if (input.value !== input.defaultValue) {
1188
1250
  states.push({
1189
1251
  targetId,
1190
1252
  kind: "value",
1191
- value: element.value,
1192
- selectionStart: element.selectionStart,
1193
- selectionEnd: element.selectionEnd
1253
+ value: input.value,
1254
+ selectionStart: input.selectionStart,
1255
+ selectionEnd: input.selectionEnd
1194
1256
  });
1195
1257
  }
1196
- } else if (element instanceof HTMLTextAreaElement && element.value !== element.defaultValue) {
1258
+ } else if (element.localName === "textarea" && element.value !== element.defaultValue) {
1197
1259
  states.push({
1198
1260
  targetId,
1199
1261
  kind: "value",
@@ -1201,11 +1263,12 @@ function collectFullRuntimeState(root, portals) {
1201
1263
  selectionStart: element.selectionStart,
1202
1264
  selectionEnd: element.selectionEnd
1203
1265
  });
1204
- } else if (element instanceof HTMLSelectElement) {
1266
+ } else if (element.localName === "select") {
1267
+ const select = element;
1205
1268
  const selectedIndices = [];
1206
1269
  let changed = false;
1207
- for (let optionIndex = 0; optionIndex < element.options.length; optionIndex += 1) {
1208
- const option = element.options[optionIndex];
1270
+ for (let optionIndex = 0; optionIndex < select.options.length; optionIndex += 1) {
1271
+ const option = select.options[optionIndex];
1209
1272
  if (!option) continue;
1210
1273
  if (option.selected) selectedIndices.push(optionIndex);
1211
1274
  if (option.selected !== option.defaultSelected) changed = true;
@@ -4087,14 +4150,23 @@ function getPortalTracker() {
4087
4150
  }
4088
4151
  return instance;
4089
4152
  }
4153
+ function fiberHostElement(fiber) {
4154
+ const state = fiber.stateNode;
4155
+ if (state instanceof Element) return state;
4156
+ if (fiber.tag === FiberTag.HostPortal && state && "containerInfo" in state && state.containerInfo instanceof Element)
4157
+ return state.containerInfo;
4158
+ return null;
4159
+ }
4090
4160
  function isElementOwnedByRoot(candidate, root) {
4091
4161
  const fiber = getFiberFromElement(candidate);
4092
4162
  if (!fiber) return false;
4093
4163
  let current = fiber.return;
4094
4164
  while (current) {
4095
- if (current.stateNode instanceof Element && (current.stateNode === root || root.contains(current.stateNode))) {
4165
+ const host = fiberHostElement(current);
4166
+ if (host && (host === root || root.contains(host) && !underForeignProjectionRoot(host, root))) {
4096
4167
  return true;
4097
4168
  }
4169
+ if (host?.hasAttribute(PROJECTION_ROOT_ATTRIBUTE)) break;
4098
4170
  current = current.return;
4099
4171
  }
4100
4172
  return false;
@@ -4268,8 +4340,8 @@ var PortalTrackerImpl = class {
4268
4340
  if (!fiber) return matched;
4269
4341
  let current = fiber.return;
4270
4342
  while (current && matched.size < watchers.length) {
4271
- const host = current.stateNode;
4272
- if (host instanceof Element) {
4343
+ const host = fiberHostElement(current);
4344
+ if (host) {
4273
4345
  for (const watcher of watchers) {
4274
4346
  if (!matched.has(watcher) && (host === watcher.element || watcher.element.contains(host) && !underForeignProjectionRoot(host, watcher.element))) {
4275
4347
  matched.add(watcher);
@@ -6744,7 +6816,7 @@ var combinedWatchers = /* @__PURE__ */ new Map();
6744
6816
  var nextCombinedWatcherId = 1;
6745
6817
  var combinedSourceInitialized = false;
6746
6818
  var combinedSourceCleanup = null;
6747
- function installWhenDocumentBodyReady(install2) {
6819
+ function installWhenDocumentBodyReady(install) {
6748
6820
  let cancelled = false;
6749
6821
  let installedCleanup = null;
6750
6822
  let animationFrameId = null;
@@ -6754,7 +6826,7 @@ function installWhenDocumentBodyReady(install2) {
6754
6826
  animationFrameId = null;
6755
6827
  if (cancelled) return;
6756
6828
  if (document.body) {
6757
- installedCleanup = install2();
6829
+ installedCleanup = install();
6758
6830
  return;
6759
6831
  }
6760
6832
  animationFrameId = requestAnimationFrame(init);
@@ -8180,37 +8252,31 @@ function serveCanvasFrameLanes(subscribePorts, options) {
8180
8252
  };
8181
8253
  }
8182
8254
 
8183
- // ../../modules/iframe-projection/canvas-frames/preserve-drawing-buffer.ts
8184
- var PRESERVE_DRAWING_BUFFER_SOURCE = String.raw`(scope => {
8185
- const WEBGL_CONTEXT_IDS = new Set(["webgl", "webgl2", "experimental-webgl"]);
8255
+ // ../../modules/iframe-projection/canvas-frames/preserve-drawing-buffer-runtime.js
8256
+ function installPreserveDrawingBufferRuntime(scope) {
8257
+ const WEBGL_CONTEXT_IDS = /* @__PURE__ */ new Set(["webgl", "webgl2", "experimental-webgl"]);
8186
8258
  const prototype = scope.HTMLCanvasElement?.prototype;
8187
- if (!prototype) return () => {};
8259
+ if (!prototype) return () => {
8260
+ };
8188
8261
  const original = prototype.getContext;
8189
- if (typeof original !== "function") return () => {};
8190
- // Forward every argument unchanged except WebGL's preservation attribute.
8191
- const patched = function (contextId, attributes, ...rest) {
8192
- const forced = WEBGL_CONTEXT_IDS.has(contextId)
8193
- ? {
8194
- ...(typeof attributes === "object" && attributes !== null
8195
- ? attributes
8196
- : {}),
8197
- preserveDrawingBuffer: true,
8198
- }
8199
- : attributes;
8262
+ if (typeof original !== "function") return () => {
8263
+ };
8264
+ const patched = function(contextId, attributes, ...rest) {
8265
+ const forced = WEBGL_CONTEXT_IDS.has(contextId) ? {
8266
+ ...typeof attributes === "object" && attributes !== null ? attributes : {},
8267
+ preserveDrawingBuffer: true
8268
+ } : attributes;
8200
8269
  return original.call(this, contextId, forced, ...rest);
8201
8270
  };
8202
8271
  prototype.getContext = patched;
8203
-
8204
8272
  return () => {
8205
8273
  if (prototype.getContext === patched) prototype.getContext = original;
8206
8274
  };
8207
- })`;
8208
- var install;
8275
+ }
8276
+
8277
+ // ../../modules/iframe-projection/canvas-frames/preserve-drawing-buffer.ts
8209
8278
  function installPreserveDrawingBuffer(scope = globalThis) {
8210
- install ?? (install = new Function(
8211
- `return ${PRESERVE_DRAWING_BUFFER_SOURCE}`
8212
- )());
8213
- return install(scope);
8279
+ return installPreserveDrawingBufferRuntime(scope);
8214
8280
  }
8215
8281
 
8216
8282
  // canvas/interact-canvas-frames.ts
@@ -8256,9 +8322,11 @@ function installTempoInteractProjectionSource() {
8256
8322
  delete hook[PENDING_ROOTS_KEY];
8257
8323
  }
8258
8324
  const disposeCanvasFrames = installTempoInteractCanvasFrameLane();
8325
+ const stopCssInputs = observeCssInputs(document);
8259
8326
  const disposeProjection = startCombinedSourceInterface();
8260
8327
  return () => {
8261
8328
  disposeProjection();
8329
+ stopCssInputs();
8262
8330
  disposeCanvasFrames();
8263
8331
  };
8264
8332
  }
@@ -8266,4 +8334,4 @@ function installTempoInteractProjectionSource() {
8266
8334
  export {
8267
8335
  installTempoInteractProjectionSource
8268
8336
  };
8269
- //# sourceMappingURL=chunk-3XEEVCM3.js.map
8337
+ //# sourceMappingURL=chunk-6QGMLNO3.js.map