tempo-sdk 0.0.99 → 0.0.102

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 (170) hide show
  1. package/README.md +3 -403
  2. package/dist/assets/editor.d.ts +43 -65
  3. package/dist/assets/editor.js +1 -573
  4. package/dist/assets/index.d.ts +11 -61
  5. package/dist/assets/index.js +1 -338
  6. package/dist/assets/parser.d.ts +68 -78
  7. package/dist/assets/parser.js +1 -33
  8. package/dist/astro/asset-preview-client.d.ts +3 -2
  9. package/dist/astro/asset-preview-client.js +1 -93
  10. package/dist/astro/controls.d.ts +1 -3
  11. package/dist/astro/controls.js +1 -7
  12. package/dist/astro/document-client.d.ts +5 -6
  13. package/dist/astro/document-client.js +1 -78
  14. package/dist/astro/runtime.d.ts +23 -11
  15. package/dist/astro/runtime.js +1 -86
  16. package/dist/astro.d.ts +19 -13
  17. package/dist/astro.js +1 -818
  18. package/dist/canvas/astro-contract.d.ts +0 -3
  19. package/dist/canvas/astro-contract.js +1 -9
  20. package/dist/canvas/astro.d.ts +3 -4
  21. package/dist/canvas/astro.js +1 -42
  22. package/dist/canvas/editor.d.ts +187 -183
  23. package/dist/canvas/editor.js +1 -1094
  24. package/dist/canvas/flutter-preview.d.ts +0 -1
  25. package/dist/canvas/flutter-preview.js +1 -9
  26. package/dist/canvas/index.d.ts +46 -100
  27. package/dist/canvas/index.js +1 -3926
  28. package/dist/canvas/interact-projection.d.ts +7 -5
  29. package/dist/canvas/interact-projection.js +1 -12
  30. package/dist/canvas/parser.d.ts +10 -303
  31. package/dist/canvas/parser.js +1 -30
  32. package/dist/canvas/svelte.d.ts +6 -7
  33. package/dist/canvas/svelte.js +1 -91
  34. package/dist/canvas/vue.d.ts +9 -49
  35. package/dist/canvas/vue.js +1 -264
  36. package/dist/chunk-CXCUJCXD.js +1 -0
  37. package/dist/chunk-FH6TMWFA.js +1 -0
  38. package/dist/chunk-FL7FSJSL.js +1 -0
  39. package/dist/chunk-GQIOB5SV.js +1 -0
  40. package/dist/chunk-HBQ7FFH7.js +1 -0
  41. package/dist/chunk-JRJOWLCN.js +1 -0
  42. package/dist/chunk-LJCBFTMP.js +1 -0
  43. package/dist/chunk-M3GN2KUH.js +1 -0
  44. package/dist/chunk-MPIHFFML.js +1 -0
  45. package/dist/chunk-T5TY3U2H.js +1 -0
  46. package/dist/chunk-XO2BSHWM.js +1 -0
  47. package/dist/chunk-XUSV3KOD.js +1 -0
  48. package/dist/chunk-ZXBMP6RV.js +1 -0
  49. package/dist/{controls-uCaQ3CNX.d.ts → controls-DKslABtM.d.ts} +0 -3
  50. package/dist/expo/plugin.cjs +1 -1928
  51. package/dist/expo/plugin.js +1 -8
  52. package/dist/expo-babel-plugin.cjs +1 -1928
  53. package/dist/expo-babel-plugin.d.cts +46 -40
  54. package/dist/expo-babel-plugin.d.ts +46 -40
  55. package/dist/expo-babel-plugin.js +1 -8
  56. package/dist/flutter-preview-path.d.ts +23 -7
  57. package/dist/flutter-preview-path.js +1 -16
  58. package/dist/index.d.ts +33 -45
  59. package/dist/index.js +1 -20
  60. package/dist/nextjs/plugin.cjs +1 -413
  61. package/dist/nextjs/plugin.js +1 -7
  62. package/dist/nextjs-loader.cjs +1 -2277
  63. package/dist/nextjs.cjs +1 -484
  64. package/dist/nextjs.d.cts +2 -58
  65. package/dist/nextjs.d.ts +2 -58
  66. package/dist/nextjs.js +1 -17
  67. package/dist/nuxt/runtime/identity.d.ts +2 -4
  68. package/dist/nuxt/runtime/identity.js +1 -18
  69. package/dist/nuxt.d.ts +31 -92
  70. package/dist/nuxt.js +1 -5854
  71. package/dist/{page-DwLnOM5d.d.ts → page-Bc8PekIX.d.ts} +1 -5
  72. package/dist/parser.d-MO5ciJ5n.d.ts +236 -0
  73. package/dist/{storyboard-CMJVBSXn.d.ts → storyboard.contract.d-UQ4MUYN5.d.ts} +3 -25
  74. package/dist/svelte.d.ts +8 -18
  75. package/dist/svelte.js +1 -917
  76. package/dist/types-CfUgM2w4.d.ts +57 -0
  77. package/dist/v1-client-compat-n0E0XxuX.d.ts +5 -0
  78. package/dist/vue.d.ts +17 -58
  79. package/dist/vue.js +1 -1501
  80. package/package.json +12 -62
  81. package/dist/assets/editor.js.map +0 -1
  82. package/dist/assets/index.js.map +0 -1
  83. package/dist/assets/parser.js.map +0 -1
  84. package/dist/astro/asset-preview-client.js.map +0 -1
  85. package/dist/astro/controls.js.map +0 -1
  86. package/dist/astro/document-client.js.map +0 -1
  87. package/dist/astro/runtime.js.map +0 -1
  88. package/dist/astro.js.map +0 -1
  89. package/dist/canvas/astro-contract.js.map +0 -1
  90. package/dist/canvas/astro.js.map +0 -1
  91. package/dist/canvas/editor.js.map +0 -1
  92. package/dist/canvas/flutter-preview.js.map +0 -1
  93. package/dist/canvas/index.js.map +0 -1
  94. package/dist/canvas/interact-projection.js.map +0 -1
  95. package/dist/canvas/parser.js.map +0 -1
  96. package/dist/canvas/svelte.js.map +0 -1
  97. package/dist/canvas/vue.js.map +0 -1
  98. package/dist/chunk-27WT3XUG.js +0 -455
  99. package/dist/chunk-27WT3XUG.js.map +0 -1
  100. package/dist/chunk-5HIIF354.js +0 -67
  101. package/dist/chunk-5HIIF354.js.map +0 -1
  102. package/dist/chunk-65B52AR7.js +0 -11
  103. package/dist/chunk-65B52AR7.js.map +0 -1
  104. package/dist/chunk-6HYKKP5N.js +0 -2658
  105. package/dist/chunk-6HYKKP5N.js.map +0 -1
  106. package/dist/chunk-6SOP4XU6.js +0 -1891
  107. package/dist/chunk-6SOP4XU6.js.map +0 -1
  108. package/dist/chunk-AFXE462X.js +0 -1253
  109. package/dist/chunk-AFXE462X.js.map +0 -1
  110. package/dist/chunk-BQPKOVI5.js +0 -115
  111. package/dist/chunk-BQPKOVI5.js.map +0 -1
  112. package/dist/chunk-CYDF4LYJ.js +0 -342
  113. package/dist/chunk-CYDF4LYJ.js.map +0 -1
  114. package/dist/chunk-CYQE3TLC.js +0 -37
  115. package/dist/chunk-CYQE3TLC.js.map +0 -1
  116. package/dist/chunk-DI2ZFAWL.js +0 -14
  117. package/dist/chunk-DI2ZFAWL.js.map +0 -1
  118. package/dist/chunk-EGRHWZRV.js +0 -1
  119. package/dist/chunk-EGRHWZRV.js.map +0 -1
  120. package/dist/chunk-FGWGY3G3.js +0 -157
  121. package/dist/chunk-FGWGY3G3.js.map +0 -1
  122. package/dist/chunk-HOBTDB6G.js +0 -112
  123. package/dist/chunk-HOBTDB6G.js.map +0 -1
  124. package/dist/chunk-I7VF4ZOV.js +0 -630
  125. package/dist/chunk-I7VF4ZOV.js.map +0 -1
  126. package/dist/chunk-JVVHU3A7.js +0 -1077
  127. package/dist/chunk-JVVHU3A7.js.map +0 -1
  128. package/dist/chunk-MIXQVPDH.js +0 -8606
  129. package/dist/chunk-MIXQVPDH.js.map +0 -1
  130. package/dist/chunk-MU7S7NU7.js +0 -183
  131. package/dist/chunk-MU7S7NU7.js.map +0 -1
  132. package/dist/chunk-OX2YKYSL.js +0 -13
  133. package/dist/chunk-OX2YKYSL.js.map +0 -1
  134. package/dist/chunk-PYAJHLXO.js +0 -903
  135. package/dist/chunk-PYAJHLXO.js.map +0 -1
  136. package/dist/chunk-SGN7BDRE.js +0 -16
  137. package/dist/chunk-SGN7BDRE.js.map +0 -1
  138. package/dist/chunk-SGTGDLOX.js +0 -285
  139. package/dist/chunk-SGTGDLOX.js.map +0 -1
  140. package/dist/chunk-T364NBR3.js +0 -1440
  141. package/dist/chunk-T364NBR3.js.map +0 -1
  142. package/dist/chunk-U66QI3EN.js +0 -1524
  143. package/dist/chunk-U66QI3EN.js.map +0 -1
  144. package/dist/chunk-WTXOWQ7N.js +0 -47
  145. package/dist/chunk-WTXOWQ7N.js.map +0 -1
  146. package/dist/chunk-X5DJKVBT.js +0 -1308
  147. package/dist/chunk-X5DJKVBT.js.map +0 -1
  148. package/dist/chunk-ZT7HJ6YU.js +0 -38
  149. package/dist/chunk-ZT7HJ6YU.js.map +0 -1
  150. package/dist/chunk-ZW26VZHX.js +0 -3169
  151. package/dist/chunk-ZW26VZHX.js.map +0 -1
  152. package/dist/controls-reader-5MFHYBZZ.js +0 -192
  153. package/dist/controls-reader-5MFHYBZZ.js.map +0 -1
  154. package/dist/expo/plugin.cjs.map +0 -1
  155. package/dist/expo/plugin.js.map +0 -1
  156. package/dist/expo-babel-plugin.cjs.map +0 -1
  157. package/dist/expo-babel-plugin.js.map +0 -1
  158. package/dist/flutter-preview-path.js.map +0 -1
  159. package/dist/index.js.map +0 -1
  160. package/dist/nextjs/plugin.cjs.map +0 -1
  161. package/dist/nextjs/plugin.js.map +0 -1
  162. package/dist/nextjs-loader.cjs.map +0 -1
  163. package/dist/nextjs.cjs.map +0 -1
  164. package/dist/nextjs.js.map +0 -1
  165. package/dist/nuxt/runtime/identity.js.map +0 -1
  166. package/dist/nuxt.js.map +0 -1
  167. package/dist/svelte.js.map +0 -1
  168. package/dist/types-C8OIU-kc.d.ts +0 -106
  169. package/dist/v1-client-compat-qxaXEDm_.d.ts +0 -23
  170. package/dist/vue.js.map +0 -1
@@ -1,630 +0,0 @@
1
- import {
2
- CSS_RUNTIME_MUTATION,
3
- cssSourcesFor,
4
- observeRuntimeMutations
5
- } from "./chunk-T364NBR3.js";
6
-
7
- // ../../modules/iframe-projection/html/head-text.ts
8
- function extractStyleSourceEvidence(text) {
9
- const attributes = {};
10
- const clone = {
11
- setAttribute: (key, value) => {
12
- attributes[key] = value;
13
- }
14
- };
15
- const reference = [
16
- ...text.matchAll(/\/\*[#@]\s*sourceMappingURL\s*=\s*(\S+?)\s*\*\//g)
17
- ].slice(-1)[0]?.[1];
18
- if (!reference || reference.length > 1024 * 1024) return attributes;
19
- const inline = /^data:application\/json(?:;charset=[\w-]+)?(;base64)?,(.*)$/is.exec(
20
- reference
21
- );
22
- if (!inline) {
23
- try {
24
- const url = new URL(reference);
25
- if (/^https?:$/.test(url.protocol))
26
- clone.setAttribute("data-projection-css-source-map-url", url.href);
27
- } catch {
28
- }
29
- return attributes;
30
- }
31
- function compact(raw, depth) {
32
- if (!raw || typeof raw !== "object" || depth > 16) return null;
33
- const map = raw;
34
- if (map.version !== 3) return null;
35
- const sources = Array.isArray(map.sources) && map.sources.length <= 4096 && map.sources.every((source) => typeof source === "string") ? map.sources : void 0;
36
- const sections = Array.isArray(map.sections) && map.sections.length <= 256 ? map.sections.flatMap((section) => {
37
- const nested = section && typeof section === "object" ? compact(section.map, depth + 1) : null;
38
- return nested ? [{ map: nested }] : [];
39
- }) : void 0;
40
- return {
41
- version: 3,
42
- ...typeof map.file === "string" ? { file: map.file } : {},
43
- ...typeof map.sourceRoot === "string" ? { sourceRoot: map.sourceRoot } : {},
44
- ...sources ? { sources } : {},
45
- ...sections ? { sections } : {}
46
- };
47
- }
48
- try {
49
- const json = inline[1] ? new TextDecoder().decode(
50
- Uint8Array.from(
51
- atob(inline[2]),
52
- (character) => character.charCodeAt(0)
53
- )
54
- ) : decodeURIComponent(inline[2]);
55
- const metadata = compact(JSON.parse(json), 0);
56
- if (!metadata) return attributes;
57
- const serialized = JSON.stringify(metadata);
58
- if (serialized.length <= 64 * 1024)
59
- clone.setAttribute("data-projection-css-source-map", serialized);
60
- } catch {
61
- }
62
- return attributes;
63
- }
64
- function resolveReference(value, baseHref, rootRelativeOrigin) {
65
- const url = new URL(value, baseHref);
66
- const sameOrigin = rootRelativeOrigin !== void 0 && rootRelativeOrigin !== "null" && url.origin === rootRelativeOrigin;
67
- return sameOrigin ? url.pathname + url.search + url.hash : url.href;
68
- }
69
- function absolutifyCssReferences(cssText, baseHref, rootRelativeOrigin) {
70
- const resolve = (value) => {
71
- const trimmed = value.trim();
72
- if (!trimmed || trimmed.startsWith("#") || /^(?:data|blob|javascript):/i.test(trimmed)) {
73
- return /^javascript:/i.test(trimmed) ? "" : trimmed;
74
- }
75
- try {
76
- return resolveReference(trimmed, baseHref, rootRelativeOrigin);
77
- } catch {
78
- return trimmed;
79
- }
80
- };
81
- return cssText.replace(
82
- /url\(\s*(["']?)([^"')]+)\1\s*\)/gi,
83
- (_match, quote, value) => `url(${quote}${resolve(value)}${quote})`
84
- ).replace(
85
- /@import\s+(["'])([^"']+)\1/gi,
86
- (_match, quote, value) => `@import ${quote}${resolve(value)}${quote}`
87
- );
88
- }
89
-
90
- // ../../modules/iframe-projection/html/head-capture-diagnostics.ts
91
- var observers = /* @__PURE__ */ new WeakMap();
92
- function measureHead(timing, stage, work) {
93
- if (!timing) return work();
94
- const start = performance.now();
95
- try {
96
- return work();
97
- } finally {
98
- const elapsed = performance.now() - start;
99
- timing.report.stages[stage] = (timing.report.stages[stage] ?? 0) + elapsed;
100
- if (timing.sheet)
101
- timing.sheet.stages[stage] = (timing.sheet.stages[stage] ?? 0) + elapsed;
102
- }
103
- }
104
- function beginHeadCapture(doc) {
105
- const observer = observers.get(doc);
106
- if (!observer) return;
107
- return {
108
- observer,
109
- report: {
110
- startedAt: Date.now(),
111
- clockStart: performance.now(),
112
- totalMs: 0,
113
- unaccountedMs: 0,
114
- cacheHits: 0,
115
- cacheMisses: 0,
116
- readWallMs: 0,
117
- workerWallMs: 0,
118
- stages: {},
119
- sheets: [],
120
- omittedSheets: 0
121
- }
122
- };
123
- }
124
- function finishHeadCapture(doc, timing) {
125
- if (observers.get(doc) !== timing.observer) return;
126
- const report = timing.report;
127
- report.totalMs = performance.now() - report.clockStart;
128
- report.unaccountedMs = Math.max(
129
- 0,
130
- report.totalMs - Object.values(report.stages).reduce((a, b) => a + b, 0)
131
- );
132
- try {
133
- observers.get(doc)?.(report);
134
- } catch {
135
- }
136
- }
137
- function captureHeadTiming(doc, capture) {
138
- const timing = beginHeadCapture(doc);
139
- try {
140
- return capture(timing);
141
- } finally {
142
- if (timing) finishHeadCapture(doc, timing);
143
- }
144
- }
145
- function beginHeadSheet(timing, kind) {
146
- if (!timing) return;
147
- const sheet = {
148
- index: timing.report.sheets.length + timing.report.omittedSheets,
149
- kind,
150
- rules: 0,
151
- characters: 0,
152
- stages: {}
153
- };
154
- if (timing.report.sheets.length < 64) timing.report.sheets.push(sheet);
155
- else timing.report.omittedSheets++;
156
- return { report: timing.report, observer: timing.observer, sheet };
157
- }
158
-
159
- // ../../modules/iframe-projection/html/watch-head.ts
160
- var INCLUDE_TAGS = /* @__PURE__ */ new Set(["STYLE", "META", "BASE", "LINK"]);
161
- var INCLUDE_LINK_RELS = /* @__PURE__ */ new Set(["stylesheet"]);
162
- var instance = null;
163
- function getHeadTracker() {
164
- if (!instance) {
165
- instance = new HeadTrackerImpl();
166
- }
167
- return instance;
168
- }
169
- var HeadSubscriptionImpl = class {
170
- constructor(doc, callback, onUnsubscribe, getRevision) {
171
- this.hasMutations = false;
172
- this.doc = doc;
173
- this.callback = callback;
174
- this.onUnsubscribe = onUnsubscribe;
175
- this.getRevision = getRevision;
176
- }
177
- get revision() {
178
- return this.getRevision();
179
- }
180
- flush(isInitial) {
181
- if (!isInitial && !this.hasMutations) {
182
- return void 0;
183
- }
184
- this.hasMutations = false;
185
- return captureHead(this.doc);
186
- }
187
- unsubscribe() {
188
- this.onUnsubscribe();
189
- }
190
- /** Called by tracker when relevant mutation detected */
191
- notifyMutation(details) {
192
- this.hasMutations = true;
193
- this.callback(details);
194
- }
195
- };
196
- var HeadTrackerImpl = class {
197
- constructor() {
198
- this.docObservers = /* @__PURE__ */ new Map();
199
- this.activeSubscriptions = 0;
200
- }
201
- flushPending(doc) {
202
- this.docObservers.get(doc)?.flushPending();
203
- }
204
- subscribe(doc, onMutation) {
205
- let docState = this.docObservers.get(doc);
206
- if (!docState) {
207
- docState = this.createDocObserver(doc);
208
- this.docObservers.set(doc, docState);
209
- }
210
- const subscription = new HeadSubscriptionImpl(
211
- doc,
212
- onMutation,
213
- () => {
214
- this.unsubscribe(doc, subscription);
215
- },
216
- () => docState.revision
217
- );
218
- docState.subscriptions.add(subscription);
219
- this.activeSubscriptions += 1;
220
- return subscription;
221
- }
222
- createDocObserver(doc) {
223
- const subscriptions = /* @__PURE__ */ new Set();
224
- let revision = {};
225
- const notify = (details) => {
226
- revision = {};
227
- for (const sub of subscriptions) {
228
- sub.notifyMutation(details);
229
- }
230
- };
231
- const stopHooks = observeRuntimeMutations(doc);
232
- const cssChanged = (event) => {
233
- const detail = event.detail;
234
- notify({
235
- stylesheetPaths: [],
236
- elements: detail?.ownerNode ? [detail.ownerNode] : [],
237
- sheets: detail?.sheet ? [detail.sheet] : [],
238
- allStyles: !detail?.sheet,
239
- mutable: detail?.mutable === true
240
- });
241
- };
242
- const loaded = (event) => {
243
- const target = event.target;
244
- if (target instanceof HTMLLinkElement && shouldIncludeLink(target))
245
- notify({ stylesheetPaths: [], elements: [target] });
246
- };
247
- doc.addEventListener("load", loaded, true);
248
- doc.addEventListener(CSS_RUNTIME_MUTATION, cssChanged);
249
- const stopRuntime = () => {
250
- doc.removeEventListener(CSS_RUNTIME_MUTATION, cssChanged);
251
- doc.removeEventListener("load", loaded, true);
252
- stopHooks();
253
- };
254
- const observeHead = (head) => {
255
- const changed = (mutations) => {
256
- const details = this.readRelevantMutations(mutations, head);
257
- if (!details) return;
258
- notify(details);
259
- };
260
- const observer = new MutationObserver(changed);
261
- observer.observe(head, {
262
- childList: true,
263
- subtree: true,
264
- attributes: true,
265
- characterData: true
266
- });
267
- return { observer, flushPending: () => changed(observer.takeRecords()) };
268
- };
269
- if (doc.head) {
270
- return {
271
- ...observeHead(doc.head),
272
- subscriptions,
273
- stopRuntime,
274
- get revision() {
275
- return revision;
276
- }
277
- };
278
- }
279
- const attachHead = () => {
280
- const head = doc.head;
281
- if (!head) return;
282
- bootstrap.disconnect();
283
- Object.assign(state, observeHead(head));
284
- notify({ stylesheetPaths: [] });
285
- };
286
- const bootstrap = new MutationObserver(attachHead);
287
- bootstrap.observe(doc, { childList: true, subtree: true });
288
- const state = {
289
- get revision() {
290
- return revision;
291
- },
292
- observer: bootstrap,
293
- flushPending: attachHead,
294
- subscriptions,
295
- stopRuntime
296
- };
297
- return state;
298
- }
299
- unsubscribe(doc, sub) {
300
- const docState = this.docObservers.get(doc);
301
- if (!docState) return;
302
- if (!docState.subscriptions.delete(sub)) return;
303
- this.activeSubscriptions = Math.max(0, this.activeSubscriptions - 1);
304
- if (docState.subscriptions.size === 0) {
305
- docState.observer.disconnect();
306
- docState.stopRuntime();
307
- this.docObservers.delete(doc);
308
- }
309
- }
310
- /**
311
- * Check if mutations contain changes to elements we care about.
312
- * This filtering runs once per mutation batch (not once per subscription).
313
- */
314
- readRelevantMutations(mutations, head) {
315
- let relevant = false;
316
- const stylesheetPaths = /* @__PURE__ */ new Set();
317
- const elements = /* @__PURE__ */ new Set();
318
- const collectStylesheetPath = (node) => {
319
- const element = node instanceof Element ? node : node?.parentElement ?? null;
320
- if (!element) return;
321
- elements.add(element);
322
- const candidates = [
323
- element,
324
- ...element.querySelectorAll(
325
- "style[data-vite-dev-id], link[rel~='stylesheet']"
326
- )
327
- ];
328
- for (const candidate of candidates) {
329
- if (candidate instanceof HTMLStyleElement) {
330
- const id = candidate.getAttribute("data-vite-dev-id")?.trim();
331
- if (id) stylesheetPaths.add(id);
332
- } else if (candidate instanceof HTMLLinkElement && shouldIncludeLink(candidate)) {
333
- const href = candidate.getAttribute("href")?.trim() || candidate.href;
334
- if (href) stylesheetPaths.add(href);
335
- }
336
- }
337
- };
338
- for (const mutation of mutations) {
339
- const target = mutation.target;
340
- const element = target instanceof Element ? target : target.parentElement;
341
- if (!element || !head.contains(element) && target !== head) continue;
342
- const tagName = element.tagName;
343
- if (INCLUDE_TAGS.has(tagName)) {
344
- if (tagName === "LINK") {
345
- const relChanged = mutation.type === "attributes" && mutation.attributeName === "rel";
346
- if (!relChanged && !shouldIncludeLink(element)) continue;
347
- }
348
- relevant = true;
349
- collectStylesheetPath(element);
350
- }
351
- if (mutation.type === "childList" && target === head) {
352
- relevant = true;
353
- }
354
- if (mutation.type === "childList") {
355
- for (const node of mutation.addedNodes) collectStylesheetPath(node);
356
- for (const node of mutation.removedNodes) collectStylesheetPath(node);
357
- }
358
- }
359
- return relevant ? { stylesheetPaths: [...stylesheetPaths], elements: [...elements] } : null;
360
- }
361
- destroy() {
362
- for (const docState of this.docObservers.values()) {
363
- docState.observer.disconnect();
364
- docState.stopRuntime();
365
- docState.subscriptions.clear();
366
- }
367
- this.docObservers.clear();
368
- this.activeSubscriptions = 0;
369
- }
370
- readPerfSnapshot() {
371
- return {
372
- observers: this.docObservers.size,
373
- subscriptions: this.activeSubscriptions
374
- };
375
- }
376
- };
377
- function serializeHeadStyle(style, resource, timing) {
378
- const type = style.getAttribute("type")?.trim().toLowerCase();
379
- const href = !type || type === "text/css" ? measureHead(
380
- timing,
381
- "resourceHash",
382
- () => resource?.(style.textContent ?? "")
383
- ) : null;
384
- if (href) {
385
- return measureHead(timing, "serializeMarkup", () => {
386
- const link = style.ownerDocument.createElement("link");
387
- for (const attribute of Array.from(style.attributes))
388
- if (!["type", "href", "rel", "integrity", "crossorigin"].includes(
389
- attribute.name
390
- ))
391
- link.setAttribute(attribute.name, attribute.value);
392
- link.rel = "stylesheet";
393
- link.href = href;
394
- return link.outerHTML;
395
- });
396
- }
397
- return measureHead(timing, "serializeMarkup", () => {
398
- escapeStyleForHtmlSerialization(style);
399
- return style.outerHTML;
400
- });
401
- }
402
- function captureHead(doc, resource, options = {}) {
403
- return captureHeadTiming(
404
- doc,
405
- (timing) => captureHeadValue(doc, resource, timing, options.rootRelativeOrigin)
406
- );
407
- }
408
- function captureHeadValue(doc, resource, timing, origin) {
409
- const head = doc.head;
410
- if (!head) return "";
411
- const baseURI = doc.baseURI;
412
- const fragments = [];
413
- for (const child of Array.from(head.children)) {
414
- const tagName = child.tagName;
415
- if (!INCLUDE_TAGS.has(tagName)) continue;
416
- if (tagName === "LINK" && !shouldIncludeLink(child)) continue;
417
- if (tagName !== "META" && tagName !== "BASE" && isDisabledStylesheet(child))
418
- continue;
419
- if (tagName === "META") {
420
- const httpEquiv = child.getAttribute("http-equiv")?.toLowerCase();
421
- const name = child.getAttribute("name")?.toLowerCase();
422
- if (httpEquiv === "content-security-policy" || name === "content-security-policy" || name === "theme-color") {
423
- continue;
424
- }
425
- }
426
- const sheetTiming = tagName === "STYLE" || tagName === "LINK" ? beginHeadSheet(timing, tagName) : timing;
427
- if (sheetTiming?.sheet) {
428
- sheetTiming.sheet.source = (child.getAttribute("data-vite-dev-id") ?? child.getAttribute("href") ?? child.id).split(/[?#]/)[0].slice(0, 512);
429
- }
430
- let clone = measureHead(
431
- sheetTiming,
432
- "cloneNodes",
433
- () => child.cloneNode(true)
434
- );
435
- materializeStyleElementCssom(child, clone, sheetTiming);
436
- if (tagName === "LINK") {
437
- clone = materializeStylesheetLinkCssom(child, clone, sheetTiming, origin);
438
- }
439
- measureHead(
440
- sheetTiming,
441
- "resolveUrls",
442
- () => resolveUrls(clone, baseURI, origin)
443
- );
444
- if (clone.tagName === "LINK") {
445
- clone.removeAttribute("crossorigin");
446
- } else if (clone.tagName === "STYLE") {
447
- measureHead(sheetTiming, "resolveUrls", () => {
448
- clone.textContent = absolutifyCssReferences(
449
- clone.textContent ?? "",
450
- baseURI,
451
- origin
452
- );
453
- });
454
- fragments.push(serializeHeadStyle(clone, resource, sheetTiming));
455
- continue;
456
- }
457
- fragments.push(
458
- measureHead(sheetTiming, "serializeMarkup", () => clone.outerHTML)
459
- );
460
- }
461
- fragments.push(...captureAdoptedStyleSheets(doc, resource, timing, origin));
462
- return measureHead(timing, "joinMarkup", () => fragments.join("\n"));
463
- }
464
- function materializeStylesheetLinkCssom(source, clone, timing, origin) {
465
- const link = source;
466
- const cssText = serializeCssRules(link.ownerDocument, link.sheet, timing);
467
- if (cssText === null) {
468
- return clone;
469
- }
470
- const resolvedCss = measureHead(
471
- timing,
472
- "resolveUrls",
473
- () => absolutifyCssReferences(cssText, link.href, origin)
474
- );
475
- return measureHead(timing, "materializeNodes", () => {
476
- const style = source.ownerDocument.createElement("style");
477
- for (const attribute of Array.from(source.attributes)) {
478
- if ([
479
- "as",
480
- "crossorigin",
481
- "fetchpriority",
482
- "href",
483
- "integrity",
484
- "referrerpolicy",
485
- "rel"
486
- ].includes(attribute.name.toLowerCase())) {
487
- continue;
488
- }
489
- style.setAttribute(attribute.name, attribute.value);
490
- }
491
- style.setAttribute("data-projection-stylesheet-href", link.href);
492
- style.textContent = resolvedCss;
493
- return style;
494
- });
495
- }
496
- var styleSourceEvidence = /* @__PURE__ */ new WeakMap();
497
- function retainStyleSourceEvidence(source, clone) {
498
- clone.removeAttribute("data-projection-css-source-map");
499
- clone.removeAttribute("data-projection-css-source-map-url");
500
- const text = source.textContent ?? "";
501
- if (text.length > 5 * 1024 * 1024) {
502
- styleSourceEvidence.delete(source);
503
- return;
504
- }
505
- const cached = styleSourceEvidence.get(source);
506
- if (cached?.text === text) {
507
- if (cached.inline)
508
- clone.setAttribute("data-projection-css-source-map", cached.inline);
509
- if (cached.url)
510
- clone.setAttribute("data-projection-css-source-map-url", cached.url);
511
- return;
512
- }
513
- captureStyleSourceEvidence(text, clone);
514
- styleSourceEvidence.set(source, {
515
- text,
516
- inline: clone.getAttribute("data-projection-css-source-map"),
517
- url: clone.getAttribute("data-projection-css-source-map-url")
518
- });
519
- }
520
- function captureStyleSourceEvidence(text, clone) {
521
- for (const [key, value] of Object.entries(extractStyleSourceEvidence(text)))
522
- clone.setAttribute(key, value);
523
- }
524
- function materializeStyleElementCssom(source, clone, timing) {
525
- if (source.tagName !== "STYLE" || clone.tagName !== "STYLE") {
526
- return;
527
- }
528
- const style = source;
529
- measureHead(
530
- timing,
531
- "sourceMetadata",
532
- () => retainStyleSourceEvidence(style, clone)
533
- );
534
- const cssText = serializeCssRules(style.ownerDocument, style.sheet, timing);
535
- if (cssText !== null) {
536
- measureHead(timing, "materializeNodes", () => {
537
- clone.textContent = cssText;
538
- });
539
- }
540
- }
541
- function captureAdoptedStyleSheets(doc, resource, timing, origin) {
542
- const sheets = Array.from(doc.adoptedStyleSheets ?? []);
543
- if (sheets.length === 0) {
544
- return [];
545
- }
546
- const fragments = [];
547
- for (const sheet of sheets) {
548
- if (sheet.disabled) continue;
549
- const sheetTiming = beginHeadSheet(timing, "adopted");
550
- const cssText = serializeCssRules(doc, sheet, sheetTiming);
551
- if (!cssText) {
552
- continue;
553
- }
554
- const style = measureHead(sheetTiming, "materializeNodes", () => {
555
- const node = doc.createElement("style");
556
- node.setAttribute("data-projection-adopted-stylesheet", "true");
557
- return node;
558
- });
559
- measureHead(sheetTiming, "resolveUrls", () => {
560
- style.textContent = absolutifyCssReferences(cssText, doc.baseURI, origin);
561
- });
562
- fragments.push(serializeHeadStyle(style, resource, sheetTiming));
563
- }
564
- return fragments;
565
- }
566
- function escapeStyleForHtmlSerialization(style) {
567
- style.textContent = (style.textContent ?? "").replace(/<\//gi, "<\\/");
568
- }
569
- function serializeCssRules(doc, sheet, timing) {
570
- if (!sheet) {
571
- return null;
572
- }
573
- try {
574
- return measureHead(timing, "readCssRules", () => {
575
- const rules = Array.from(sheet.cssRules);
576
- const sources = cssSourcesFor(doc);
577
- const text = rules.map((rule) => sources.ruleText(rule)).join("\n");
578
- if (timing?.sheet) {
579
- timing.sheet.rules = rules.length;
580
- timing.sheet.characters = text.length;
581
- }
582
- return text;
583
- });
584
- } catch {
585
- return null;
586
- }
587
- }
588
- function shouldIncludeLink(element) {
589
- const rel = element.getAttribute("rel");
590
- if (!rel) {
591
- return false;
592
- }
593
- return rel.toLowerCase().split(/\s+/).some((token) => INCLUDE_LINK_RELS.has(token));
594
- }
595
- function isDisabledStylesheet(element) {
596
- const owner = element;
597
- return owner.disabled === true || owner.sheet?.disabled === true;
598
- }
599
- function resolveUrls(element, baseURI, rootRelativeOrigin) {
600
- for (const name of ["href", "src"]) {
601
- const value = element.getAttribute(name);
602
- if (!value) continue;
603
- const onlyRelativizes = isAbsoluteUrl(value);
604
- if (onlyRelativizes && rootRelativeOrigin === void 0) continue;
605
- try {
606
- const resolved = resolveReference(value, baseURI, rootRelativeOrigin);
607
- if (onlyRelativizes && !resolved.startsWith("/")) continue;
608
- element.setAttribute(name, resolved);
609
- } catch {
610
- }
611
- }
612
- }
613
- function isAbsoluteUrl(url) {
614
- return /^(https?:)?\/\//i.test(url) || url.startsWith("data:");
615
- }
616
-
617
- export {
618
- extractStyleSourceEvidence,
619
- resolveReference,
620
- absolutifyCssReferences,
621
- beginHeadCapture,
622
- finishHeadCapture,
623
- beginHeadSheet,
624
- getHeadTracker,
625
- captureHead,
626
- shouldIncludeLink,
627
- isDisabledStylesheet,
628
- resolveUrls
629
- };
630
- //# sourceMappingURL=chunk-I7VF4ZOV.js.map