boot-function #1

Merged
SethTrowbridge merged 25 commits from boot-function into master 2023-06-21 07:53:14 -04:00
2 changed files with 26 additions and 19 deletions
Showing only changes of commit 50aaaf136e - Show all commits

View File

@ -1,3 +1,5 @@
import { type StateCapture } from "./react.tsx";
type FileHandler = (module:unknown)=>void
const FileListeners = new Map() as Map<string, Array<FileHandler>>;
export const FileListen =(inPath:string, inHandler:()=>void)=>
@ -27,8 +29,8 @@ const SocketTimer = setInterval(()=>{Socket.send("ping")}, 5000);
const HMR = {
reloads:0,
createdElements: new Map() as Map<string, ()=>void>,
states: new Map(),
statesOld: new Map(),
states: new Map() as Map<string, StateCapture>,
statesOld: new Map() as Map<string, StateCapture>,
wireframe: false,
onChange(reactID:string, value:()=>void):void
{
@ -61,17 +63,3 @@ const HMR = {
};
export {HMR};
export const MapAt =(inMap, inIndex)=>
{
let index = 0;
for(const kvp of inMap)
{
if(index == inIndex)
{
return kvp;
}
index++;
}
return false;
};

View File

@ -1,5 +1,24 @@
import * as ReactParts from "react-original";
import { HMR, MapAt } from "./hmr.tsx";
import { HMR } from "./hmr.tsx";
export type StateType = boolean|number|string|Record<string, string>
export type StateCapture = {state:StateType, set:ReactParts.StateUpdater<StateType>, reload:number};
const pluck =(m:Map<string, number>)=> m.keys()
const MapAt =(inMap:Map<string, StateCapture>, inIndex:number)=>
{
let index = 0;
for(const kvp of inMap)
{
if(index == inIndex)
{
return kvp;
}
index++;
}
return false;
};
const H = ReactParts.createElement;
@ -29,7 +48,7 @@ const ProxyCreate =(...args)=>
return typeof args[0] != "string" ? H(ProxyElement, {__args:args, ...args[1]}) : H(...args);
};
const ProxyState =(arg)=>
const ProxyState =(arg:StateType)=>
{
const id = ReactParts.useId();
const trueArg = arg;