From d9801f3e952b0e1c3cafd630e2c3e890c54a42aa Mon Sep 17 00:00:00 2001 From: Seth Trowbridge Date: Sun, 5 May 2024 16:03:00 -0400 Subject: [PATCH] adjust import proxies something was very wrong and could still be... --- app.tsx | 6 +++++- deno.jsonc | 5 +++-- deno.lock | 32 ++++++++++++++++++++++++++++++++ run-local.tsx | 3 ++- run-serve.tsx | 47 +++++++++-------------------------------------- 5 files changed, 51 insertions(+), 42 deletions(-) create mode 100644 deno.lock diff --git a/app.tsx b/app.tsx index b92be06..787f4b5 100644 --- a/app.tsx +++ b/app.tsx @@ -1,3 +1,7 @@ +import * as ISO from ">able/iso-elements.tsx"; + +console.log(ISO) + export default ()=>
-

App!

+

App

; \ No newline at end of file diff --git a/deno.jsonc b/deno.jsonc index c729253..ca2dea8 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -3,11 +3,12 @@ "react": "https://esm.sh/preact@10.20.2/compat", "react-original": "https://esm.sh/preact@10.20.2/compat", + "react-original/": "https://esm.sh/preact@10.20.2/compat/", "react/": "https://esm.sh/preact@10.20.2/compat/", "@preact/signals": "https://esm.sh/@preact/signals@1.2.3?deps=preact@10.20.2", - "@twind/core": "https://esm.sh/@twind/core@1.1.3", - + "@twind/core": "https://esm.sh/v126/@twind/core@1.1.3/es2022/core.mjs", + ">other/": "https://esm.sh/", ">able/": "./", ">able/app.tsx": "./app.tsx" }, diff --git a/deno.lock b/deno.lock new file mode 100644 index 0000000..3983028 --- /dev/null +++ b/deno.lock @@ -0,0 +1,32 @@ +{ + "version": "3", + "remote": { + "https://deno.land/std@0.180.0/media_types/_db.ts": "7606d83e31f23ce1a7968cbaee852810c2cf477903a095696cdc62eaab7ce570", + "https://deno.land/std@0.180.0/media_types/_util.ts": "916efbd30b6148a716f110e67a4db29d6949bf4048997b754415dd7e42c52378", + "https://deno.land/std@0.180.0/media_types/content_type.ts": "c682589a0aeb016bfed355cc1ed6fbb3ead2ea48fc0000ac5de6a5730613ad1c", + "https://deno.land/std@0.180.0/media_types/extension.ts": "7a4ef2813d7182f724a941f38161525996e4a67abc3cf6a0f9bc2168d73a0f0e", + "https://deno.land/std@0.180.0/media_types/extensions_by_type.ts": "4358023feac696e6e9d49c0f1e76a859f03ca254df57812f31f8536890c3a443", + "https://deno.land/std@0.180.0/media_types/format_media_type.ts": "1e35e16562e5c417401ffc388a9f8f421f97f0ee06259cbe990c51bae4e6c7a8", + "https://deno.land/std@0.180.0/media_types/get_charset.ts": "8be15a1fd31a545736b91ace56d0e4c66ea0d7b3fdc5c90760e8202e7b4b1fad", + "https://deno.land/std@0.180.0/media_types/mod.ts": "d3f0b99f85053bc0b98ecc24eaa3546dfa09b856dc0bbaf60d8956d2cdd710c8", + "https://deno.land/std@0.180.0/media_types/parse_media_type.ts": "bed260d868ea271445ae41d748e7afed9b5a7f407d2777ead08cecf73e9278de", + "https://deno.land/std@0.180.0/media_types/type_by_extension.ts": "6076a7fc63181d70f92ec582fdea2c927eb2cfc7f9c9bee9d6add2aca86f2355", + "https://deno.land/std@0.180.0/media_types/vendor/mime-db.v1.52.0.ts": "6925bbcae81ca37241e3f55908d0505724358cda3384eaea707773b2c7e99586", + "https://deno.land/std@0.194.0/_util/asserts.ts": "178dfc49a464aee693a7e285567b3d0b555dc805ff490505a8aae34f9cfb1462", + "https://deno.land/std@0.194.0/collections/filter_values.ts": "5b9feaf17b9a6e5ffccdd36cf6f38fa4ffa94cff2602d381c2ad0c2a97929652", + "https://deno.land/std@0.194.0/collections/without_all.ts": "a89f5da0b5830defed4f59666e188df411d8fece35a5f6ca69be6ca71a95c185", + "https://deno.land/std@0.194.0/dotenv/mod.ts": "39e5d19e077e55d7e01ea600eb1c6d1e18a8dfdfc65d68826257a576788da3a4", + "https://deno.land/std@0.194.0/flags/mod.ts": "17f444ddbee43c5487568de0c6a076c7729cfe90d96d2ffcd2b8f8adadafb6e8", + "https://deno.land/x/jsonct@v0.1.0/mod.ts": "dba7e7f3529be6369f5c718e3a18b69f15ffa176006d2a7565073ce6c5bd9f3f", + "https://deno.land/x/jsonct@v0.1.0/src/_util/asserts.ts": "178dfc49a464aee693a7e285567b3d0b555dc805ff490505a8aae34f9cfb1462", + "https://deno.land/x/jsonct@v0.1.0/src/parse.ts": "a3a016822446b0584b40bae9098df480db5590a9915c9e3c623ba2801cf1b8df", + "https://esm.sh/@swc/wasm-web@1.3.62": "b43fb5cde95beb7736182fa62250235dfa6b71717b9d38aa4e6077f05ec90e5e", + "https://esm.sh/preact@10.20.2/compat/jsx-runtime": "e3942a5ffd734d5eaf0790ada3ed4ad81c0c0c2ff56a8e4740247de259f7fb65", + "https://esm.sh/stable/preact@10.20.2/denonext/compat.js": "2e0564fd10e09b587503f9ecd4407ac8726c79beae80026ac89034a47b270c68", + "https://esm.sh/stable/preact@10.20.2/denonext/compat/jsx-runtime.js": "fbbbceb98af95d1c73181f9e5043fad6cdae30ef9e5fcf90d44ffd6fa6055c02", + "https://esm.sh/stable/preact@10.20.2/denonext/hooks.js": "91d64a217b2f2c9f724042d0ed1b87bf3edf721261e86358aa6fd55501ee915f", + "https://esm.sh/stable/preact@10.20.2/denonext/jsx-runtime.js": "2a5b981955e92e3ff86906ac0e5955ec0e6e5ca71032f3f063912cb85ae9a7f1", + "https://esm.sh/stable/preact@10.20.2/denonext/preact.mjs": "f418bc70c24b785703afb9d4dea8cdc1e315e43c8df620a0c52fd27ad9bd70eb", + "https://esm.sh/v135/@swc/wasm-web@1.3.62/denonext/wasm-web.mjs": "57046d46c9ef1398a294ba7447034f5966e48866a05c309cccec4bb4d6e7c61b" + } +} diff --git a/run-local.tsx b/run-local.tsx index a845712..c77fa7c 100644 --- a/run-local.tsx +++ b/run-local.tsx @@ -1,4 +1,5 @@ -import {Configure, Transpile, Extension, Root} from "./run-serve.tsx"; +import {Configure, Transpile, Extension} from "./run-serve.tsx"; +import { Root } from "./checker.tsx"; import * as Collect from "./hmr-static.tsx"; const SocketsLive:Set = new Set(); diff --git a/run-serve.tsx b/run-serve.tsx index cb61263..2a34f58 100644 --- a/run-serve.tsx +++ b/run-serve.tsx @@ -1,49 +1,33 @@ 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 { HuntConfig } from "./checker.tsx"; +import { HuntConfig, Root } from "./checker.tsx"; import CustomServe from ">able/api.tsx"; -export const Root = new URL(`file://${Deno.cwd().replaceAll("\\", "/")}`).toString(); - type DenoConfig = {imports:Record}; const ImportMap:DenoConfig = {imports:{}}; -let ImportMapProxies:Record = {}; const ImportMapReload =async()=> { - const [, {json, path}] = await HuntConfig(); + const [, {json}] = await HuntConfig(); const imports = (json as DenoConfig).imports; if(imports) { - ImportMapProxies = {}; Object.entries(imports).forEach(([key, value])=> { + // re-write deno project-relative paths (e.g. "./app.tsx") to root-relative for the browser ("/app.tsx"); if(value.startsWith("./")) { imports[key] = value.substring(1); } - if(key.startsWith(">")) + + if(key.startsWith(">") && key.endsWith("/")) { - if(value.startsWith("./")) - { - ImportMapProxies[encodeURI(key)] = value.substring(1); - imports[key] = value.substring(1); - } - else - { - ImportMapProxies["/"+encodeURI(key)] = value; - imports[key] = "/"+key; - } + imports[key] = "/"+key; } }); ImportMap.imports = Configuration.Remap(imports, Configuration); - - } - else - { - } }; @@ -193,21 +177,9 @@ export default async()=> // proxy imports if(url.pathname.startsWith(encodeURI("/>"))) { - let bestMatch=""; - for(let key in ImportMapProxies) - { - if(url.pathname.startsWith(key) && key.length > bestMatch.length) - { - bestMatch = key; - } - } - if(bestMatch.length) - { - const match = ImportMapProxies[bestMatch]; - const path = url.pathname.substring(bestMatch.length); - proxy = path ? match + path : Root + match; - - } + /** pathname with no leading slash */ + const clippedPath = decodeURI(url.pathname.substring(1)); + proxy = import.meta.resolve(clippedPath); } // allow for custom handlers @@ -225,7 +197,6 @@ export default async()=> // transpileable files if(Transpile.Check(ext)) { - console.log("transpiling:", proxy); const code = await Transpile.Fetch(proxy, url.pathname); if(code) {