diff --git a/.vscode/launch.json b/.vscode/launch.json index a00fbf1..b827b6e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,13 +5,18 @@ "version": "0.2.0", "configurations": [ { + "name": "Host Process", "request": "launch", - "name": "Debug Serve Mode", "type": "node", - "cwd": "${workspaceFolder}/example", "runtimeExecutable": "deno", "runtimeArgs": ["task", "debug"], "attachSimplePort": 9229 + }, + { + "name": "Subprocess", + "request": "attach", + "type": "node", + "port": 9230 } ] } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index b943dbc..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "deno.enable": true -} \ No newline at end of file diff --git a/checker.tsx b/checker.tsx index c44c7bd..b0673ed 100644 --- a/checker.tsx +++ b/checker.tsx @@ -167,9 +167,9 @@ export async function Check() const importMap = imports.json.imports as Record; const bake =async(obj:ConfigCheck)=> await Deno.writeTextFile(Deno.cwd()+"/"+obj.path, JSON.stringify(obj.json, null, "\t")); - importMap["react"] = `https://esm.sh/preact@10.18.1/compat`; - importMap["react/"] = `https://esm.sh/preact@10.18.1/compat/`; - importMap["@preact/signals"] = `https://esm.sh/@preact/signals@1.2.1`; + importMap["react"] = `https://esm.sh/preact@10.18.2/compat`; + importMap["react/"] = `https://esm.sh/preact@10.20.2/compat/`; + importMap["@preact/signals"] = `https://esm.sh/@preact/signals@1.2.3`; importMap["@twind/core"] = `https://esm.sh/@twind/core@1.1.3`; importMap[">able/"] = `${RootHost}`; if(!importMap[">able/app.tsx"]) diff --git a/cli.tsx b/cli.tsx index 8619f1a..9628d78 100644 --- a/cli.tsx +++ b/cli.tsx @@ -87,7 +87,7 @@ if(arg._.length) } case "debug" : { - await SubProcess(["run", `-A`, `--no-lock`, `--config=${config.path}`, `--inspect-brk`, RootHost+"run.tsx", "--dev", ...Deno.args]); + await SubProcess(["run", `-A`, `--no-lock`, `--config=${config.path}`, `--inspect-wait=127.0.0.1:9230`, RootHost+"run.tsx", "--dev", ...Deno.args]); break; } case "serve" : diff --git a/deno.jsonc b/deno.jsonc index 4b3d16f..2bf99bc 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -6,24 +6,24 @@ "@preact/signals": "https://esm.sh/@preact/signals@1.2.1", "signals-original": "https://esm.sh/@preact/signals@1.2.1", "@twind/core": "https://esm.sh/@twind/core@1.1.3", - ">able/": "http://localhost:4507/", + ">able/": "./", ">able/app.tsx": "./app.tsx" }, "tasks": { - "check": "deno run -A --no-lock http://localhost:4507/cli.tsx check", - "local": "deno run -A --no-lock http://localhost:4507/cli.tsx local", - "debug": "deno run -A --no-lock http://localhost:4507/cli.tsx debug", - "serve": "deno run -A --no-lock http://localhost:4507/cli.tsx serve", - "cloud": "deno run -A --no-lock http://localhost:4507/cli.tsx cloud", - "baker": "deno run -A --no-lock http://localhost:4507/cli.tsx baker", - "install": "deno install -A -r -f -n able http://localhost:4507/cli.tsx" + "check": "deno run -A --no-lock ./cli.tsx check", + "local": "deno run -A --no-lock ./cli.tsx local", + "debug": "deno run -A --no-lock --inspect-wait=127.0.0.1:9229 ./cli.tsx debug", + "serve": "deno run -A --no-lock ./cli.tsx serve", + "cloud": "deno run -A --no-lock ./cli.tsx cloud", + "baker": "deno run -A --no-lock ./cli.tsx baker", + "install": "deno install -A -r -f -n able ./cli.tsx" }, "compilerOptions": { "jsx": "react-jsx", "jsxImportSource": "react", "lib": [ "deno.window", - "dom", + "dom", "dom.asynciterable" ] } diff --git a/deno__.json b/deno__.json deleted file mode 100644 index cc26f5d..0000000 --- a/deno__.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { "lib": ["deno.window", "dom"], - "jsx": "react-jsx", - "jsxImportSource": "react" - }, - "imports": - { - "react":"https://esm.sh/preact@10.15.1/compat", - "react/":"https://esm.sh/preact@10.15.1/compat/", - "react-original":"https://esm.sh/preact@10.15.1/compat", - - }, - "tasks": - { - "local": "deno run -A --reload=http://localhost:4507 --no-lock ./run-local.tsx --port=1234", - "serve": "deno run -A --reload=http://localhost:4507 --no-lock ./run-serve.tsx --port=1234", - "cloud": "deno run -A --reload=http://localhost:4507 --no-lock ./run-deploy.tsx", - "debug": "deno run -A --reload=http://localhost:4507 --no-lock --inspect-wait ./run-serve.tsx --port=1234", - } -} \ No newline at end of file diff --git a/run-serve.tsx b/run-serve.tsx index ff9547e..74e0dc8 100644 --- a/run-serve.tsx +++ b/run-serve.tsx @@ -1,5 +1,5 @@ import * as MIME from "https://deno.land/std@0.180.0/media_types/mod.ts"; -import * as SWCW from "https://esm.sh/@swc/wasm-web@1.3.62"; +import * as SWCW from "https://esm.sh/@swc/wasm-web@1.4.17"; import { HuntConfig } from "./checker.tsx"; import CustomServe from ">able/api.tsx"; @@ -9,6 +9,12 @@ type DenoConfig = {imports:Record}; const ImportMap:DenoConfig = {imports:{}}; let ImportMapProxies:Record = {}; +// (re)scan the project directory looking for the config +// process the found import map: +// - make a copy of the import map +// - change root relative imports that deno needs (starts with "./") to "/" for use in the browser +// - change + const ImportMapReload =async()=> { const [, {json, path}] = await HuntConfig(); @@ -39,7 +45,6 @@ const ImportMapReload =async()=> }); ImportMap.imports = Configuration.Remap(imports, Configuration); - } else { @@ -162,6 +167,7 @@ export const Configure =(config:ConfigurationArgs)=> } + let running = false; export default async()=> { @@ -184,30 +190,34 @@ export default async()=> const ext = Extension(url.pathname); const headers = {"content-type":"application/json", "Access-Control-Allow-Origin": Configuration.Allow, "charset":"UTF-8"}; let proxy = Root + url.pathname; - + + // dont serve hidden files (end file or folder names with "__" to hide) if(url.pathname.includes("__/") || url.pathname.lastIndexOf("__.") > -1) { return new Response(`{"error":"unmatched route", "path":"${url.pathname}"}`, {status:404, headers}); } - + // proxy imports if(url.pathname.startsWith(encodeURI("/>"))) { + console.log(ImportMapProxies); + console.log("checking for", url.pathname) let bestMatch=""; - for(let key in ImportMapProxies) + for(const key in ImportMapProxies) { - if(url.pathname.startsWith(key) && key.length > bestMatch.length) + const match = url.pathname.startsWith(key) && key.length > bestMatch.length; + console.log(`key:${key} match:${match}`); + if(match) { bestMatch = key; } } if(bestMatch.length) { - const match = ImportMapProxies[bestMatch]; + const value = ImportMapProxies[bestMatch]; const path = url.pathname.substring(bestMatch.length); - proxy = path ? match + path : Root + match; - - } + proxy = path ? value + path : Root + value; + } } // allow for custom handlers