Compare commits

..

No commits in common. "c70ab52a1fb86e0879b1624342d12c347d77e72b" and "5efb25541be2317bcdf9ded767652749a00fa166" have entirely different histories.

6 changed files with 35 additions and 74 deletions

View File

@ -3,15 +3,14 @@
"deno.window", "DOM"
]},
"imports": {
"react-original": "https://esm.sh/preact@10.13.2/compat",
"react": "https://esm.sh/preact@10.13.2/compat",
"react-original": "https://esm.sh/react@18.2.0",
"react": "https://esm.sh/react@18.2.0",
"@eno/app": "./dummy-app.tsx"
},
"tasks":
{
"install": "deno install -f -A --unstable --no-lock -n eno server.tsx",
"run": "deno run -A --unstable --no-lock server.tsx",
"complete": "deno run -A --unstable https://deno.land/std@0.181.0/http/file_server.ts & cd example && pwd && deno task dev",
"host": "deno run -A --unstable https://deno.land/std@0.181.0/http/file_server.ts"
}
}

View File

@ -1,11 +0,0 @@
import React from "react";
import Component from "./deep/component.tsx";
export default ()=>{
const [countGet, countSet] = React.useState(1);
return <div class="p-4 font-sans">
<h1 class="my-2 font(bold serif) text(2xl)">Title!!</h1>
<h2>subtitle</h2>
<Component/>
</div>;
};

View File

@ -1,9 +0,0 @@
import React from "react";
export default ()=>
{
const [countGet, countSet] = React.useState(1);
return <div class="p-4 text-red-500">
Component!!!
</div>;
};

View File

@ -1,11 +0,0 @@
{
"imports":
{
"react": "https://esm.sh/preact@10.13.2/compat",
"@deep/": "./deep/",
"@eno/app": "./app.tsx"
},
"tasks": {
"dev": "deno run -A --unstable --reload=http://localhost:4507/ --no-lock --config=deno.json http://localhost:4507/server.tsx"
}
}

View File

@ -73,5 +73,4 @@ const ProxyState =(arg)=>
export * from "react-original";
export { ProxyCreate as createElement, ProxyState as useState };
export const isProxy = true;
export default {...ReactParts.default, createElement:ProxyCreate, useState:ProxyState, isProxy:true};
export default {...ReactParts.default, createElement:ProxyCreate, useState:ProxyState};

View File

@ -1,8 +1,6 @@
import * as ESBuild from 'https://deno.land/x/esbuild@v0.14.45/mod.js';
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/deno/preact-render-to-string.mjs";
import React, {createElement as h} from "react";
const Transpiled = new Map();
const Transpileable =(inFilePath:string):boolean=>
@ -126,8 +124,38 @@ catch(e)
{
console.log(`deno.json not found`);
}
const Index = `
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="importmap">${JSON.stringify(ImportObject)}</script>
<script async src="https://ga.jspm.io/npm:es-module-shims@1.5.1/dist/es-module-shims.js" crossorigin="anonymous"></script>
</head>
<body>
<div id="app">Loading</div>
<script type="module">
import * as TW from "https://esm.sh/@twind/core@1.0.1";
import TWPreTail from "https://esm.sh/@twind/preset-tailwind@1.0.1";
import TWPreAuto from "https://esm.sh/@twind/preset-autoprefix@1.0.1";
const Configure = {presets: [TWPreTail(), TWPreAuto()]};
const ShadowDOM = document.querySelector("#app").attachShadow({mode: "open"});
const ShadowDiv = document.createElement("div");
const ShadowCSS = document.createElement("style");
ShadowDOM.append(ShadowCSS);
ShadowDOM.append(ShadowDiv);
const App = await import("@eno/app");
TW.observe(TW.twind(Configure, TW.cssom(ShadowCSS)), ShadowDiv);
import App from "@eno/app";
import {render, createElement as H} from "react";
render(H(()=>H(App)), ShadowDiv);
</script>
</body>
</html>
`;
Deno.serve({ port: 3000 }, async(_req:Request) =>
{
@ -165,7 +193,7 @@ Deno.serve({ port: 3000 }, async(_req:Request) =>
{
// serve index by default
let type = `text/html`;
let body:BodyInit = ``;
let body:BodyInit = Index;
const isLib = url.pathname.startsWith(`/${LibPath}/`)
@ -218,40 +246,6 @@ FileListen("${url.pathname}", reloadHandler);`;
body = await Deno.readFile(fsPath);
}
}
else
{
type = `text/html`;
body = `<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="importmap">${JSON.stringify(ImportObject)}</script>
<script async src="https://ga.jspm.io/npm:es-module-shims@1.5.1/dist/es-module-shims.js" crossorigin="anonymous"></script>
</head>
<body>
<div id="app">${SSR(<App.default/>)}</div>
<script type="module">
import * as TW from "https://esm.sh/@twind/core@1.0.1";
import TWPreTail from "https://esm.sh/@twind/preset-tailwind@1.0.1";
import TWPreAuto from "https://esm.sh/@twind/preset-autoprefix@1.0.1";
const Configure = {presets: [TWPreTail(), TWPreAuto()]};
const ShadowDOM = document.querySelector("#app").attachShadow({mode: "open"});
const ShadowDiv = document.createElement("div");
const ShadowCSS = document.createElement("style");
ShadowDOM.append(ShadowCSS);
ShadowDOM.append(ShadowDiv);
TW.observe(TW.twind(Configure, TW.cssom(ShadowCSS)), ShadowDiv);
import App from "@eno/app";
import {render, createElement as H} from "react";
render(H(()=>H(App)), ShadowDiv);
</script>
</body>
</html>`;
}
return new Response(body, {headers:{"content-type":type as string}});
}