@ic-reactor/core 1.7.3 → 1.7.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.
package/README.md CHANGED
@@ -19,7 +19,7 @@ yarn add @ic-reactor/core
19
19
  or you can use the UMD version:
20
20
 
21
21
  ```html
22
- <script src="https://github.com/B3Pay/ic-reactor/releases/download/v1.7.1/ic-reactor-core.min.js"></script>
22
+ <script src="https://github.com/B3Pay/ic-reactor/releases/download/v1.7.3/ic-reactor-core.min.js"></script>
23
23
  ```
24
24
 
25
25
  ### Using `createReactorCore`
@@ -1,4 +1,27 @@
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
+ };
2
25
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
26
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
27
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -38,10 +61,12 @@ class CandidAdapter {
38
61
  return;
39
62
  }
40
63
  try {
41
- this.parserModule = require("@ic-reactor/parser");
42
- if (typeof this.parserModule !== "undefined" &&
43
- "default" in this.parserModule) {
44
- yield this.parserModule.default();
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");
45
70
  }
46
71
  }
47
72
  catch (error) {
@@ -1,4 +1,13 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.stringToHash = exports.generateActorHash = exports.generateHash = exports.generateRequestHash = exports.jsonToString = exports.isQuery = exports.getProcessEnvNetwork = exports.isInLocalOrDevelopment = exports.importCandidDefinition = exports.createStoreWithOptionalDevtools = void 0;
4
13
  const agent_1 = require("@dfinity/agent");
@@ -15,15 +24,32 @@ function createStoreWithOptionalDevtools(initialState, config) {
15
24
  }
16
25
  }
17
26
  exports.createStoreWithOptionalDevtools = createStoreWithOptionalDevtools;
18
- const importCandidDefinition = (candidDef) => {
19
- try {
20
- const dataUri = "data:text/javascript;charset=utf-8," + encodeURIComponent(candidDef);
21
- return eval('import("' + dataUri + '")');
27
+ const importCandidDefinition = (candidDef) => __awaiter(void 0, void 0, void 0, function* () {
28
+ if (typeof window === "undefined") {
29
+ // Node.js environment
30
+ try {
31
+ const dataUri = "data:text/javascript;charset=utf-8," + encodeURIComponent(candidDef);
32
+ return eval('import("' + dataUri + '")');
33
+ }
34
+ catch (error) {
35
+ throw new Error("Error importing Candid definition in Node.js");
36
+ }
22
37
  }
23
- catch (error) {
24
- throw new Error("Error importing Candid definition");
38
+ else {
39
+ // Browser environment
40
+ const jsBlob = new Blob([candidDef], { type: "application/javascript" });
41
+ const url = URL.createObjectURL(jsBlob);
42
+ try {
43
+ const module = eval('import("' + url + '")');
44
+ URL.revokeObjectURL(url);
45
+ return module;
46
+ }
47
+ catch (error) {
48
+ URL.revokeObjectURL(url);
49
+ throw new Error("Error importing Candid definition in Browser");
50
+ }
25
51
  }
26
- };
52
+ });
27
53
  exports.importCandidDefinition = importCandidDefinition;
28
54
  const isInLocalOrDevelopment = () => {
29
55
  return typeof process !== "undefined" && process.env.DFX_NETWORK === "local";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ic-reactor/core",
3
- "version": "1.7.3",
3
+ "version": "1.7.4",
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": "9b07706cc8a8e81a56f528cac5a65743587eeb48"
59
+ "gitHead": "b29be90830729f198c63164041141e35ee0aaafa"
60
60
  }