char/avril
(wip) why'd you have to go and make things so complicaaaaated?
git clone https://git.t4t.associates/char/avril
d71572b
main
1import { state } from "./state.js" ; 2import { ops , primordials } from "ext:core" ; 3import { ArrayPrototypePush } from "ext:core/primordials" ; 4import { onRuntimeStart , startRuntime } from "ext:core/bootstrap" ; 5import { enqueueMicrotask } from "ext:core/microtasks" ; 6import { setEventHandlers } from "ext:core/event_hooks" ; 7import { safePromise } from "ext:core/promises" ; 8import { 9asyncSeed , 10collect , 11finishWasm , 12nativeSeed , 13registerWasm , 14staticOnly , 15} from "ext:core/ops" ; 16 17staticOnly (); 18if ( 19ops . nativeSeed !== nativeSeed || 20primordials . ArrayPrototypePush !== ArrayPrototypePush 21) { 22throw Error ( "Core export identity" ); 23} 24globalThis . events = [ "static" ]; 25globalThis . snapshotState = state ; 26globalThis . readNative = nativeSeed ; 27globalThis . startAgain = startRuntime ; 28globalThis . extensionMeta = import . meta; 29globalThis . extensionDynamic = () => import ( "./state.js" ); 30globalThis . seedAsync = () => safePromise ( asyncSeed ()); 31 32await Promise . resolve (); 33onRuntimeStart (() => { 34state . seed = nativeSeed (); 35Object . freeze ( state ); 36events . push ( "live" ); 37setEventHandlers ( 38( error ) => { 39events . push ( error . message ); 40return true ; 41}, 42( _promise , reason ) => { 43events . push ( reason . message ); 44return true ; 45}, 46() => { 47events . push ( "handled" ); 48}, 49); 50registerWasm (( source , id ) => { 51if ( source !== state . seed || id !== 1 ) throw Error ( "Stale Wasm registry" ); 52finishWasm ( id ); 53}); 54}); 55export function reportMicrotask () { 56enqueueMicrotask (() => { 57throw Error ( "microtask" ); 58}); 59} 60export { collect , state };