tempo-sdk 0.0.94 → 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.
- package/dist/assets/index.js +2 -2
- package/dist/astro/asset-preview-client.js +2 -2
- package/dist/astro.js +2 -2
- package/dist/canvas/astro.js +2 -2
- package/dist/canvas/index.js +35 -6
- package/dist/canvas/index.js.map +1 -1
- package/dist/canvas/interact-projection.js +3 -3
- package/dist/canvas/svelte.js +2 -2
- package/dist/canvas/vue.js +2 -2
- package/dist/{chunk-3W6B75UK.js → chunk-27WT3XUG.js} +2 -2
- package/dist/{chunk-3W6B75UK.js.map → chunk-27WT3XUG.js.map} +1 -1
- package/dist/{chunk-VRNJI4Y6.js → chunk-6HYKKP5N.js} +3 -2
- package/dist/{chunk-VRNJI4Y6.js.map → chunk-6HYKKP5N.js.map} +1 -1
- package/dist/{chunk-OYNR6D7K.js → chunk-CYDF4LYJ.js} +2 -2
- package/dist/{chunk-OYNR6D7K.js.map → chunk-CYDF4LYJ.js.map} +1 -1
- package/dist/{chunk-YHGUAOBM.js → chunk-I7VF4ZOV.js} +34 -25
- package/dist/chunk-I7VF4ZOV.js.map +1 -0
- package/dist/{chunk-6QGMLNO3.js → chunk-MIXQVPDH.js} +450 -181
- package/dist/chunk-MIXQVPDH.js.map +1 -0
- package/dist/{chunk-REYOX4JT.js → chunk-SGTGDLOX.js} +2 -2
- package/dist/{chunk-REYOX4JT.js.map → chunk-SGTGDLOX.js.map} +1 -1
- package/dist/{chunk-LEW24RRZ.js → chunk-X5DJKVBT.js} +10 -17
- package/dist/chunk-X5DJKVBT.js.map +1 -0
- package/dist/{chunk-WRILG6GR.js → chunk-ZT7HJ6YU.js} +2 -2
- package/dist/{chunk-KY52JZZL.js → chunk-ZW26VZHX.js} +41 -2
- package/dist/chunk-ZW26VZHX.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/nextjs/plugin.cjs +1 -1
- package/dist/nextjs/plugin.cjs.map +1 -1
- package/dist/nextjs/plugin.js +1 -1
- package/dist/nextjs-loader.cjs +1 -1
- package/dist/nextjs-loader.cjs.map +1 -1
- package/dist/nextjs.cjs +1 -1
- package/dist/nextjs.cjs.map +1 -1
- package/dist/nextjs.js +1 -1
- package/dist/nuxt/runtime/identity.js +1 -1
- package/dist/nuxt.js +1 -1
- package/dist/vue.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-6QGMLNO3.js.map +0 -1
- package/dist/chunk-KY52JZZL.js.map +0 -1
- package/dist/chunk-LEW24RRZ.js.map +0 -1
- package/dist/chunk-YHGUAOBM.js.map +0 -1
- /package/dist/{chunk-WRILG6GR.js.map → chunk-ZT7HJ6YU.js.map} +0 -0
|
@@ -11,9 +11,10 @@ import {
|
|
|
11
11
|
finishHeadCapture,
|
|
12
12
|
getHeadTracker,
|
|
13
13
|
isDisabledStylesheet,
|
|
14
|
+
resolveReference,
|
|
14
15
|
resolveUrls,
|
|
15
16
|
shouldIncludeLink
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-I7VF4ZOV.js";
|
|
17
18
|
import {
|
|
18
19
|
isTempoInteractFrameName
|
|
19
20
|
} from "./chunk-65B52AR7.js";
|
|
@@ -80,10 +81,11 @@ import {
|
|
|
80
81
|
syncProjectionDomIdsToClone,
|
|
81
82
|
trackAstroSources,
|
|
82
83
|
underForeignProjectionRoot,
|
|
84
|
+
wantsLegacyInteractSourceCoordinates,
|
|
83
85
|
watchDom,
|
|
84
86
|
watchPortal,
|
|
85
87
|
watchState
|
|
86
|
-
} from "./chunk-
|
|
88
|
+
} from "./chunk-ZW26VZHX.js";
|
|
87
89
|
import {
|
|
88
90
|
captureAttributes,
|
|
89
91
|
captureWithSupplementalRoots,
|
|
@@ -108,6 +110,66 @@ function isProjectionRepairPaths(value) {
|
|
|
108
110
|
);
|
|
109
111
|
}
|
|
110
112
|
|
|
113
|
+
// ../../modules/iframe-projection/html/document-assets.ts
|
|
114
|
+
var observers = /* @__PURE__ */ new WeakMap();
|
|
115
|
+
function observeDocumentAssets(doc, listener) {
|
|
116
|
+
let observer = observers.get(doc);
|
|
117
|
+
if (!observer) {
|
|
118
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
119
|
+
let active = true;
|
|
120
|
+
const notify = (target, kind) => {
|
|
121
|
+
if (active)
|
|
122
|
+
for (const callback of listeners) {
|
|
123
|
+
if (kind) callback(target, kind);
|
|
124
|
+
else callback(target);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const onResource = (event) => {
|
|
128
|
+
const target = event.target;
|
|
129
|
+
if (target?.localName === "img" || target?.localName === "image")
|
|
130
|
+
notify(target);
|
|
131
|
+
else if (target?.localName === "link" && target.relList.contains("stylesheet"))
|
|
132
|
+
notify(null);
|
|
133
|
+
};
|
|
134
|
+
const onFonts = () => notify(null, "font");
|
|
135
|
+
doc.addEventListener("load", onResource, true);
|
|
136
|
+
doc.addEventListener("error", onResource, true);
|
|
137
|
+
for (const type of ["loading", "loadingdone", "loadingerror"])
|
|
138
|
+
doc.fonts?.addEventListener(type, onFonts);
|
|
139
|
+
const PerformanceObserver = doc.defaultView?.PerformanceObserver;
|
|
140
|
+
const performanceObserver = PerformanceObserver ? new PerformanceObserver((list) => {
|
|
141
|
+
if (list.getEntries().some(
|
|
142
|
+
(entry) => entry.initiatorType === "css"
|
|
143
|
+
))
|
|
144
|
+
notify(null);
|
|
145
|
+
}) : null;
|
|
146
|
+
performanceObserver?.observe({ type: "resource", buffered: false });
|
|
147
|
+
observer = {
|
|
148
|
+
listeners,
|
|
149
|
+
stop() {
|
|
150
|
+
active = false;
|
|
151
|
+
performanceObserver?.disconnect();
|
|
152
|
+
doc.removeEventListener("load", onResource, true);
|
|
153
|
+
doc.removeEventListener("error", onResource, true);
|
|
154
|
+
for (const type of ["loading", "loadingdone", "loadingerror"])
|
|
155
|
+
doc.fonts?.removeEventListener(type, onFonts);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
observers.set(doc, observer);
|
|
159
|
+
}
|
|
160
|
+
observer.listeners.add(listener);
|
|
161
|
+
let subscribed = true;
|
|
162
|
+
return () => {
|
|
163
|
+
if (!subscribed) return;
|
|
164
|
+
subscribed = false;
|
|
165
|
+
observer.listeners.delete(listener);
|
|
166
|
+
if (observer.listeners.size === 0) {
|
|
167
|
+
observer.stop();
|
|
168
|
+
observers.delete(doc);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
111
173
|
// ../../modules/rate-limiter/browser-frame-clock.ts
|
|
112
174
|
function browserFrameClock() {
|
|
113
175
|
let next = 0;
|
|
@@ -526,7 +588,7 @@ async function processHeadText(input) {
|
|
|
526
588
|
const rawCss = measure("joinRules", () => input.rules.join("\n"));
|
|
527
589
|
const css = measure(
|
|
528
590
|
"resolveUrls",
|
|
529
|
-
() => absolutifyCssReferences(rawCss, input.base)
|
|
591
|
+
() => absolutifyCssReferences(rawCss, input.base, input.rootRelativeOrigin)
|
|
530
592
|
);
|
|
531
593
|
const start = input.measure ? performance.now() : 0;
|
|
532
594
|
const digest = await crypto.subtle.digest(
|
|
@@ -542,7 +604,7 @@ async function processHeadText(input) {
|
|
|
542
604
|
}
|
|
543
605
|
|
|
544
606
|
// ../../modules/iframe-projection/html/head-worker-source.ts
|
|
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
|
|
607
|
+
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 resolveReference(value, baseHref, rootRelativeOrigin) {\n const url = new URL(value, baseHref);\n const sameOrigin = rootRelativeOrigin !== void 0 && rootRelativeOrigin !== "null" && url.origin === rootRelativeOrigin;\n return sameOrigin ? url.pathname + url.search + url.hash : url.href;\n }\n function absolutifyCssReferences(cssText, baseHref, rootRelativeOrigin) {\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 resolveReference(trimmed, baseHref, rootRelativeOrigin);\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, input.rootRelativeOrigin)\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';
|
|
546
608
|
|
|
547
609
|
// ../../modules/iframe-projection/html/head-worker.ts
|
|
548
610
|
var WORKER_TIMEOUT_MS = 3e4;
|
|
@@ -628,14 +690,21 @@ function createHeadWorker() {
|
|
|
628
690
|
|
|
629
691
|
// ../../modules/iframe-projection/html/prepared-head.ts
|
|
630
692
|
var documents = /* @__PURE__ */ new WeakMap();
|
|
631
|
-
function createPreparedHead(doc, clock) {
|
|
632
|
-
|
|
693
|
+
function createPreparedHead(doc, clock, options = {}) {
|
|
694
|
+
const mode = options.rootRelativeOrigin ?? "";
|
|
695
|
+
let modes = documents.get(doc);
|
|
696
|
+
if (!modes) documents.set(doc, modes = /* @__PURE__ */ new Map());
|
|
697
|
+
let shared = modes.get(mode);
|
|
633
698
|
if (!shared) {
|
|
634
|
-
shared = {
|
|
635
|
-
|
|
699
|
+
shared = {
|
|
700
|
+
head: buildPreparedHead(doc, clock, options.rootRelativeOrigin),
|
|
701
|
+
owners: 0
|
|
702
|
+
};
|
|
703
|
+
modes.set(mode, shared);
|
|
636
704
|
}
|
|
637
705
|
shared.owners++;
|
|
638
706
|
const owner = shared;
|
|
707
|
+
const ownerModes = modes;
|
|
639
708
|
let disposed = false;
|
|
640
709
|
return {
|
|
641
710
|
...owner.head,
|
|
@@ -644,12 +713,13 @@ function createPreparedHead(doc, clock) {
|
|
|
644
713
|
disposed = true;
|
|
645
714
|
if (--owner.owners === 0) {
|
|
646
715
|
owner.head.dispose();
|
|
647
|
-
|
|
716
|
+
ownerModes.delete(mode);
|
|
717
|
+
if (ownerModes.size === 0) documents.delete(doc);
|
|
648
718
|
}
|
|
649
719
|
}
|
|
650
720
|
};
|
|
651
721
|
}
|
|
652
|
-
function buildPreparedHead(doc, clock) {
|
|
722
|
+
function buildPreparedHead(doc, clock, origin) {
|
|
653
723
|
const work = createWorkScheduler({ clock });
|
|
654
724
|
const worker = createHeadWorker();
|
|
655
725
|
const cssSources = cssSourcesFor(doc);
|
|
@@ -788,7 +858,7 @@ function buildPreparedHead(doc, clock) {
|
|
|
788
858
|
let prepared;
|
|
789
859
|
if (kind === "META" || kind === "BASE") {
|
|
790
860
|
const node = source.cloneNode(true);
|
|
791
|
-
resolveUrls(node, base);
|
|
861
|
+
resolveUrls(node, base, origin);
|
|
792
862
|
prepared = { node, rules: 0 };
|
|
793
863
|
} else {
|
|
794
864
|
const queued = timing ? performance.now() : 0;
|
|
@@ -800,7 +870,7 @@ function buildPreparedHead(doc, clock) {
|
|
|
800
870
|
let node = input.node;
|
|
801
871
|
if (input.rules === null) {
|
|
802
872
|
node.removeAttribute("crossorigin");
|
|
803
|
-
resolveUrls(node, base);
|
|
873
|
+
resolveUrls(node, base, origin);
|
|
804
874
|
prepared = { node, rules: 0 };
|
|
805
875
|
} else {
|
|
806
876
|
if (kind === "LINK") {
|
|
@@ -829,6 +899,7 @@ function buildPreparedHead(doc, clock) {
|
|
|
829
899
|
rules: input.rules,
|
|
830
900
|
authored: authored && authored.length <= 5 * 1024 * 1024 ? authored : "",
|
|
831
901
|
base: input.cssBase,
|
|
902
|
+
rootRelativeOrigin: origin,
|
|
832
903
|
metadata: previous?.authored === authored ? previous?.value : void 0,
|
|
833
904
|
measure: !!timing
|
|
834
905
|
});
|
|
@@ -846,7 +917,7 @@ function buildPreparedHead(doc, clock) {
|
|
|
846
917
|
node.setAttribute(key, value);
|
|
847
918
|
if ("tagName" in source && authored !== void 0)
|
|
848
919
|
metadata.set(source, { authored, value: text.metadata });
|
|
849
|
-
resolveUrls(node, base);
|
|
920
|
+
resolveUrls(node, base, origin);
|
|
850
921
|
prepared = { node, text, rules: input.count };
|
|
851
922
|
if (sheetTiming?.sheet) {
|
|
852
923
|
sheetTiming.sheet.rules = input.count;
|
|
@@ -962,66 +1033,6 @@ function buildPreparedHead(doc, clock) {
|
|
|
962
1033
|
};
|
|
963
1034
|
}
|
|
964
1035
|
|
|
965
|
-
// ../../modules/iframe-projection/html/document-assets.ts
|
|
966
|
-
var observers = /* @__PURE__ */ new WeakMap();
|
|
967
|
-
function observeDocumentAssets(doc, listener) {
|
|
968
|
-
let observer = observers.get(doc);
|
|
969
|
-
if (!observer) {
|
|
970
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
971
|
-
let active = true;
|
|
972
|
-
const notify = (target, kind) => {
|
|
973
|
-
if (active)
|
|
974
|
-
for (const callback of listeners) {
|
|
975
|
-
if (kind) callback(target, kind);
|
|
976
|
-
else callback(target);
|
|
977
|
-
}
|
|
978
|
-
};
|
|
979
|
-
const onResource = (event) => {
|
|
980
|
-
const target = event.target;
|
|
981
|
-
if (target?.localName === "img" || target?.localName === "image")
|
|
982
|
-
notify(target);
|
|
983
|
-
else if (target?.localName === "link" && target.relList.contains("stylesheet"))
|
|
984
|
-
notify(null);
|
|
985
|
-
};
|
|
986
|
-
const onFonts = () => notify(null, "font");
|
|
987
|
-
doc.addEventListener("load", onResource, true);
|
|
988
|
-
doc.addEventListener("error", onResource, true);
|
|
989
|
-
for (const type of ["loading", "loadingdone", "loadingerror"])
|
|
990
|
-
doc.fonts?.addEventListener(type, onFonts);
|
|
991
|
-
const PerformanceObserver = doc.defaultView?.PerformanceObserver;
|
|
992
|
-
const performanceObserver = PerformanceObserver ? new PerformanceObserver((list) => {
|
|
993
|
-
if (list.getEntries().some(
|
|
994
|
-
(entry) => entry.initiatorType === "css"
|
|
995
|
-
))
|
|
996
|
-
notify(null);
|
|
997
|
-
}) : null;
|
|
998
|
-
performanceObserver?.observe({ type: "resource", buffered: false });
|
|
999
|
-
observer = {
|
|
1000
|
-
listeners,
|
|
1001
|
-
stop() {
|
|
1002
|
-
active = false;
|
|
1003
|
-
performanceObserver?.disconnect();
|
|
1004
|
-
doc.removeEventListener("load", onResource, true);
|
|
1005
|
-
doc.removeEventListener("error", onResource, true);
|
|
1006
|
-
for (const type of ["loading", "loadingdone", "loadingerror"])
|
|
1007
|
-
doc.fonts?.removeEventListener(type, onFonts);
|
|
1008
|
-
}
|
|
1009
|
-
};
|
|
1010
|
-
observers.set(doc, observer);
|
|
1011
|
-
}
|
|
1012
|
-
observer.listeners.add(listener);
|
|
1013
|
-
let subscribed = true;
|
|
1014
|
-
return () => {
|
|
1015
|
-
if (!subscribed) return;
|
|
1016
|
-
subscribed = false;
|
|
1017
|
-
observer.listeners.delete(listener);
|
|
1018
|
-
if (observer.listeners.size === 0) {
|
|
1019
|
-
observer.stop();
|
|
1020
|
-
observers.delete(doc);
|
|
1021
|
-
}
|
|
1022
|
-
};
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
1036
|
// ../../modules/iframe-projection/combined/projection-capture-perf.ts
|
|
1026
1037
|
function buildProjectionCapturePerf(input) {
|
|
1027
1038
|
const flushCounters = readCaptureFlushCounters();
|
|
@@ -1076,8 +1087,17 @@ function buildProjectionCapturePerf(input) {
|
|
|
1076
1087
|
};
|
|
1077
1088
|
}
|
|
1078
1089
|
|
|
1090
|
+
// ../../modules/iframe-projection/root-color.ts
|
|
1091
|
+
var PROJECTION_ROOT_COLOR_ATTR = "data-tempo-root-color";
|
|
1092
|
+
function captureProjectionRootColor(documentElement) {
|
|
1093
|
+
const color = documentElement.ownerDocument.defaultView?.getComputedStyle(documentElement).color.trim();
|
|
1094
|
+
return color ? { [PROJECTION_ROOT_COLOR_ATTR]: color } : {};
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1079
1097
|
// ../../modules/iframe-projection/html/root-coordinates.ts
|
|
1080
1098
|
var ROOT_COORDINATES_ATTRIBUTE = "data-projection-root-coordinates";
|
|
1099
|
+
|
|
1100
|
+
// ../../modules/iframe-projection/combined/legacy-source-coordinates.ts
|
|
1081
1101
|
function changesFixedCoordinates(css) {
|
|
1082
1102
|
const active = (value) => Boolean(value && value !== "none");
|
|
1083
1103
|
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);
|
|
@@ -1120,12 +1140,111 @@ function captureRootCoordinates(root, portals = []) {
|
|
|
1120
1140
|
...layout
|
|
1121
1141
|
};
|
|
1122
1142
|
}
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
const
|
|
1128
|
-
|
|
1143
|
+
function createLegacySourceCoordinateTracker(options) {
|
|
1144
|
+
const sentPortalCoordinates = /* @__PURE__ */ new Map();
|
|
1145
|
+
let stopped = false;
|
|
1146
|
+
let sentCoordinates;
|
|
1147
|
+
const hasCoordinateFrame = () => sentCoordinates !== void 0;
|
|
1148
|
+
const ancestorsOf = (element) => {
|
|
1149
|
+
const chain = [];
|
|
1150
|
+
for (let ancestor = element.parentElement; ancestor; ancestor = ancestor.parentElement) {
|
|
1151
|
+
chain.push(ancestor);
|
|
1152
|
+
}
|
|
1153
|
+
return chain;
|
|
1154
|
+
};
|
|
1155
|
+
const sameChain = (chain, other) => chain.length === other.length && chain.every((element, index) => element === other[index]);
|
|
1156
|
+
let observedAncestors = [];
|
|
1157
|
+
const frameWatcher = new MutationObserver((records) => {
|
|
1158
|
+
if (stopped) return;
|
|
1159
|
+
let reparented = false;
|
|
1160
|
+
if (records.some((record) => record.type === "childList")) {
|
|
1161
|
+
const chain = ancestorsOf(options.root);
|
|
1162
|
+
reparented = !sameChain(chain, observedAncestors);
|
|
1163
|
+
if (reparented) observeAncestors(chain);
|
|
1164
|
+
}
|
|
1165
|
+
const restyled = records.some((record) => record.type === "attributes");
|
|
1166
|
+
if (!reparented && !restyled) return;
|
|
1167
|
+
if (!options.hasPortals() && !hasCoordinateFrame()) return;
|
|
1168
|
+
options.onChange();
|
|
1169
|
+
});
|
|
1170
|
+
function observeAncestors(chain) {
|
|
1171
|
+
frameWatcher.disconnect();
|
|
1172
|
+
observedAncestors = chain;
|
|
1173
|
+
for (const ancestor of chain) {
|
|
1174
|
+
frameWatcher.observe(ancestor, {
|
|
1175
|
+
attributes: true,
|
|
1176
|
+
attributeFilter: ["style", "class"],
|
|
1177
|
+
childList: true
|
|
1178
|
+
});
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
observeAncestors(ancestorsOf(options.root));
|
|
1182
|
+
const view = options.root.ownerDocument.defaultView;
|
|
1183
|
+
const invalidateCoordinates = () => {
|
|
1184
|
+
if (!stopped && (hasCoordinateFrame() || options.hasPortals()))
|
|
1185
|
+
options.onChange();
|
|
1186
|
+
};
|
|
1187
|
+
const onScroll = (event) => {
|
|
1188
|
+
const target = event.target;
|
|
1189
|
+
if (target?.contains?.(options.root)) invalidateCoordinates();
|
|
1190
|
+
};
|
|
1191
|
+
view?.addEventListener("resize", invalidateCoordinates);
|
|
1192
|
+
view?.addEventListener("scroll", onScroll, true);
|
|
1193
|
+
return {
|
|
1194
|
+
hasCoordinateFrame,
|
|
1195
|
+
rememberCoordinates(coordinates) {
|
|
1196
|
+
sentCoordinates = coordinates ? JSON.stringify(coordinates) : void 0;
|
|
1197
|
+
},
|
|
1198
|
+
portalSent(portal, patch) {
|
|
1199
|
+
if (patch.kind === "replace" && patch.coordinateSpace) {
|
|
1200
|
+
sentPortalCoordinates.set(
|
|
1201
|
+
portal,
|
|
1202
|
+
JSON.stringify(patch.coordinateSpace)
|
|
1203
|
+
);
|
|
1204
|
+
}
|
|
1205
|
+
},
|
|
1206
|
+
portalRemoved(portal) {
|
|
1207
|
+
sentPortalCoordinates.delete(portal);
|
|
1208
|
+
},
|
|
1209
|
+
portalRefreshes(livePortals, resent) {
|
|
1210
|
+
const patches = [];
|
|
1211
|
+
for (const portal of livePortals) {
|
|
1212
|
+
if (resent.has(portal)) continue;
|
|
1213
|
+
const coordinates = captureProjectionPortalCoordinates(
|
|
1214
|
+
options.root,
|
|
1215
|
+
portal
|
|
1216
|
+
);
|
|
1217
|
+
if (!coordinates) continue;
|
|
1218
|
+
const measured = JSON.stringify(coordinates.coordinateSpace);
|
|
1219
|
+
if (sentPortalCoordinates.get(portal) === measured) continue;
|
|
1220
|
+
sentPortalCoordinates.set(portal, measured);
|
|
1221
|
+
patches.push(coordinates);
|
|
1222
|
+
}
|
|
1223
|
+
return patches;
|
|
1224
|
+
},
|
|
1225
|
+
rootPatch(livePortals) {
|
|
1226
|
+
const coordinates = captureRootCoordinates(options.root, livePortals);
|
|
1227
|
+
const measuredCoordinates = coordinates ? JSON.stringify(coordinates) : void 0;
|
|
1228
|
+
const coordinatesChanged = measuredCoordinates !== sentCoordinates;
|
|
1229
|
+
sentCoordinates = measuredCoordinates;
|
|
1230
|
+
if (!coordinatesChanged) return null;
|
|
1231
|
+
return {
|
|
1232
|
+
kind: "attributes",
|
|
1233
|
+
targetId: PROJECTION_ROOT_TARGET_ID,
|
|
1234
|
+
attributes: {
|
|
1235
|
+
[ROOT_COORDINATES_ATTRIBUTE]: measuredCoordinates ?? null
|
|
1236
|
+
}
|
|
1237
|
+
};
|
|
1238
|
+
},
|
|
1239
|
+
stop() {
|
|
1240
|
+
if (stopped) return;
|
|
1241
|
+
stopped = true;
|
|
1242
|
+
frameWatcher.disconnect();
|
|
1243
|
+
view?.removeEventListener("resize", invalidateCoordinates);
|
|
1244
|
+
view?.removeEventListener("scroll", onScroll, true);
|
|
1245
|
+
sentPortalCoordinates.clear();
|
|
1246
|
+
}
|
|
1247
|
+
};
|
|
1129
1248
|
}
|
|
1130
1249
|
|
|
1131
1250
|
// ../../modules/iframe-projection/combined/projection-full-snapshot.ts
|
|
@@ -1135,7 +1254,9 @@ function captureProjectionFullSnapshot(options) {
|
|
|
1135
1254
|
const { dom, hostDomIdCount } = captureFullDom(
|
|
1136
1255
|
options.root,
|
|
1137
1256
|
options.portals ?? [],
|
|
1138
|
-
observedFiles
|
|
1257
|
+
observedFiles,
|
|
1258
|
+
void 0,
|
|
1259
|
+
options.legacySourceCoordinates === true
|
|
1139
1260
|
);
|
|
1140
1261
|
const pointerEventsNone = [];
|
|
1141
1262
|
for (const element of projectedElements(options.root)) {
|
|
@@ -1167,7 +1288,7 @@ function captureProjectionFullSnapshot(options) {
|
|
|
1167
1288
|
function captureFullDom(root, portals, observedFiles, identity = {
|
|
1168
1289
|
readId: (element) => ensureProjectionDomId(element),
|
|
1169
1290
|
syncClone: syncProjectionDomIdsToClone
|
|
1170
|
-
}) {
|
|
1291
|
+
}, legacySourceCoordinates = false) {
|
|
1171
1292
|
for (const scope of [root, ...portals]) {
|
|
1172
1293
|
for (const element of projectedElements(scope)) {
|
|
1173
1294
|
identity.readId(element);
|
|
@@ -1193,7 +1314,7 @@ function captureFullDom(root, portals, observedFiles, identity = {
|
|
|
1193
1314
|
)) {
|
|
1194
1315
|
hostDomIds.add(domId);
|
|
1195
1316
|
}
|
|
1196
|
-
const coordinateSpace = capturePortalCoordinateSpace(root, portal);
|
|
1317
|
+
const coordinateSpace = legacySourceCoordinates ? capturePortalCoordinateSpace(root, portal) : void 0;
|
|
1197
1318
|
portalPatches.push({
|
|
1198
1319
|
kind: "replace",
|
|
1199
1320
|
portalId,
|
|
@@ -1203,7 +1324,7 @@ function captureFullDom(root, portals, observedFiles, identity = {
|
|
|
1203
1324
|
}
|
|
1204
1325
|
const body = root.ownerDocument.body;
|
|
1205
1326
|
const rootDomId = identity.readId(root);
|
|
1206
|
-
const coordinates = captureRootCoordinates(root, portals);
|
|
1327
|
+
const coordinates = legacySourceCoordinates ? captureRootCoordinates(root, portals) : void 0;
|
|
1207
1328
|
const dom = {
|
|
1208
1329
|
...coordinates ? { coordinates } : {},
|
|
1209
1330
|
html: removeScriptTags(clone.innerHTML),
|
|
@@ -4379,55 +4500,12 @@ function createProjectionRootAccumulator(options) {
|
|
|
4379
4500
|
const portals = /* @__PURE__ */ new Map();
|
|
4380
4501
|
const dirtyPortals = /* @__PURE__ */ new Set();
|
|
4381
4502
|
const removedPortals = /* @__PURE__ */ new Map();
|
|
4382
|
-
const sentPortalCoordinates = /* @__PURE__ */ new Map();
|
|
4383
4503
|
let stopped = false;
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
chain.push(ancestor);
|
|
4390
|
-
}
|
|
4391
|
-
return chain;
|
|
4392
|
-
};
|
|
4393
|
-
const sameChain = (chain, other) => chain.length === other.length && chain.every((element, index) => element === other[index]);
|
|
4394
|
-
let observedAncestors = [];
|
|
4395
|
-
const frameWatcher = new MutationObserver((records) => {
|
|
4396
|
-
if (stopped) return;
|
|
4397
|
-
let reparented = false;
|
|
4398
|
-
if (records.some((record) => record.type === "childList")) {
|
|
4399
|
-
const chain = ancestorsOf(options.root);
|
|
4400
|
-
reparented = !sameChain(chain, observedAncestors);
|
|
4401
|
-
if (reparented) observeAncestors(chain);
|
|
4402
|
-
}
|
|
4403
|
-
const restyled = records.some((record) => record.type === "attributes");
|
|
4404
|
-
if (!reparented && !restyled) return;
|
|
4405
|
-
if (portals.size === 0 && !hasCoordinateFrame()) return;
|
|
4406
|
-
options.onChange("portal-coordinate-change");
|
|
4407
|
-
});
|
|
4408
|
-
function observeAncestors(chain) {
|
|
4409
|
-
frameWatcher.disconnect();
|
|
4410
|
-
observedAncestors = chain;
|
|
4411
|
-
for (const ancestor of chain) {
|
|
4412
|
-
frameWatcher.observe(ancestor, {
|
|
4413
|
-
attributes: true,
|
|
4414
|
-
attributeFilter: ["style", "class"],
|
|
4415
|
-
childList: true
|
|
4416
|
-
});
|
|
4417
|
-
}
|
|
4418
|
-
}
|
|
4419
|
-
observeAncestors(ancestorsOf(options.root));
|
|
4420
|
-
const view = options.root.ownerDocument.defaultView;
|
|
4421
|
-
const invalidateCoordinates = () => {
|
|
4422
|
-
if (!stopped && (hasCoordinateFrame() || portals.size > 0))
|
|
4423
|
-
options.onChange("portal-coordinate-change");
|
|
4424
|
-
};
|
|
4425
|
-
const onScroll = (event) => {
|
|
4426
|
-
const target = event.target;
|
|
4427
|
-
if (target?.contains?.(options.root)) invalidateCoordinates();
|
|
4428
|
-
};
|
|
4429
|
-
view?.addEventListener("resize", invalidateCoordinates);
|
|
4430
|
-
view?.addEventListener("scroll", onScroll, true);
|
|
4504
|
+
const legacyCoordinates = options.legacySourceCoordinates ? createLegacySourceCoordinateTracker({
|
|
4505
|
+
root: options.root,
|
|
4506
|
+
hasPortals: () => portals.size > 0,
|
|
4507
|
+
onChange: () => options.onChange("portal-coordinate-change")
|
|
4508
|
+
}) : null;
|
|
4431
4509
|
const registerPortals = options.registerPortals ?? ((registration) => getPortalTracker().register({
|
|
4432
4510
|
element: options.root,
|
|
4433
4511
|
...registration
|
|
@@ -4452,7 +4530,7 @@ function createProjectionRootAccumulator(options) {
|
|
|
4452
4530
|
});
|
|
4453
4531
|
dirtyPortals.delete(portal);
|
|
4454
4532
|
portals.delete(portal);
|
|
4455
|
-
|
|
4533
|
+
legacyCoordinates?.portalRemoved(portal);
|
|
4456
4534
|
handle.stop();
|
|
4457
4535
|
options.onChange("portal-mutation");
|
|
4458
4536
|
}
|
|
@@ -4462,9 +4540,9 @@ function createProjectionRootAccumulator(options) {
|
|
|
4462
4540
|
if (stopped) return 0;
|
|
4463
4541
|
return dom.takePendingRecords();
|
|
4464
4542
|
},
|
|
4465
|
-
hasCoordinateFrame,
|
|
4543
|
+
hasCoordinateFrame: () => legacyCoordinates?.hasCoordinateFrame() ?? false,
|
|
4466
4544
|
rememberCoordinates(coordinates) {
|
|
4467
|
-
|
|
4545
|
+
legacyCoordinates?.rememberCoordinates(coordinates);
|
|
4468
4546
|
},
|
|
4469
4547
|
hasPortals() {
|
|
4470
4548
|
return !stopped && portals.size > 0;
|
|
@@ -4530,16 +4608,11 @@ function createProjectionRootAccumulator(options) {
|
|
|
4530
4608
|
const captured = captureProjectionPortalRegion(
|
|
4531
4609
|
portal,
|
|
4532
4610
|
false,
|
|
4533
|
-
options.root
|
|
4611
|
+
legacyCoordinates ? options.root : void 0
|
|
4534
4612
|
);
|
|
4535
4613
|
if (!captured) continue;
|
|
4536
4614
|
resentPortals.add(portal);
|
|
4537
|
-
|
|
4538
|
-
sentPortalCoordinates.set(
|
|
4539
|
-
portal,
|
|
4540
|
-
JSON.stringify(captured.portal.coordinateSpace)
|
|
4541
|
-
);
|
|
4542
|
-
}
|
|
4615
|
+
legacyCoordinates?.portalSent(portal, captured.portal);
|
|
4543
4616
|
portalPatches.push(captured.portal);
|
|
4544
4617
|
observedFiles.merge(captured.observedFiles);
|
|
4545
4618
|
layerObservedFiles.merge(captured.observedFiles);
|
|
@@ -4554,18 +4627,10 @@ function createProjectionRootAccumulator(options) {
|
|
|
4554
4627
|
}
|
|
4555
4628
|
}
|
|
4556
4629
|
dirtyPortals.clear();
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
options.root,
|
|
4561
|
-
portal
|
|
4630
|
+
if (legacyCoordinates)
|
|
4631
|
+
portalPatches.push(
|
|
4632
|
+
...legacyCoordinates.portalRefreshes(portals.keys(), resentPortals)
|
|
4562
4633
|
);
|
|
4563
|
-
if (!coordinates2) continue;
|
|
4564
|
-
const measured = JSON.stringify(coordinates2.coordinateSpace);
|
|
4565
|
-
if (sentPortalCoordinates.get(portal) === measured) continue;
|
|
4566
|
-
sentPortalCoordinates.set(portal, measured);
|
|
4567
|
-
portalPatches.push(coordinates2);
|
|
4568
|
-
}
|
|
4569
4634
|
const observedSnapshot = observedFiles.snapshot();
|
|
4570
4635
|
for (const snapshot of metadata)
|
|
4571
4636
|
layerObservedFiles.addLayerProps(snapshot.props);
|
|
@@ -4574,19 +4639,9 @@ function createProjectionRootAccumulator(options) {
|
|
|
4574
4639
|
...metadata.length > 0 ? { metadata } : {},
|
|
4575
4640
|
...Object.keys(layerObservedSnapshot).length > 0 ? { observedFiles: layerObservedSnapshot } : {}
|
|
4576
4641
|
};
|
|
4577
|
-
const coordinates = captureRootCoordinates(options.root, portals.keys());
|
|
4578
|
-
const measuredCoordinates = coordinates ? JSON.stringify(coordinates) : void 0;
|
|
4579
|
-
const coordinatesChanged = measuredCoordinates !== sentCoordinates;
|
|
4580
|
-
sentCoordinates = measuredCoordinates;
|
|
4581
4642
|
const domPatches = [...mutationPatch.dom];
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
kind: "attributes",
|
|
4585
|
-
targetId: PROJECTION_ROOT_TARGET_ID,
|
|
4586
|
-
attributes: {
|
|
4587
|
-
[ROOT_COORDINATES_ATTRIBUTE]: measuredCoordinates ?? null
|
|
4588
|
-
}
|
|
4589
|
-
});
|
|
4643
|
+
const rootCoordinatesPatch = legacyCoordinates?.rootPatch(portals.keys());
|
|
4644
|
+
if (rootCoordinatesPatch) domPatches.push(rootCoordinatesPatch);
|
|
4590
4645
|
const patch = {
|
|
4591
4646
|
...Object.keys(layers).length > 0 ? { layers } : {},
|
|
4592
4647
|
...domPatches.length > 0 ? { dom: domPatches } : {},
|
|
@@ -4622,16 +4677,13 @@ function createProjectionRootAccumulator(options) {
|
|
|
4622
4677
|
if (stopped) return;
|
|
4623
4678
|
stopped = true;
|
|
4624
4679
|
unregisterPortals();
|
|
4625
|
-
|
|
4626
|
-
view?.removeEventListener("resize", invalidateCoordinates);
|
|
4627
|
-
view?.removeEventListener("scroll", onScroll, true);
|
|
4680
|
+
legacyCoordinates?.stop();
|
|
4628
4681
|
dom.stop();
|
|
4629
4682
|
state.stop();
|
|
4630
4683
|
for (const portal of portals.values()) portal.stop();
|
|
4631
4684
|
portals.clear();
|
|
4632
4685
|
dirtyPortals.clear();
|
|
4633
4686
|
removedPortals.clear();
|
|
4634
|
-
sentPortalCoordinates.clear();
|
|
4635
4687
|
}
|
|
4636
4688
|
};
|
|
4637
4689
|
}
|
|
@@ -4660,7 +4712,9 @@ function collectDomLayerTargets(root, mutations) {
|
|
|
4660
4712
|
var MODULE_EVALUATED_GRACE_MS = 3e3;
|
|
4661
4713
|
function createCombinedDocumentProducer(options) {
|
|
4662
4714
|
const reactHook = initHook();
|
|
4663
|
-
const preparedHead = options.prepareHead ? createPreparedHead(options.document, options.headWorkClock
|
|
4715
|
+
const preparedHead = options.prepareHead ? createPreparedHead(options.document, options.headWorkClock, {
|
|
4716
|
+
rootRelativeOrigin: options.rootRelativeOrigin
|
|
4717
|
+
}) : void 0;
|
|
4664
4718
|
const roots = /* @__PURE__ */ new Map();
|
|
4665
4719
|
const captureStats = /* @__PURE__ */ new WeakMap();
|
|
4666
4720
|
let stopped = false;
|
|
@@ -4950,10 +5004,15 @@ function createCombinedDocumentProducer(options) {
|
|
|
4950
5004
|
root: runtime.options.element,
|
|
4951
5005
|
fiberTarget,
|
|
4952
5006
|
portals: accumulator.portalElements(),
|
|
4953
|
-
layerAdapter: runtime.layerAdapter
|
|
5007
|
+
layerAdapter: runtime.layerAdapter,
|
|
5008
|
+
legacySourceCoordinates: options.legacySourceCoordinates === true
|
|
4954
5009
|
});
|
|
4955
|
-
|
|
4956
|
-
|
|
5010
|
+
accumulator.rememberCoordinates(captured.snapshot.dom.coordinates);
|
|
5011
|
+
const snapshot = options.rootRelativeOrigin === void 0 ? captured.snapshot : rootRelativeSnapshot(
|
|
5012
|
+
captured.snapshot,
|
|
5013
|
+
runtime.options.element,
|
|
5014
|
+
options.rootRelativeOrigin
|
|
5015
|
+
);
|
|
4957
5016
|
const documentContext = JSON.stringify([
|
|
4958
5017
|
snapshot.dom.documentElementAttributes,
|
|
4959
5018
|
snapshot.dom.bodyAttributes,
|
|
@@ -5146,7 +5205,7 @@ function createCombinedDocumentProducer(options) {
|
|
|
5146
5205
|
}
|
|
5147
5206
|
const observedSnapshot = observedFiles.snapshot();
|
|
5148
5207
|
const layerObservedSnapshot = layerObservedFiles.snapshot();
|
|
5149
|
-
|
|
5208
|
+
let patch = {
|
|
5150
5209
|
...basePatch,
|
|
5151
5210
|
...adapterLayerPatch ? { layers: adapterLayerPatch } : regions.snapshots.length > 0 || metadata.length > 0 ? {
|
|
5152
5211
|
layers: {
|
|
@@ -5174,6 +5233,14 @@ function createCombinedDocumentProducer(options) {
|
|
|
5174
5233
|
layers: { ...patch.layers, observedFiles: layerObservedSnapshot }
|
|
5175
5234
|
});
|
|
5176
5235
|
}
|
|
5236
|
+
if (options.rootRelativeOrigin !== void 0) {
|
|
5237
|
+
patch = rootRelativePatch(
|
|
5238
|
+
patch,
|
|
5239
|
+
runtime.options.element,
|
|
5240
|
+
accumulator.portalElements(),
|
|
5241
|
+
options.rootRelativeOrigin
|
|
5242
|
+
);
|
|
5243
|
+
}
|
|
5177
5244
|
const absentFiles = captureAbsentFiles(runtime, observedSnapshot, false);
|
|
5178
5245
|
if (absentFiles) Object.assign(patch, { absentFiles });
|
|
5179
5246
|
if (Object.keys(patch).length === 0) {
|
|
@@ -5204,7 +5271,9 @@ function createCombinedDocumentProducer(options) {
|
|
|
5204
5271
|
captureHead(flushContext) {
|
|
5205
5272
|
if (flushContext.candidateRootCount === 0) resetCaptureFlushCounters();
|
|
5206
5273
|
const startedAt = Date.now();
|
|
5207
|
-
const head = preparedHead ? preparedHead.capture(options.styleResource) : captureHead(options.document, options.styleResource
|
|
5274
|
+
const head = preparedHead ? preparedHead.capture(options.styleResource) : captureHead(options.document, options.styleResource, {
|
|
5275
|
+
rootRelativeOrigin: options.rootRelativeOrigin
|
|
5276
|
+
});
|
|
5208
5277
|
headSnapshotMs = Date.now() - startedAt;
|
|
5209
5278
|
headPerfContext = flushContext;
|
|
5210
5279
|
return head;
|
|
@@ -5268,6 +5337,7 @@ function createCombinedDocumentProducer(options) {
|
|
|
5268
5337
|
try {
|
|
5269
5338
|
const accumulator = createProjectionRootAccumulator({
|
|
5270
5339
|
root: runtime.options.element,
|
|
5340
|
+
legacySourceCoordinates: options.legacySourceCoordinates === true,
|
|
5271
5341
|
onChange(trigger) {
|
|
5272
5342
|
if (!runtime.options.element.isConnected) {
|
|
5273
5343
|
makeRootDormant(runtime);
|
|
@@ -5586,11 +5656,22 @@ function createCombinedDocumentProducer(options) {
|
|
|
5586
5656
|
if (!runtime || runtime.dormant || !runtime.options.element.isConnected) {
|
|
5587
5657
|
return null;
|
|
5588
5658
|
}
|
|
5589
|
-
|
|
5659
|
+
const portals = runtime.accumulator?.portalElements() ?? [];
|
|
5660
|
+
const capture = captureProjectionRegion(
|
|
5590
5661
|
runtime.options.element,
|
|
5591
5662
|
targetId,
|
|
5592
|
-
|
|
5663
|
+
portals
|
|
5593
5664
|
);
|
|
5665
|
+
if (!capture || options.rootRelativeOrigin === void 0) return capture;
|
|
5666
|
+
return {
|
|
5667
|
+
...capture,
|
|
5668
|
+
html: rootRelativeBodyHtml(
|
|
5669
|
+
capture.html,
|
|
5670
|
+
options.document,
|
|
5671
|
+
options.rootRelativeOrigin,
|
|
5672
|
+
resolveRegionElement(runtime.options.element, targetId, portals)
|
|
5673
|
+
)
|
|
5674
|
+
};
|
|
5594
5675
|
},
|
|
5595
5676
|
stop() {
|
|
5596
5677
|
if (stopped) return;
|
|
@@ -6080,6 +6161,177 @@ function aggregateBatchPerf(roots, head, context, capturedHeadMs, rootsPerBatch,
|
|
|
6080
6161
|
sourceViewportSamples
|
|
6081
6162
|
};
|
|
6082
6163
|
}
|
|
6164
|
+
function rootRelativeSnapshot(snapshot, root, origin) {
|
|
6165
|
+
const { baseUrl: _, ...dom } = snapshot.dom;
|
|
6166
|
+
const rewriteAttributes = (attributes, element) => Object.fromEntries(
|
|
6167
|
+
Object.entries(attributes).map(([name, value]) => [
|
|
6168
|
+
name,
|
|
6169
|
+
rootRelativeBodyAttribute(element, name, value, origin)
|
|
6170
|
+
])
|
|
6171
|
+
);
|
|
6172
|
+
return {
|
|
6173
|
+
...snapshot,
|
|
6174
|
+
dom: {
|
|
6175
|
+
...dom,
|
|
6176
|
+
html: rootRelativeBodyHtml(dom.html, root.ownerDocument, origin, root),
|
|
6177
|
+
documentElementAttributes: rewriteAttributes(
|
|
6178
|
+
dom.documentElementAttributes,
|
|
6179
|
+
root.ownerDocument.documentElement
|
|
6180
|
+
),
|
|
6181
|
+
...dom.bodyAttributes && root.ownerDocument.body ? {
|
|
6182
|
+
bodyAttributes: rewriteAttributes(
|
|
6183
|
+
dom.bodyAttributes,
|
|
6184
|
+
root.ownerDocument.body
|
|
6185
|
+
)
|
|
6186
|
+
} : {},
|
|
6187
|
+
...dom.rootAttributes ? { rootAttributes: rewriteAttributes(dom.rootAttributes, root) } : {},
|
|
6188
|
+
portals: dom.portals.map(
|
|
6189
|
+
(portal) => portal.kind === "replace" ? {
|
|
6190
|
+
...portal,
|
|
6191
|
+
html: rootRelativeBodyHtml(
|
|
6192
|
+
portal.html,
|
|
6193
|
+
root.ownerDocument,
|
|
6194
|
+
origin
|
|
6195
|
+
)
|
|
6196
|
+
} : portal
|
|
6197
|
+
)
|
|
6198
|
+
}
|
|
6199
|
+
};
|
|
6200
|
+
}
|
|
6201
|
+
function rootRelativePatch(patch, root, portals, origin) {
|
|
6202
|
+
const resolve = (id) => resolveRegionElement(root, id, portals);
|
|
6203
|
+
return {
|
|
6204
|
+
...patch,
|
|
6205
|
+
...patch.dom ? {
|
|
6206
|
+
dom: patch.dom.map((change) => {
|
|
6207
|
+
if (change.kind === "remove") return change;
|
|
6208
|
+
const element = resolve(change.targetId);
|
|
6209
|
+
if (change.kind === "attributes") {
|
|
6210
|
+
if (!element) return change;
|
|
6211
|
+
return {
|
|
6212
|
+
...change,
|
|
6213
|
+
attributes: Object.fromEntries(
|
|
6214
|
+
Object.entries(change.attributes).map(([name, value]) => [
|
|
6215
|
+
name,
|
|
6216
|
+
value === null ? null : rootRelativeBodyAttribute(element, name, value, origin)
|
|
6217
|
+
])
|
|
6218
|
+
)
|
|
6219
|
+
};
|
|
6220
|
+
}
|
|
6221
|
+
return {
|
|
6222
|
+
...change,
|
|
6223
|
+
html: rootRelativeBodyHtml(
|
|
6224
|
+
change.html,
|
|
6225
|
+
root.ownerDocument,
|
|
6226
|
+
origin,
|
|
6227
|
+
change.kind === "children" ? element : resolve(change.parentId)
|
|
6228
|
+
)
|
|
6229
|
+
};
|
|
6230
|
+
})
|
|
6231
|
+
} : {},
|
|
6232
|
+
...patch.portals ? {
|
|
6233
|
+
portals: patch.portals.map(
|
|
6234
|
+
(portal) => portal.kind === "replace" ? {
|
|
6235
|
+
...portal,
|
|
6236
|
+
html: rootRelativeBodyHtml(
|
|
6237
|
+
portal.html,
|
|
6238
|
+
root.ownerDocument,
|
|
6239
|
+
origin
|
|
6240
|
+
)
|
|
6241
|
+
} : portal
|
|
6242
|
+
)
|
|
6243
|
+
} : {},
|
|
6244
|
+
...patch.layers?.metadata ? {
|
|
6245
|
+
layers: {
|
|
6246
|
+
...patch.layers,
|
|
6247
|
+
metadata: patch.layers.metadata.map((entry) => {
|
|
6248
|
+
const parent = entry.ancestorIds?.[0];
|
|
6249
|
+
if (entry.content === void 0 || !parent || resolve(parent)?.localName !== "style")
|
|
6250
|
+
return entry;
|
|
6251
|
+
return {
|
|
6252
|
+
...entry,
|
|
6253
|
+
content: rootRelativeBodyCss(entry.content, origin)
|
|
6254
|
+
};
|
|
6255
|
+
})
|
|
6256
|
+
}
|
|
6257
|
+
} : {}
|
|
6258
|
+
};
|
|
6259
|
+
}
|
|
6260
|
+
function rootRelativeBodyHtml(html, doc, origin, context) {
|
|
6261
|
+
if (context?.localName === "style") return rootRelativeBodyCss(html, origin);
|
|
6262
|
+
if (!html.includes(origin.replace(/^[a-z]+:/i, ""))) return html;
|
|
6263
|
+
const template = doc.createElement("template");
|
|
6264
|
+
const svgContext = context?.namespaceURI === "http://www.w3.org/2000/svg";
|
|
6265
|
+
const container = svgContext ? template.content.ownerDocument.createElementNS(
|
|
6266
|
+
context.namespaceURI,
|
|
6267
|
+
context.localName
|
|
6268
|
+
) : template;
|
|
6269
|
+
container.innerHTML = html;
|
|
6270
|
+
const content = container === template ? template.content : container;
|
|
6271
|
+
let changed = false;
|
|
6272
|
+
for (const element of content.querySelectorAll("*")) {
|
|
6273
|
+
for (const attribute of [...element.attributes]) {
|
|
6274
|
+
const value = rootRelativeBodyAttribute(
|
|
6275
|
+
element,
|
|
6276
|
+
attribute.name,
|
|
6277
|
+
attribute.value,
|
|
6278
|
+
origin
|
|
6279
|
+
);
|
|
6280
|
+
if (value === attribute.value) continue;
|
|
6281
|
+
attribute.value = value;
|
|
6282
|
+
changed = true;
|
|
6283
|
+
}
|
|
6284
|
+
if (element.localName !== "style") continue;
|
|
6285
|
+
const css = element.textContent ?? "";
|
|
6286
|
+
const rewritten = rootRelativeBodyCss(css, origin);
|
|
6287
|
+
if (rewritten === css) continue;
|
|
6288
|
+
element.textContent = rewritten;
|
|
6289
|
+
changed = true;
|
|
6290
|
+
}
|
|
6291
|
+
return changed ? container.innerHTML : html;
|
|
6292
|
+
}
|
|
6293
|
+
function rootRelativeBodyAttribute(element, name, value, origin) {
|
|
6294
|
+
if (name === "style") return rootRelativeBodyCss(value, origin);
|
|
6295
|
+
if (name === "srcset") {
|
|
6296
|
+
let cursor = 0;
|
|
6297
|
+
let copied = 0;
|
|
6298
|
+
let rewritten = "";
|
|
6299
|
+
while (cursor < value.length) {
|
|
6300
|
+
while (cursor < value.length && /[\s,]/.test(value[cursor])) cursor++;
|
|
6301
|
+
const start = cursor;
|
|
6302
|
+
while (cursor < value.length && !/\s/.test(value[cursor])) cursor++;
|
|
6303
|
+
const token = value.slice(start, cursor);
|
|
6304
|
+
const url = token.replace(/,+$/, "");
|
|
6305
|
+
rewritten += value.slice(copied, start) + rootRelativeBodyUrl(url, origin);
|
|
6306
|
+
copied = start + url.length;
|
|
6307
|
+
if (token.endsWith(",")) continue;
|
|
6308
|
+
while (cursor < value.length && value[cursor] !== ",") cursor++;
|
|
6309
|
+
}
|
|
6310
|
+
return rewritten + value.slice(copied);
|
|
6311
|
+
}
|
|
6312
|
+
const svgResource = element.namespaceURI === "http://www.w3.org/2000/svg" && element.localName !== "a";
|
|
6313
|
+
const stylesheet = element.localName === "link" && /(?:^|\s)stylesheet(?:\s|$)/i.test(element.getAttribute("rel") ?? "");
|
|
6314
|
+
const resourceAttribute = name === "src" || name === "poster" || (name === "href" || name === "xlink:href") && (svgResource || stylesheet);
|
|
6315
|
+
return resourceAttribute ? rootRelativeBodyUrl(value, origin) : value;
|
|
6316
|
+
}
|
|
6317
|
+
function rootRelativeBodyCss(css, origin) {
|
|
6318
|
+
return css.replace(
|
|
6319
|
+
/url\(\s*(["']?)([^"')]+)\1\s*\)/gi,
|
|
6320
|
+
(match, _quote, value) => {
|
|
6321
|
+
const rewritten = rootRelativeBodyUrl(value, origin);
|
|
6322
|
+
return rewritten === value ? match : match.replace(value, rewritten);
|
|
6323
|
+
}
|
|
6324
|
+
);
|
|
6325
|
+
}
|
|
6326
|
+
function rootRelativeBodyUrl(value, origin) {
|
|
6327
|
+
if (!/^(?:https?:)?\/\//i.test(value.trim())) return value;
|
|
6328
|
+
try {
|
|
6329
|
+
const resolved = resolveReference(value, origin, origin);
|
|
6330
|
+
return resolved.startsWith("/") ? resolved : value;
|
|
6331
|
+
} catch {
|
|
6332
|
+
return value;
|
|
6333
|
+
}
|
|
6334
|
+
}
|
|
6083
6335
|
|
|
6084
6336
|
// ../../modules/iframe-projection/combined/layer-framework.ts
|
|
6085
6337
|
var LAYER_FRAMEWORKS = [
|
|
@@ -6649,6 +6901,9 @@ function watchCombined(element, onChange, options = {}) {
|
|
|
6649
6901
|
const producer = createCombinedDocumentProducer({
|
|
6650
6902
|
document: element.ownerDocument,
|
|
6651
6903
|
flushWindowMs: options.debounceDelay ?? LEGACY_FLUSH_WINDOW_MS,
|
|
6904
|
+
// Only clients older than canvas protocol 3 send this command, and they
|
|
6905
|
+
// rebase the envelope's portals from the coordinate refreshes it drives.
|
|
6906
|
+
legacySourceCoordinates: true,
|
|
6652
6907
|
emit(batch) {
|
|
6653
6908
|
if (stopped) return;
|
|
6654
6909
|
if (paused) {
|
|
@@ -6897,6 +7152,7 @@ function createProjectionSourceController(options) {
|
|
|
6897
7152
|
}
|
|
6898
7153
|
producer ?? (producer = createCombinedDocumentProducer({
|
|
6899
7154
|
document: options.document,
|
|
7155
|
+
legacySourceCoordinates: options.legacySourceCoordinates === true,
|
|
6900
7156
|
emit: publishBatch,
|
|
6901
7157
|
onError: (error) => sendError(error)
|
|
6902
7158
|
}));
|
|
@@ -7126,7 +7382,12 @@ function createProjectionSourceController(options) {
|
|
|
7126
7382
|
}
|
|
7127
7383
|
function startCombinedSourceInterface(options = {}) {
|
|
7128
7384
|
if (typeof document !== "undefined") trackAstroSources(document);
|
|
7129
|
-
const {
|
|
7385
|
+
const {
|
|
7386
|
+
targetOrigin = "*",
|
|
7387
|
+
serialize,
|
|
7388
|
+
hideFiberProp,
|
|
7389
|
+
legacySourceCoordinates = false
|
|
7390
|
+
} = options;
|
|
7130
7391
|
if (combinedSourceInitialized) {
|
|
7131
7392
|
console.warn("[combined-postmessage:source] Already initialized");
|
|
7132
7393
|
return combinedSourceCleanup || (() => {
|
|
@@ -7152,13 +7413,18 @@ function startCombinedSourceInterface(options = {}) {
|
|
|
7152
7413
|
};
|
|
7153
7414
|
combinedSourceCleanup = cleanup;
|
|
7154
7415
|
const deferredInstall = installWhenDocumentBodyReady(
|
|
7155
|
-
() => initCombinedSourceInterface(
|
|
7416
|
+
() => initCombinedSourceInterface(
|
|
7417
|
+
targetOrigin,
|
|
7418
|
+
serialize,
|
|
7419
|
+
hideFiberProp,
|
|
7420
|
+
legacySourceCoordinates
|
|
7421
|
+
)
|
|
7156
7422
|
);
|
|
7157
7423
|
if (disposed) deferredInstall();
|
|
7158
7424
|
else disposeDeferredInstall = deferredInstall;
|
|
7159
7425
|
return cleanup;
|
|
7160
7426
|
}
|
|
7161
|
-
function initCombinedSourceInterface(targetOrigin, serialize, hideFiberProp) {
|
|
7427
|
+
function initCombinedSourceInterface(targetOrigin, serialize, hideFiberProp, legacySourceCoordinates = false) {
|
|
7162
7428
|
window.__IFRAME_PROJECTION_COMBINED_INTERFACE_ACTIVE__ = true;
|
|
7163
7429
|
const send = (msg) => {
|
|
7164
7430
|
if ("batch" in msg && msg.batch instanceof ArrayBuffer) {
|
|
@@ -7176,6 +7442,7 @@ function initCombinedSourceInterface(targetOrigin, serialize, hideFiberProp) {
|
|
|
7176
7442
|
watcherIdPrefix: "iframe-projection-watcher",
|
|
7177
7443
|
serialize,
|
|
7178
7444
|
hideFiberProp,
|
|
7445
|
+
legacySourceCoordinates,
|
|
7179
7446
|
send(type, payload) {
|
|
7180
7447
|
if (type === "error") {
|
|
7181
7448
|
send({
|
|
@@ -8323,7 +8590,9 @@ function installTempoInteractProjectionSource() {
|
|
|
8323
8590
|
}
|
|
8324
8591
|
const disposeCanvasFrames = installTempoInteractCanvasFrameLane();
|
|
8325
8592
|
const stopCssInputs = observeCssInputs(document);
|
|
8326
|
-
const disposeProjection = startCombinedSourceInterface(
|
|
8593
|
+
const disposeProjection = startCombinedSourceInterface({
|
|
8594
|
+
legacySourceCoordinates: wantsLegacyInteractSourceCoordinates()
|
|
8595
|
+
});
|
|
8327
8596
|
return () => {
|
|
8328
8597
|
disposeProjection();
|
|
8329
8598
|
stopCssInputs();
|
|
@@ -8334,4 +8603,4 @@ function installTempoInteractProjectionSource() {
|
|
|
8334
8603
|
export {
|
|
8335
8604
|
installTempoInteractProjectionSource
|
|
8336
8605
|
};
|
|
8337
|
-
//# sourceMappingURL=chunk-
|
|
8606
|
+
//# sourceMappingURL=chunk-MIXQVPDH.js.map
|