From 6b8a20780987b1930a6f3b4e7dfb023ce28ee8b1 Mon Sep 17 00:00:00 2001 From: Seth Trowbridge Date: Thu, 8 Jun 2023 16:59:56 -0400 Subject: [PATCH] make _lib_ accessable --- {hmr => _lib_}/hmr.tsx | 0 {hmr => _lib_}/react.tsx | 0 local.tsx | 18 +++--------------- serve.tsx | 16 ++++++++++++++-- 4 files changed, 17 insertions(+), 17 deletions(-) rename {hmr => _lib_}/hmr.tsx (100%) rename {hmr => _lib_}/react.tsx (100%) diff --git a/hmr/hmr.tsx b/_lib_/hmr.tsx similarity index 100% rename from hmr/hmr.tsx rename to _lib_/hmr.tsx diff --git a/hmr/react.tsx b/_lib_/react.tsx similarity index 100% rename from hmr/react.tsx rename to _lib_/react.tsx diff --git a/local.tsx b/local.tsx index 4a43f00..e29ed2f 100644 --- a/local.tsx +++ b/local.tsx @@ -31,18 +31,8 @@ Configure({ }); return inImports; }, - async Serve(inReq, inURL, inExt, inMap) + Serve(inReq, inURL, inExt, inMap) { - if(inURL.pathname.startsWith("/hmr/")) - { - const path = import.meta.url+"/.."+inURL.pathname; - const code = await Transpile.Fetch(path, inURL.pathname, true); - if(code) - { - return new Response(code, {headers:{"content-type":"application/javascript"}}) - } - } - if(inReq.headers.get("upgrade") == "websocket") { try @@ -54,9 +44,7 @@ Configure({ socket.onerror = (e) => console.log("Socket errored:", e); return response; } - catch(e) - { - } + catch(e){ /**/ } } } }); @@ -92,4 +80,4 @@ for await (const event of Deno.watchFs(Deno.cwd())) } , 1000); } -} +} \ No newline at end of file diff --git a/serve.tsx b/serve.tsx index 4e08888..53fa90d 100644 --- a/serve.tsx +++ b/serve.tsx @@ -178,8 +178,20 @@ HTTP.serve(async(req: Request)=> // transpileable files if(Transpile.Check(ext)) { - const lookup = await Transpile.Fetch(Configuration.Proxy + url.pathname, url.pathname); - return new Response(lookup, {status:lookup?200:404, headers:{...headers, "content-type":"application/javascript"}} ); + if(url.pathname.startsWith("/_lib_/")) + { + const path = import.meta.url+"/.."+url.pathname; + const code = await Transpile.Fetch(path, url.pathname, true); + if(code) + { + return new Response(code, {headers:{"content-type":"application/javascript"}}); + } + } + else + { + const lookup = await Transpile.Fetch(Configuration.Proxy + url.pathname, url.pathname); + return new Response(lookup, {status:lookup?200:404, headers:{...headers, "content-type":"application/javascript"}} ); + } } // all other static files