@wren-js/core 0.3.2 → 0.5.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.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{_ as e,b as t,d as n,f as r,g as i,h as a,l as o,m as s,t as c,u as l,v as u,y as d}from"./constants-
|
|
1
|
+
import{_ as e,b as t,d as n,f as r,g as i,h as a,l as o,m as s,t as c,u as l,v as u,y as d}from"./constants-Bd5vaufk.mjs";import{c as f,d as p,l as m,n as h,s as g,u as _}from"./constants-BzbcwnVj.mjs";import{CONFIG_VALID_EXTENSIONS as v,DEFAULTS as y}from"./config.mjs";import{t as b}from"./utils-DhsYUjpC.mjs";import{existsSync as ee}from"node:fs";import{basename as x,dirname as S,extname as te,isAbsolute as C,join as w,relative as T,resolve as E}from"node:path";import D from"node:process";import{parseArgs as ne}from"node:util";import{Visitor as re,createBuilder as ie,createServer as ae,defineConfig as oe,isCSSRequest as se,loadConfigFromFile as ce,loadEnv as le,mergeConfig as O,normalizePath as k,parseSync as A}from"vite";import{mkdir as ue,readFile as j,readdir as de,rm as M,writeFile as N}from"node:fs/promises";import{pathToFileURL as fe}from"node:url";const P=e=>{let t=0;for(let n=e.indexOf(`
|
|
2
2
|
`);n!==-1;n=e.indexOf(`
|
|
3
|
-
`,n+1))t++;return t},pe=(e,t,n,r)=>{let i=
|
|
4
|
-
`.repeat(i):r}},me=(e,t)=>{let n=``,r=0;for(let{end:i,start:a,text:o}of t.toSorted((e,t)=>e.start-t.start))n+=e.slice(r,a)+o,r=i;return n+e.slice(r)},
|
|
5
|
-
`.repeat(
|
|
3
|
+
`,n+1))t++;return t},pe=(e,t,n,r)=>{let i=P(e.slice(t,n))-P(r);return{end:n,start:t,text:i>0?r+`
|
|
4
|
+
`.repeat(i):r}},me=(e,t)=>{let n=``,r=0;for(let{end:i,start:a,text:o}of t.toSorted((e,t)=>e.start-t.start))n+=e.slice(r,a)+o,r=i;return n+e.slice(r)},F=e=>x(e,te(e)),I=e=>Object.fromEntries(e.toSorted(([e],[t])=>e<t?-1:1)),he=e=>{let t=[];for(let{entries:n}of e)for(let{exportName:e,isType:r}of n){if(r)continue;let n=e.kind===`Default`?`default`:e.name;n!==null&&t.push(n)}return t},ge=/^(?:[a-z][a-z\d+.-]*:|\/\/)/i,L=e=>{if(e.type===`Literal`&&typeof e.value==`string`)return e.value;if(e.type===`TemplateLiteral`&&e.expressions.length===0)return e.quasis[0]?.value.cooked??void 0},R=({value:e})=>{if(e?.type===`Literal`)return e.value;if(e?.type===`JSXExpressionContainer`)return L(e.expression)},_e=(e,t)=>{let n={kept:[]};for(let r of t.attributes){let t=e.slice(r.start,r.end);if(r.type!==`JSXAttribute`||r.name.type!==`JSXIdentifier`){n.kept.push(t);continue}let{name:i}=r.name;i===`src`?n.src=r:i===`dangerouslySetInnerHTML`?n.html=r:(i===`type`&&(n.type=R(r)),n.kept.push(t))}return n},ve=({key:e})=>e.type===`Identifier`?e.name:e.type===`Literal`?e.value:null,ye=({value:e})=>{let t=e?.type===`JSXExpressionContainer`?e.expression:void 0;if(t?.type===`ObjectExpression`)for(let e of t.properties){if(e.type!==`Property`||e.computed||ve(e)!==`__html`)continue;let t=L(e.value);return t===void 0?void 0:[t,e.value.start+1]}},be=(e,t)=>{if(t)return ye(t);let n=e.children.filter(e=>e.type!==`JSXText`||e.value.trim()!==``);if(n.length===0)return[``,e.start];if(n.length!==1)return;let[r]=n;if(r.type===`JSXText`)return[r.value,r.start];if(r.type!==`JSXExpressionContainer`)return;let i=L(r.expression);return i===void 0?void 0:[i,r.expression.start+1]},xe=({name:e})=>e.type===`JSXIdentifier`&&e.name===`script`,z=(e,t)=>{let n=[],r=[],{errors:i,program:a}=A(t,e);if(i.length>0)return{scripts:n,warnings:r};let o=0,s=/* @__PURE__ */ new Set,c=e=>{for(let t of e.children)s.add(t.start)},l=t=>{let{html:i,kept:a,src:c,type:l}=_e(e,t.openingElement),u=c&&R(c),d=u!==void 0&&!ge.test(u);if(l!==`module`){d&&p.test(u)&&r.push(`<script src="${u}"> is not bundled; add type="module" to make it a page script.`);return}let f={attributes:a,end:t.end,replacement:s.has(t.start)?``:`<></>`,start:t.start};if(c){d&&n.push({...f,kind:`src`,src:u});return}let m=be(t,i);if(!m){r.push(`<script type="module"> content must be a static string to be bundled.`);return}let[h,g]=m;h.trim()!==``&&n.push({...f,code:h,codeStart:g,index:o++,kind:`inline`})};return new re({JSXElement(e){c(e),xe(e.openingElement)&&l(e)},JSXFragment:c}).visit(a),{scripts:n,warnings:r}},B=`virtual:${d}-page-scripts`,V=`__wrenPageScripts`,H=`${B}:route:`,U=`\0${H}`,W=`\0${g}`,G=/\?wren-script=(\d+)\.ts$/,K=`__wren-page-scripts.mjs`,q=`\0${f}`,J=(e,t)=>{let n=k(T(e,t));return n.startsWith(`../`)||C(n)?`@fs/${k(t).replace(/^\//,``)}`:n},Se=async(e,t,n)=>{let r=t.attributes.filter(e=>!/^type\b/.test(e));if(r.length>0&&e.warn(`Page script attributes are dropped when hoisted: ${r.join(` `)}`),t.kind===`inline`)return{id:`${n}?wren-script=${t.index}.ts`,name:`${F(n)}-${t.index}`};let i=await e.resolve(t.src,n);if(!i||i.external||i.id.includes(`/node_modules/`))e.warn(`Page script "${t.src}" must resolve to a project file; left as is.`);else return{id:i.id,name:F(i.id)}},Ce=async(e,t,n)=>{let r=await j(t,`utf8`),i=z(r,t).scripts.find(e=>e.kind===`inline`&&e.index===n);return i?.kind===`inline`?{code:`
|
|
5
|
+
`.repeat(P(r.slice(0,i.codeStart)))+i.code,map:null}:e.error(`Inline page script #${n} not found in ${t}.`)},we=e=>{let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Map,o=/* @__PURE__ */ new Map,s,c=[],l=(e,n)=>{let r=J(e,n.id),i=t.get(r)??{...n,key:r};return t.set(r,i),i},u=(e,t)=>{let n=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Set,o=e=>{if(!a.has(e)){a.add(e);for(let t of r.get(e)??[])n.add(t);for(let t of i.get(e)?.values()??[])for(let e of t)n.add(e);for(let n of t(e))o(n)}};return o(e),[...n]},m=async(e,t,n,i)=>{let{scripts:a,warnings:o}=z(t,n),s=a.map(({end:e,replacement:n,start:r})=>pe(t,r,e,n));if(!i)return s;for(let t of o)e.warn(t);let c=await Promise.all(a.map(t=>Se(e,t,n))),{root:u}=e.environment.config;return r.set(n,c.flatMap(e=>e?[l(u,e)]:[])),s.filter((e,t)=>c[t])},v=(e,t,n)=>{if(!n)return`\nexport const ${h} = async () => (await import(${JSON.stringify(H+encodeURIComponent(e))})).default;\n`;let r=J(t,e);return a.set(e,r),`\nimport ${V} from ${JSON.stringify(B)};export const ${h} = () => ${V}.routes[${JSON.stringify(r)}];\n`},y=(e,t)=>{let n=u(t,t=>c.flatMap(({moduleGraph:n})=>{let r=n.getModuleById(t);return r?.file&&C(r.file)&&e.addWatchFile(r.file),Array.from(r?.importedModules??[],e=>e.id).filter(e=>e!==null&&!se(e))})),{base:r}=e.environment.config;return`export default ${JSON.stringify(n.map(e=>r+e.key))};`};return{buildApp:{async handler(e){let r=[...t.values()],i=r.filter(e=>!e.url).map(e=>e.key);if(i.length>0)throw Error(`[${d}] Page scripts were not bundled by the client environment (server environments must build first): ${i.join(`, `)}`);let s={routes:I(Array.from(a,([e,t])=>[t,u(e,e=>o.get(e)??[]).map(e=>e.url)])),scripts:I(r.map(e=>[e.key,e.url]))},c=`export default ${JSON.stringify(s)};\n`;await Promise.all([...n].map(async t=>{let{build:n,root:r}=e.environments[t].config;await N(E(r,n.outDir,K),c)}))},order:`post`},buildEnd(){if(this.environment.mode===`build`)for(let e of this.getModuleIds()){let t=this.getModuleInfo(e);if(!t)continue;let n=[...t.importedIds,...t.dynamicallyImportedIds];o.set(e,[...o.get(e)??[],...n])}},buildStart(){let{mode:e,name:n}=this.environment;if(e===`build`&&n===`client`)for(let e of t.values())e.reference=this.emitFile({id:e.id,name:`scripts/${e.name}`,preserveSignature:`exports-only`,type:`chunk`})},configResolved(t){s=`${k(E(t.root,e))}/`},configureServer(e){c=Object.values(e.environments)},enforce:`pre`,generateBundle(){if(this.environment.name!==`client`)return;let{base:e}=this.environment.config;for(let n of t.values())n.reference&&(n.url=e+this.getFileName(n.reference))},load:{filter:{id:[G,RegExp(`^${q}`),RegExp(`^${U}`),RegExp(`^${W}$`)]},async handler(e){let{config:t,mode:n}=this.environment;if(e===W)return`export {};`;if(e.startsWith(q)){let r=e.slice(q.length),{key:i}=l(t.root,{id:r,name:F(r)});return n===`build`?`import ${V} from ${JSON.stringify(B)};export default ${V}.scripts[${JSON.stringify(i)}];`:`export default ${JSON.stringify(t.base+i)};`}if(e.startsWith(U))return y(this,decodeURIComponent(e.slice(U.length)));let r=G.exec(e);return r?Ce(this,e.slice(0,r.index),Number(r[1])):null}},name:`${d}-page-scripts`,renderChunk(e,t){if(!e.includes(B))return null;this.environment.config.build.write&&n.add(this.environment.name);let r=k(T(S(t.fileName),K)),i=r.startsWith(`.`)?r:`./${r}`;return{code:e.replaceAll(B,i),map:null}},resolveId:{filter:{id:RegExp(`^(?:${g}|${f}|${B})`)},async handler(e,t){if(e.startsWith(`virtual:wrenjs-hoist:`)){if(t&&this.environment.config.consumer===`server`){let n=await this.resolve(e.slice(g.length),t);if(!n?.id.startsWith(q))return this.error(`"${e}" must resolve to a Wren page script (${t}).`);let r=n.id.slice(q.length),a=l(this.environment.config.root,{id:r,name:F(r)}),o=i.get(t)??/* @__PURE__ */ new Map,s=o.get(this.environment.name)??/* @__PURE__ */ new Set;i.set(t,o.set(this.environment.name,s.add(a)))}return W}return e.startsWith(`virtual:wrenjs-script-url:`)||e.startsWith(H)?`\0${e}`:e===B?{external:!0,id:e}:null}},sharedDuringBuild:!0,transform:{filter:{id:p},async handler(e,t){let{config:n,mode:a}=this.environment,o=n.consumer===`server`,c=o&&t.startsWith(s)&&_.test(t),l=e.includes(`<script`)?await m(this,e,t,o):[];if(l.length===0&&r.delete(t),i.get(t)?.delete(this.environment.name),l.length===0&&!c)return null;let u=c?v(t,n.root,a===`build`):``;return{code:me(e,l)+u,map:null}}}}},Te=/<link\b(?=[^>]*\srel="stylesheet")(?![^>]*\s(?:disabled|media)\b)[^>]*\shref="([^"]+)"[^>]*>/gi,Ee=/\sdata-precedence="[^"]*"/i,De=/<\/(style)/gi,Oe=(e,t,n,r)=>{for(let i of Object.values(e)){if(i.type!==`asset`||!i.fileName.endsWith(`.css`))continue;let e=Buffer.from(i.source);e.byteLength<n&&r.set(t+i.fileName,e.toString().replace(De,`<\\/$1`))}},ke=(e,t)=>{let n=e.indexOf(`</head>`);return n===-1&&(n=e.length),e.slice(0,n).replace(Te,(e,n)=>{let r=t.get(n);if(r===void 0)return e;let i=Ee.exec(e)?.[0]??``,a=`<style data-href="${n}"${i}>${r}</style>`;return i?`${a}<link disabled type="text/x-inlined"${e.slice(5)}`:a})+e.slice(n)},Ae=async(e,t,n=`http://localhost`,r=!1,i=/* @__PURE__ */ new Map)=>{let a=new URL(n);if(!/^https?:$/.test(a.protocol)||a.href!==`${a.origin}/`)throw Error(`build.prerender.origin must be an HTTP(S) origin.`);let o=/* @__PURE__ */ new Set,s=/* @__PURE__ */ new Set,c=async({pathname:e,response:n})=>{let r=b(e);if(n.status!==200)throw Error(`Cannot prerender ${r}: HTTP ${n.status}.`);let a=n.headers.get(`content-type`)?.startsWith(`text/html`),c=a?w(r.slice(1),`index.html`):r.slice(1);if(o.has(r)||s.has(c))throw Error(`Conflicting prerender artifact: ${r}.`);o.add(r),s.add(c);let l=w(t,c);await ue(S(l),{recursive:!0}),await N(l,a&&i.size>0?ke(await n.text(),i):new Uint8Array(await n.arrayBuffer()))},l=0;return await Promise.all(e.map(async e=>{let t=await e.getPaths(r);await Promise.all(t.map(async t=>{let n=b(t);if(o.has(n))throw Error(`Multiple prerender providers claim ${n}.`);let r=await e.render(new Request(new URL(n,a)));if(await Promise.all(r.map(c)),!o.has(n))throw Error(`Prerender renderer did not return ${n}.`);l++}))})),l},je=e=>{let t=e.integrations?.flatMap(({prerender:e})=>e?[{...e,output:``,reference:``}]:[])??[],n=e.build?.inlineCSS,r=n===!0?1/0:n||0,i=/* @__PURE__ */ new Map;return{apply:`build`,buildApp:{async handler(n){if(!t.length)return;let r=await Promise.all(t.map(async({environment:e,output:t})=>{if(!t)throw Error(`No prerender entry was built for ${e}.`);return import(
|
|
6
6
|
/* @vite-ignore */
|
|
7
|
-
fe(t).href)})),a=n.environments.client;if(!a)throw Error(`Prerendering requires a client output environment.`);let o=await Ae(r,
|
|
8
|
-
`)}`);let i=Fe(e.name,he(r.staticExports));return i&&{file:t,kind:i}},
|
|
7
|
+
fe(t).href)})),a=n.environments.client;if(!a)throw Error(`Prerendering requires a client output environment.`);let o=await Ae(r,E(n.config.root,a.config.build.outDir),e.build?.prerender?.origin,e.build?.output===`static`,i);n.config.logger.info(`Prerendered ${o} pages.`),await Promise.all(t.flatMap(({output:e})=>[M(e,{force:!0}),M(`${e}.map`,{force:!0})]))},order:`post`},buildStart(){for(let e of t)e.environment===this.environment.name&&(e.reference=this.emitFile({id:e.entry,preserveSignature:`strict`,type:`chunk`}))},generateBundle(){if(this.environment.config.build.write)for(let e of t)e.environment===this.environment.name&&(e.output=E(this.environment.config.root,this.environment.config.build.outDir,this.getFileName(e.reference)))},name:`${d}-prerender`,sharedDuringBuild:!0,writeBundle(e,t){r&&this.environment.name===`client`&&Oe(t,this.environment.config.base,r,i)}}},Me=/* @__PURE__ */ new Map([[o,s],[l,a],[n,e],[r,u]]),Ne={layouts:[],proxies:[]},Pe=/\/\([^/]+\)(?=\/|$)/g,Fe=(e,t)=>{let n=t.includes(`default`),r=c.some(e=>t.includes(e)),a=Me.get(F(e));if(n)return a?r?void 0:a:i;if(r)return!a||a===`LAYOUT`||a===`ROOT`?`API`:void 0},Ie=e=>e.isFile()&&_.test(e.name),Le=async e=>{let t=k(`${e.parentPath}/${e.name}`),{errors:n,module:r}=A(t,await j(t,`utf8`));if(n.length>0)throw SyntaxError(`Cannot parse ${t}: ${n.map(e=>e.message).join(`
|
|
8
|
+
`)}`);let i=Fe(e.name,he(r.staticExports));return i&&{file:t,kind:i}},Y=(e,t)=>{let n=[];return{params:n,pattern:t.slice(e.length).replace(/\.[^/.]+$/,``).replace(/\/(?:index|__not-found)$/,``).replaceAll(/\[(\.\.\.)?([^[\]]+)\]/g,(e,t,r)=>(n.push(r),t?`:${r}*`:`:${r}`)).replaceAll(Pe,``)||`/`}},Re=async(e,t)=>{let n=k(E(t,e.router)),r=await de(n,{recursive:!0,withFileTypes:!0}),i=(await Promise.all(r.filter(Ie).map(Le))).filter(e=>e!==void 0),a=/* @__PURE__ */ new Map;for(let e of i){let{kind:t}=e;if(t!==`LAYOUT`&&t!==`PROXY`&&t!==`ROOT`)continue;let n=S(e.file),r=a.get(n)??{layouts:[],proxies:[],roots:[]};a.set(n,r),t===`LAYOUT`?r.layouts.push(e):t===`PROXY`?r.proxies.push(e):r.roots.push(e)}let o=/* @__PURE__ */ new Map,s=e=>{let t=o.get(e);if(!t){let r=e===n?Ne:s(S(e)),{layouts:i=[],proxies:c=[],roots:l=[]}=a.get(e)??{};t={layouts:[...i,...l,...r.layouts],proxies:[...c,...r.proxies]},o.set(e,t)}return t},c=[],l=[];for(let{file:e,kind:t}of i)t===`PAGE`?l.push({file:e,kind:t,...Y(n,e),...s(S(e))}):(t===`API`||t===`NOT_FOUND`)&&(t===`API`?l:c).push({file:e,kind:t,...Y(n,e)});return{notFounds:c,routes:l}},X=()=>({s:Object.create(null)}),ze=(e,t,n)=>{let r=[],i=e,a=n;for(;a<t.length;a++){let e=i.indexOf(`:${t[a]}`);if(e<0)break;r.push(i.slice(0,e)),i=i.slice(e+t[a].length+1)}return r.push(i),{i:a,lits:r}},Be=(e,t,n)=>{let r=n.params,i=t.split(`/`).filter(Boolean),a=i.at(-1)===`:${r.at(-1)}*`?`w`:`e`;a===`w`&&i.pop();let o=e,s=0;for(let e of i)if(!e.includes(`:`))o.s[e]??=X(),o=o.s[e];else if(e===`:${r[s]}`)o.p??=X(),o=o.p,s++;else if(e.endsWith(`*`))throw Error(`Catch-all must be last in "${t}".`);else{let n=ze(e,r,s);if(n.i===s)throw Error(`Params do not match pattern "${t}".`);let i=X();o.m??=[],o.m.push({lits:n.lits,node:i}),o=i,s=n.i}if(s!==r.length-+(a===`w`))throw Error(`Params do not match pattern "${t}".`);let c=o[a];if(c)throw Error(`"${n.file}" conflicts with "${c.file}".`);o[a]=n},Ve=e=>{let t=X();for(let[n,r]of Object.entries(e))Be(t,n,r);return t},Z=e=>{let t={},n={};for(let r of e){let{params:e,pattern:i,...a}=r;e?.length?t[i]=r:n[i]=a}return[Ve(t),n]},He=async(e,t)=>{let{notFounds:n,routes:r}=await Re(e,t),[i,a]=Z(n),[o,s]=Z(r);return{dynamicNotFounds:i,dynamicRoutes:o,staticNotFounds:a,staticRoutes:s}},Q=e=>({__wrenCode:e}),Ue=(e,t)=>{let n=/* @__PURE__ */ new Map,r=e=>{let t=k(e.file),r=n.get(t);return r||(r=`load${n.size}`,n.set(t,r)),r},i=JSON.stringify(e,(e,t)=>{if(!t||typeof t.file!=`string`)return t;let n=r(t),i=t.layouts?.map(r),a=t.proxies?.map(r);return{kind:t.kind,layouts:i?.map(Q),module:Q(n),params:t.params,pattern:t.pattern,proxies:a?.map(Q),stack:Q(`createStack(${n}, [${i?.join(`, `)??``}], [${a?.join(`, `)??``}])`)}}).replace(/\{"__wrenCode":"([^"]+)"\}/g,`$1`),a=[...n].map(([e,n])=>{let r=`() => import(${JSON.stringify(e)})`;return`const ${n} = ${t?`memoize(${r})`:r};`});return`
|
|
9
9
|
${t?`function memoize(load) {
|
|
10
10
|
let pending;
|
|
11
11
|
return () => {
|
|
@@ -48,4 +48,4 @@ fe(t).href)})),a=n.environments.client;if(!a)throw Error(`Prerendering requires
|
|
|
48
48
|
const manifest = deepFreeze(${i});
|
|
49
49
|
export const { dynamicNotFounds, dynamicRoutes, staticNotFounds, staticRoutes } = manifest;
|
|
50
50
|
export default manifest;
|
|
51
|
-
`}
|
|
51
|
+
`},$=`\0${m}`,We=(e,t)=>({configureServer(e){let n=`${k(E(e.config.root,t.router))}/`,r=t=>{if(!k(t).startsWith(n))return;let r=!1;for(let{moduleGraph:t}of Object.values(e.environments)){let e=t.getModuleById($);e&&(r=!0,t.invalidateModule(e))}r&&e.ws.send({type:`full-reload`})};e.watcher.on(`add`,r).on(`change`,r).on(`unlink`,r)},load:{filter:{id:RegExp(`^${$}$`)},async handler(){let n=await He(t,this.environment.config.root);return Ue(n,e.command===`build`)}},name:`${d}-route-manifest`,resolveId:{filter:{id:RegExp(`^${m}$`)},handler:()=>$}}),Ge=async(e,t)=>{let n=oe({appType:`custom`,build:{minify:!0,outDir:`dist`,rolldownOptions:{experimental:{nativeMagicString:!0},optimization:{inlineConst:{mode:`smart`,pass:2}}}},builder:{async buildApp(e){let t=Object.values(e.environments).toSorted((e,t)=>Number(e.config.consumer===`client`)-Number(t.config.consumer===`client`));for(let n of t){if(n.isBuilt)continue;let{build:t,input:r,isBundled:i}=n.config,a=t.rolldownOptions.input??(t.lib?t.lib.entry:void 0)??(typeof t.ssr==`string`?t.ssr:r);!(typeof a==`string`||Object.keys(a??{}).length>0)||!i?delete e.environments[n.name]:await e.build(n)}},sharedConfigBuild:!0,sharedPlugins:!0},plugins:[{api:{wrenConfig:t},name:`${d}-config`},We(e,t),we(t.router),je(t)],resolve:{noExternal:[/^@wren-js\//],tsconfigPaths:!0}});return(await Promise.all([t.adapter,...t.integrations??[]].map(async n=>n?.viteConfig(t,e)))).reduce((e,t)=>t?O(e,t):e,n)},Ke=`VITE_`,qe=async e=>{let t=D.cwd();Object.assign(D.env,le(e.mode,t,[``,Ke]));let n=v.map(e=>k(E(t,`wren.config.${e}`))),r=n.find(e=>ee(e)),i=r?await ce(e,r):null,a=/* @__PURE__ */ new Set([...n,...(i?.dependencies??[]).map(e=>k(E(e)))]),o=i?O(y,i.config):y,s=O(await Ge(e,o),o.vite??{});return{...s,clearScreen:!1,configFile:!1,envDir:t,envPrefix:Ke,mode:e.mode,plugins:[...s.plugins??[],{apply:`serve`,configResolved(e){e.configFileDependencies.push(...a)},configureServer(t){let n=t.restart.bind(t),r;t.restart=i=>(r??=(async()=>{let r=await qe(e),{inlineConfig:a}=t.config;for(let e of Object.keys(a))Reflect.deleteProperty(a,e);Object.assign(a,r),await n(i)})().finally(()=>{r=void 0}),r),t.watcher.on(`change`,e=>{let n=x(e);(/\.config\.[^/]*$/.test(k(e))||n.startsWith(`.env`)&&!n.startsWith(`.env.example`))&&t.restart().catch(e=>{t.config.logger.error(e instanceof Error?e.stack??e.message:String(e))})})},name:`${d}-config-reload`}]}},Je=async e=>{let n=await qe(e);if(e.command===`build`)return(await ie(n)).buildApp();let r=await ae(n);return await r.listen(),console.info(`${d} v${t}`),r.printUrls(),r.bindCLIShortcuts({print:!0}),r},{positionals:Ye,values:Xe}=ne({allowPositionals:!0,args:D.argv.slice(2),options:{help:{short:`h`,type:`boolean`},version:{short:`v`,type:`boolean`}}});if(Xe.version)console.info(`${d} v${t}`);else if(Xe.help)console.info(`Usage: wren [dev|build] [-h|--help] [-v|--version]`);else{let e=Ye[0]===`build`?`build`:`serve`;Je({command:e,mode:e===`build`?`production`:D.env.NODE_ENV??`development`}).catch(e=>{console.error(e),D.exit(1)})}export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=`0.5.0`;const t=`wrenjs`,n=e,r=`ROOT`,i=`PAGE`,a=`API`,o=`NOT_FOUND`,s=`LAYOUT`,c=`PROXY`,l=`___root`,u=`__layout`,d=`__not-found`,f=`__proxy`,p=`GET`,m=`DELETE`,h=`HEAD`,g=`OPTIONS`,_=`PATCH`,v=`POST`,y=`PUT`,b=[`GET`,m,h,g,_,v,`PUT`];export{c as _,g as a,n as b,y as c,f as d,l as f,i as g,o as h,h as i,u as l,s as m,m as n,_ as o,a as p,p as r,v as s,b as t,d as u,r as v,t as y};
|
package/dist/constants.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,a as t,b as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as u,n as d,o as f,p,r as m,s as h,t as g,u as _,v,y}from"./constants-
|
|
1
|
+
import{_ as e,a as t,b as n,c as r,d as i,f as a,g as o,h as s,i as c,l,m as u,n as d,o as f,p,r as m,s as h,t as g,u as _,v,y}from"./constants-Bd5vaufk.mjs";import{u as b}from"./constants-BzbcwnVj.mjs";export{g as ENTRY_API_EXPORTS,d as ENTRY_FILEROUTE_API_EXPORT_DELETE,m as ENTRY_FILEROUTE_API_EXPORT_GET,c as ENTRY_FILEROUTE_API_EXPORT_HEAD,t as ENTRY_FILEROUTE_API_EXPORT_OPTIONS,f as ENTRY_FILEROUTE_API_EXPORT_PATCH,h as ENTRY_FILEROUTE_API_EXPORT_POST,r as ENTRY_FILEROUTE_API_EXPORT_PUT,l as ENTRY_FILEROUTE_LAYOUT,_ as ENTRY_FILEROUTE_NOT_FOUND,i as ENTRY_FILEROUTE_PROXY,a as ENTRY_FILEROUTE_ROOT,p as ENTRY_KIND_API,u as ENTRY_KIND_LAYOUT,s as ENTRY_KIND_NOT_FOUND,o as ENTRY_KIND_PAGE,e as ENTRY_KIND_PROXY,v as ENTRY_KIND_ROOT,b as ROUTE_MODULE_RE,y as WREN_NAME,n as WREN_VERSION};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../constants-
|
|
1
|
+
import"../constants-Bd5vaufk.mjs";import{t as e}from"../utils-DhsYUjpC.mjs";function*t(e){e.e&&(yield e.e),e.w&&(yield e.w);for(let n of Object.values(e.s))yield*t(n);e.p&&(yield*t(e.p));for(let n of e.m??[])yield*t(n.node)}const n=async(e,t,n)=>{if(e.kind!==`PAGE`)return[];let r=await Promise.all([e.module(),...e.layouts?.map(e=>e())??[]]);if(!n&&!r.some(e=>e.config?.prerender===!0))return[];if(!e.params?.length){if(!t)throw Error(`A static prerender route must have a pathname.`);return[t]}let[i]=r;if(!i.getStaticPaths)throw Error(`Prerendered route ${t} must export getStaticPaths().`);return i.getStaticPaths()},r=async(r,i=!1)=>{let{dynamicRoutes:a,staticRoutes:o={}}=r,s=await Promise.all([...Object.entries(o).map(([e,t])=>n(t,e,i)),...Array.from(t(a),e=>n(e,e.pattern,i))]);return[...new Set(s.flat().map(t=>e(t)))]};export{r as getPrerenderPaths};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wren-js/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Framework agnostic utilities for the wrenjs meta-framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"@wren-js/core",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"typescript": "7.0.2",
|
|
66
|
-
"vite-plus": "1.
|
|
66
|
+
"vite-plus": "1.3.0"
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|
|
69
69
|
"build": "vp pack",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./constants-BzbcwnVj.mjs";var e=`0.3.2`;const t=`wrenjs`,n=e,r=`ROOT`,i=`PAGE`,a=`API`,o=`NOT_FOUND`,s=`LAYOUT`,c=`PROXY`,l=`___root`,u=`__layout`,d=`__not-found`,f=`__proxy`,p=`GET`,m=`DELETE`,h=`HEAD`,g=`OPTIONS`,_=`PATCH`,v=`POST`,y=`PUT`,b=[`GET`,m,h,g,_,v,`PUT`];export{c as _,g as a,n as b,y as c,f as d,l as f,i as g,o as h,h as i,u as l,s as m,m as n,_ as o,a as p,p as r,v as s,b as t,d as u,r as v,t as y};
|