char/avril
(wip) why'd you have to go and make things so complicaaaaated?
git clone https://git.t4t.associates/char/avril
44fe2c6
main
1import { 2AbortController , 3AbortSignal , 4CustomEvent , 5DOMException , 6ErrorEvent , 7Event , 8EventTarget , 9installGlobalEventTarget , 10PromiseRejectionEvent , 11reportErrorValue , 12reportException , 13reportRejectionHandled , 14reportUnhandledRejection , 15} from "./events.js" ; 16import { 17ObjectDefineProperty as define , 18SymbolFor , 19} from "ext:core/primordials" ; 20import { setEventHandlers } from "ext:core/event_hooks" ; 21import { onRuntimeStart } from "ext:core/bootstrap" ; 22import { required } from "./idl.js" ; 23import { atob , btoa } from "./base64.js" ; 24import { navigator , NavigatorUAData , WorkerNavigator } from "./navigator.js" ; 25import { Performance , performance } from "./performance.js" ; 26import { MessageChannel , MessageEvent , MessagePort } from "./messaging.js" ; 27import { BroadcastChannel } from "./broadcast.js" ; 28import { installInterface } from "./interface.js" ; 29for ( 30const ctor of [ 31DOMException , 32Event , 33CustomEvent , 34ErrorEvent , 35PromiseRejectionEvent , 36MessageEvent , 37MessagePort , 38MessageChannel , 39BroadcastChannel , 40EventTarget , 41AbortSignal , 42AbortController , 43WorkerNavigator , 44NavigatorUAData , 45Performance , 46] 47) installInterface ( ctor . name , ctor ); 48 49const global = globalThis ; 50onRuntimeStart (() => { 51// V8 restores a fresh global proxy; its WeakMap brand must be installed live. 52installGlobalEventTarget ( global ); 53setEventHandlers ( 54reportException , 55reportUnhandledRejection , 56reportRejectionHandled , 57); 58}); 59const reportError = ( ...args :unknown []) :void => { 60required ( args . length , 1 ); 61reportErrorValue ( args [ 0 ]); 62}; 63define ( reportError , "length" , { value :1 }); 64define ( global , "reportError" , { 65value :reportError , 66writable :true , 67enumerable :true , 68configurable :true , 69}); 70for ( const fn of [ atob , btoa ]) { 71define ( global , fn . name , { 72value :fn , 73writable :true , 74enumerable :true , 75configurable :true , 76}); 77} 78function replaceable ( name :string , value :unknown ) :void { 79define ( global , name , { 80get :() => value , 81set :( replacement ) => 82define ( global , name , { 83value :replacement , 84writable :true , 85enumerable :true , 86configurable :true , 87}), 88enumerable :true , 89configurable :true , 90}); 91} 92replaceable ( "self" , global ); 93define ( global , SymbolFor ( "runtime:avril" ), { 94value :true , 95writable :false , 96enumerable :false , 97configurable :false , 98}); 99define ( global , "navigator" , { 100get :() => navigator , 101enumerable :true , 102configurable :true , 103}); 104replaceable ( "performance" , performance );