@jxsuite/compiler 0.34.1 → 0.35.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/dist/cli.js +1 -1
- package/package.json +4 -4
- package/src/site/site-loader.ts +4 -0
package/dist/cli.js
CHANGED
|
@@ -202,7 +202,7 @@ ${u.join(`,
|
|
|
202
202
|
<${U}></${U}>
|
|
203
203
|
<script type="module" src="./${U}.js"></script>
|
|
204
204
|
</body>
|
|
205
|
-
</html>`;return{files:[H],html:$}}return q3(Y,{litHtmlSrc:J,projectStyle:G,reactivitySrc:Q,title:X})}async function J$(Z,W){let[X,Q]=await Promise.all([V3(Z),n4(Z)]),{writeFileSync:J,mkdirSync:G}=await import("node:fs"),{dirname:Y,join:U}=await import("node:path");if(W){J(W,X.html,"utf8"),console.error(`Written to ${W}`);let K=Y(W);for(let V of X.files){let H=U(K,V.path);G(Y(H),{recursive:!0}),J(H,V.content,"utf8"),console.error(`Written to ${H}`)}}else process.stdout.write(X.html);if(Q&&W){let K=W.replace(/(\.[^.]+)?$/,"-server.js");J(K,Q,"utf8"),console.error(`Server handler written to ${K}`)}}var Y9=c(()=>{y6();Z3();a4();Z9();K3();X6();R6();y6();Z3();a4();K3()});import{existsSync as sQ,readFileSync as oQ}from"node:fs";import{resolve as z9}from"node:path";function q9(Z){let W=z9(Z,"project.json");if(!sQ(W))throw Error(`project.json not found in ${Z}`);let X;try{X=h5(oQ(W,"utf8"),W)}catch(Y){throw Error(`Invalid project.json: ${T6(Y)}`,{cause:Y})}let Q={...d2,...X,build:{...d2.build,...X.build},defaults:{...d2.defaults,...X.defaults},images:{...d2.images,...X.images}};if(X.$head)Q.$head=X.$head;if(X.$media)Q.$media=X.$media;if(X.style)Q.style=X.style;if(X.state)Q.state=X.state;if(X.redirects)Q.redirects=X.redirects;if(X.imports)Q.imports=X.imports;if(X.contentTypes)Q.contentTypes=X.contentTypes;let J=["cloudflare-workers","cloudflare-pages","node","bun"];if(Q.build.adapter&&!J.includes(Q.build.adapter))throw Error(`Unknown build adapter "${Q.build.adapter}" in project.json. Valid adapters: ${J.join(", ")}`);let G=["build","cloudflare"];if(!G.includes(Q.images.service))throw Error(`Unknown images.service "${Q.images.service}" in project.json. Valid services: ${G.join(", ")}`);return{config:Q,configPath:W,projectRoot:z9(Z)}}var d2;var U9=c(()=>{R6();d2={$head:[],$media:{},build:{format:"directory",outDir:"./dist",provider:null,trailingSlash:"always"},contentTypes:{},defaults:{charset:"utf8",lang:"en",layout:null},images:{formats:["webp","avif"],lazyLoad:!0,optimize:!0,quality:{avif:65,jpeg:80,png:80,webp:80},service:"build",sizes:"(max-width: 768px) 100vw, 50vw",widths:[320,640,960,1280,1920]},imports:{},name:"Jx Site",redirects:{},state:{},style:{},url:""}});import{readFileSync as K9,readdirSync as tQ}from"node:fs";import{extname as B3,join as eQ,relative as ZJ,resolve as WJ}from"node:path";async function s4(Z,W){let X=K9(Z,"utf8");if(Z.endsWith(".json"))return g6(X,Z);let Q=B3(Z).toLowerCase(),J=W?.byExtension(Q,"parse");if(!J)throw Error(`No format class imported for "${Q}" (${Z}). Add a format class to project.json imports, e.g. "Markdown": "@jxsuite/parser/Markdown.class.json".`);return await J.call("parse",X)}async function V9(Z,W){let X=[],Q=new Set([".json",...W?.documentExtensions("page")??[]]);return await B9(Z,Z,X,Q,W),X.sort((J,G)=>{if(J.isDynamic!==G.isDynamic)return J.isDynamic?1:-1;if(J.isCatchAll!==G.isCatchAll)return J.isCatchAll?1:-1;return J.urlPattern.localeCompare(G.urlPattern)}),X}async function B9(Z,W,X,Q,J){let G=tQ(Z,{withFileTypes:!0});for(let Y of G){let U=eQ(Z,Y.name);if(Y.isDirectory()){if(Y.name.startsWith("_"))continue;await B9(U,W,X,Q,J);continue}let K=B3(Y.name).toLowerCase();if(!Q.has(K))continue;if(Y.name.startsWith("_"))continue;let V=ZJ(W,U),H=await XJ(V,U,J);if(H)X.push(H)}}async function XJ(Z,W,X){let Q=B3(Z),J=Q?Z.slice(0,-Q.length):Z;if(J=J.split("\\").join("/"),J.endsWith("/index"))J=J.slice(0,-6)||"/";else if(J==="index")J="/";if(!J.startsWith("/"))J=`/${J}`;let G=[],Y=!1,U=!1,K=J.replaceAll(/\[\.\.\.(\w+)\]|\[(\w+)\]/g,(H,B,$)=>{if(B)return U=!0,Y=!0,G.push(B),"*";return Y=!0,G.push($),`:${$}`}),V=null;try{let B=(await s4(W,X)).$layout;if(typeof B==="string")V=B}catch{}return{$layout:V,isCatchAll:U,isDynamic:Y,params:G,relativePath:Z,sourcePath:W,urlPattern:K}}async function H9(Z,W,X=new Map,Q){let J=[];for(let G of Z){if(!G.isDynamic){J.push(G);continue}let Y;try{Y=await s4(G.sourcePath,Q)}catch{J.push(G);continue}if(!Y.$paths){console.warn(`Warning: dynamic route ${G.urlPattern} has no $paths — skipping`);continue}let U=QJ(Y.$paths,W,X);for(let K of U){let V=G.urlPattern,H={};for(let[B,$]of Object.entries(K))H[B]=String($),V=V.replace(`:${B}`,H[B]),V=V.replace("*",H[B]);J.push({...G,_pathParams:H,isCatchAll:!1,isDynamic:!1,params:[],urlPattern:V})}}return J}function QJ(Z,W,X){if(Array.isArray(Z))return Z;if("contentType"in Z&&Z.contentType){let Q=X.get(Z.contentType);if(!Q||Q.length===0)return console.warn(`Warning: $paths references content type "${Z.contentType}" but it has no entries`),[];let J=Z.param??"slug",G=Z.field??"id";return Q.map((Y)=>({[J]:G==="id"?Y.id:Y.data[G]??Y.id})).filter((Y)=>Y[J])}if("values"in Z&&Array.isArray(Z.values)){let Q=Z.param??"value";return Z.values.map((J)=>({[Q]:J}))}if("$ref"in Z&&Z.$ref){let Q=WJ(W,Z.$ref),J;try{J=JSON.parse(K9(Q,"utf8"))}catch(U){let K=U;return console.warn(`Warning: $paths.$ref could not load "${Z.$ref}": ${K.message}`),[]}if(!Array.isArray(J))return console.warn(`Warning: $paths.$ref "${Z.$ref}" must be a JSON array`),[];let G=Z.param??"id",Y=Z.field??"id";return J.map((U)=>({[G]:U[Y]??U.id??String(U)}))}return console.warn("Warning: unrecognized $paths shape — skipping"),[]}var $9=c(()=>{R6()});import{existsSync as JJ,readFileSync as GJ}from"node:fs";import{resolve as YJ}from"node:path";function H3(Z,W,X){let Q=Z.$layout??W.defaults?.layout??null;if(!Q)return Z;let J=YJ(X,Q);if(!JJ(J))throw Error(`Layout not found: ${Q} (resolved to ${J})`);let G;try{G=g6(GJ(J,"utf8"),J)}catch(V){throw Error(`Invalid layout JSON at ${J}: ${V.message}`,{cause:V})}if(G.$layout)G=H3(G,W,X);let Y=Z.children??[],U=typeof Y==="string"?[Y]:Array.isArray(Y)?Y:[],K=qJ(G);if(zJ(K,U),Z.state)K.state={...K.state,...Z.state};if(Z.$media)K.$media={...K.$media,...Z.$media};if(Z.style)K.style={...K.style,...Z.style};if(Z.attributes)K.attributes={...K.attributes,...Z.attributes};if(Z.$head)K._pageHead=Z.$head;if(Z.title)K._pageTitle=Z.title;return delete K.$layout,K}function zJ(Z,W){if(!Z||typeof Z!=="object")return;if(!Array.isArray(Z.children))return;let X=new Map,Q=[];for(let J of W)if(J&&typeof J==="object"&&J.attributes?.slot){let G=J.attributes.slot;if(!X.has(G))X.set(G,[]);X.get(G).push(J)}else Q.push(J);F9(Z,X,Q)}function F9(Z,W,X){if(!Z||typeof Z!=="object")return;if(!Array.isArray(Z.children))return;let Q=[];for(let J of Z.children)if(J&&typeof J==="object"&&J.tagName==="slot"){let G=J.attributes?.name;if(G&&W.has(G))Q.push(...W.get(G)),W.delete(G);else if(!G&&X.length>0)Q.push(...X);else if(Array.isArray(J.children))Q.push(...J.children)}else F9(J,W,X),Q.push(J);Z.children=Q}function qJ(Z){return structuredClone(Z)}var L9=c(()=>{R6()});function A9(Z=[],W=[],X=[],Q={}){let J=[{attributes:{charset:Q.charset??"utf8"},tagName:"meta"},{attributes:{content:"width=device-width, initial-scale=1",name:"viewport"},tagName:"meta"}],G=new Map;for(let U of[...J,...Z,...W,...X]){let K=UJ(U);G.set(K,U)}let Y=Q.title??Q.siteName??"Jx Site";if(G.set("title",{children:[Y],tagName:"title"}),Q.pageUrl&&Q.siteUrl){let U=new URL(Q.pageUrl,Q.siteUrl).href;G.set("link:canonical",{attributes:{href:U,rel:"canonical"},tagName:"link"})}return[...G.values()]}function UJ(Z){if(!Z||typeof Z!=="object")return String(Z);let W=Z.tagName??"unknown",X=Z.attributes??{};if(W==="title")return"title";if(X.charset)return"meta:charset";if(W==="meta"&&X.name)return`meta:${X.name}`;if(W==="meta"&&X.property)return`meta:${X.property}`;if(W==="link"&&X.rel)return`link:${X.rel}:${X.href??""}`;if(W==="script"&&X.src)return`script:${X.src}`;if(W==="style"){let Q=Array.isArray(Z.children)?Z.children.join(""):Z.textContent??"";return`style:${KJ(Q)}`}return`${W}:${JSON.stringify(Z)}`}function KJ(Z){let W=0;for(let X=0;X<Z.length;X++)W=Math.trunc((W<<5)-W+(Z.codePointAt(X)??0));return W.toString(36)}function M9(Z){return Z.map((W)=>VJ(W)).join(`
|
|
205
|
+
</html>`;return{files:[H],html:$}}return q3(Y,{litHtmlSrc:J,projectStyle:G,reactivitySrc:Q,title:X})}async function J$(Z,W){let[X,Q]=await Promise.all([V3(Z),n4(Z)]),{writeFileSync:J,mkdirSync:G}=await import("node:fs"),{dirname:Y,join:U}=await import("node:path");if(W){J(W,X.html,"utf8"),console.error(`Written to ${W}`);let K=Y(W);for(let V of X.files){let H=U(K,V.path);G(Y(H),{recursive:!0}),J(H,V.content,"utf8"),console.error(`Written to ${H}`)}}else process.stdout.write(X.html);if(Q&&W){let K=W.replace(/(\.[^.]+)?$/,"-server.js");J(K,Q,"utf8"),console.error(`Server handler written to ${K}`)}}var Y9=c(()=>{y6();Z3();a4();Z9();K3();X6();R6();y6();Z3();a4();K3()});import{existsSync as sQ,readFileSync as oQ}from"node:fs";import{resolve as z9}from"node:path";function q9(Z){let W=z9(Z,"project.json");if(!sQ(W))throw Error(`project.json not found in ${Z}`);let X;try{X=h5(oQ(W,"utf8"),W)}catch(Y){throw Error(`Invalid project.json: ${T6(Y)}`,{cause:Y})}let Q={...d2,...X,build:{...d2.build,...X.build},defaults:{...d2.defaults,...X.defaults},images:{...d2.images,...X.images}};if(X.$head)Q.$head=X.$head;if(X.$media)Q.$media=X.$media;if(X.style)Q.style=X.style;if(X.state)Q.state=X.state;if(X.redirects)Q.redirects=X.redirects;if(X.imports)Q.imports=X.imports;if(X.contentTypes)Q.contentTypes=X.contentTypes;let J=["cloudflare-workers","cloudflare-pages","node","bun"];if(Q.build.adapter==="static")delete Q.build.adapter;if(Q.build.adapter&&!J.includes(Q.build.adapter))throw Error(`Unknown build adapter "${Q.build.adapter}" in project.json. Valid adapters: ${J.join(", ")}`);let G=["build","cloudflare"];if(!G.includes(Q.images.service))throw Error(`Unknown images.service "${Q.images.service}" in project.json. Valid services: ${G.join(", ")}`);return{config:Q,configPath:W,projectRoot:z9(Z)}}var d2;var U9=c(()=>{R6();d2={$head:[],$media:{},build:{format:"directory",outDir:"./dist",provider:null,trailingSlash:"always"},contentTypes:{},defaults:{charset:"utf8",lang:"en",layout:null},images:{formats:["webp","avif"],lazyLoad:!0,optimize:!0,quality:{avif:65,jpeg:80,png:80,webp:80},service:"build",sizes:"(max-width: 768px) 100vw, 50vw",widths:[320,640,960,1280,1920]},imports:{},name:"Jx Site",redirects:{},state:{},style:{},url:""}});import{readFileSync as K9,readdirSync as tQ}from"node:fs";import{extname as B3,join as eQ,relative as ZJ,resolve as WJ}from"node:path";async function s4(Z,W){let X=K9(Z,"utf8");if(Z.endsWith(".json"))return g6(X,Z);let Q=B3(Z).toLowerCase(),J=W?.byExtension(Q,"parse");if(!J)throw Error(`No format class imported for "${Q}" (${Z}). Add a format class to project.json imports, e.g. "Markdown": "@jxsuite/parser/Markdown.class.json".`);return await J.call("parse",X)}async function V9(Z,W){let X=[],Q=new Set([".json",...W?.documentExtensions("page")??[]]);return await B9(Z,Z,X,Q,W),X.sort((J,G)=>{if(J.isDynamic!==G.isDynamic)return J.isDynamic?1:-1;if(J.isCatchAll!==G.isCatchAll)return J.isCatchAll?1:-1;return J.urlPattern.localeCompare(G.urlPattern)}),X}async function B9(Z,W,X,Q,J){let G=tQ(Z,{withFileTypes:!0});for(let Y of G){let U=eQ(Z,Y.name);if(Y.isDirectory()){if(Y.name.startsWith("_"))continue;await B9(U,W,X,Q,J);continue}let K=B3(Y.name).toLowerCase();if(!Q.has(K))continue;if(Y.name.startsWith("_"))continue;let V=ZJ(W,U),H=await XJ(V,U,J);if(H)X.push(H)}}async function XJ(Z,W,X){let Q=B3(Z),J=Q?Z.slice(0,-Q.length):Z;if(J=J.split("\\").join("/"),J.endsWith("/index"))J=J.slice(0,-6)||"/";else if(J==="index")J="/";if(!J.startsWith("/"))J=`/${J}`;let G=[],Y=!1,U=!1,K=J.replaceAll(/\[\.\.\.(\w+)\]|\[(\w+)\]/g,(H,B,$)=>{if(B)return U=!0,Y=!0,G.push(B),"*";return Y=!0,G.push($),`:${$}`}),V=null;try{let B=(await s4(W,X)).$layout;if(typeof B==="string")V=B}catch{}return{$layout:V,isCatchAll:U,isDynamic:Y,params:G,relativePath:Z,sourcePath:W,urlPattern:K}}async function H9(Z,W,X=new Map,Q){let J=[];for(let G of Z){if(!G.isDynamic){J.push(G);continue}let Y;try{Y=await s4(G.sourcePath,Q)}catch{J.push(G);continue}if(!Y.$paths){console.warn(`Warning: dynamic route ${G.urlPattern} has no $paths — skipping`);continue}let U=QJ(Y.$paths,W,X);for(let K of U){let V=G.urlPattern,H={};for(let[B,$]of Object.entries(K))H[B]=String($),V=V.replace(`:${B}`,H[B]),V=V.replace("*",H[B]);J.push({...G,_pathParams:H,isCatchAll:!1,isDynamic:!1,params:[],urlPattern:V})}}return J}function QJ(Z,W,X){if(Array.isArray(Z))return Z;if("contentType"in Z&&Z.contentType){let Q=X.get(Z.contentType);if(!Q||Q.length===0)return console.warn(`Warning: $paths references content type "${Z.contentType}" but it has no entries`),[];let J=Z.param??"slug",G=Z.field??"id";return Q.map((Y)=>({[J]:G==="id"?Y.id:Y.data[G]??Y.id})).filter((Y)=>Y[J])}if("values"in Z&&Array.isArray(Z.values)){let Q=Z.param??"value";return Z.values.map((J)=>({[Q]:J}))}if("$ref"in Z&&Z.$ref){let Q=WJ(W,Z.$ref),J;try{J=JSON.parse(K9(Q,"utf8"))}catch(U){let K=U;return console.warn(`Warning: $paths.$ref could not load "${Z.$ref}": ${K.message}`),[]}if(!Array.isArray(J))return console.warn(`Warning: $paths.$ref "${Z.$ref}" must be a JSON array`),[];let G=Z.param??"id",Y=Z.field??"id";return J.map((U)=>({[G]:U[Y]??U.id??String(U)}))}return console.warn("Warning: unrecognized $paths shape — skipping"),[]}var $9=c(()=>{R6()});import{existsSync as JJ,readFileSync as GJ}from"node:fs";import{resolve as YJ}from"node:path";function H3(Z,W,X){let Q=Z.$layout??W.defaults?.layout??null;if(!Q)return Z;let J=YJ(X,Q);if(!JJ(J))throw Error(`Layout not found: ${Q} (resolved to ${J})`);let G;try{G=g6(GJ(J,"utf8"),J)}catch(V){throw Error(`Invalid layout JSON at ${J}: ${V.message}`,{cause:V})}if(G.$layout)G=H3(G,W,X);let Y=Z.children??[],U=typeof Y==="string"?[Y]:Array.isArray(Y)?Y:[],K=qJ(G);if(zJ(K,U),Z.state)K.state={...K.state,...Z.state};if(Z.$media)K.$media={...K.$media,...Z.$media};if(Z.style)K.style={...K.style,...Z.style};if(Z.attributes)K.attributes={...K.attributes,...Z.attributes};if(Z.$head)K._pageHead=Z.$head;if(Z.title)K._pageTitle=Z.title;return delete K.$layout,K}function zJ(Z,W){if(!Z||typeof Z!=="object")return;if(!Array.isArray(Z.children))return;let X=new Map,Q=[];for(let J of W)if(J&&typeof J==="object"&&J.attributes?.slot){let G=J.attributes.slot;if(!X.has(G))X.set(G,[]);X.get(G).push(J)}else Q.push(J);F9(Z,X,Q)}function F9(Z,W,X){if(!Z||typeof Z!=="object")return;if(!Array.isArray(Z.children))return;let Q=[];for(let J of Z.children)if(J&&typeof J==="object"&&J.tagName==="slot"){let G=J.attributes?.name;if(G&&W.has(G))Q.push(...W.get(G)),W.delete(G);else if(!G&&X.length>0)Q.push(...X);else if(Array.isArray(J.children))Q.push(...J.children)}else F9(J,W,X),Q.push(J);Z.children=Q}function qJ(Z){return structuredClone(Z)}var L9=c(()=>{R6()});function A9(Z=[],W=[],X=[],Q={}){let J=[{attributes:{charset:Q.charset??"utf8"},tagName:"meta"},{attributes:{content:"width=device-width, initial-scale=1",name:"viewport"},tagName:"meta"}],G=new Map;for(let U of[...J,...Z,...W,...X]){let K=UJ(U);G.set(K,U)}let Y=Q.title??Q.siteName??"Jx Site";if(G.set("title",{children:[Y],tagName:"title"}),Q.pageUrl&&Q.siteUrl){let U=new URL(Q.pageUrl,Q.siteUrl).href;G.set("link:canonical",{attributes:{href:U,rel:"canonical"},tagName:"link"})}return[...G.values()]}function UJ(Z){if(!Z||typeof Z!=="object")return String(Z);let W=Z.tagName??"unknown",X=Z.attributes??{};if(W==="title")return"title";if(X.charset)return"meta:charset";if(W==="meta"&&X.name)return`meta:${X.name}`;if(W==="meta"&&X.property)return`meta:${X.property}`;if(W==="link"&&X.rel)return`link:${X.rel}:${X.href??""}`;if(W==="script"&&X.src)return`script:${X.src}`;if(W==="style"){let Q=Array.isArray(Z.children)?Z.children.join(""):Z.textContent??"";return`style:${KJ(Q)}`}return`${W}:${JSON.stringify(Z)}`}function KJ(Z){let W=0;for(let X=0;X<Z.length;X++)W=Math.trunc((W<<5)-W+(Z.codePointAt(X)??0));return W.toString(36)}function M9(Z){return Z.map((W)=>VJ(W)).join(`
|
|
206
206
|
`)}function VJ(Z){if(typeof Z==="string")return Z;if(!Z||typeof Z!=="object")return"";let W=Z.tagName,X=Z.attributes??{},Q=Object.entries(X).map(([U,K])=>K===!0?U:`${U}="${BJ(K)}"`).join(" "),J=Q?`<${W} ${Q}>`:`<${W}>`;if(new Set(["meta","link","base","br","hr","img","input"]).has(W))return J;let Y=Array.isArray(Z.children)?Z.children.join(""):Z.textContent??"";return`${J}${Y}</${W}>`}function BJ(Z){return String(Z).replaceAll("&","&").replaceAll('"',""").replaceAll("<","<")}import{dirname as HJ,relative as $J,resolve as FJ}from"node:path";function I9(Z,W,X,Q=new Map,J=null){if(!Z.state)Z.state={};if(Z.state.$site={name:W.name??"Jx Site",url:W.url??"",...W.state},Z.state.$page={params:X._pathParams??{},title:Z.title??Z._pageTitle??W.name??"",url:X.urlPattern},W.state){for(let[G,Y]of Object.entries(W.state))if(G!=="$site"&&G!=="$page"&&!(G in Z.state))Z.state[G]=Y}if(W.$media)Z.$media={...W.$media,...Z.$media};if(W.imports&&Object.keys(W.imports).length>0){if(!Z.imports)Z.imports={};for(let[G,Y]of Object.entries(W.imports))if(!(G in Z.imports)){let U=Y;if(J&&X.sourcePath&&(U.startsWith("./")||U.startsWith("../"))){let K=FJ(J,U);Z.imports[G]=`./${$J(HJ(X.sourcePath),K)}`}else Z.imports[G]=U}}if(W.$elements?.length)if(!Z.$elements?.length)Z.$elements=[...W.$elements];else{let G=new Set,Y=[];for(let U of[...W.$elements,...Z.$elements]){let K=typeof U==="string"?U:U?.$ref;if(K&&!G.has(K))G.add(K),Y.push(U)}Z.$elements=Y}return Z}var N9=()=>{};import{existsSync as LJ,readFileSync as AJ,readdirSync as MJ}from"node:fs";import{basename as w9,extname as D9,resolve as F3}from"node:path";function IJ(Z){let W=JSON.parse(AJ(Z,"utf8"));if(Array.isArray(W))return W.map((Q,J)=>({body:null,data:Q,id:Q.id??`${w9(Z,".json")}-${J}`}));let X=W;return[{body:null,data:X,id:X.id??w9(Z,".json")}]}function NJ(Z){if(D9(Z))return LJ(Z)?[Z]:[];try{return MJ(Z,{recursive:!0}).filter((W)=>String(W).endsWith(".json")).map((W)=>F3(Z,String(W)))}catch{return[]}}function L3(Z,W){let X=F3(Z,"content");return{config:{contentTypes:W?.contentTypes??{}},contentDir:X}}async function T9(Z,W,X){let Q=L3(Z,W);if(!Q)return new Map;let{config:J}=Q,G=new Map;if(Object.keys(J.contentTypes).length===0)return G;let Y=X??await i4(Z,W);for(let[U,K]of Object.entries(J.contentTypes)){let V=await wJ(U,K,Z,Y);G.set(U,V)}return G}async function wJ(Z,W,X,Q){let{source:J}=W;if(!J)return[];let{schema:G}=W,Y=W.$elements?.length?{allowedNames:W.$elements.filter((L)=>typeof L==="string"||typeof L==="object"&&L?.$ref).map((L)=>typeof L==="string"?L:L.$ref)}:void 0,U=W.format,K;if(U&&U!=="json"){if(K=Q.byName(U),!K)throw Error(`Content type "${Z}": format "${U}" is not an imported format class. Add it to project.json imports, e.g. "${U}": "@jxsuite/parser/${U}.class.json".`)}if(J.startsWith("http://")||J.startsWith("https://")){if(!K)throw Error(`Content type "${Z}": remote sources require an explicit "format" naming an imported format class with "remote": true (e.g. "Csv").`);if(!K.remote)throw Error(`Content type "${Z}": format "${K.name}" does not support remote sources (its format block lacks "remote": true).`);try{let L=await K.call("load",J,{directiveOptions:Y,schema:G});if(G)$3(L,G,Z);return L}catch(L){return console.warn(`Content type "${Z}": ${T6(L)}`),[]}}let V=F3(X,J).split("\\").join("/"),H=D9(J).toLowerCase();if(U==="json"||!K&&H===".json"){let L=NJ(V),A=[];for(let _ of L)A.push(...IJ(_));if(G)$3(A,G,Z);return A}if(!K&&H)K=Q.byExtension(H,"load");if(!K)throw Q3(J,H||`content type "${Z}" (directory sources need an explicit "format")`);let B=K.capabilities.discover?await K.call("discover",J,{baseDir:X}):[V],$=[];for(let L of B)$.push(...await K.call("load",L,{directiveOptions:Y,schema:G}));if(G)$3($,G,Z);return $}function $3(Z,W,X){let Q=W.required??[],J=W.properties??{};for(let G of Z){for(let Y of Q)if(!(Y in G.data)||G.data[Y]==null)console.warn(`Content validation: "${X}/${G.id}" missing required field "${Y}"`);for(let[Y,U]of Object.entries(J)){let K=G.data[Y];if(K==null)continue;if(U.type==="string"&&typeof K!=="string")console.warn(`Content validation: "${X}/${G.id}" field "${Y}" expected string, got ${typeof K}`);else if(U.type==="number"&&typeof K!=="number")console.warn(`Content validation: "${X}/${G.id}" field "${Y}" expected number, got ${typeof K}`);else if(U.type==="boolean"&&typeof K!=="boolean")console.warn(`Content validation: "${X}/${G.id}" field "${Y}" expected boolean, got ${typeof K}`);else if(U.type==="array"&&!Array.isArray(K))console.warn(`Content validation: "${X}/${G.id}" field "${Y}" expected array, got ${typeof K}`)}}}function R9(Z,W){for(let[X,Q]of Object.entries(W.contentTypes)){let{schema:J}=Q;if(!J?.properties)continue;let G=Z.get(X);if(!G)continue;for(let[Y,U]of Object.entries(J.properties)){let K=U;if(!K.$ref?.startsWith("#/contentTypes/"))continue;let V=K.$ref.replace("#/contentTypes/",""),H=Z.get(V);if(!H)continue;for(let B of G){let $=B.data[Y];if(typeof $==="string"){let L=H.find((A)=>A.id===$);if(L)B.data[Y]=L}}}}}var P9=c(()=>{R6();M4()});import{readFileSync as DJ}from"node:fs";import{dirname as A3,resolve as c2}from"node:path";import{createRequire as TJ}from"node:module";async function j9(Z,W,X,Q={}){let J=Z.imports??{},{state:G}=Z;if(!G)return;for(let[Y,U]of Object.entries(G)){if(!n6(U))continue;if(RJ.has(U.$prototype))continue;if(U.timing&&U.timing!=="compiler")continue;if(!U.$src){let K=J[U.$prototype];if(!K)continue;U.$src=K}try{let K=await jJ(U,W,X,G,Q);if(U.timing&&K&&typeof K==="object"&&!Array.isArray(K))K.timing=U.timing;G[Y]=K}catch(K){console.warn(`prototype-resolver: failed to resolve "${Y}" ($prototype: "${U.$prototype}"):`,T6(K))}}}async function jJ(Z,W,X,Q,J){let G=Z.$src;if(!G)throw Error(`$prototype "${Z.$prototype}" has no $src to resolve`);let Y;if(G.startsWith("./")||G.startsWith("../"))Y=W.sourcePath?c2(A3(W.sourcePath),G):c2(X,G);else Y=TJ(c2(X,"package.json")).resolve(G);let U=DJ(Y,"utf8"),K=f5(U,Y);if(!K.$implementation)throw Error(`${G} has no $implementation field`);let V=c2(A3(Y),K.$implementation),H=await f2(V),B=Z.$export??K.title??Z.$prototype,$=H[B]??H.default?.[B];if(!$)throw Error(`Module ${K.$implementation} does not export "${B}"`);let L={};for(let[_,D]of Object.entries(Z))if(!PJ.has(_))L[_]=D;if(L.src&&!L.basePath&&W.sourcePath)L.basePath=A3(W.sourcePath);L._project={config:J.config??null,contentTypes:J.contentTypes??null,root:X},L._document={route:W,state:Q};let A=new $(L);if(typeof A.resolve==="function")return await A.resolve();return A}var RJ,PJ;var _9=c(()=>{M4();X6();R6();RJ=new Set(["Function","LocalStorage","SessionStorage","Array"]),PJ=new Set(["$prototype","$src","$export","timing","default","description"])});var E9=(Z)=>typeof Z<"u"&&Z!==null,_J=(Z)=>typeof Z==="object",EJ=(Z)=>Object.prototype.toString.call(Z)==="[object Object]",CJ=(Z)=>typeof Z==="function",OJ=(Z)=>typeof Z==="boolean",xJ=(Z)=>Z instanceof Buffer,kJ=(Z)=>{if(E9(Z))switch(Z.constructor){case Uint8Array:case Uint8ClampedArray:case Int8Array:case Uint16Array:case Int16Array:case Uint32Array:case Int32Array:case Float32Array:case Float64Array:return!0}return!1},SJ=(Z)=>Z instanceof ArrayBuffer,bJ=(Z)=>typeof Z==="string"&&Z.length>0,vJ=(Z)=>typeof Z==="number"&&Number.isFinite(Z),yJ=(Z)=>Number.isInteger(Z),gJ=(Z,W,X)=>Z>=W&&Z<=X,hJ=(Z,W)=>W.includes(Z),fJ=(Z,W,X)=>Error(`Expected ${W} for ${Z} but received ${X} of type ${typeof X}`),mJ=(Z,W)=>{return W.message=Z.message,W},z;var Y6=c(()=>{/*!
|
|
207
207
|
Copyright 2013 Lovell Fuller and others.
|
|
208
208
|
SPDX-License-Identifier: Apache-2.0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jxsuite/compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"description": "Jx static HTML compiler, island detector, and site builder",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@apidevtools/json-schema-ref-parser": "^15.4.0",
|
|
46
|
-
"@jxsuite/parser": "^0.35.
|
|
47
|
-
"@jxsuite/runtime": "^0.34.
|
|
48
|
-
"@jxsuite/schema": "^0.
|
|
46
|
+
"@jxsuite/parser": "^0.35.1",
|
|
47
|
+
"@jxsuite/runtime": "^0.34.2",
|
|
48
|
+
"@jxsuite/schema": "^0.35.0",
|
|
49
49
|
"sharp": "^0.35.3"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
package/src/site/site-loader.ts
CHANGED
|
@@ -117,6 +117,10 @@ export function loadProjectConfig(projectRoot: string) {
|
|
|
117
117
|
|
|
118
118
|
// Validate adapter
|
|
119
119
|
const VALID_ADAPTERS = ["cloudflare-workers", "cloudflare-pages", "node", "bun"];
|
|
120
|
+
// "static" is the Settings UI's explicit no-adapter choice; normalize it away.
|
|
121
|
+
if (config.build.adapter === "static") {
|
|
122
|
+
delete config.build.adapter;
|
|
123
|
+
}
|
|
120
124
|
if (config.build.adapter && !VALID_ADAPTERS.includes(config.build.adapter)) {
|
|
121
125
|
throw new Error(
|
|
122
126
|
`Unknown build adapter "${config.build.adapter}" in project.json. ` +
|