tempo-sdk 0.0.60 → 0.0.69

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 (108) hide show
  1. package/astro/client.d.ts +4 -0
  2. package/dist/assets/editor.js +1 -1
  3. package/dist/assets/index.d.ts +10 -63
  4. package/dist/assets/index.js +35 -33
  5. package/dist/assets/index.js.map +1 -1
  6. package/dist/assets/parser.js +1 -1
  7. package/dist/astro/asset-preview-client.d.ts +4 -0
  8. package/dist/astro/asset-preview-client.js +93 -0
  9. package/dist/astro/asset-preview-client.js.map +1 -0
  10. package/dist/astro/controls.d.ts +7 -0
  11. package/dist/astro/controls.js +7 -0
  12. package/dist/astro/controls.js.map +1 -0
  13. package/dist/astro/document-client.d.ts +10 -0
  14. package/dist/astro/document-client.js +78 -0
  15. package/dist/astro/document-client.js.map +1 -0
  16. package/dist/astro/runtime.d.ts +15 -0
  17. package/dist/astro/runtime.js +86 -0
  18. package/dist/astro/runtime.js.map +1 -0
  19. package/dist/astro.d.ts +21 -0
  20. package/dist/astro.js +808 -0
  21. package/dist/astro.js.map +1 -0
  22. package/dist/canvas/astro-contract.d.ts +21 -0
  23. package/dist/canvas/astro-contract.js +9 -0
  24. package/dist/canvas/astro-contract.js.map +1 -0
  25. package/dist/canvas/astro.d.ts +18 -0
  26. package/dist/canvas/astro.js +42 -0
  27. package/dist/canvas/astro.js.map +1 -0
  28. package/dist/canvas/editor.d.ts +1 -1
  29. package/dist/canvas/editor.js +3 -2
  30. package/dist/canvas/editor.js.map +1 -1
  31. package/dist/canvas/index.d.ts +1 -1
  32. package/dist/canvas/index.js +40 -16
  33. package/dist/canvas/index.js.map +1 -1
  34. package/dist/canvas/interact-projection.js +4 -4
  35. package/dist/canvas/parser.d.ts +3 -1
  36. package/dist/canvas/parser.js +1 -1
  37. package/dist/canvas/svelte.d.ts +1 -1
  38. package/dist/canvas/svelte.js +3 -3
  39. package/dist/{chunk-5BHIHP25.js → chunk-2JRAG36X.js} +37 -11
  40. package/dist/chunk-2JRAG36X.js.map +1 -0
  41. package/dist/{chunk-N2TYN3RB.js → chunk-6AAE4LYV.js} +123 -123
  42. package/dist/chunk-6AAE4LYV.js.map +1 -0
  43. package/dist/{chunk-FQSZRVSL.js → chunk-6BSLP7P3.js} +46 -5
  44. package/dist/chunk-6BSLP7P3.js.map +1 -0
  45. package/dist/{chunk-7DT5DDSH.js → chunk-6IR5JY6W.js} +106 -7
  46. package/dist/chunk-6IR5JY6W.js.map +1 -0
  47. package/dist/chunk-77DZCV5Z.js +38 -0
  48. package/dist/chunk-77DZCV5Z.js.map +1 -0
  49. package/dist/{chunk-MXKZZOLM.js → chunk-EYKOOLPL.js} +368 -32
  50. package/dist/chunk-EYKOOLPL.js.map +1 -0
  51. package/dist/chunk-F23JGM4U.js +107 -0
  52. package/dist/chunk-F23JGM4U.js.map +1 -0
  53. package/dist/chunk-FE6TYCLF.js +1514 -0
  54. package/dist/chunk-FE6TYCLF.js.map +1 -0
  55. package/dist/chunk-H6OZIX2U.js +133 -0
  56. package/dist/chunk-H6OZIX2U.js.map +1 -0
  57. package/dist/chunk-JVVHU3A7.js +1077 -0
  58. package/dist/chunk-JVVHU3A7.js.map +1 -0
  59. package/dist/{chunk-2IQD2KPS.js → chunk-KOSJXE4G.js} +3 -102
  60. package/dist/chunk-KOSJXE4G.js.map +1 -0
  61. package/dist/{chunk-TL4MGN7E.js → chunk-NSKYOKG5.js} +254 -10
  62. package/dist/chunk-NSKYOKG5.js.map +1 -0
  63. package/dist/chunk-OX2YKYSL.js +13 -0
  64. package/dist/chunk-OX2YKYSL.js.map +1 -0
  65. package/dist/{chunk-VMTQDG4U.js → chunk-PXDTH36X.js} +12 -10
  66. package/dist/chunk-PXDTH36X.js.map +1 -0
  67. package/dist/{chunk-XLEKCOB7.js → chunk-PYAJHLXO.js} +56 -1
  68. package/dist/chunk-PYAJHLXO.js.map +1 -0
  69. package/dist/{chunk-OTVBSF7U.js → chunk-Q2A46HHW.js} +17 -12
  70. package/dist/chunk-Q2A46HHW.js.map +1 -0
  71. package/dist/chunk-WTQQOLXM.js +2495 -0
  72. package/dist/chunk-WTQQOLXM.js.map +1 -0
  73. package/dist/controls-reader-SNMI2UY7.js +191 -0
  74. package/dist/controls-reader-SNMI2UY7.js.map +1 -0
  75. package/dist/controls-uCaQ3CNX.d.ts +61 -0
  76. package/dist/expo/plugin.cjs +16 -11
  77. package/dist/expo/plugin.cjs.map +1 -1
  78. package/dist/expo/plugin.js +1 -1
  79. package/dist/expo-babel-plugin.cjs +16 -11
  80. package/dist/expo-babel-plugin.cjs.map +1 -1
  81. package/dist/expo-babel-plugin.js +1 -1
  82. package/dist/index.d.ts +4 -0
  83. package/dist/index.js +10 -2465
  84. package/dist/index.js.map +1 -1
  85. package/dist/nextjs/plugin.cjs +45 -4
  86. package/dist/nextjs/plugin.cjs.map +1 -1
  87. package/dist/nextjs/plugin.js +1 -1
  88. package/dist/nextjs-loader.cjs +61 -15
  89. package/dist/nextjs-loader.cjs.map +1 -1
  90. package/dist/nextjs.cjs +45 -4
  91. package/dist/nextjs.cjs.map +1 -1
  92. package/dist/nextjs.d.cts +4 -4
  93. package/dist/nextjs.d.ts +4 -4
  94. package/dist/nextjs.js +1 -1
  95. package/dist/{storyboard-DjOF61B_.d.ts → storyboard-4YdTYq_e.d.ts} +1 -1
  96. package/dist/svelte.js +7 -1075
  97. package/dist/svelte.js.map +1 -1
  98. package/package.json +45 -4
  99. package/dist/chunk-2IQD2KPS.js.map +0 -1
  100. package/dist/chunk-5BHIHP25.js.map +0 -1
  101. package/dist/chunk-7DT5DDSH.js.map +0 -1
  102. package/dist/chunk-FQSZRVSL.js.map +0 -1
  103. package/dist/chunk-MXKZZOLM.js.map +0 -1
  104. package/dist/chunk-N2TYN3RB.js.map +0 -1
  105. package/dist/chunk-OTVBSF7U.js.map +0 -1
  106. package/dist/chunk-TL4MGN7E.js.map +0 -1
  107. package/dist/chunk-VMTQDG4U.js.map +0 -1
  108. package/dist/chunk-XLEKCOB7.js.map +0 -1
@@ -1,6 +1,7 @@
1
1
  import {
2
- isTempoInteractFrameName
3
- } from "./chunk-65B52AR7.js";
2
+ captureHead,
3
+ getHeadTracker
4
+ } from "./chunk-2JRAG36X.js";
4
5
  import {
5
6
  DOM_ID_ATTR,
6
7
  DOM_LAYER_ROOT_ID,
@@ -21,6 +22,7 @@ import {
21
22
  captureProjectionStatePatch,
22
23
  captureRegionWithoutAnnotations,
23
24
  captureTree,
25
+ cloneProjectionDom,
24
26
  createProjectionDomLayerSerializer,
25
27
  createProjectionLayerSerializer,
26
28
  cssEscape,
@@ -43,6 +45,7 @@ import {
43
45
  nextRealmCaptureSequence,
44
46
  projectedElements,
45
47
  projectionLayerRoots,
48
+ readAstroMarker,
46
49
  readProjectionDomId,
47
50
  resolveCommittedFiber,
48
51
  sanitizeProps,
@@ -51,15 +54,12 @@ import {
51
54
  serializeTree,
52
55
  stripSourceAnnotations,
53
56
  syncProjectionDomIdsToClone,
57
+ trackAstroSources,
54
58
  underForeignProjectionRoot,
55
59
  watchDom,
56
60
  watchPortal,
57
61
  watchState
58
- } from "./chunk-TL4MGN7E.js";
59
- import {
60
- captureHead,
61
- getHeadTracker
62
- } from "./chunk-5BHIHP25.js";
62
+ } from "./chunk-NSKYOKG5.js";
63
63
  import {
64
64
  captureAttributes,
65
65
  captureWithSupplementalRoots,
@@ -73,7 +73,10 @@ import {
73
73
  registerDocumentCaptureProducer,
74
74
  removeScriptTags,
75
75
  resetCaptureFlushCounters
76
- } from "./chunk-N2TYN3RB.js";
76
+ } from "./chunk-6AAE4LYV.js";
77
+ import {
78
+ isTempoInteractFrameName
79
+ } from "./chunk-65B52AR7.js";
77
80
 
78
81
  // ../../modules/iframe-projection/combined/projection-repair-paths.ts
79
82
  function isProjectionRepairPaths(value) {
@@ -241,7 +244,7 @@ function captureFullDom(root, portals, observedFiles) {
241
244
  ensureProjectionDomId(element);
242
245
  }
243
246
  }
244
- const clone = root.cloneNode(true);
247
+ const clone = cloneProjectionDom(root);
245
248
  syncProjectionDomIdsToClone(root, clone);
246
249
  for (const script of clone.querySelectorAll("script")) script.remove();
247
250
  const hostDomIds = stripSourceAnnotations(clone, observedFiles, false);
@@ -250,7 +253,7 @@ function captureFullDom(root, portals, observedFiles) {
250
253
  if (!portal.isConnected) continue;
251
254
  const portalId = portal.getAttribute(PORTAL_ID_ATTR);
252
255
  if (!portalId) continue;
253
- const portalClone = portal.cloneNode(true);
256
+ const portalClone = cloneProjectionDom(portal);
254
257
  syncProjectionDomIdsToClone(portal, portalClone);
255
258
  for (const script of portalClone.querySelectorAll("script"))
256
259
  script.remove();
@@ -289,6 +292,8 @@ function collectFullRuntimeState(root, portals) {
289
292
  const states = [];
290
293
  for (const scope of [root, ...portals]) {
291
294
  for (const element of projectedElements(scope)) {
295
+ if (element !== scope && element.hasAttribute(PROJECTION_ROOT_ATTRIBUTE))
296
+ continue;
292
297
  const targetId = ensureProjectionDomId(element);
293
298
  if (!targetId) continue;
294
299
  if (element.scrollTop !== 0 || element.scrollLeft !== 0) {
@@ -365,6 +370,218 @@ function resolveRegionElement(root, targetId, portals) {
365
370
  return null;
366
371
  }
367
372
 
373
+ // ../../modules/iframe-projection/combined/projection-astro-layers.ts
374
+ var ASTRO_LAYER_ROOT_ID = "astro:$projection-root";
375
+ function createProjectionAstroLayerSerializer(island) {
376
+ const ids = /* @__PURE__ */ new WeakMap();
377
+ const id = (value) => {
378
+ let found = ids.get(value);
379
+ if (!found) {
380
+ found = nextProjectionId();
381
+ ids.set(value, found);
382
+ }
383
+ return found;
384
+ };
385
+ const domOwners = /* @__PURE__ */ new Map();
386
+ const identity = {
387
+ id: /* @__PURE__ */ new WeakMap(),
388
+ layerIdForElement: (_root, element) => id(element),
389
+ bindableDomIdForElement(_root, element) {
390
+ const value = ensureProjectionDomId(element);
391
+ if (!value) return null;
392
+ if (!domOwners.has(value)) domOwners.set(value, element);
393
+ return domOwners.get(value) === element ? value : null;
394
+ }
395
+ };
396
+ function session(root, files) {
397
+ const tracking = trackAstroSources(root.ownerDocument);
398
+ const observed = new ProjectionObservedFileAccumulator();
399
+ observed.merge(files);
400
+ for (const receipt of tracking.moduleSources())
401
+ observed.add(receipt.filepath, receipt.modifiedTs, receipt.sourceVersion);
402
+ const props = (element) => {
403
+ const live = {
404
+ ...captureProjectionDomLayerProps(element)
405
+ };
406
+ for (const { name, value } of element.attributes) {
407
+ if (name === "class" || name === "style" || name === "data-dom-id" || name === "data-host-layer-id" || name.startsWith("data-tempo-"))
408
+ continue;
409
+ live[name] = value;
410
+ }
411
+ const safe = tracking.owns(element);
412
+ const result = safe ? live : Object.fromEntries(
413
+ Object.entries(live ?? {}).filter(
414
+ ([key]) => !key.startsWith("data-tempo-") || key === "data-tempo-locked"
415
+ )
416
+ );
417
+ observed.addLayerProps(result);
418
+ return result;
419
+ };
420
+ const component = (node, boundary, children) => {
421
+ const source = boundary.source;
422
+ observed.add(source.filepath, source.modifiedTs, source.sourceVersion);
423
+ if (boundary.definition)
424
+ observed.add(
425
+ boundary.definition.filepath,
426
+ boundary.definition.modifiedTs,
427
+ boundary.definition.sourceVersion
428
+ );
429
+ return {
430
+ kind: "component",
431
+ runtime: "astro",
432
+ id: id(node),
433
+ key: null,
434
+ name: source.name,
435
+ domId: null,
436
+ elementTag: null,
437
+ source: {
438
+ kind: "react-fiber",
439
+ fiber: {
440
+ tag: FiberTag.FunctionComponent,
441
+ name: source.name,
442
+ id: id(node)
443
+ }
444
+ },
445
+ props: {
446
+ // Inspector edits are represented as JSON prop fields in the edit
447
+ // tree. Publish the compiler's literal callsite values after each
448
+ // reload so history can validate its inverse against fresh facts.
449
+ ...Object.fromEntries(
450
+ Object.entries(source.literalProps ?? {}).map(([name, value]) => [
451
+ `data-tempo-component-prop-${name}`,
452
+ JSON.stringify(value)
453
+ ])
454
+ ),
455
+ "data-tempo-filepath": source.filepath,
456
+ "data-tempo-position": source.position,
457
+ "data-tempo-modifiedts": source.modifiedTs,
458
+ "data-tempo-source-version": source.sourceVersion,
459
+ ...source.expressions !== void 0 ? { "data-tempo-expr": source.expressions } : {},
460
+ ...boundary.definition ? {
461
+ "data-tempo-component-reference": JSON.stringify([
462
+ "import",
463
+ boundary.definition.filepath,
464
+ boundary.definition.exportName ?? "default"
465
+ ])
466
+ } : {}
467
+ },
468
+ children
469
+ };
470
+ };
471
+ const list = (children) => {
472
+ const output = [];
473
+ const endings = /* @__PURE__ */ new Map();
474
+ for (const [index, node] of children.entries()) {
475
+ const marker = readAstroMarker(node);
476
+ if (marker?.kind === "e" && tracking.owns(node))
477
+ endings.set(marker.value.occurrence, index);
478
+ }
479
+ for (let at = 0; at < children.length; at++) {
480
+ const node = children[at];
481
+ const marker = readAstroMarker(node);
482
+ if (marker) {
483
+ if (marker.kind === "b" && tracking.owns(node)) {
484
+ const end = endings.get(marker.value.occurrence) ?? -1;
485
+ if (end > at) {
486
+ output.push(
487
+ component(
488
+ node,
489
+ marker.value,
490
+ list(children.slice(at + 1, end))
491
+ )
492
+ );
493
+ at = end;
494
+ }
495
+ }
496
+ continue;
497
+ }
498
+ if (node instanceof Element) {
499
+ if (node.localName === "script" || node.hasAttribute(PROJECTION_ROOT_ATTRIBUTE))
500
+ continue;
501
+ const tree = host(node);
502
+ if (tree) output.push(tree);
503
+ } else {
504
+ const tree = serializeDomLayerNode(root, node, identity);
505
+ if (tree) output.push(tree);
506
+ }
507
+ }
508
+ return output;
509
+ };
510
+ const host = (element) => {
511
+ const embedded = element.localName === "astro-island" ? island?.(element, observed.snapshot()) : null;
512
+ if (embedded) observed.merge(embedded.observedFiles);
513
+ const embeddedNodes = embedded?.semantic.kind === "scope" ? embedded.semantic.fragment.children : embedded?.semantic.kind === "layers" && embedded.semantic.tree ? [embedded.semantic.tree] : null;
514
+ const tree = serializeDomLayerNode(
515
+ root,
516
+ element,
517
+ identity,
518
+ void 0,
519
+ embeddedNodes ?? list([...element.childNodes])
520
+ );
521
+ return tree?.kind === "host" ? { ...tree, runtime: "astro", props: props(element) } : tree;
522
+ };
523
+ const rootTree = () => ({
524
+ kind: "fragment",
525
+ runtime: "astro",
526
+ id: id(root),
527
+ key: null,
528
+ name: "astro-root",
529
+ domId: null,
530
+ elementTag: null,
531
+ source: {
532
+ kind: "react-fiber",
533
+ fiber: {
534
+ tag: FiberTag.HostRoot,
535
+ name: "astro-root",
536
+ id: ASTRO_LAYER_ROOT_ID
537
+ }
538
+ },
539
+ props: props(root),
540
+ children: list([...root.childNodes])
541
+ });
542
+ return { props, host, rootTree, observed };
543
+ }
544
+ return {
545
+ serializeRoot(root, files = {}) {
546
+ const pass = session(root, files);
547
+ const tree = pass.rootTree();
548
+ return {
549
+ semantic: { kind: "layers", tree },
550
+ observedFiles: pass.observed.snapshot()
551
+ };
552
+ },
553
+ capturePatch(root, targets, files = {}) {
554
+ const pass = session(root, files);
555
+ const islandRoot = (target) => target.closest("astro-island") ?? target;
556
+ const structuralCandidates = [
557
+ ...targets.structural.map(islandRoot),
558
+ ...targets.metadata.filter((target) => target.closest("astro-island")).map(islandRoot)
559
+ ];
560
+ const structural = [...new Set(structuralCandidates)].filter(
561
+ (target) => (target === root || root.contains(target)) && !structuralCandidates.some(
562
+ (parent) => parent !== target && parent.contains(target)
563
+ )
564
+ );
565
+ const regions = structural.map((target) => ({
566
+ targetFiberId: target === root ? ASTRO_LAYER_ROOT_ID : id(target),
567
+ targetId: target === root ? id(root) : identity.bindableDomIdForElement(root, target) ?? id(target),
568
+ tree: target === root ? pass.rootTree() : pass.host(target),
569
+ observedFiles: pass.observed.snapshot()
570
+ }));
571
+ const metadata = targets.metadata.filter(
572
+ (target) => target !== root && root.contains(target) && !structural.some(
573
+ (parent) => parent === target || parent.contains(target)
574
+ )
575
+ ).map((target) => ({
576
+ targetFiberId: id(target),
577
+ targetId: identity.bindableDomIdForElement(root, target) ?? id(target),
578
+ props: pass.props(target)
579
+ }));
580
+ return regions.length || metadata.length ? { regions, metadata } : void 0;
581
+ }
582
+ };
583
+ }
584
+
368
585
  // ../../modules/iframe-projection/combined/enriched-to-serialized-fiber.ts
369
586
  function detachTagFromFiberTag(tag) {
370
587
  switch (tag) {
@@ -1250,6 +1467,38 @@ function createProjectionLayerAdapter(layerFramework, watchedRoot, scope) {
1250
1467
  },
1251
1468
  scope
1252
1469
  );
1470
+ case "astro": {
1471
+ if (!watchedRoot)
1472
+ throw new Error("The Astro layer adapter needs its watched root");
1473
+ const react = createReactLayerAdapter(watchedRoot, scope);
1474
+ const svelte = createProjectionSvelteLayerSerializer();
1475
+ const dom = createDomBackedLayerAdapter(
1476
+ "astro",
1477
+ createProjectionAstroLayerSerializer((element, files) => {
1478
+ const renderer = element.getAttribute("renderer-url") ?? "";
1479
+ if (renderer.includes("svelte"))
1480
+ return svelte.serializeRoot(element, files);
1481
+ if (renderer.includes("react") || getCommittedFiberRoots().some(
1482
+ ({ containerInfo }) => containerInfo === element
1483
+ ))
1484
+ return react.captureFull(element, element.firstElementChild, files).snapshot;
1485
+ return null;
1486
+ }),
1487
+ () => null,
1488
+ scope
1489
+ );
1490
+ return {
1491
+ ...react,
1492
+ ...dom,
1493
+ portalClosure: react.portalClosure,
1494
+ resolveCommittedRoot: react.resolveCommittedRoot,
1495
+ resolveElementCandidate: react.resolveElementCandidate,
1496
+ layerSourceId: react.layerSourceId,
1497
+ captureRegion: react.captureRegion,
1498
+ captureMetadata: react.captureMetadata,
1499
+ captureSemanticSubtree: (target, id, options) => react.captureSemanticSubtree(target, id, options) ?? dom.captureSemanticSubtree(target, id, options)
1500
+ };
1501
+ }
1253
1502
  case "dom":
1254
1503
  return createDomBackedLayerAdapter(
1255
1504
  "dom",
@@ -1436,6 +1685,7 @@ function fiberOrAncestor(fiber, candidate) {
1436
1685
  function createObservedLayerAdapter(watchedRoot, scope) {
1437
1686
  const react = createReactLayerAdapter(watchedRoot, scope);
1438
1687
  const svelte = createProjectionLayerAdapter("svelte", watchedRoot, scope);
1688
+ const astro = createProjectionLayerAdapter("astro", watchedRoot, scope);
1439
1689
  let active = react;
1440
1690
  return {
1441
1691
  portalClosure: (fiber) => active.portalClosure?.(fiber) ?? { required: false, nodesVisited: 0 },
@@ -1450,6 +1700,10 @@ function createObservedLayerAdapter(watchedRoot, scope) {
1450
1700
  capturePatch: (root, targets, files) => active.capturePatch(root, targets, files),
1451
1701
  resolveCommittedRoot(fiberRoot, target) {
1452
1702
  const root = target.element;
1703
+ if (trackAstroSources(root.ownerDocument).hasAstro()) {
1704
+ active = astro;
1705
+ return active.resolveCommittedRoot(fiberRoot, target);
1706
+ }
1453
1707
  let element = root;
1454
1708
  let svelteRoot = false;
1455
1709
  while (element) {
@@ -1498,7 +1752,42 @@ function createDomBackedLayerAdapter(layerFramework, serializer, readProblem, sc
1498
1752
  layerSourceId: () => null,
1499
1753
  captureRegion: () => null,
1500
1754
  captureMetadata: () => null,
1501
- captureSemanticSubtree: () => null
1755
+ captureSemanticSubtree(target, id, options) {
1756
+ if (layerFramework !== "astro") return null;
1757
+ const roots = projectionLayerRoots(
1758
+ serializer.serializeRoot(target.element)
1759
+ );
1760
+ const find = (nodes) => {
1761
+ for (const node of nodes) {
1762
+ if (node.id === id) return node;
1763
+ const child = find(node.children ?? []);
1764
+ if (child) return child;
1765
+ }
1766
+ };
1767
+ const selected = typeof id === "string" ? find(roots) : roots[0];
1768
+ if (!selected) return null;
1769
+ let count = 0;
1770
+ const serialize = (node, parent) => {
1771
+ count++;
1772
+ const props = Object.fromEntries(
1773
+ Object.entries(node.props ?? {}).filter(
1774
+ ([name, value]) => name.startsWith("data-tempo-") && ["string", "number", "boolean"].includes(typeof value)
1775
+ )
1776
+ );
1777
+ const file = props["data-tempo-filepath"], position = Number(props["data-tempo-position"]);
1778
+ return {
1779
+ fiber_id: node.id,
1780
+ name: node.name ?? "#text",
1781
+ tag: node.kind === "component" ? "function" : node.kind,
1782
+ owner_fiber_id: parent,
1783
+ props: node.content === void 0 ? props : { ...props, text: node.content },
1784
+ ...typeof file === "string" && Number.isSafeInteger(position) ? { source: { file, position } } : {},
1785
+ children: options?.descendants === false || count > 5e3 ? [] : (node.children ?? []).map((child) => serialize(child, node.id))
1786
+ };
1787
+ };
1788
+ const captured = serialize(selected, null);
1789
+ return { ...captured, ...count > 5e3 ? { truncated: true } : {} };
1790
+ }
1502
1791
  };
1503
1792
  }
1504
1793
  function countLayerNodes(snapshot) {
@@ -1565,7 +1854,7 @@ function normalizeContentsPatch(patch, scope) {
1565
1854
  return {
1566
1855
  ...patch,
1567
1856
  regions: patch.regions?.map(
1568
- (region) => region.targetFiberId === DOM_LAYER_ROOT_ID || region.targetFiberId === SVELTE_LAYER_ROOT_ID ? {
1857
+ (region) => region.targetFiberId === DOM_LAYER_ROOT_ID || region.targetFiberId === SVELTE_LAYER_ROOT_ID || region.targetFiberId === ASTRO_LAYER_ROOT_ID ? {
1569
1858
  ...region,
1570
1859
  targetId: PROJECTION_SCOPE_TARGET,
1571
1860
  tree: null,
@@ -1651,10 +1940,15 @@ function createProjectionFixedWindow(options) {
1651
1940
  };
1652
1941
  }
1653
1942
  function createProjectionOutbox(options) {
1943
+ const rootLimit = options.maxRootsPerFlush ?? Infinity;
1944
+ if (rootLimit < 1 || rootLimit !== Infinity && !Number.isInteger(rootLimit))
1945
+ throw new Error("maxRootsPerFlush must be a positive integer");
1654
1946
  const roots = /* @__PURE__ */ new Set();
1947
+ const headProofRoots = /* @__PURE__ */ new Set();
1655
1948
  const dirty = /* @__PURE__ */ new Set();
1656
1949
  const full = /* @__PURE__ */ new Set();
1657
1950
  const requested = /* @__PURE__ */ new Set();
1951
+ const foregroundRoots = /* @__PURE__ */ new Set();
1658
1952
  const assets = /* @__PURE__ */ new Set();
1659
1953
  const sizes = /* @__PURE__ */ new Map();
1660
1954
  const emittedSizes = /* @__PURE__ */ new Map();
@@ -1679,7 +1973,7 @@ function createProjectionOutbox(options) {
1679
1973
  return size !== void 0 && (size.width !== emitted?.width || size.height !== emitted?.height);
1680
1974
  };
1681
1975
  const gated = (rootId) => credited.has(rootId) && awaitingAck.has(rootId) && !full.has(rootId);
1682
- const hasWork = () => dirtyHead || dirtyModules || dirtyHeadRoots.size > 0 || [...dirty].some((rootId) => !gated(rootId)) || assets.size > 0 || [...roots].some(sizePending);
1976
+ const hasWork = () => roots.size > 0 && (dirtyHead || dirtyModules || dirtyHeadRoots.size > 0 || [...dirty].some((rootId) => !gated(rootId)) || assets.size > 0 || [...roots].some(sizePending));
1683
1977
  const report = (error) => {
1684
1978
  try {
1685
1979
  options.onError?.(error);
@@ -1710,7 +2004,7 @@ function createProjectionOutbox(options) {
1710
2004
  const activeSession = sessionId;
1711
2005
  if (stopped || !activeSession || !hasWork()) return;
1712
2006
  const requestedRoots = [...requested].filter((rootId) => dirty.has(rootId));
1713
- const rootIds = (requestedRoots.length && sequence > 0 ? requestedRoots : [...dirty]).filter((rootId) => !gated(rootId));
2007
+ const rootIds = (requestedRoots.length ? requestedRoots : [...dirty]).filter((rootId) => !gated(rootId)).slice(0, rootLimit);
1714
2008
  const fullRootIds = new Set(full);
1715
2009
  const includeHeadForAllRoots = dirtyHead;
1716
2010
  const headRootIds = includeHeadForAllRoots ? [] : [...dirtyHeadRoots];
@@ -1786,6 +2080,9 @@ function createProjectionOutbox(options) {
1786
2080
  sessionId: activeSession,
1787
2081
  sequence: emittedSequence,
1788
2082
  ...head === void 0 ? {} : { head, headRevision },
2083
+ ...head === void 0 && changes.some(
2084
+ (root) => root.kind === "full" && headProofRoots.has(root.rootId)
2085
+ ) ? { headRevision } : {},
1789
2086
  ...head !== void 0 && emittedHeadRootIds.length > 0 ? { headRootIds: emittedHeadRootIds } : {},
1790
2087
  roots: changes,
1791
2088
  ...Object.keys(batchSizes).length > 0 ? { sizes: batchSizes } : {},
@@ -1822,6 +2119,7 @@ function createProjectionOutbox(options) {
1822
2119
  currentTriggers
1823
2120
  );
1824
2121
  }
2122
+ if (rootLimit !== Infinity && hasWork()) fixedWindow.schedule();
1825
2123
  };
1826
2124
  fixedWindow = createProjectionFixedWindow({
1827
2125
  scheduler: options.scheduler,
@@ -1854,14 +2152,17 @@ function createProjectionOutbox(options) {
1854
2152
  for (const rootId of roots.keys()) {
1855
2153
  dirty.add(rootId);
1856
2154
  full.add(rootId);
2155
+ if (foregroundRoots.has(rootId)) requested.add(rootId);
1857
2156
  }
1858
2157
  fixedWindow.schedule();
1859
2158
  },
1860
- addRoot(rootId, receiverCredit = false) {
2159
+ addRoot(rootId, receiverCredit = false, userInitiated = false, knownHead) {
1861
2160
  assertActive();
1862
2161
  if (!rootId) throw new Error("Projection root ID must not be empty");
1863
2162
  if (roots.has(rootId)) return;
1864
2163
  roots.add(rootId);
2164
+ if (knownHead) headProofRoots.add(rootId);
2165
+ if (userInitiated) foregroundRoots.add(rootId);
1865
2166
  if (receiverCredit) {
1866
2167
  requiredCredit.add(rootId);
1867
2168
  credited.add(rootId);
@@ -1870,8 +2171,13 @@ function createProjectionOutbox(options) {
1870
2171
  dirty.add(rootId);
1871
2172
  full.add(rootId);
1872
2173
  triggerReasons.add("root-added");
1873
- if (!dirtyHead) dirtyHeadRoots.add(rootId);
1874
- if (sequence === 0) fixedWindow.schedule();
2174
+ if (!dirtyHead && (!knownHead || knownHead.sessionId !== sessionId || knownHead.headRevision !== headRevision))
2175
+ dirtyHeadRoots.add(rootId);
2176
+ if (userInitiated) {
2177
+ requested.add(rootId);
2178
+ fixedWindow.flushNow();
2179
+ } else if (sequence === 0 || rootLimit !== Infinity)
2180
+ fixedWindow.schedule();
1875
2181
  else fixedWindow.flushNow();
1876
2182
  },
1877
2183
  setRootSize(rootId, size) {
@@ -1883,10 +2189,12 @@ function createProjectionOutbox(options) {
1883
2189
  if (sessionId) fixedWindow.schedule();
1884
2190
  },
1885
2191
  removeRoot(rootId) {
2192
+ foregroundRoots.delete(rootId);
1886
2193
  if (stopped) return;
1887
2194
  sizes.delete(rootId);
1888
2195
  emittedSizes.delete(rootId);
1889
2196
  roots.delete(rootId);
2197
+ headProofRoots.delete(rootId);
1890
2198
  rootRevisions.delete(rootId);
1891
2199
  awaitingAck.delete(rootId);
1892
2200
  credited.delete(rootId);
@@ -1897,12 +2205,16 @@ function createProjectionOutbox(options) {
1897
2205
  full.delete(rootId);
1898
2206
  dirtyHeadRoots.delete(rootId);
1899
2207
  if (!hasWork()) {
1900
- if (roots.size === 0) fixedWindow.cancel();
2208
+ if (roots.size === 0) {
2209
+ fixedWindow.cancel();
2210
+ dirtyHead = false;
2211
+ dirtyModules = false;
2212
+ }
1901
2213
  triggerReasons.clear();
1902
2214
  }
1903
2215
  },
1904
2216
  record(activity) {
1905
- if (stopped || !sessionId) return;
2217
+ if (stopped || !sessionId || roots.size === 0) return;
1906
2218
  dirtyHead || (dirtyHead = activity.head === true);
1907
2219
  dirtyModules || (dirtyModules = activity.modules === true);
1908
2220
  for (const id of activity.assetRootIds ?? [])
@@ -1918,6 +2230,7 @@ function createProjectionOutbox(options) {
1918
2230
  if (!sessionId || !roots.has(rootId)) return;
1919
2231
  awaitingAck.delete(rootId);
1920
2232
  dirty.add(rootId);
2233
+ requested.add(rootId);
1921
2234
  triggerReasons.add("receiver-baseline");
1922
2235
  fixedWindow.flushNow();
1923
2236
  },
@@ -1945,6 +2258,8 @@ function createProjectionOutbox(options) {
1945
2258
  stopped = true;
1946
2259
  fixedWindow.stop();
1947
2260
  roots.clear();
2261
+ headProofRoots.clear();
2262
+ foregroundRoots.clear();
1948
2263
  sizes.clear();
1949
2264
  emittedSizes.clear();
1950
2265
  rootRevisions.clear();
@@ -1994,6 +2309,7 @@ function findOwnedPortalRoots(root) {
1994
2309
  portals.push(candidate);
1995
2310
  return;
1996
2311
  }
2312
+ if (candidate.hasAttribute(PROJECTION_ROOT_ATTRIBUTE)) return;
1997
2313
  for (const child of Array.from(candidate.children)) visit(child);
1998
2314
  };
1999
2315
  for (const child of Array.from(body.children)) visit(child);
@@ -2120,6 +2436,7 @@ var PortalTrackerImpl = class {
2120
2436
  ];
2121
2437
  if (eligibleWatchers.length === 0) return;
2122
2438
  const matchedWatchers = this.checkElement(element, eligibleWatchers);
2439
+ if (element.hasAttribute(PROJECTION_ROOT_ATTRIBUTE)) return;
2123
2440
  const descendantSettled = settledWatchers.filter(
2124
2441
  (watcher) => !matchedWatchers.has(watcher)
2125
2442
  );
@@ -2607,6 +2924,7 @@ function createCombinedDocumentProducer(options) {
2607
2924
  scheduler: options.scheduler,
2608
2925
  flushWindowMs: options.flushWindowMs,
2609
2926
  keepArmed: options.keepArmed,
2927
+ maxRootsPerFlush: options.maxRootsPerFlush,
2610
2928
  onError: options.onError,
2611
2929
  captureRoot(rootId, flushContext) {
2612
2930
  readModuleEvaluations();
@@ -2622,6 +2940,7 @@ function createCombinedDocumentProducer(options) {
2622
2940
  };
2623
2941
  }
2624
2942
  const accumulator = runtime.accumulator;
2943
+ const openingRoot = runtime.publishedLayerFramework === null;
2625
2944
  const observation = accumulator.perfSnapshot();
2626
2945
  resetCaptureFlushCounters();
2627
2946
  const captureStartedAt = Date.now();
@@ -2644,7 +2963,7 @@ function createCombinedDocumentProducer(options) {
2644
2963
  portals: 0,
2645
2964
  observedFiles: 0,
2646
2965
  candidatesAfter: 0,
2647
- fullReason: fullReason(flushContext)
2966
+ fullReason: fullReason(flushContext, openingRoot)
2648
2967
  })
2649
2968
  });
2650
2969
  return { kind: "problem", problem: renderError };
@@ -2754,7 +3073,7 @@ function createCombinedDocumentProducer(options) {
2754
3073
  portals: snapshot.dom.portals.length,
2755
3074
  observedFiles: Object.keys(snapshot.observedFiles).length,
2756
3075
  candidatesAfter: 1,
2757
- fullReason: fullReason(flushContext)
3076
+ fullReason: fullReason(flushContext, openingRoot)
2758
3077
  })
2759
3078
  });
2760
3079
  return {
@@ -2791,7 +3110,9 @@ function createCombinedDocumentProducer(options) {
2791
3110
  }
2792
3111
  if (fullRequested || repairNeedsFull) {
2793
3112
  const accumulated2 = runtime.accumulator.capturePatch();
2794
- const unchanged = accumulated2.kind === "empty" && runtime.pendingRegions.size === 0 && runtime.pendingMetadata.size === 0 && !endedSuspendedEpisode && !recoveredFromLayerProblem && runtime.publishedLayerFramework === runtime.layerAdapter.layerFramework;
3113
+ const unchanged = accumulated2.kind === "empty" && runtime.pendingRegions.size === 0 && (runtime.pendingMetadata.size === 0 || [...runtime.pendingMetadata.values()].every(
3114
+ (entry) => entry.layoutOnly
3115
+ ) && captureSemanticMetadata(runtime, /* @__PURE__ */ new Set()).length === 0) && !endedSuspendedEpisode && !recoveredFromLayerProblem && runtime.publishedLayerFramework === runtime.layerAdapter.layerFramework;
2795
3116
  return serveFull(unchanged);
2796
3117
  }
2797
3118
  let accumulated = runtime.accumulator.capturePatch({
@@ -3275,7 +3596,14 @@ function createCombinedDocumentProducer(options) {
3275
3596
  roots.set(rootOptions.rootId, runtime);
3276
3597
  try {
3277
3598
  startRootObserver(rootOptions.rootId, runtime);
3278
- core.addRoot(rootOptions.rootId, rootOptions.receiverCredit);
3599
+ if (rootOptions.knownHead)
3600
+ getHeadTracker().flushPending?.(options.document);
3601
+ core.addRoot(
3602
+ rootOptions.rootId,
3603
+ rootOptions.receiverCredit,
3604
+ rootOptions.userInitiated,
3605
+ rootOptions.knownHead
3606
+ );
3279
3607
  syncRootLifecycleObserver();
3280
3608
  } catch (error) {
3281
3609
  roots.delete(rootOptions.rootId);
@@ -3443,6 +3771,10 @@ function collectChangedSemanticFibers(previous, current, runtime) {
3443
3771
  runtime.publishedHostProps
3444
3772
  )) {
3445
3773
  addMetadata(runtime, after, "fiber");
3774
+ } else if (after.tag === FiberTag.HostComponent && runtime.publishedHostProps.has(
3775
+ runtime.layerAdapter.layerSourceId(after) ?? ""
3776
+ )) {
3777
+ addMetadata(runtime, after, "fiber", true);
3446
3778
  }
3447
3779
  if (before.child === after.child) return;
3448
3780
  let oldChild = before.child;
@@ -3520,7 +3852,7 @@ function addRegion(runtime, fiber) {
3520
3852
  }
3521
3853
  runtime.pendingRegions.set(id, fiber);
3522
3854
  }
3523
- function addMetadata(runtime, fiber, sourceAnnotations) {
3855
+ function addMetadata(runtime, fiber, sourceAnnotations, layoutOnly = false) {
3524
3856
  if (!isProjectionLayerFiber(fiber)) return;
3525
3857
  if (runtime.options.scope === "contents" && runtime.committedFiber && fiberPair(fiber, runtime.committedFiber))
3526
3858
  return;
@@ -3534,6 +3866,7 @@ function addMetadata(runtime, fiber, sourceAnnotations) {
3534
3866
  const existing = runtime.pendingMetadata.get(id);
3535
3867
  runtime.pendingMetadata.set(id, {
3536
3868
  fiber,
3869
+ layoutOnly: layoutOnly && (existing?.layoutOnly ?? true),
3537
3870
  sourceAnnotations: existing?.sourceAnnotations === "live-host" || sourceAnnotations === "live-host" ? "live-host" : "fiber"
3538
3871
  });
3539
3872
  }
@@ -3551,12 +3884,11 @@ function fiberContains(ancestor, candidate) {
3551
3884
  return false;
3552
3885
  }
3553
3886
  function projectionPropsEqual(before, after, adapter, publishedHostProps) {
3554
- const right = adapter.captureMetadata(after)?.props;
3555
- const left = adapter.captureMetadata(before, {
3556
- layoutMode: right?.layoutMode ?? null
3557
- })?.props;
3558
3887
  const id = adapter.layerSourceId(after);
3559
3888
  const published = id === null ? void 0 : publishedHostProps.get(id);
3889
+ const layoutMode = published?.layoutMode ?? null;
3890
+ const right = adapter.captureMetadata(after, { layoutMode })?.props;
3891
+ const left = adapter.captureMetadata(before, { layoutMode })?.props;
3560
3892
  const liveHostPropsEqual = published === void 0 || published.className === right?.className && published.layoutMode === right?.layoutMode && recordEqual(published.style, right?.style);
3561
3893
  return liveHostPropsEqual && layerPropsEqual(left, right);
3562
3894
  }
@@ -3692,6 +4024,8 @@ function captureSemanticMetadata(runtime, coveredFibers) {
3692
4024
  sourceAnnotations: retained.sourceAnnotations
3693
4025
  });
3694
4026
  if (metadata) {
4027
+ if (retained.layoutOnly && runtime.publishedHostProps.get(metadata.targetFiberId)?.layoutMode === metadata.props?.layoutMode)
4028
+ continue;
3695
4029
  snapshots.push(metadata);
3696
4030
  updatePublishedMetadata(runtime, metadata);
3697
4031
  }
@@ -3710,8 +4044,8 @@ function patchHtmlChars(patch) {
3710
4044
  }
3711
4045
  return chars;
3712
4046
  }
3713
- function fullReason(context) {
3714
- return context.initialForSession ? "initial" : "explicit-full";
4047
+ function fullReason(context, openingRoot) {
4048
+ return context.initialForSession ? "initial" : openingRoot ? "root-added" : "explicit-full";
3715
4049
  }
3716
4050
  function makePerf(input) {
3717
4051
  return buildProjectionCapturePerf({
@@ -3783,6 +4117,7 @@ function aggregateBatchPerf(roots, head, context, capturedHeadMs, rootsPerBatch,
3783
4117
  flushStartedAt,
3784
4118
  flushMs: Date.now() - flushStartedAt,
3785
4119
  snapshotMs: sum((perf) => perf.snapshotMs) + capturedHeadMs,
4120
+ headSnapshotMs: capturedHeadMs,
3786
4121
  identityMs: sum((perf) => perf.identityMs),
3787
4122
  identityNodesVisited: sum((perf) => perf.identityNodesVisited),
3788
4123
  sourceVersionDomScanNodes: sum((perf) => perf.sourceVersionDomScanNodes),
@@ -3842,7 +4177,7 @@ function aggregateBatchPerf(roots, head, context, capturedHeadMs, rootsPerBatch,
3842
4177
 
3843
4178
  // ../../modules/iframe-projection/combined/layer-framework.ts
3844
4179
  function isLayerFramework(value) {
3845
- return value === "react" || value === "svelte" || value === "dom" || value === "auto";
4180
+ return value === "react" || value === "svelte" || value === "astro" || value === "dom" || value === "auto";
3846
4181
  }
3847
4182
 
3848
4183
  // ../../modules/iframe-projection/combined/projection-batch.ts
@@ -4871,6 +5206,7 @@ function createProjectionSourceController(options) {
4871
5206
  };
4872
5207
  }
4873
5208
  function startCombinedSourceInterface(options = {}) {
5209
+ if (typeof document !== "undefined") trackAstroSources(document);
4874
5210
  const { targetOrigin = "*", serialize, hideFiberProp } = options;
4875
5211
  if (combinedSourceInitialized) {
4876
5212
  console.warn("[combined-postmessage:source] Already initialized");
@@ -6083,4 +6419,4 @@ function installTempoInteractProjectionSource() {
6083
6419
  export {
6084
6420
  installTempoInteractProjectionSource
6085
6421
  };
6086
- //# sourceMappingURL=chunk-MXKZZOLM.js.map
6422
+ //# sourceMappingURL=chunk-EYKOOLPL.js.map