@homepages/concrete 7.0.0 → 8.0.0
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 +19 -0
- package/codemods/manifest.json +6 -0
- package/dist/artifact/playground/client/assets/{index-D8eepVr-.js → index-Dn_xT16-.js} +115 -115
- package/dist/artifact/playground/client/index.html +1 -1
- package/dist/artifact/playground/host.mjs +7 -7
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +5 -6
- package/dist/packages/internal/fill-vocabulary/dist/origination.js +2 -62
- package/dist/packages/internal/section-contracts/dist/catalog.js +2 -18
- package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +1 -0
- package/dist/packages/internal/section-contracts/dist/index.js +0 -4
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +15 -6
- package/dist/packages/internal/section-contracts/dist/runners.js +3 -23
- package/dist/packages/internal/section-contracts/dist/source-contract.js +21 -24
- package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +8 -4
- package/dist/packages/internal/source-resolution/dist/index.js +3 -49
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +2 -12
- package/dist/packages/internal/template-contracts/dist/facts-view.js +4 -11
- package/dist/packages/internal/template-contracts/dist/row-sources.js +1 -7
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +1 -5
- package/dist/schema/extract-fill-spec.js +2 -7
- package/dist/schema/fill-spec.js +9 -0
- package/dist/schema/property-facts.d.ts +4 -3
- package/dist/schema/slot-builders.d.ts +25 -5
- package/guide/reference/cli/INDEX.md +2 -2
- package/guide/reference/cli/build.md +1 -1
- package/guide/reference/cli/check.md +1 -1
- package/guide/reference/cli/dev.md +1 -1
- package/guide/reference/cli/property-add.md +1 -1
- package/guide/reference/cli/property-list.md +1 -1
- package/guide/reference/cli/publish.md +1 -1
- package/guide/reference/cli/upgrade.md +1 -1
- package/guide/reference/rules/INDEX.md +3 -7
- package/package.json +1 -1
- package/dist/packages/internal/section-contracts/dist/choose-select-contract.js +0 -20
- package/dist/packages/internal/section-contracts/dist/name-title-contract.js +0 -20
- package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +0 -22
- package/dist/packages/internal/section-contracts/dist/source-filter-contract.js +0 -15
|
@@ -4,7 +4,7 @@
|
|
|
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-
|
|
7
|
+
<script type="module" crossorigin src="./assets/index-Dn_xT16-.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="./assets/index-CckS2ONm.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Xe=/^(\d+(?:\.\d+)?)(in|mm)$/;function Y(e){let t=Xe.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 O(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=Y(t.width),r=Y(t.height),o=t.bleed===void 0?0:Y(t.bleed),c=n*96,
|
|
1
|
+
var Xe=/^(\d+(?:\.\d+)?)(in|mm)$/;function Y(e){let t=Xe.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 O(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=Y(t.width),r=Y(t.height),o=t.bleed===void 0?0:Y(t.bleed),c=n*96,u=r*96,d=o*96,i=c+2*d,h=u+2*d,w=t.dpi/96;return{frameWidth:c,frameHeight:u,bleed:d,viewportWidth:i,viewportHeight:h,deviceScaleFactor:w,pixelWidth:Math.round(i*w),pixelHeight:Math.round(h*w),pointWidth:(n+2*o)*72,pointHeight:(r+2*o)*72,bleedPoints:o*72}}var $="concrete-frame";function N(e){let t=O(e);return{"--frame-w":`${t.frameWidth}px`,"--frame-h":`${t.frameHeight}px`,"--frame-bleed":`${t.bleed}px`}}var J=`(function () {
|
|
2
2
|
function CaptureIntersectionObserver(callback, options) {
|
|
3
3
|
var opts = options || {};
|
|
4
4
|
this.root = opts.root || null;
|
|
@@ -83,11 +83,11 @@ var Xe=/^(\d+(?:\.\d+)?)(in|mm)$/;function Y(e){let t=Xe.exec(e),[,n,r]=t??[];if
|
|
|
83
83
|
await frame();
|
|
84
84
|
}
|
|
85
85
|
await frame();
|
|
86
|
-
})()`;function M(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026")}function g(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ce(e){return
|
|
86
|
+
})()`;function M(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026")}function g(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ce(e){return pe(e.id,{...N(e)})}function pe(e,t){let n=Object.entries(t).map(([r,o])=>`${r}:${o}`).join(";");return{class:$,dataFormat:e,style:n}}function L(e,t){let n=ce(e);return`<div class="${g(n.class)}" data-format="${g(n.dataFormat)}" style="${g(n.style)}">${t.join("")}</div>`}function C(e){switch(e.destination){case"published":return Qe(e);case"artifact":return et(e);case"preview":return tt(e);case"diff":return nt(e)}}function ue(e){return e.kind==="none"||Object.keys(e.islandMap).length===0?[]:[`<script>${J}</script>`]}var me="html, body { margin: 0; padding: 0; }";function fe(e){let t=[`rel="${e.rel}"`,`href="${g(e.href)}"`];return e.sizes!==void 0&&t.push(`sizes="${g(e.sizes)}"`),e.type!==void 0&&t.push(`type="${g(e.type)}"`),`<link ${t.join(" ")} />`}function Qe(e){let{meta:t}=e,n=['<meta charset="utf-8" />','<meta name="viewport" content="width=device-width, initial-scale=1" />',`<title>${g(t.title)}</title>`,`<meta name="description" content="${g(t.description)}" />`];t.canonical&&n.push(`<link rel="canonical" href="${g(t.canonical)}" />`);for(let o of t.icons??[])n.push(fe(o));n.push('<meta property="og:type" content="website" />'),t.siteName&&n.push(`<meta property="og:site_name" content="${g(t.siteName)}" />`),n.push(`<meta property="og:title" content="${g(t.title)}" />`),n.push(`<meta property="og:description" content="${g(t.description)}" />`),t.ogUrl&&n.push(`<meta property="og:url" content="${g(t.ogUrl)}" />`),t.ogImage&&(n.push(`<meta property="og:image" content="${g(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="${g(t.ogImageType)}" />`),t.ogImageAlt&&n.push(`<meta property="og:image:alt" content="${g(t.ogImageAlt)}" />`),n.push('<meta name="twitter:card" content="summary_large_image" />'),n.push(`<meta name="twitter:title" content="${g(t.title)}" />`),n.push(`<meta name="twitter:description" content="${g(t.description)}" />`),n.push(`<meta name="twitter:image" content="${g(t.ogImage)}" />`)),n.push(...q(e.stylesheets)),n.push(...Q(e.islands)),e.prefetchUrls&&e.prefetchUrls.length>0&&n.push(`<script type="speculationrules">${M({prefetch:[{source:"list",urls:[...e.prefetchUrls]}]})}</script>`);let r=e.siteConfig?`
|
|
87
87
|
<script type="application/json" id="concrete-site-config">${M(e.siteConfig)}</script>`:"";return j({lang:t.lang??"en",head:n,body:` <body class="concrete-root">
|
|
88
88
|
${e.root.bodyHtml}${r}${ee(e.islands,"viewport")}
|
|
89
89
|
<script type="module" src="${g(e.analyticsJs.url)}"></script>
|
|
90
|
-
</body>`})}function et(e){let t=['<meta charset="utf-8" />'];e.title!==void 0&&t.push(`<title>${g(e.title)}</title>`),t.push(...q(e.stylesheets));let n=[me,...ot(e.root)];return t.push(Z(n)),t.push(...
|
|
90
|
+
</body>`})}function et(e){let t=['<meta charset="utf-8" />'];e.title!==void 0&&t.push(`<title>${g(e.title)}</title>`),t.push(...q(e.stylesheets));let n=[me,...ot(e.root)];return t.push(Z(n)),t.push(...ue(e.islands)),t.push(...Q(e.islands)),j({lang:"en",head:t,body:` <body>${rt(e.root)}${ee(e.islands,"eager")}</body>`})}function tt(e){let t=['<meta charset="utf-8" />','<meta name="viewport" content="width=device-width, initial-scale=1" />',`<title>${g(e.title)}</title>`,...e.icon===void 0?[]:[fe({rel:"icon",href:e.icon})],...q(e.stylesheets),Z([me,...e.extraCss??[]]),...e.capture===!0?ue(e.islands):[],...Q(e.islands)],n=(e.devScripts??[]).map(r=>`
|
|
91
91
|
${r}`).join("");return j({lang:"en",head:t,body:` <body>
|
|
92
92
|
${e.root.bodyHtml}${ee(e.islands,e.capture===!0?"eager":"viewport")}${n}
|
|
93
93
|
</body>`})}function nt(e){let t=['<meta charset="utf-8" />',`<meta name="viewport" content="width=${e.viewportWidth}, initial-scale=1" />`,`<title>${g(e.title)}</title>`,...q(e.stylesheets),Z([`html, body { margin: 0; padding: 0; width: ${e.viewportWidth}px; }`])];return j({lang:"en",head:t,body:` <body>${e.root.bodyHtml}</body>`})}function j(e){let t=e.head.map(n=>` ${n}`).join(`
|
|
@@ -113,7 +113,7 @@ ${e.body}
|
|
|
113
113
|
window.$RefreshReg$ = () => {};
|
|
114
114
|
window.$RefreshSig$ = () => (type) => type;
|
|
115
115
|
window.__vite_plugin_react_preamble_installed__ = true;
|
|
116
|
-
</script>`;function ye(){let e={};return new Proxy(e,{get:(t,n)=>typeof n!="string"||n in e||n==="then"||n==="toJSON"?e[n]:`#${n}`})}function ge(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 T={catalog:"api/catalog",render:"api/render",media:e=>`api/media${ge({fixture:e})}`,capture:(e,t)=>`api/capture/${e}${ge({fixture:t.fixture,format:t.format,page:t.page,canvas:t.canvas})}`,live:(e,t)=>`fixtures/${encodeURIComponent(e)}/live${t==="/"?"/":`${t}/`}`,hmr:"__hmr"};var y=class extends Error{constructor(n,r){super(r);this.status=n}status};function it(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:it(n)})),locked:t.locked}}}function _e(e){return Object.fromEntries(e.map(t=>[t.instance_id,{enabled:t.enabled,...t.variant===void 0?{}:{variant:t.variant}}]))}function be(e){if(e==null)return{};if(typeof e!="object"||Array.isArray(e))throw new y(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 y(400,`The display state of "${n}" is not an object.`);let{enabled:o,variant:c}=r;if(o!==void 0&&typeof o!="boolean")throw new y(400,`The display state of "${n}" has a non-boolean enabled.`);if(c!==void 0&&typeof c!="string")throw new y(400,`The display state of "${n}" has a non-string variant.`);t[n]={...o===void 0?{}:{enabled:o},...c===void 0?{}:{variant:c}}}return t}function we(e,t){for(let[n,r]of Object.entries(t)){let o=e.instances.find(p=>p.instanceId===n);if(o===void 0)throw new y(400,`The composition places no instance "${n}".`);if(r.enabled===!1&&o.display.required)throw new y(400,`Section instance "${n}" is required and cannot be hidden.`);if(r.variant===void 0)continue;let c=o.display.variant;if(c===null)throw new y(400,`Section instance "${n}" declares no display variant.`);if(c.locked)throw new y(400,`Section instance "${n}" declares a locked variant, which the user cannot switch.`);if(!c.cases.includes(r.variant))throw new y(400,`"${r.variant}" is not a declared case of section instance "${n}" (declared: ${c.cases.join(", ")}).`)}}function ve(e,t){return new Map(e.instances.map(n=>[n.instance_id,t[n.instance_id]?.enabled??n.enabled]))}function xe(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[c,p]of Object.entries(t))c in o||(p.variant===void 0||p.variant.cases.includes(r))&&(o[c]=p.type==="list"?[]:null);return{...e,variant:r,slots:o}}function Re(e){return Array.isArray(e)?e.length:0}function Se(e){return typeof e=="string"&&e!==""?e:null}function st(e){return{propertyType:Se(e.property_type),listingIntent:Se(e.listing_intent),units:Re(e.units),photos:Re(e.photos)}}function lt(e){let t=JSON.stringify(e),n=3735928559,r=1103547991;for(let o=0;o<t.length;o++){let c=t.charCodeAt(o);n=Math.imul(n^c,2654435761),r=Math.imul(r^c,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:st(e.facts),doc:lt(e.instances),display:_e(e.instances)}}function ke(e,t){let n=e.replace(/\/+$/,"");return t==="/"?`${n}/`:`${n}${t}/`}function Pe(e){let{pages:t,currentPageId:n,basePath:r}=e,o=t.find(d=>d.id===n);if(!o)throw new Error(`nav: page "${n}" is not one of the declared pages (${t.map(d=>d.id).join(", ")}).`);let c=[o,...t.filter(d=>d.id!==o.id&&d.enabled!==!1)],p={};for(let d of c)for(let i of d.sections)i.enabled===!1||i.key in p||(p[i.key]=d.id===o.id?`#${i.anchor}`:`${ke(r,d.path)}#${i.anchor}`);return{anchors:p,pages:t.filter(d=>d.enabled!==!1).map(d=>({id:d.id,label:d.label,href:ke(r,d.path),current:d.id===o.id}))}}function W(e,t){return e.pages?.[t]?.enabled!==!1}function te(e,t){return t.filter(n=>W(e,n.id))}var D={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 dt=["text","number","select","image","list","poi","url","video","tour","document"],ct=[],hn=[...dt,...ct];var ut=["address","type","intent","describe","uploads","units","comparables","contacts"];var pt={address:"always",type:"always",intent:"always",describe:"always",uploads:"always",units:"derived",comparables:"derived",contacts:"derived"},_n=ut.filter(e=>pt[e]==="always");var mt={matterport:{kind:"tour",label:"Matterport",pattern:/(^|\.)matterport\.com$/i,strategy:"api"},biganto:{kind:"tour",label:"Biganto",pattern:/(^|\.)biganto\.com$/i,strategy:"opengraph"},youtube:{kind:"video",label:"YouTube",pattern:/(^|\.)(youtube\.com|youtu\.be)$/i,strategy:"oembed"},vimeo:{kind:"video",label:"Vimeo",pattern:/(^|\.)vimeo\.com$/i,strategy:"oembed"},zillow:{kind:"listing",label:"Zillow",pattern:/(^|\.)zillow\.com$/i,strategy:"none"},redfin:{kind:"listing",label:"Redfin",pattern:/(^|\.)redfin\.com$/i,strategy:"none"},dropbox:{kind:"file",label:"Dropbox",pattern:/(^|\.)dropbox\.com$/i,strategy:"none"},drive:{kind:"file",label:"Google Drive",pattern:/^drive\.google\.com$/i,strategy:"none"},maps:{kind:"map",label:"Google Maps",pattern:/(^|\.)google\.com$/i,path:/^\/maps(\/|$)/i,strategy:"none"}};function $e(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!=="http:"&&t.protocol!=="https:")return null;for(let[n,r]of Object.entries(mt))if(r.pattern.test(t.hostname)&&!(r.path&&!r.path.test(t.pathname)))return n;return null}var ft="badge=0&autopause=0&player_id=0&title=0&byline=0&portrait=0&sidedock=0&vimeo_logo=0&pip=0&chromecast=0&quality_selector=0&progress_bar=1";function Ce(e){let t=e.trim();if(!t)return null;let n=$e(t);if(n==="vimeo"){let r=t.match(/vimeo\.com\/(?:.*\/)?(\d+)/);return r?`https://player.vimeo.com/video/${r[1]}?${ft}`:null}if(n==="youtube"){let r=t.match(/youtu\.be\/([A-Za-z0-9_-]{11})/)??t.match(/[?&]v=([A-Za-z0-9_-]{11})/)??t.match(/youtube\.com\/(?:embed|shorts)\/([A-Za-z0-9_-]{11})/);return r?`https://www.youtube.com/embed/${r[1]}?rel=0`:null}return null}function Ae(e){let t=e.trim();if(!t)return null;let n=$e(t);if(n==="matterport"){let r=new URL(t).searchParams.get("m");return r!==null&&/^[A-Za-z0-9]+$/.test(r)?`https://my.matterport.com/show/?m=${r}&nt=1`:null}return n==="biganto"?t:null}var V=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(i=>typeof i=="number"&&Number.isFinite(i)))return null;let c=V(t),p=V(n),d={nx:c,ny:p,nw:Math.min(V(r),1-c),nh:Math.min(V(o),1-p)};return d.nw<=0||d.nh<=0||d.nx===0&&d.ny===0&&d.nw===1&&d.nh===1?null:d}var z={file(e){return typeof e=="string"?{url:e,responsive:null}:{url:e.url,responsive:e.responsive}}};function yt(e,t){if(typeof t!="object"||t===null)return null;let{asset_id:n,photo_id:r}=t;return typeof n=="string"&&n!==""?n:e==="image"&&typeof r=="string"&&r!==""?r:null}function gt(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),c=n.file(e.file),p=r===null?{photo_id:e.id,url:c.url,alt:e.alt,responsive:c.responsive}:{photo_id:e.id,url:n.crop(e.file,r),alt:e.alt,responsive:null,rect:r};if(o!==null&&(p.mobile={url:n.crop(e.file,o),responsive:null}),"floor_label"in t){let d=typeof t.floor_label=="string"?t.floor_label:null;p.floor_label=d,p.alt===""&&(p.alt=d??"Floor plan")}return p}function He(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 ht(e,t){let n=He(e,t);return e.file===null?{video_id:e.id,url:Ce(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 _t(e,t){return{tour_id:e.id,url:Ae(e.url??"")??"",...He(e,t),alt:e.alt,...e.provider===null?{}:{provider:e.provider}}}function bt(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 wt(e,t,n,r){let o=yt(e,t),c=o===null?void 0:n.get(o);if(c===void 0||c.kind!==e)return null;switch(e){case"image":return gt(c,t,r);case"video":return ht(c,r);case"tour":return _t(c,r);case"document":return bt(c,r);default:return null}}var vt=new Set(["image","video","tour","document"]);function re(e,t,n,r){if(t==null)return t;if(vt.has(e.type))return wt(e.type,t,n,r);if(e.type!=="list"||!Array.isArray(t))return t;let o=t;if(e.fields!==void 0){let c=e.fields;return o.map(p=>{if(typeof p!="object"||p===null)return p;let d={...p};for(let[i,h]of Object.entries(c))d[i]=re(h,d[i],n,r);return d})}if(e.element!==void 0){let c=e.element;return o.map(p=>re(c,p,n,r))}return o}function Oe(e,t,n,r=z){let o={};for(let[c,p]of Object.entries(e.slots)){let d=t.schema.slots[c];o[c]=d===void 0?p:re(d,p,n,r)}return o}function Ne(e){return typeof e=="string"?e:e.url}function xt(e,t){return e.split(",").map(n=>{let[r="",...o]=n.trim().split(/\s+/);return[t(r),...o].join(" ")}).join(", ")}function Rt(e){return{file(t){let n=z.file(t),r=n.responsive===null?null:{...n.responsive,sources:n.responsive.sources.map(o=>({...o,srcset:xt(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 Me(e,t){let{facts:n}=e,r=i=>e.media[i],o=i=>i?.file===null||i?.file===void 0?"":t(Ne(i.file)),c=i=>i?.posterFile!==void 0?t(Ne(i.posterFile)):i?.posterUrl??"",p=[];for(let i of A(n.photos)){let h=r(i.id);p.push({id:i.id,kind:"photo",name:h?.filename||i.id,size:"",src:o(h),caption:i.caption??null})}for(let i of A(n.floor_plans)){let h=r(i.id);p.push({id:i.id,kind:"plan",name:h?.filename||i.id,size:"",src:o(h)})}for(let i of A(n.videos)){let h=i.provider??void 0;p.push({id:i.id,kind:"video",name:i.caption??r(i.id)?.filename??i.id,size:"",src:c(r(i.id)),caption:i.caption??null,ready:!0,durationMs:i.duration_ms??null,...h===void 0?{}:{provider:h}})}for(let i of A(n.tours))p.push({id:i.id,kind:"tour",name:`${i.provider??"Tour"} ${i.id}`,size:"",src:c(r(i.id)),ready:!0,provider:i.provider??""});for(let i of A(n.documents)){let h=r(i.id)?.sizeBytes;p.push({id:i.id,kind:"document",name:i.filename??i.id,size:"",src:"",mime:i.mime??"",...h===void 0?{}:{sizeBytes:h}})}let d=[["avatar_upload_id","headshot"],["logo_dark_upload_id","logo (dark)"],["logo_light_upload_id","logo (light)"]];for(let i of A(n.contacts)){let h=typeof i.name=="string"?i.name:"Contact";for(let[w,E]of d){let S=i[w];typeof S=="string"&&p.push({id:S,kind:"library",name:`${h} \u2014 ${E}`,size:"",src:o(r(S)),caption:h})}}return p}var St={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=St[e.type];if(n!==void 0){if(typeof t!="object")return null;let o=t,c=n.map(h=>o[h]).find(h=>typeof h=="string"&&h!=="");if(typeof c!="string")return null;if(e.type!=="image")return{asset_id:c};let p=F(o.rect),d=typeof o.mobile=="object"&&o.mobile!==null?F(o.mobile.rect):null,i="floor_label"in o?{floor_label:typeof o.floor_label=="string"?o.floor_label:null}:{};return{asset_id:c,...p===null?{}:{rect:p},...d===null?{}:{mobile_rect:d},...i}}if(e.type!=="list"||!Array.isArray(t))return t;let r=t;if(e.fields!==void 0){let o=e.fields;return r.map(c=>{if(typeof c!="object"||c===null)return c;let p={...c};for(let[d,i]of Object.entries(o))d in p&&(p[d]=oe(i,p[d]));return p})}if(e.element!==void 0){let o=e.element;return r.map(c=>oe(o,c))}return r}function De(e){let{instance:t,slots:n,fixture:r,session:o,assetUrl:c}=e,p={...t.slots},d={},i=r.provenance[t.instance_id]??{};for(let w of Object.keys(n))d[w]=i[w]??{kind:"empty"};for(let[w,E]of Object.entries(o??{})){let S=n[w];S!==void 0&&(p[w]=oe(S,E),d[w]={kind:"session"})}let h=new Map(Object.entries(r.media));return{slots:Oe({...t,slots:p},{schema:{slots:n}},h,Rt(c)),provenance:d}}var Fe=1024*1024;function kt(e){let t=O(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 Pt(e,t){return new Response(t,{status:e,headers:{"content-type":"text/plain; charset=utf-8"}})}function ae(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 Et(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 y(400,`${n} needs a ${t} parameter.`);return r}function Tt(e){return`<script>
|
|
116
|
+
</script>`;function ye(){let e={};return new Proxy(e,{get:(t,n)=>typeof n!="string"||n in e||n==="then"||n==="toJSON"?e[n]:`#${n}`})}function ge(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 T={catalog:"api/catalog",render:"api/render",media:e=>`api/media${ge({fixture:e})}`,capture:(e,t)=>`api/capture/${e}${ge({fixture:t.fixture,format:t.format,page:t.page,canvas:t.canvas})}`,live:(e,t)=>`fixtures/${encodeURIComponent(e)}/live${t==="/"?"/":`${t}/`}`,hmr:"__hmr"};var y=class extends Error{constructor(n,r){super(r);this.status=n}status};function it(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:it(n)})),locked:t.locked}}}function _e(e){return Object.fromEntries(e.map(t=>[t.instance_id,{enabled:t.enabled,...t.variant===void 0?{}:{variant:t.variant}}]))}function be(e){if(e==null)return{};if(typeof e!="object"||Array.isArray(e))throw new y(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 y(400,`The display state of "${n}" is not an object.`);let{enabled:o,variant:c}=r;if(o!==void 0&&typeof o!="boolean")throw new y(400,`The display state of "${n}" has a non-boolean enabled.`);if(c!==void 0&&typeof c!="string")throw new y(400,`The display state of "${n}" has a non-string variant.`);t[n]={...o===void 0?{}:{enabled:o},...c===void 0?{}:{variant:c}}}return t}function we(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 y(400,`The composition places no instance "${n}".`);if(r.enabled===!1&&o.display.required)throw new y(400,`Section instance "${n}" is required and cannot be hidden.`);if(r.variant===void 0)continue;let c=o.display.variant;if(c===null)throw new y(400,`Section instance "${n}" declares no display variant.`);if(c.locked)throw new y(400,`Section instance "${n}" declares a locked variant, which the user cannot switch.`);if(!c.cases.includes(r.variant))throw new y(400,`"${r.variant}" is not a declared case of section instance "${n}" (declared: ${c.cases.join(", ")}).`)}}function ve(e,t){return new Map(e.instances.map(n=>[n.instance_id,t[n.instance_id]?.enabled??n.enabled]))}function xe(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[c,u]of Object.entries(t))c in o||(u.variant===void 0||u.variant.cases.includes(r))&&(o[c]=u.type==="list"?[]:null);return{...e,variant:r,slots:o}}function Re(e){return Array.isArray(e)?e.length:0}function Se(e){return typeof e=="string"&&e!==""?e:null}function st(e){return{propertyType:Se(e.property_type),listingIntent:Se(e.listing_intent),units:Re(e.units),photos:Re(e.photos)}}function lt(e){let t=JSON.stringify(e),n=3735928559,r=1103547991;for(let o=0;o<t.length;o++){let c=t.charCodeAt(o);n=Math.imul(n^c,2654435761),r=Math.imul(r^c,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:st(e.facts),doc:lt(e.instances),display:_e(e.instances)}}function ke(e,t){let n=e.replace(/\/+$/,"");return t==="/"?`${n}/`:`${n}${t}/`}function Pe(e){let{pages:t,currentPageId:n,basePath:r}=e,o=t.find(d=>d.id===n);if(!o)throw new Error(`nav: page "${n}" is not one of the declared pages (${t.map(d=>d.id).join(", ")}).`);let c=[o,...t.filter(d=>d.id!==o.id&&d.enabled!==!1)],u={};for(let d of c)for(let i of d.sections)i.enabled===!1||i.key in u||(u[i.key]=d.id===o.id?`#${i.anchor}`:`${ke(r,d.path)}#${i.anchor}`);return{anchors:u,pages:t.filter(d=>d.enabled!==!1).map(d=>({id:d.id,label:d.label,href:ke(r,d.path),current:d.id===o.id}))}}function W(e,t){return e.pages?.[t]?.enabled!==!1}function te(e,t){return t.filter(n=>W(e,n.id))}var D={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 dt=["text","number","select","image","list","poi","url","video","tour","document"],ct=[],hn=[...dt,...ct];var pt=["address","type","intent","describe","uploads","units","comparables","contacts"];var ut={address:"always",type:"always",intent:"always",describe:"always",uploads:"always",units:"derived",comparables:"derived",contacts:"derived"},_n=pt.filter(e=>ut[e]==="always");var mt={matterport:{kind:"tour",label:"Matterport",pattern:/(^|\.)matterport\.com$/i,strategy:"api"},biganto:{kind:"tour",label:"Biganto",pattern:/(^|\.)biganto\.com$/i,strategy:"opengraph"},youtube:{kind:"video",label:"YouTube",pattern:/(^|\.)(youtube\.com|youtu\.be)$/i,strategy:"oembed"},vimeo:{kind:"video",label:"Vimeo",pattern:/(^|\.)vimeo\.com$/i,strategy:"oembed"},zillow:{kind:"listing",label:"Zillow",pattern:/(^|\.)zillow\.com$/i,strategy:"none"},redfin:{kind:"listing",label:"Redfin",pattern:/(^|\.)redfin\.com$/i,strategy:"none"},dropbox:{kind:"file",label:"Dropbox",pattern:/(^|\.)dropbox\.com$/i,strategy:"none"},drive:{kind:"file",label:"Google Drive",pattern:/^drive\.google\.com$/i,strategy:"none"},maps:{kind:"map",label:"Google Maps",pattern:/(^|\.)google\.com$/i,path:/^\/maps(\/|$)/i,strategy:"none"}};function $e(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!=="http:"&&t.protocol!=="https:")return null;for(let[n,r]of Object.entries(mt))if(r.pattern.test(t.hostname)&&!(r.path&&!r.path.test(t.pathname)))return n;return null}var ft="badge=0&autopause=0&player_id=0&title=0&byline=0&portrait=0&sidedock=0&vimeo_logo=0&pip=0&chromecast=0&quality_selector=0&progress_bar=1";function Ce(e){let t=e.trim();if(!t)return null;let n=$e(t);if(n==="vimeo"){let r=t.match(/vimeo\.com\/(?:.*\/)?(\d+)/);return r?`https://player.vimeo.com/video/${r[1]}?${ft}`:null}if(n==="youtube"){let r=t.match(/youtu\.be\/([A-Za-z0-9_-]{11})/)??t.match(/[?&]v=([A-Za-z0-9_-]{11})/)??t.match(/youtube\.com\/(?:embed|shorts)\/([A-Za-z0-9_-]{11})/);return r?`https://www.youtube.com/embed/${r[1]}?rel=0`:null}return null}function Ae(e){let t=e.trim();if(!t)return null;let n=$e(t);if(n==="matterport"){let r=new URL(t).searchParams.get("m");return r!==null&&/^[A-Za-z0-9]+$/.test(r)?`https://my.matterport.com/show/?m=${r}&nt=1`:null}return n==="biganto"?t:null}var V=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(i=>typeof i=="number"&&Number.isFinite(i)))return null;let c=V(t),u=V(n),d={nx:c,ny:u,nw:Math.min(V(r),1-c),nh:Math.min(V(o),1-u)};return d.nw<=0||d.nh<=0||d.nx===0&&d.ny===0&&d.nw===1&&d.nh===1?null:d}var z={file(e){return typeof e=="string"?{url:e,responsive:null}:{url:e.url,responsive:e.responsive}}};function yt(e,t){if(typeof t!="object"||t===null)return null;let{asset_id:n,photo_id:r}=t;return typeof n=="string"&&n!==""?n:e==="image"&&typeof r=="string"&&r!==""?r:null}function gt(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),c=n.file(e.file),u=r===null?{photo_id:e.id,url:c.url,alt:e.alt,responsive:c.responsive}:{photo_id:e.id,url:n.crop(e.file,r),alt:e.alt,responsive:null,rect:r};if(o!==null&&(u.mobile={url:n.crop(e.file,o),responsive:null}),"floor_label"in t){let d=typeof t.floor_label=="string"?t.floor_label:null;u.floor_label=d,u.alt===""&&(u.alt=d??"Floor plan")}return u}function He(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 ht(e,t){let n=He(e,t);return e.file===null?{video_id:e.id,url:Ce(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 _t(e,t){return{tour_id:e.id,url:Ae(e.url??"")??"",...He(e,t),alt:e.alt,...e.provider===null?{}:{provider:e.provider}}}function bt(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 wt(e,t,n,r){let o=yt(e,t),c=o===null?void 0:n.get(o);if(c===void 0||c.kind!==e)return null;switch(e){case"image":return gt(c,t,r);case"video":return ht(c,r);case"tour":return _t(c,r);case"document":return bt(c,r);default:return null}}var vt=new Set(["image","video","tour","document"]);function re(e,t,n,r){if(t==null)return t;if(vt.has(e.type))return wt(e.type,t,n,r);if(e.type!=="list"||!Array.isArray(t))return t;let o=t;if(e.fields!==void 0){let c=e.fields;return o.map(u=>{if(typeof u!="object"||u===null)return u;let d={...u};for(let[i,h]of Object.entries(c))d[i]=re(h,d[i],n,r);return d})}if(e.element!==void 0){let c=e.element;return o.map(u=>re(c,u,n,r))}return o}function Oe(e,t,n,r=z){let o={};for(let[c,u]of Object.entries(e.slots)){let d=t.schema.slots[c];o[c]=d===void 0?u:re(d,u,n,r)}return o}function Ne(e){return typeof e=="string"?e:e.url}function xt(e,t){return e.split(",").map(n=>{let[r="",...o]=n.trim().split(/\s+/);return[t(r),...o].join(" ")}).join(", ")}function Rt(e){return{file(t){let n=z.file(t),r=n.responsive===null?null:{...n.responsive,sources:n.responsive.sources.map(o=>({...o,srcset:xt(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 Me(e,t){let{facts:n}=e,r=i=>e.media[i],o=i=>i?.file===null||i?.file===void 0?"":t(Ne(i.file)),c=i=>i?.posterFile!==void 0?t(Ne(i.posterFile)):i?.posterUrl??"",u=[];for(let i of A(n.photos)){let h=r(i.id);u.push({id:i.id,kind:"photo",name:h?.filename||i.id,size:"",src:o(h),caption:i.caption??null})}for(let i of A(n.floor_plans)){let h=r(i.id);u.push({id:i.id,kind:"plan",name:h?.filename||i.id,size:"",src:o(h)})}for(let i of A(n.videos)){let h=i.provider??void 0;u.push({id:i.id,kind:"video",name:i.caption??r(i.id)?.filename??i.id,size:"",src:c(r(i.id)),caption:i.caption??null,ready:!0,durationMs:i.duration_ms??null,...h===void 0?{}:{provider:h}})}for(let i of A(n.tours))u.push({id:i.id,kind:"tour",name:`${i.provider??"Tour"} ${i.id}`,size:"",src:c(r(i.id)),ready:!0,provider:i.provider??""});for(let i of A(n.documents)){let h=r(i.id)?.sizeBytes;u.push({id:i.id,kind:"document",name:i.filename??i.id,size:"",src:"",mime:i.mime??"",...h===void 0?{}:{sizeBytes:h}})}let d=[["avatar_upload_id","headshot"],["logo_dark_upload_id","logo (dark)"],["logo_light_upload_id","logo (light)"]];for(let i of A(n.contacts)){let h=typeof i.name=="string"?i.name:"Contact";for(let[w,E]of d){let S=i[w];typeof S=="string"&&u.push({id:S,kind:"library",name:`${h} \u2014 ${E}`,size:"",src:o(r(S)),caption:h})}}return u}var St={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=St[e.type];if(n!==void 0){if(typeof t!="object")return null;let o=t,c=n.map(h=>o[h]).find(h=>typeof h=="string"&&h!=="");if(typeof c!="string")return null;if(e.type!=="image")return{asset_id:c};let u=F(o.rect),d=typeof o.mobile=="object"&&o.mobile!==null?F(o.mobile.rect):null,i="floor_label"in o?{floor_label:typeof o.floor_label=="string"?o.floor_label:null}:{};return{asset_id:c,...u===null?{}:{rect:u},...d===null?{}:{mobile_rect:d},...i}}if(e.type!=="list"||!Array.isArray(t))return t;let r=t;if(e.fields!==void 0){let o=e.fields;return r.map(c=>{if(typeof c!="object"||c===null)return c;let u={...c};for(let[d,i]of Object.entries(o))d in u&&(u[d]=oe(i,u[d]));return u})}if(e.element!==void 0){let o=e.element;return r.map(c=>oe(o,c))}return r}function De(e){let{instance:t,slots:n,fixture:r,session:o,assetUrl:c}=e,u={...t.slots},d={},i=r.provenance[t.instance_id]??{};for(let w of Object.keys(n))d[w]=i[w]??{kind:"empty"};for(let[w,E]of Object.entries(o??{})){let S=n[w];S!==void 0&&(u[w]=oe(S,E),d[w]={kind:"session"})}let h=new Map(Object.entries(r.media));return{slots:Oe({...t,slots:u},{schema:{slots:n}},h,Rt(c)),provenance:d}}var Fe=1024*1024;function kt(e){let t=O(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 Pt(e,t){return new Response(t,{status:e,headers:{"content-type":"text/plain; charset=utf-8"}})}function ae(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 Et(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 y(400,`${n} needs a ${t} parameter.`);return r}function Tt(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 $t(e){if(e===T.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 Nn(e){let{reader:t,assetUrl:n,renderer:r}=e,o=(e.base??"/").endsWith("/")?e.base??"/":`${e.base??"/"}/`,c=
|
|
126
|
-
${l.problems}`:void 0;return{...s,template:{key:a.key,name:a.name,output:a.output,formats:a.output==="website"?[]:a.formats.map(kt),pages:a.pages.map(m=>({id:m.id,label:m.label,...m.path===void 0?{}:{path:m.path},instanceIds:m.sections.map(_=>_.instanceId)})),canvases:a.canvases.map(m=>({id:m.id,label:m.label,pages:[...m.pages]})),instances:a.instances.map(m=>({...m,display:he(m.display)}))},fixtures:l.fixtures.map(Ie),capabilities:{hmr:t.live,capture:a.output!=="website"&&t.capture!==void 0},...f===void 0?{}:{error:f}}}async function Le(
|
|
127
|
-
`)},islands:(await t.islands()).documentLoader,stylesheets:{kind:"links",hrefs:
|
|
125
|
+
</script>`}function $t(e){if(e===T.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 Nn(e){let{reader:t,assetUrl:n,renderer:r}=e,o=(e.base??"/").endsWith("/")?e.base??"/":`${e.base??"/"}/`,c=p=>/^([a-z][a-z0-9+.-]*:|\/)/i.test(p)?p:`${o}${p}`,u=()=>[D.base,D.template].map(p=>c(n(p)));async function d(p){let{fixtures:s}=await t.fixtures(),a=s.find(l=>l.id===p);if(a===void 0){let l=s.map(f=>f.id).join(", ")||"none";throw new y(404,`There is no fixture "${p}" (have: ${l}).`)}return a}function i(p,s){let a=p.instances.find(l=>l.instance_id===s);if(a===void 0)throw new y(400,`The composition places no instance "${s}".`);return a}function h(p,s,a,l,f){if(p.output!=="website")return{selfAnchor:l,anchors:ye(),pages:[]};let m=ve(s,f),_=p.pages.map(R=>({id:R.id,label:R.label,path:R.path??`/${R.id}`,sections:R.sections.map(k=>({key:k.section,anchor:k.section,enabled:m.get(k.instanceId)!==!1}))})),b=`${o}${T.live(s.id,"/").replace(/\/$/,"")}`,v=Pe({pages:_,currentPageId:a,basePath:b});return{selfAnchor:l,anchors:v.anchors,pages:v.pages}}async function w(p,s,a,l,f,m){let _=p.instances.find(X=>X.instanceId===l.instance_id);if(_===void 0)throw new Error(`The composition places no section "${l.section_key}".`);let b=xe(l,_.sectionSchema.slots,m),{slots:v,provenance:R}=De({instance:b,slots:_.sectionSchema.slots,fixture:s,session:f,assetUrl:n}),k=h(p,s,a,b.section_key,m),x=b.variant,H=await r.section(b.section_key);return{html:r.renderToString(r.createElement(H,{slots:v,nav:k,variant:x??""}),{identifierPrefix:b.instance_id}),resolvedProps:{slots:v,nav:k,variant:x},provenance:R}}async function E(p,s,a){let l=[];for(let f of a.sections){let m=i(s,f.instanceId);m.enabled&&l.push((await w(p,s,a.id,m,void 0,{})).html)}return l}function S(p,s,a){let l=p.pages.find(f=>f.id===s);if(l===void 0)throw new y(a,`The template declares no page "${s}".`);return l}function B(p,s){if(p.output==="website")throw new y(404,`"${p.key}" is a website \u2014 captures are for rendered templates; open its pages live instead.`);let a=s===null?p.formats[0]:p.formats.find(l=>l.id===s);if(a===void 0)throw new y(404,`The template declares no format "${s??""}" (have: ${p.formats.map(l=>l.id).join(", ")}).`);return a}async function Ue(){let p=await t.islands(),s={wire:1,islands:{map:{...p.map},hostScript:p.canvasHost,importMap:{...p.importMap}},stylesheets:[D.base,D.template].map(m=>n(m))},a,l;try{a=await t.template(),l=await t.fixtures()}catch(m){return{...s,template:{key:"",name:"",output:"website",formats:[],pages:[],canvases:[],instances:[]},fixtures:[],capabilities:{hmr:t.live,capture:!1},error:m instanceof Error?m.message:String(m)}}let f=l.problems!==void 0&&l.fixtures.length===0?`No fixture could be rendered:
|
|
126
|
+
${l.problems}`:void 0;return{...s,template:{key:a.key,name:a.name,output:a.output,formats:a.output==="website"?[]:a.formats.map(kt),pages:a.pages.map(m=>({id:m.id,label:m.label,...m.path===void 0?{}:{path:m.path},instanceIds:m.sections.map(_=>_.instanceId)})),canvases:a.canvases.map(m=>({id:m.id,label:m.label,pages:[...m.pages]})),instances:a.instances.map(m=>({...m,display:he(m.display)}))},fixtures:l.fixtures.map(Ie),capabilities:{hmr:t.live,capture:a.output!=="website"&&t.capture!==void 0},...f===void 0?{}:{error:f}}}async function Le(p){if(p.method!=="POST")throw new y(405,`POST a render request to ${T.render}.`);let s=await p.text();if(new TextEncoder().encode(s).byteLength>Fe)throw new y(413,`request body exceeds ${Fe} bytes`);let a;try{a=s===""?void 0:JSON.parse(s)}catch(v){throw new y(400,`request body is not JSON: ${v instanceof Error?v.message:String(v)}`)}if(a===void 0||typeof a.page!="string"||typeof a.instance!="string"||typeof a.fixture!="string")throw new y(400,"A render request names a page, an instance and a fixture.");let l=typeof a.session=="object"&&a.session!==null?a.session:{},f=be(a.display),m=await t.template(),_=await d(a.fixture),b=S(m,a.page,400);return we(m,f),w(m,_,b.id,i(_,a.instance),l.slots,f)}async function je(p){let s=await d(U(p,"fixture","api/media"));return{items:Me(s,n)}}async function qe(p,s){let a=await t.template();if(a.output!=="website")throw new y(404,`"${a.key}" is a rendered ${a.output} template and has no live pages \u2014 preview it on the canvas.`);let l=a.pages.find(_=>_.path===s);if(l===void 0){let _=a.pages.map(b=>b.path??b.id).join(", ");throw new y(404,`The template declares no page at "${s}" (have: ${_}).`)}let f=await d(p),m=await E(a,f,l);return C({destination:"preview",root:{kind:"plain",bodyHtml:m.join(`
|
|
127
|
+
`)},islands:(await t.islands()).documentLoader,stylesheets:{kind:"links",hrefs:u()},title:`${a.name} - ${l.label}`,extraCss:["html, body { background: #fff; }"],...t.live?{devScripts:[Tt(`${o}${T.hmr}`)]}:{}})}function se(p,s,a){let l=S(p,a,404);if(!W(s,l.id))throw new y(404,`The fixture "${s.id}" switches the page "${l.id}" off, so it has no capture.`);return l}async function We(p){let s=I.frame,a=await t.template(),l=B(a,p.searchParams.get("format")),f=await d(U(p,"fixture",s)),m=se(a,f,U(p,"page",s));return C({destination:"artifact",root:{kind:"frame",format:l,sectionHtml:await E(a,f,m)},islands:(await t.islands()).documentLoader,stylesheets:{kind:"links",hrefs:u()},title:`${a.name} \u2014 ${m.id}`})}async function Ve(p){let s=await t.template(),a=B(s,p.searchParams.get("format"));if(s.output!=="document")throw new y(404,`"${s.key}" is an ${s.output} template \u2014 a PDF is for the document class; download its pages as a zip.`);let l=await d(U(p,"fixture",I.print)),f=[];for(let m of te(l,s.pages))f.push(await E(s,l,m));if(f.length===0)throw new y(404,`The fixture "${l.id}" switches every page off, so it has no PDF.`);return C({destination:"artifact",root:{kind:"frameStack",format:a,pages:f},islands:(await t.islands()).documentLoader,stylesheets:{kind:"links",hrefs:u()},title:`${s.name} \u2014 print`})}async function ze(p,s){let a=p;if(a!=="screenshot"&&a!=="bundle"&&a!=="print")throw new y(404,`There is no capture at ${s.pathname}.`);let l=U(s,"fixture",`api/capture/${a}`),f=await t.template(),m=B(f,s.searchParams.get("format")),_=await d(l),b,v,R;if(a==="screenshot"){let x=s.searchParams.get("page")??te(_,f.pages)[0]?.id;if(x===void 0)throw new y(404,`The fixture "${l}" leaves no page on.`);se(f,_,x),b={kind:a,fixture:l,format:m,documents:[{path:ne(l,x,m.id),page:x,name:`${x}.png`}]},v="image/png",R=`${f.key}-${x}-${m.id}.png`}else if(a==="bundle"){if(f.output!=="image")throw new y(404,`"${f.key}" is a ${f.output} template \u2014 the zip is for the image class; a document downloads its PDF.`);let x=s.searchParams.get("canvas"),H=x===null?f.canvases[0]:f.canvases.find(P=>P.id===x);if(H===void 0)throw new y(404,`The template declares no canvas "${x??""}".`);let G=H.pages.filter(P=>W(_,P));if(G.length===0)throw new y(404,`The fixture "${l}" switches every page of the canvas "${H.id}" off, so it has no zip.`);let X=G.map(P=>({path:ne(l,P,m.id),page:P,name:`${f.pages.find(Ge=>Ge.id===P)?.label||P}.png`}));b={kind:a,fixture:l,format:m,documents:X},v="application/zip",R=`${f.key}-${m.id}.zip`}else{if(f.output!=="document")throw new y(404,`"${f.key}" is an ${f.output} template \u2014 a PDF is for the document class; download its pages as a zip.`);b={kind:a,fixture:l,format:m,documents:[{path:Te(l,m.id),page:null,name:`${f.key}.pdf`}]},v="application/pdf",R=`${f.key}.pdf`}if(t.capture===void 0)throw new y(501,"This playground has no captures to give.");let k=await t.capture(b);return new Response(new Uint8Array(k),{headers:{"content-type":v,"content-disposition":`attachment; filename="${encodeURIComponent(R)}"`}})}async function Be(p,s,a){if(a===T.render)return ae(await Le(p));if(p.method!=="GET"&&p.method!=="HEAD"&&$t(a))throw new y(405,`${a} only reads; the playground accepts no uploads and writes nothing.`);if(a===T.catalog)return ae(await Ue());if(a==="api/media")return ae(await je(s));if(a.startsWith("api/capture/"))return ze(a.slice(12),s);if(a===I.frame)return ie(await We(s));if(a===I.print)return ie(await Ve(s));let[l,f,m,_,...b]=a.split("/").filter(Boolean);if(l==="fixtures"&&f!==void 0&&m==="live"){if(b.length>0)throw new y(404,`There is no route at ${s.pathname}.`);return ie(await qe(decodeURIComponent(f),_===void 0?"/":`/${decodeURIComponent(_)}`))}return null}return{async handle(p){let s=new URL(p.url);if(!s.pathname.startsWith(o)&&`${s.pathname}/`!==o)return null;let a=s.pathname.slice(o.length);try{return await Be(p,s,a)}catch(l){let f=Et(l);if(f===null)throw l;return Pt(f,l instanceof Error?l.message:String(l))}}}}export{Nn as createHost};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DISPLAY_ENTRIES } from "../../template-contracts/dist/slot-catalog.js";
|
|
2
|
-
import { rowMemberSources
|
|
3
|
-
import {
|
|
1
|
+
import { COLLECTIONS, DISPLAY_ENTRIES } from "../../template-contracts/dist/slot-catalog.js";
|
|
2
|
+
import { rowMemberSources } from "../../template-contracts/dist/row-sources.js";
|
|
3
|
+
import { projectCollectionRows, readFrom } from "../../source-resolution/dist/index.js";
|
|
4
4
|
import { buildDeriveFactsView } from "../../property-facts/dist/derive-facts-view.js";
|
|
5
5
|
import { callDerived, readsAnySlot } from "./derive-source.js";
|
|
6
6
|
import { declaredDisplay } from "./display.js";
|
|
@@ -13,8 +13,7 @@ function directField(def) {
|
|
|
13
13
|
return typeof src["field"] === "string" ? src["field"] : null;
|
|
14
14
|
}
|
|
15
15
|
function resolveDirectField(field, facts, fields, rowComputes) {
|
|
16
|
-
if (Object.hasOwn(
|
|
17
|
-
if (field === "unit_floorplans") return buildUnitFloorplanList(facts);
|
|
16
|
+
if (Object.hasOwn(COLLECTIONS, field)) return projectCollectionRows(field, facts, fields, rowComputes);
|
|
18
17
|
return readFrom(field, { facts });
|
|
19
18
|
}
|
|
20
19
|
function derivedSource(def) {
|
|
@@ -58,7 +57,7 @@ function rowComputesOf(listKey, fields, deriveFacts, ctx) {
|
|
|
58
57
|
return computes;
|
|
59
58
|
}
|
|
60
59
|
function projectComputedRows(value, fields, rowComputes) {
|
|
61
|
-
if (!Array.isArray(value) ||
|
|
60
|
+
if (!Array.isArray(value) || fields === void 0) return value;
|
|
62
61
|
const members = rowMemberSources(fields);
|
|
63
62
|
return value.map((computed) => {
|
|
64
63
|
const computedRow = computed !== null && typeof computed === "object" ? computed : {};
|
|
@@ -9,52 +9,6 @@ const LEGACY_COLLECTION_ITEM = {
|
|
|
9
9
|
function isListSlot(slot) {
|
|
10
10
|
return slot.type === "list" || slot.type !== void 0 && slot.type in LEGACY_COLLECTION_ITEM;
|
|
11
11
|
}
|
|
12
|
-
function pooledFieldsOf(fields) {
|
|
13
|
-
const found = [];
|
|
14
|
-
for (const [field, def] of Object.entries(fields)) {
|
|
15
|
-
if (def.source !== void 0) continue;
|
|
16
|
-
const pool = poolingPrimitiveOf(def);
|
|
17
|
-
if (pool !== void 0) found.push({
|
|
18
|
-
field,
|
|
19
|
-
pool
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
return found;
|
|
23
|
-
}
|
|
24
|
-
function selectFieldsOf(fields) {
|
|
25
|
-
return Object.entries(fields).filter(([, def]) => def.type === "select" && Array.isArray(def.values)).map(([name]) => name);
|
|
26
|
-
}
|
|
27
|
-
function keyRows(slot, fields) {
|
|
28
|
-
const selects = selectFieldsOf(fields);
|
|
29
|
-
const title = slot.title;
|
|
30
|
-
if (title !== void 0) {
|
|
31
|
-
const def = fields[title];
|
|
32
|
-
if (def?.type === "text") return {
|
|
33
|
-
kind: "keyed-rows",
|
|
34
|
-
keyField: title,
|
|
35
|
-
keys: "written"
|
|
36
|
-
};
|
|
37
|
-
if (def?.type === "select" && selects.includes(title)) return {
|
|
38
|
-
kind: "keyed-rows",
|
|
39
|
-
keyField: title,
|
|
40
|
-
keys: "picked"
|
|
41
|
-
};
|
|
42
|
-
return def?.type === void 0 ? {
|
|
43
|
-
kind: "no-key",
|
|
44
|
-
title
|
|
45
|
-
} : {
|
|
46
|
-
kind: "no-key",
|
|
47
|
-
title,
|
|
48
|
-
titleType: def.type
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
if (selects.length === 1) return {
|
|
52
|
-
kind: "keyed-rows",
|
|
53
|
-
keyField: selects[0],
|
|
54
|
-
keys: "picked"
|
|
55
|
-
};
|
|
56
|
-
return { kind: "no-key" };
|
|
57
|
-
}
|
|
58
12
|
function everyFieldFilled(fields, filled) {
|
|
59
13
|
if (filled.size === 0) return false;
|
|
60
14
|
return Object.entries(fields).every(([name, def]) => def.source !== void 0 || filled.has(name));
|
|
@@ -68,22 +22,7 @@ function originationFor(slot, filled = []) {
|
|
|
68
22
|
kind: "bound-rows",
|
|
69
23
|
iterate: bound.field
|
|
70
24
|
};
|
|
71
|
-
|
|
72
|
-
const pooled = pooledFieldsOf(fields);
|
|
73
|
-
const key = keyRows(slot, fields);
|
|
74
|
-
if (pooled.length === 1 && !(key.kind === "keyed-rows" && key.keys === "picked")) return {
|
|
75
|
-
kind: "pick-assets",
|
|
76
|
-
pool: pooled[0].pool,
|
|
77
|
-
field: pooled[0].field
|
|
78
|
-
};
|
|
79
|
-
if (key.kind === "keyed-rows") return key;
|
|
80
|
-
const { kind: _noKey, ...pointed } = key;
|
|
81
|
-
return {
|
|
82
|
-
kind: "unkeyed-rows",
|
|
83
|
-
...pointed,
|
|
84
|
-
selects: selectFieldsOf(fields),
|
|
85
|
-
pools: pooled.map((p) => p.field)
|
|
86
|
-
};
|
|
25
|
+
return everyFieldFilled(fields, new Set(filled)) ? { kind: "filled-rows" } : void 0;
|
|
87
26
|
}
|
|
88
27
|
const item = slot.element?.type ?? LEGACY_COLLECTION_ITEM[slot.type ?? ""];
|
|
89
28
|
if (item === "poi") return { kind: "curate" };
|
|
@@ -96,6 +35,7 @@ function originationFor(slot, filled = []) {
|
|
|
96
35
|
return { kind: "write-items" };
|
|
97
36
|
}
|
|
98
37
|
if (slot.type === "text") return { kind: "write" };
|
|
38
|
+
if (slot.type === "number") return { kind: "estimate" };
|
|
99
39
|
if (slot.type === "select") return {
|
|
100
40
|
kind: "pick-one",
|
|
101
41
|
from: "values"
|
|
@@ -6,7 +6,7 @@ const SECTION_CONTRACT_CATALOG = [
|
|
|
6
6
|
},
|
|
7
7
|
{
|
|
8
8
|
id: "decision-kind",
|
|
9
|
-
summary: "Every fill decision names a kind the platform runs: text, pick, list or display."
|
|
9
|
+
summary: "Every fill decision names a kind the platform runs: text, number, pick, list or display."
|
|
10
10
|
},
|
|
11
11
|
{
|
|
12
12
|
id: "produces-known-slot",
|
|
@@ -18,19 +18,7 @@ const SECTION_CONTRACT_CATALOG = [
|
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
id: "list-fill",
|
|
21
|
-
summary: "A list fill declares what the slot's own origination needs: a brief where the model originates rows, a bound where it writes them
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
id: "choose-select",
|
|
25
|
-
summary: "A record list the model originates is keyed by its title field, else by exactly one select field with declared values."
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
id: "name-title",
|
|
29
|
-
summary: "A list keyed by a written name needs that field to be capped text that carries no fill of its own."
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
id: "pooling-field",
|
|
33
|
-
summary: "A list fill's record item declares at most one unbound pooled asset field."
|
|
21
|
+
summary: "A list fill declares what the slot's own origination needs: rows bound to facts or filled field by field, a brief where the model originates rows, a bound where it writes them."
|
|
34
22
|
},
|
|
35
23
|
{
|
|
36
24
|
id: "row-fill",
|
|
@@ -84,10 +72,6 @@ const SECTION_CONTRACT_CATALOG = [
|
|
|
84
72
|
id: "url",
|
|
85
73
|
summary: "A url slot's accepts names a link kind or provider that a registered provider implements."
|
|
86
74
|
},
|
|
87
|
-
{
|
|
88
|
-
id: "source-filter",
|
|
89
|
-
summary: "A media slot's source filter names a filter the platform supports."
|
|
90
|
-
},
|
|
91
75
|
{
|
|
92
76
|
id: "sources",
|
|
93
77
|
summary: "Only a video slot declares sources, as a non-empty list of distinct known video sources."
|
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
import { SECTION_CONTRACT_CATALOG } from "./catalog.js";
|
|
2
2
|
import { assertCapContract } from "./cap-contract.js";
|
|
3
|
-
import { assertChooseSelectContract } from "./choose-select-contract.js";
|
|
4
3
|
import { assertCountBoundsContract } from "./count-bounds-contract.js";
|
|
5
4
|
import { assertGroupContract } from "./group-contract.js";
|
|
6
5
|
import { assertInterpolationContract } from "./interpolation-contract.js";
|
|
7
6
|
import { assertWriterReadsFactContract } from "./writer-reads-fact-contract.js";
|
|
8
7
|
import { assertListFillContract } from "./list-fill-contract.js";
|
|
9
8
|
import { assertListScalarContract } from "./list-scalar-contract.js";
|
|
10
|
-
import { assertNameTitleContract } from "./name-title-contract.js";
|
|
11
9
|
import { assertNestedSlotTypes } from "./nested-slot-contract.js";
|
|
12
10
|
import { assertRecordCollectionContract } from "./record-collection-contract.js";
|
|
13
11
|
import { assertOptionSourceContract } from "./option-source-contract.js";
|
|
14
12
|
import { assertPoiCurationContract } from "./poi-curation-contract.js";
|
|
15
|
-
import { assertPoolingFieldContract } from "./pooling-field-contract.js";
|
|
16
13
|
import { assertRowFillContract } from "./row-fill-contract.js";
|
|
17
14
|
import { assertSourceContract } from "./source-contract.js";
|
|
18
15
|
import { assertDisplayContract } from "./display-contract.js";
|
|
19
16
|
import { assertDisplayEvidenceContract } from "./display-evidence-contract.js";
|
|
20
17
|
import { assertSelectContract } from "./select-contract.js";
|
|
21
|
-
import { assertSourceFilterContract } from "./source-filter-contract.js";
|
|
22
18
|
import { assertSourcesContract } from "./sources-contract.js";
|
|
23
19
|
import { assertUrlContract } from "./url-contract.js";
|
|
24
20
|
import { collectSectionContractViolations } from "./runners.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { originationFor } from "../../fill-vocabulary/dist/origination.js";
|
|
1
|
+
import { isListSlot, originationFor } from "../../fill-vocabulary/dist/origination.js";
|
|
2
2
|
import { isListFill, plannedFieldsOf } from "./fill-spec-view.js";
|
|
3
3
|
|
|
4
4
|
//#region ../../internal/section-contracts/dist/list-fill-contract.js
|
|
@@ -8,12 +8,21 @@ function assertListFillContract(schema, decision, sectionKey) {
|
|
|
8
8
|
if (!isListFill(decision)) return;
|
|
9
9
|
for (const slotId of decision.produces) {
|
|
10
10
|
const slot = schema.slots[slotId];
|
|
11
|
-
if (slot === void 0) continue;
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
if (slot === void 0 || !isListSlot(slot)) continue;
|
|
12
|
+
const planned = plannedFieldsOf(decision);
|
|
13
|
+
const origination = originationFor(slot, planned);
|
|
14
|
+
const where = `Section "${sectionKey}": list fill "${decision.id}"`;
|
|
15
|
+
if (origination === void 0) {
|
|
16
|
+
if (slot.fields !== void 0) assertRowsOriginate(slot, planned, `${where} produces "${slotId}"`);
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
assertOrigination(fill, origination, slot, where);
|
|
15
20
|
}
|
|
16
21
|
}
|
|
22
|
+
function assertRowsOriginate(slot, planned, where) {
|
|
23
|
+
const unwritten = Object.entries(slot.fields ?? {}).filter(([name, field]) => field.source === void 0 && !planned.includes(name)).map(([name]) => name);
|
|
24
|
+
throw new Error(`${where}, a record list whose rows nothing originates: it is not bound to a facts array, and ${unwritten.length > 0 ? `${unwritten.map((name) => `"${name}"`).join(", ")} ${unwritten.length === 1 ? "carries" : "carry"} no fill of its own` : "no row field carries a fill of its own"}. Bind the list with \`source:\`, or give every row field a \`fill()\`, a row member or a \`compute()\`.`);
|
|
25
|
+
}
|
|
17
26
|
function assertOrigination(fill, origination, slot, where) {
|
|
18
27
|
if (fill.none !== void 0 && NO_ABSTENTION.includes(origination.kind)) throw new Error(`${where} declares \`none\`, but ${origination.kind === "curate" ? "a curated list" : "a fact-bound list"} has no discretion to abstain — its rows come from the platform's place search or from the facts. Drop \`none\`, or give a row field its own.`);
|
|
19
28
|
if (origination.kind === "bound-rows") {
|
|
@@ -25,7 +34,7 @@ function assertOrigination(fill, origination, slot, where) {
|
|
|
25
34
|
return;
|
|
26
35
|
}
|
|
27
36
|
if (typeof fill.brief !== "string" || fill.brief.length === 0) throw new Error(`${where} originates rows but declares no \`brief\` — the brief is the whole instruction.`);
|
|
28
|
-
if ((origination.kind === "write-items" || origination.kind === "filled-rows"
|
|
37
|
+
if ((origination.kind === "write-items" || origination.kind === "filled-rows") && fill.count === void 0 && slot.max === void 0) throw new Error(`${where} writes its ${origination.kind === "write-items" ? "items" : "rows"} but neither it nor the slot says how many — declare a \`count\`, or give the slot a \`max\`.`);
|
|
29
38
|
const band = fill.count;
|
|
30
39
|
if (typeof band?.min === "number" && typeof band.max === "number" && band.min > band.max) throw new Error(`${where} declares count.min ${String(band.min)} above count.max ${String(band.max)} — a band the model can never answer inside.`);
|
|
31
40
|
}
|
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
import { FACT_GRAPH } from "../../template-contracts/dist/slot-catalog.js";
|
|
2
2
|
import { SECTION_CONTRACT_CATALOG } from "./catalog.js";
|
|
3
3
|
import { assertCapContract } from "./cap-contract.js";
|
|
4
|
-
import { DECISION_KINDS } from "./fill-spec-view.js";
|
|
5
|
-
import { assertChooseSelectContract } from "./choose-select-contract.js";
|
|
6
4
|
import { assertCountBoundsContract } from "./count-bounds-contract.js";
|
|
7
5
|
import { assertGroupContract } from "./group-contract.js";
|
|
8
6
|
import { assertInterpolationContract } from "./interpolation-contract.js";
|
|
7
|
+
import { DECISION_KINDS } from "./fill-spec-view.js";
|
|
9
8
|
import { assertWriterReadsFactContract } from "./writer-reads-fact-contract.js";
|
|
10
9
|
import { assertListFillContract } from "./list-fill-contract.js";
|
|
11
10
|
import { assertListScalarContract } from "./list-scalar-contract.js";
|
|
12
|
-
import { assertNameTitleContract } from "./name-title-contract.js";
|
|
13
11
|
import { assertNestedSlotTypes } from "./nested-slot-contract.js";
|
|
14
12
|
import { assertRecordCollectionContract } from "./record-collection-contract.js";
|
|
15
13
|
import { assertOptionSourceContract } from "./option-source-contract.js";
|
|
16
14
|
import { assertPoiCurationContract } from "./poi-curation-contract.js";
|
|
17
|
-
import { assertPoolingFieldContract } from "./pooling-field-contract.js";
|
|
18
15
|
import { assertRowFillContract } from "./row-fill-contract.js";
|
|
19
16
|
import { assertSourceContract } from "./source-contract.js";
|
|
20
17
|
import { assertDisplayContract } from "./display-contract.js";
|
|
21
18
|
import { assertDisplayEvidenceContract } from "./display-evidence-contract.js";
|
|
22
19
|
import { assertSelectContract } from "./select-contract.js";
|
|
23
|
-
import { assertSourceFilterContract } from "./source-filter-contract.js";
|
|
24
20
|
import { assertSourcesContract } from "./sources-contract.js";
|
|
25
21
|
import { assertUrlContract } from "./url-contract.js";
|
|
26
22
|
|
|
@@ -64,18 +60,6 @@ const CONTRACTS = {
|
|
|
64
60
|
implementation: byDecision(({ key, schema }, d) => assertListFillContract(schema, d, key)),
|
|
65
61
|
assertions: [assertListFillContract]
|
|
66
62
|
},
|
|
67
|
-
"choose-select": {
|
|
68
|
-
implementation: byDecision(({ key, schema }, d) => assertChooseSelectContract(schema, d, key)),
|
|
69
|
-
assertions: [assertChooseSelectContract]
|
|
70
|
-
},
|
|
71
|
-
"name-title": {
|
|
72
|
-
implementation: byDecision(({ key, schema }, d) => assertNameTitleContract(schema, d, key)),
|
|
73
|
-
assertions: [assertNameTitleContract]
|
|
74
|
-
},
|
|
75
|
-
"pooling-field": {
|
|
76
|
-
implementation: byDecision(({ key, schema }, d) => assertPoolingFieldContract(schema, d, key)),
|
|
77
|
-
assertions: [assertPoolingFieldContract]
|
|
78
|
-
},
|
|
79
63
|
"row-fill": {
|
|
80
64
|
implementation: byDecision(({ key, schema }, d) => assertRowFillContract(schema, d, key)),
|
|
81
65
|
assertions: [assertRowFillContract]
|
|
@@ -101,10 +85,10 @@ const CONTRACTS = {
|
|
|
101
85
|
assertions: [assertDisplayEvidenceContract]
|
|
102
86
|
},
|
|
103
87
|
source: {
|
|
104
|
-
implementation: bySection(({ key, schema }) => assertSourceContract({
|
|
88
|
+
implementation: bySection(({ key, schema, fillSpec }) => assertSourceContract({
|
|
105
89
|
key,
|
|
106
90
|
slots: schema.slots
|
|
107
|
-
})),
|
|
91
|
+
}, fillSpec)),
|
|
108
92
|
assertions: [assertSourceContract]
|
|
109
93
|
},
|
|
110
94
|
"record-collection": {
|
|
@@ -131,10 +115,6 @@ const CONTRACTS = {
|
|
|
131
115
|
implementation: bySection(({ key, schema }) => assertUrlContract(schema, key)),
|
|
132
116
|
assertions: [assertUrlContract]
|
|
133
117
|
},
|
|
134
|
-
"source-filter": {
|
|
135
|
-
implementation: bySection(({ key, schema }) => assertSourceFilterContract(schema, key)),
|
|
136
|
-
assertions: [assertSourceFilterContract]
|
|
137
|
-
},
|
|
138
118
|
sources: {
|
|
139
119
|
implementation: bySection(({ key, schema }) => assertSourcesContract(schema, key)),
|
|
140
120
|
assertions: [assertSourcesContract]
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { COLLECTIONS, FACT_GRAPH, SOURCE_FIELDS, isWritableSourceField } from "../../template-contracts/dist/slot-catalog.js";
|
|
2
|
-
import {
|
|
2
|
+
import { plannedFieldsOf } from "./fill-spec-view.js";
|
|
3
3
|
|
|
4
4
|
//#region ../../internal/section-contracts/dist/source-contract.js
|
|
5
|
-
function
|
|
6
|
-
if (desc.value_type === "unit_list") return "unit";
|
|
7
|
-
if (desc.value_type === "contact_list") return "contact";
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
function assertOne(path, key, slot, rowContainer) {
|
|
5
|
+
function assertOne(path, key, slot) {
|
|
11
6
|
const src = slot.source;
|
|
12
7
|
if (!src) {
|
|
13
8
|
if (slot.writeback !== void 0) throw new Error(`${path}: "writeback" without a source. Only a slot bound to a fact (a direct source) answers whether edits propagate — remove the key.`);
|
|
@@ -17,11 +12,10 @@ function assertOne(path, key, slot, rowContainer) {
|
|
|
17
12
|
const def = SOURCE_FIELDS[src.field ?? ""];
|
|
18
13
|
if (!def) throw new Error(`${path}: unknown direct source field "${String(src.field)}"`);
|
|
19
14
|
const recordItemSlot = slot.type === "list" && slot.fields != null;
|
|
20
|
-
if (def.image && slot.type !== "image"
|
|
15
|
+
if (def.image && slot.type !== "image") throw new Error(`${path}: image source field "${src.field}" must sit on an image slot`);
|
|
21
16
|
if (Object.hasOwn(COLLECTIONS, src.field ?? "")) {
|
|
22
17
|
if (!recordItemSlot) throw new Error(`${path}: fact-collection source "${src.field}" needs a record item (a list declaring \`fields\`) — a fact row cannot project onto one slot.`);
|
|
23
18
|
}
|
|
24
|
-
if (rowContainer !== null && def.container !== rowContainer) throw new Error(`${path}: row-field source "${src.field}" belongs to the "${def.container}" container, but this list's rows resolve against "${rowContainer}" — a row field must bind a field of its own row.`);
|
|
25
19
|
if (typeof slot.writeback !== "boolean") throw new Error(`${path}: a direct source requires "writeback" (boolean) — declare whether edits propagate to "${src.field}".`);
|
|
26
20
|
if (slot.writeback === true && !isWritableSourceField(src.field ?? "")) throw new Error(`${path}: "writeback: true" on read-only source field "${src.field}" — the catalog has no write path for it; declare "writeback: false".`);
|
|
27
21
|
return;
|
|
@@ -46,25 +40,29 @@ function assertDeclaredRefs(path, reads, rowMember) {
|
|
|
46
40
|
throw new Error(kind === void 0 ? `${path}: reads[${String(i)}] is a ref without a "kind" — this framework reads only kind-tagged fact and slot refs. Run \`concrete upgrade\`, then build again.` : `${path}: reads[${String(i)}] is not a fact ref ({ kind: "fact", key }) or a slot ref ({ kind: "slot", section, slot }).`);
|
|
47
41
|
});
|
|
48
42
|
}
|
|
49
|
-
function assertSourceContract(schema) {
|
|
43
|
+
function assertSourceContract(schema, fillSpec = { decisions: [] }) {
|
|
50
44
|
for (const [name, slot] of Object.entries(schema.slots)) {
|
|
51
45
|
const at = `${schema.key}.${name}`;
|
|
52
46
|
if (slot.source?.kind === "row") throw new Error(`${at}: a row source on a top-level slot — a row member or marker names a field of a record list's row, and a top-level slot has no row. Bind the slot to a fact instead.`);
|
|
53
|
-
assertOne(at, name, slot
|
|
47
|
+
assertOne(at, name, slot);
|
|
54
48
|
if (slot.type !== "list" || slot.fields === void 0) continue;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
49
|
+
assertNotImplicit(at, slot.fields, plannedRowFields(fillSpec, name));
|
|
50
|
+
assertRowSourceList(at, name, slot, slot.fields);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function plannedRowFields(fillSpec, listKey) {
|
|
54
|
+
const decision = fillSpec.decisions.find((d) => d.produces.includes(listKey));
|
|
55
|
+
return new Set(decision === void 0 ? [] : plannedFieldsOf(decision));
|
|
56
|
+
}
|
|
57
|
+
function assertNotImplicit(at, fields, planned) {
|
|
58
|
+
const offenders = [];
|
|
59
|
+
for (const [fieldKey, field] of Object.entries(fields)) {
|
|
60
|
+
const kind = field.source?.kind;
|
|
61
|
+
if (kind === "direct") offenders.push(`"${fieldKey}" (bound \`direct\` to "${String(field.source?.field)}")`);
|
|
62
|
+
else if ((kind === void 0 || kind === "authored") && !planned.has(fieldKey)) offenders.push(`"${fieldKey}" (no origin)`);
|
|
67
63
|
}
|
|
64
|
+
if (offenders.length === 0) return;
|
|
65
|
+
throw new Error(`${at}: a record list in the implicit form, which this platform no longer reads — row field ${offenders.join(", ")}. Every row field declares its own origin: a member of its row (\`row.<member>\`), a \`compute()\`, or a \`fill()\`. Rebuild the section with @homepages/concrete 7.0.0 or later (\`concrete upgrade\`).`);
|
|
68
66
|
}
|
|
69
67
|
function memberFits(valueType, field) {
|
|
70
68
|
switch (valueType) {
|
|
@@ -107,7 +105,6 @@ function assertRowSourceList(at, listKey, list, fields) {
|
|
|
107
105
|
if (field.writeback !== void 0) throw new Error(`${path}: "writeback" without a source. Only a field bound to a row member answers whether edits propagate — remove the key.`);
|
|
108
106
|
continue;
|
|
109
107
|
}
|
|
110
|
-
if (src.kind === "direct") throw new Error(`${path}: a direct source on a row field of a list whose other fields name row members — one list declares its rows one way. Name this field's member too (\`source: <row>.<member>\`).`);
|
|
111
108
|
if (src.kind === "derived") {
|
|
112
109
|
if (field.writeback !== void 0) throw new Error(`${path}: "writeback" on a derived (compute) source. Nothing can write back through a derivation — remove the key.`);
|
|
113
110
|
const handle = `${listKey}.${fieldKey}`;
|
|
@@ -2,12 +2,16 @@ import { originationFor } from "../../fill-vocabulary/dist/origination.js";
|
|
|
2
2
|
import { plannedFieldsOf } from "./fill-spec-view.js";
|
|
3
3
|
|
|
4
4
|
//#region ../../internal/section-contracts/dist/writer-reads-fact-contract.js
|
|
5
|
-
const WRITES = [
|
|
5
|
+
const WRITES = [
|
|
6
|
+
"write",
|
|
7
|
+
"estimate",
|
|
8
|
+
"write-items"
|
|
9
|
+
];
|
|
6
10
|
function writes(slot, planned = []) {
|
|
7
11
|
if (slot === void 0) return false;
|
|
8
12
|
const origination = originationFor(slot, planned);
|
|
9
13
|
if (origination === void 0) return false;
|
|
10
|
-
return WRITES.includes(origination.kind)
|
|
14
|
+
return WRITES.includes(origination.kind);
|
|
11
15
|
}
|
|
12
16
|
function readsAFact(reads, rowsAreFacts) {
|
|
13
17
|
return (reads ?? []).some((ref) => {
|
|
@@ -16,7 +20,7 @@ function readsAFact(reads, rowsAreFacts) {
|
|
|
16
20
|
});
|
|
17
21
|
}
|
|
18
22
|
function assertWriterReadsFactContract(schema, decision, sectionKey) {
|
|
19
|
-
if (decision.kind !== "text" && decision.kind !== "list") return;
|
|
23
|
+
if (decision.kind !== "text" && decision.kind !== "number" && decision.kind !== "list") return;
|
|
20
24
|
const fill = decision;
|
|
21
25
|
const writing = [];
|
|
22
26
|
let rowsAreFacts = false;
|
|
@@ -24,7 +28,7 @@ function assertWriterReadsFactContract(schema, decision, sectionKey) {
|
|
|
24
28
|
const slot = schema.slots[slotId];
|
|
25
29
|
if (slot === void 0) continue;
|
|
26
30
|
if (originationFor(slot)?.kind === "bound-rows") rowsAreFacts = true;
|
|
27
|
-
if (decision.kind === "text" || writes(slot, plannedFieldsOf(decision))) writing.push(slotId);
|
|
31
|
+
if (decision.kind === "text" || decision.kind === "number" || writes(slot, plannedFieldsOf(decision))) writing.push(slotId);
|
|
28
32
|
for (const field of Object.keys(fill.fields ?? {})) if (writes(slot.fields?.[field])) writing.push(`${slotId}.${field}`);
|
|
29
33
|
}
|
|
30
34
|
if (writing.length === 0) return;
|