feat: refactoring project

This commit is contained in:
Carlos
2024-11-23 14:56:07 -05:00
parent f0c2a50c18
commit 1c6db5818d
2351 changed files with 39323 additions and 60326 deletions

View File

@@ -44,7 +44,7 @@ class AsyncWasmLoadingRuntimeModule extends RuntimeModule {
`" + ${RuntimeGlobals.getFullHash}}().slice(0, ${length}) + "`,
module: {
id: '" + wasmModuleId + "',
hash: `" + wasmModuleHash + "`,
hash: '" + wasmModuleHash + "',
hashWithLength(length) {
return `" + wasmModuleHash.slice(0, ${length}) + "`;
}
@@ -75,18 +75,18 @@ class AsyncWasmLoadingRuntimeModule extends RuntimeModule {
concat(
"return req.then(",
runtimeTemplate.basicFunction("res", [
`if (typeof WebAssembly.instantiateStreaming === "function") {`,
'if (typeof WebAssembly.instantiateStreaming === "function") {',
Template.indent([
"return WebAssembly.instantiateStreaming(res, importsObj)",
Template.indent([
".then(",
Template.indent([
runtimeTemplate.returningFunction(
`${runtimeTemplate.returningFunction(
"Object.assign(exports, res.instance.exports)",
"res"
) + ",",
)},`,
runtimeTemplate.basicFunction("e", [
`if(res.headers.get("Content-Type") !== "application/wasm") {`,
'if(res.headers.get("Content-Type") !== "application/wasm") {',
Template.indent([
'console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n", e);',
"return fallback();"
@@ -110,7 +110,7 @@ class AsyncWasmLoadingRuntimeModule extends RuntimeModule {
"exports, wasmModuleId, wasmModuleHash, importsObj",
this.supportsStreaming
? getStreaming()
: [`return ${loader}`, Template.indent(fallback) + ";"]
: [`return ${loader}`, `${Template.indent(fallback)};`]
)};`;
}
}