@mapl/web 0.0.3 → 0.0.5
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapl/web",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
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.0.21",
|
|
38
38
|
"@mapl/router": "^0.4.10",
|
|
39
39
|
"safe-throw": "^0.0.9"
|
|
40
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default (router,args)=>{let baseRouter={};let dependencies=[];compileGroup(router.group,[baseRouter,dependencies,createArgSet(["mc",...args]),"let mh=[],mc=mwci(mwr,mh);",compileHandler,compileErrorHandler,transformRoute],"","",false,false,"return mwbr;");return Function("mie","mwci",...dependencies.map((_,i)=>"mp"+(i+1)),'let [mwh,mwj]=["text/html","application/json"].map(c=>["content-type",c]),[mwnf,mwbr]=[404,400].map(s=>new Response(null,{status:s}));return (mwr)=>{'+compile(baseRouter,o2,"mwr.method",'let mwru=mwr.url,ps=mwru.indexOf("/",12)+1,pe=mwru.indexOf("?",ps),p=pe===-1?mwru.slice(ps):mwru.substring(ps,pe);',1)+"return mwnf}")(isErr,createContext,...dependencies)};import{compileGroup,createArgSet,isFuncAsync,selectArgs}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
|
|
1
|
+
export default (router,args)=>{let baseRouter={};let dependencies=[];compileGroup(router.group,[baseRouter,dependencies,createArgSet(["mc",...args]),"let mh=[],mc=mwci(mwr,mh);",compileHandler,compileErrorHandler,transformRoute],"","",false,false,"return mwbr;");return Function("mie","mwci",...dependencies.map((_,i)=>"mp"+(i+1)),'let [mwh,mwj]=["text/html","application/json"].map(c=>["content-type",c]),[mwnf,mwbr]=[404,400].map(s=>new Response(null,{status:s}));return (mwr)=>{'+compile(baseRouter,o2,"mwr.method",'let mwru=mwr.url,ps=mwru.indexOf("/",12)+1,pe=mwru.indexOf("?",ps),p=pe===-1?mwru.slice(ps):mwru.substring(ps,pe);',1)+"return mwnf}")(isErr,createContext,...dependencies)};import{compileGroup,createArgSet,isFuncAsync,selectArgs}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,wrapAsync,contextCreated,result)=>{let typ=dat.type;return typ==null?"return new Response("+result+(contextCreated?",mc);":");"):typ==="raw"?"return "+result+";":(wrapAsync?"return (async()=>{":"")+(contextCreated?"":state[3])+"mh.push("+(typ==="json"?"mwj":"mwh")+");return new Response("+(typ==="json"?"JSON.stringify("+result+")":result)+",mc);"+(wrapAsync?"});":"")};let compileHandler=(fn,dat,path,state,scopeAsync,contextCreated)=>{let wrapAsync=false;let call="mp"+state[1].push(fn)+"(";if(isFuncAsync(fn)){call="await "+call;wrapAsync=!scopeAsync}let paramCount=path[0].length;if(paramCount>0)call+=paramArgs[paramCount];if(fn.length>paramCount){if(paramCount>0)call+=",";call+=selectArgs(state[2],fn.length-paramCount);if(!contextCreated){contextCreated=true;call=state[3]+call}}return compileReturn(state,dat,wrapAsync,contextCreated,call+")")};let compileErrorHandler=(fn,dat,state,scopeAsync,contextCreated)=>{let wrapAsync=false;let call="mp"+state[1].push(fn)+"(me";if(isFuncAsync(fn)){call="await "+call;wrapAsync=!scopeAsync}if(fn.length>1){call+=","+selectArgs(state[2],fn.length-1);if(!contextCreated){contextCreated=true;call=state[3]+call}}return compileReturn(state,dat,wrapAsync,contextCreated,call+")")};
|