@mapl/web 0.0.7 → 0.0.8
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/package.json +2 -2
- package/router/compiler.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapl/web",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "A compiled web standard framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fast",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"typescript-eslint": "latest"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@mapl/framework": "^0.0
|
|
37
|
+
"@mapl/framework": "^0.1.0",
|
|
38
38
|
"@mapl/router": "^0.4.13",
|
|
39
39
|
"safe-throw": "^0.0.9"
|
|
40
40
|
}
|
package/router/compiler.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default (router)=>{let baseRouter={};let dependencies=[];compileGroup(router._,[baseRouter,dependencies,"let mh=[],c=mwc(r,mh);",(fn,dat,path,state,scope)=>{let call="f"+state[1].push(fn)+"(";let paramCount=path[0].length;if(paramCount>0)call+=paramArgs[paramCount];if(fn.length>paramCount){call+=paramCount===0?"c":",c";if(!scope[1])return state[2]+compileReturn(state,dat,isFuncAsync(fn),scope[0],true,call+")")}return compileReturn(state,dat,isFuncAsync(fn),scope[0],scope[1],call+")")},(fn,dat,state,scope)=>{let call="f"+state[1].push(fn)+"(t";if(fn.length>1){call+=",c";if(!scope[1])return state[2]+compileReturn(state,dat,isFuncAsync(fn),scope[0],true,call+")")}return compileReturn(state,dat,isFuncAsync(fn),scope[0],scope[1],call+")")},transformRoute],[false,false,null,"return mwb"],"","");return Function("me","mwc",...dependencies.map((_,i)=>"f"+(i+1)),'let [mwh,mwj]=["text/html","application/json"].map(c=>["content-type",c]),[mwn,mwb]=[404,400].map(s=>new Response(null,{status:s}));return(r)=>{'+compile(baseRouter,o2,"r.method",'let u=r.url,s=u.indexOf("/",12)+1,e=u.indexOf("?",s),p=e===-1?u.slice(s):u.substring(s,e);',1)+"return mwn}")(isErr,createContext,...dependencies)};import{compileGroup,createArgSet,isFuncAsync}from"@mapl/framework";import{o2}from"@mapl/router/tree/compiler";import compile from"@mapl/router/method/compiler";import{transformRoute}from"@mapl/router/transform";import{isErr}from"safe-throw";import{createContext}from"./context";let paramArgs=createArgSet(new Array(16).fill(0).map((_1,i)=>"q"+i));let compileReturn=(state,dat,fnAsync,scopeAsync,contextCreated,result)=>{let typ=dat.type;if(typ==="raw")return"return "+result;if(fnAsync)result="await "+result;let str=typ==null?"return new Response("+result+(contextCreated?",c)":")"):(contextCreated?"":state[2])+"mh.push("+(typ==="json"?"mwj":"mwh")+");return new Response("+(typ==="json"?"JSON.stringify("+result+")":result)+",c)";return fnAsync&&!scopeAsync?"return (async()=>{"+str+"})":str};
|
|
1
|
+
export default (router)=>{let baseRouter={};let dependencies=[];compileGroup(router._,[baseRouter,dependencies,"let mh=[],c=mwc(r,mh);",(fn,dat,path,state,scope)=>{let call="f"+state[1].push(fn)+"(";let paramCount=path[0].length;if(paramCount>0)call+=paramArgs[paramCount];if(fn.length>paramCount){call+=paramCount===0?"c":",c";if(!scope[1])return state[2]+compileReturn(state,dat,isFuncAsync(fn),scope[0],true,call+")")}return compileReturn(state,dat,isFuncAsync(fn),scope[0],scope[1],call+")")},(fn,dat,state,scope)=>{let call="f"+state[1].push(fn)+"(t";if(fn.length>1){call+=",c";if(!scope[1])return state[2]+compileReturn(state,dat,isFuncAsync(fn),scope[0],true,call+")")}return compileReturn(state,dat,isFuncAsync(fn),scope[0],scope[1],call+")")},transformRoute],[false,false,null,"return mwb"],"","");return Function("me","mwc",...dependencies.map((_,i)=>"f"+(i+1)),'let [mwh,mwj]=["text/html","application/json"].map(c=>["content-type",c]),[mwn,mwb]=[404,400].map(s=>new Response(null,{status:s}));return(r)=>{'+compile(baseRouter,o2,"r.method",'let u=r.url,s=u.indexOf("/",12)+1,e=u.indexOf("?",s),p=e===-1?u.slice(s):u.substring(s,e);',1)+"return mwn}")(isErr,createContext,...dependencies)};import{compileGroup,createArgSet,isFuncAsync}from"@mapl/framework";import{o2}from"@mapl/router/tree/compiler";import compile from"@mapl/router/method/compiler";import{transformRoute}from"@mapl/router/transform";import{isErr}from"safe-throw";import{createContext}from"./context";let paramArgs=createArgSet(new Array(16).fill(0).map((_1,i)=>"q"+i));let compileReturn=(state,dat,fnAsync,scopeAsync,contextCreated,result)=>{let typ=dat.type;if(typ==="raw")return"return "+result;if(fnAsync)result="await "+result;let str=typ==null?"return new Response("+result+(contextCreated?",c)":")"):(contextCreated?"":state[2])+"mh.push("+(typ==="json"?"mwj":"mwh")+");return new Response("+(typ==="json"?"JSON.stringify("+result+")":result)+",c)";return fnAsync&&!scopeAsync?"return (async()=>{"+str+"})()":scopeAsync?str+"})()":str};
|