@meshconnect/web-link-sdk 3.4.2 → 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;
@@ -233,7 +235,8 @@ function addLanguage(linkUrl, language) {
233
235
  }
234
236
  function addDisplayFiatCurrency(linkUrl, displayFiatCurrency) {
235
237
  if (displayFiatCurrency) {
236
- return "".concat(linkUrl).concat(linkUrl.includes('?') ? '&' : '?', "fiatCur=").concat(displayFiatCurrency);
238
+ var queryString = linkUrl.includes('?') ? '&' : '?';
239
+ return "".concat(linkUrl).concat(queryString, "fiatCur=").concat(displayFiatCurrency);
237
240
  }
238
241
  return linkUrl;
239
242
  }
@@ -243,3 +246,6 @@ function addTheme(linkUrl, theme) {
243
246
  }
244
247
  return linkUrl;
245
248
  }
249
+ if (!window.meshLinkShouldSkipPrewarm) {
250
+ createPrewarmIframe();
251
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshconnect/web-link-sdk",
3
- "version": "3.4.2",
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
@@ -148,3 +148,8 @@ export interface LinkStyle {
148
148
  ir: number;
149
149
  io: number;
150
150
  }
151
+ declare global {
152
+ interface Window {
153
+ meshLinkShouldSkipPrewarm?: boolean;
154
+ }
155
+ }
@@ -1 +1 @@
1
- export declare const sdkVersion = "3.4.2";
1
+ export declare const sdkVersion = "3.5.0";
package/utils/version.js CHANGED
@@ -1 +1 @@
1
- export var sdkVersion = '3.4.2';
1
+ export var sdkVersion = '3.5.0';