@wren-js/core 0.0.0-stage → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/bin/cli.mjs +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +50 -0
- package/dist/components/Link/wren-link.d.mts +1 -0
- package/dist/components/Link/wren-link.mjs +1 -0
- package/dist/config.d.mts +107 -0
- package/dist/config.mjs +1 -0
- package/dist/constants-B7Wo9Ox0.mjs +1 -0
- package/dist/constants-CQI5U_DU.mjs +1 -0
- package/dist/constants-CstgyYjd.d.mts +134 -0
- package/dist/constants.d.mts +2 -0
- package/dist/constants.mjs +1 -0
- package/dist/link.d.mts +5 -0
- package/dist/link.mjs +1 -0
- package/dist/runtime/prerender.d.mts +7 -0
- package/dist/runtime/prerender.mjs +1 -0
- package/dist/runtime/router.d.mts +5 -0
- package/dist/runtime/router.mjs +1 -0
- package/dist/trie-lookup-BLa5NWBJ.mjs +1 -0
- package/dist/tsconfig/base.json +18 -0
- package/dist/tsconfig/strict.json +7 -0
- package/dist/tsconfig/strictest.json +14 -0
- package/dist/types.d.ts +130 -0
- package/dist/utils-0wezGh38.mjs +1 -0
- package/dist/virtual-wrenjs-fetch.d.ts +12 -0
- package/dist/virtual-wrenjs-island-script.d.ts +4 -0
- package/dist/virtual-wrenjs-link-client.d.ts +9 -0
- package/dist/virtual-wrenjs-page-scripts.d.ts +6 -0
- package/dist/virtual-wrenjs-routes.d.ts +9 -0
- package/package.json +72 -3
- package/README.md +0 -3
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Austin Raey 24833719+austin-raey@users.noreply.github.com
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/bin/cli.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../dist/cli.mjs";
|
package/dist/cli.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import{C as e,S as t,_ as n,b as r,d as i,f as a,g as o,h as s,l as c,p as l,t as u,u as d,v as f,w as p,x as m,y as h}from"./constants-CQI5U_DU.mjs";import{c as ee,l as g,n as te,s as _}from"./constants-B7Wo9Ox0.mjs";import{CONFIG_VALID_EXTENSIONS as ne,DEFAULTS as v}from"./config.mjs";import{t as y}from"./utils-0wezGh38.mjs";import{t as b}from"./trie-lookup-BLa5NWBJ.mjs";import{existsSync as re}from"node:fs";import{basename as ie,dirname as x,extname as ae,isAbsolute as oe,join as S,relative as C,resolve as w}from"node:path";import T,{cwd as se}from"node:process";import{parseArgs as ce}from"node:util";import{Visitor as le,createBuilder as ue,createServer as de,defineConfig as fe,loadConfigFromFile as pe,mergeConfig as E,normalizePath as D,parseSync as O}from"vite";import{mkdir as me,readFile as k,readdir as A,rm as j,writeFile as M}from"node:fs/promises";import{pathToFileURL as he}from"node:url";const ge=()=>se(),N=e=>e.split(`
|
|
2
|
+
`).length-1,_e=(e,t,n,r)=>{let i=N(e.slice(t,n))-N(r);return{end:n,start:t,text:i>0?r+`
|
|
3
|
+
`.repeat(i):r}},ve=(e,t)=>{let n=e;for(let{end:e,start:r,text:i}of t.toSorted((e,t)=>t.start-e.start))n=n.slice(0,r)+i+n.slice(e);return n},ye=/\.[cm]?[jt]sx?$/,be=/^(?:[a-z][a-z\d+.-]*:|\/\/)/i,P=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},F=({value:e})=>{if(e?.type===`Literal`)return e.value;if(e?.type===`JSXExpressionContainer`)return P(e.expression)},xe=(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=F(r)),n.kept.push(t))}return n},Se=({key:e})=>e.type===`Identifier`?e.name:e.type===`Literal`?e.value:null,Ce=({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||Se(e)!==`__html`)continue;let t=P(e.value);return t===void 0?void 0:[t,e.value.start+1]}},we=(e,t)=>{if(t)return Ce(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=P(r.expression);return i===void 0?void 0:[i,r.expression.start+1]},Te=({name:e})=>e.type===`JSXIdentifier`&&e.name===`script`,I=(e,t)=>{let n=[],r=[],{errors:i,program:a}=O(t,e);if(i.length>0)return{importOffset:0,scripts:n,warnings:r};let o=a.body.find(e=>e.type!==`ExpressionStatement`||typeof e.directive!=`string`)?.start??e.length,s=0,c=/* @__PURE__ */ new Set,l=e=>{for(let t of e.children)c.add(t.start)},u=t=>{let{html:i,kept:a,src:o,type:l}=xe(e,t.openingElement),u=o&&F(o),d=u!==void 0&&!be.test(u);if(l!==`module`){d&&ye.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:c.has(t.start)?``:`<></>`,start:t.start};if(o){d&&n.push({...f,kind:`src`,src:u});return}let p=we(t,i);if(!p){r.push(`<script type="module"> content must be a static string to be bundled.`);return}let[m,h]=p;m.trim()!==``&&n.push({...f,code:m,codeStart:h,index:s++,kind:`inline`})};return new le({JSXElement(e){l(e),Te(e.openingElement)&&u(e)},JSXFragment:l}).visit(a),{importOffset:o,scripts:n,warnings:r}},L=`virtual:${e}-page-scripts`,R=`__wrenPageScripts`,z=`${L}:route:`,B=`\0${z}`,V=`\0${_}`,H=/\?wren-script=(\d+)\.ts$/,U=`__wren-page-scripts.mjs`,W=`\0${ee}`,Ee=/\.[cm]?[jt]sx?$/,De=(e,t)=>{let n=D(C(e,t));return n.startsWith(`../`)||oe(n)?`@fs/${D(t).replace(/^\//,``)}`:n},G=e=>ie(e,ae(e)),Oe=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:`${G(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:G(i.id)}},ke=async(e,t,n)=>{let r=await k(t,`utf8`),i=I(r,t).scripts.find(e=>e.kind===`inline`&&e.index===n);return i?.kind===`inline`?{code:`
|
|
4
|
+
`.repeat(N(r.slice(0,i.codeStart)))+i.code,map:null}:e.error(`Inline page script #${n} not found in ${t}.`)},Ae=t=>{let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Map,o=[],s=/* @__PURE__ */ new Map,c,l=[],u=(e,t)=>{let r=De(e,t.id),i=n.get(r)??{...t,index:n.size,key:r};return n.set(r,i),i},d=e=>{let t=o.indexOf(e);return t===-1?o.push(e)-1:t},f=(e,t)=>{let n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set,o=e=>{if(!r.has(e)){r.add(e);for(let t of i.get(e)??[])n.add(t);for(let t of a.get(e)?.values()??[])for(let e of t)n.add(e);for(let n of t(e))o(n)}};return o(e),[...n]},p=async(e,t,n,r)=>{let{scripts:a,warnings:o}=I(t,n),s=a.map(({end:e,replacement:n,start:r})=>_e(t,r,e,n));if(!r)return s;for(let t of o)e.warn(t);let c=await Promise.all(a.map(t=>Oe(e,t,n))),{root:l}=e.environment.config;return i.set(n,c.flatMap(e=>e?[u(l,e)]:[])),s.filter((e,t)=>c[t])},m=(e,t)=>{let n=t?`() => ${R}.routes[${d(e)}]`:`async () => (await import(${JSON.stringify(z+encodeURIComponent(e))})).default`;return`\n${t?`import ${R} from ${JSON.stringify(L)};`:``}export const ${te} = ${n};\n`},h=(e,t)=>{let n=f(t,t=>l.flatMap(({moduleGraph:n})=>{let r=n.getModuleById(t);return r?.file&&e.addWatchFile(r.file),Array.from(r?.importedModules??[],e=>e.id).filter(e=>e!==null)})),{base:r}=e.environment.config;return`export default ${JSON.stringify(n.map(e=>r+e.key))};`};return{buildApp:{async handler(t){let i=[...n.values()],a=i.filter(e=>!e.url).map(e=>e.key);if(a.length>0)throw Error(`[${e}] Page scripts were not bundled by the client environment (server environments must build first): ${a.join(`, `)}`);let c={routes:o.map(e=>f(e,e=>s.get(e)??[]).map(e=>e.url)),scripts:i.map(e=>e.url)},l=`export default ${JSON.stringify(c)};\n`;await Promise.all([...r].map(async e=>{let{build:n,root:r}=t.environments[e].config;await M(w(r,n.outDir,U),l)}))},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];s.set(e,[...s.get(e)??[],...n])}},buildStart(){let{mode:e,name:t}=this.environment;if(e===`build`&&t===`client`)for(let e of n.values())e.reference=this.emitFile({id:e.id,name:`scripts/${e.name}`,preserveSignature:`exports-only`,type:`chunk`})},configResolved(e){c=`${D(w(e.root,t))}/`},configureServer(e){l=Object.values(e.environments)},enforce:`pre`,generateBundle(){if(this.environment.name!==`client`)return;let{base:e}=this.environment.config;for(let t of n.values())t.reference&&(t.url=e+this.getFileName(t.reference))},load:{filter:{id:[H,RegExp(`^${W}`),RegExp(`^${B}`),RegExp(`^${V}$`)]},async handler(e){let{config:t,mode:n}=this.environment;if(e===V)return`export {};`;if(e.startsWith(W)){let r=e.slice(W.length),{index:i,key:a}=u(t.root,{id:r,name:G(r)});return n===`build`?`import ${R} from ${JSON.stringify(L)};export default ${R}.scripts[${i}];`:`export default ${JSON.stringify(t.base+a)};`}if(e.startsWith(B))return h(this,decodeURIComponent(e.slice(B.length)));let r=H.exec(e);return r?ke(this,e.slice(0,r.index),Number(r[1])):null}},name:`${e}-page-scripts`,renderChunk(e,t){if(!e.includes(L))return null;this.environment.config.build.write&&r.add(this.environment.name);let n=D(C(x(t.fileName),U)),i=n.startsWith(`.`)?n:`./${n}`;return{code:e.replaceAll(L,i),map:null}},async resolveId(e,t){if(e.startsWith(`virtual:wrenjs-hoist:`)){if(t&&this.environment.config.consumer===`server`){let n=await this.resolve(e.slice(_.length),t);if(!n?.id.startsWith(W))return this.error(`"${e}" must resolve to a Wren page script (${t}).`);let r=n.id.slice(W.length),i=u(this.environment.config.root,{id:r,name:G(r)}),o=a.get(t)??/* @__PURE__ */ new Map,s=o.get(this.environment.name)??/* @__PURE__ */ new Set;a.set(t,o.set(this.environment.name,s.add(i)))}return V}return e.startsWith(`virtual:wrenjs-script-url:`)||e.startsWith(z)?`\0${e}`:e===L?{external:!0,id:e}:null},sharedDuringBuild:!0,transform:{filter:{id:Ee},async handler(e,t){let{config:n,mode:r}=this.environment,o=n.consumer===`server`,s=o&&t.startsWith(c)&&g.test(t),l=e.includes(`<script`)?await p(this,e,t,o):[];if(l.length===0&&i.delete(t),a.get(t)?.delete(this.environment.name),l.length===0&&!s)return null;let u=s?m(t,r===`build`):``;return{code:ve(e,l)+u,map:null}}}}},je=async(e,t,n=`http://localhost`,r=!1)=>{let i=new URL(n);if(!/^https?:$/.test(i.protocol)||i.href!==`${i.origin}/`)throw Error(`build.prerender.origin must be an HTTP(S) origin.`);let a=/* @__PURE__ */ new Set,o=/* @__PURE__ */ new Set,s=async({pathname:e,response:n})=>{let r=y(e);if(n.status!==200)throw Error(`Cannot prerender ${r}: HTTP ${n.status}.`);let i=n.headers.get(`content-type`)?.startsWith(`text/html`)?S(r.slice(1),`index.html`):r.slice(1);if(a.has(r)||o.has(i))throw Error(`Conflicting prerender artifact: ${r}.`);a.add(r),o.add(i);let s=S(t,i);await me(x(s),{recursive:!0}),await M(s,new Uint8Array(await n.arrayBuffer()))},c=0;return await Promise.all(e.map(async e=>{let t=await e.getPaths(r);await Promise.all(t.map(async t=>{let n=y(t);if(a.has(n))throw Error(`Multiple prerender providers claim ${n}.`);let r=await e.render(new Request(new URL(n,i)));if(await Promise.all(r.map(s)),!a.has(n))throw Error(`Prerender renderer did not return ${n}.`);c++}))})),c},Me=(t,n)=>{let r=n.integrations?.flatMap(({prerender:e})=>e?[{...e,output:``,reference:``}]:[])??[];return{apply:`build`,buildApp:{async handler(e){if(!r.length)return;let t=await Promise.all(r.map(async({environment:e,output:t})=>{if(!t)throw Error(`No prerender entry was built for ${e}.`);return import(
|
|
5
|
+
/* @vite-ignore */
|
|
6
|
+
he(t).href)})),i=e.environments.client;if(!i)throw Error(`Prerendering requires a client output environment.`);let a=await je(t,w(e.config.root,i.config.build.outDir),n.build?.prerender?.origin,n.build?.output===`static`);e.config.logger.info(`Prerendered ${a} pages.`),await Promise.all(r.flatMap(({output:e})=>[j(e,{force:!0}),j(`${e}.map`,{force:!0})]))},order:`post`},buildStart(){for(let e of r)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 r)e.environment===this.environment.name&&(e.output=w(this.environment.config.root,this.environment.config.build.outDir,this.getFileName(e.reference)))},name:`${e}-prerender`,sharedDuringBuild:!0}},Ne={0:void 0,1:n,10:`API`,11:n,100:void 0,101:s,110:`API`,200:void 0,201:o,210:void 0,300:void 0,301:f,310:void 0,1e3:void 0,1001:h,1010:`API`},K=(e,t)=>{let n=t.includes(`default`),r=u.some(e=>t.includes(e)),o=e.replace(/\.[^/.]+$/,``),s=Number(n)+10*Number(r)+100*Number(o===c)+200*Number(o===d)+300*Number(o===i)+1e3*Number(o===a);return Ne[s]||void 0};let q=0;const J=e=>e.isFile()&&g.test(e.name),Y=async e=>{let{errors:t,module:n}=O(e,await k(e,`utf8`));if(t.length>0)throw SyntaxError(`Cannot parse ${e}: ${t.map(e=>e.message).join(`
|
|
7
|
+
`)}`);return n.staticExports.reduce((e,t)=>{for(let n of t.entries){if(n.isType)continue;let t=n.exportName.kind===`Default`?`default`:n.exportName.name;t!==null&&e.push(t)}return e},[])},Pe=[l,c,i],X={layouts:[],proxies:[]},Fe=async e=>{let t=await A(e,{withFileTypes:!0}),n=[],r=[];return await Promise.all(t.filter(e=>J(e)&&Pe.some(t=>e.name.startsWith(t)||!e.name.startsWith(`_`))).map(async t=>{let i=w(e,t.name),a=K(t.name,await Y(i));switch(a){case s:n.push({file:i,id:q++,kind:a});break;case f:r.push({file:i,id:q++,kind:a});break;case h:n.push({file:i,id:q++,kind:a})}})),{layouts:n.toSorted((e,t)=>Number(e.kind===h)-Number(t.kind===h)),proxies:r}},Ie=e=>{let t=/* @__PURE__ */ new Map,n=w(e),r=n.endsWith(`/`)?n:`${n}/`,i=e=>{if(e!==n&&!e.startsWith(r))return Promise.resolve(X);let a=t.get(e);if(a)return a;let o=Promise.all([Fe(e),e===n?Promise.resolve(X):i(w(e,`..`))]).then(([e,t])=>({layouts:[...e.layouts,...t.layouts],proxies:[...e.proxies,...t.proxies]}));return t.set(e,o),o};return e=>i(w(e,`..`))},Le=/\/\(([^/]+)\)(?=\/|$)/g,Re=(e,t)=>{let n=[],r=[],i=t.slice(e.length).replace(/\.[^/.]+$/,``).replace(/\/(?:index|__not-found)$/,``).replaceAll(/\[(\.\.\.)?([^[\]]+)\]/g,(e,t,n)=>(r.push(n),t?`:${n}*`:`:${n}`)).replace(Le,(e,t)=>(n.push(t),``))||`/`;return{groups:n.length>0?n:void 0,params:r,pattern:i}},ze=/* @__PURE__ */ new Set([`API`,o,n]),Be=async(e,t,r)=>{let i=D(`${r.parentPath}/${r.name}`),a=await Y(i),o=K(r.name,a);if(!o||!ze.has(o))return;let s=await e(i),c=o===n,{groups:l=[],params:u,pattern:d}=Re(t,i);return{file:i,groups:l,id:q++,kind:o,layouts:c?s.layouts:void 0,params:u,pattern:d,proxies:c?s.proxies:void 0}},Ve=async(e,n)=>{let r=w(n,e.router??`src/pages`),i=await A(r,{recursive:!0,withFileTypes:!0}),a=Ie(r),o=await Promise.all(i.filter(J).map(async e=>Be(a,r,e))),s=[],c=[];for(let e of o)e&&(m.has(e.kind)&&s.push(e),t.has(e.kind)&&c.push(e));return{notFounds:s,routes:c}},Z=async e=>{if(!e)return{dynamicRoutes:void 0,staticRoutes:void 0};let t={},n={};for(let r of e){let{params:e,pattern:i,...a}=r;e?.length?n[i]=r:t[i]=a}return{dynamicRoutes:n,staticRoutes:t}},He=async e=>{let[{dynamicRoutes:t,staticRoutes:n},{dynamicRoutes:r,staticRoutes:i}]=await Promise.all([Z(e.routes),Z(e.notFounds)]);return{dynamicNotFounds:r,dynamicRoutes:t,staticNotFounds:i,staticRoutes:n}},Ue=(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}},We=(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]??=b(),o=o.s[e];else if(e===`:${r[s]}`)o.p??=b(),o=o.p,s++;else if(e.endsWith(`*`))throw Error(`Catch-all must be last in "${t}".`);else{let n=Ue(e,r,s);if(n.i===s)throw Error(`Params do not match pattern "${t}".`);let i=b();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},Q=(e={})=>{let t=b();for(let[n,r]of Object.entries(e))We(t,n,r);return t},Ge=async(e,t)=>{let n=await Ve(e,t),{dynamicNotFounds:r,dynamicRoutes:i,staticNotFounds:a,staticRoutes:o}=await He(n);return{dynamicNotFounds:Q(r),dynamicRoutes:Q(i),staticNotFounds:a,staticRoutes:o}},Ke=(e,t)=>{let n=/* @__PURE__ */ new Map,i=e=>{let t=D(e.file),r=n.get(t);return r||(r=`load${n.size}`,n.set(t,r)),r},a=JSON.stringify(e,(e,t)=>{if(!t||typeof t.file!=`string`)return t;let n=i(t),a={__wrenCode:n};if(r.includes(t.kind))return a;let o=(t.layouts??[]).map(i).join(`, `),s=(t.proxies??[]).map(i).join(`, `);return{kind:t.kind,layouts:t.layouts,module:a,params:t.params,pattern:t.pattern,proxies:t.proxies,stack:{__wrenCode:`createStack(${n}, [${o}], [${s}])`}}}).replace(/\{"__wrenCode":"([^"]+)"\}/g,`$1`),o=[...n].map(([e,n])=>{let r=`() => import(${JSON.stringify(e)})`;return`const ${n} = ${t?`memoize(${r})`:r};`});return`
|
|
8
|
+
${t?`function memoize(load) {
|
|
9
|
+
let pending;
|
|
10
|
+
return () => {
|
|
11
|
+
pending ??= load().catch((error) => {
|
|
12
|
+
pending = undefined;
|
|
13
|
+
throw error;
|
|
14
|
+
});
|
|
15
|
+
return pending;
|
|
16
|
+
};
|
|
17
|
+
}`:``}
|
|
18
|
+
|
|
19
|
+
// Resolves a route's module, layouts, and proxies together; once loaded, returns
|
|
20
|
+
// the same object synchronously so requests skip the promise machinery.
|
|
21
|
+
function createStack(load, layouts, proxies) {
|
|
22
|
+
let resolved;
|
|
23
|
+
return () =>
|
|
24
|
+
resolved ??
|
|
25
|
+
Promise.all([
|
|
26
|
+
load(),
|
|
27
|
+
Promise.all(layouts.map((load) => load())),
|
|
28
|
+
Promise.all(proxies.map((load) => load())),
|
|
29
|
+
]).then(([module, layouts, proxies]) => {
|
|
30
|
+
const stack = { layouts, module, proxies };
|
|
31
|
+
${t?`resolved = stack;`:``}
|
|
32
|
+
return stack;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
${o.join(`
|
|
37
|
+
`)}
|
|
38
|
+
|
|
39
|
+
function deepFreeze(value) {
|
|
40
|
+
if (value && typeof value === "object" && !Object.isFrozen(value)) {
|
|
41
|
+
Object.values(value).forEach(deepFreeze);
|
|
42
|
+
Object.freeze(value);
|
|
43
|
+
}
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const manifest = deepFreeze(${a});
|
|
48
|
+
export const { dynamicNotFounds, dynamicRoutes, staticNotFounds, staticRoutes } = manifest;
|
|
49
|
+
export default manifest;
|
|
50
|
+
`},$=`virtual:${e}-routes`,qe=[`\0${$}`],Je=(e,t,n)=>{let r=!1,i=D(w(e.config.root,t.router));if(D(n).startsWith(`${i}/`)){for(let t of Object.values(e.environments))for(let e of qe){let n=t.moduleGraph.getModuleById(e);n&&(r=!0,t.moduleGraph.invalidateModule(n))}r&&e.ws.send({type:`full-reload`})}},Ye=async(e,t,n=!0)=>Ke(await Ge(e,t),n),Xe=(t,n)=>{let r=typeof n.router==`string`,i=t.command===`build`;return{async buildApp(e){if(!n.integrations||n.integrations?.length===0){let t=await Ye(n,e.config.root,i);console.debug(`Generated route manifest:`),console.debug(t)}},async configureServer(e){let t=r?t=>Je(e,n,t):e=>void 0;e.watcher.on(`add`,t),e.watcher.on(`change`,t),e.watcher.on(`unlink`,t)},async load(e){return qe.includes(e)?Ye(n,this.environment.config.root,i):null},name:`${e}-route-manifest`,resolveId(e){return e===$?`\0${e}`:null}}},Ze=async(t,n)=>{let r=fe({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:n},name:`${e}-config`},Xe(t,n),Ae(n.router),Me(t,n)],resolve:{noExternal:[/^@wren-js\//],tsconfigPaths:!0}}),i=await Promise.all([n.adapter,...n.integrations??[]].map(async e=>e?.viteConfig(n,t))),a=r;for(let e of i)e&&(a=E(a,e));return a},Qe=async t=>{let n=ge(),r=ne.map(e=>D(w(n,`wren.config.${e}`))),i=r.find(e=>re(e)),a=i?await pe(t,i):null,o=/* @__PURE__ */ new Set([...r,...(a?.dependencies??[]).map(e=>D(w(e)))]),s=a?E(v,a.config):v,c=E(await Ze(t,s),s.vite??{});return{...c,configFile:!1,mode:t.mode,plugins:[...c.plugins??[],{apply:`serve`,configResolved(e){e.configFileDependencies.push(...o)},configureServer(e){let n=e.restart.bind(e),r;e.restart=i=>(r??=(async()=>{let r=await Qe(t),{inlineConfig:a}=e.config;for(let e of Object.keys(a))Reflect.deleteProperty(a,e);Object.assign(a,r),await n(i)})().finally(()=>{r=void 0}),r)},name:`${e}-config-reload`}]}},$e=async t=>{t.mode=t.command===`build`?`production`:T.env.NODE_ENV??`development`;let n=await Qe(t);if(t.command===`serve`){let t=await de(n);return await t.listen(),console.info(`${e} v${p}`),t.printUrls(),t.bindCLIShortcuts({print:!0}),t}return t.command===`build`?(await ue(n)).buildApp():Promise.resolve()},et=ce({allowPositionals:!0,args:T.argv,options:{help:{short:`h`,type:`boolean`},version:{short:`v`,type:`boolean`}}}).positionals[2];$e({command:et===`build`?`build`:`serve`,mode:T.env.NODE_ENV??`production`}).catch(e=>{console.error(e),T.exit(1)});export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,i as t,o as n,r,t as i}from"../../constants-B7Wo9Ox0.mjs";import{kind as a,render as o}from"virtual:wrenjs-link-client";const s=`__wrenNavigation`,c=e=>{if(typeof e!=`object`||!e||!(s in e))return;let t=e[s];if(typeof t==`object`&&t&&`x`in t&&`y`in t)return typeof t.x==`number`&&typeof t.y==`number`?{x:t.x,y:t.y}:void 0},l=e=>{let t=e.getAttribute(`href`),n=e.getAttribute(`target`);if(!t||e.hasAttribute(`download`)||n&&n!==`_self`||!URL.canParse(t,document.baseURI))return;let r=new URL(t,document.baseURI);if(r.origin===location.origin&&(r.pathname!==location.pathname||r.search!==location.search))return r},u=(e,t)=>{let n=document.createElement(`a`);for(let t of[`href`,`target`,`download`,`rel`]){let r=e.getAttribute(t);r!==null&&n.setAttribute(t,r)}(t.button===1||t.metaKey||t.ctrlKey||t.shiftKey)&&(n.target=`_blank`),document.body.append(n),n.click(),n.remove()},d=e=>{try{return decodeURIComponent(e.slice(1))}catch{return e.slice(1)}},f=(e,t)=>{if(t){scrollTo(t.x,t.y);return}let n=e.hash?document.getElementById(d(e.hash)):null;n?n.scrollIntoView():scrollTo(0,0);let r=n??document.querySelector(`main`)??document.body;r.hasAttribute(`tabindex`)||(r.tabIndex=-1),r.focus({preventScroll:!0})},p=e=>{e.key!==`Enter`||e.defaultPrevented||e.target instanceof HTMLElement&&e.target.matches(`wren-link[href]`)&&e.target.click()},m=e=>{let t=t=>{if(t.defaultPrevented||t.button>1||!(t.target instanceof Element))return;let n=t.target.closest(`wren-link[href]`);if(!n||t.target.closest(`a, button, input, select, textarea`))return;t.preventDefault();let r=l(n),i=t.button===0&&!t.metaKey&&!t.ctrlKey&&!t.altKey&&!t.shiftKey;e&&r&&i?e(r):u(n,t)};window.addEventListener(`click`,t),window.addEventListener(`auxclick`,t),window.addEventListener(`keydown`,p)},h=()=>{let e=history.state,t=typeof e==`object`&&e?e:{};history.replaceState({...t,[s]:{x:scrollX,y:scrollY}},``)},g=e=>{let t=new URL(location.href),n,r,i=!1,a=async(r,i)=>{n?.abort(),n=new AbortController;let{signal:a}=n;try{if(await e(r,a),a.aborted)return;i||history.pushState({[s]:{x:0,y:0}},``,r),t=r,f(r,i)}catch(e){if(a.aborted)return;console.error(`[wrenjs] Client navigation failed; using browser navigation.`,e),i?location.reload():location.assign(r.href)}};m(e=>{i=!0,history.scrollRestoration=`manual`,h(),a(e)}),window.addEventListener(`popstate`,e=>{if(!i)return;let r=new URL(location.href),o=c(e.state);r.pathname===t.pathname&&r.search===t.search?(n?.abort(),f(r,o)):o?a(r,o):location.reload()}),window.addEventListener(`scroll`,()=>{r??=requestAnimationFrame(()=>{r=void 0,i&&h()})},{passive:!0})};function _(n,a){let o=new URL(n);o.pathname+=e,o.hash=``;let s=new Headers({[i]:r});return a&&s.set(t,a.id),new Request(o,{body:a?.body,headers:s,method:a?`POST`:`GET`})}const v=`data-prefetch`,y={"":!0,false:!1,hover:`hover`,"on-load":`on-load`,true:!0,visible:`visible`},b=/* @__PURE__ */ new Map,x=/* @__PURE__ */ new Set,S=()=>{let{connection:e,onLine:t}=navigator;return t&&!e?.saveData&&!e?.effectiveType?.includes(`2g`)},C=e=>{let t=new URL(e);return t.hash=``,t.href},w=e=>{b.get(e)?.controller.abort(),b.delete(e)},T=()=>{for(let e of b.keys())w(e)},E=async(e,t)=>{let n=await fetch(_(e),{signal:t});if(n.redirected||!n.ok&&n.status!==404||!n.headers.get(`content-type`)?.startsWith(`text/x-component`))throw await n.body?.cancel(),Error(`Invalid Flight response for ${e} (${n.status}).`);return n},D=e=>{let t=Date.now();for(let[e,n]of b)t-n.created>=3e4&&w(e);let n=b.get(e);if(n)return n;b.size>=20&&w(b.keys().next().value);let r=new AbortController,i={controller:r,created:t,response:E(e,r.signal)};return b.set(e,i),i.response.catch(()=>{b.get(e)===i&&b.delete(e)}),i},O=async e=>{let t=S()?l(e):void 0;if(!t)return;let n=C(t);if(a===`flight`)await D(n).response;else if(a===`document`&&!x.has(n)){x.add(n);let e=document.createElement(`link`);e.rel=`prefetch`,e.as=`document`,e.href=n,document.head.append(e)}};var k=class extends HTMLElement{static observedAttributes=[v,`href`];get prefetch(){let e=this.getAttribute(v);return e===null?`hover`:Object.hasOwn(y,e)?y[e]:(console.warn(`[wrenjs] Invalid Link prefetch mode:`,e),!1)}#e;#t;#n;attributeChangedCallback(){this.isConnected&&this.#s()}connectedCallback(){this.#e=new AbortController;let{signal:e}=this.#e;this.addEventListener(`mouseenter`,this.#i,{signal:e}),this.addEventListener(`focus`,this.#i,{signal:e}),this.addEventListener(`mouseleave`,this.#a,{signal:e}),this.addEventListener(`blur`,this.#a,{signal:e}),this.#s()}disconnectedCallback(){this.#r(),this.#e?.abort()}#r(){this.#a(),this.#n?.disconnect(),this.#n=void 0}#i=()=>{this.#a(),(this.prefetch===!0||this.prefetch===`hover`)&&(this.#t=setTimeout(()=>this.#o(),80))};#a=()=>{clearTimeout(this.#t),this.#t=void 0};#o(){O(this).catch(e=>{e instanceof DOMException&&e.name===`AbortError`||console.error(`[wrenjs] Unable to prefetch Link.`,e)})}#s(){this.#r(),this.hasAttribute(`href`)&&(this.hasAttribute(`role`)||this.setAttribute(`role`,`link`),this.hasAttribute(`tabindex`)||(this.tabIndex=0),this.prefetch===`on-load`?this.#o():this.prefetch===`visible`&&(this.#n=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(this.#n?.disconnect(),this.#o())}),this.#n.observe(this)))}};customElements.get(`wren-link`)||(document.head.insertAdjacentHTML(`beforeend`,`<style>:where(wren-link[href]){color:inherit;cursor:pointer}</style>`),customElements.define(`wren-link`,k),window.addEventListener(n,T),a===`flight`?g(async(e,t)=>{let n=C(e),r=D(n);b.delete(n),t.addEventListener(`abort`,()=>r.controller.abort(),{once:!0});let i=await r.response;t.throwIfAborted(),await o(i,t)}):m());export{};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { ConfigEnv, UserConfig } from "vite";
|
|
2
|
+
//#region src/entry/config/types.d.ts
|
|
3
|
+
interface WrenAdapter {
|
|
4
|
+
name: string;
|
|
5
|
+
viteConfig(config: WrenConfig, env: ConfigEnv): Promise<UserConfig> | UserConfig;
|
|
6
|
+
}
|
|
7
|
+
interface WrenConfig {
|
|
8
|
+
/**
|
|
9
|
+
* Hosting adapter plugins that hook into the Vite build pipeline.
|
|
10
|
+
*
|
|
11
|
+
* Each adapter is a standard Vite `Plugin` and can use any Vite plugin hooks
|
|
12
|
+
* to generate platform-specific output during `wren build`.
|
|
13
|
+
*
|
|
14
|
+
* The adapter receives the resolved `WrenConfig`.
|
|
15
|
+
*
|
|
16
|
+
* If no adapters are specified, Wren's default build output remains unchanged.
|
|
17
|
+
*
|
|
18
|
+
* @default undefined
|
|
19
|
+
*/
|
|
20
|
+
adapter?: WrenAdapter;
|
|
21
|
+
/**
|
|
22
|
+
* Configuration options related to the build output.
|
|
23
|
+
*/
|
|
24
|
+
build?: {
|
|
25
|
+
/**
|
|
26
|
+
* If client CSS assets should be inlined into the per-route HTML for prerendered and SSR output.
|
|
27
|
+
*
|
|
28
|
+
* | Value | Behavior |
|
|
29
|
+
* | :---: | :--- |
|
|
30
|
+
* | `true` | Inline all CSS assets. |
|
|
31
|
+
* | `false` | Do not inline any CSS assets. |
|
|
32
|
+
* | `number` | Inline assets smaller than the specified size in bytes. |
|
|
33
|
+
*
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
inlineCSS?: boolean | number;
|
|
37
|
+
/**
|
|
38
|
+
* If client JS assets should be inlined into the per-route HTML for prerendered and SSR output.
|
|
39
|
+
*
|
|
40
|
+
* | Value | Behavior |
|
|
41
|
+
* | :---: | :--- |
|
|
42
|
+
* | `true` | Inline all JS assets. |
|
|
43
|
+
* | `false` | Do not inline any JS assets. |
|
|
44
|
+
* | `number` | Inline assets smaller than the specified size in bytes. |
|
|
45
|
+
*
|
|
46
|
+
* @default false
|
|
47
|
+
*/
|
|
48
|
+
inlineJS?: boolean | number;
|
|
49
|
+
/**
|
|
50
|
+
* Defines the output format for the build.
|
|
51
|
+
*
|
|
52
|
+
* | Value | Behavior |
|
|
53
|
+
* | :---: | :--- |
|
|
54
|
+
* | `static` | Output a static site with prerendered assets for each route. Intended for deployment to static hosting. |
|
|
55
|
+
* | `server` | Output a server-rendered application. Intended for deployment to a host which supports execution of server-side code. Note that `output: "server"` can still have static routes and assets. |
|
|
56
|
+
*
|
|
57
|
+
* @default "server"
|
|
58
|
+
*/
|
|
59
|
+
output?: "server" | "static";
|
|
60
|
+
prerender?: {
|
|
61
|
+
/** Origin used by build-time requests; no HTTP server is started. */
|
|
62
|
+
origin?: string;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Rendering integrations used by the application.
|
|
67
|
+
*
|
|
68
|
+
* Integrations contribute framework-specific Vite environments, runtime
|
|
69
|
+
* entries, and plugins.
|
|
70
|
+
*
|
|
71
|
+
* @default undefined
|
|
72
|
+
*/
|
|
73
|
+
integrations?: WrenIntegration[];
|
|
74
|
+
/**
|
|
75
|
+
* Defines the routing strategy used by the application.
|
|
76
|
+
*
|
|
77
|
+
* | Value | Behavior |
|
|
78
|
+
* | :---: | :--- |
|
|
79
|
+
* | `string` | Use a file-based routing strategy where routes are determined by the file structure, at the specified directory. |
|
|
80
|
+
* | `() => Config` | Use a code-based routing strategy where routes are determined programmatically. |
|
|
81
|
+
*
|
|
82
|
+
* @default "src/pages"
|
|
83
|
+
*/
|
|
84
|
+
router?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Allows you to provide custom Vite configuration options. These options will be merged with wren's vite configuration, with these options taking precedence in case of conflicts.
|
|
87
|
+
* @default undefined
|
|
88
|
+
* @see https://vitejs.dev/config/ for more details on Vite configuration options.
|
|
89
|
+
*/
|
|
90
|
+
vite?: UserConfig;
|
|
91
|
+
}
|
|
92
|
+
interface WrenIntegration {
|
|
93
|
+
name: string;
|
|
94
|
+
/** Server entry exporting the framework-neutral PrerenderRuntime contract. */
|
|
95
|
+
prerender?: {
|
|
96
|
+
entry: string;
|
|
97
|
+
environment: string;
|
|
98
|
+
};
|
|
99
|
+
viteConfig(config: WrenConfig, env: ConfigEnv): Promise<UserConfig> | UserConfig;
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/entry/config/index.d.ts
|
|
103
|
+
export declare const CONFIG_VALID_EXTENSIONS: readonly ["ts", "mts", "js", "mjs"];
|
|
104
|
+
export declare function defineConfig(config?: WrenConfig): WrenConfig;
|
|
105
|
+
export declare const DEFAULTS: WrenConfig;
|
|
106
|
+
//#endregion
|
|
107
|
+
export {};
|
package/dist/config.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=[`ts`,`mts`,`js`,`mjs`];function t(e={}){return e}const n={build:{output:`server`},router:`src/pages`};export{e as CONFIG_VALID_EXTENSIONS,n as DEFAULTS,t as defineConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=`Accept`,t=`text/x-component;charset=utf-8`,n=`_.flt`,r=`x-server-action`,i=`wrenjs:invalidate-prefetch`,a=`virtual:wrenjs-script-url:`,o=`virtual:wrenjs-hoist:`,s=`__wrenScripts`,c=/\.([cm]?[jt]sx?|astro|svelte|tsrx)$/;export{n as a,a as c,r as i,c as l,s as n,i as o,t as r,o as s,e as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./constants-B7Wo9Ox0.mjs";var e=`0.1.3`;const t=`wrenjs`,n=e,r=`ROOT`,i=`PAGE`,a=`API`,o=`NOT_FOUND`,s=`LAYOUT`,c=`PROXY`,l=[r,s,c],u=`___root`,d=`___root`,f=`__layout`,p=`__not-found`,m=`__proxy`,h=`GET`,g=`DELETE`,_=`HEAD`,v=`OPTIONS`,y=`PATCH`,b=`POST`,x=`PUT`,S=[`GET`,g,_,v,y,b,`PUT`],C=/* @__PURE__ */ new Set([`API`,i]),w=/* @__PURE__ */ new Set([o]);export{t as C,C as S,i as _,v as a,l as b,x as c,m as d,u as f,o as g,s as h,_ as i,f as l,a as m,g as n,y as o,d as p,h as r,b as s,S as t,p as u,c as v,n as w,w as x,r as y};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
//#region src/virtual-wrenjs-fetch.d.ts
|
|
3
|
+
declare module "virtual:wrenjs-fetch" {
|
|
4
|
+
export type RequestInput = Request | {
|
|
5
|
+
headers: Pick<Headers, "get">;
|
|
6
|
+
method: string;
|
|
7
|
+
toRequest(): Request;
|
|
8
|
+
url: string;
|
|
9
|
+
};
|
|
10
|
+
export const fetch: (request: RequestInput) => Promise<Response>;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/virtual-wrenjs-island-script.d.ts
|
|
14
|
+
declare module "virtual:wrenjs-island-script" {
|
|
15
|
+
const url: string;
|
|
16
|
+
export default url;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/virtual-wrenjs-link-client.d.ts
|
|
20
|
+
declare module "virtual:wrenjs-link-client" {
|
|
21
|
+
export const kind: "document" | "flight" | "native";
|
|
22
|
+
export function render(response: Response, signal: AbortSignal): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
declare module "virtual:wrenjs-link-script" {
|
|
25
|
+
const url: string;
|
|
26
|
+
export default url;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/virtual-wrenjs-page-scripts.d.ts
|
|
30
|
+
declare module "virtual:wrenjs-page-scripts" {
|
|
31
|
+
const scripts: string[];
|
|
32
|
+
export default scripts;
|
|
33
|
+
}
|
|
34
|
+
declare module "virtual:wrenjs-hoist:*" {}
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/virtual-wrenjs-routes.d.ts
|
|
37
|
+
declare module "virtual:wrenjs-routes" {
|
|
38
|
+
export type Entry = RouteEntry;
|
|
39
|
+
export type RadixTrie = RadixTrie$1<Entry>;
|
|
40
|
+
export const dynamicNotFounds: RadixTrie;
|
|
41
|
+
export const dynamicRoutes: RadixTrie;
|
|
42
|
+
export const staticNotFounds: Record<string, Entry> | undefined;
|
|
43
|
+
export const staticRoutes: Record<string, Entry> | undefined;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/types.d.ts
|
|
47
|
+
interface Entry$1 {
|
|
48
|
+
file: string;
|
|
49
|
+
groups?: string[];
|
|
50
|
+
id: number;
|
|
51
|
+
kind: EntryKind;
|
|
52
|
+
layouts?: Entry$1[];
|
|
53
|
+
params?: string[];
|
|
54
|
+
pattern?: string;
|
|
55
|
+
proxies?: Entry$1[];
|
|
56
|
+
}
|
|
57
|
+
type EntryKind = typeof ENTRY_KIND_API | typeof ENTRY_KIND_LAYOUT | typeof ENTRY_KIND_NOT_FOUND | typeof ENTRY_KIND_PAGE | typeof ENTRY_KIND_PROXY | typeof ENTRY_KIND_ROOT;
|
|
58
|
+
interface RadixTrie$1<Route = Entry$1> {
|
|
59
|
+
e?: Route;
|
|
60
|
+
m?: {
|
|
61
|
+
lits: string[];
|
|
62
|
+
node: RadixTrie$1<Route>;
|
|
63
|
+
}[];
|
|
64
|
+
p?: RadixTrie$1<Route>;
|
|
65
|
+
s: Record<string, RadixTrie$1<Route>>;
|
|
66
|
+
w?: Route;
|
|
67
|
+
}
|
|
68
|
+
interface RouteConfig {
|
|
69
|
+
prerender?: boolean;
|
|
70
|
+
}
|
|
71
|
+
interface RouteEntry {
|
|
72
|
+
kind: RouteStack["kind"];
|
|
73
|
+
layouts?: (() => Promise<RouteModule>)[];
|
|
74
|
+
module: () => Promise<RouteModule>;
|
|
75
|
+
params?: string[];
|
|
76
|
+
pattern?: string;
|
|
77
|
+
proxies?: (() => Promise<RouteModule>)[];
|
|
78
|
+
stack: () => Promise<RouteStackModules> | RouteStackModules;
|
|
79
|
+
}
|
|
80
|
+
type RouteLoader<TDefault = unknown> = ({ params, request }: RouteLoaderParams) => Promise<TDefault>;
|
|
81
|
+
interface RouteLoaderParams {
|
|
82
|
+
params?: Record<string, string>;
|
|
83
|
+
request: Request;
|
|
84
|
+
}
|
|
85
|
+
interface RouteModule<TDefault = unknown, THandler = unknown> {
|
|
86
|
+
config?: RouteConfig;
|
|
87
|
+
default: TDefault;
|
|
88
|
+
DELETE?: THandler;
|
|
89
|
+
GET?: THandler;
|
|
90
|
+
getStaticPaths?: () => Promise<string[]> | string[];
|
|
91
|
+
loader?: RouteLoader<TDefault>;
|
|
92
|
+
PATCH?: THandler;
|
|
93
|
+
POST?: THandler;
|
|
94
|
+
PUT?: THandler;
|
|
95
|
+
}
|
|
96
|
+
interface RouteStack<TModule extends RouteModule = RouteModule, TLayout extends RouteModule = RouteModule, TProxy extends RouteModule = RouteModule> {
|
|
97
|
+
kind: "API" | "NOT_FOUND" | "PAGE";
|
|
98
|
+
layouts?: TLayout[];
|
|
99
|
+
module: TModule;
|
|
100
|
+
params: Record<string, string>;
|
|
101
|
+
proxies?: TProxy[];
|
|
102
|
+
}
|
|
103
|
+
type RouteStackModules = Pick<Required<RouteStack>, "layouts" | "module" | "proxies">;
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region ../_shared/constants.d.ts
|
|
106
|
+
declare const ROUTE_MODULE_RE: RegExp;
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/constants.d.ts
|
|
109
|
+
declare const WREN_NAME = "wrenjs";
|
|
110
|
+
declare const WREN_VERSION: string;
|
|
111
|
+
declare const ENTRY_KIND_ROOT = "ROOT";
|
|
112
|
+
declare const ENTRY_KIND_PAGE = "PAGE";
|
|
113
|
+
declare const ENTRY_KIND_API = "API";
|
|
114
|
+
declare const ENTRY_KIND_NOT_FOUND = "NOT_FOUND";
|
|
115
|
+
declare const ENTRY_KIND_LAYOUT = "LAYOUT";
|
|
116
|
+
declare const ENTRY_KIND_PROXY = "PROXY";
|
|
117
|
+
declare const ENTRY_WRAPPER_TYPES: readonly ["ROOT", "LAYOUT", "PROXY"];
|
|
118
|
+
declare const ENTRY_FILEROUTE_ROOT = "___root";
|
|
119
|
+
declare const ENTRY_FILEROUTE_ROOT_LAYOUT = "___root";
|
|
120
|
+
declare const ENTRY_FILEROUTE_LAYOUT = "__layout";
|
|
121
|
+
declare const ENTRY_FILEROUTE_NOT_FOUND = "__not-found";
|
|
122
|
+
declare const ENTRY_FILEROUTE_PROXY = "__proxy";
|
|
123
|
+
declare const ENTRY_FILEROUTE_API_EXPORT_GET = "GET";
|
|
124
|
+
declare const ENTRY_FILEROUTE_API_EXPORT_DELETE = "DELETE";
|
|
125
|
+
declare const ENTRY_FILEROUTE_API_EXPORT_HEAD = "HEAD";
|
|
126
|
+
declare const ENTRY_FILEROUTE_API_EXPORT_OPTIONS = "OPTIONS";
|
|
127
|
+
declare const ENTRY_FILEROUTE_API_EXPORT_PATCH = "PATCH";
|
|
128
|
+
declare const ENTRY_FILEROUTE_API_EXPORT_POST = "POST";
|
|
129
|
+
declare const ENTRY_FILEROUTE_API_EXPORT_PUT = "PUT";
|
|
130
|
+
declare const ENTRY_API_EXPORTS: readonly ["GET", "DELETE", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"];
|
|
131
|
+
declare const ROUTE_ENTRIES: ReadonlySet<EntryKind>;
|
|
132
|
+
declare const FALLBACK_ENTRIES: ReadonlySet<EntryKind>;
|
|
133
|
+
//#endregion
|
|
134
|
+
export { WREN_NAME as C, RouteEntry as D, RadixTrie$1 as E, RouteModule as O, ROUTE_ENTRIES as S, ROUTE_MODULE_RE as T, ENTRY_KIND_PAGE as _, ENTRY_FILEROUTE_API_EXPORT_OPTIONS as a, ENTRY_WRAPPER_TYPES as b, ENTRY_FILEROUTE_API_EXPORT_PUT as c, ENTRY_FILEROUTE_PROXY as d, ENTRY_FILEROUTE_ROOT as f, ENTRY_KIND_NOT_FOUND as g, ENTRY_KIND_LAYOUT as h, ENTRY_FILEROUTE_API_EXPORT_HEAD as i, RouteStack as k, ENTRY_FILEROUTE_LAYOUT as l, ENTRY_KIND_API as m, ENTRY_FILEROUTE_API_EXPORT_DELETE as n, ENTRY_FILEROUTE_API_EXPORT_PATCH as o, ENTRY_FILEROUTE_ROOT_LAYOUT as p, ENTRY_FILEROUTE_API_EXPORT_GET as r, ENTRY_FILEROUTE_API_EXPORT_POST as s, ENTRY_API_EXPORTS as t, ENTRY_FILEROUTE_NOT_FOUND as u, ENTRY_KIND_PROXY as v, WREN_VERSION as w, FALLBACK_ENTRIES as x, ENTRY_KIND_ROOT as y };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { C as WREN_NAME, S as ROUTE_ENTRIES, T as ROUTE_MODULE_RE, _ as ENTRY_KIND_PAGE, a as ENTRY_FILEROUTE_API_EXPORT_OPTIONS, b as ENTRY_WRAPPER_TYPES, c as ENTRY_FILEROUTE_API_EXPORT_PUT, d as ENTRY_FILEROUTE_PROXY, f as ENTRY_FILEROUTE_ROOT, g as ENTRY_KIND_NOT_FOUND, h as ENTRY_KIND_LAYOUT, i as ENTRY_FILEROUTE_API_EXPORT_HEAD, l as ENTRY_FILEROUTE_LAYOUT, m as ENTRY_KIND_API, n as ENTRY_FILEROUTE_API_EXPORT_DELETE, o as ENTRY_FILEROUTE_API_EXPORT_PATCH, p as ENTRY_FILEROUTE_ROOT_LAYOUT, r as ENTRY_FILEROUTE_API_EXPORT_GET, s as ENTRY_FILEROUTE_API_EXPORT_POST, t as ENTRY_API_EXPORTS, u as ENTRY_FILEROUTE_NOT_FOUND, v as ENTRY_KIND_PROXY, w as WREN_VERSION, x as FALLBACK_ENTRIES, y as ENTRY_KIND_ROOT } from "./constants-CstgyYjd.mjs";
|
|
2
|
+
export { ENTRY_API_EXPORTS, ENTRY_FILEROUTE_API_EXPORT_DELETE, ENTRY_FILEROUTE_API_EXPORT_GET, ENTRY_FILEROUTE_API_EXPORT_HEAD, ENTRY_FILEROUTE_API_EXPORT_OPTIONS, ENTRY_FILEROUTE_API_EXPORT_PATCH, ENTRY_FILEROUTE_API_EXPORT_POST, ENTRY_FILEROUTE_API_EXPORT_PUT, ENTRY_FILEROUTE_LAYOUT, ENTRY_FILEROUTE_NOT_FOUND, ENTRY_FILEROUTE_PROXY, ENTRY_FILEROUTE_ROOT, ENTRY_FILEROUTE_ROOT_LAYOUT, ENTRY_KIND_API, ENTRY_KIND_LAYOUT, ENTRY_KIND_NOT_FOUND, ENTRY_KIND_PAGE, ENTRY_KIND_PROXY, ENTRY_KIND_ROOT, ENTRY_WRAPPER_TYPES, FALLBACK_ENTRIES, ROUTE_ENTRIES, ROUTE_MODULE_RE, WREN_NAME, WREN_VERSION };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,S as t,_ as n,a as r,b as i,c as a,d as o,f as s,g as c,h as l,i as u,l as d,m as f,n as p,o as m,p as h,r as g,s as _,t as v,u as y,v as b,w as x,x as S,y as C}from"./constants-CQI5U_DU.mjs";import{l as w}from"./constants-B7Wo9Ox0.mjs";export{v as ENTRY_API_EXPORTS,p as ENTRY_FILEROUTE_API_EXPORT_DELETE,g as ENTRY_FILEROUTE_API_EXPORT_GET,u as ENTRY_FILEROUTE_API_EXPORT_HEAD,r as ENTRY_FILEROUTE_API_EXPORT_OPTIONS,m as ENTRY_FILEROUTE_API_EXPORT_PATCH,_ as ENTRY_FILEROUTE_API_EXPORT_POST,a as ENTRY_FILEROUTE_API_EXPORT_PUT,d as ENTRY_FILEROUTE_LAYOUT,y as ENTRY_FILEROUTE_NOT_FOUND,o as ENTRY_FILEROUTE_PROXY,s as ENTRY_FILEROUTE_ROOT,h as ENTRY_FILEROUTE_ROOT_LAYOUT,f as ENTRY_KIND_API,l as ENTRY_KIND_LAYOUT,c as ENTRY_KIND_NOT_FOUND,n as ENTRY_KIND_PAGE,b as ENTRY_KIND_PROXY,C as ENTRY_KIND_ROOT,i as ENTRY_WRAPPER_TYPES,S as FALLBACK_ENTRIES,t as ROUTE_ENTRIES,w as ROUTE_MODULE_RE,e as WREN_NAME,x as WREN_VERSION};
|
package/dist/link.d.mts
ADDED
package/dist/link.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"virtual:wrenjs-hoist:virtual:wrenjs-link-script";const e=`wren-link`;export{e as default};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { D as RouteEntry, E as RadixTrie } from "../constants-CstgyYjd.mjs";
|
|
2
|
+
//#region src/runtime/prerender/index.d.ts
|
|
3
|
+
export declare const getPrerenderPaths: (manifest: {
|
|
4
|
+
dynamicRoutes: RadixTrie<RouteEntry>;
|
|
5
|
+
staticRoutes?: Record<string, RouteEntry>;
|
|
6
|
+
}, prerenderAll?: boolean) => Promise<string[]>;
|
|
7
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"../utils-0wezGh38.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};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { O as RouteModule, k as RouteStack } from "../constants-CstgyYjd.mjs";
|
|
2
|
+
//#region src/runtime/router/index.d.ts
|
|
3
|
+
export declare function matchRouteToStack<T extends RouteStack = RouteStack>(path?: string): Promise<T | undefined> | T | undefined;
|
|
4
|
+
//#endregion
|
|
5
|
+
export type { RouteModule, RouteStack };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"../utils-0wezGh38.mjs";import{n as t}from"../trie-lookup-BLa5NWBJ.mjs";import{dynamicNotFounds as n,dynamicRoutes as r,staticNotFounds as i,staticRoutes as a}from"virtual:wrenjs-routes";function o(o){let s=e(o);if(!s)return;let c=[],l=a?.[s]??t(r,s,c)??i?.[s]??t(n,s,c);if(!l)return;let u=l.params?.length?Object.fromEntries(l.params.map((e,t)=>[e,c[t]])):{},d=({layouts:e,module:t,proxies:n})=>({kind:l.kind,layouts:e,module:t,params:u,proxies:n}),f=l.stack();return f instanceof Promise?f.then(d):d(f)}export{o as matchRouteToStack};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=()=>({s:Object.create(null)}),t=(e,t,n)=>{let r=e.length-1;if(!t.startsWith(e[0])||!t.endsWith(e[r]))return!1;let i=e[0].length;for(let a=1;a<r;a++){let r=t.indexOf(e[a],i+1);if(r<0)return!1;n?.push(t.slice(i,r)),i=r+e[a].length}let a=t.length-e[r].length;return a<=i?!1:(n?.push(t.slice(i,a)),!0)},n=(e,n,i,a,o)=>{let s=o?.length??0;for(let{lits:c,node:l}of e){let e=t(c,n,o)?r(l,i,a,o):void 0;if(e!==void 0)return e;o&&(o.length=s)}},r=(e,t,i,a)=>{if(i>=t.length)return e.e;let o=t.indexOf(`/`,i),s=o<0?t.length:o,c=t.slice(i,s),l=s+1,u=e.s,d=Object.hasOwn(u,c)?r(u[c],t,l,a):void 0;if(d!==void 0)return d;let f=e.m&&n(e.m,c,t,l,a);if(f!==void 0)return f;if(e.p&&c){let n=a?.length??0;a?.push(c);let i=r(e.p,t,l,a);if(i!==void 0)return i;a&&(a.length=n)}return e.w!==void 0&&a?.push(t.slice(i)),e.w},i=(e,t,n)=>r(e,t,1,n);export{i as n,e as t};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"allowJs": true,
|
|
5
|
+
"esModuleInterop": true,
|
|
6
|
+
"lib": ["DOM", "ESNext"],
|
|
7
|
+
"module": "ESNext",
|
|
8
|
+
"moduleResolution": "Bundler",
|
|
9
|
+
"noEmit": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"target": "ESNext",
|
|
13
|
+
"verbatimModuleSyntax": true
|
|
14
|
+
},
|
|
15
|
+
"exclude": ["${configDir}/dist", "${configDir}/node_modules"],
|
|
16
|
+
"files": ["../types.d.ts"],
|
|
17
|
+
"include": ["${configDir}/**/*"]
|
|
18
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"allowUnreachableCode": false,
|
|
5
|
+
"allowUnusedLabels": false,
|
|
6
|
+
"noFallthroughCasesInSwitch": true,
|
|
7
|
+
"noImplicitOverride": true,
|
|
8
|
+
"noImplicitReturns": true,
|
|
9
|
+
"noUncheckedIndexedAccess": true,
|
|
10
|
+
"noUnusedLocals": true,
|
|
11
|
+
"noUnusedParameters": true
|
|
12
|
+
},
|
|
13
|
+
"extends": "./strict.json"
|
|
14
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
|
|
3
|
+
import "./virtual-wrenjs-fetch.d.ts";
|
|
4
|
+
import "./virtual-wrenjs-island-script.d.ts";
|
|
5
|
+
import "./virtual-wrenjs-link-client.d.ts";
|
|
6
|
+
import "./virtual-wrenjs-page-scripts.d.ts";
|
|
7
|
+
import "./virtual-wrenjs-routes.d.ts";
|
|
8
|
+
|
|
9
|
+
export interface Entry {
|
|
10
|
+
file: string;
|
|
11
|
+
|
|
12
|
+
groups?: string[];
|
|
13
|
+
|
|
14
|
+
id: number;
|
|
15
|
+
|
|
16
|
+
kind: EntryKind;
|
|
17
|
+
|
|
18
|
+
layouts?: Entry[];
|
|
19
|
+
|
|
20
|
+
params?: string[];
|
|
21
|
+
|
|
22
|
+
pattern?: string;
|
|
23
|
+
|
|
24
|
+
proxies?: Entry[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
import type {
|
|
28
|
+
ENTRY_KIND_API,
|
|
29
|
+
ENTRY_KIND_LAYOUT,
|
|
30
|
+
ENTRY_KIND_NOT_FOUND,
|
|
31
|
+
ENTRY_KIND_PAGE,
|
|
32
|
+
ENTRY_KIND_PROXY,
|
|
33
|
+
ENTRY_KIND_ROOT,
|
|
34
|
+
} from "./constants.ts";
|
|
35
|
+
|
|
36
|
+
export type EntryKind =
|
|
37
|
+
| typeof ENTRY_KIND_API
|
|
38
|
+
| typeof ENTRY_KIND_LAYOUT
|
|
39
|
+
| typeof ENTRY_KIND_NOT_FOUND
|
|
40
|
+
| typeof ENTRY_KIND_PAGE
|
|
41
|
+
| typeof ENTRY_KIND_PROXY
|
|
42
|
+
| typeof ENTRY_KIND_ROOT;
|
|
43
|
+
|
|
44
|
+
export interface PartitionedRoutes {
|
|
45
|
+
dynamicNotFound?: Entry[];
|
|
46
|
+
dynamicRoutes?: Entry[];
|
|
47
|
+
staticNotFound?: Entry[];
|
|
48
|
+
staticRoutes?: Entry[];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface PrerenderArtifact {
|
|
52
|
+
pathname: string;
|
|
53
|
+
response: Response;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface PrerenderRuntime {
|
|
57
|
+
getPaths(prerenderAll?: boolean): Promise<string[]>;
|
|
58
|
+
render(request: Request): Promise<PrerenderArtifact[]>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface RadixTrie<Route = Entry> {
|
|
62
|
+
e?: Route;
|
|
63
|
+
|
|
64
|
+
m?: { lits: string[]; node: RadixTrie<Route> }[];
|
|
65
|
+
|
|
66
|
+
p?: RadixTrie<Route>;
|
|
67
|
+
|
|
68
|
+
s: Record<string, RadixTrie<Route>>;
|
|
69
|
+
|
|
70
|
+
w?: Route;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface RoutableEntry {
|
|
74
|
+
notFounds?: Entry[];
|
|
75
|
+
routes?: Entry[];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface RouteConfig {
|
|
79
|
+
prerender?: boolean;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface RouteEntry {
|
|
83
|
+
kind: RouteStack["kind"];
|
|
84
|
+
layouts?: (() => Promise<RouteModule>)[];
|
|
85
|
+
module: () => Promise<RouteModule>;
|
|
86
|
+
params?: string[];
|
|
87
|
+
pattern?: string;
|
|
88
|
+
proxies?: (() => Promise<RouteModule>)[];
|
|
89
|
+
|
|
90
|
+
stack: () => Promise<RouteStackModules> | RouteStackModules;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export type RouteLoader<TDefault = unknown> = ({
|
|
94
|
+
params,
|
|
95
|
+
request,
|
|
96
|
+
}: RouteLoaderParams) => Promise<TDefault>;
|
|
97
|
+
|
|
98
|
+
export interface RouteLoaderParams {
|
|
99
|
+
params?: Record<string, string>;
|
|
100
|
+
request: Request;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface RouteModule<TDefault = unknown, THandler = unknown> {
|
|
104
|
+
config?: RouteConfig;
|
|
105
|
+
default: TDefault;
|
|
106
|
+
DELETE?: THandler;
|
|
107
|
+
GET?: THandler;
|
|
108
|
+
|
|
109
|
+
getStaticPaths?: () => Promise<string[]> | string[];
|
|
110
|
+
loader?: RouteLoader<TDefault>;
|
|
111
|
+
PATCH?: THandler;
|
|
112
|
+
POST?: THandler;
|
|
113
|
+
PUT?: THandler;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface RouteStack<
|
|
117
|
+
TModule extends RouteModule = RouteModule,
|
|
118
|
+
TLayout extends RouteModule = RouteModule,
|
|
119
|
+
TProxy extends RouteModule = RouteModule,
|
|
120
|
+
> {
|
|
121
|
+
kind: "API" | "NOT_FOUND" | "PAGE";
|
|
122
|
+
layouts?: TLayout[];
|
|
123
|
+
module: TModule;
|
|
124
|
+
params: Record<string, string>;
|
|
125
|
+
proxies?: TProxy[];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export type RouteStackModules = Pick<Required<RouteStack>, "layouts" | "module" | "proxies">;
|
|
129
|
+
|
|
130
|
+
export type { fetch } from "virtual:wrenjs-fetch";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=e=>{if(!e)return;let t=0,n=e.indexOf(`?`);n===-1&&(n=e.length);let r=e.indexOf(`#`);if(r!==-1&&r<n&&(n=r),e[0]!==`/`){let r=e.indexOf(`://`);if(r!==-1&&r<n){let i=e.indexOf(`/`,r+3);t=i!==-1&&i<n?i:n}}for(;n>t+1&&e[n-1]===`/`;)n--;let i=e.slice(t,n);return i[0]===`/`?i:`/${i}`};export{e as t};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare module "virtual:wrenjs-fetch" {
|
|
2
|
+
export type RequestInput =
|
|
3
|
+
| Request
|
|
4
|
+
| {
|
|
5
|
+
headers: Pick<Headers, "get">;
|
|
6
|
+
method: string;
|
|
7
|
+
toRequest(): Request;
|
|
8
|
+
url: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const fetch: (request: RequestInput) => Promise<Response>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare module "virtual:wrenjs-link-client" {
|
|
2
|
+
export const kind: "document" | "flight" | "native";
|
|
3
|
+
export function render(response: Response, signal: AbortSignal): Promise<void>;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
declare module "virtual:wrenjs-link-script" {
|
|
7
|
+
const url: string;
|
|
8
|
+
export default url;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare module "virtual:wrenjs-routes" {
|
|
2
|
+
export type Entry = import("./types.js").RouteEntry;
|
|
3
|
+
export type RadixTrie = import("./types.js").RadixTrie<Entry>;
|
|
4
|
+
|
|
5
|
+
export const dynamicNotFounds: RadixTrie;
|
|
6
|
+
export const dynamicRoutes: RadixTrie;
|
|
7
|
+
export const staticNotFounds: Record<string, Entry> | undefined;
|
|
8
|
+
export const staticRoutes: Record<string, Entry> | undefined;
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,75 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wren-js/core",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "Framework agnostic utilities for the wrenjs meta-framework",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"@wren-js/core",
|
|
7
|
+
"framework",
|
|
8
|
+
"meta-framework",
|
|
9
|
+
"vite",
|
|
10
|
+
"wren"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://wrenjs.org",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/wrenjs/wrenjs/issues",
|
|
15
|
+
"email": "maintainers@wrenjs.org"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"author": {
|
|
19
|
+
"name": "wrenjs Authors",
|
|
20
|
+
"email": "maintainers@wrenjs.org",
|
|
21
|
+
"url": "https://github.com/wrenjs/wrenjs/AUTHORS.md"
|
|
22
|
+
},
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/wrenjs/wrenjs.git",
|
|
26
|
+
"directory": "packages/core"
|
|
27
|
+
},
|
|
28
|
+
"funding": {
|
|
29
|
+
"type": "github",
|
|
30
|
+
"url": "https://github.com/sponsors/wrenjs"
|
|
31
|
+
},
|
|
32
|
+
"bin": {
|
|
33
|
+
"wren": "./bin/cli.mjs"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"bin",
|
|
37
|
+
"dist"
|
|
38
|
+
],
|
|
39
|
+
"type": "module",
|
|
40
|
+
"imports": {
|
|
41
|
+
"#/*": "./src/*"
|
|
42
|
+
},
|
|
43
|
+
"exports": {
|
|
44
|
+
"./cli": "./dist/cli.mjs",
|
|
45
|
+
"./components/Link/wren-link": "./dist/components/Link/wren-link.mjs",
|
|
46
|
+
"./config": "./dist/config.mjs",
|
|
47
|
+
"./constants": "./dist/constants.mjs",
|
|
48
|
+
"./link": "./dist/link.mjs",
|
|
49
|
+
"./runtime/prerender": "./dist/runtime/prerender.mjs",
|
|
50
|
+
"./runtime/router": "./dist/runtime/router.mjs",
|
|
51
|
+
"./package.json": "./package.json",
|
|
52
|
+
"./tsconfig/*": "./dist/tsconfig/*.json",
|
|
53
|
+
"./tsconfig/*.json": "./dist/tsconfig/*.json",
|
|
54
|
+
"./types": {
|
|
55
|
+
"types": "./dist/types.d.ts"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"access": "public"
|
|
60
|
+
},
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"vite": "8.3.4"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"typescript": "7.0.2",
|
|
66
|
+
"vite-plus": "1.2.0"
|
|
67
|
+
},
|
|
68
|
+
"scripts": {
|
|
69
|
+
"build": "vp pack",
|
|
70
|
+
"check": "vp check",
|
|
71
|
+
"dev": "vp pack --watch",
|
|
72
|
+
"test": "vp test",
|
|
73
|
+
"test:types": "vp run build && tsc --noEmit -p test-dts/tsconfig.json"
|
|
74
|
+
}
|
|
6
75
|
}
|
package/README.md
DELETED