tempo-sdk 0.0.57 → 0.0.66

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 +12 -32
  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 +749 -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 +4 -2
  32. package/dist/canvas/index.js +138 -34
  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-U3SLJNRS.js → chunk-6IR5JY6W.js} +106 -7
  44. package/dist/chunk-6IR5JY6W.js.map +1 -0
  45. package/dist/{chunk-QXL6GL2P.js → chunk-6W6UKDSY.js} +46 -5
  46. package/dist/chunk-6W6UKDSY.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-DELFOKU3.js +2495 -0
  50. package/dist/chunk-DELFOKU3.js.map +1 -0
  51. package/dist/{chunk-U64AHDHZ.js → chunk-EYKOOLPL.js} +380 -34
  52. package/dist/chunk-EYKOOLPL.js.map +1 -0
  53. package/dist/chunk-F23JGM4U.js +107 -0
  54. package/dist/chunk-F23JGM4U.js.map +1 -0
  55. package/dist/chunk-FE6TYCLF.js +1514 -0
  56. package/dist/chunk-FE6TYCLF.js.map +1 -0
  57. package/dist/chunk-H6OZIX2U.js +133 -0
  58. package/dist/chunk-H6OZIX2U.js.map +1 -0
  59. package/dist/chunk-JVVHU3A7.js +1077 -0
  60. package/dist/chunk-JVVHU3A7.js.map +1 -0
  61. package/dist/{chunk-2IQD2KPS.js → chunk-KOSJXE4G.js} +3 -102
  62. package/dist/chunk-KOSJXE4G.js.map +1 -0
  63. package/dist/{chunk-TL4MGN7E.js → chunk-NSKYOKG5.js} +254 -10
  64. package/dist/chunk-NSKYOKG5.js.map +1 -0
  65. package/dist/chunk-OX2YKYSL.js +13 -0
  66. package/dist/chunk-OX2YKYSL.js.map +1 -0
  67. package/dist/{chunk-RHHVVWAC.js → chunk-PXDTH36X.js} +14 -12
  68. package/dist/chunk-PXDTH36X.js.map +1 -0
  69. package/dist/{chunk-XLEKCOB7.js → chunk-PYAJHLXO.js} +56 -1
  70. package/dist/chunk-PYAJHLXO.js.map +1 -0
  71. package/dist/{chunk-EMYYTS6D.js → chunk-Q2A46HHW.js} +19 -14
  72. package/dist/chunk-Q2A46HHW.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 +18 -13
  77. package/dist/expo/plugin.cjs.map +1 -1
  78. package/dist/expo/plugin.js +1 -1
  79. package/dist/expo-babel-plugin.cjs +18 -13
  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 -2294
  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 +63 -17
  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-BtQuVGpl.d.ts → storyboard-4YdTYq_e.d.ts} +3 -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-EMYYTS6D.js.map +0 -1
  102. package/dist/chunk-N2TYN3RB.js.map +0 -1
  103. package/dist/chunk-QXL6GL2P.js.map +0 -1
  104. package/dist/chunk-RHHVVWAC.js.map +0 -1
  105. package/dist/chunk-TL4MGN7E.js.map +0 -1
  106. package/dist/chunk-U3SLJNRS.js.map +0 -1
  107. package/dist/chunk-U64AHDHZ.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,9 +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();
1950
+ const requested = /* @__PURE__ */ new Set();
1951
+ const foregroundRoots = /* @__PURE__ */ new Set();
1657
1952
  const assets = /* @__PURE__ */ new Set();
1658
1953
  const sizes = /* @__PURE__ */ new Map();
1659
1954
  const emittedSizes = /* @__PURE__ */ new Map();
@@ -1678,7 +1973,7 @@ function createProjectionOutbox(options) {
1678
1973
  return size !== void 0 && (size.width !== emitted?.width || size.height !== emitted?.height);
1679
1974
  };
1680
1975
  const gated = (rootId) => credited.has(rootId) && awaitingAck.has(rootId) && !full.has(rootId);
1681
- 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));
1682
1977
  const report = (error) => {
1683
1978
  try {
1684
1979
  options.onError?.(error);
@@ -1708,7 +2003,8 @@ function createProjectionOutbox(options) {
1708
2003
  const flushOnce = (timing) => {
1709
2004
  const activeSession = sessionId;
1710
2005
  if (stopped || !activeSession || !hasWork()) return;
1711
- const rootIds = [...dirty].filter((rootId) => !gated(rootId));
2006
+ const requestedRoots = [...requested].filter((rootId) => dirty.has(rootId));
2007
+ const rootIds = (requestedRoots.length ? requestedRoots : [...dirty]).filter((rootId) => !gated(rootId)).slice(0, rootLimit);
1712
2008
  const fullRootIds = new Set(full);
1713
2009
  const includeHeadForAllRoots = dirtyHead;
1714
2010
  const headRootIds = includeHeadForAllRoots ? [] : [...dirtyHeadRoots];
@@ -1723,8 +2019,11 @@ function createProjectionOutbox(options) {
1723
2019
  fullRequested: false,
1724
2020
  triggerReasons: currentTriggers
1725
2021
  };
1726
- for (const rootId of rootIds) dirty.delete(rootId);
1727
- full.clear();
2022
+ for (const rootId of rootIds) {
2023
+ dirty.delete(rootId);
2024
+ full.delete(rootId);
2025
+ requested.delete(rootId);
2026
+ }
1728
2027
  dirtyHead = false;
1729
2028
  const includeModules = dirtyModules;
1730
2029
  dirtyModules = false;
@@ -1781,6 +2080,9 @@ function createProjectionOutbox(options) {
1781
2080
  sessionId: activeSession,
1782
2081
  sequence: emittedSequence,
1783
2082
  ...head === void 0 ? {} : { head, headRevision },
2083
+ ...head === void 0 && changes.some(
2084
+ (root) => root.kind === "full" && headProofRoots.has(root.rootId)
2085
+ ) ? { headRevision } : {},
1784
2086
  ...head !== void 0 && emittedHeadRootIds.length > 0 ? { headRootIds: emittedHeadRootIds } : {},
1785
2087
  roots: changes,
1786
2088
  ...Object.keys(batchSizes).length > 0 ? { sizes: batchSizes } : {},
@@ -1817,6 +2119,7 @@ function createProjectionOutbox(options) {
1817
2119
  currentTriggers
1818
2120
  );
1819
2121
  }
2122
+ if (rootLimit !== Infinity && hasWork()) fixedWindow.schedule();
1820
2123
  };
1821
2124
  fixedWindow = createProjectionFixedWindow({
1822
2125
  scheduler: options.scheduler,
@@ -1837,6 +2140,7 @@ function createProjectionOutbox(options) {
1837
2140
  for (const rootId of requiredCredit) credited.add(rootId);
1838
2141
  emittedSizes.clear();
1839
2142
  dirty.clear();
2143
+ requested.clear();
1840
2144
  assets.clear();
1841
2145
  full.clear();
1842
2146
  dirtyHeadRoots.clear();
@@ -1848,14 +2152,17 @@ function createProjectionOutbox(options) {
1848
2152
  for (const rootId of roots.keys()) {
1849
2153
  dirty.add(rootId);
1850
2154
  full.add(rootId);
2155
+ if (foregroundRoots.has(rootId)) requested.add(rootId);
1851
2156
  }
1852
2157
  fixedWindow.schedule();
1853
2158
  },
1854
- addRoot(rootId, receiverCredit = false) {
2159
+ addRoot(rootId, receiverCredit = false, userInitiated = false, knownHead) {
1855
2160
  assertActive();
1856
2161
  if (!rootId) throw new Error("Projection root ID must not be empty");
1857
2162
  if (roots.has(rootId)) return;
1858
2163
  roots.add(rootId);
2164
+ if (knownHead) headProofRoots.add(rootId);
2165
+ if (userInitiated) foregroundRoots.add(rootId);
1859
2166
  if (receiverCredit) {
1860
2167
  requiredCredit.add(rootId);
1861
2168
  credited.add(rootId);
@@ -1864,8 +2171,13 @@ function createProjectionOutbox(options) {
1864
2171
  dirty.add(rootId);
1865
2172
  full.add(rootId);
1866
2173
  triggerReasons.add("root-added");
1867
- if (!dirtyHead) dirtyHeadRoots.add(rootId);
1868
- 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();
1869
2181
  else fixedWindow.flushNow();
1870
2182
  },
1871
2183
  setRootSize(rootId, size) {
@@ -1877,25 +2189,32 @@ function createProjectionOutbox(options) {
1877
2189
  if (sessionId) fixedWindow.schedule();
1878
2190
  },
1879
2191
  removeRoot(rootId) {
2192
+ foregroundRoots.delete(rootId);
1880
2193
  if (stopped) return;
1881
2194
  sizes.delete(rootId);
1882
2195
  emittedSizes.delete(rootId);
1883
2196
  roots.delete(rootId);
2197
+ headProofRoots.delete(rootId);
1884
2198
  rootRevisions.delete(rootId);
1885
2199
  awaitingAck.delete(rootId);
1886
2200
  credited.delete(rootId);
1887
2201
  requiredCredit.delete(rootId);
1888
2202
  dirty.delete(rootId);
2203
+ requested.delete(rootId);
1889
2204
  assets.delete(rootId);
1890
2205
  full.delete(rootId);
1891
2206
  dirtyHeadRoots.delete(rootId);
1892
2207
  if (!hasWork()) {
1893
- if (roots.size === 0) fixedWindow.cancel();
2208
+ if (roots.size === 0) {
2209
+ fixedWindow.cancel();
2210
+ dirtyHead = false;
2211
+ dirtyModules = false;
2212
+ }
1894
2213
  triggerReasons.clear();
1895
2214
  }
1896
2215
  },
1897
2216
  record(activity) {
1898
- if (stopped || !sessionId) return;
2217
+ if (stopped || !sessionId || roots.size === 0) return;
1899
2218
  dirtyHead || (dirtyHead = activity.head === true);
1900
2219
  dirtyModules || (dirtyModules = activity.modules === true);
1901
2220
  for (const id of activity.assetRootIds ?? [])
@@ -1911,6 +2230,7 @@ function createProjectionOutbox(options) {
1911
2230
  if (!sessionId || !roots.has(rootId)) return;
1912
2231
  awaitingAck.delete(rootId);
1913
2232
  dirty.add(rootId);
2233
+ requested.add(rootId);
1914
2234
  triggerReasons.add("receiver-baseline");
1915
2235
  fixedWindow.flushNow();
1916
2236
  },
@@ -1918,10 +2238,12 @@ function createProjectionOutbox(options) {
1918
2238
  assertActive();
1919
2239
  if (!sessionId || !roots.has(rootId)) return;
1920
2240
  dirty.add(rootId);
2241
+ requested.add(rootId);
1921
2242
  full.add(rootId);
1922
2243
  triggerReasons.add(options2?.trigger ?? "receiver-baseline");
1923
2244
  if (options2?.includeHead && !dirtyHead) dirtyHeadRoots.add(rootId);
1924
2245
  fixedWindow.flushNow();
2246
+ if (hasWork()) fixedWindow.schedule();
1925
2247
  },
1926
2248
  acknowledge(ackSessionId, rootId, ackSequence) {
1927
2249
  if (stopped || !sessionId || ackSessionId !== sessionId || !roots.has(rootId))
@@ -1936,6 +2258,8 @@ function createProjectionOutbox(options) {
1936
2258
  stopped = true;
1937
2259
  fixedWindow.stop();
1938
2260
  roots.clear();
2261
+ headProofRoots.clear();
2262
+ foregroundRoots.clear();
1939
2263
  sizes.clear();
1940
2264
  emittedSizes.clear();
1941
2265
  rootRevisions.clear();
@@ -1945,6 +2269,7 @@ function createProjectionOutbox(options) {
1945
2269
  lastHead = void 0;
1946
2270
  assets.clear();
1947
2271
  dirty.clear();
2272
+ requested.clear();
1948
2273
  full.clear();
1949
2274
  dirtyHeadRoots.clear();
1950
2275
  dirtyHead = false;
@@ -1984,6 +2309,7 @@ function findOwnedPortalRoots(root) {
1984
2309
  portals.push(candidate);
1985
2310
  return;
1986
2311
  }
2312
+ if (candidate.hasAttribute(PROJECTION_ROOT_ATTRIBUTE)) return;
1987
2313
  for (const child of Array.from(candidate.children)) visit(child);
1988
2314
  };
1989
2315
  for (const child of Array.from(body.children)) visit(child);
@@ -2110,6 +2436,7 @@ var PortalTrackerImpl = class {
2110
2436
  ];
2111
2437
  if (eligibleWatchers.length === 0) return;
2112
2438
  const matchedWatchers = this.checkElement(element, eligibleWatchers);
2439
+ if (element.hasAttribute(PROJECTION_ROOT_ATTRIBUTE)) return;
2113
2440
  const descendantSettled = settledWatchers.filter(
2114
2441
  (watcher) => !matchedWatchers.has(watcher)
2115
2442
  );
@@ -2597,6 +2924,7 @@ function createCombinedDocumentProducer(options) {
2597
2924
  scheduler: options.scheduler,
2598
2925
  flushWindowMs: options.flushWindowMs,
2599
2926
  keepArmed: options.keepArmed,
2927
+ maxRootsPerFlush: options.maxRootsPerFlush,
2600
2928
  onError: options.onError,
2601
2929
  captureRoot(rootId, flushContext) {
2602
2930
  readModuleEvaluations();
@@ -2612,6 +2940,7 @@ function createCombinedDocumentProducer(options) {
2612
2940
  };
2613
2941
  }
2614
2942
  const accumulator = runtime.accumulator;
2943
+ const openingRoot = runtime.publishedLayerFramework === null;
2615
2944
  const observation = accumulator.perfSnapshot();
2616
2945
  resetCaptureFlushCounters();
2617
2946
  const captureStartedAt = Date.now();
@@ -2634,7 +2963,7 @@ function createCombinedDocumentProducer(options) {
2634
2963
  portals: 0,
2635
2964
  observedFiles: 0,
2636
2965
  candidatesAfter: 0,
2637
- fullReason: fullReason(flushContext)
2966
+ fullReason: fullReason(flushContext, openingRoot)
2638
2967
  })
2639
2968
  });
2640
2969
  return { kind: "problem", problem: renderError };
@@ -2744,7 +3073,7 @@ function createCombinedDocumentProducer(options) {
2744
3073
  portals: snapshot.dom.portals.length,
2745
3074
  observedFiles: Object.keys(snapshot.observedFiles).length,
2746
3075
  candidatesAfter: 1,
2747
- fullReason: fullReason(flushContext)
3076
+ fullReason: fullReason(flushContext, openingRoot)
2748
3077
  })
2749
3078
  });
2750
3079
  return {
@@ -2781,7 +3110,9 @@ function createCombinedDocumentProducer(options) {
2781
3110
  }
2782
3111
  if (fullRequested || repairNeedsFull) {
2783
3112
  const accumulated2 = runtime.accumulator.capturePatch();
2784
- 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;
2785
3116
  return serveFull(unchanged);
2786
3117
  }
2787
3118
  let accumulated = runtime.accumulator.capturePatch({
@@ -3265,7 +3596,14 @@ function createCombinedDocumentProducer(options) {
3265
3596
  roots.set(rootOptions.rootId, runtime);
3266
3597
  try {
3267
3598
  startRootObserver(rootOptions.rootId, runtime);
3268
- 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
+ );
3269
3607
  syncRootLifecycleObserver();
3270
3608
  } catch (error) {
3271
3609
  roots.delete(rootOptions.rootId);
@@ -3433,6 +3771,10 @@ function collectChangedSemanticFibers(previous, current, runtime) {
3433
3771
  runtime.publishedHostProps
3434
3772
  )) {
3435
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);
3436
3778
  }
3437
3779
  if (before.child === after.child) return;
3438
3780
  let oldChild = before.child;
@@ -3510,7 +3852,7 @@ function addRegion(runtime, fiber) {
3510
3852
  }
3511
3853
  runtime.pendingRegions.set(id, fiber);
3512
3854
  }
3513
- function addMetadata(runtime, fiber, sourceAnnotations) {
3855
+ function addMetadata(runtime, fiber, sourceAnnotations, layoutOnly = false) {
3514
3856
  if (!isProjectionLayerFiber(fiber)) return;
3515
3857
  if (runtime.options.scope === "contents" && runtime.committedFiber && fiberPair(fiber, runtime.committedFiber))
3516
3858
  return;
@@ -3524,6 +3866,7 @@ function addMetadata(runtime, fiber, sourceAnnotations) {
3524
3866
  const existing = runtime.pendingMetadata.get(id);
3525
3867
  runtime.pendingMetadata.set(id, {
3526
3868
  fiber,
3869
+ layoutOnly: layoutOnly && (existing?.layoutOnly ?? true),
3527
3870
  sourceAnnotations: existing?.sourceAnnotations === "live-host" || sourceAnnotations === "live-host" ? "live-host" : "fiber"
3528
3871
  });
3529
3872
  }
@@ -3541,12 +3884,11 @@ function fiberContains(ancestor, candidate) {
3541
3884
  return false;
3542
3885
  }
3543
3886
  function projectionPropsEqual(before, after, adapter, publishedHostProps) {
3544
- const right = adapter.captureMetadata(after)?.props;
3545
- const left = adapter.captureMetadata(before, {
3546
- layoutMode: right?.layoutMode ?? null
3547
- })?.props;
3548
3887
  const id = adapter.layerSourceId(after);
3549
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;
3550
3892
  const liveHostPropsEqual = published === void 0 || published.className === right?.className && published.layoutMode === right?.layoutMode && recordEqual(published.style, right?.style);
3551
3893
  return liveHostPropsEqual && layerPropsEqual(left, right);
3552
3894
  }
@@ -3682,6 +4024,8 @@ function captureSemanticMetadata(runtime, coveredFibers) {
3682
4024
  sourceAnnotations: retained.sourceAnnotations
3683
4025
  });
3684
4026
  if (metadata) {
4027
+ if (retained.layoutOnly && runtime.publishedHostProps.get(metadata.targetFiberId)?.layoutMode === metadata.props?.layoutMode)
4028
+ continue;
3685
4029
  snapshots.push(metadata);
3686
4030
  updatePublishedMetadata(runtime, metadata);
3687
4031
  }
@@ -3700,8 +4044,8 @@ function patchHtmlChars(patch) {
3700
4044
  }
3701
4045
  return chars;
3702
4046
  }
3703
- function fullReason(context) {
3704
- return context.initialForSession ? "initial" : "explicit-full";
4047
+ function fullReason(context, openingRoot) {
4048
+ return context.initialForSession ? "initial" : openingRoot ? "root-added" : "explicit-full";
3705
4049
  }
3706
4050
  function makePerf(input) {
3707
4051
  return buildProjectionCapturePerf({
@@ -3773,6 +4117,7 @@ function aggregateBatchPerf(roots, head, context, capturedHeadMs, rootsPerBatch,
3773
4117
  flushStartedAt,
3774
4118
  flushMs: Date.now() - flushStartedAt,
3775
4119
  snapshotMs: sum((perf) => perf.snapshotMs) + capturedHeadMs,
4120
+ headSnapshotMs: capturedHeadMs,
3776
4121
  identityMs: sum((perf) => perf.identityMs),
3777
4122
  identityNodesVisited: sum((perf) => perf.identityNodesVisited),
3778
4123
  sourceVersionDomScanNodes: sum((perf) => perf.sourceVersionDomScanNodes),
@@ -3832,7 +4177,7 @@ function aggregateBatchPerf(roots, head, context, capturedHeadMs, rootsPerBatch,
3832
4177
 
3833
4178
  // ../../modules/iframe-projection/combined/layer-framework.ts
3834
4179
  function isLayerFramework(value) {
3835
- return value === "react" || value === "svelte" || value === "dom" || value === "auto";
4180
+ return value === "react" || value === "svelte" || value === "astro" || value === "dom" || value === "auto";
3836
4181
  }
3837
4182
 
3838
4183
  // ../../modules/iframe-projection/combined/projection-batch.ts
@@ -4861,6 +5206,7 @@ function createProjectionSourceController(options) {
4861
5206
  };
4862
5207
  }
4863
5208
  function startCombinedSourceInterface(options = {}) {
5209
+ if (typeof document !== "undefined") trackAstroSources(document);
4864
5210
  const { targetOrigin = "*", serialize, hideFiberProp } = options;
4865
5211
  if (combinedSourceInitialized) {
4866
5212
  console.warn("[combined-postmessage:source] Already initialized");
@@ -6073,4 +6419,4 @@ function installTempoInteractProjectionSource() {
6073
6419
  export {
6074
6420
  installTempoInteractProjectionSource
6075
6421
  };
6076
- //# sourceMappingURL=chunk-U64AHDHZ.js.map
6422
+ //# sourceMappingURL=chunk-EYKOOLPL.js.map