gale implementation started
This commit is contained in:
parent
cf9bb45a62
commit
f27e71839f
65
app-gale.js
Normal file
65
app-gale.js
Normal 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);
|
||||||
@ -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";
|
import * as FSHandle from "./store-directory-handle.js";
|
||||||
|
|
||||||
|
|
||||||
/** @type {(type:string, attributes?:Record<string, string>, ...children:Array<string|HTMLElement>)=>HTMLElement} */
|
/** @type {(type:string, attributes?:Record<string, string>, ...children:Array<string|HTMLElement>)=>HTMLElement} */
|
||||||
const H =(type, attributes={}, ...children)=> {
|
const H =(type, attributes={}, ...children)=> {
|
||||||
const el =document.createElement(type);
|
const el =document.createElement(type);
|
||||||
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions":
|
||||||
|
{
|
||||||
"checkJs": true,
|
"checkJs": true,
|
||||||
"lib":[
|
"lib": ["deno.window", "DOM"],
|
||||||
"deno.window", "dom"
|
"types": ["https://treetopflyer.github.io/gale/types.d.ts"]
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
15
index.html
15
index.html
@ -6,15 +6,12 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script>
|
<script>
|
||||||
|
if ('serviceWorker' in navigator) {
|
||||||
if ('serviceWorker' in navigator) {
|
navigator.serviceWorker.register('/service-worker.js', {type:"module"})
|
||||||
navigator.serviceWorker.register('/service-worker.js', {type:"module"})
|
.then(reg => console.log('Service Worker registered:', reg))
|
||||||
.then(reg => console.log('Service Worker registered:', reg))
|
.catch(err => console.error('Service Worker registration failed:', err));
|
||||||
.catch(err => console.error('Service Worker registration failed:', err));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
|
||||||
<script src="app.js" type="module">
|
|
||||||
</script>
|
</script>
|
||||||
|
<script type="module" src="https://treetopflyer.github.io/gale/boot.js?entry=/app-gale.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import Graph from "../graph.js";
|
import Graph from "../../graph/graph.js";
|
||||||
import User from "./user.js";
|
import User from "./user.js";
|
||||||
|
|
||||||
export default Graph(
|
export default Graph(
|
||||||
Loading…
Reference in New Issue
Block a user