@dynamic-labs/sdk-react-core 2.3.2 → 2.3.3
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/CHANGELOG.md +7 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +13 -13
- package/src/lib/context/DynamicContext/DynamicContext.cjs +20 -25
- package/src/lib/context/DynamicContext/DynamicContext.js +20 -25
- package/src/lib/shared/utils/hooks/index.d.ts +2 -1
- package/src/lib/shared/utils/hooks/usePrefetch/index.d.ts +1 -0
- package/src/lib/shared/utils/hooks/usePrefetch/usePrefetch.cjs +51 -0
- package/src/lib/shared/utils/hooks/usePrefetch/usePrefetch.d.ts +23 -0
- package/src/lib/shared/utils/hooks/usePrefetch/usePrefetch.js +47 -0
- package/src/lib/widgets/DynamicWidget/index.d.ts +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
|
|
2
|
+
### [2.3.3](https://github.com/dynamic-labs/DynamicAuth/compare/v2.3.2...v2.3.3) (2024-07-18)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* add project setting prefetch ([#6368](https://github.com/dynamic-labs/DynamicAuth/issues/6368)) ([4f3009e](https://github.com/dynamic-labs/DynamicAuth/commit/4f3009ec1fbe110be73bd7b775cfb040592a8b2a))
|
|
8
|
+
|
|
2
9
|
### [2.3.2](https://github.com/dynamic-labs/DynamicAuth/compare/v2.3.1...v2.3.2) (2024-07-16)
|
|
3
10
|
|
|
4
11
|
### [2.3.1](https://github.com/dynamic-labs/DynamicAuth/compare/v2.3.1-alpha.0...v2.3.1) (2024-07-13)
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
|
|
@@ -17,18 +17,18 @@
|
|
|
17
17
|
"react-i18next": "13.5.0",
|
|
18
18
|
"yup": "0.32.11",
|
|
19
19
|
"react-international-phone": "4.2.5",
|
|
20
|
-
"@dynamic-labs/iconic": "2.3.
|
|
21
|
-
"@dynamic-labs/logger": "2.3.
|
|
22
|
-
"@dynamic-labs/multi-wallet": "2.3.
|
|
23
|
-
"@dynamic-labs/rpc-provider-ethereum": "2.3.
|
|
24
|
-
"@dynamic-labs/rpc-provider-solana": "2.3.
|
|
25
|
-
"@dynamic-labs/rpc-providers": "2.3.
|
|
26
|
-
"@dynamic-labs/store": "2.3.
|
|
27
|
-
"@dynamic-labs/types": "2.3.
|
|
28
|
-
"@dynamic-labs/utils": "2.3.
|
|
29
|
-
"@dynamic-labs/viem-utils": "2.3.
|
|
30
|
-
"@dynamic-labs/wallet-book": "2.3.
|
|
31
|
-
"@dynamic-labs/wallet-connector-core": "2.3.
|
|
20
|
+
"@dynamic-labs/iconic": "2.3.3",
|
|
21
|
+
"@dynamic-labs/logger": "2.3.3",
|
|
22
|
+
"@dynamic-labs/multi-wallet": "2.3.3",
|
|
23
|
+
"@dynamic-labs/rpc-provider-ethereum": "2.3.3",
|
|
24
|
+
"@dynamic-labs/rpc-provider-solana": "2.3.3",
|
|
25
|
+
"@dynamic-labs/rpc-providers": "2.3.3",
|
|
26
|
+
"@dynamic-labs/store": "2.3.3",
|
|
27
|
+
"@dynamic-labs/types": "2.3.3",
|
|
28
|
+
"@dynamic-labs/utils": "2.3.3",
|
|
29
|
+
"@dynamic-labs/viem-utils": "2.3.3",
|
|
30
|
+
"@dynamic-labs/wallet-book": "2.3.3",
|
|
31
|
+
"@dynamic-labs/wallet-connector-core": "2.3.3",
|
|
32
32
|
"eventemitter3": "5.0.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
@@ -25,6 +25,7 @@ var values = require('../../utils/constants/values.cjs');
|
|
|
25
25
|
var localStorage = require('../../shared/utils/classes/storage/localStorage.cjs');
|
|
26
26
|
var useGlobalLoading = require('../../shared/utils/hooks/useGlobalLoading/useGlobalLoading.cjs');
|
|
27
27
|
var useLocalStorage = require('../../shared/utils/hooks/useLocalStorage/useLocalStorage.cjs');
|
|
28
|
+
var usePrefetch = require('../../shared/utils/hooks/usePrefetch/usePrefetch.cjs');
|
|
28
29
|
require('../../shared/consts/index.cjs');
|
|
29
30
|
var CaptchaContext = require('../CaptchaContext/CaptchaContext.cjs');
|
|
30
31
|
var ErrorContext = require('../ErrorContext/ErrorContext.cjs');
|
|
@@ -34,6 +35,7 @@ var getMinAuthToken = require('../../utils/functions/getMinAuthToken/getMinAuthT
|
|
|
34
35
|
require('react-international-phone');
|
|
35
36
|
require('viem');
|
|
36
37
|
require('viem/chains');
|
|
38
|
+
var version = require('../../../version.cjs');
|
|
37
39
|
var ApiEndpoint = require('../../config/ApiEndpoint.cjs');
|
|
38
40
|
var userActions = require('../../store/actions/userActions/userActions.cjs');
|
|
39
41
|
var settings = require('../../data/api/settings/settings.cjs');
|
|
@@ -674,31 +676,24 @@ const InnerDynamicContextProvider = ({ children, theme, settings: settings$1, lo
|
|
|
674
676
|
walletUiUtils,
|
|
675
677
|
walletsFilter,
|
|
676
678
|
]);
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
addPrefetch({
|
|
696
|
-
as: 'fetch',
|
|
697
|
-
href: walletBook.getWalletBookCdnUrl(),
|
|
698
|
-
id: 'wallet-book',
|
|
699
|
-
type: 'application/json',
|
|
700
|
-
});
|
|
701
|
-
}, []);
|
|
679
|
+
usePrefetch.usePrefetch({
|
|
680
|
+
as: 'image',
|
|
681
|
+
href: iconic.getIconicSpriteUrl(),
|
|
682
|
+
id: 'sprite',
|
|
683
|
+
type: 'image/svg+xml',
|
|
684
|
+
});
|
|
685
|
+
usePrefetch.usePrefetch({
|
|
686
|
+
as: 'fetch',
|
|
687
|
+
href: walletBook.getWalletBookCdnUrl(),
|
|
688
|
+
id: 'wallet-book',
|
|
689
|
+
type: 'application/json',
|
|
690
|
+
});
|
|
691
|
+
usePrefetch.usePrefetch({
|
|
692
|
+
as: 'fetch',
|
|
693
|
+
href: `${ApiEndpoint.getBaseUrl()}/sdk/${environmentId}/settings?sdkVersion=${encodeURIComponent(`WalletKit/${version.VERSION}`)}`,
|
|
694
|
+
id: `project-settings-${environmentId}`,
|
|
695
|
+
type: 'application/json',
|
|
696
|
+
});
|
|
702
697
|
// DYN-1140 - Opens Widget when multiWalletWidgetState changes
|
|
703
698
|
React.useEffect(() => {
|
|
704
699
|
// If statement to secure SingleWallet widget
|
|
@@ -21,6 +21,7 @@ import { DEFAULT_NUMBER_OF_WALLETS_TO_SHOW } from '../../utils/constants/values.
|
|
|
21
21
|
import { LocalStorage } from '../../shared/utils/classes/storage/localStorage.js';
|
|
22
22
|
import { useGlobalLoading } from '../../shared/utils/hooks/useGlobalLoading/useGlobalLoading.js';
|
|
23
23
|
import { useLocalStorage } from '../../shared/utils/hooks/useLocalStorage/useLocalStorage.js';
|
|
24
|
+
import { usePrefetch } from '../../shared/utils/hooks/usePrefetch/usePrefetch.js';
|
|
24
25
|
import '../../shared/consts/index.js';
|
|
25
26
|
import { CaptchaContextProvider } from '../CaptchaContext/CaptchaContext.js';
|
|
26
27
|
import { ErrorContextProvider } from '../ErrorContext/ErrorContext.js';
|
|
@@ -30,6 +31,7 @@ import { getMinAuthToken } from '../../utils/functions/getMinAuthToken/getMinAut
|
|
|
30
31
|
import 'react-international-phone';
|
|
31
32
|
import 'viem';
|
|
32
33
|
import 'viem/chains';
|
|
34
|
+
import { VERSION } from '../../../version.js';
|
|
33
35
|
import ApiEndpoint from '../../config/ApiEndpoint.js';
|
|
34
36
|
import { setUser } from '../../store/actions/userActions/userActions.js';
|
|
35
37
|
import { sendDynamicProps } from '../../data/api/settings/settings.js';
|
|
@@ -670,31 +672,24 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, enable
|
|
|
670
672
|
walletUiUtils,
|
|
671
673
|
walletsFilter,
|
|
672
674
|
]);
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
addPrefetch({
|
|
692
|
-
as: 'fetch',
|
|
693
|
-
href: getWalletBookCdnUrl(),
|
|
694
|
-
id: 'wallet-book',
|
|
695
|
-
type: 'application/json',
|
|
696
|
-
});
|
|
697
|
-
}, []);
|
|
675
|
+
usePrefetch({
|
|
676
|
+
as: 'image',
|
|
677
|
+
href: getIconicSpriteUrl(),
|
|
678
|
+
id: 'sprite',
|
|
679
|
+
type: 'image/svg+xml',
|
|
680
|
+
});
|
|
681
|
+
usePrefetch({
|
|
682
|
+
as: 'fetch',
|
|
683
|
+
href: getWalletBookCdnUrl(),
|
|
684
|
+
id: 'wallet-book',
|
|
685
|
+
type: 'application/json',
|
|
686
|
+
});
|
|
687
|
+
usePrefetch({
|
|
688
|
+
as: 'fetch',
|
|
689
|
+
href: `${ApiEndpoint.getBaseUrl()}/sdk/${environmentId}/settings?sdkVersion=${encodeURIComponent(`WalletKit/${VERSION}`)}`,
|
|
690
|
+
id: `project-settings-${environmentId}`,
|
|
691
|
+
type: 'application/json',
|
|
692
|
+
});
|
|
698
693
|
// DYN-1140 - Opens Widget when multiWalletWidgetState changes
|
|
699
694
|
useEffect(() => {
|
|
700
695
|
// If statement to secure SingleWallet widget
|
|
@@ -5,4 +5,5 @@ export { useLocalStorage } from './useLocalStorage';
|
|
|
5
5
|
export { useMediaQuery } from './useMediaQuery';
|
|
6
6
|
export { useOnClickOutside } from './useOnClickOutside';
|
|
7
7
|
export { usePreventPageScroll } from './usePreventPageScroll';
|
|
8
|
-
export
|
|
8
|
+
export { useThrottle } from './useThrottle';
|
|
9
|
+
export { usePrefetch } from './usePrefetch';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { usePrefetch } from './usePrefetch';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
require('@dynamic-labs/sdk-api-core');
|
|
7
|
+
require('../../../logger.cjs');
|
|
8
|
+
require('@dynamic-labs/iconic');
|
|
9
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
10
|
+
require('react/jsx-runtime');
|
|
11
|
+
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
12
|
+
require('react');
|
|
13
|
+
require('@dynamic-labs/wallet-book');
|
|
14
|
+
var isSSR = require('../../functions/isSSR/isSSR.cjs');
|
|
15
|
+
require('../../../../utils/constants/colors.cjs');
|
|
16
|
+
require('../../../../utils/constants/values.cjs');
|
|
17
|
+
require('../../classes/storage/localStorage.cjs');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Prefetches a resource
|
|
21
|
+
* Adds a link element to the head of the document with the provided attributes
|
|
22
|
+
* when the element is not already present
|
|
23
|
+
* @param {PrefetchProps} prefetchProps
|
|
24
|
+
* @returns {void}
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* usePrefetch({
|
|
28
|
+
* href: 'https://example.com/image.jpg',
|
|
29
|
+
* as: 'image',
|
|
30
|
+
* type: 'image/jpeg',
|
|
31
|
+
* id: 'image-prefetch',
|
|
32
|
+
* });
|
|
33
|
+
*/
|
|
34
|
+
const usePrefetch = ({ as, href, id, type }) => {
|
|
35
|
+
// Do not run on server side
|
|
36
|
+
if (isSSR.isSSR())
|
|
37
|
+
return;
|
|
38
|
+
const predefinedElement = document.head.querySelector(`#${id}`);
|
|
39
|
+
// Do not add the element if it already exists
|
|
40
|
+
if (predefinedElement)
|
|
41
|
+
return;
|
|
42
|
+
const element = document.createElement('link');
|
|
43
|
+
element.setAttribute('id', id);
|
|
44
|
+
element.setAttribute('rel', 'prefetch');
|
|
45
|
+
element.setAttribute('href', href);
|
|
46
|
+
element.setAttribute('as', as);
|
|
47
|
+
element.setAttribute('type', type);
|
|
48
|
+
document.head.insertAdjacentElement('beforeend', element);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
exports.usePrefetch = usePrefetch;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
type PrefetchProps = {
|
|
2
|
+
href: string;
|
|
3
|
+
as: string;
|
|
4
|
+
type: string;
|
|
5
|
+
id: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Prefetches a resource
|
|
9
|
+
* Adds a link element to the head of the document with the provided attributes
|
|
10
|
+
* when the element is not already present
|
|
11
|
+
* @param {PrefetchProps} prefetchProps
|
|
12
|
+
* @returns {void}
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* usePrefetch({
|
|
16
|
+
* href: 'https://example.com/image.jpg',
|
|
17
|
+
* as: 'image',
|
|
18
|
+
* type: 'image/jpeg',
|
|
19
|
+
* id: 'image-prefetch',
|
|
20
|
+
* });
|
|
21
|
+
*/
|
|
22
|
+
export declare const usePrefetch: ({ as, href, id, type }: PrefetchProps) => void;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import '@dynamic-labs/sdk-api-core';
|
|
3
|
+
import '../../../logger.js';
|
|
4
|
+
import '@dynamic-labs/iconic';
|
|
5
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
6
|
+
import 'react/jsx-runtime';
|
|
7
|
+
import '../../../../context/ViewContext/ViewContext.js';
|
|
8
|
+
import 'react';
|
|
9
|
+
import '@dynamic-labs/wallet-book';
|
|
10
|
+
import { isSSR } from '../../functions/isSSR/isSSR.js';
|
|
11
|
+
import '../../../../utils/constants/colors.js';
|
|
12
|
+
import '../../../../utils/constants/values.js';
|
|
13
|
+
import '../../classes/storage/localStorage.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Prefetches a resource
|
|
17
|
+
* Adds a link element to the head of the document with the provided attributes
|
|
18
|
+
* when the element is not already present
|
|
19
|
+
* @param {PrefetchProps} prefetchProps
|
|
20
|
+
* @returns {void}
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* usePrefetch({
|
|
24
|
+
* href: 'https://example.com/image.jpg',
|
|
25
|
+
* as: 'image',
|
|
26
|
+
* type: 'image/jpeg',
|
|
27
|
+
* id: 'image-prefetch',
|
|
28
|
+
* });
|
|
29
|
+
*/
|
|
30
|
+
const usePrefetch = ({ as, href, id, type }) => {
|
|
31
|
+
// Do not run on server side
|
|
32
|
+
if (isSSR())
|
|
33
|
+
return;
|
|
34
|
+
const predefinedElement = document.head.querySelector(`#${id}`);
|
|
35
|
+
// Do not add the element if it already exists
|
|
36
|
+
if (predefinedElement)
|
|
37
|
+
return;
|
|
38
|
+
const element = document.createElement('link');
|
|
39
|
+
element.setAttribute('id', id);
|
|
40
|
+
element.setAttribute('rel', 'prefetch');
|
|
41
|
+
element.setAttribute('href', href);
|
|
42
|
+
element.setAttribute('as', as);
|
|
43
|
+
element.setAttribute('type', type);
|
|
44
|
+
document.head.insertAdjacentElement('beforeend', element);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { usePrefetch };
|