@hpcc-js/wasm 1.16.1 → 1.16.4

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.
Binary file
package/dist/index.es6.js CHANGED
@@ -18,6 +18,7 @@ var expatlib = /*#__PURE__*/Object.freeze({
18
18
  'default': cpp$1
19
19
  });
20
20
 
21
+ var _a, _b, _c, _d;
21
22
  function getGlobal() {
22
23
  if (typeof self !== "undefined") {
23
24
  return self;
@@ -51,11 +52,8 @@ function trimStart(str, charToRemove) {
51
52
  }
52
53
  return str;
53
54
  }
54
- let scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src :
55
- typeof __filename !== 'undefined' ? __filename :
56
- typeof document !== 'undefined' && document.currentScript ? document.currentScript.src :
57
- "";
58
- scriptDir = scriptDir.substr(0, scriptDir.replace(/[?#].*/, "").lastIndexOf('/') + 1);
55
+ let scriptDir = (_d = (_c = (_b = (_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) === null || _a === void 0 ? void 0 : _a.currentScript) === null || _b === void 0 ? void 0 : _b.src) !== null && _c !== void 0 ? _c : undefined) !== null && _d !== void 0 ? _d : "./dummy.js";
56
+ scriptDir = scriptDir.substring(0, scriptDir.replace(/[?#].*/, "").lastIndexOf('/') + 1);
59
57
  async function browserFetch(wasmUrl) {
60
58
  return fetch(wasmUrl, { credentials: 'same-origin' }).then(response => {
61
59
  if (!response.ok) {
@@ -77,7 +75,8 @@ async function _loadWasm(_wasmLib, wasmUrl, wasmBinary) {
77
75
  });
78
76
  }
79
77
  async function loadWasm(_wasmLib, filename, wf, wasmBinary) {
80
- const wasmUrl = `${trimEnd(wf || wasmFolder() || scriptDir || ".", "/")}/${trimStart(`${filename}.wasm`, "/")}`;
78
+ let wasmUrl = `${trimEnd(wf || wasmFolder() || scriptDir, "/")}/${trimStart(`${filename}.wasm`, "/")}`;
79
+ wasmUrl = URL && globalThis.document ? new URL(wasmUrl, document.baseURI).href : wasmUrl;
81
80
  if (!g_wasmCache[wasmUrl]) {
82
81
  g_wasmCache[wasmUrl] = _loadWasm(_wasmLib, wasmUrl, wasmBinary);
83
82
  }