@ic-reactor/core 1.7.4 → 1.7.5

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.
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -61,12 +38,10 @@ class CandidAdapter {
61
38
  return;
62
39
  }
63
40
  try {
64
- const parserModule = (yield Promise.resolve().then(() => __importStar(require("@ic-reactor/parser"))));
65
- if (parserModule) {
66
- this.parserModule = parserModule;
67
- }
68
- else {
69
- throw new Error("Failed to load parser module");
41
+ this.parserModule = require("@ic-reactor/parser");
42
+ if (typeof this.parserModule !== "undefined" &&
43
+ "default" in this.parserModule) {
44
+ yield this.parserModule.default();
70
45
  }
71
46
  }
72
47
  catch (error) {
@@ -28,25 +28,27 @@ const importCandidDefinition = (candidDef) => __awaiter(void 0, void 0, void 0,
28
28
  if (typeof window === "undefined") {
29
29
  // Node.js environment
30
30
  try {
31
- const dataUri = "data:text/javascript;charset=utf-8," + encodeURIComponent(candidDef);
32
- return eval('import("' + dataUri + '")');
31
+ const loaderFunction = new Function(`
32
+ return import("data:text/javascript;charset=utf-8, ${encodeURIComponent(candidDef)}")
33
+ `);
34
+ return loaderFunction();
33
35
  }
34
36
  catch (error) {
35
- throw new Error("Error importing Candid definition in Node.js");
37
+ throw new Error(`Error importing candid definition in NodeJs: ${error}`);
36
38
  }
37
39
  }
38
40
  else {
39
41
  // Browser environment
40
- const jsBlob = new Blob([candidDef], { type: "application/javascript" });
41
- const url = URL.createObjectURL(jsBlob);
42
42
  try {
43
- const module = eval('import("' + url + '")');
44
- URL.revokeObjectURL(url);
45
- return module;
43
+ const loaderFunction = new Function(`
44
+ const blob = new Blob([\`${candidDef}\`], { type: "application/javascript" })
45
+ const url = URL.createObjectURL(blob)
46
+ return import(url)
47
+ `);
48
+ return loaderFunction();
46
49
  }
47
50
  catch (error) {
48
- URL.revokeObjectURL(url);
49
- throw new Error("Error importing Candid definition in Browser");
51
+ throw new Error(`Error importing candid definition: ${error}`);
50
52
  }
51
53
  }
52
54
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ic-reactor/core",
3
- "version": "1.7.4",
3
+ "version": "1.7.5",
4
4
  "description": "A library for intracting with the Internet Computer canisters",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -56,5 +56,5 @@
56
56
  "engines": {
57
57
  "node": ">=10"
58
58
  },
59
- "gitHead": "b29be90830729f198c63164041141e35ee0aaafa"
59
+ "gitHead": "926af41a399b6ef28f1c5a7c419c22e3b7baa6db"
60
60
  }