@meshconnect/web-link-sdk 3.4.1 → 3.5.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 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;
@@ -172,6 +173,7 @@ function eventsListener(event) {
172
173
  export var createLink = function (options) {
173
174
  var openLink = function (linkToken, customIframeId) {
174
175
  var _a, _b;
176
+ removePrewarmIframe();
175
177
  if (!linkToken) {
176
178
  (_a = options === null || options === void 0 ? void 0 : options.onExit) === null || _a === void 0 ? void 0 : _a.call(options, 'Invalid link token!');
177
179
  return;
@@ -185,6 +187,7 @@ export var createLink = function (options) {
185
187
  }
186
188
  linkUrl = addLanguage(linkUrl, currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.language);
187
189
  linkUrl = addDisplayFiatCurrency(linkUrl, currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.displayFiatCurrency);
190
+ linkUrl = addTheme(linkUrl, currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.theme);
188
191
  linkTokenOrigin = new URL(linkUrl).origin;
189
192
  window.removeEventListener('message', eventsListener);
190
193
  if (customIframeId) {
@@ -232,7 +235,17 @@ function addLanguage(linkUrl, language) {
232
235
  }
233
236
  function addDisplayFiatCurrency(linkUrl, displayFiatCurrency) {
234
237
  if (displayFiatCurrency) {
235
- return "".concat(linkUrl).concat(linkUrl.includes('?') ? '&' : '?', "fiatCur=").concat(displayFiatCurrency);
238
+ var queryString = linkUrl.includes('?') ? '&' : '?';
239
+ return "".concat(linkUrl).concat(queryString, "fiatCur=").concat(displayFiatCurrency);
236
240
  }
237
241
  return linkUrl;
238
242
  }
243
+ function addTheme(linkUrl, theme) {
244
+ if (theme) {
245
+ return "".concat(linkUrl).concat(linkUrl.includes('?') ? '&' : '?', "th=").concat(theme);
246
+ }
247
+ return linkUrl;
248
+ }
249
+ if (!window.meshLinkShouldSkipPrewarm) {
250
+ createPrewarmIframe();
251
+ }
package/README.md CHANGED
@@ -105,6 +105,7 @@ After successfull authentication on the Link session, the popup will be closed a
105
105
  | `accessTokens` | `IntegrationAccessToken[]` | An array of integration access tokens |
106
106
  | `language` | `'en' \| undefined` | Link UI language |
107
107
  | `displayFiatCurrency` | `'USD' \| undefined` | A fiat currency to display fiat equivalent of a crypto amount |
108
+ | `theme` | `'dark' \| 'light' \| 'system' \| undefined` | Color theme of Link UI interface |
108
109
 
109
110
  #### `createLink` return value
110
111
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshconnect/web-link-sdk",
3
- "version": "3.4.1",
3
+ "version": "3.5.0",
4
4
  "description": "A client-side JS library for integrating with Mesh Connect",
5
5
  "exports": "./index.js",
6
6
  "license": "MIT",
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Creates a hidden iframe for pre-warming the catalog.
3
+ * The iframe loads in the background and will be reused when openLink is called.
4
+ */
5
+ export declare function createPrewarmIframe(): void;
6
+ export declare function removePrewarmIframe(): void;
@@ -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
@@ -139,8 +139,17 @@ export interface LinkOptions {
139
139
  * Default: 'USD'
140
140
  */
141
141
  displayFiatCurrency?: string;
142
+ /**
143
+ * Link UI theme. Possible values: 'dark', 'light' and 'system'.
144
+ */
145
+ theme?: 'dark' | 'light' | 'system';
142
146
  }
143
147
  export interface LinkStyle {
144
148
  ir: number;
145
149
  io: number;
146
150
  }
151
+ declare global {
152
+ interface Window {
153
+ meshLinkShouldSkipPrewarm?: boolean;
154
+ }
155
+ }
@@ -1 +1 @@
1
- export declare const sdkVersion = "3.4.1";
1
+ export declare const sdkVersion = "3.5.0";
package/utils/version.js CHANGED
@@ -1 +1 @@
1
- export var sdkVersion = '3.4.1';
1
+ export var sdkVersion = '3.5.0';