api #3
@ -7,8 +7,6 @@
|
|||||||
{
|
{
|
||||||
"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",
|
"react-original":"https://esm.sh/preact@10.15.1/compat",
|
||||||
"able/": "http://localhost:1234/",
|
|
||||||
"able:app": "./example/app.tsx",
|
|
||||||
">able/": "https://gitea.hptrow.me/SethTrowbridge/able-baker/raw/branch/master/"
|
">able/": "https://gitea.hptrow.me/SethTrowbridge/able-baker/raw/branch/master/"
|
||||||
},
|
},
|
||||||
"tasks":
|
"tasks":
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Router, Switch, Case } from "able/iso-elements.tsx";
|
import { Router, Switch, Case } from ">able/iso-elements.tsx";
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ export default ()=>
|
|||||||
return <CTXString.Provider value="intradestink">
|
return <CTXString.Provider value="intradestink">
|
||||||
<Router.Provider>
|
<Router.Provider>
|
||||||
<div class="my-4 font-sans">
|
<div class="my-4 font-sans">
|
||||||
<h1 class="font-black text-xl text-red-500">Title</h1>
|
<h1 class="font-black text-xl text-red-500">Title?????</h1>
|
||||||
<h2 class="font-black text-blue-500 p-4">subtitle</h2>
|
<h2 class="font-black text-blue-500 p-4">subtitle</h2>
|
||||||
<p>
|
<p>
|
||||||
<button onClick={e=>Dispatch(1)}>{Store.name}|{Store.age}?</button>
|
<button onClick={e=>Dispatch(1)}>{Store.name}|{Store.age}?</button>
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
"imports":
|
"imports":
|
||||||
{
|
{
|
||||||
"react": "https://esm.sh/preact@10.15.1/compat",
|
"react": "https://esm.sh/preact@10.15.1/compat",
|
||||||
"able/": "http://localhost:1234/",
|
">able/app.tsx": "./app.tsx",
|
||||||
"entry": "./app.tsx"
|
">able/": "http://localhost:4507/"
|
||||||
},
|
},
|
||||||
"tasks":
|
"tasks":
|
||||||
{
|
{
|
||||||
"local": "deno run -A --no-lock --reload=http://localhost:1234 http://localhost:1234/run-local.tsx",
|
"local": "deno run -A --no-lock --reload=http://localhost:4507/ http://localhost:4507/run-local.tsx",
|
||||||
"serve": "deno run -A --no-lock --reload=http://localhost:1234 http://localhost:1234/run-serve.tsx"
|
"serve": "deno run -A --no-lock --reload=http://localhost:4507/ http://localhost:4507/run-serve.tsx"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,15 +0,0 @@
|
|||||||
|
|
||||||
import * as Util from "@able/";
|
|
||||||
import * as React from "react";
|
|
||||||
import {createElement} from "react/client";
|
|
||||||
|
|
||||||
import('react').then((module) => {
|
|
||||||
console.log(module);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
function unimport(n:number)
|
|
||||||
{
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
unimport(123)
|
|
@ -22,18 +22,23 @@ Configure({
|
|||||||
Remap: (inImports, inConfig)=>
|
Remap: (inImports, inConfig)=>
|
||||||
{
|
{
|
||||||
inImports["react-original"] = inImports["react"];
|
inImports["react-original"] = inImports["react"];
|
||||||
inImports["react"] = import.meta.resolve(`./hmr-react.tsx`);
|
inImports["react"] = `/>able/hmr-react.tsx`;
|
||||||
return inImports;
|
return inImports;
|
||||||
},
|
},
|
||||||
async Serve(inReq, inURL, inExt, inMap, inConfig)
|
async Serve(inReq, inURL, inExt, inMap, inConfig)
|
||||||
|
{
|
||||||
|
if(!inURL.pathname.startsWith(encodeURI("/>")))
|
||||||
{
|
{
|
||||||
if(Transpile.Check(inExt) && !inURL.searchParams.get("reload"))
|
if(Transpile.Check(inExt) && !inURL.searchParams.get("reload"))
|
||||||
{
|
{
|
||||||
|
|
||||||
// we dont need to add ?reload= because this fetch is by way the file system not the hosted url
|
// we dont need to add ?reload= because this fetch is by way the file system not the hosted url
|
||||||
|
|
||||||
|
console.log("collecting exports for", Root+inURL.pathname);
|
||||||
|
|
||||||
const [local, foreign] = await Collect.FileExports(Root+inURL.pathname);
|
const [local, foreign] = await Collect.FileExports(Root+inURL.pathname);
|
||||||
const code =`
|
const code =`
|
||||||
import {FileListen} from "${import.meta.resolve(`./hmr-listen.tsx`)}";
|
import {FileListen} from ">able/hmr-listen.tsx";
|
||||||
import * as Import from "${inURL.pathname}?reload=0";
|
import * as Import from "${inURL.pathname}?reload=0";
|
||||||
${ local.map(m=>`let proxy_${m} = Import.${m}; export { proxy_${m} as ${m} };`).join("\n") }
|
${ local.map(m=>`let proxy_${m} = Import.${m}; export { proxy_${m} as ${m} };`).join("\n") }
|
||||||
FileListen("${inURL.pathname}", (updatedModule)=>
|
FileListen("${inURL.pathname}", (updatedModule)=>
|
||||||
@ -61,6 +66,12 @@ ${ foreign.join(";\n") }
|
|||||||
catch(e){ /**/ }
|
catch(e){ /**/ }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
console.log("not collecting", inURL.pathname)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const Watcher =async()=>
|
const Watcher =async()=>
|
||||||
@ -82,7 +93,7 @@ const Watcher =async()=>
|
|||||||
const key = path.substring(Deno.cwd().length).replaceAll("\\", "/");
|
const key = path.substring(Deno.cwd().length).replaceAll("\\", "/");
|
||||||
if(action != "remove")
|
if(action != "remove")
|
||||||
{
|
{
|
||||||
const tsx = await Transpile.Fetch(`file://${Deno.cwd().replaceAll("\\", "/")}`+key, key, true);
|
const tsx = await Transpile.Fetch(Root+key, key, true);
|
||||||
tsx && SocketsSend(key);
|
tsx && SocketsSend(key);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -56,11 +56,19 @@ const ImportMapReload =async()=>
|
|||||||
{
|
{
|
||||||
json.imports[key] = value.substring(1);
|
json.imports[key] = value.substring(1);
|
||||||
}
|
}
|
||||||
if(key.startsWith(">")||key.startsWith("able/"))
|
if(key.startsWith(">"))
|
||||||
|
{
|
||||||
|
if(value.startsWith("./"))
|
||||||
|
{
|
||||||
|
ImportMapProxies[encodeURI(key)] = value.substring(1);
|
||||||
|
json.imports[key] = value.substring(1);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
ImportMapProxies["/"+encodeURI(key)] = value;
|
ImportMapProxies["/"+encodeURI(key)] = value;
|
||||||
json.imports[key] = "/"+key;
|
json.imports[key] = "/"+key;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ImportMap.imports = Configuration.Remap(json.imports, Configuration);
|
ImportMap.imports = Configuration.Remap(json.imports, Configuration);
|
||||||
@ -92,8 +100,8 @@ let Configuration:Configuration =
|
|||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<script type="importmap">${JSON.stringify(inMap)}</script>
|
<script type="importmap">${JSON.stringify(inMap)}</script>
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import Mount from "${import.meta.resolve("./run-browser.tsx")}";
|
import Mount from ">able/run-browser.tsx";
|
||||||
Mount("#app", "able:app");
|
Mount("#app", ">able/app.tsx");
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>`, {status:200, headers:{"content-type":"text/html"}});
|
</html>`, {status:200, headers:{"content-type":"text/html"}});
|
||||||
@ -296,9 +304,13 @@ const server = Deno.serve({port:parseInt(Deno.env.get("port")||"8000")}, async(r
|
|||||||
}
|
}
|
||||||
if(bestMatch.length)
|
if(bestMatch.length)
|
||||||
{
|
{
|
||||||
proxy = ImportMapProxies[bestMatch] + url.pathname.substring(bestMatch.length);
|
const match = ImportMapProxies[bestMatch];
|
||||||
|
const path = url.pathname.substring(bestMatch.length);
|
||||||
|
proxy = path ? match + path : Root + match;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log("proxy will be", proxy);
|
||||||
|
|
||||||
// allow for custom handler
|
// allow for custom handler
|
||||||
const custom = await Configuration.Serve(req, url, ext, ImportMap, Configuration);
|
const custom = await Configuration.Serve(req, url, ext, ImportMap, Configuration);
|
||||||
@ -310,6 +322,7 @@ const server = Deno.serve({port:parseInt(Deno.env.get("port")||"8000")}, async(r
|
|||||||
// transpileable files
|
// transpileable files
|
||||||
if(Transpile.Check(ext))
|
if(Transpile.Check(ext))
|
||||||
{
|
{
|
||||||
|
console.log("transpiling:", proxy);
|
||||||
const code = await Transpile.Fetch(proxy, url.pathname);
|
const code = await Transpile.Fetch(proxy, url.pathname);
|
||||||
if(code)
|
if(code)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user