emsdk-env 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{build-BOZTStIM.js → build-BE9Z95iJ.js} +16 -8
- package/dist/{build-BOZTStIM.js.map → build-BE9Z95iJ.js.map} +1 -1
- package/dist/{build-CgmcFNSR.cjs → build-BGtsNe6D.cjs} +16 -8
- package/dist/{build-CgmcFNSR.cjs.map → build-BGtsNe6D.cjs.map} +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +3 -3
- package/dist/vite.cjs +5 -5
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.ts +2 -2
- package/dist/vite.mjs +5 -5
- package/dist/vite.mjs.map +1 -1
- package/package.json +7 -7
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: emsdk-env
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.10.0
|
|
4
4
|
* description: Emscripten environment builder
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/emsdk-env
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: 7ee173408d930a3cc7444806156538a24a617b55
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { mkdir, access, constants, mkdtemp, rename, rm, writeFile, readFile } from "fs/promises";
|
|
@@ -866,9 +866,7 @@ const buildGeneratedLoaderContent = (generatedLoaderFile, targets) => {
|
|
|
866
866
|
options?: TargetWasmLoadOptions
|
|
867
867
|
): Promise<WasmInstance<T>> => {
|
|
868
868
|
const source = options?.url ?? new URL(${specifier}, import.meta.url);
|
|
869
|
-
return await loadWasm<T>(source,
|
|
870
|
-
imports: options?.imports,
|
|
871
|
-
});
|
|
869
|
+
return await loadWasm<T>(source, createWasmLoadOptions(options?.imports));
|
|
872
870
|
};`;
|
|
873
871
|
}).join("\n\n");
|
|
874
872
|
return `// Generated by emsdk-env. DO NOT EDIT.
|
|
@@ -888,6 +886,13 @@ export interface TargetWasmLoadOptions extends WasmLoadOptions {
|
|
|
888
886
|
readonly url?: string | URL;
|
|
889
887
|
}
|
|
890
888
|
|
|
889
|
+
const isResponse = (value: WasmSource): value is Response =>
|
|
890
|
+
typeof Response !== 'undefined' && value instanceof Response;
|
|
891
|
+
|
|
892
|
+
const createWasmLoadOptions = (
|
|
893
|
+
imports: WebAssembly.Imports | undefined
|
|
894
|
+
): WasmLoadOptions | undefined => (imports ? { imports } : undefined);
|
|
895
|
+
|
|
891
896
|
export interface WasmInstance<T extends object> {
|
|
892
897
|
readonly exports: T;
|
|
893
898
|
readonly memory: WebAssembly.Memory;
|
|
@@ -900,7 +905,7 @@ export interface WasmInstance<T extends object> {
|
|
|
900
905
|
}
|
|
901
906
|
|
|
902
907
|
const resolveWasmBytes = async (source: WasmSource): Promise<ArrayBuffer> => {
|
|
903
|
-
if (
|
|
908
|
+
if (isResponse(source)) {
|
|
904
909
|
return await source.arrayBuffer();
|
|
905
910
|
}
|
|
906
911
|
if (source instanceof URL || typeof source === 'string') {
|
|
@@ -910,6 +915,9 @@ const resolveWasmBytes = async (source: WasmSource): Promise<ArrayBuffer> => {
|
|
|
910
915
|
}
|
|
911
916
|
return await response.arrayBuffer();
|
|
912
917
|
}
|
|
918
|
+
if (source instanceof ArrayBuffer) {
|
|
919
|
+
return source;
|
|
920
|
+
}
|
|
913
921
|
if (ArrayBuffer.isView(source)) {
|
|
914
922
|
const view = new Uint8Array(
|
|
915
923
|
source.buffer,
|
|
@@ -918,7 +926,7 @@ const resolveWasmBytes = async (source: WasmSource): Promise<ArrayBuffer> => {
|
|
|
918
926
|
);
|
|
919
927
|
return view.slice().buffer;
|
|
920
928
|
}
|
|
921
|
-
|
|
929
|
+
throw new TypeError('Unsupported wasm source.');
|
|
922
930
|
};
|
|
923
931
|
|
|
924
932
|
const getImportValue = (
|
|
@@ -1657,4 +1665,4 @@ export {
|
|
|
1657
1665
|
createConsoleLogger as c,
|
|
1658
1666
|
prepareEmsdk as p
|
|
1659
1667
|
};
|
|
1660
|
-
//# sourceMappingURL=build-
|
|
1668
|
+
//# sourceMappingURL=build-BE9Z95iJ.js.map
|