chayns-api 3.6.0-beta.4 → 3.6.1

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.
@@ -8,7 +8,7 @@ var _reactCompilerRuntime = require("react-compiler-runtime");
8
8
  var _react = require("react");
9
9
  var _useFunctions = require("./useFunctions");
10
10
  const useFunctionsWithOverrides = overrideFactory => {
11
- const $ = (0, _reactCompilerRuntime.c)(21);
11
+ const $ = (0, _reactCompilerRuntime.c)(15);
12
12
  const base = (0, _useFunctions.useFunctions)();
13
13
  let t0;
14
14
  if ($[0] !== base || $[1] !== overrideFactory) {
@@ -21,87 +21,63 @@ const useFunctionsWithOverrides = overrideFactory => {
21
21
  }
22
22
  const overrides = t0;
23
23
  let t1;
24
- if ($[3] !== base) {
25
- t1 = Object.keys(base);
24
+ if ($[3] !== base || $[4] !== overrides) {
25
+ t1 = () => [...new Set([...Object.keys(base), ...Object.keys(overrides)])];
26
26
  $[3] = base;
27
- $[4] = t1;
27
+ $[4] = overrides;
28
+ $[5] = t1;
28
29
  } else {
29
- t1 = $[4];
30
+ t1 = $[5];
30
31
  }
32
+ const [functionNames] = (0, _react.useState)(t1);
31
33
  let t2;
32
- if ($[5] !== overrides) {
33
- t2 = Object.keys(overrides);
34
- $[5] = overrides;
35
- $[6] = t2;
36
- } else {
37
- t2 = $[6];
38
- }
39
- let t3;
40
- if ($[7] !== t1 || $[8] !== t2) {
41
- t3 = new Set([...t1, ...t2]);
42
- $[7] = t1;
43
- $[8] = t2;
44
- $[9] = t3;
45
- } else {
46
- t3 = $[9];
47
- }
48
- let t4;
49
- if ($[10] !== t3) {
50
- t4 = [...t3];
51
- $[10] = t3;
52
- $[11] = t4;
53
- } else {
54
- t4 = $[11];
55
- }
56
- const functionNames = t4;
57
- let t5;
58
- if ($[12] !== base || $[13] !== overrides) {
59
- t5 = {
34
+ if ($[6] !== base || $[7] !== overrides) {
35
+ t2 = {
60
36
  base,
61
37
  overrides
62
38
  };
63
- $[12] = base;
64
- $[13] = overrides;
65
- $[14] = t5;
39
+ $[6] = base;
40
+ $[7] = overrides;
41
+ $[8] = t2;
66
42
  } else {
67
- t5 = $[14];
43
+ t2 = $[8];
68
44
  }
69
- const stateRef = (0, _react.useRef)(t5);
70
- let t6;
71
- let t7;
72
- if ($[15] !== base || $[16] !== overrides) {
73
- t6 = () => {
45
+ const stateRef = (0, _react.useRef)(t2);
46
+ let t3;
47
+ let t4;
48
+ if ($[9] !== base || $[10] !== overrides) {
49
+ t3 = () => {
74
50
  stateRef.current = {
75
51
  base,
76
52
  overrides
77
53
  };
78
54
  };
79
- t7 = [base, overrides];
80
- $[15] = base;
81
- $[16] = overrides;
82
- $[17] = t6;
83
- $[18] = t7;
55
+ t4 = [base, overrides];
56
+ $[9] = base;
57
+ $[10] = overrides;
58
+ $[11] = t3;
59
+ $[12] = t4;
84
60
  } else {
85
- t6 = $[17];
86
- t7 = $[18];
61
+ t3 = $[11];
62
+ t4 = $[12];
87
63
  }
88
- (0, _react.useEffect)(t6, t7);
64
+ (0, _react.useEffect)(t3, t4);
89
65
  let functions;
90
- if ($[19] !== functionNames) {
66
+ if ($[13] !== functionNames) {
91
67
  functions = {};
92
68
  for (const key of functionNames) {
93
- functions[key] = (...t8) => {
69
+ functions[key] = (...t5) => {
94
70
  var _stateRef$current$ove;
95
- const args = t8;
71
+ const args = t5;
96
72
  const functionKey = key;
97
73
  const implementation = (_stateRef$current$ove = stateRef.current.overrides[functionKey]) !== null && _stateRef$current$ove !== void 0 ? _stateRef$current$ove : stateRef.current.base[functionKey];
98
74
  return implementation(...args);
99
75
  };
100
76
  }
101
- $[19] = functionNames;
102
- $[20] = functions;
77
+ $[13] = functionNames;
78
+ $[14] = functions;
103
79
  } else {
104
- functions = $[20];
80
+ functions = $[14];
105
81
  }
106
82
  return functions;
107
83
  };
@@ -25,14 +25,14 @@ const TrustedDomainsPlugin = trustedDomains => {
25
25
  name: 'trusted-domains',
26
26
  async beforeRequest(args) {
27
27
  const domains = await getTrustedDomains();
28
- args.options.remotes.forEach(remote => {
29
- if ('entry' in remote) {
30
- const parsed = new URL(remote.entry);
31
- if (!domains.some(domain => parsed.hostname.endsWith(domain))) {
32
- throw new TrustedDomainsError(remote.entry);
33
- }
28
+ const scope = args.id.split('/')[0];
29
+ const remote = args.options.remotes.find(remote => (remote.alias || remote.name) === scope);
30
+ if (remote && 'entry' in remote) {
31
+ const parsed = new URL(remote.entry);
32
+ if (!domains.some(domain => parsed.hostname.endsWith(domain))) {
33
+ throw new TrustedDomainsError(remote.entry);
34
34
  }
35
- });
35
+ }
36
36
  return args;
37
37
  }
38
38
  };
@@ -6,7 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.loadTrustedDomains = void 0;
7
7
  var _trustedDomains = require("../constants/trustedDomains");
8
8
  const TRUSTED_DOMAINS_URL = 'https://service-rpc.chayns.net/ConfigurationSettings/TrustedDomains';
9
- const loadTrustedDomains = async () => {
9
+ let trustedDomainsPromise;
10
+ const fetchTrustedDomains = async () => {
10
11
  try {
11
12
  var _AbortSignal$timeout, _AbortSignal;
12
13
  const response = await fetch(TRUSTED_DOMAINS_URL, {
@@ -23,4 +24,8 @@ const loadTrustedDomains = async () => {
23
24
  }
24
25
  return _trustedDomains.DefaultTrustedDomains;
25
26
  };
27
+ const loadTrustedDomains = () => {
28
+ trustedDomainsPromise !== null && trustedDomainsPromise !== void 0 ? trustedDomainsPromise : trustedDomainsPromise = fetchTrustedDomains();
29
+ return trustedDomainsPromise;
30
+ };
26
31
  exports.loadTrustedDomains = loadTrustedDomains;
@@ -1,8 +1,8 @@
1
1
  import { c as _c } from "react-compiler-runtime";
2
- import { useEffect, useMemo, useRef } from 'react';
2
+ import { useEffect, useMemo, useRef, useState } from 'react';
3
3
  import { useFunctions } from './useFunctions';
4
4
  export const useFunctionsWithOverrides = overrideFactory => {
5
- const $ = _c(21);
5
+ const $ = _c(15);
6
6
  const base = useFunctions();
7
7
  let t0;
8
8
  if ($[0] !== base || $[1] !== overrideFactory) {
@@ -15,87 +15,63 @@ export const useFunctionsWithOverrides = overrideFactory => {
15
15
  }
16
16
  const overrides = t0;
17
17
  let t1;
18
- if ($[3] !== base) {
19
- t1 = Object.keys(base);
18
+ if ($[3] !== base || $[4] !== overrides) {
19
+ t1 = () => [...new Set([...Object.keys(base), ...Object.keys(overrides)])];
20
20
  $[3] = base;
21
- $[4] = t1;
21
+ $[4] = overrides;
22
+ $[5] = t1;
22
23
  } else {
23
- t1 = $[4];
24
+ t1 = $[5];
24
25
  }
26
+ const [functionNames] = useState(t1);
25
27
  let t2;
26
- if ($[5] !== overrides) {
27
- t2 = Object.keys(overrides);
28
- $[5] = overrides;
29
- $[6] = t2;
30
- } else {
31
- t2 = $[6];
32
- }
33
- let t3;
34
- if ($[7] !== t1 || $[8] !== t2) {
35
- t3 = new Set([...t1, ...t2]);
36
- $[7] = t1;
37
- $[8] = t2;
38
- $[9] = t3;
39
- } else {
40
- t3 = $[9];
41
- }
42
- let t4;
43
- if ($[10] !== t3) {
44
- t4 = [...t3];
45
- $[10] = t3;
46
- $[11] = t4;
47
- } else {
48
- t4 = $[11];
49
- }
50
- const functionNames = t4;
51
- let t5;
52
- if ($[12] !== base || $[13] !== overrides) {
53
- t5 = {
28
+ if ($[6] !== base || $[7] !== overrides) {
29
+ t2 = {
54
30
  base,
55
31
  overrides
56
32
  };
57
- $[12] = base;
58
- $[13] = overrides;
59
- $[14] = t5;
33
+ $[6] = base;
34
+ $[7] = overrides;
35
+ $[8] = t2;
60
36
  } else {
61
- t5 = $[14];
37
+ t2 = $[8];
62
38
  }
63
- const stateRef = useRef(t5);
64
- let t6;
65
- let t7;
66
- if ($[15] !== base || $[16] !== overrides) {
67
- t6 = () => {
39
+ const stateRef = useRef(t2);
40
+ let t3;
41
+ let t4;
42
+ if ($[9] !== base || $[10] !== overrides) {
43
+ t3 = () => {
68
44
  stateRef.current = {
69
45
  base,
70
46
  overrides
71
47
  };
72
48
  };
73
- t7 = [base, overrides];
74
- $[15] = base;
75
- $[16] = overrides;
76
- $[17] = t6;
77
- $[18] = t7;
49
+ t4 = [base, overrides];
50
+ $[9] = base;
51
+ $[10] = overrides;
52
+ $[11] = t3;
53
+ $[12] = t4;
78
54
  } else {
79
- t6 = $[17];
80
- t7 = $[18];
55
+ t3 = $[11];
56
+ t4 = $[12];
81
57
  }
82
- useEffect(t6, t7);
58
+ useEffect(t3, t4);
83
59
  let functions;
84
- if ($[19] !== functionNames) {
60
+ if ($[13] !== functionNames) {
85
61
  functions = {};
86
62
  for (const key of functionNames) {
87
- functions[key] = (...t8) => {
63
+ functions[key] = (...t5) => {
88
64
  var _stateRef$current$ove;
89
- const args = t8;
65
+ const args = t5;
90
66
  const functionKey = key;
91
67
  const implementation = (_stateRef$current$ove = stateRef.current.overrides[functionKey]) !== null && _stateRef$current$ove !== void 0 ? _stateRef$current$ove : stateRef.current.base[functionKey];
92
68
  return implementation(...args);
93
69
  };
94
70
  }
95
- $[19] = functionNames;
96
- $[20] = functions;
71
+ $[13] = functionNames;
72
+ $[14] = functions;
97
73
  } else {
98
- functions = $[20];
74
+ functions = $[14];
99
75
  }
100
76
  return functions;
101
77
  };
@@ -21,14 +21,14 @@ export const TrustedDomainsPlugin = trustedDomains => {
21
21
  name: 'trusted-domains',
22
22
  async beforeRequest(args) {
23
23
  const domains = await getTrustedDomains();
24
- args.options.remotes.forEach(remote => {
25
- if ('entry' in remote) {
26
- const parsed = new URL(remote.entry);
27
- if (!domains.some(domain => parsed.hostname.endsWith(domain))) {
28
- throw new TrustedDomainsError(remote.entry);
29
- }
24
+ const scope = args.id.split('/')[0];
25
+ const remote = args.options.remotes.find(remote => (remote.alias || remote.name) === scope);
26
+ if (remote && 'entry' in remote) {
27
+ const parsed = new URL(remote.entry);
28
+ if (!domains.some(domain => parsed.hostname.endsWith(domain))) {
29
+ throw new TrustedDomainsError(remote.entry);
30
30
  }
31
- });
31
+ }
32
32
  return args;
33
33
  }
34
34
  };
@@ -1,6 +1,7 @@
1
1
  import { DefaultTrustedDomains } from '../constants/trustedDomains';
2
2
  const TRUSTED_DOMAINS_URL = 'https://service-rpc.chayns.net/ConfigurationSettings/TrustedDomains';
3
- export const loadTrustedDomains = async () => {
3
+ let trustedDomainsPromise;
4
+ const fetchTrustedDomains = async () => {
4
5
  try {
5
6
  var _AbortSignal$timeout, _AbortSignal;
6
7
  const response = await fetch(TRUSTED_DOMAINS_URL, {
@@ -16,4 +17,8 @@ export const loadTrustedDomains = async () => {
16
17
  return DefaultTrustedDomains;
17
18
  }
18
19
  return DefaultTrustedDomains;
20
+ };
21
+ export const loadTrustedDomains = () => {
22
+ trustedDomainsPromise !== null && trustedDomainsPromise !== void 0 ? trustedDomainsPromise : trustedDomainsPromise = fetchTrustedDomains();
23
+ return trustedDomainsPromise;
19
24
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-api",
3
- "version": "3.6.0-beta.4",
3
+ "version": "3.6.1",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",