@@ -21,6 +21,7 @@ import {
2121import { createClient , type NormalizeOAS } from "fets" ;
2222import { glob } from "glob" ;
2323import { setupServer } from "msw/node" ;
24+ import { toUint8Array } from "uint8array-extras" ;
2425import { createHandler } from "./msw.js" ;
2526import { entriesToNetworkJson } from "./util/entriesToNetworkJson.js" ;
2627import { createErrorAPI , InitializationError } from "./util/error.js" ;
@@ -30,6 +31,7 @@ import { makeSynchronousRequest } from "./workers/makeRequest.js";
3031import type openapi from "../__generated__/openapi.js" ;
3132
3233export type * from "../types.js" ;
34+ export { toUint8Array } from "uint8array-extras" ;
3335
3436/** Autoloading interface for Taskless, hides manual pack loading and automatically initializes */
3537export const autoload = ( secret ?: string , options ?: InitOptions ) => {
@@ -292,7 +294,7 @@ export const taskless = (
292294 /** Packs are added programatically or during the init step */
293295 const packs : Pack [ ] = [ ] ;
294296
295- const moduleSource = new Map < string , MaybePromise < ArrayBuffer > > ( ) ;
297+ const moduleSource = new Map < string , MaybePromise < Uint8Array > > ( ) ;
296298
297299 /** WASM modules are added programatically or during the init step */
298300 const modules = new Map < string , Promise < Plugin > > ( ) ;
@@ -384,7 +386,7 @@ export const taskless = (
384386 configuration : Pack [ "configuration" ] ;
385387 url : Pack [ "url" ] ;
386388 } ;
387- const wasmContents = readFile ( wasmPath ) ;
389+ const wasmContents = readFile ( wasmPath ) as Promise < Uint8Array > ;
388390 const pack : Pack = {
389391 ...config ,
390392 ...manifest ,
@@ -423,7 +425,8 @@ export const taskless = (
423425 } ,
424426 } ) ;
425427 logger . trace ( `Fetched ${ ident } from ${ pack . url . source } ` ) ;
426- return data . arrayBuffer ( ) ;
428+ const buffer = await data . arrayBuffer ( ) ;
429+ return toUint8Array ( buffer ) ;
427430 } ) ( )
428431 ) ;
429432 }
@@ -517,7 +520,7 @@ export const taskless = (
517520 logger,
518521
519522 /** add additional local packs programatically */
520- add ( manifest : Manifest , wasm : ArrayBuffer ) {
523+ add ( manifest : Manifest , wasm : Uint8Array ) {
521524 if ( initialized ) {
522525 throw new Error ( "A pack was added after Taskless was initialized" ) ;
523526 }
0 commit comments