30 lines
771 B
TypeScript
30 lines
771 B
TypeScript
|
import React, {hydrate} from "react";
|
||
|
import * as Twind from "https://esm.sh/v115/@twind/core@1.1.3/es2022/core.mjs";
|
||
|
import {Router, CSS, Meta} from "@eno/iso";
|
||
|
|
||
|
export function Boot(inApp:()=>React.JSX.Element, inCSS?:object)
|
||
|
{
|
||
|
console.log(inApp, inCSS);
|
||
|
Twind.install(inCSS ? {...CSS, ...inCSS} : CSS);
|
||
|
|
||
|
const HMRWrap =()=> React.createElement(inApp, null, null);
|
||
|
|
||
|
const root = document.querySelector("#app");
|
||
|
|
||
|
if(root)
|
||
|
{
|
||
|
hydrate(
|
||
|
<Router.Provider url={new URL(window.location.href)}>
|
||
|
<Meta.Provider>
|
||
|
<HMRWrap/>
|
||
|
</Meta.Provider>
|
||
|
</Router.Provider>,
|
||
|
root
|
||
|
);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
console.log(`no "#app" element is present!`)
|
||
|
}
|
||
|
|
||
|
};
|