emscripten-utils.js 947 B

12345678910111213141516171819202122232425262728
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.pathify = pathify;
  6. exports.instantiateEmscriptenWasm = instantiateEmscriptenWasm;
  7. var _url = require("url");
  8. function pathify(path) {
  9. if (path.startsWith("file://")) {
  10. path = (0, _url).fileURLToPath(path);
  11. }
  12. return path;
  13. }
  14. function instantiateEmscriptenWasm(factory, path, workerJS = "") {
  15. return factory({
  16. locateFile (requestPath) {
  17. // The glue code generated by emscripten uses the original
  18. // file names of the worker file and the wasm binary.
  19. // These will have changed in the bundling process and
  20. // we need to inject them here.
  21. if (requestPath.endsWith(".wasm")) return pathify(path);
  22. if (requestPath.endsWith(".worker.js")) return pathify(workerJS);
  23. return requestPath;
  24. }
  25. });
  26. }
  27. //# sourceMappingURL=emscripten-utils.js.map