@homepages/concrete 1.0.1 → 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.
- package/CHANGELOG.md +22 -0
- package/codemods/manifest.json +8 -0
- package/dist/artifact/playground/client/assets/index-CckS2ONm.css +1 -0
- package/dist/artifact/playground/client/assets/{index-JloQyj8h.js → index-Da8V3M7E.js} +105 -105
- package/dist/artifact/playground/client/index.html +2 -2
- package/dist/artifact/playground/host.mjs +20 -20
- package/dist/cli/build/artifact.js +7 -3
- package/dist/cli/build/captures.js +15 -18
- package/dist/cli/build/fixtures.js +11 -3
- package/dist/cli/build/sections.js +13 -4
- package/dist/cli/check/load-workspace.js +7 -2
- package/dist/cli/check/stages/bundles.js +5 -2
- package/dist/cli/check/stages/logic.js +2 -1
- package/dist/cli/check/stages/sections.js +2 -1
- package/dist/cli/commands.js +1 -1
- package/dist/cli/dev/load-template.js +32 -25
- package/dist/cli/dev/server.js +5 -1
- package/dist/cli/dev/vite.js +37 -1
- package/dist/cli/dev/workspace-reader.js +2 -6
- package/dist/cli/media/derive.js +30 -3
- package/dist/cli/media/deriver-plugin.js +6 -2
- package/dist/cli/media/frame-rung-floor.js +18 -0
- package/dist/css/graph.js +2 -1
- package/dist/fixtures/load.js +6 -1
- package/dist/fixtures/media.js +37 -6
- package/dist/fixtures/package-stylesheets.js +59 -0
- package/dist/fixtures/property.js +28 -7
- package/dist/fixtures.d.ts +27 -4
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/primitives/slot-bindings.d.ts +19 -13
- package/dist/primitives/slot-bindings.js +7 -3
- package/dist/section/discovery.js +27 -4
- package/dist/section/section.d.ts +6 -1
- package/dist/template/logic-build.js +54 -9
- package/guide/reference/cli/build.md +1 -1
- package/package.json +1 -1
- 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-
|
|
8
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
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
|
|
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",
|
|
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
|
|
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,
|
|
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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ce(e){return ue(e.id,{...
|
|
86
|
+
})()`;function D(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026")}function y(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}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}${
|
|
88
|
+
${e.root.bodyHtml}${r}${ee(e.islands,"viewport")}
|
|
89
89
|
<script type="module" src="${y(e.analyticsJs.url)}"></script>
|
|
90
|
-
</body>`})}function
|
|
91
|
-
${
|
|
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
|
|
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
|
|
102
|
-
`)}function
|
|
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
|
|
106
|
-
<script>window.__TR_ISLAND_MAP=${n};${
|
|
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
|
-
${
|
|
109
|
-
<script>window.__TR_ISLAND_MAP = ${n};${
|
|
110
|
-
<script type="module" src="${y(e.bootstrapUrl)}"></script>`}var
|
|
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
|
|
126
|
-
${d.problems}`:void 0;return{...a,template:{key:i.key,name:i.name,output:i.output,formats:i.output==="website"?[]:i.formats.map(
|
|
127
|
-
`)},islands:(await t.islands()).documentLoader,stylesheets:{kind:"links",hrefs:
|
|
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,7 +8,9 @@ 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";
|
|
13
|
+
import { exportSite } from "../../section/discovery.js";
|
|
12
14
|
import { buildSection } from "./sections.js";
|
|
13
15
|
import { TEMPLATE_FILE } from "../check/load-workspace.js";
|
|
14
16
|
import { analyzeWorkspace } from "../check/analyze.js";
|
|
@@ -74,7 +76,7 @@ async function buildArtifact(options) {
|
|
|
74
76
|
const key = publishedKey(local);
|
|
75
77
|
if (!isSectionKey(key)) throw new Error(`Section key "${local}" cannot name an artifact directory: a key is one path segment of letters, digits, ".", "_" and "-".`);
|
|
76
78
|
const entry = entryByKey.get(local);
|
|
77
|
-
const site = discovered
|
|
79
|
+
const site = exportSite(discovered, section);
|
|
78
80
|
const sectionLogic = logic.sections.get(local);
|
|
79
81
|
if (entry === void 0 || site === void 0 || sectionLogic === void 0) throw new Error(`build: check passed without materializing, discovering or bundling the logic of section "${local}".`);
|
|
80
82
|
const module = join(root, site.module);
|
|
@@ -86,7 +88,8 @@ async function buildArtifact(options) {
|
|
|
86
88
|
root,
|
|
87
89
|
key,
|
|
88
90
|
module,
|
|
89
|
-
exportName: site.exportName
|
|
91
|
+
exportName: site.exportName,
|
|
92
|
+
minRungWidth: frameRungFloor(template)
|
|
90
93
|
});
|
|
91
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.`);
|
|
92
95
|
builtByKey.set(key, built);
|
|
@@ -171,7 +174,8 @@ async function buildArtifact(options) {
|
|
|
171
174
|
const fixtures = await fixtureFiles({
|
|
172
175
|
fixtures: corpus.filter((entry) => entry.emptied === void 0).map((entry) => entry.fixture),
|
|
173
176
|
assets: fixtureAssets,
|
|
174
|
-
cacheDir: mediaCacheDir(root)
|
|
177
|
+
cacheDir: mediaCacheDir(root),
|
|
178
|
+
minRungWidth: frameRungFloor(template)
|
|
175
179
|
});
|
|
176
180
|
for (const [path, bytes] of fixtures.files) files.set(path, bytes);
|
|
177
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
};
|
|
52
|
-
|
|
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, {
|
|
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] =
|
|
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
|
-
...
|
|
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({
|
|
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({
|
|
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({
|
|
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) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { isTemplate } from "../../template/define-template.js";
|
|
2
|
+
import { listModules } from "../../section/discovery.js";
|
|
2
3
|
import { MEDIA_LOADERS, createFixtureMediaPlugin, externalOutsideWorkspace } from "../../fixtures/media-plugin.js";
|
|
3
4
|
import { runningCopyPlugin } from "../../template/running-copy.js";
|
|
4
|
-
import {
|
|
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,7 @@
|
|
|
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";
|
|
4
|
+
import { exportSite } from "../../../section/discovery.js";
|
|
3
5
|
import { buildFramedRenderer, buildSection, framedRendererPath } from "../../build/sections.js";
|
|
4
6
|
import { workspacePath } from "../load-workspace.js";
|
|
5
7
|
import { describeError } from "../messages.js";
|
|
@@ -32,13 +34,14 @@ async function bundlesStage(ctx) {
|
|
|
32
34
|
const weights = [];
|
|
33
35
|
const built = /* @__PURE__ */ new Map();
|
|
34
36
|
for (const entry of [...sections].sort((a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0)) {
|
|
35
|
-
const site = discovered
|
|
37
|
+
const site = exportSite(discovered, entry.section);
|
|
36
38
|
if (site === void 0) continue;
|
|
37
39
|
const input = {
|
|
38
40
|
root: ctx.root,
|
|
39
41
|
key: publishedSectionKey(template.key, entry.key),
|
|
40
42
|
module: join(ctx.root, site.module),
|
|
41
|
-
exportName: site.exportName
|
|
43
|
+
exportName: site.exportName,
|
|
44
|
+
minRungWidth: frameRungFloor(template)
|
|
42
45
|
};
|
|
43
46
|
let section;
|
|
44
47
|
try {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { exportSite } from "../../../section/discovery.js";
|
|
1
2
|
import { TEMPLATE_FILE } from "../load-workspace.js";
|
|
2
3
|
import { describeError } from "../messages.js";
|
|
3
4
|
import { buildSectionLogic, buildTemplateLogic } from "../../../template/logic-build.js";
|
|
@@ -16,7 +17,7 @@ async function logicStage(ctx) {
|
|
|
16
17
|
const violations = [];
|
|
17
18
|
const sections = /* @__PURE__ */ new Map();
|
|
18
19
|
for (const [key, section] of composition.sections) {
|
|
19
|
-
const site = discovered
|
|
20
|
+
const site = exportSite(discovered, section);
|
|
20
21
|
if (site === void 0) continue;
|
|
21
22
|
try {
|
|
22
23
|
sections.set(key, await buildSectionLogic({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { declaringModule } from "../../../section/section.js";
|
|
2
2
|
import { fillSpecFromSchema } from "../../../schema/extract-fill-spec.js";
|
|
3
|
+
import { exportSite } from "../../../section/discovery.js";
|
|
3
4
|
import { TEMPLATE_FILE, workspacePath } from "../load-workspace.js";
|
|
4
5
|
import { describeError } from "../messages.js";
|
|
5
6
|
import { renderInstanceSlots } from "../../../fixtures/media.js";
|
|
@@ -30,7 +31,7 @@ function sectionsStage(ctx) {
|
|
|
30
31
|
if (workspace === void 0 || discovered === void 0 || composition === void 0) return Promise.resolve({ skipped: "the composition stage could not derive the placed sections" });
|
|
31
32
|
const corpus = ctx.corpus ?? [];
|
|
32
33
|
const fileOf = (section) => {
|
|
33
|
-
const exported = discovered
|
|
34
|
+
const exported = exportSite(discovered, section);
|
|
34
35
|
if (exported !== void 0) return exported.module;
|
|
35
36
|
const at = declaringModule(section);
|
|
36
37
|
return at !== void 0 && isAbsolute(at) && at.startsWith(workspace.root) ? workspacePath(workspace.root, at) : TEMPLATE_FILE;
|
package/dist/cli/commands.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
package/dist/cli/dev/server.js
CHANGED
|
@@ -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);
|