From 4d3760d92c80ddb56483959d86ae89a607e9660d Mon Sep 17 00:00:00 2001 From: Seth Trowbridge Date: Sat, 8 Apr 2023 12:38:36 -0400 Subject: [PATCH 1/6] standardize of fetch for reading files --- example/deep/component.tsx | 1 + example/deno.json | 1 + server.tsx | 48 +++++++++++++------------------------- 3 files changed, 18 insertions(+), 32 deletions(-) diff --git a/example/deep/component.tsx b/example/deep/component.tsx index 637cedd..22970d5 100644 --- a/example/deep/component.tsx +++ b/example/deep/component.tsx @@ -6,6 +6,7 @@ export default ()=> const [countGet, countSet] = React.useState(1); return
+ Component!!!
; }; \ No newline at end of file diff --git a/example/deno.json b/example/deno.json index bb0e33d..ed849e6 100644 --- a/example/deno.json +++ b/example/deno.json @@ -8,6 +8,7 @@ "@eno/iso": "http://localhost:4507/lib/iso.tsx" }, "tasks": { + "host": "deno run -A --unstable https://deno.land/std@0.181.0/http/file_server.ts", "dev": "deno run -A --unstable --reload=http://localhost:4507/ --no-lock --config=deno.json 'http://localhost:4507/server.tsx?reload=1'" } } \ No newline at end of file diff --git a/server.tsx b/server.tsx index f07399e..f668358 100644 --- a/server.tsx +++ b/server.tsx @@ -6,6 +6,13 @@ import * as Twind from "https://esm.sh/@twind/core@1.1.3"; import React, {JSX, createElement as h} from "react"; import * as Iso from "@eno/iso"; +let hosted = import.meta.resolve("./"); +const Path = { + Hosted:hosted.substring(0, hosted.length-1), + Active:`file://${Deno.cwd().replaceAll("\\", "/")}` +}; +console.log(Path); + const Transpiled = new Map(); const Transpileable =(inFilePath:string):boolean=> { @@ -33,19 +40,6 @@ const Transpile =async(inCode:string, inKey:string):Promise=> return transpile.code; }; type Transpiler = (inPath:string, inKey:string, inCheck?:boolean)=>Promise; -const TranspileFS:Transpiler =async(inPath, inKey, inCheck)=> -{ - if(inCheck) - { - const cached = Transpiled.get(inKey); - if(cached) - { - return cached; - } - } - const body = await Deno.readTextFile(inPath); - return Transpile(body, inKey); -}; const TranspileURL:Transpiler =async(inPath, inKey, inCheck)=> { if(inCheck) @@ -56,8 +50,7 @@ const TranspileURL:Transpiler =async(inPath, inKey, inCheck)=> return cached; } } - const path = import.meta.resolve(`.${inPath}`); - let body = await fetch(path); + let body = await fetch(inPath); let text = await body.text(); return Transpile(text, inKey); }; @@ -68,8 +61,8 @@ type ImportMap = {imports?:Record, importMap?:string}; let ImportObject:ImportMap = {}; try { - const confDeno = await Deno.readTextFile(Deno.cwd()+"/deno.json"); - const confDenoParsed:ImportMap = JSON.parse(confDeno); + const confDeno = await fetch(`${Path.Active}/deno.json`); + const confDenoParsed:ImportMap = await confDeno.json(); if(confDenoParsed.importMap) { try @@ -147,7 +140,6 @@ catch(e) Deno.serve({ port: Deno.args[0]||3000 }, async(_req:Request) => { const url:URL = new URL(_req.url); - const fsPath = Deno.cwd()+url.pathname; const pathParts = url.pathname.substring(1, url.pathname.endsWith("/") ? url.pathname.length-1 : url.pathname.length).split("/"); const pathLast = pathParts[pathParts.length-1]; const pathExt:string|undefined = pathLast.split(".")[1]; @@ -194,12 +186,11 @@ Deno.serve({ port: Deno.args[0]||3000 }, async(_req:Request) => type = `application/javascript`; if(isLib) { - body = await TranspileURL(url.pathname, url.pathname, true); + body = await TranspileURL(Path.Hosted+url.pathname, url.pathname, true); } else if(!url.searchParams.get("reload")) { - const path = `file://${Deno.cwd().replaceAll("\\", "/")+url.pathname}`; - const imp = await import(path); + const imp = await import(Path.Active+url.pathname); const members = []; for( const key in imp ) { members.push(key); } body = @@ -218,22 +209,15 @@ FileListen("${url.pathname}", reloadHandler);`; } else { - body = await TranspileFS(fsPath, url.pathname, true); + body = await TranspileURL(Path.Active+url.pathname, url.pathname, true); } } // serve static media else if( pathExt ) { type = MIME.typeByExtension(pathExt) || "text/html"; - if(isLib) - { - const _fetch = await fetch(import.meta.resolve(`.${url.pathname}`)); - body = await _fetch.text(); - } - else - { - body = await Deno.readFile(fsPath); - } + const _fetch = await fetch((isLib ? Path.Hosted : Path.Active)+url.pathname); + body = await _fetch.text(); } else { @@ -289,7 +273,7 @@ const ProcessFiles =debounce(async()=> if(action != "remove") { - await TranspileFS(path, key, false); + await TranspileURL(Path.Active+key, key, false); console.log(` ...cached "${key}"`); SocketsBroadcast(key); } From 06266d7ca6c7a79728505428ec0f148bb26e5246 Mon Sep 17 00:00:00 2001 From: Seth Trowbridge Date: Thu, 13 Apr 2023 22:23:04 -0400 Subject: [PATCH 2/6] router started --- example/deep/component.tsx | 6 ++++- lib/iso.tsx | 46 +++++++++++++++++++++++++++++++++++++- server.tsx | 13 ++++++----- 3 files changed, 57 insertions(+), 8 deletions(-) diff --git a/example/deep/component.tsx b/example/deep/component.tsx index 22970d5..c47499c 100644 --- a/example/deep/component.tsx +++ b/example/deep/component.tsx @@ -4,9 +4,13 @@ import * as Iso from "@eno/iso"; export default ()=> { const [countGet, countSet] = React.useState(1); + + const [routeGet, routeSet] = Iso.Router.Consumer(); + return
- + Route is: {routeGet.Path.toString()} + Component!!!
; }; \ No newline at end of file diff --git a/lib/iso.tsx b/lib/iso.tsx index 9243188..3f5f020 100644 --- a/lib/iso.tsx +++ b/lib/iso.tsx @@ -31,4 +31,48 @@ export const Metas =(props:{concatListed?:boolean; dropUnlisted?:boolean}&MetasI } return null; -} \ No newline at end of file +} + +type RoutePath = Array; +type RouteParams = Record; +type RouteState = {URL:URL, Path:string[]}; +type RouteContext = [Route:RouteState, Update:(inPath?:RoutePath, inParams?:RouteParams)=>void]; +type RouteProps = {children:typeof React.Children, url?:URL }; +export const Router = { + Path(url:URL) + { + return url.pathname.substring(1, url.pathname.endsWith("/") ? url.pathname.length-1 : url.pathname.length).split("/"); + }, + Context:React.createContext([{URL:new URL("https://original.route/"), Path:[]}, ()=>{}] as RouteContext), + Provider(props:RouteProps) + { + const url = props.url || new URL(document.location.href); + const path = Router.Path(url); + + const [routeGet, routeSet] = React.useState({URL:url, Path:path} as RouteState); + //const routeUpdate:RouteContext[1] =(inURL:URL)=>routeSet({URL:inURL, Path:Router.Path(inURL)}); + const routeUpdate:RouteContext[1] =(inPath?:RoutePath, inParams?:RouteParams)=> + { + const clone = new URL(routeGet.URL.href); + inPath && (clone.pathname = `/${inPath.join("/")}`); + inParams && (clone.search = new URLSearchParams(inParams).toString()); + routeSet({ + URL:clone, + Path: inPath ? inPath : routeGet.Path + }); + }; + + React.useEffect(()=>history.pushState({Path:routeGet.Path, Params:routeGet.URL.search}, "", routeGet.URL), [routeGet.URL.href]); + React.useEffect(()=>{ + window.addEventListener("popstate", ()=>routeUpdate()); + }, []); + + return + {props.children} + ; + }, + Consumer() + { + return React.useContext(Router.Context); + } +}; \ No newline at end of file diff --git a/server.tsx b/server.tsx index f668358..d818c79 100644 --- a/server.tsx +++ b/server.tsx @@ -3,7 +3,7 @@ import * as MIME from "https://deno.land/std@0.180.0/media_types/mod.ts"; import { debounce } from "https://deno.land/std@0.151.0/async/debounce.ts"; import SSR from "https://esm.sh/v113/preact-render-to-string@6.0.2"; import * as Twind from "https://esm.sh/@twind/core@1.1.3"; -import React, {JSX, createElement as h} from "react"; +import React from "react"; import * as Iso from "@eno/iso"; let hosted = import.meta.resolve("./"); @@ -141,12 +141,12 @@ Deno.serve({ port: Deno.args[0]||3000 }, async(_req:Request) => { const url:URL = new URL(_req.url); const pathParts = url.pathname.substring(1, url.pathname.endsWith("/") ? url.pathname.length-1 : url.pathname.length).split("/"); - const pathLast = pathParts[pathParts.length-1]; - const pathExt:string|undefined = pathLast.split(".")[1]; + const pathLast = pathParts.at(-1); + const pathExt:string|undefined = pathLast?.split(".")[1]; console.log(pathParts, pathLast, pathExt); - console.log(`Request for "${url.pathname}"...`); + console.log(`Request for "${url.pathname}"...`); if(_req.headers.get("upgrade") == "websocket") { @@ -221,7 +221,7 @@ FileListen("${url.pathname}", reloadHandler);`; } else { - const results = Twind.extract(SSR(), TwindInst); + const results = Twind.extract(SSR(), TwindInst); type = `text/html`; body = ` @@ -240,8 +240,9 @@ FileListen("${url.pathname}", reloadHandler);`; import {render, createElement as H} from "react"; import * as Twind from "https://esm.sh/@twind/core@1.1.3"; import {default as App, CSS} from "@eno/app"; + import {Router} from "@eno/iso"; Twind.install(CSS); - render(H(()=>H(App)), document.querySelector("#app")); + render( H(Router.Provider, null, H(App)), document.querySelector("#app")); `; From 64a4a82ac8db717a53265cb572a334bf6eacbeb6 Mon Sep 17 00:00:00 2001 From: Seth Trowbridge Date: Fri, 14 Apr 2023 06:58:12 -0400 Subject: [PATCH 3/6] allow for params and route --- lib/iso.tsx | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/lib/iso.tsx b/lib/iso.tsx index 3f5f020..0bab3f3 100644 --- a/lib/iso.tsx +++ b/lib/iso.tsx @@ -34,37 +34,47 @@ export const Metas =(props:{concatListed?:boolean; dropUnlisted?:boolean}&MetasI } type RoutePath = Array; -type RouteParams = Record; -type RouteState = {URL:URL, Path:string[]}; -type RouteContext = [Route:RouteState, Update:(inPath?:RoutePath, inParams?:RouteParams)=>void]; +type RouteParams = Record; +type RouteState = {URL:URL, Path:RoutePath, Params:RouteParams, Anchor:string}; +type RouteContext = [Route:RouteState, Update:(inPath?:RoutePath, inParams?:RouteParams, inAnchor?:string)=>void]; type RouteProps = {children:typeof React.Children, url?:URL }; export const Router = { - Path(url:URL) + Parse(url:URL):RouteState { - return url.pathname.substring(1, url.pathname.endsWith("/") ? url.pathname.length-1 : url.pathname.length).split("/"); + const Path = url.pathname.substring(1, url.pathname.endsWith("/") ? url.pathname.length-1 : url.pathname.length).split("/"); + const Params:RouteParams = {}; + new URLSearchParams(url.search).forEach((k, v)=> Params[k] = v); + const Anchor = url.hash.substring(1); + return {URL:url, Path, Params, Anchor} as RouteState; }, - Context:React.createContext([{URL:new URL("https://original.route/"), Path:[]}, ()=>{}] as RouteContext), + Context:React.createContext([{URL:new URL("https://original.route/"), Path:[], Params:{}, Anchor:""}, ()=>{}] as RouteContext), Provider(props:RouteProps) { - const url = props.url || new URL(document.location.href); - const path = Router.Path(url); + const [routeGet, routeSet] = React.useState(Router.Parse(props.url || new URL(document.location.href))); + const [dirtyGet, dirtySet] = React.useState(false); - const [routeGet, routeSet] = React.useState({URL:url, Path:path} as RouteState); - //const routeUpdate:RouteContext[1] =(inURL:URL)=>routeSet({URL:inURL, Path:Router.Path(inURL)}); - const routeUpdate:RouteContext[1] =(inPath?:RoutePath, inParams?:RouteParams)=> + const routeUpdate:RouteContext[1] =(inPath, inParams, inAnchor)=> { - const clone = new URL(routeGet.URL.href); - inPath && (clone.pathname = `/${inPath.join("/")}`); - inParams && (clone.search = new URLSearchParams(inParams).toString()); + const clone = new URL(routeGet.URL); + inPath && (clone.pathname = inPath.join("/")); + inParams && (clone.search = new URLSearchParams(inParams as Record).toString()); routeSet({ URL:clone, - Path: inPath ? inPath : routeGet.Path + Path: inPath || routeGet.Path, + Params: inParams || routeGet.Params, + Anchor: inAnchor || routeGet.Anchor }); + dirtySet(true); }; - React.useEffect(()=>history.pushState({Path:routeGet.Path, Params:routeGet.URL.search}, "", routeGet.URL), [routeGet.URL.href]); + // when the state changes, update the page url React.useEffect(()=>{ - window.addEventListener("popstate", ()=>routeUpdate()); + history.pushState({...routeGet, URL:undefined}, "", routeGet.URL); + }, [routeGet.URL.href]); + + React.useEffect(()=>{ + // when the history changes, update the state + window.addEventListener("popstate", ({state})=>{routeUpdate(state.Path, state.Params, state.Anchor)}); }, []); return From ca556e3a68a3e9505ca18050fb7d28cf20c4de7f Mon Sep 17 00:00:00 2001 From: Seth Trowbridge Date: Fri, 14 Apr 2023 21:41:01 -0400 Subject: [PATCH 4/6] link clicking --- example/deep/component.tsx | 3 ++- lib/iso.tsx | 32 ++++++++++++++++++++++---------- server.tsx | 2 +- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/example/deep/component.tsx b/example/deep/component.tsx index c47499c..5bed3d8 100644 --- a/example/deep/component.tsx +++ b/example/deep/component.tsx @@ -10,7 +10,8 @@ export default ()=> return
Route is: {routeGet.Path.toString()} - + Component!!! + a link
; }; \ No newline at end of file diff --git a/lib/iso.tsx b/lib/iso.tsx index 0bab3f3..8333a1f 100644 --- a/lib/iso.tsx +++ b/lib/iso.tsx @@ -22,9 +22,6 @@ export const Metas =(props:{concatListed?:boolean; dropUnlisted?:boolean}&MetasI const propValue = props[metaKey]||""; propValue ? additive(metaKey, propValue) : subtractive(metaKey); }) - - console.log(`rendering metas`, Meta) - if(window.innerWidth) { document.title = Meta.title; @@ -51,7 +48,7 @@ export const Router = { Provider(props:RouteProps) { const [routeGet, routeSet] = React.useState(Router.Parse(props.url || new URL(document.location.href))); - const [dirtyGet, dirtySet] = React.useState(false); + const [dirtyGet, dirtySet] = React.useState(true); const routeUpdate:RouteContext[1] =(inPath, inParams, inAnchor)=> { @@ -64,17 +61,32 @@ export const Router = { Params: inParams || routeGet.Params, Anchor: inAnchor || routeGet.Anchor }); - dirtySet(true); }; // when the state changes, update the page url - React.useEffect(()=>{ - history.pushState({...routeGet, URL:undefined}, "", routeGet.URL); - }, [routeGet.URL.href]); + React.useEffect(()=> dirtyGet ? dirtySet(false) : history.pushState({...routeGet, URL:undefined}, "", routeGet.URL), [routeGet.URL.href]); React.useEffect(()=>{ - // when the history changes, update the state - window.addEventListener("popstate", ({state})=>{routeUpdate(state.Path, state.Params, state.Anchor)}); + history.replaceState({...routeGet, URL:undefined}, "", routeGet.URL); + window.addEventListener("popstate", ({state})=> + { + dirtySet(true); + routeUpdate(state.Path, state.Params, state.Anchor); + }); + document.addEventListener("click", e=> + { + const t = e.target as HTMLAnchorElement; + if(t.href) + { + const u = new URL(t.href); + if(u.origin == document.location.origin) + { + e.preventDefault(); + const parts = Router.Parse(u); + routeUpdate(parts.Path, parts.Params, parts.Anchor); + } + } + }) }, []); return diff --git a/server.tsx b/server.tsx index d818c79..06c98d5 100644 --- a/server.tsx +++ b/server.tsx @@ -35,7 +35,7 @@ const Transpileable =(inFilePath:string):boolean=> }; const Transpile =async(inCode:string, inKey:string):Promise=> { - const transpile = await ESBuild.transform(inCode, { loader: "tsx", sourcemap: "inline", minify:true }); + const transpile = await ESBuild.transform(inCode, { loader: "tsx", sourcemap: "inline", minify:false }); Transpiled.set(inKey, transpile.code); return transpile.code; }; From 8ed6a4b029be5235c799f2863b129a9457533e2c Mon Sep 17 00:00:00 2001 From: Seth Trowbridge Date: Sat, 15 Apr 2023 12:39:08 -0400 Subject: [PATCH 5/6] switch/case rendering --- example/app.tsx | 6 ++++ example/deep/component.tsx | 2 +- lib/iso.tsx | 56 +++++++++++++++++++++++++++++++++++++- server.tsx | 2 +- 4 files changed, 63 insertions(+), 3 deletions(-) diff --git a/example/app.tsx b/example/app.tsx index 405429d..d6bdc70 100644 --- a/example/app.tsx +++ b/example/app.tsx @@ -13,6 +13,12 @@ export default ()=>

Title!!

subtitle

+ + + About Us + + lol/idk + ; }; diff --git a/example/deep/component.tsx b/example/deep/component.tsx index 5bed3d8..124ecfc 100644 --- a/example/deep/component.tsx +++ b/example/deep/component.tsx @@ -12,6 +12,6 @@ export default ()=> Route is: {routeGet.Path.toString()} Component!!! - a link + a link ; }; \ No newline at end of file diff --git a/lib/iso.tsx b/lib/iso.tsx index 8333a1f..fa6a91a 100644 --- a/lib/iso.tsx +++ b/lib/iso.tsx @@ -97,4 +97,58 @@ export const Router = { { return React.useContext(Router.Context); } -}; \ No newline at end of file +}; + +type SwitchContext = {depth:number, keys:Record}; +export const SwitchContext = React.createContext({depth:0, keys:{}} as SwitchContext); +export const Switch =({children}:{children:typeof React.Children})=> +{ + const contextSelection = React.useContext(SwitchContext); + const [contextRoute] = Router.Consumer(); + const routeSegment = contextRoute.Path.slice(contextSelection.depth); + const checkChild =(inChild:{props:{value?:string}})=> + { + if(inChild?.props?.value) + { + const parts = inChild.props.value.split("/"); + if(parts.length > routeSegment.length) + { + return false; + } + + const output:SwitchContext = {depth:contextSelection.depth+parts.length, keys:{}}; + for(let i=0; iRoute Rendred!{child} + } + } + return null; +}; +export const Case =({children, value}:{children:typeof React.Children, value?:string})=> +{ + return <>{children}; +}; +export const useRouteVars =()=> React.useContext(SwitchContext).keys; \ No newline at end of file diff --git a/server.tsx b/server.tsx index 06c98d5..e6613ff 100644 --- a/server.tsx +++ b/server.tsx @@ -35,7 +35,7 @@ const Transpileable =(inFilePath:string):boolean=> }; const Transpile =async(inCode:string, inKey:string):Promise=> { - const transpile = await ESBuild.transform(inCode, { loader: "tsx", sourcemap: "inline", minify:false }); + const transpile = await ESBuild.transform(inCode, { loader: "tsx", sourcemap: "inline", minify:false}); Transpiled.set(inKey, transpile.code); return transpile.code; }; From 101a5d2218627dffc8e2336b503a75676906aecb Mon Sep 17 00:00:00 2001 From: Seth Trowbridge Date: Sun, 16 Apr 2023 21:33:09 -0400 Subject: [PATCH 6/6] cleanup --- example/app.tsx | 14 ++++--- lib/iso.tsx | 97 ++++++++++++++++++++++++++----------------------- server.tsx | 7 ++-- 3 files changed, 63 insertions(+), 55 deletions(-) diff --git a/example/app.tsx b/example/app.tsx index d6bdc70..ea4529d 100644 --- a/example/app.tsx +++ b/example/app.tsx @@ -1,23 +1,25 @@ -import TWPreTail from "https://esm.sh/@twind/preset-tailwind@1.1.4"; -import TWPreAuto from "https://esm.sh/@twind/preset-autoprefix@1.0.7"; +import TWPreTail from "https://esm.sh/v115/@twind/preset-tailwind@1.1.4/es2022/preset-tailwind.mjs"; +import TWPreAuto from "https://esm.sh/v115/@twind/preset-autoprefix@1.0.7/es2022/preset-autoprefix.mjs"; import React from "react"; import Component from "./deep/component.tsx"; import * as Iso from "@eno/iso"; export default ()=> { - console.log(Iso.Meta); - const [countGet, countSet] = React.useState(1); return

Title!!

subtitle

- - About Us + + + About us! + sorry no page + lol/idk +

404!

; }; diff --git a/lib/iso.tsx b/lib/iso.tsx index fa6a91a..2b1789a 100644 --- a/lib/iso.tsx +++ b/lib/iso.tsx @@ -1,6 +1,5 @@ import React from "react"; - type Meta = {title:string, description:string, keywords:string, image:string, canonical:string } type MetaKeys = keyof Meta; export const Meta:Meta = { @@ -30,11 +29,14 @@ export const Metas =(props:{concatListed?:boolean; dropUnlisted?:boolean}&MetasI return null; } + +export type Children = string | number | React.JSX.Element | React.JSX.Element[]; + type RoutePath = Array; type RouteParams = Record; type RouteState = {URL:URL, Path:RoutePath, Params:RouteParams, Anchor:string}; type RouteContext = [Route:RouteState, Update:(inPath?:RoutePath, inParams?:RouteParams, inAnchor?:string)=>void]; -type RouteProps = {children:typeof React.Children, url?:URL }; +type RouteProps = {children:Children, url?:URL }; export const Router = { Parse(url:URL):RouteState { @@ -89,9 +91,7 @@ export const Router = { }) }, []); - return - {props.children} - ; + return {props.children}; }, Consumer() { @@ -101,54 +101,61 @@ export const Router = { type SwitchContext = {depth:number, keys:Record}; export const SwitchContext = React.createContext({depth:0, keys:{}} as SwitchContext); -export const Switch =({children}:{children:typeof React.Children})=> +export const Switch =({children}:{children:Children})=> { - const contextSelection = React.useContext(SwitchContext); - const [contextRoute] = Router.Consumer(); - const routeSegment = contextRoute.Path.slice(contextSelection.depth); - const checkChild =(inChild:{props:{value?:string}})=> + let fallback = null; + if(Array.isArray(children)) { - if(inChild?.props?.value) - { - const parts = inChild.props.value.split("/"); - if(parts.length > routeSegment.length) - { - return false; - } - - const output:SwitchContext = {depth:contextSelection.depth+parts.length, keys:{}}; - for(let i=0; i + { + if(inChild?.props?.value) + { + const parts = inChild.props.value.split("/"); + if(parts.length > routeSegment.length) { return false; } + + const output:SwitchContext = {depth:contextSelection.depth+parts.length, keys:{}}; + for(let i=0; i{childCaseChildren} + } + if(childCase?.props?.default && !fallback) + { + console.log(routeSegment); + fallback = childCaseChildren; + } + } } - for(let i=0; iRoute Rendred!{child} - } - } - return null; -}; -export const Case =({children, value}:{children:typeof React.Children, value?:string})=> -{ - return <>{children}; + return fallback; }; +export const Case =({children, value}:{children:Children, value?:string, default?:true})=>null; export const useRouteVars =()=> React.useContext(SwitchContext).keys; \ No newline at end of file diff --git a/server.tsx b/server.tsx index e6613ff..300d9c6 100644 --- a/server.tsx +++ b/server.tsx @@ -35,7 +35,7 @@ const Transpileable =(inFilePath:string):boolean=> }; const Transpile =async(inCode:string, inKey:string):Promise=> { - const transpile = await ESBuild.transform(inCode, { loader: "tsx", sourcemap: "inline", minify:false}); + const transpile = await ESBuild.transform(inCode, { loader: "tsx", minify:true}); Transpiled.set(inKey, transpile.code); return transpile.code; }; @@ -181,7 +181,7 @@ Deno.serve({ port: Deno.args[0]||3000 }, async(_req:Request) => const isLib = url.pathname.startsWith(`/${LibPath}/`); - if(Transpileable(pathLast)) + if(Transpileable(url.pathname)) { type = `application/javascript`; if(isLib) @@ -232,13 +232,12 @@ FileListen("${url.pathname}", reloadHandler);`; -
${results.html}