@homepages/concrete 1.0.2 → 1.0.3

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 (33) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/codemods/manifest.json +4 -0
  3. package/dist/artifact/playground/client/assets/index-CckS2ONm.css +1 -0
  4. package/dist/artifact/playground/client/assets/{index-JloQyj8h.js → index-Da8V3M7E.js} +105 -105
  5. package/dist/artifact/playground/client/index.html +2 -2
  6. package/dist/artifact/playground/host.mjs +20 -20
  7. package/dist/cli/build/artifact.js +5 -2
  8. package/dist/cli/build/captures.js +15 -18
  9. package/dist/cli/build/fixtures.js +11 -3
  10. package/dist/cli/build/sections.js +13 -4
  11. package/dist/cli/check/load-workspace.js +6 -1
  12. package/dist/cli/check/stages/bundles.js +3 -1
  13. package/dist/cli/commands.js +1 -1
  14. package/dist/cli/dev/load-template.js +32 -25
  15. package/dist/cli/dev/server.js +5 -1
  16. package/dist/cli/dev/vite.js +37 -1
  17. package/dist/cli/dev/workspace-reader.js +2 -6
  18. package/dist/cli/media/derive.js +30 -3
  19. package/dist/cli/media/deriver-plugin.js +6 -2
  20. package/dist/cli/media/frame-rung-floor.js +18 -0
  21. package/dist/css/graph.js +2 -1
  22. package/dist/fixtures/load.js +6 -1
  23. package/dist/fixtures/media.js +37 -6
  24. package/dist/fixtures/package-stylesheets.js +59 -0
  25. package/dist/fixtures/property.js +28 -7
  26. package/dist/fixtures.d.ts +27 -4
  27. package/dist/packages/external/concrete/package.js +1 -1
  28. package/dist/primitives/slot-bindings.d.ts +19 -13
  29. package/dist/primitives/slot-bindings.js +7 -3
  30. package/dist/section/section.d.ts +6 -1
  31. package/guide/reference/cli/build.md +1 -1
  32. package/package.json +1 -1
  33. package/dist/artifact/playground/client/assets/index-BSA1yutg.css +0 -1
@@ -4,8 +4,8 @@
4
4
  <meta charset="utf-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
6
  <title>Playground</title>
7
- <script type="module" crossorigin src="./assets/index-JloQyj8h.js"></script>
8
- <link rel="stylesheet" crossorigin href="./assets/index-BSA1yutg.css">
7
+ <script type="module" crossorigin src="./assets/index-Da8V3M7E.js"></script>
8
+ <link rel="stylesheet" crossorigin href="./assets/index-CckS2ONm.css">
9
9
  </head>
10
10
  <body>
11
11
  <div id="root"></div>
@@ -1,4 +1,4 @@
1
- var Ve=/^(\d+(?:\.\d+)?)(in|mm)$/;function J(e){let t=Ve.exec(e),[,n,o]=t??[];if(n===void 0||o===void 0)throw new Error(`malformed physical length: "${e}"`);let s=Number.parseFloat(n);return o==="mm"?s/25.4:s}function N(e){if(typeof e.width=="number"&&typeof e.height=="number")return{frameWidth:e.width,frameHeight:e.height,bleed:0,viewportWidth:e.width,viewportHeight:e.height,deviceScaleFactor:1,pixelWidth:e.width,pixelHeight:e.height,pointWidth:e.width/96*72,pointHeight:e.height/96*72,bleedPoints:0};let t=e,n=J(t.width),o=J(t.height),s=t.bleed===void 0?0:J(t.bleed),l=n*96,f=o*96,r=s*96,m=l+2*r,v=f+2*r,R=t.dpi/96;return{frameWidth:l,frameHeight:f,bleed:r,viewportWidth:m,viewportHeight:v,deviceScaleFactor:R,pixelWidth:Math.round(m*R),pixelHeight:Math.round(v*R),pointWidth:(n+2*s)*72,pointHeight:(o+2*s)*72,bleedPoints:s*72}}var T="tr-frame";function M(e){let t=N(e);return{"--frame-w":`${t.frameWidth}px`,"--frame-h":`${t.frameHeight}px`,"--frame-bleed":`${t.bleed}px`}}var K=`(function () {
1
+ var ze=/^(\d+(?:\.\d+)?)(in|mm)$/;function J(e){let t=ze.exec(e),[,n,r]=t??[];if(n===void 0||r===void 0)throw new Error(`malformed physical length: "${e}"`);let o=Number.parseFloat(n);return r==="mm"?o/25.4:o}function M(e){if(typeof e.width=="number"&&typeof e.height=="number")return{frameWidth:e.width,frameHeight:e.height,bleed:0,viewportWidth:e.width,viewportHeight:e.height,deviceScaleFactor:1,pixelWidth:e.width,pixelHeight:e.height,pointWidth:e.width/96*72,pointHeight:e.height/96*72,bleedPoints:0};let t=e,n=J(t.width),r=J(t.height),o=t.bleed===void 0?0:J(t.bleed),l=n*96,u=r*96,c=o*96,s=l+2*c,h=u+2*c,b=t.dpi/96;return{frameWidth:l,frameHeight:u,bleed:c,viewportWidth:s,viewportHeight:h,deviceScaleFactor:b,pixelWidth:Math.round(s*b),pixelHeight:Math.round(h*b),pointWidth:(n+2*o)*72,pointHeight:(r+2*o)*72,bleedPoints:o*72}}var T="tr-frame";function N(e){let t=M(e);return{"--frame-w":`${t.frameWidth}px`,"--frame-h":`${t.frameHeight}px`,"--frame-bleed":`${t.bleed}px`}}var K=`(function () {
2
2
  function CaptureIntersectionObserver(callback, options) {
3
3
  var opts = options || {};
4
4
  this.root = opts.root || null;
@@ -46,7 +46,7 @@ var Ve=/^(\d+(?:\.\d+)?)(in|mm)$/;function J(e){let t=Ve.exec(e),[,n,o]=t??[];if
46
46
  return entries;
47
47
  };
48
48
  window.IntersectionObserver = CaptureIntersectionObserver;
49
- })();`;var Y="__trIslandsReady",ze=`(async () => {
49
+ })();`;var Y="__trIslandsReady",Xe=`(async () => {
50
50
  const ready = window.${Y};
51
51
  if (ready === undefined) {
52
52
  throw new Error(
@@ -55,14 +55,14 @@ var Ve=/^(\d+(?:\.\d+)?)(in|mm)$/;function J(e){let t=Ve.exec(e),[,n,o]=t??[];if
55
55
  );
56
56
  }
57
57
  await ready;
58
- })()`;var le=400;var Be=`(async () => {
58
+ })()`;var le=400;var Ge=`(async () => {
59
59
  await new Promise((resolve) => {
60
60
  setTimeout(resolve, ${le});
61
61
  });
62
62
  await new Promise((resolve) => {
63
63
  requestAnimationFrame(() => resolve(undefined));
64
64
  });
65
- })()`,de=5,Ge=`(async () => {
65
+ })()`,de=5,Je=`(async () => {
66
66
  const frame = () => new Promise((resolve) => {
67
67
  requestAnimationFrame(() => resolve(undefined));
68
68
  });
@@ -83,14 +83,14 @@ var Ve=/^(\d+(?:\.\d+)?)(in|mm)$/;function J(e){let t=Ve.exec(e),[,n,o]=t??[];if
83
83
  await frame();
84
84
  }
85
85
  await frame();
86
- })()`;function D(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026")}function y(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function ce(e){return ue(e.id,{...M(e)})}function ue(e,t){let n=Object.entries(t).map(([o,s])=>`${o}:${s}`).join(";");return{class:T,dataFormat:e,style:n}}function j(e,t){let n=ce(e);return`<div class="${y(n.class)}" data-format="${y(n.dataFormat)}" style="${y(n.style)}">${t.join("")}</div>`}function k(e){switch(e.destination){case"published":return Xe(e);case"artifact":return Je(e);case"preview":return Ye(e);case"diff":return Ke(e)}}function pe(e){return e.kind==="none"||Object.keys(e.islandMap).length===0?[]:[`<script>${K}</script>`]}var fe="html, body { margin: 0; padding: 0; }";function me(e){let t=[`rel="${e.rel}"`,`href="${y(e.href)}"`];return e.sizes!==void 0&&t.push(`sizes="${y(e.sizes)}"`),e.type!==void 0&&t.push(`type="${y(e.type)}"`),`<link ${t.join(" ")} />`}function Xe(e){let{meta:t}=e,n=['<meta charset="utf-8" />','<meta name="viewport" content="width=device-width, initial-scale=1" />',`<title>${y(t.title)}</title>`,`<meta name="description" content="${y(t.description)}" />`];t.canonical&&n.push(`<link rel="canonical" href="${y(t.canonical)}" />`);for(let s of t.icons??[])n.push(me(s));n.push('<meta property="og:type" content="website" />'),t.siteName&&n.push(`<meta property="og:site_name" content="${y(t.siteName)}" />`),n.push(`<meta property="og:title" content="${y(t.title)}" />`),n.push(`<meta property="og:description" content="${y(t.description)}" />`),t.ogUrl&&n.push(`<meta property="og:url" content="${y(t.ogUrl)}" />`),t.ogImage&&(n.push(`<meta property="og:image" content="${y(t.ogImage)}" />`),t.ogImageWidth&&n.push(`<meta property="og:image:width" content="${t.ogImageWidth}" />`),t.ogImageHeight&&n.push(`<meta property="og:image:height" content="${t.ogImageHeight}" />`),t.ogImageType&&n.push(`<meta property="og:image:type" content="${y(t.ogImageType)}" />`),t.ogImageAlt&&n.push(`<meta property="og:image:alt" content="${y(t.ogImageAlt)}" />`),n.push('<meta name="twitter:card" content="summary_large_image" />'),n.push(`<meta name="twitter:title" content="${y(t.title)}" />`),n.push(`<meta name="twitter:description" content="${y(t.description)}" />`),n.push(`<meta name="twitter:image" content="${y(t.ogImage)}" />`)),n.push(...W(e.stylesheets)),n.push(...Z(e.islands)),e.prefetchUrls&&e.prefetchUrls.length>0&&n.push(`<script type="speculationrules">${D({prefetch:[{source:"list",urls:[...e.prefetchUrls]}]})}</script>`);let o=e.siteConfig?`
86
+ })()`;function D(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026")}function y(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function ce(e){return ue(e.id,{...N(e)})}function ue(e,t){let n=Object.entries(t).map(([r,o])=>`${r}:${o}`).join(";");return{class:T,dataFormat:e,style:n}}function j(e,t){let n=ce(e);return`<div class="${y(n.class)}" data-format="${y(n.dataFormat)}" style="${y(n.style)}">${t.join("")}</div>`}function C(e){switch(e.destination){case"published":return Ye(e);case"artifact":return Ke(e);case"preview":return Qe(e);case"diff":return Ze(e)}}function pe(e){return e.kind==="none"||Object.keys(e.islandMap).length===0?[]:[`<script>${K}</script>`]}var fe="html, body { margin: 0; padding: 0; }";function me(e){let t=[`rel="${e.rel}"`,`href="${y(e.href)}"`];return e.sizes!==void 0&&t.push(`sizes="${y(e.sizes)}"`),e.type!==void 0&&t.push(`type="${y(e.type)}"`),`<link ${t.join(" ")} />`}function Ye(e){let{meta:t}=e,n=['<meta charset="utf-8" />','<meta name="viewport" content="width=device-width, initial-scale=1" />',`<title>${y(t.title)}</title>`,`<meta name="description" content="${y(t.description)}" />`];t.canonical&&n.push(`<link rel="canonical" href="${y(t.canonical)}" />`);for(let o of t.icons??[])n.push(me(o));n.push('<meta property="og:type" content="website" />'),t.siteName&&n.push(`<meta property="og:site_name" content="${y(t.siteName)}" />`),n.push(`<meta property="og:title" content="${y(t.title)}" />`),n.push(`<meta property="og:description" content="${y(t.description)}" />`),t.ogUrl&&n.push(`<meta property="og:url" content="${y(t.ogUrl)}" />`),t.ogImage&&(n.push(`<meta property="og:image" content="${y(t.ogImage)}" />`),t.ogImageWidth&&n.push(`<meta property="og:image:width" content="${t.ogImageWidth}" />`),t.ogImageHeight&&n.push(`<meta property="og:image:height" content="${t.ogImageHeight}" />`),t.ogImageType&&n.push(`<meta property="og:image:type" content="${y(t.ogImageType)}" />`),t.ogImageAlt&&n.push(`<meta property="og:image:alt" content="${y(t.ogImageAlt)}" />`),n.push('<meta name="twitter:card" content="summary_large_image" />'),n.push(`<meta name="twitter:title" content="${y(t.title)}" />`),n.push(`<meta name="twitter:description" content="${y(t.description)}" />`),n.push(`<meta name="twitter:image" content="${y(t.ogImage)}" />`)),n.push(...W(e.stylesheets)),n.push(...Z(e.islands)),e.prefetchUrls&&e.prefetchUrls.length>0&&n.push(`<script type="speculationrules">${D({prefetch:[{source:"list",urls:[...e.prefetchUrls]}]})}</script>`);let r=e.siteConfig?`
87
87
  <script type="application/json" id="tr-site-config">${D(e.siteConfig)}</script>`:"";return L({lang:t.lang??"en",head:n,body:` <body class="tr-root">
88
- ${e.root.bodyHtml}${o}${ee(e.islands,"viewport")}
88
+ ${e.root.bodyHtml}${r}${ee(e.islands,"viewport")}
89
89
  <script type="module" src="${y(e.analyticsJs.url)}"></script>
90
- </body>`})}function Je(e){let t=['<meta charset="utf-8" />'];e.title!==void 0&&t.push(`<title>${y(e.title)}</title>`),t.push(...W(e.stylesheets));let n=[fe,...Ze(e.root)];return t.push(Q(n)),t.push(...pe(e.islands)),t.push(...Z(e.islands)),L({lang:"en",head:t,body:` <body>${Qe(e.root)}${ee(e.islands,"eager")}</body>`})}function Ye(e){let t=['<meta charset="utf-8" />','<meta name="viewport" content="width=device-width, initial-scale=1" />',`<title>${y(e.title)}</title>`,...e.icon===void 0?[]:[me({rel:"icon",href:e.icon})],...W(e.stylesheets),Q([fe,...e.extraCss??[]]),...e.capture===!0?pe(e.islands):[],...Z(e.islands)],n=(e.devScripts??[]).map(o=>`
91
- ${o}`).join("");return L({lang:"en",head:t,body:` <body>
90
+ </body>`})}function Ke(e){let t=['<meta charset="utf-8" />'];e.title!==void 0&&t.push(`<title>${y(e.title)}</title>`),t.push(...W(e.stylesheets));let n=[fe,...tt(e.root)];return t.push(Q(n)),t.push(...pe(e.islands)),t.push(...Z(e.islands)),L({lang:"en",head:t,body:` <body>${et(e.root)}${ee(e.islands,"eager")}</body>`})}function Qe(e){let t=['<meta charset="utf-8" />','<meta name="viewport" content="width=device-width, initial-scale=1" />',`<title>${y(e.title)}</title>`,...e.icon===void 0?[]:[me({rel:"icon",href:e.icon})],...W(e.stylesheets),Q([fe,...e.extraCss??[]]),...e.capture===!0?pe(e.islands):[],...Z(e.islands)],n=(e.devScripts??[]).map(r=>`
91
+ ${r}`).join("");return L({lang:"en",head:t,body:` <body>
92
92
  ${e.root.bodyHtml}${ee(e.islands,e.capture===!0?"eager":"viewport")}${n}
93
- </body>`})}function Ke(e){let t=['<meta charset="utf-8" />',`<meta name="viewport" content="width=${e.viewportWidth}, initial-scale=1" />`,`<title>${y(e.title)}</title>`,...W(e.stylesheets),Q([`html, body { margin: 0; padding: 0; width: ${e.viewportWidth}px; }`])];return L({lang:"en",head:t,body:` <body>${e.root.bodyHtml}</body>`})}function L(e){let t=e.head.map(n=>` ${n}`).join(`
93
+ </body>`})}function Ze(e){let t=['<meta charset="utf-8" />',`<meta name="viewport" content="width=${e.viewportWidth}, initial-scale=1" />`,`<title>${y(e.title)}</title>`,...W(e.stylesheets),Q([`html, body { margin: 0; padding: 0; width: ${e.viewportWidth}px; }`])];return L({lang:"en",head:t,body:` <body>${e.root.bodyHtml}</body>`})}function L(e){let t=e.head.map(n=>` ${n}`).join(`
94
94
  `);return`<!doctype html>
95
95
  <html lang="${y(e.lang)}">
96
96
  <head>
@@ -98,22 +98,22 @@ ${t}
98
98
  </head>
99
99
  ${e.body}
100
100
  </html>
101
- `}function Qe(e){return e.kind==="frame"?j(e.format,e.sectionHtml):e.pages.map(t=>j(e.format,t)).join(`
102
- `)}function Ze(e){return e.kind!=="frameStack"?[]:[`body > .${T} { break-after: page; }`,`body > .${T}:last-child { break-after: auto; }`]}function W(e){return e.kind==="links"?e.hrefs.map(t=>`<link rel="stylesheet" href="${y(t)}" />`):e.css.map(t=>`<style>${t}</style>`)}function Q(e){let[t,...n]=e;return t===void 0?"<style></style>":n.length===0?`<style>${t}</style>`:`<style>${t}
101
+ `}function et(e){return e.kind==="frame"?j(e.format,e.sectionHtml):e.pages.map(t=>j(e.format,t)).join(`
102
+ `)}function tt(e){return e.kind!=="frameStack"?[]:[`body > .${T} { break-after: page; }`,`body > .${T}:last-child { break-after: auto; }`]}function W(e){return e.kind==="links"?e.hrefs.map(t=>`<link rel="stylesheet" href="${y(t)}" />`):e.css.map(t=>`<style>${t}</style>`)}function Q(e){let[t,...n]=e;return t===void 0?"<style></style>":n.length===0?`<style>${t}</style>`:`<style>${t}
103
103
  ${n.join(`
104
104
  `)}
105
- </style>`}function Z(e){if(e.kind!=="bundles")return[];let t=[],n=e.reactVendorMap;if(n&&Object.keys(n).length>0&&t.push(`<script type="importmap">${D({imports:n})}</script>`),Object.keys(e.islandMap).length===0)return t;for(let o of[e.runtime.url,...Object.values(n??{}),...e.reactVendorCore?[e.reactVendorCore.url]:[]])t.push(`<link rel="modulepreload" href="${y(o)}" />`);return t}function ee(e,t){if(e.kind==="none"||Object.keys(e.islandMap).length===0)return"";let n=D(e.islandMap),o=t==="eager"?' window.__TR_ISLAND_SCHEDULE = "eager";':"";return e.kind==="bundles"?`
106
- <script>window.__TR_ISLAND_MAP=${n};${o}</script>
105
+ </style>`}function Z(e){if(e.kind!=="bundles")return[];let t=[],n=e.reactVendorMap;if(n&&Object.keys(n).length>0&&t.push(`<script type="importmap">${D({imports:n})}</script>`),Object.keys(e.islandMap).length===0)return t;for(let r of[e.runtime.url,...Object.values(n??{}),...e.reactVendorCore?[e.reactVendorCore.url]:[]])t.push(`<link rel="modulepreload" href="${y(r)}" />`);return t}function ee(e,t){if(e.kind==="none"||Object.keys(e.islandMap).length===0)return"";let n=D(e.islandMap),r=t==="eager"?' window.__TR_ISLAND_SCHEDULE = "eager";':"";return e.kind==="bundles"?`
106
+ <script>window.__TR_ISLAND_MAP=${n};${r}</script>
107
107
  <script type="module" src="${y(e.runtime.url)}"></script>`:`
108
- ${et}
109
- <script>window.__TR_ISLAND_MAP = ${n};${o}</script>
110
- <script type="module" src="${y(e.bootstrapUrl)}"></script>`}var et=`<script type="module">
108
+ ${nt}
109
+ <script>window.__TR_ISLAND_MAP = ${n};${r}</script>
110
+ <script type="module" src="${y(e.bootstrapUrl)}"></script>`}var nt=`<script type="module">
111
111
  import RefreshRuntime from "/@react-refresh";
112
112
  RefreshRuntime.injectIntoGlobalHook(window);
113
113
  window.$RefreshReg$ = () => {};
114
114
  window.$RefreshSig$ = () => (type) => type;
115
115
  window.__vite_plugin_react_preamble_installed__ = true;
116
- </script>`;function ge(){let e={};return new Proxy(e,{get:(t,n)=>typeof n!="string"||n in e||n==="then"||n==="toJSON"?e[n]:`#${n}`})}function ye(e){let t=new URLSearchParams;for(let[o,s]of Object.entries(e))s!=null&&s!==""&&t.set(o,s);let n=t.toString();return n===""?"":`?${n}`}var E={catalog:"api/catalog",render:"api/render",media:e=>`api/media${ye({fixture:e})}`,capture:(e,t)=>`api/capture/${e}${ye({fixture:t.fixture,format:t.format,page:t.page,canvas:t.canvas})}`,live:(e,t)=>`fixtures/${encodeURIComponent(e)}/live${t==="/"?"/":`${t}/`}`,hmr:"__hmr"};var g=class extends Error{constructor(n,o){super(o);this.status=n}status};function tt(e){return e.split("-").map(t=>t&&t[0].toUpperCase()+t.slice(1)).join(" ")}function he(e){let{variant:t}=e;return{required:e.required,variant:t===null?null:{cases:t.cases.map(n=>({value:n,label:tt(n)})),locked:t.locked}}}function we(e){return Object.fromEntries(e.map(t=>[t.instance_id,{enabled:t.enabled,...t.variant===void 0?{}:{variant:t.variant}}]))}function Re(e){if(e==null)return{};if(typeof e!="object"||Array.isArray(e))throw new g(400,"A render request's display is an object keyed by instance id.");let t={};for(let[n,o]of Object.entries(e)){if(typeof o!="object"||o===null||Array.isArray(o))throw new g(400,`The display state of "${n}" is not an object.`);let{enabled:s,variant:l}=o;if(s!==void 0&&typeof s!="boolean")throw new g(400,`The display state of "${n}" has a non-boolean enabled.`);if(l!==void 0&&typeof l!="string")throw new g(400,`The display state of "${n}" has a non-string variant.`);t[n]={...s===void 0?{}:{enabled:s},...l===void 0?{}:{variant:l}}}return t}function be(e,t){for(let[n,o]of Object.entries(t)){let s=e.instances.find(f=>f.instanceId===n);if(s===void 0)throw new g(400,`The composition places no instance "${n}".`);if(o.enabled===!1&&s.display.required)throw new g(400,`Section instance "${n}" is required and cannot be hidden.`);if(o.variant===void 0)continue;let l=s.display.variant;if(l===null)throw new g(400,`Section instance "${n}" declares no display variant.`);if(l.locked)throw new g(400,`Section instance "${n}" declares a locked variant, which the user cannot switch.`);if(!l.cases.includes(o.variant))throw new g(400,`"${o.variant}" is not a declared case of section instance "${n}" (declared: ${l.cases.join(", ")}).`)}}function Se(e,t){return new Map(e.instances.map(n=>[n.instance_id,t[n.instance_id]?.enabled??n.enabled]))}function _e(e,t,n){let o=n[e.instance_id]?.variant;if(o===void 0||o===e.variant)return e;let s={...e.slots};for(let[l,f]of Object.entries(t))l in s||(f.variant===void 0||f.variant.cases.includes(o))&&(s[l]=f.type==="list"?[]:null);return{...e,variant:o,slots:s}}function ve(e){return Array.isArray(e)?e.length:0}function xe(e){return typeof e=="string"&&e!==""?e:null}function nt(e){return{propertyType:xe(e.property_type),listingIntent:xe(e.listing_intent),units:ve(e.units),photos:ve(e.photos)}}function rt(e){let t=JSON.stringify(e),n=3735928559,o=1103547991;for(let s=0;s<t.length;s++){let l=t.charCodeAt(s);n=Math.imul(n^l,2654435761),o=Math.imul(o^l,1597334677)}return n=Math.imul(n^n>>>16,2246822507)^Math.imul(o^o>>>13,3266489909),o=Math.imul(o^o>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),(4294967296*(2097151&o)+(n>>>0)).toString(16).padStart(14,"0")}function Ie(e){return{id:e.id,label:e.label,group:e.synthesized===!0?"empties":"fixtures",summary:nt(e.facts),doc:rt(e.instances),display:we(e.instances)}}function Pe(e,t){let n=e.replace(/\/+$/,"");return t==="/"?`${n}/`:`${n}${t}/`}function $e(e){let{pages:t,currentPageId:n,basePath:o}=e,s=t.find(r=>r.id===n);if(!s)throw new Error(`nav: page "${n}" is not one of the declared pages (${t.map(r=>r.id).join(", ")}).`);let l=[s,...t.filter(r=>r.id!==s.id&&r.enabled!==!1)],f={};for(let r of l)for(let m of r.sections)m.enabled===!1||m.key in f||(f[m.key]=r.id===s.id?`#${m.anchor}`:`${Pe(o,r.path)}#${m.anchor}`);return{anchors:f,pages:t.filter(r=>r.enabled!==!1).map(r=>({id:r.id,label:r.label,href:Pe(o,r.path),current:r.id===s.id}))}}function V(e,t){return e.pages?.[t]?.enabled!==!1}function te(e,t){return t.filter(n=>V(e,n.id))}var O={base:"stylesheets/base.css",template:"stylesheets/template.css"},I={frame:"__capture/frame",print:"__capture/print"};function Ee(e){return new URLSearchParams(e).toString()}function ne(e,t,n){return`${I.frame}?${Ee({fixture:e,page:t,format:n})}`}function Te(e,t){return`${I.print}?${Ee({fixture:e,format:t})}`}var q=e=>e<0?0:e>1?1:e;function F(e){if(typeof e!="object"||e===null)return null;let{nx:t=0,ny:n=0,nw:o=1,nh:s=1}=e;if(![t,n,o,s].every(m=>typeof m=="number"&&Number.isFinite(m)))return null;let l=q(t),f=q(n),r={nx:l,ny:f,nw:Math.min(q(o),1-l),nh:Math.min(q(s),1-f)};return r.nw<=0||r.nh<=0||r.nx===0&&r.ny===0&&r.nw===1&&r.nh===1?null:r}var z={file(e){return typeof e=="string"?{url:e,responsive:null}:{url:e.url,responsive:e.responsive}}};function ot(e){if(typeof e!="object"||e===null)return null;let t=e.asset_id;return typeof t=="string"&&t!==""?t:null}function st(e,t,n){if(e.file===null)return null;let o=n.crop===void 0?null:F(t.rect),s=n.crop===void 0?null:F(t.mobile_rect),l=n.file(e.file),f=o===null?{photo_id:e.id,url:l.url,alt:e.alt,responsive:l.responsive}:{photo_id:e.id,url:n.crop(e.file,o),alt:e.alt,responsive:null,rect:o};return s!==null&&(f.mobile={url:n.crop(e.file,s),responsive:null}),f}function it(e,t){return e.file===null?{video_id:e.id,url:e.url??"",poster:"",alt:e.alt,source:"link",...e.provider===null?{}:{provider:e.provider}}:{video_id:e.id,url:t.file(e.file).url,poster:"",alt:e.alt,source:"upload"}}function at(e){return{tour_id:e.id,url:e.url??"",poster:"",alt:e.alt,...e.provider===null?{}:{provider:e.provider}}}function lt(e,t){return e.file===null?null:{asset_id:e.id,url:t.file(e.file).url,filename:e.filename,content_type:e.mime,size_bytes:0}}function dt(e,t,n,o){let s=ot(t),l=s===null?void 0:n.get(s);if(l===void 0||l.kind!==e)return null;switch(e){case"image":return st(l,t,o);case"video":return it(l,o);case"tour":return at(l);case"document":return lt(l,o);default:return null}}var ct=new Set(["image","video","tour","document"]);function re(e,t,n,o){if(t==null)return t;if(ct.has(e.type))return dt(e.type,t,n,o);if(e.type!=="list"||!Array.isArray(t))return t;let s=t;if(e.fields!==void 0){let l=e.fields;return s.map(f=>{if(typeof f!="object"||f===null)return f;let r={...f};for(let[m,v]of Object.entries(l))r[m]=re(v,r[m],n,o);return r})}if(e.element!==void 0){let l=e.element;return s.map(f=>re(l,f,n,o))}return s}function ke(e,t,n,o=z){let s={};for(let[l,f]of Object.entries(e.slots)){let r=t.schema.slots[l];s[l]=r===void 0?f:re(r,f,n,o)}return s}function ut(e){return typeof e=="string"?e:e.url}function pt(e,t){return e.split(",").map(n=>{let[o="",...s]=n.trim().split(/\s+/);return[t(o),...s].join(" ")}).join(", ")}function ft(e){return{file(t){let n=z.file(t),o=n.responsive===null?null:{...n.responsive,sources:n.responsive.sources.map(s=>({...s,srcset:pt(s.srcset,e)}))};return{url:e(n.url),responsive:o}},crop(t,n){return e(z.file(t).url,{crop:n})}}}function C(e){return Array.isArray(e)?e:[]}function Ce(e,t){let{facts:n}=e,o=r=>e.media[r],s=r=>r?.file===null||r?.file===void 0?"":t(ut(r.file)),l=[];for(let r of C(n.photos)){let m=o(r.id);l.push({id:r.id,kind:"photo",name:m?.filename||r.id,size:"",src:s(m),caption:r.caption??null})}for(let r of C(n.floor_plans)){let m=o(r.id);l.push({id:r.id,kind:"plan",name:m?.filename||r.id,size:"",src:s(m)})}for(let r of C(n.videos)){let m=r.provider??void 0;l.push({id:r.id,kind:"video",name:r.caption??o(r.id)?.filename??r.id,size:"",src:"",caption:r.caption??null,ready:!0,durationMs:r.duration_ms??null,...m===void 0?{}:{provider:m}})}for(let r of C(n.tours))l.push({id:r.id,kind:"tour",name:`${r.provider??"Tour"} ${r.id}`,size:"",src:"",ready:!0,provider:r.provider??""});for(let r of C(n.documents)){let m=o(r.id)?.sizeBytes;l.push({id:r.id,kind:"document",name:r.filename??r.id,size:"",src:"",mime:r.mime??"",...m===void 0?{}:{sizeBytes:m}})}let f=[["avatar_upload_id","headshot"],["logo_dark_upload_id","logo (dark)"],["logo_light_upload_id","logo (light)"]];for(let r of C(n.contacts)){let m=typeof r.name=="string"?r.name:"Contact";for(let[v,R]of f){let x=r[v];typeof x=="string"&&l.push({id:x,kind:"library",name:`${m} \u2014 ${R}`,size:"",src:s(o(x)),caption:m})}}return l}var mt={image:["photo_id","asset_id"],video:["video_id","asset_id"],tour:["tour_id","asset_id"],document:["asset_id"]};function oe(e,t){if(t==null)return t;let n=mt[e.type];if(n!==void 0){if(typeof t!="object")return null;let s=t,l=n.map(m=>s[m]).find(m=>typeof m=="string"&&m!=="");if(typeof l!="string")return null;if(e.type!=="image")return{asset_id:l};let f=F(s.rect),r=typeof s.mobile=="object"&&s.mobile!==null?F(s.mobile.rect):null;return{asset_id:l,...f===null?{}:{rect:f},...r===null?{}:{mobile_rect:r}}}if(e.type!=="list"||!Array.isArray(t))return t;let o=t;if(e.fields!==void 0){let s=e.fields;return o.map(l=>{if(typeof l!="object"||l===null)return l;let f={...l};for(let[r,m]of Object.entries(s))r in f&&(f[r]=oe(m,f[r]));return f})}if(e.element!==void 0){let s=e.element;return o.map(l=>oe(s,l))}return o}function Ae(e){let{instance:t,slots:n,fixture:o,session:s,assetUrl:l}=e,f={...t.slots},r={},m=o.provenance[t.instance_id]??{};for(let R of Object.keys(n))r[R]=m[R]??{kind:"empty"};for(let[R,x]of Object.entries(s??{})){let A=n[R];A!==void 0&&(f[R]=oe(A,x),r[R]={kind:"session"})}let v=new Map(Object.entries(o.media));return{slots:ke({...t,slots:f},{schema:{slots:n}},v,ft(l)),provenance:r}}var He=1024*1024;function yt(e){let t=N(e),n=typeof e.width=="string"?`${e.width} \xD7 ${String(e.height)}`:void 0;return{id:e.id,label:e.label,cssWidth:t.viewportWidth,cssHeight:t.viewportHeight,bleed:t.bleed,pixelWidth:t.pixelWidth,pixelHeight:t.pixelHeight,...n===void 0?{}:{physical:n},tokens:{...M(e)}}}function ht(e,t){return new Response(t,{status:e,headers:{"content-type":"text/plain; charset=utf-8"}})}function se(e){return new Response(JSON.stringify(e),{headers:{"content-type":"application/json; charset=utf-8"}})}function ie(e){return new Response(e,{headers:{"content-type":"text/html; charset=utf-8"}})}function wt(e){if(typeof e!="object"||e===null)return null;let t=e.status;return typeof t=="number"&&Number.isInteger(t)&&t>=400&&t<600?t:null}function U(e,t,n){let o=e.searchParams.get(t);if(o===null||o==="")throw new g(400,`${n} needs a ${t} parameter.`);return o}function Rt(e){return`<script>
116
+ </script>`;function ge(){let e={};return new Proxy(e,{get:(t,n)=>typeof n!="string"||n in e||n==="then"||n==="toJSON"?e[n]:`#${n}`})}function ye(e){let t=new URLSearchParams;for(let[r,o]of Object.entries(e))o!=null&&o!==""&&t.set(r,o);let n=t.toString();return n===""?"":`?${n}`}var k={catalog:"api/catalog",render:"api/render",media:e=>`api/media${ye({fixture:e})}`,capture:(e,t)=>`api/capture/${e}${ye({fixture:t.fixture,format:t.format,page:t.page,canvas:t.canvas})}`,live:(e,t)=>`fixtures/${encodeURIComponent(e)}/live${t==="/"?"/":`${t}/`}`,hmr:"__hmr"};var g=class extends Error{constructor(n,r){super(r);this.status=n}status};function rt(e){return e.split("-").map(t=>t&&t[0].toUpperCase()+t.slice(1)).join(" ")}function he(e){let{variant:t}=e;return{required:e.required,variant:t===null?null:{cases:t.cases.map(n=>({value:n,label:rt(n)})),locked:t.locked}}}function we(e){return Object.fromEntries(e.map(t=>[t.instance_id,{enabled:t.enabled,...t.variant===void 0?{}:{variant:t.variant}}]))}function Re(e){if(e==null)return{};if(typeof e!="object"||Array.isArray(e))throw new g(400,"A render request's display is an object keyed by instance id.");let t={};for(let[n,r]of Object.entries(e)){if(typeof r!="object"||r===null||Array.isArray(r))throw new g(400,`The display state of "${n}" is not an object.`);let{enabled:o,variant:l}=r;if(o!==void 0&&typeof o!="boolean")throw new g(400,`The display state of "${n}" has a non-boolean enabled.`);if(l!==void 0&&typeof l!="string")throw new g(400,`The display state of "${n}" has a non-string variant.`);t[n]={...o===void 0?{}:{enabled:o},...l===void 0?{}:{variant:l}}}return t}function be(e,t){for(let[n,r]of Object.entries(t)){let o=e.instances.find(u=>u.instanceId===n);if(o===void 0)throw new g(400,`The composition places no instance "${n}".`);if(r.enabled===!1&&o.display.required)throw new g(400,`Section instance "${n}" is required and cannot be hidden.`);if(r.variant===void 0)continue;let l=o.display.variant;if(l===null)throw new g(400,`Section instance "${n}" declares no display variant.`);if(l.locked)throw new g(400,`Section instance "${n}" declares a locked variant, which the user cannot switch.`);if(!l.cases.includes(r.variant))throw new g(400,`"${r.variant}" is not a declared case of section instance "${n}" (declared: ${l.cases.join(", ")}).`)}}function _e(e,t){return new Map(e.instances.map(n=>[n.instance_id,t[n.instance_id]?.enabled??n.enabled]))}function Se(e,t,n){let r=n[e.instance_id]?.variant;if(r===void 0||r===e.variant)return e;let o={...e.slots};for(let[l,u]of Object.entries(t))l in o||(u.variant===void 0||u.variant.cases.includes(r))&&(o[l]=u.type==="list"?[]:null);return{...e,variant:r,slots:o}}function ve(e){return Array.isArray(e)?e.length:0}function xe(e){return typeof e=="string"&&e!==""?e:null}function ot(e){return{propertyType:xe(e.property_type),listingIntent:xe(e.listing_intent),units:ve(e.units),photos:ve(e.photos)}}function it(e){let t=JSON.stringify(e),n=3735928559,r=1103547991;for(let o=0;o<t.length;o++){let l=t.charCodeAt(o);n=Math.imul(n^l,2654435761),r=Math.imul(r^l,1597334677)}return n=Math.imul(n^n>>>16,2246822507)^Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),(4294967296*(2097151&r)+(n>>>0)).toString(16).padStart(14,"0")}function Ie(e){return{id:e.id,label:e.label,summary:ot(e.facts),doc:it(e.instances),display:we(e.instances)}}function Pe(e,t){let n=e.replace(/\/+$/,"");return t==="/"?`${n}/`:`${n}${t}/`}function Ee(e){let{pages:t,currentPageId:n,basePath:r}=e,o=t.find(c=>c.id===n);if(!o)throw new Error(`nav: page "${n}" is not one of the declared pages (${t.map(c=>c.id).join(", ")}).`);let l=[o,...t.filter(c=>c.id!==o.id&&c.enabled!==!1)],u={};for(let c of l)for(let s of c.sections)s.enabled===!1||s.key in u||(u[s.key]=c.id===o.id?`#${s.anchor}`:`${Pe(r,c.path)}#${s.anchor}`);return{anchors:u,pages:t.filter(c=>c.enabled!==!1).map(c=>({id:c.id,label:c.label,href:Pe(r,c.path),current:c.id===o.id}))}}function V(e,t){return e.pages?.[t]?.enabled!==!1}function te(e,t){return t.filter(n=>V(e,n.id))}var O={base:"stylesheets/base.css",template:"stylesheets/template.css"},I={frame:"__capture/frame",print:"__capture/print"};function $e(e){return new URLSearchParams(e).toString()}function ne(e,t,n){return`${I.frame}?${$e({fixture:e,page:t,format:n})}`}function ke(e,t){return`${I.print}?${$e({fixture:e,format:t})}`}var q=e=>e<0?0:e>1?1:e;function F(e){if(typeof e!="object"||e===null)return null;let{nx:t=0,ny:n=0,nw:r=1,nh:o=1}=e;if(![t,n,r,o].every(s=>typeof s=="number"&&Number.isFinite(s)))return null;let l=q(t),u=q(n),c={nx:l,ny:u,nw:Math.min(q(r),1-l),nh:Math.min(q(o),1-u)};return c.nw<=0||c.nh<=0||c.nx===0&&c.ny===0&&c.nw===1&&c.nh===1?null:c}var z={file(e){return typeof e=="string"?{url:e,responsive:null}:{url:e.url,responsive:e.responsive}}};function st(e){if(typeof e!="object"||e===null)return null;let t=e.asset_id;return typeof t=="string"&&t!==""?t:null}function at(e,t,n){if(e.file===null)return null;let r=n.crop===void 0?null:F(t.rect),o=n.crop===void 0?null:F(t.mobile_rect),l=n.file(e.file),u=r===null?{photo_id:e.id,url:l.url,alt:e.alt,responsive:l.responsive}:{photo_id:e.id,url:n.crop(e.file,r),alt:e.alt,responsive:null,rect:r};return o!==null&&(u.mobile={url:n.crop(e.file,o),responsive:null}),u}function Te(e,t){if(e.posterFile!==void 0){let n=t.file(e.posterFile);return n.responsive===null?{poster:n.url}:{poster:n.url,poster_responsive:n.responsive}}return{poster:e.posterUrl??""}}function lt(e,t){let n=Te(e,t);return e.file===null?{video_id:e.id,url:e.url??"",...n,alt:e.alt,source:"link",...e.provider===null?{}:{provider:e.provider}}:{video_id:e.id,url:t.file(e.file).url,...n,alt:e.alt,source:"upload"}}function dt(e,t){return{tour_id:e.id,url:e.url??"",...Te(e,t),alt:e.alt,...e.provider===null?{}:{provider:e.provider}}}function ct(e,t){return e.file===null?null:{asset_id:e.id,url:t.file(e.file).url,filename:e.filename,content_type:e.mime,size_bytes:0}}function ut(e,t,n,r){let o=st(t),l=o===null?void 0:n.get(o);if(l===void 0||l.kind!==e)return null;switch(e){case"image":return at(l,t,r);case"video":return lt(l,r);case"tour":return dt(l,r);case"document":return ct(l,r);default:return null}}var pt=new Set(["image","video","tour","document"]),ft=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function mt(e,t,n){let r=typeof e.id=="string"?e.id:"",o=typeof e.floor_label=="string"?e.floor_label:null,l=r===""?void 0:t.get(r),u=l?.kind==="image"&&l.file!==null?n.file(l.file):null;return{id:r,...typeof e.upload_id=="string"?{upload_id:e.upload_id}:{},url:u?.url??"",alt:o??"Floor plan",floor_label:o,position:typeof e.position=="number"?e.position:0,...u?.responsive?{responsive:u.responsive}:{}}}function gt(e,t,n,r){return e.type==="image"&&Array.isArray(t)?t.filter(ft).map(o=>mt(o,n,r)):re(e,t,n,r)}function re(e,t,n,r){if(t==null)return t;if(pt.has(e.type))return ut(e.type,t,n,r);if(e.type!=="list"||!Array.isArray(t))return t;let o=t;if(e.fields!==void 0){let l=e.fields;return o.map(u=>{if(typeof u!="object"||u===null)return u;let c={...u};for(let[s,h]of Object.entries(l))c[s]=gt(h,c[s],n,r);return c})}if(e.element!==void 0){let l=e.element;return o.map(u=>re(l,u,n,r))}return o}function Ce(e,t,n,r=z){let o={};for(let[l,u]of Object.entries(e.slots)){let c=t.schema.slots[l];o[l]=c===void 0?u:re(c,u,n,r)}return o}function Ae(e){return typeof e=="string"?e:e.url}function yt(e,t){return e.split(",").map(n=>{let[r="",...o]=n.trim().split(/\s+/);return[t(r),...o].join(" ")}).join(", ")}function ht(e){return{file(t){let n=z.file(t),r=n.responsive===null?null:{...n.responsive,sources:n.responsive.sources.map(o=>({...o,srcset:yt(o.srcset,e)}))};return{url:e(n.url),responsive:r}},crop(t,n){return e(z.file(t).url,{crop:n})}}}function A(e){return Array.isArray(e)?e:[]}function He(e,t){let{facts:n}=e,r=s=>e.media[s],o=s=>s?.file===null||s?.file===void 0?"":t(Ae(s.file)),l=s=>s?.posterFile!==void 0?t(Ae(s.posterFile)):s?.posterUrl??"",u=[];for(let s of A(n.photos)){let h=r(s.id);u.push({id:s.id,kind:"photo",name:h?.filename||s.id,size:"",src:o(h),caption:s.caption??null})}for(let s of A(n.floor_plans)){let h=r(s.id);u.push({id:s.id,kind:"plan",name:h?.filename||s.id,size:"",src:o(h)})}for(let s of A(n.videos)){let h=s.provider??void 0;u.push({id:s.id,kind:"video",name:s.caption??r(s.id)?.filename??s.id,size:"",src:l(r(s.id)),caption:s.caption??null,ready:!0,durationMs:s.duration_ms??null,...h===void 0?{}:{provider:h}})}for(let s of A(n.tours))u.push({id:s.id,kind:"tour",name:`${s.provider??"Tour"} ${s.id}`,size:"",src:l(r(s.id)),ready:!0,provider:s.provider??""});for(let s of A(n.documents)){let h=r(s.id)?.sizeBytes;u.push({id:s.id,kind:"document",name:s.filename??s.id,size:"",src:"",mime:s.mime??"",...h===void 0?{}:{sizeBytes:h}})}let c=[["avatar_upload_id","headshot"],["logo_dark_upload_id","logo (dark)"],["logo_light_upload_id","logo (light)"]];for(let s of A(n.contacts)){let h=typeof s.name=="string"?s.name:"Contact";for(let[b,$]of c){let x=s[b];typeof x=="string"&&u.push({id:x,kind:"library",name:`${h} \u2014 ${$}`,size:"",src:o(r(x)),caption:h})}}return u}var wt={image:["photo_id","asset_id"],video:["video_id","asset_id"],tour:["tour_id","asset_id"],document:["asset_id"]};function Rt(e){return e.filter(t=>typeof t=="object"&&t!==null&&!Array.isArray(t)).map(({id:t,upload_id:n,floor_label:r,position:o})=>({id:typeof t=="string"?t:"",...typeof n=="string"?{upload_id:n}:{},floor_label:typeof r=="string"?r:null,position:typeof o=="number"?o:0}))}function oe(e,t){if(t==null)return t;let n=wt[e.type];if(n!==void 0){if(typeof t!="object")return null;let o=t,l=n.map(s=>o[s]).find(s=>typeof s=="string"&&s!=="");if(typeof l!="string")return null;if(e.type!=="image")return{asset_id:l};let u=F(o.rect),c=typeof o.mobile=="object"&&o.mobile!==null?F(o.mobile.rect):null;return{asset_id:l,...u===null?{}:{rect:u},...c===null?{}:{mobile_rect:c}}}if(e.type!=="list"||!Array.isArray(t))return t;let r=t;if(e.fields!==void 0){let o=e.fields;return r.map(l=>{if(typeof l!="object"||l===null)return l;let u={...l};for(let[c,s]of Object.entries(o))c in u&&(u[c]=s.type==="image"&&Array.isArray(u[c])?Rt(u[c]):oe(s,u[c]));return u})}if(e.element!==void 0){let o=e.element;return r.map(l=>oe(o,l))}return r}function Me(e){let{instance:t,slots:n,fixture:r,session:o,assetUrl:l}=e,u={...t.slots},c={},s=r.provenance[t.instance_id]??{};for(let b of Object.keys(n))c[b]=s[b]??{kind:"empty"};for(let[b,$]of Object.entries(o??{})){let x=n[b];x!==void 0&&(u[b]=oe(x,$),c[b]={kind:"session"})}let h=new Map(Object.entries(r.media));return{slots:Ce({...t,slots:u},{schema:{slots:n}},h,ht(l)),provenance:c}}var Ne=1024*1024;function _t(e){let t=M(e),n=typeof e.width=="string"?`${e.width} \xD7 ${String(e.height)}`:void 0;return{id:e.id,label:e.label,cssWidth:t.viewportWidth,cssHeight:t.viewportHeight,bleed:t.bleed,pixelWidth:t.pixelWidth,pixelHeight:t.pixelHeight,...n===void 0?{}:{physical:n},tokens:{...N(e)}}}function St(e,t){return new Response(t,{status:e,headers:{"content-type":"text/plain; charset=utf-8"}})}function ie(e){return new Response(JSON.stringify(e),{headers:{"content-type":"application/json; charset=utf-8"}})}function se(e){return new Response(e,{headers:{"content-type":"text/html; charset=utf-8"}})}function vt(e){if(typeof e!="object"||e===null)return null;let t=e.status;return typeof t=="number"&&Number.isInteger(t)&&t>=400&&t<600?t:null}function U(e,t,n){let r=e.searchParams.get(t);if(r===null||r==="")throw new g(400,`${n} needs a ${t} parameter.`);return r}function xt(e){return`<script>
117
117
  (function () {
118
118
  try {
119
119
  var src = new EventSource(${JSON.stringify(e)});
@@ -122,6 +122,6 @@ ${e.body}
122
122
  });
123
123
  } catch (e) { /* no change channel; the page stays as it is */ }
124
124
  })();
125
- </script>`}function bt(e){if(e===E.catalog||e==="api/media"||e.startsWith("api/capture/")||e===I.frame||e===I.print)return!0;let[t,n,o]=e.split("/").filter(Boolean);return t==="fixtures"&&n!==void 0&&o==="live"}function Sn(e){let{reader:t,assetUrl:n,renderer:o}=e,s=(e.base??"/").endsWith("/")?e.base??"/":`${e.base??"/"}/`,l=c=>/^([a-z][a-z0-9+.-]*:|\/)/i.test(c)?c:`${s}${c}`,f=()=>[O.base,O.template].map(c=>l(n(c)));async function r(c){let{fixtures:a}=await t.fixtures(),i=a.find(d=>d.id===c);if(i===void 0){let d=a.filter(h=>h.synthesized!==!0).map(h=>h.id),p=a.length-d.length,u=[d.join(", ")||"none",...p===0?[]:[`${p} synthesized empties`]].join(", and ");throw new g(404,`There is no fixture "${c}" (have: ${u}).`)}return i}function m(c,a){let i=c.instances.find(d=>d.instance_id===a);if(i===void 0)throw new g(400,`The composition places no instance "${a}".`);return i}function v(c,a,i,d,p){if(c.output!=="website")return{selfAnchor:d,anchors:ge(),pages:[]};let u=Se(a,p),h=c.pages.map(_=>({id:_.id,label:_.label,path:_.path??`/${_.id}`,sections:_.sections.map(P=>({key:P.section,anchor:P.section,enabled:u.get(P.instanceId)!==!1}))})),w=`${s}${E.live(a.id,"/").replace(/\/$/,"")}`,b=$e({pages:h,currentPageId:i,basePath:w});return{selfAnchor:d,anchors:b.anchors,pages:b.pages}}async function R(c,a,i,d,p,u){let h=c.instances.find(X=>X.instanceId===d.instance_id);if(h===void 0)throw new Error(`The composition places no section "${d.section_key}".`);let w=_e(d,h.sectionSchema.slots,u),{slots:b,provenance:_}=Ae({instance:w,slots:h.sectionSchema.slots,fixture:a,session:p,assetUrl:n}),P=v(c,a,i,w.section_key,u),S=w.variant,H=await o.section(w.section_key);return{html:o.renderToString(o.createElement(H,{slots:b,nav:P,variant:S??""}),{identifierPrefix:w.instance_id}),resolvedProps:{slots:b,nav:P,variant:S},provenance:_}}async function x(c,a,i){let d=[];for(let p of i.sections){let u=m(a,p.instanceId);u.enabled&&d.push((await R(c,a,i.id,u,void 0,{})).html)}return d}function A(c,a,i){let d=c.pages.find(p=>p.id===a);if(d===void 0)throw new g(i,`The template declares no page "${a}".`);return d}function B(c,a){if(c.output==="website")throw new g(404,`"${c.key}" is a website \u2014 captures are for rendered templates; open its pages live instead.`);let i=a===null?c.formats[0]:c.formats.find(d=>d.id===a);if(i===void 0)throw new g(404,`The template declares no format "${a??""}" (have: ${c.formats.map(d=>d.id).join(", ")}).`);return i}async function Ne(){let c=await t.islands(),a={wire:1,islands:{map:{...c.map},hostScript:c.canvasHost,importMap:{...c.importMap}},stylesheets:[O.base,O.template].map(u=>n(u))},i,d;try{i=await t.template(),d=await t.fixtures()}catch(u){return{...a,template:{key:"",name:"",output:"website",formats:[],pages:[],canvases:[],instances:[]},fixtures:[],capabilities:{hmr:t.live,capture:!1},error:u instanceof Error?u.message:String(u)}}let p=d.problems!==void 0&&d.fixtures.length===0?`No fixture could be rendered:
126
- ${d.problems}`:void 0;return{...a,template:{key:i.key,name:i.name,output:i.output,formats:i.output==="website"?[]:i.formats.map(yt),pages:i.pages.map(u=>({id:u.id,label:u.label,...u.path===void 0?{}:{path:u.path},instanceIds:u.sections.map(h=>h.instanceId)})),canvases:i.canvases.map(u=>({id:u.id,label:u.label,pages:[...u.pages]})),instances:i.instances.map(u=>({...u,display:he(u.display)}))},fixtures:d.fixtures.map(Ie),capabilities:{hmr:t.live,capture:i.output!=="website"&&t.capture!==void 0},...p===void 0?{}:{error:p}}}async function Me(c){if(c.method!=="POST")throw new g(405,`POST a render request to ${E.render}.`);let a=await c.text();if(new TextEncoder().encode(a).byteLength>He)throw new g(413,`request body exceeds ${He} bytes`);let i;try{i=a===""?void 0:JSON.parse(a)}catch(b){throw new g(400,`request body is not JSON: ${b instanceof Error?b.message:String(b)}`)}if(i===void 0||typeof i.page!="string"||typeof i.instance!="string"||typeof i.fixture!="string")throw new g(400,"A render request names a page, an instance and a fixture.");let d=typeof i.session=="object"&&i.session!==null?i.session:{},p=Re(i.display),u=await t.template(),h=await r(i.fixture),w=A(u,i.page,400);return be(u,p),R(u,h,w.id,m(h,i.instance),d.slots,p)}async function De(c){let a=await r(U(c,"fixture","api/media"));return{items:Ce(a,n)}}async function Oe(c,a){let i=await t.template();if(i.output!=="website")throw new g(404,`"${i.key}" is a rendered ${i.output} template and has no live pages \u2014 preview it on the canvas.`);let d=i.pages.find(h=>h.path===a);if(d===void 0){let h=i.pages.map(w=>w.path??w.id).join(", ");throw new g(404,`The template declares no page at "${a}" (have: ${h}).`)}let p=await r(c),u=await x(i,p,d);return k({destination:"preview",root:{kind:"plain",bodyHtml:u.join(`
127
- `)},islands:(await t.islands()).documentLoader,stylesheets:{kind:"links",hrefs:f()},title:`${i.name} \u2014 ${d.label}`,extraCss:["html, body { background: #fff; }"],...t.live?{devScripts:[Rt(`${s}${E.hmr}`)]}:{}})}function ae(c,a,i){let d=A(c,i,404);if(!V(a,d.id))throw new g(404,`The fixture "${a.id}" switches the page "${d.id}" off, so it has no capture.`);return d}async function Fe(c){let a=I.frame,i=await t.template(),d=B(i,c.searchParams.get("format")),p=await r(U(c,"fixture",a)),u=ae(i,p,U(c,"page",a));return k({destination:"artifact",root:{kind:"frame",format:d,sectionHtml:await x(i,p,u)},islands:(await t.islands()).documentLoader,stylesheets:{kind:"links",hrefs:f()},title:`${i.name} \u2014 ${u.id}`})}async function Ue(c){let a=await t.template(),i=B(a,c.searchParams.get("format"));if(a.output!=="document")throw new g(404,`"${a.key}" is an ${a.output} template \u2014 a PDF is for the document class; download its pages as a zip.`);let d=await r(U(c,"fixture",I.print)),p=[];for(let u of te(d,a.pages))p.push(await x(a,d,u));if(p.length===0)throw new g(404,`The fixture "${d.id}" switches every page off, so it has no PDF.`);return k({destination:"artifact",root:{kind:"frameStack",format:i,pages:p},islands:(await t.islands()).documentLoader,stylesheets:{kind:"links",hrefs:f()},title:`${a.name} \u2014 print`})}async function je(c,a){let i=c;if(i!=="screenshot"&&i!=="bundle"&&i!=="print")throw new g(404,`There is no capture at ${a.pathname}.`);let d=U(a,"fixture",`api/capture/${i}`),p=await t.template(),u=B(p,a.searchParams.get("format")),h=await r(d),w,b,_;if(i==="screenshot"){let S=a.searchParams.get("page")??te(h,p.pages)[0]?.id;if(S===void 0)throw new g(404,`The fixture "${d}" leaves no page on.`);ae(p,h,S),w={kind:i,fixture:d,format:u,documents:[{path:ne(d,S,u.id),page:S,name:`${S}.png`}]},b="image/png",_=`${p.key}-${S}-${u.id}.png`}else if(i==="bundle"){if(p.output!=="image")throw new g(404,`"${p.key}" is a ${p.output} template \u2014 the zip is for the image class; a document downloads its PDF.`);let S=a.searchParams.get("canvas"),H=S===null?p.canvases[0]:p.canvases.find($=>$.id===S);if(H===void 0)throw new g(404,`The template declares no canvas "${S??""}".`);let G=H.pages.filter($=>V(h,$));if(G.length===0)throw new g(404,`The fixture "${d}" switches every page of the canvas "${H.id}" off, so it has no zip.`);let X=G.map($=>({path:ne(d,$,u.id),page:$,name:`${p.pages.find(We=>We.id===$)?.label||$}.png`}));w={kind:i,fixture:d,format:u,documents:X},b="application/zip",_=`${p.key}-${u.id}.zip`}else{if(p.output!=="document")throw new g(404,`"${p.key}" is an ${p.output} template \u2014 a PDF is for the document class; download its pages as a zip.`);w={kind:i,fixture:d,format:u,documents:[{path:Te(d,u.id),page:null,name:`${p.key}.pdf`}]},b="application/pdf",_=`${p.key}.pdf`}if(t.capture===void 0)throw new g(501,"This playground has no captures to give.");let P=await t.capture(w);return new Response(new Uint8Array(P),{headers:{"content-type":b,"content-disposition":`attachment; filename="${encodeURIComponent(_)}"`}})}async function Le(c,a,i){if(i===E.render)return se(await Me(c));if(c.method!=="GET"&&c.method!=="HEAD"&&bt(i))throw new g(405,`${i} only reads; the playground accepts no uploads and writes nothing.`);if(i===E.catalog)return se(await Ne());if(i==="api/media")return se(await De(a));if(i.startsWith("api/capture/"))return je(i.slice(12),a);if(i===I.frame)return ie(await Fe(a));if(i===I.print)return ie(await Ue(a));let[d,p,u,h,...w]=i.split("/").filter(Boolean);if(d==="fixtures"&&p!==void 0&&u==="live"){if(w.length>0)throw new g(404,`There is no route at ${a.pathname}.`);return ie(await Oe(decodeURIComponent(p),h===void 0?"/":`/${decodeURIComponent(h)}`))}return null}return{async handle(c){let a=new URL(c.url);if(!a.pathname.startsWith(s)&&`${a.pathname}/`!==s)return null;let i=a.pathname.slice(s.length);try{return await Le(c,a,i)}catch(d){let p=wt(d);if(p===null)throw d;return ht(p,d instanceof Error?d.message:String(d))}}}}export{Sn as createHost};
125
+ </script>`}function It(e){if(e===k.catalog||e==="api/media"||e.startsWith("api/capture/")||e===I.frame||e===I.print)return!0;let[t,n,r]=e.split("/").filter(Boolean);return t==="fixtures"&&n!==void 0&&r==="live"}function Pn(e){let{reader:t,assetUrl:n,renderer:r}=e,o=(e.base??"/").endsWith("/")?e.base??"/":`${e.base??"/"}/`,l=p=>/^([a-z][a-z0-9+.-]*:|\/)/i.test(p)?p:`${o}${p}`,u=()=>[O.base,O.template].map(p=>l(n(p)));async function c(p){let{fixtures:a}=await t.fixtures(),i=a.find(d=>d.id===p);if(i===void 0){let d=a.map(m=>m.id).join(", ")||"none";throw new g(404,`There is no fixture "${p}" (have: ${d}).`)}return i}function s(p,a){let i=p.instances.find(d=>d.instance_id===a);if(i===void 0)throw new g(400,`The composition places no instance "${a}".`);return i}function h(p,a,i,d,m){if(p.output!=="website")return{selfAnchor:d,anchors:ge(),pages:[]};let f=_e(a,m),w=p.pages.map(v=>({id:v.id,label:v.label,path:v.path??`/${v.id}`,sections:v.sections.map(P=>({key:P.section,anchor:P.section,enabled:f.get(P.instanceId)!==!1}))})),R=`${o}${k.live(a.id,"/").replace(/\/$/,"")}`,_=Ee({pages:w,currentPageId:i,basePath:R});return{selfAnchor:d,anchors:_.anchors,pages:_.pages}}async function b(p,a,i,d,m,f){let w=p.instances.find(G=>G.instanceId===d.instance_id);if(w===void 0)throw new Error(`The composition places no section "${d.section_key}".`);let R=Se(d,w.sectionSchema.slots,f),{slots:_,provenance:v}=Me({instance:R,slots:w.sectionSchema.slots,fixture:a,session:m,assetUrl:n}),P=h(p,a,i,R.section_key,f),S=R.variant,H=await r.section(R.section_key);return{html:r.renderToString(r.createElement(H,{slots:_,nav:P,variant:S??""}),{identifierPrefix:R.instance_id}),resolvedProps:{slots:_,nav:P,variant:S},provenance:v}}async function $(p,a,i){let d=[];for(let m of i.sections){let f=s(a,m.instanceId);f.enabled&&d.push((await b(p,a,i.id,f,void 0,{})).html)}return d}function x(p,a,i){let d=p.pages.find(m=>m.id===a);if(d===void 0)throw new g(i,`The template declares no page "${a}".`);return d}function B(p,a){if(p.output==="website")throw new g(404,`"${p.key}" is a website \u2014 captures are for rendered templates; open its pages live instead.`);let i=a===null?p.formats[0]:p.formats.find(d=>d.id===a);if(i===void 0)throw new g(404,`The template declares no format "${a??""}" (have: ${p.formats.map(d=>d.id).join(", ")}).`);return i}async function De(){let p=await t.islands(),a={wire:1,islands:{map:{...p.map},hostScript:p.canvasHost,importMap:{...p.importMap}},stylesheets:[O.base,O.template].map(f=>n(f))},i,d;try{i=await t.template(),d=await t.fixtures()}catch(f){return{...a,template:{key:"",name:"",output:"website",formats:[],pages:[],canvases:[],instances:[]},fixtures:[],capabilities:{hmr:t.live,capture:!1},error:f instanceof Error?f.message:String(f)}}let m=d.problems!==void 0&&d.fixtures.length===0?`No fixture could be rendered:
126
+ ${d.problems}`:void 0;return{...a,template:{key:i.key,name:i.name,output:i.output,formats:i.output==="website"?[]:i.formats.map(_t),pages:i.pages.map(f=>({id:f.id,label:f.label,...f.path===void 0?{}:{path:f.path},instanceIds:f.sections.map(w=>w.instanceId)})),canvases:i.canvases.map(f=>({id:f.id,label:f.label,pages:[...f.pages]})),instances:i.instances.map(f=>({...f,display:he(f.display)}))},fixtures:d.fixtures.map(Ie),capabilities:{hmr:t.live,capture:i.output!=="website"&&t.capture!==void 0},...m===void 0?{}:{error:m}}}async function Oe(p){if(p.method!=="POST")throw new g(405,`POST a render request to ${k.render}.`);let a=await p.text();if(new TextEncoder().encode(a).byteLength>Ne)throw new g(413,`request body exceeds ${Ne} bytes`);let i;try{i=a===""?void 0:JSON.parse(a)}catch(_){throw new g(400,`request body is not JSON: ${_ instanceof Error?_.message:String(_)}`)}if(i===void 0||typeof i.page!="string"||typeof i.instance!="string"||typeof i.fixture!="string")throw new g(400,"A render request names a page, an instance and a fixture.");let d=typeof i.session=="object"&&i.session!==null?i.session:{},m=Re(i.display),f=await t.template(),w=await c(i.fixture),R=x(f,i.page,400);return be(f,m),b(f,w,R.id,s(w,i.instance),d.slots,m)}async function Fe(p){let a=await c(U(p,"fixture","api/media"));return{items:He(a,n)}}async function Ue(p,a){let i=await t.template();if(i.output!=="website")throw new g(404,`"${i.key}" is a rendered ${i.output} template and has no live pages \u2014 preview it on the canvas.`);let d=i.pages.find(w=>w.path===a);if(d===void 0){let w=i.pages.map(R=>R.path??R.id).join(", ");throw new g(404,`The template declares no page at "${a}" (have: ${w}).`)}let m=await c(p),f=await $(i,m,d);return C({destination:"preview",root:{kind:"plain",bodyHtml:f.join(`
127
+ `)},islands:(await t.islands()).documentLoader,stylesheets:{kind:"links",hrefs:u()},title:`${i.name} - ${d.label}`,extraCss:["html, body { background: #fff; }"],...t.live?{devScripts:[xt(`${o}${k.hmr}`)]}:{}})}function ae(p,a,i){let d=x(p,i,404);if(!V(a,d.id))throw new g(404,`The fixture "${a.id}" switches the page "${d.id}" off, so it has no capture.`);return d}async function je(p){let a=I.frame,i=await t.template(),d=B(i,p.searchParams.get("format")),m=await c(U(p,"fixture",a)),f=ae(i,m,U(p,"page",a));return C({destination:"artifact",root:{kind:"frame",format:d,sectionHtml:await $(i,m,f)},islands:(await t.islands()).documentLoader,stylesheets:{kind:"links",hrefs:u()},title:`${i.name} \u2014 ${f.id}`})}async function Le(p){let a=await t.template(),i=B(a,p.searchParams.get("format"));if(a.output!=="document")throw new g(404,`"${a.key}" is an ${a.output} template \u2014 a PDF is for the document class; download its pages as a zip.`);let d=await c(U(p,"fixture",I.print)),m=[];for(let f of te(d,a.pages))m.push(await $(a,d,f));if(m.length===0)throw new g(404,`The fixture "${d.id}" switches every page off, so it has no PDF.`);return C({destination:"artifact",root:{kind:"frameStack",format:i,pages:m},islands:(await t.islands()).documentLoader,stylesheets:{kind:"links",hrefs:u()},title:`${a.name} \u2014 print`})}async function We(p,a){let i=p;if(i!=="screenshot"&&i!=="bundle"&&i!=="print")throw new g(404,`There is no capture at ${a.pathname}.`);let d=U(a,"fixture",`api/capture/${i}`),m=await t.template(),f=B(m,a.searchParams.get("format")),w=await c(d),R,_,v;if(i==="screenshot"){let S=a.searchParams.get("page")??te(w,m.pages)[0]?.id;if(S===void 0)throw new g(404,`The fixture "${d}" leaves no page on.`);ae(m,w,S),R={kind:i,fixture:d,format:f,documents:[{path:ne(d,S,f.id),page:S,name:`${S}.png`}]},_="image/png",v=`${m.key}-${S}-${f.id}.png`}else if(i==="bundle"){if(m.output!=="image")throw new g(404,`"${m.key}" is a ${m.output} template \u2014 the zip is for the image class; a document downloads its PDF.`);let S=a.searchParams.get("canvas"),H=S===null?m.canvases[0]:m.canvases.find(E=>E.id===S);if(H===void 0)throw new g(404,`The template declares no canvas "${S??""}".`);let X=H.pages.filter(E=>V(w,E));if(X.length===0)throw new g(404,`The fixture "${d}" switches every page of the canvas "${H.id}" off, so it has no zip.`);let G=X.map(E=>({path:ne(d,E,f.id),page:E,name:`${m.pages.find(qe=>qe.id===E)?.label||E}.png`}));R={kind:i,fixture:d,format:f,documents:G},_="application/zip",v=`${m.key}-${f.id}.zip`}else{if(m.output!=="document")throw new g(404,`"${m.key}" is an ${m.output} template \u2014 a PDF is for the document class; download its pages as a zip.`);R={kind:i,fixture:d,format:f,documents:[{path:ke(d,f.id),page:null,name:`${m.key}.pdf`}]},_="application/pdf",v=`${m.key}.pdf`}if(t.capture===void 0)throw new g(501,"This playground has no captures to give.");let P=await t.capture(R);return new Response(new Uint8Array(P),{headers:{"content-type":_,"content-disposition":`attachment; filename="${encodeURIComponent(v)}"`}})}async function Ve(p,a,i){if(i===k.render)return ie(await Oe(p));if(p.method!=="GET"&&p.method!=="HEAD"&&It(i))throw new g(405,`${i} only reads; the playground accepts no uploads and writes nothing.`);if(i===k.catalog)return ie(await De());if(i==="api/media")return ie(await Fe(a));if(i.startsWith("api/capture/"))return We(i.slice(12),a);if(i===I.frame)return se(await je(a));if(i===I.print)return se(await Le(a));let[d,m,f,w,...R]=i.split("/").filter(Boolean);if(d==="fixtures"&&m!==void 0&&f==="live"){if(R.length>0)throw new g(404,`There is no route at ${a.pathname}.`);return se(await Ue(decodeURIComponent(m),w===void 0?"/":`/${decodeURIComponent(w)}`))}return null}return{async handle(p){let a=new URL(p.url);if(!a.pathname.startsWith(o)&&`${a.pathname}/`!==o)return null;let i=a.pathname.slice(o.length);try{return await Ve(p,a,i)}catch(d){let m=vt(d);if(m===null)throw d;return St(m,d instanceof Error?d.message:String(d))}}}}export{Pn as createHost};
@@ -8,6 +8,7 @@ import { verifyArtifact } from "../../packages/internal/template-artifact/dist/v
8
8
  import "../../packages/internal/template-artifact/dist/index.js";
9
9
  import { compileTemplateCss } from "../../css/compile.js";
10
10
  import { mediaCacheDir } from "../media/cache.js";
11
+ import { frameRungFloor } from "../media/frame-rung-floor.js";
11
12
  import { usedFactsFromSchema } from "../../schema/extract-used-facts.js";
12
13
  import { exportSite } from "../../section/discovery.js";
13
14
  import { buildSection } from "./sections.js";
@@ -87,7 +88,8 @@ async function buildArtifact(options) {
87
88
  root,
88
89
  key,
89
90
  module,
90
- exportName: site.exportName
91
+ exportName: site.exportName,
92
+ minRungWidth: frameRungFloor(template)
91
93
  });
92
94
  if (built.passthrough.size > 0) throw new Error(`Section "${local}" imports images that could not be derived because \`sharp\` is not installed: ${[...built.passthrough].map((p) => relative(root, p)).join(", ")}. An artifact carries every image's responsive ladder; reinstall so sharp's native binary lands, then build again.`);
93
95
  builtByKey.set(key, built);
@@ -172,7 +174,8 @@ async function buildArtifact(options) {
172
174
  const fixtures = await fixtureFiles({
173
175
  fixtures: corpus.filter((entry) => entry.emptied === void 0).map((entry) => entry.fixture),
174
176
  assets: fixtureAssets,
175
- cacheDir: mediaCacheDir(root)
177
+ cacheDir: mediaCacheDir(root),
178
+ minRungWidth: frameRungFloor(template)
176
179
  });
177
180
  for (const [path, bytes] of fixtures.files) files.set(path, bytes);
178
181
  for (const asset of fixtures.assets) putAsset(files, asset);
@@ -37,25 +37,22 @@ async function captureFiles(options) {
37
37
  const template = await server.workspace.template();
38
38
  const { fixtures, problems } = await server.workspace.fixtures();
39
39
  if (problems !== void 0) throw new Error(`build: the fixtures did not resolve for capture:\n${problems}`);
40
- for (const fixture of fixtures) {
41
- if (fixture.synthesized === true) continue;
42
- for (const format of template.formats) {
43
- const take = async (kind, target, file) => {
44
- const response = await fetch(new URL(ROUTES.capture(kind, {
45
- fixture: fixture.id,
46
- format: format.id,
47
- ...target
48
- }), server.url));
49
- if (!response.ok) throw new Error(`build: capturing ${file} of fixture "${fixture.id}" at ${format.id} failed (${String(response.status)}): ${await response.text()}`);
50
- files.set(capturePath(fixture.id, format.id, file), new Uint8Array(await response.arrayBuffer()));
51
- };
52
- if (template.output === "document") {
53
- await take("print", {}, CAPTURE_FILES.document);
54
- continue;
55
- }
56
- for (const page of enabledPages(fixture, template.pages)) await take("screenshot", { page: page.id }, `${page.id}.png`);
57
- await take("bundle", {}, CAPTURE_FILES.bundle);
40
+ for (const fixture of fixtures) for (const format of template.formats) {
41
+ const take = async (kind, target, file) => {
42
+ const response = await fetch(new URL(ROUTES.capture(kind, {
43
+ fixture: fixture.id,
44
+ format: format.id,
45
+ ...target
46
+ }), server.url));
47
+ if (!response.ok) throw new Error(`build: capturing ${file} of fixture "${fixture.id}" at ${format.id} failed (${String(response.status)}): ${await response.text()}`);
48
+ files.set(capturePath(fixture.id, format.id, file), new Uint8Array(await response.arrayBuffer()));
49
+ };
50
+ if (template.output === "document") {
51
+ await take("print", {}, CAPTURE_FILES.document);
52
+ continue;
58
53
  }
54
+ for (const page of enabledPages(fixture, template.pages)) await take("screenshot", { page: page.id }, `${page.id}.png`);
55
+ await take("bundle", {}, CAPTURE_FILES.bundle);
59
56
  }
60
57
  } finally {
61
58
  await server.close();
@@ -30,7 +30,10 @@ async function fixtureFiles(input) {
30
30
  const bytes = new Uint8Array(await readFile(source.path));
31
31
  let result;
32
32
  if (source.derived && typeof file !== "string") {
33
- const derivation = await deriveAuthorImage(source.path, bytes, { cacheDir: input.cacheDir });
33
+ const derivation = await deriveAuthorImage(source.path, bytes, {
34
+ cacheDir: input.cacheDir,
35
+ minRungWidth: input.minRungWidth
36
+ });
34
37
  if (derivation.passthrough) throw new Error(`Fixture media ${source.path} could not be derived because \`sharp\` is not installed. An artifact carries every image's responsive ladder; reinstall so sharp's native binary lands, then build again.`);
35
38
  for (const asset of [...derivation.derivatives, derivation.master]) assets.set(asset.filename, asset);
36
39
  result = {
@@ -63,14 +66,19 @@ async function fixtureFiles(input) {
63
66
  const urls = /* @__PURE__ */ new Map();
64
67
  const media = {};
65
68
  for (const [id, entry] of fixture.media) {
69
+ const poster = entry.posterFile === void 0 ? null : await artifactFile(entry.posterFile);
70
+ const withPoster = poster === null ? entry : {
71
+ ...entry,
72
+ posterFile: poster.file
73
+ };
66
74
  if (entry.file === null) {
67
- media[id] = entry;
75
+ media[id] = withPoster;
68
76
  continue;
69
77
  }
70
78
  const stored = await artifactFile(entry.file);
71
79
  for (const [from, to] of stored.urls) urls.set(from, to);
72
80
  media[id] = {
73
- ...entry,
81
+ ...withPoster,
74
82
  file: stored.file,
75
83
  sizeBytes: stored.bytes
76
84
  };
@@ -140,7 +140,7 @@ function sourcesOf(metafile) {
140
140
  }
141
141
  /** Build a placed section's renderer bundle and its island chunks. */
142
142
  async function buildSection(input) {
143
- const { root, key } = input;
143
+ const { root, key, minRungWidth } = input;
144
144
  const cacheDir = mediaCacheDir(root);
145
145
  const found = /* @__PURE__ */ new Map();
146
146
  const assets = /* @__PURE__ */ new Map();
@@ -169,12 +169,18 @@ async function buildSection(input) {
169
169
  for (const [masterKey, filename] of deriver.masters) masters.set(masterKey, filename);
170
170
  for (const path of deriver.passthrough) passthrough.add(path);
171
171
  };
172
- const rendererDeriver = createMediaDeriver({ cacheDir });
172
+ const rendererDeriver = createMediaDeriver({
173
+ cacheDir,
174
+ minRungWidth
175
+ });
173
176
  const rendered = await rendererPass(input, rendererDeriver, found, true);
174
177
  collect(rendererDeriver, rendered.outputFiles, rendered.metafile);
175
178
  const islands = [];
176
179
  for (const [islandKey, file] of [...found].sort(([a], [b]) => a < b ? -1 : 1)) {
177
- const deriver = createMediaDeriver({ cacheDir });
180
+ const deriver = createMediaDeriver({
181
+ cacheDir,
182
+ minRungWidth
183
+ });
178
184
  const bytes = await runPass(`The island chunk ${islandKey}`, async () => {
179
185
  const result = await build({
180
186
  entryPoints: [file],
@@ -225,7 +231,10 @@ async function buildSection(input) {
225
231
  * not delete it. Never written to an artifact.
226
232
  */
227
233
  async function buildFramedRenderer(input) {
228
- return (await rendererPass(input, createMediaDeriver({ cacheDir: mediaCacheDir(input.root) }), /* @__PURE__ */ new Map(), false)).bytes;
234
+ return (await rendererPass(input, createMediaDeriver({
235
+ cacheDir: mediaCacheDir(input.root),
236
+ minRungWidth: input.minRungWidth
237
+ }), /* @__PURE__ */ new Map(), false)).bytes;
229
238
  }
230
239
  /** Where `check` writes a framed renderer to import it: inside the workspace, so its React resolves from there. */
231
240
  function framedRendererPath(root, key, bytes) {
@@ -2,6 +2,7 @@ import { isTemplate } from "../../template/define-template.js";
2
2
  import { listModules } from "../../section/discovery.js";
3
3
  import { MEDIA_LOADERS, createFixtureMediaPlugin, externalOutsideWorkspace } from "../../fixtures/media-plugin.js";
4
4
  import { runningCopyPlugin } from "../../template/running-copy.js";
5
+ import { createPackageStylesheetsPlugin } from "../../fixtures/package-stylesheets.js";
5
6
  import { existsSync } from "node:fs";
6
7
  import { join, relative, sep } from "node:path";
7
8
  import { pathToFileURL } from "node:url";
@@ -35,6 +36,7 @@ async function loadWorkspace(root) {
35
36
  };
36
37
  const files = listModules(root);
37
38
  const media = createFixtureMediaPlugin(root);
39
+ const stylesheets = await createPackageStylesheetsPlugin(root);
38
40
  let result;
39
41
  try {
40
42
  result = await build({
@@ -56,7 +58,8 @@ async function loadWorkspace(root) {
56
58
  plugins: [
57
59
  runningCopyPlugin(),
58
60
  externalOutsideWorkspace(root),
59
- media.plugin
61
+ media.plugin,
62
+ stylesheets.plugin
60
63
  ],
61
64
  sourcemap: "inline",
62
65
  metafile: true,
@@ -78,6 +81,8 @@ async function loadWorkspace(root) {
78
81
  message: m.text
79
82
  }))
80
83
  };
84
+ } finally {
85
+ await stylesheets.dispose();
81
86
  }
82
87
  process.setSourceMapsEnabled(true);
83
88
  const outputByInput = /* @__PURE__ */ new Map();
@@ -1,5 +1,6 @@
1
1
  import { publishedSectionKey } from "../../../packages/internal/template-artifact/dist/layout.js";
2
2
  import "../../../packages/internal/template-artifact/dist/index.js";
3
+ import { frameRungFloor } from "../../media/frame-rung-floor.js";
3
4
  import { exportSite } from "../../../section/discovery.js";
4
5
  import { buildFramedRenderer, buildSection, framedRendererPath } from "../../build/sections.js";
5
6
  import { workspacePath } from "../load-workspace.js";
@@ -39,7 +40,8 @@ async function bundlesStage(ctx) {
39
40
  root: ctx.root,
40
41
  key: publishedSectionKey(template.key, entry.key),
41
42
  module: join(ctx.root, site.module),
42
- exportName: site.exportName
43
+ exportName: site.exportName,
44
+ minRungWidth: frameRungFloor(template)
43
45
  };
44
46
  let section;
45
47
  try {
@@ -78,7 +78,7 @@ const DECLARED_COMMANDS = [
78
78
  constraints: [
79
79
  "The only producer of an artifact. Nothing else — no bare bundler — writes one.",
80
80
  "Deterministic: the same tree builds to the same artifact hash.",
81
- "An image or document template also carries `captures/`: every authored fixture at every declared format, taken exactly as `dev`'s *Download fixture render* takes it — the enabled pages and their zip, or the PDF. Captures sit outside the artifact hash, and need Playwright: without it, build refuses with the install line.",
81
+ "An image or document template also carries `captures/`: every authored fixture at every declared format, taken exactly as `dev`'s *Download* takes it — the enabled pages and their zip, or the PDF. Captures sit outside the artifact hash, and need Playwright: without it, build refuses with the install line.",
82
82
  `The default output directory, \`${DEFAULT_BUILD_DIR}/\`, is gitignored by the scaffold.`
83
83
  ]
84
84
  },
@@ -1,5 +1,6 @@
1
1
  import { islandEsbuildPlugin } from "./islands.js";
2
2
  import { MEDIA_LOADERS, createFixtureMediaPlugin, externalOutsideWorkspace } from "../../fixtures/media-plugin.js";
3
+ import { createPackageStylesheetsPlugin } from "../../fixtures/package-stylesheets.js";
3
4
  import { join } from "node:path";
4
5
  import { pathToFileURL } from "node:url";
5
6
  import { build } from "esbuild";
@@ -10,32 +11,38 @@ let serial = 0;
10
11
  async function loadTemplateModule(options) {
11
12
  const { root } = options;
12
13
  const media = createFixtureMediaPlugin(root);
14
+ const stylesheets = await createPackageStylesheetsPlugin(root);
13
15
  const outfile = join(root, ".concrete", "cache", "dev", "template.mjs");
14
- await build({
15
- entryPoints: [options.templateFile],
16
- bundle: true,
17
- format: "esm",
18
- platform: "node",
19
- target: "node22",
20
- outfile,
21
- absWorkingDir: root,
22
- packages: "external",
23
- jsx: "automatic",
24
- loader: {
25
- ".css": "empty",
26
- ...MEDIA_LOADERS
27
- },
28
- plugins: [
29
- externalOutsideWorkspace(root),
30
- islandEsbuildPlugin({
31
- root,
32
- markerSpecifier: options.markerSpecifier
33
- }),
34
- media.plugin
35
- ],
36
- write: true,
37
- logLevel: "silent"
38
- });
16
+ try {
17
+ await build({
18
+ entryPoints: [options.templateFile],
19
+ bundle: true,
20
+ format: "esm",
21
+ platform: "node",
22
+ target: "node22",
23
+ outfile,
24
+ absWorkingDir: root,
25
+ packages: "external",
26
+ jsx: "automatic",
27
+ loader: {
28
+ ".css": "empty",
29
+ ...MEDIA_LOADERS
30
+ },
31
+ plugins: [
32
+ externalOutsideWorkspace(root),
33
+ islandEsbuildPlugin({
34
+ root,
35
+ markerSpecifier: options.markerSpecifier
36
+ }),
37
+ media.plugin,
38
+ stylesheets.plugin
39
+ ],
40
+ write: true,
41
+ logLevel: "silent"
42
+ });
43
+ } finally {
44
+ await stylesheets.dispose();
45
+ }
39
46
  return {
40
47
  template: (await import(`${pathToFileURL(outfile).href}?load=${Date.now()}-${serial++}`)).default,
41
48
  assets: media.assets
@@ -10,7 +10,7 @@ import { croppedMediaUrl, cutRegion } from "./crop.js";
10
10
  import { createHmrBus } from "./hmr.js";
11
11
  import { RequestError, contentTypeFor, readBody, sendBytes, sendFile, sendHtml, sendText } from "./http.js";
12
12
  import { respondToHandlerError } from "./request-error.js";
13
- import { createDevVite } from "./vite.js";
13
+ import { createDevVite, settleBrowserDependencies } from "./vite.js";
14
14
  import { DevWorkspace } from "./workspace-reader.js";
15
15
  import { existsSync, statSync } from "node:fs";
16
16
  import { dirname, extname, join, relative, resolve, sep } from "node:path";
@@ -103,7 +103,10 @@ async function startDevServer(options) {
103
103
  packageRoot
104
104
  });
105
105
  const origin = `http://localhost:${port}/`;
106
+ let browserGraphSettled = null;
106
107
  const capture = async (request) => {
108
+ browserGraphSettled ??= settleBrowserDependencies(vite, [...islands.previewHost === null ? [] : [islands.previewHost], ...Object.values(islands.map)]);
109
+ await browserGraphSettled;
107
110
  try {
108
111
  return await captureFixture(capturer, origin, request);
109
112
  } catch (err) {
@@ -139,6 +142,7 @@ async function startDevServer(options) {
139
142
  const fixturesDir = join(root, "fixtures") + sep;
140
143
  const onChange = (path) => {
141
144
  vite.moduleGraph.invalidateAll();
145
+ browserGraphSettled = null;
142
146
  if (path.startsWith(fixturesDir)) {
143
147
  workspace.invalidateFixtures();
144
148
  hmr.broadcast(HMR_EVENTS.fixtures);
@@ -80,6 +80,42 @@ async function createDevVite(options) {
80
80
  }
81
81
  });
82
82
  }
83
+ /**
84
+ * Resolves once the browser graph reachable from `entryUrls` has been transformed and the
85
+ * dependency optimizer has committed every package that graph imports. Never rejects: a
86
+ * module that fails to transform is left for the page to report.
87
+ *
88
+ * A capture awaits this before Chromium opens a page. A package import Vite first meets
89
+ * mid-page — one the dependency scan missed, or one added after the cache under
90
+ * `node_modules/.vite` was written — re-optimizes, and when that moves an optimized file
91
+ * Vite FULL-RELOADS every open page, destroying the one a capture is settling. Met here,
92
+ * with no page open, the reload lands on nobody.
93
+ */
94
+ async function settleBrowserDependencies(vite, entryUrls) {
95
+ const client = vite.environments.client;
96
+ const optimizer = client.depsOptimizer;
97
+ const seen = /* @__PURE__ */ new Set();
98
+ const crawl = async (url) => {
99
+ if (seen.has(url) || optimizer?.isOptimizedDepUrl(url) === true) return;
100
+ seen.add(url);
101
+ try {
102
+ await client.transformRequest(url);
103
+ } catch {
104
+ return;
105
+ }
106
+ const node = await client.moduleGraph.getModuleByUrl(url);
107
+ await Promise.all([...node?.importedModules ?? []].map((imported) => crawl(imported.url)));
108
+ };
109
+ await Promise.all(entryUrls.map(crawl));
110
+ if (optimizer === void 0) return;
111
+ for (;;) {
112
+ await optimizer.scanProcessing;
113
+ const pending = Object.values(optimizer.metadata.discovered).flatMap((dep) => dep.processing === void 0 ? [] : [dep.processing]);
114
+ if (pending.length === 0) break;
115
+ await Promise.all(pending);
116
+ }
117
+ await new Promise((resolveTurn) => setImmediate(resolveTurn));
118
+ }
83
119
 
84
120
  //#endregion
85
- export { authorImagePlugin, createDevVite };
121
+ export { authorImagePlugin, createDevVite, settleBrowserDependencies };