gale implementation started

This commit is contained in:
Seth Trowbridge 2025-10-30 16:39:25 -04:00
parent cf9bb45a62
commit f27e71839f
11 changed files with 78 additions and 15 deletions

65
app-gale.js Normal file
View File

@ -0,0 +1,65 @@
/** @import * as TYPES from "./graph/types.ts" */
import * as FSHandle from "./store-directory-handle.js";
const {Div, DOM} = Gale({
Title:{
padding:"2rem",
background: "blue",
color:"white"
},
Plain:{}
})
/** @type {Van.State<Record<string, TYPES.GraphParts>>} */
const rooms = van.state({});
async function EvaluateHandle()
{
try
{
const module = await import("./data/room.js"+"?rand="+Math.random());
/** @type {Record<string, TYPES.GraphParts>} */
const read = module.default();
console.log("rooms found:", read);
rooms.val = read;
}
catch(e)
{
console.log("rooms read error:", e);
rooms.val = {};
}
}
let handle = await FSHandle.getDirectoryHandle();
EvaluateHandle();
/** @type {(pass:TYPES.Pass)=>HTMLElement} */
function Pass(pass)
{
return Div.Plain(
Div.Title(
DOM.span.Plain(pass.name),
DOM.span.Plain(pass.path),
)
)
}
function App()
{
return Div.Plain(
DOM.button({
async onclick(){
handle = await showDirectoryPicker();
await FSHandle.setDirectoryHandle(handle);
EvaluateHandle();
}
}, "Pick Directory"),
Object.entries(rooms.val).map(([room_id, graphParts])=>
Object.entries(graphParts.Pass).map(([pass_id, pass])=>{
return Pass(pass)
})
)
)
}
van.add(document.body, App);

View File

@ -1,7 +1,8 @@
/** @import * as TYPES from "./types.ts" */
/** @import * as TYPES from "./graph/types.ts" */
import * as FSHandle from "./store-directory-handle.js";
/** @type {(type:string, attributes?:Record<string, string>, ...children:Array<string|HTMLElement>)=>HTMLElement} */
const H =(type, attributes={}, ...children)=> {
const el =document.createElement(type);

View File

@ -1,8 +1,8 @@
{
"compilerOptions": {
"compilerOptions":
{
"checkJs": true,
"lib":[
"deno.window", "dom"
]
"lib": ["deno.window", "DOM"],
"types": ["https://treetopflyer.github.io/gale/types.d.ts"]
}
}

View File

@ -6,15 +6,12 @@
</head>
<body>
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/service-worker.js', {type:"module"})
.then(reg => console.log('Service Worker registered:', reg))
.catch(err => console.error('Service Worker registration failed:', err));
}
</script>
<script src="app.js" type="module">
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/service-worker.js', {type:"module"})
.then(reg => console.log('Service Worker registered:', reg))
.catch(err => console.error('Service Worker registration failed:', err));
}
</script>
<script type="module" src="https://treetopflyer.github.io/gale/boot.js?entry=/app-gale.js"></script>
</body>
</html>

View File

@ -1,4 +1,4 @@
import Graph from "../graph.js";
import Graph from "../../graph/graph.js";
import User from "./user.js";
export default Graph(