naming #2

Merged
SethTrowbridge merged 5 commits from naming into master 2023-06-30 10:23:59 -04:00
2 changed files with 13 additions and 13 deletions
Showing only changes of commit cc80a2725d - Show all commits

View File

@ -18,17 +18,17 @@ Configure({
} }
} }
}, },
Remap: (inImports)=> Remap: (inImports, inConfig)=>
{ {
inImports["react-original"] = inImports["react"]; inImports["react-original"] = inImports["react"];
inImports["react"] = "/_lib_/hmr-react.tsx"; inImports["react"] = "/_lib_/hmr-react.tsx";
return inImports; return inImports;
}, },
async Serve(inReq, inURL, inExt, inMap, inProxy) async Serve(inReq, inURL, inExt, inMap, inConfig)
{ {
if(Transpile.Check(inExt) && !inURL.searchParams.get("reload") && !inURL.pathname.startsWith("/_lib_/")) if(Transpile.Check(inExt) && !inURL.searchParams.get("reload") && !inURL.pathname.startsWith("/_lib_/"))
{ {
const imp = await import(inProxy+inURL.pathname); const imp = await import(inConfig.Proxy+inURL.pathname);
const members = []; const members = [];
for( const key in imp ) { members.push(key); } for( const key in imp ) { members.push(key); }

View File

@ -39,12 +39,12 @@ const ImportMapReload =async()=>
console.log(`"react" specifier not defined in import map`); console.log(`"react" specifier not defined in import map`);
} }
ImportMap.imports = Configuration.Remap(json.imports); ImportMap.imports = Configuration.Remap(json.imports, Configuration);
console.log(ImportMap.imports); console.log(ImportMap.imports);
}; };
type CustomHTTPHandler = (inReq:Request, inURL:URL, inExt:string|false, inMap:{imports:Record<string, string>}, inProxy:string)=>void|false|Response|Promise<Response|void|false>; type CustomHTTPHandler = (inReq:Request, inURL:URL, inExt:string|false, inMap:{imports:Record<string, string>}, inConfig:Configuration)=>void|false|Response|Promise<Response|void|false>;
type CustomRemapper = (inImports:Record<string, string>)=>Record<string, string>; type CustomRemapper = (inImports:Record<string, string>, inConfig:Configuration)=>Record<string, string>;
type Configuration = {Proxy:string, Allow:string, Reset:string, SWCOp:SWCW.Options, Serve:CustomHTTPHandler, Shell:CustomHTTPHandler, Remap:CustomRemapper}; type Configuration = {Proxy:string, Allow:string, Reset:string, SWCOp:SWCW.Options, Serve:CustomHTTPHandler, Shell:CustomHTTPHandler, Remap:CustomRemapper};
type ConfigurationArgs = {Proxy?:string, Allow?:string, Reset?:string, SWCOp?:SWCW.Options, Serve?:CustomHTTPHandler, Shell?:CustomHTTPHandler, Remap?:CustomRemapper}; type ConfigurationArgs = {Proxy?:string, Allow?:string, Reset?:string, SWCOp?:SWCW.Options, Serve?:CustomHTTPHandler, Shell?:CustomHTTPHandler, Remap?:CustomRemapper};
let Configuration:Configuration = let Configuration:Configuration =
@ -53,7 +53,7 @@ let Configuration:Configuration =
Allow: "*", Allow: "*",
Reset: "/clear-cache", Reset: "/clear-cache",
Serve(inReq, inURL, inExt, inMap, inProxy){}, Serve(inReq, inURL, inExt, inMap, inProxy){},
Remap: (inImports)=> Remap: (inImports, inConfig)=>
{ {
const reactURL = inImports["react"]; const reactURL = inImports["react"];
const setting = Configuration.SWCOp?.jsc?.transform?.react; const setting = Configuration.SWCOp?.jsc?.transform?.react;
@ -63,12 +63,12 @@ let Configuration:Configuration =
} }
return inImports; return inImports;
}, },
Shell(inReq, inURL, inExt, inMap, inProxy) Shell(inReq, inURL, inExt, inMap, inConfig)
{ {
console.log("Start app:", Deno.mainModule, "start dir", inProxy); console.log("Start app:", Deno.mainModule, "start dir", inConfig.Proxy);
console.log("Split:", Deno.mainModule.split(inProxy) ); console.log("Split:", Deno.mainModule.split(inConfig.Proxy) );
const parts = Deno.mainModule.split(inProxy); const parts = Deno.mainModule.split(inConfig.Proxy);
return new Response( return new Response(
`<!doctype html> `<!doctype html>
@ -181,7 +181,7 @@ HTTP.serve(async(req: Request)=>
} }
// allow for custom handler // allow for custom handler
const custom = await Configuration.Serve(req, url, ext, ImportMap, Configuration.Proxy); const custom = await Configuration.Serve(req, url, ext, ImportMap, Configuration);
if(custom) if(custom)
{ {
return custom; return custom;
@ -222,7 +222,7 @@ HTTP.serve(async(req: Request)=>
// custom page html // custom page html
if(!ext) if(!ext)
{ {
const shell = await Configuration.Shell(req, url, ext, ImportMap, Configuration.Proxy); const shell = await Configuration.Shell(req, url, ext, ImportMap, Configuration);
if(shell) if(shell)
{ {
return shell; return shell;