@mapl/web 0.6.5 → 0.6.6

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.
@@ -1 +1 @@
1
- import{exportScope,markExported}from"runtime-compiler";import{isHydrating}from"runtime-compiler/config";import{TMP_SCOPE,initScope,setHandlerArgs}from"../../compilers/globals.js";import{wrapScope}from"../../compilers/scope.js";import{initRouter,insertItem,toRoutes}from"./router.js";let PARAM_MAP;let WILDCARD_PARAM_MAP;let loadToMethodRouter=(router,scope,prefix,content)=>{for(let i=0,layers=router[0];i<layers.length;i++){let self=layers[i];content+=self[0](self,scope)}for(let i=0,routes=router[1];i<routes.length;i++){let route=routes[i];let routeScope=scope.slice();let path=route[1];let routeContent=content;if(path.includes(`*`)){routeContent=`let q=mr.params;`+routeContent;let paramCount=1;if(path.endsWith(`**`)){let newPath=`/*`,endIdx=path.length-3,nextIdx=path.lastIndexOf(`*`,endIdx);while(nextIdx>1){newPath=`:q`+ paramCount+++path.slice(nextIdx+1,endIdx)+newPath;endIdx=nextIdx;nextIdx=path.lastIndexOf(`*`,nextIdx-2)}path=nextIdx>-1?path.slice(0,nextIdx-1)+`:q`+ paramCount+++path.slice(nextIdx+1,endIdx)+newPath:path.slice(0,endIdx)+newPath;for(let j=2,params=WILDCARD_PARAM_MAP[paramCount];j<route.length;j++){let self=route[j];routeContent+=self[0](self,routeScope,params,paramCount)}}else{let nextIdx=path.lastIndexOf(`*`),newPath=`:q0`+path.slice(nextIdx+1),endIdx=nextIdx;nextIdx=path.lastIndexOf(`*`,nextIdx-2);while(nextIdx>1){newPath=`:q`+ paramCount+++path.slice(nextIdx+1,endIdx)+newPath;endIdx=nextIdx;nextIdx=path.lastIndexOf(`*`,nextIdx-2)}path=nextIdx>-1?path.slice(0,nextIdx-1)+`:q`+ paramCount+++path.slice(nextIdx+1,endIdx)+newPath:path.slice(0,endIdx)+newPath;for(let j=2,params=PARAM_MAP[paramCount];j<route.length;j++){let self=route[j];routeContent+=self[0](self,routeScope,params,paramCount)}}}else for(let j=2;j<route.length;j++){let self=route[j];routeContent+=self[0](self,routeScope,``,0)}insertItem(route[0],prefix+path,wrapScope(routeScope,routeContent))}for(let i=2;i<router.length;i++){let childRouter=router[i];loadToMethodRouter(childRouter[1],scope.slice(),childRouter[0]===`/`?prefix:prefix+childRouter[0],content)}};export let _load=router=>{initScope();initRouter();PARAM_MAP=[``,`q.q0`];WILDCARD_PARAM_MAP=[``,`q['*']`];for(let i=1;i<=8;i++){let newParam=`q.q`+i+`,`;PARAM_MAP.push(newParam+PARAM_MAP[i]);WILDCARD_PARAM_MAP.push(newParam+WILDCARD_PARAM_MAP[i])}loadToMethodRouter(router,[0],``,``)};export let loadToString=toRoutes;export let _hydrate=(router,scope)=>{for(let i=0,layers=router[0];i<layers.length;i++){let self=layers[i];self[0](self,scope)}for(let i=0,routes=router[1];i<routes.length;i++){let route=routes[i];let routeScope=scope.slice();let path=route[1];if(path.includes(`*`)){let paramCount=1;{let i=path.lastIndexOf(`*`);if(i>1){i=path.lastIndexOf(`*`,i-2);while(i>1){paramCount++;i=path.lastIndexOf(`*`,i-2)}i>-1&&paramCount++}}for(let j=2,params=PARAM_MAP[paramCount];j<route.length;j++){let self=route[j];self[0](self,routeScope,params,paramCount)}}else for(let j=2;j<route.length;j++){let self=route[j];self[0](self,routeScope,``,0)}}for(let i=2;i<router.length;i++)_hydrate(router[i][1],scope.slice())};export let build=isHydrating?router=>(_hydrate(router,[0]),markExported()):router=>(setHandlerArgs(`(mr,mi)`),_load(router),exportScope(TMP_SCOPE,loadToString()));
1
+ import{exportScope,markExported}from"runtime-compiler";import{isHydrating}from"runtime-compiler/config";import{TMP_SCOPE,initScope,setHandlerArgs}from"../../compilers/globals.js";import{wrapScope}from"../../compilers/scope.js";import{initRouter,insertItem,toRoutes}from"./router.js";let PARAM_MAP;let WILDCARD_PARAM_MAP;let loadToMethodRouter=(router,scope,prefix,content)=>{for(let i=0,layers=router[0];i<layers.length;i++){let self=layers[i];content+=self[0](self,scope)}for(let i=0,routes=router[1];i<routes.length;i++){let route=routes[i];let routeScope=scope.slice();let path=route[1];let routeContent=content;if(path.includes(`*`)){routeContent=`let q=mr.params;`+routeContent;let paramCount=1;if(path.endsWith(`**`)){let newPath=`/*`,endIdx=path.length-3,nextIdx=path.lastIndexOf(`*`,endIdx);while(nextIdx>1){newPath=`:q`+ paramCount+++path.slice(nextIdx+1,endIdx)+newPath;endIdx=nextIdx;nextIdx=path.lastIndexOf(`*`,nextIdx-2)}path=nextIdx>-1?path.slice(0,nextIdx-1)+`:q`+ paramCount+++path.slice(nextIdx+1,endIdx)+newPath:path.slice(0,endIdx)+newPath;for(let j=2,params=WILDCARD_PARAM_MAP[paramCount];j<route.length;j++){let self=route[j];routeContent+=self[0](self,routeScope,params,paramCount)}}else{let nextIdx=path.lastIndexOf(`*`),newPath=`:q0`+path.slice(nextIdx+1),endIdx=nextIdx;nextIdx=path.lastIndexOf(`*`,nextIdx-2);while(nextIdx>1){newPath=`:q`+ paramCount+++path.slice(nextIdx+1,endIdx)+newPath;endIdx=nextIdx;nextIdx=path.lastIndexOf(`*`,nextIdx-2)}path=nextIdx>-1?path.slice(0,nextIdx-1)+`:q`+ paramCount+++path.slice(nextIdx+1,endIdx)+newPath:path.slice(0,endIdx)+newPath;for(let j=2,params=PARAM_MAP[paramCount];j<route.length;j++){let self=route[j];routeContent+=self[0](self,routeScope,params,paramCount)}}}else for(let j=2;j<route.length;j++){let self=route[j];routeContent+=self[0](self,routeScope,``,0)}insertItem(route[0],prefix+path,wrapScope(routeScope,routeContent))}for(let i=2;i<router.length;i++){let childRouter=router[i];loadToMethodRouter(childRouter[1],scope.slice(),childRouter[0]===`/`?prefix:prefix+childRouter[0],content)}};export let _load=router=>{initScope();initRouter();PARAM_MAP=[``,`q.q0`];WILDCARD_PARAM_MAP=[``,`q['*']`];for(let i=1;i<=8;i++){let newParam=`q.q`+i+`,`;PARAM_MAP.push(newParam+PARAM_MAP[i]);WILDCARD_PARAM_MAP.push(newParam+WILDCARD_PARAM_MAP[i])}loadToMethodRouter(router,[0],``,``)};export let loadToString=toRoutes;export let _hydrate=(router,scope)=>{for(let i=0,layers=router[0];i<layers.length;i++){let self=layers[i];self[0](self,scope)}for(let i=0,routes=router[1];i<routes.length;i++){let route=routes[i];let routeScope=scope.slice();let path=route[1];if(path.includes(`*`)){let paramCount=1;{let i=path.lastIndexOf(`*`);if(i>1){i=path.lastIndexOf(`*`,i-2);while(i>1){paramCount++;i=path.lastIndexOf(`*`,i-2)}i>-1&&paramCount++}}for(let j=2;j<route.length;j++){let self=route[j];self[0](self,routeScope,``,paramCount)}}else for(let j=2;j<route.length;j++){let self=route[j];self[0](self,routeScope,``,0)}}for(let i=2;i<router.length;i++)_hydrate(router[i][1],scope.slice())};export let build=isHydrating?router=>(_hydrate(router,[0]),markExported()):router=>(setHandlerArgs(`(mr,mi)`),_load(router),exportScope(TMP_SCOPE,loadToString()));
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@mapl/web","version":"0.6.5","description":"A compiled web framework for all runtimes","keywords":["fast","lightweight","cross-runtime","framework","web","backend"],"repository":{"type":"git","url":"git+https://github.com/mapljs/web.git"},"license":"MIT","type":"module","main":"./index.js","types":"./index.d.ts","dependencies":{"@mapl/router":"^0.8.4","@safe-std/error":"^2.0.4","runtime-compiler":"^3.1.1"},"exports":{"./utils":"./utils.js","./layer":"./layer.js",".":"./index.js","./constants":"./constants.js","./router":"./router.js","./generic":"./generic/index.js","./cloudflare/compiler":"./cloudflare/compiler.js","./response":"./response.js","./deno":"./deno/index.js","./generic/compiler":"./generic/compiler.js","./compilers/scope":"./compilers/scope.js","./compilers/globals":"./compilers/globals.js","./deno/compiler":"./deno/compiler.js","./bun/compiler":"./bun/compiler/index.js","./compilers/call":"./compilers/call.js","./bun":"./bun/index.js","./cloudflare":"./cloudflare/index.js","./bun/compiler/router":"./bun/compiler/router.js"}}
1
+ {"name":"@mapl/web","version":"0.6.6","description":"A compiled web framework for all runtimes","keywords":["fast","lightweight","cross-runtime","framework","web","backend"],"repository":{"type":"git","url":"git+https://github.com/mapljs/web.git"},"license":"MIT","type":"module","main":"./index.js","types":"./index.d.ts","dependencies":{"@mapl/router":"^0.8.4","@safe-std/error":"^2.0.4","runtime-compiler":"^3.1.1"},"exports":{"./utils":"./utils.js","./layer":"./layer.js","./router":"./router.js","./constants":"./constants.js",".":"./index.js","./response":"./response.js","./bun/compiler/router":"./bun/compiler/router.js","./cloudflare/compiler":"./cloudflare/compiler.js","./cloudflare":"./cloudflare/index.js","./bun":"./bun/index.js","./compilers/call":"./compilers/call.js","./bun/compiler":"./bun/compiler/index.js","./deno/compiler":"./deno/compiler.js","./compilers/scope":"./compilers/scope.js","./generic":"./generic/index.js","./deno":"./deno/index.js","./compilers/globals":"./compilers/globals.js","./generic/compiler":"./generic/compiler.js"}}