@meshconnect/web-link-sdk 3.4.2 → 3.6.0
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/Link.js +7 -7
- package/package.json +1 -1
- package/utils/prewarm.d.ts +6 -0
- package/utils/prewarm.js +33 -0
- package/utils/types.d.ts +5 -5
- package/utils/version.d.ts +1 -1
- package/utils/version.js +1 -1
package/Link.js
CHANGED
|
@@ -49,6 +49,7 @@ import { addPopup, iframeId, removePopup } from './utils/popup';
|
|
|
49
49
|
import { isLinkEventTypeKey } from './utils/event-types';
|
|
50
50
|
import { sdkSpecs } from './utils/sdk-specs';
|
|
51
51
|
import { BridgeParent } from '@meshconnect/uwc-bridge-parent';
|
|
52
|
+
import { createPrewarmIframe, removePrewarmIframe } from './utils/prewarm';
|
|
52
53
|
var currentOptions;
|
|
53
54
|
var targetOrigin;
|
|
54
55
|
var linkTokenOrigin;
|
|
@@ -132,12 +133,6 @@ function handleLinkEvent(event) {
|
|
|
132
133
|
payload: currentOptions.accessTokens
|
|
133
134
|
});
|
|
134
135
|
}
|
|
135
|
-
if (currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.transferDestinationTokens) {
|
|
136
|
-
sendMessageToIframe({
|
|
137
|
-
type: 'frontTransferDestinationTokens',
|
|
138
|
-
payload: currentOptions.transferDestinationTokens
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
136
|
(_j = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _j === void 0 ? void 0 : _j.call(currentOptions, { type: 'pageLoaded' });
|
|
142
137
|
break;
|
|
143
138
|
}
|
|
@@ -172,6 +167,7 @@ function eventsListener(event) {
|
|
|
172
167
|
export var createLink = function (options) {
|
|
173
168
|
var openLink = function (linkToken, customIframeId) {
|
|
174
169
|
var _a, _b;
|
|
170
|
+
removePrewarmIframe();
|
|
175
171
|
if (!linkToken) {
|
|
176
172
|
(_a = options === null || options === void 0 ? void 0 : options.onExit) === null || _a === void 0 ? void 0 : _a.call(options, 'Invalid link token!');
|
|
177
173
|
return;
|
|
@@ -233,7 +229,8 @@ function addLanguage(linkUrl, language) {
|
|
|
233
229
|
}
|
|
234
230
|
function addDisplayFiatCurrency(linkUrl, displayFiatCurrency) {
|
|
235
231
|
if (displayFiatCurrency) {
|
|
236
|
-
|
|
232
|
+
var queryString = linkUrl.includes('?') ? '&' : '?';
|
|
233
|
+
return "".concat(linkUrl).concat(queryString, "fiatCur=").concat(displayFiatCurrency);
|
|
237
234
|
}
|
|
238
235
|
return linkUrl;
|
|
239
236
|
}
|
|
@@ -243,3 +240,6 @@ function addTheme(linkUrl, theme) {
|
|
|
243
240
|
}
|
|
244
241
|
return linkUrl;
|
|
245
242
|
}
|
|
243
|
+
if (!window.meshLinkShouldSkipPrewarm) {
|
|
244
|
+
createPrewarmIframe();
|
|
245
|
+
}
|
package/package.json
CHANGED
package/utils/prewarm.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var prewarmContainerId = 'mesh-link-prewarm-container';
|
|
2
|
+
var prewarmIframeId = 'mesh-link-prewarm-iframe';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a hidden iframe for pre-warming the catalog.
|
|
5
|
+
* The iframe loads in the background and will be reused when openLink is called.
|
|
6
|
+
*/
|
|
7
|
+
export function createPrewarmIframe() {
|
|
8
|
+
// Check if prewarm container already exists
|
|
9
|
+
if (document.getElementById(prewarmContainerId)) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
var url = 'https://web.meshconnect.com/prewarm';
|
|
13
|
+
// Create hidden container
|
|
14
|
+
var container = document.createElement('div');
|
|
15
|
+
container.id = prewarmContainerId;
|
|
16
|
+
container.style.cssText =
|
|
17
|
+
'display: none; position: fixed; top: 0; left: 0; width: 0; height: 0; pointer-events: none; visibility: hidden;';
|
|
18
|
+
// Create iframe and immediately load the catalog to pre-load assets
|
|
19
|
+
var iframe = document.createElement('iframe');
|
|
20
|
+
iframe.id = prewarmIframeId;
|
|
21
|
+
iframe.style.cssText = 'width: 100%; height: 100%; border: none;';
|
|
22
|
+
iframe.loading = 'eager';
|
|
23
|
+
// Load the base catalog URL to pre-load JS, CSS, and other static assets
|
|
24
|
+
iframe.src = url;
|
|
25
|
+
container.appendChild(iframe);
|
|
26
|
+
document.body.appendChild(container);
|
|
27
|
+
}
|
|
28
|
+
export function removePrewarmIframe() {
|
|
29
|
+
var container = document.getElementById(prewarmContainerId);
|
|
30
|
+
if (container) {
|
|
31
|
+
container.remove();
|
|
32
|
+
}
|
|
33
|
+
}
|
package/utils/types.d.ts
CHANGED
|
@@ -125,11 +125,6 @@ export interface LinkOptions {
|
|
|
125
125
|
* These access tokens are used to initialize crypto transfers flow at 'Select asset step'
|
|
126
126
|
*/
|
|
127
127
|
accessTokens?: IntegrationAccessToken[];
|
|
128
|
-
/**
|
|
129
|
-
* (Optional) An array of integration access tokens.
|
|
130
|
-
* Can be used to initialize the crypto transfers flow as an alternative to the target addresses.
|
|
131
|
-
*/
|
|
132
|
-
transferDestinationTokens?: IntegrationAccessToken[];
|
|
133
128
|
/**
|
|
134
129
|
* Link UI language. Supported: 'en', 'ru'. Can be set as 'en-US', 'ru-RU', etc.
|
|
135
130
|
*/
|
|
@@ -148,3 +143,8 @@ export interface LinkStyle {
|
|
|
148
143
|
ir: number;
|
|
149
144
|
io: number;
|
|
150
145
|
}
|
|
146
|
+
declare global {
|
|
147
|
+
interface Window {
|
|
148
|
+
meshLinkShouldSkipPrewarm?: boolean;
|
|
149
|
+
}
|
|
150
|
+
}
|
package/utils/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const sdkVersion = "3.
|
|
1
|
+
export declare const sdkVersion = "3.6.0";
|
package/utils/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export var sdkVersion = '3.
|
|
1
|
+
export var sdkVersion = '3.6.0';
|