#10 issue/iso-file-serving #11
@ -6,13 +6,14 @@
 | 
				
			|||||||
        "react": "https://esm.sh/preact@10.13.2/compat",
 | 
					        "react": "https://esm.sh/preact@10.13.2/compat",
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        "react-original": "https://esm.sh/preact@10.13.2/compat",
 | 
					        "react-original": "https://esm.sh/preact@10.13.2/compat",
 | 
				
			||||||
        "@eno/app": "./example/app.tsx"
 | 
					        "@eno/app": "./example/app.tsx",
 | 
				
			||||||
 | 
					        "@eno/iso": "./lib/iso.tsx"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "tasks":
 | 
					    "tasks":
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        "install": "deno install -f -A --unstable --no-lock -n eno server.tsx",
 | 
					        "install": "deno install -f -A --unstable --no-lock -n eno server.tsx",
 | 
				
			||||||
        "run": "deno run -A --unstable --no-lock 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",
 | 
				
			||||||
        "host": "deno run -A --unstable https://deno.land/std@0.181.0/http/file_server.ts"
 | 
					        "complete": "deno task host & cd example && pwd && deno task dev"
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -2,9 +2,11 @@ import TWPreTail from "https://esm.sh/@twind/preset-tailwind@1.1.4";
 | 
				
			|||||||
import TWPreAuto from "https://esm.sh/@twind/preset-autoprefix@1.0.7";
 | 
					import TWPreAuto from "https://esm.sh/@twind/preset-autoprefix@1.0.7";
 | 
				
			||||||
import React from "react";
 | 
					import React from "react";
 | 
				
			||||||
import Component from "./deep/component.tsx";
 | 
					import Component from "./deep/component.tsx";
 | 
				
			||||||
 | 
					import * as Iso from "@eno/iso";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default ()=>
 | 
					export default ()=>
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    console.log(Iso.Meta);
 | 
				
			||||||
    const [countGet, countSet] = React.useState(1);   
 | 
					    const [countGet, countSet] = React.useState(1);   
 | 
				
			||||||
    return <div class="p-4 font-sans">
 | 
					    return <div class="p-4 font-sans">
 | 
				
			||||||
        <h1 class="my-2 font(bold serif) text(2xl)">Title!!</h1>
 | 
					        <h1 class="my-2 font(bold serif) text(2xl)">Title!!</h1>
 | 
				
			||||||
 | 
				
			|||||||
@ -3,9 +3,10 @@
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        "react": "https://esm.sh/preact@10.13.2/compat",
 | 
					        "react": "https://esm.sh/preact@10.13.2/compat",
 | 
				
			||||||
        "@deep/": "./deep/",
 | 
					        "@deep/": "./deep/",
 | 
				
			||||||
        "@eno/app": "./app.tsx"
 | 
					        "@eno/app": "./app.tsx",
 | 
				
			||||||
 | 
					        "@eno/iso": "http://localhost:4507/lib/iso.tsx"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "tasks": {
 | 
					    "tasks": {
 | 
				
			||||||
        "dev": "deno run -A --unstable --reload=http://localhost:4507/ --no-lock --config=deno.json http://localhost:4507/server.tsx"
 | 
					        "dev": "deno run -A --unstable --reload=http://localhost:4507/ --no-lock --config=deno.json 'http://localhost:4507/server.tsx?reload=1'"
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
							
								
								
									
										10
									
								
								lib/iso.tsx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								lib/iso.tsx
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,10 @@
 | 
				
			|||||||
 | 
					import React from "react";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type Metas = {
 | 
				
			||||||
 | 
					    Title?:string,
 | 
				
			||||||
 | 
					    Description?:string
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const Meta:Metas = {
 | 
				
			||||||
 | 
					    Title:"hey"
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
							
								
								
									
										24
									
								
								server.tsx
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								server.tsx
									
									
									
									
									
								
							@ -2,7 +2,8 @@ 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 * 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 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 React, {createElement as h} from "react";
 | 
					import * as Twind from "https://esm.sh/@twind/core@1.1.3";
 | 
				
			||||||
 | 
					import React, {JSX, createElement as h} from "react";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const Transpiled = new Map();
 | 
					const Transpiled = new Map();
 | 
				
			||||||
const Transpileable =(inFilePath:string):boolean=>
 | 
					const Transpileable =(inFilePath:string):boolean=>
 | 
				
			||||||
@ -115,6 +116,15 @@ try
 | 
				
			|||||||
            console.log(`"imports" configuration does not alias an entry-point component with "@eno/app"`);
 | 
					            console.log(`"imports" configuration does not alias an entry-point component with "@eno/app"`);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 | 
					        const importIso = ImportObject.imports["@eno/iso"];
 | 
				
			||||||
 | 
					        if(importIso)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            ImportObject.imports["@eno/iso"] = `./${LibPath}/iso.tsx`;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@ -127,12 +137,8 @@ catch(e)
 | 
				
			|||||||
    console.log(`deno.json not found`);
 | 
					    console.log(`deno.json not found`);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import {default as App, CSS} from "@eno/app";
 | 
					 | 
				
			||||||
import * as Twind from "https://esm.sh/@twind/core@1.1.3";
 | 
					 | 
				
			||||||
const TwindInst = Twind.install(CSS);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Deno.serve({ port: Deno.args[0]||3000 }, async(_req:Request) =>
 | 
				
			||||||
Deno.serve({ port: 3000 }, async(_req:Request) =>
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    const url:URL = new URL(_req.url);
 | 
					    const url:URL = new URL(_req.url);
 | 
				
			||||||
    const fsPath = Deno.cwd()+url.pathname;
 | 
					    const fsPath = Deno.cwd()+url.pathname;
 | 
				
			||||||
@ -247,7 +253,7 @@ FileListen("${url.pathname}", reloadHandler);`;
 | 
				
			|||||||
</html>`;
 | 
					</html>`;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return new Response(body, {headers:{"content-type":type as string}});
 | 
					        return new Response(body, {headers:{"content-type":type as string, "Access-Control-Allow-Origin":"*"}});
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    catch(error)
 | 
					    catch(error)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@ -256,6 +262,8 @@ FileListen("${url.pathname}", reloadHandler);`;
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import App, {CSS} from "@eno/app";
 | 
				
			||||||
 | 
					const TwindInst = Twind.install(CSS);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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); } }
 | 
				
			||||||
@ -277,7 +285,7 @@ const ProcessFiles =debounce(async()=>
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            Transpiled.delete(key)
 | 
					            Transpiled.delete(key);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    FilesChanged.clear();
 | 
					    FilesChanged.clear();
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user