let nextScriptId = 1 ; let scriptIdPrefix = Math . random ( ) . toString ( 36 ) . slice ( 2 ) ; const __polestar_script__ = ( id , fn ) => { __polestar_script__ [ id ] = fn ; } ; if ( ! window [ '__polestar_script__' ] ) { window [ '__polestar_script__' ] = __polestar_script__ ; } else { throw new Error ( "Cannot load multiple copies of Polestar." ) ; } export function createFunction ( argNames , source ) { let scriptId = scriptIdPrefix + '/' + nextScriptId ++ ; let script = document . createElement ( 'script' ) ; script . innerHTML = `(function(){__polestar_script__(${ JSON . stringify ( scriptId ) }, function module(${ argNames . join ( ',' ) }) {` + source + `\n})})()` ; document . body . appendChild ( script ) ; let result = __polestar_script__ [ scriptId ] ; delete __polestar_script__ [ scriptId ] ; document . body . removeChild ( script ) ; return result ; }