MAKE_LOAD_JS

Constant MAKE_LOAD_JS 

Source
pub const MAKE_LOAD_JS: &str = "// when running the harness we need to make sure to uncommon this out...\n\nexport function makeLoad(url, deps, fusedImports, initIt) {\n  let alreadyLoaded = false;\n  return async (callbackIndex, callbackData) => {\n    await Promise.all(deps.map((dep) => dep()));\n    if (alreadyLoaded) return;\n    try {\n      const response = await fetch(url);\n      const initSync = initIt || globalThis.__wasm_split_main_initSync;\n      const mainExports = initSync(undefined, undefined);\n\n      let imports = {\n        env: {\n          memory: mainExports.memory,\n        },\n        __wasm_split: {\n          __indirect_function_table: mainExports.__indirect_function_table,\n          __stack_pointer: mainExports.__stack_pointer,\n          __tls_base: mainExports.__tls_base,\n          memory: mainExports.memory,\n        },\n      };\n\n      for (let mainExport in mainExports) {\n        imports[\"__wasm_split\"][mainExport] = mainExports[mainExport];\n      }\n\n      for (let name in fusedImports) {\n        imports[\"__wasm_split\"][name] = fusedImports[name];\n      }\n\n      let new_exports = await WebAssembly.instantiateStreaming(\n        response,\n        imports\n      );\n\n      alreadyLoaded = true;\n\n      for (let name in new_exports.instance.exports) {\n        fusedImports[name] = new_exports.instance.exports[name];\n      }\n\n      if (callbackIndex !== undefined) {\n        mainExports.__indirect_function_table.get(callbackIndex)(\n          callbackData,\n          true\n        );\n      }\n    } catch (e) {\n      console.error(\n        \"Failed to load wasm-split module\",\n        e,\n        url,\n        deps,\n        fusedImports\n      );\n      return;\n    }\n  };\n}\n\nlet fusedImports = {};\n";