11import * as apiClient from '@commontools/usuba-api' ;
22import { polyfill , hash } from './usuba_compat/usuba_compat.component.js' ;
33
4- const SERVICE_WORKER_VERSION = '0.0.1' ;
4+ const SERVICE_WORKER_VERSION = '0.0.1-alpha.6 ' ;
55
66self . addEventListener ( 'install' , ( _event ) => {
77 console . log (
8- `Usuba Service Worker installed (version ${ SERVICE_WORKER_VERSION } `
8+ `Usuba Service Worker installed (version ${ SERVICE_WORKER_VERSION } ) `
99 ) ;
1010} ) ;
1111
@@ -216,6 +216,7 @@ const buildOnDemandModule = (event: FetchEvent, url: URL) => {
216216const buildRuntimeModule = ( event : FetchEvent , url : URL ) => {
217217 event . respondWith (
218218 ( async ( ) => {
219+ console . log ( 'Preparing to build Runtime Module...' ) ;
219220 const formData = await event . request . formData ( ) ;
220221 const moduleFiles = formData . getAll ( 'module' ) as File [ ] ;
221222 const libraryFiles = formData . getAll ( 'library' ) as File [ ] ;
@@ -250,19 +251,8 @@ const buildRuntimeModule = (event: FetchEvent, url: URL) => {
250251 exports : _exports ,
251252 } = await buildModule ( moduleSlug , moduleFiles , libraryFiles , 'manual' ) ;
252253
253- const wasiShimImports = [ ] ;
254-
255- for ( const specifier of Object . values ( WASI_SHIM_MAP ) ) {
256- const trimmedSpecifier = specifier . split ( '#' ) . shift ( ) ;
257- wasiShimImports . push ( `'${ trimmedSpecifier } ': import('${ specifier } ')` ) ;
258- }
259-
260- // const wrapperModule = `export * from '${ON_DEMAND_TRANSPILED_MODULE_DIRNAME}/${moduleSlug}.js'`;
261254 const wrapperModule = `import {instantiate as innerInstantiate} from '${ RUNTIME_TRANSPILED_MODULE_DIRNAME } /${ moduleSlug } .js';
262-
263- const wasiShimImportPromises = {
264- ${ wasiShimImports . join ( ',\n ' ) }
265- };
255+ import {shim as wasiShimImportPromises} from '/wasi.js';
266256
267257const wasiShimImports = Promise.all(
268258 Object.entries(wasiShimImportPromises)
@@ -281,7 +271,8 @@ export const instantiate = async (imports) => {
281271 }
282272
283273 const getCoreModule = async (name) => fetch('${ RUNTIME_TRANSPILED_MODULE_DIRNAME } /' + name).then(WebAssembly.compileStreaming);
284- console.log('Instantiating with:', imports);
274+ console.log('Instantiating module with these resolved imports:', imports);
275+
285276 return innerInstantiate(getCoreModule, imports);
286277};` ;
287278
0 commit comments