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
|
"use strict";
|
|
@@ -889,9 +889,7 @@ const buildGeneratedLoaderContent = (generatedLoaderFile, targets) => {
|
|
|
889
889
|
options?: TargetWasmLoadOptions
|
|
890
890
|
): Promise<WasmInstance<T>> => {
|
|
891
891
|
const source = options?.url ?? new URL(${specifier}, import.meta.url);
|
|
892
|
-
return await loadWasm<T>(source,
|
|
893
|
-
imports: options?.imports,
|
|
894
|
-
});
|
|
892
|
+
return await loadWasm<T>(source, createWasmLoadOptions(options?.imports));
|
|
895
893
|
};`;
|
|
896
894
|
}).join("\n\n");
|
|
897
895
|
return `// Generated by emsdk-env. DO NOT EDIT.
|
|
@@ -911,6 +909,13 @@ export interface TargetWasmLoadOptions extends WasmLoadOptions {
|
|
|
911
909
|
readonly url?: string | URL;
|
|
912
910
|
}
|
|
913
911
|
|
|
912
|
+
const isResponse = (value: WasmSource): value is Response =>
|
|
913
|
+
typeof Response !== 'undefined' && value instanceof Response;
|
|
914
|
+
|
|
915
|
+
const createWasmLoadOptions = (
|
|
916
|
+
imports: WebAssembly.Imports | undefined
|
|
917
|
+
): WasmLoadOptions | undefined => (imports ? { imports } : undefined);
|
|
918
|
+
|
|
914
919
|
export interface WasmInstance<T extends object> {
|
|
915
920
|
readonly exports: T;
|
|
916
921
|
readonly memory: WebAssembly.Memory;
|
|
@@ -923,7 +928,7 @@ export interface WasmInstance<T extends object> {
|
|
|
923
928
|
}
|
|
924
929
|
|
|
925
930
|
const resolveWasmBytes = async (source: WasmSource): Promise<ArrayBuffer> => {
|
|
926
|
-
if (
|
|
931
|
+
if (isResponse(source)) {
|
|
927
932
|
return await source.arrayBuffer();
|
|
928
933
|
}
|
|
929
934
|
if (source instanceof URL || typeof source === 'string') {
|
|
@@ -933,6 +938,9 @@ const resolveWasmBytes = async (source: WasmSource): Promise<ArrayBuffer> => {
|
|
|
933
938
|
}
|
|
934
939
|
return await response.arrayBuffer();
|
|
935
940
|
}
|
|
941
|
+
if (source instanceof ArrayBuffer) {
|
|
942
|
+
return source;
|
|
943
|
+
}
|
|
936
944
|
if (ArrayBuffer.isView(source)) {
|
|
937
945
|
const view = new Uint8Array(
|
|
938
946
|
source.buffer,
|
|
@@ -941,7 +949,7 @@ const resolveWasmBytes = async (source: WasmSource): Promise<ArrayBuffer> => {
|
|
|
941
949
|
);
|
|
942
950
|
return view.slice().buffer;
|
|
943
951
|
}
|
|
944
|
-
|
|
952
|
+
throw new TypeError('Unsupported wasm source.');
|
|
945
953
|
};
|
|
946
954
|
|
|
947
955
|
const getImportValue = (
|
|
@@ -1678,4 +1686,4 @@ const buildWasm = async (options) => {
|
|
|
1678
1686
|
exports.buildWasm = buildWasm;
|
|
1679
1687
|
exports.createConsoleLogger = createConsoleLogger;
|
|
1680
1688
|
exports.prepareEmsdk = prepareEmsdk;
|
|
1681
|
-
//# sourceMappingURL=build-
|
|
1689
|
+
//# sourceMappingURL=build-BGtsNe6D.cjs.map
|