@ic-reactor/core 1.7.3 → 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.
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,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,34 @@ 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 loaderFunction = new Function(`
32
+ return import("data:text/javascript;charset=utf-8, ${encodeURIComponent(candidDef)}")
33
+ `);
34
+ return loaderFunction();
35
+ }
36
+ catch (error) {
37
+ throw new Error(`Error importing candid definition in NodeJs: ${error}`);
38
+ }
22
39
  }
23
- catch (error) {
24
- throw new Error("Error importing Candid definition");
40
+ else {
41
+ // Browser environment
42
+ try {
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();
49
+ }
50
+ catch (error) {
51
+ throw new Error(`Error importing candid definition: ${error}`);
52
+ }
25
53
  }
26
- };
54
+ });
27
55
  exports.importCandidDefinition = importCandidDefinition;
28
56
  const isInLocalOrDevelopment = () => {
29
57
  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.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": "9b07706cc8a8e81a56f528cac5a65743587eeb48"
59
+ "gitHead": "926af41a399b6ef28f1c5a7c419c22e3b7baa6db"
60
60
  }