blake3-npm-2.1.7-7bf40c44b4 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. diff --git a/browser-async.d.ts b/browser-async.d.ts
  2. index a5a04ce572f3c4540131331a04c97f45d5a83aec..6487148089fabdc490b38e4c8b1fa18fd948abc3 100644
  3. --- a/browser-async.d.ts
  4. +++ b/browser-async.d.ts
  5. @@ -4,4 +4,4 @@ import * as blake3 from './esm/browser';
  6. * Manually loads the WebAssembly module, returning a promise that resolves
  7. * to the BLAKE3 implementation once available.
  8. */
  9. -export default function load(module: string | URL | Request | object): Promise<typeof blake3>;
  10. +export default function load(module: string | URL | Request | object | ((imports: unknown) => Promise<WebAssembly.Module>)): Promise<typeof blake3>;
  11. diff --git a/dist/wasm/web/blake3_js.d.ts b/dist/wasm/web/blake3_js.d.ts
  12. index cd566ed3396cb5c5e591b3f6206c032bfa80ace6..a892506a5b9b7d73750b6e193c692d843615af70 100644
  13. --- a/dist/wasm/web/blake3_js.d.ts
  14. +++ b/dist/wasm/web/blake3_js.d.ts
  15. @@ -50,7 +50,7 @@ export class HashReader {
  16. set_position(position: BigInt): void;
  17. }
  18. -export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
  19. +export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module | ((imports: unknown) => Promise<WebAssembly.Module>);
  20. export interface InitOutput {
  21. readonly memory: WebAssembly.Memory;
  22. diff --git a/dist/wasm/web/blake3_js.js b/dist/wasm/web/blake3_js.js
  23. index 4fa37747aa8b61fa8f29736871ec2c8d38ffcb3d..afa8d13e1d55092aa68d6867ca99238f519ec6b5 100644
  24. --- a/dist/wasm/web/blake3_js.js
  25. +++ b/dist/wasm/web/blake3_js.js
  26. @@ -261,7 +261,15 @@ async function init(input) {
  27. input = fetch(input);
  28. }
  29. - const { instance, module } = await load(await input, imports);
  30. + let result;
  31. +
  32. + if (typeof input === 'function') {
  33. + result = await input(imports);
  34. + } else {
  35. + result = await load(await input, imports);
  36. + }
  37. +
  38. + const { instance, module } = result;
  39. wasm = instance.exports;
  40. init.__wbindgen_wasm_module = module;