Compare commits

..

No commits in common. "circular-imports" and "testing-no-dynamic-01" have entirely different histories.

4 changed files with 26 additions and 36 deletions

View File

@ -1,7 +1,13 @@
{ {
"compilerOptions": {"lib": ["deno.window", "dom"]}, "compilerOptions": {"lib": ["deno.window", "dom"]},
"importMap": "./deno.map.json", "imports":
{
"react": "https://esm.sh/stable/preact@10.13.2/compat",
"preact": "https://esm.sh/stable/preact@10.13.2/",
"@deep/": "./deep/",
"@eno/iso": "http://localhost:4507/lib/iso.tsx"
},
"tasks": { "tasks": {
"dev": "deno run -A --unstable --reload=http://localhost:4507/ --no-lock app.tsx --dev" "dev": "deno run -A --unstable --reload=http://localhost:4507/ --no-lock app.tsx"
} }
} }

View File

@ -1,10 +0,0 @@
{
"imports":
{
"react": "https://esm.sh/stable/preact@10.13.2/compat",
"preact": "https://esm.sh/stable/preact@10.13.2/",
"@deep/": "./deep/",
"@eno/iso": "http://localhost:4507/lib/iso.tsx",
"@eno/app": "./app.tsx"
}
}

View File

@ -1,6 +1,6 @@
import TWPreTail from "https://esm.sh/v115/@twind/preset-tailwind@1.1.4/es2022/preset-tailwind.mjs"; 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 TWPreAuto from "https://esm.sh/v115/@twind/preset-autoprefix@1.0.7/es2022/preset-autoprefix.mjs";
import React, {createElement as h} from "react"; import React from "react";
import { Boot as _Boot } from "../server.tsx"; import { Boot as _Boot } from "../server.tsx";
export const CSS = { export const CSS = {

View File

@ -2,23 +2,13 @@ import * as ESBuild from 'https://deno.land/x/esbuild@v0.17.4/mod.js';
import * as MIME from "https://deno.land/std@0.180.0/media_types/mod.ts"; 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 { debounce } from "https://deno.land/std@0.151.0/async/debounce.ts";
import { parse as JSONC} from "https://deno.land/std@0.185.0/jsonc/mod.ts"; import { parse as JSONC} from "https://deno.land/std@0.185.0/jsonc/mod.ts";
import * as HTTP from "https://deno.land/std@0.185.0/http/server.ts" import { toFileUrl } from "https://deno.land/std@0.185.0/path/mod.ts";
import SSR from "https://esm.sh/v113/preact-render-to-string@6.0.2"; import SSR from "https://esm.sh/v113/preact-render-to-string@6.0.2";
import Prepass from "https://esm.sh/preact-ssr-prepass@1.2.0"; import Prepass from "https://esm.sh/preact-ssr-prepass@1.2.0";
import * as Twind from "https://esm.sh/@twind/core@1.1.3"; import * as Twind from "https://esm.sh/@twind/core@1.1.3";
import React, {createElement as h} from "react"; import React from "react";
import * as Iso from "@eno/iso"; import * as Iso from "@eno/iso";
/**
* things you cant do on deno deploy:
* imports inside deno.json
* dynamic imports
* Deno.mainModule
* Deno.serve
* unspecified h
* ESBuild
*/
/** /**
* Setup a transpiler. * Setup a transpiler.
* @param inDevMode When true, starts a file-watcher * @param inDevMode When true, starts a file-watcher
@ -75,7 +65,7 @@ function Transpiler(inDevMode:boolean)
const Sockets:Set<WebSocket> = new Set(); const Sockets:Set<WebSocket> = new Set();
const SocketsBroadcast =(inData:string)=>{ for (const socket of Sockets){ socket.send(inData); } } const SocketsBroadcast =(inData:string)=>{ for (const socket of Sockets){ socket.send(inData); } }
const SocketsHandler = inDevMode ? (_req:Request):false|Response=> const SocketsHandler = inDevMode ? (_req:Request)=>
{ {
if(_req.headers.get("upgrade") == "websocket") if(_req.headers.get("upgrade") == "websocket")
{ {
@ -96,7 +86,7 @@ function Transpiler(inDevMode:boolean)
return false; return false;
} }
: :
():false=>false; ()=>false;
const watcher =async()=> const watcher =async()=>
{ {
@ -254,9 +244,7 @@ const Path = {
}; };
console.log(Path); console.log(Path);
console.log(`Dev Mode: ${DevMode}`); console.log(`Dev Mode: ${DevMode}`);
console.log(`import.meta.url:`, import.meta.url); console.log(`Args seen: `, Deno.env.toObject);
console.log(`Deno.cwd():`, Deno.cwd());
console.log(`Deno.mainModule:`, Deno.mainModule);
let Booted = false; let Booted = false;
@ -266,13 +254,19 @@ export function Boot(inApp:React.FunctionComponent, inCSS?:object)
if(Booted){return;} if(Booted){return;}
Booted = true; Booted = true;
const pathInit = Deno.mainModule;
const pathProj = toFileUrl(Deno.cwd());
//@ts-ignore //@ts-ignore
TwindInst = Twind.install({...Iso.CSS, ...inCSS||{}}); TwindInst = Twind.install({...Iso.CSS, ...inCSS||{}});
Server(inApp, TwindInst); const App = inApp;
Path.AppDir = pathInit.split(pathProj.toString())[1];
Server(App, Path.AppDir, TwindInst);
} }
async function Server(App:React.FunctionComponent, TwindInst:Twind.Twind) async function Server(App:React.FunctionComponent, AppPath:string, TwindInst:Twind.Twind)
{ {
const {Transpileable, TranspileURL, SocketsHandler} = Transpiler(DevMode); const {Transpileable, TranspileURL, SocketsHandler} = Transpiler(DevMode);
const {Imports, Error} = await Configure(DevMode, Path.LibDir); const {Imports, Error} = await Configure(DevMode, Path.LibDir);
@ -282,7 +276,7 @@ async function Server(App:React.FunctionComponent, TwindInst:Twind.Twind)
} }
else if(App && TwindInst) else if(App && TwindInst)
{ {
HTTP.serve(async(_req:Request) => Deno.serve({ port: Deno.env.get("port")||3000 }, async(_req:Request) =>
{ {
const url:URL = new URL(_req.url); 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 pathParts = url.pathname.substring(1, url.pathname.endsWith("/") ? url.pathname.length-1 : url.pathname.length).split("/");
@ -390,7 +384,7 @@ async function Server(App:React.FunctionComponent, TwindInst:Twind.Twind)
import {Fetch} from "@eno/iso"; import {Fetch} from "@eno/iso";
Fetch.Seed(${JSON.stringify(seed)}); Fetch.Seed(${JSON.stringify(seed)});
import "@eno/app"; import "${AppPath}";
</script> </script>
</body> </body>
</html>`; </html>`;
@ -403,6 +397,6 @@ async function Server(App:React.FunctionComponent, TwindInst:Twind.Twind)
console.log(error); console.log(error);
return new Response(error, {status:404}); return new Response(error, {status:404});
} }
}, { port: parseInt(Deno.env.get("port")||"3000" )}); });
} }
} }