@imtbl/sdk 1.5.3-alpha.5 → 1.5.4-alpha.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.
package/dist/index.cjs CHANGED
@@ -174,7 +174,7 @@ const flattenProperties$1 = (properties) => {
174
174
  };
175
175
 
176
176
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
177
- const SDK_VERSION$1 = '1.5.3-alpha.5';
177
+ const SDK_VERSION$1 = '1.5.4-alpha.1';
178
178
  const getReferrer$1 = () => {
179
179
  if (isNode$1()) {
180
180
  return '';
@@ -11289,7 +11289,7 @@ class MultiRollupApiClients {
11289
11289
  }
11290
11290
 
11291
11291
  // eslint-disable-next-line @typescript-eslint/naming-convention
11292
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.5.3-alpha.5' };
11292
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.5.4-alpha.1' };
11293
11293
  const createConfig = ({ basePath, headers, }) => {
11294
11294
  if (!basePath.trim()) {
11295
11295
  throw Error('basePath can not be empty');
@@ -11361,7 +11361,7 @@ class APIError extends Error {
11361
11361
 
11362
11362
  /* eslint-disable implicit-arrow-linebreak */
11363
11363
  const defaultHeaders = {
11364
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.5.3-alpha.5',
11364
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.5.4-alpha.1',
11365
11365
  };
11366
11366
  /**
11367
11367
  * createAPIConfiguration to create a custom Configuration
@@ -11794,7 +11794,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
11794
11794
  chainID,
11795
11795
  coreContractAddress,
11796
11796
  registrationContractAddress,
11797
- sdkVersion: 'ts-immutable-sdk-1.5.3-alpha.5',
11797
+ sdkVersion: 'ts-immutable-sdk-1.5.4-alpha.1',
11798
11798
  });
11799
11799
  /**
11800
11800
  * Sets `sdkVersion` at the time of build
@@ -37448,7 +37448,7 @@ const flattenProperties = (properties) => {
37448
37448
  };
37449
37449
 
37450
37450
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
37451
- const SDK_VERSION = '1.5.3-alpha.5';
37451
+ const SDK_VERSION = '1.5.4-alpha.1';
37452
37452
  const getReferrer = () => {
37453
37453
  if (isNode()) {
37454
37454
  return '';
@@ -42615,7 +42615,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
42615
42615
  maxPriorityFeePerGas: ethers.BigNumber.from(10e9),
42616
42616
  };
42617
42617
 
42618
- const SDK_VERSION_MARKER = '1.5.3-alpha.5';
42618
+ const SDK_VERSION_MARKER = '1.5.4-alpha.1';
42619
42619
  // This SDK version is replaced by the `yarn build` command ran on the root level
42620
42620
  const globalPackageVersion = () => SDK_VERSION_MARKER;
42621
42621
 
@@ -46230,28 +46230,34 @@ function validateAndBuildVersion(version) {
46230
46230
  return validatedVersion;
46231
46231
  }
46232
46232
 
46233
- function loadUnresolved(version) {
46233
+ // Loads the checkout widgets bundle from the CDN and appends the script to the document head
46234
+ function loadUnresolvedBundle(version) {
46234
46235
  if (window === undefined) {
46235
46236
  throw new Error('missing window object: please run Checkout client side');
46236
46237
  }
46237
46238
  if (document === undefined) {
46238
46239
  throw new Error('missing document object: please run Checkout client side');
46239
46240
  }
46240
- // const scriptId = 'immutable-checkout-widgets-bundle';
46241
+ const scriptId = 'immutable-checkout-widgets-bundle';
46241
46242
  const validVersion = validateAndBuildVersion(version);
46242
46243
  // Prevent the script to be loaded more than once
46243
46244
  // by checking the presence of the script and its version.
46244
- // const initScript = document.getElementById(scriptId) as HTMLScriptElement;
46245
- // if (initScript) return { loaded: true, element: initScript };
46246
- // const tag = document.createElement('script');
46247
- const cdnUrl = `https://cdn.jsdelivr.net/npm/@imtbl/sdk@${validVersion}/dist/browser/checkout/widgets.js`;
46248
- // if (useLocalBundle()) cdnUrl = `http://${window.location.host}/lib/js/widgets.js`;
46249
- // tag.setAttribute('id', scriptId);
46250
- // tag.setAttribute('data-version', validVersion);
46251
- // tag.setAttribute('type', 'module');
46252
- // tag.setAttribute('src', cdnUrl);
46253
- // document.head.appendChild(tag);
46254
- return { loaded: false, cdnUrl };
46245
+ const initScript = document.getElementById(scriptId);
46246
+ if (initScript)
46247
+ return { loaded: true, element: initScript };
46248
+ const tag = document.createElement('script');
46249
+ let cdnUrl = `https://cdn.jsdelivr.net/npm/@imtbl/sdk@${validVersion}/dist/browser/checkout/widgets.js`;
46250
+ tag.setAttribute('id', scriptId);
46251
+ tag.setAttribute('data-version', validVersion);
46252
+ tag.setAttribute('src', cdnUrl);
46253
+ document.head.appendChild(tag);
46254
+ return { loaded: false, element: tag };
46255
+ }
46256
+ // Gets the CDN url for the split checkout widgets bundle
46257
+ function getCdnUrl(version) {
46258
+ const validVersion = validateAndBuildVersion(version);
46259
+ let cdnUrl = `https://cdn.jsdelivr.net/npm/@imtbl/sdk@${validVersion}/dist/browser/checkout/widgets-esm.js`;
46260
+ return cdnUrl;
46255
46261
  }
46256
46262
 
46257
46263
  const PUBLISHABLE_KEY_PREFIX = 'pk_imapik-';
@@ -46330,6 +46336,7 @@ const SANDBOX_CONFIGURATION = {
46330
46336
  },
46331
46337
  passport: undefined,
46332
46338
  };
46339
+ const WIDGETS_SCRIPT_TIMEOUT = 100;
46333
46340
  // Checkout SDK
46334
46341
  class Checkout {
46335
46342
  readOnlyProviders;
@@ -46359,19 +46366,46 @@ class Checkout {
46359
46366
  const checkout = this;
46360
46367
  // Preload the configurations
46361
46368
  await checkout.config.remote.getConfig();
46362
- const load = loadUnresolved(init.version);
46363
- const checkoutWidgetsModule = await import(/* webpackIgnore: true */ load.cdnUrl);
46364
- const factory = new Promise((resolve, reject) => {
46365
- try {
46369
+ // Resolves the factory for the esm build of the widgets
46370
+ if (init.useEsModules) {
46371
+ const cdnUrl = getCdnUrl(init.version);
46372
+ // WebpackIgnore comment required to prevent webpack modifying the import statement and
46373
+ // breaking the dynamic import in certain applications integrating checkout
46374
+ const checkoutWidgetsModule = await import(/* webpackIgnore: true */ cdnUrl);
46375
+ const factory = new Promise((resolve, reject) => {
46366
46376
  if (checkoutWidgetsModule && checkoutWidgetsModule.WidgetsFactory) {
46367
46377
  resolve(new checkoutWidgetsModule.WidgetsFactory(checkout, init.config));
46368
46378
  }
46369
46379
  else {
46370
- throw new Error('WidgetsFactory is not found in the imported module.');
46380
+ reject(new CheckoutError('Unable to resolve the WidgetsFactory from the checkout widgets module', CheckoutErrorType.WIDGETS_SCRIPT_LOAD_ERROR));
46381
+ }
46382
+ });
46383
+ return factory;
46384
+ }
46385
+ // Resolves the factory for the umd build of the widgets
46386
+ const factory = new Promise((resolve, reject) => {
46387
+ function checkForWidgetsBundleLoaded() {
46388
+ if (typeof ImmutableCheckoutWidgets !== 'undefined') {
46389
+ resolve(new ImmutableCheckoutWidgets.WidgetsFactory(checkout, init.config));
46390
+ }
46391
+ else {
46392
+ // If ImmutableCheckoutWidgets is not defined, wait for set amount of time.
46393
+ // When time has elapsed, check again if ImmutableCheckoutWidgets is defined.
46394
+ // Once it's defined, the promise will resolve and setTimeout won't be called again.
46395
+ setTimeout(checkForWidgetsBundleLoaded, WIDGETS_SCRIPT_TIMEOUT);
46371
46396
  }
46372
46397
  }
46373
- catch (error) {
46374
- reject(error);
46398
+ try {
46399
+ const script = loadUnresolvedBundle(init.version);
46400
+ if (script.loaded && typeof ImmutableCheckoutWidgets !== 'undefined') {
46401
+ resolve(new ImmutableCheckoutWidgets.WidgetsFactory(checkout, init.config));
46402
+ }
46403
+ else {
46404
+ checkForWidgetsBundleLoaded();
46405
+ }
46406
+ }
46407
+ catch (err) {
46408
+ reject(new CheckoutError('Failed to load widgets script', CheckoutErrorType.WIDGETS_SCRIPT_LOAD_ERROR, { error: err }));
46375
46409
  }
46376
46410
  });
46377
46411
  return factory;
package/dist/index.d.ts CHANGED
@@ -32213,11 +32213,14 @@ type CheckoutWidgetsConfig = {
32213
32213
  /**
32214
32214
  * Represents the configuration options for instantiating the Checkout Widgets factory.
32215
32215
  * @property {WidgetConfiguration} config - global configuration options for the widgets.
32216
- * @property {SemanticVersion | undefined} version - version of the Checkout widgets bundle (default latest version will be used).
32216
+ * @property {SemanticVersion | undefined} version - version of the Checkout widgets bundle(default latest version will be used).
32217
+ * @property {boolean | undefined} useEsModules - Set to true to use the esm build of the widgets.
32217
32218
  */
32218
32219
  type WidgetsInit = {
32219
32220
  config: WidgetConfiguration;
32220
32221
  version?: SemanticVersion;
32222
+ /** Loads separate parts of the widget script as required for performance improvements. */
32223
+ useEsModules?: boolean;
32221
32224
  };
32222
32225
 
32223
32226
  declare class Checkout {
package/dist/index.js CHANGED
@@ -152,7 +152,7 @@ const flattenProperties$1 = (properties) => {
152
152
  };
153
153
 
154
154
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
155
- const SDK_VERSION$1 = '1.5.3-alpha.5';
155
+ const SDK_VERSION$1 = '1.5.4-alpha.1';
156
156
  const getReferrer$1 = () => {
157
157
  if (isNode$1()) {
158
158
  return '';
@@ -11267,7 +11267,7 @@ class MultiRollupApiClients {
11267
11267
  }
11268
11268
 
11269
11269
  // eslint-disable-next-line @typescript-eslint/naming-convention
11270
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.5.3-alpha.5' };
11270
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.5.4-alpha.1' };
11271
11271
  const createConfig = ({ basePath, headers, }) => {
11272
11272
  if (!basePath.trim()) {
11273
11273
  throw Error('basePath can not be empty');
@@ -11339,7 +11339,7 @@ class APIError extends Error {
11339
11339
 
11340
11340
  /* eslint-disable implicit-arrow-linebreak */
11341
11341
  const defaultHeaders = {
11342
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.5.3-alpha.5',
11342
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.5.4-alpha.1',
11343
11343
  };
11344
11344
  /**
11345
11345
  * createAPIConfiguration to create a custom Configuration
@@ -11772,7 +11772,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
11772
11772
  chainID,
11773
11773
  coreContractAddress,
11774
11774
  registrationContractAddress,
11775
- sdkVersion: 'ts-immutable-sdk-1.5.3-alpha.5',
11775
+ sdkVersion: 'ts-immutable-sdk-1.5.4-alpha.1',
11776
11776
  });
11777
11777
  /**
11778
11778
  * Sets `sdkVersion` at the time of build
@@ -37426,7 +37426,7 @@ const flattenProperties = (properties) => {
37426
37426
  };
37427
37427
 
37428
37428
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
37429
- const SDK_VERSION = '1.5.3-alpha.5';
37429
+ const SDK_VERSION = '1.5.4-alpha.1';
37430
37430
  const getReferrer = () => {
37431
37431
  if (isNode()) {
37432
37432
  return '';
@@ -42593,7 +42593,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
42593
42593
  maxPriorityFeePerGas: BigNumber$1.from(10e9),
42594
42594
  };
42595
42595
 
42596
- const SDK_VERSION_MARKER = '1.5.3-alpha.5';
42596
+ const SDK_VERSION_MARKER = '1.5.4-alpha.1';
42597
42597
  // This SDK version is replaced by the `yarn build` command ran on the root level
42598
42598
  const globalPackageVersion = () => SDK_VERSION_MARKER;
42599
42599
 
@@ -46208,28 +46208,34 @@ function validateAndBuildVersion(version) {
46208
46208
  return validatedVersion;
46209
46209
  }
46210
46210
 
46211
- function loadUnresolved(version) {
46211
+ // Loads the checkout widgets bundle from the CDN and appends the script to the document head
46212
+ function loadUnresolvedBundle(version) {
46212
46213
  if (window === undefined) {
46213
46214
  throw new Error('missing window object: please run Checkout client side');
46214
46215
  }
46215
46216
  if (document === undefined) {
46216
46217
  throw new Error('missing document object: please run Checkout client side');
46217
46218
  }
46218
- // const scriptId = 'immutable-checkout-widgets-bundle';
46219
+ const scriptId = 'immutable-checkout-widgets-bundle';
46219
46220
  const validVersion = validateAndBuildVersion(version);
46220
46221
  // Prevent the script to be loaded more than once
46221
46222
  // by checking the presence of the script and its version.
46222
- // const initScript = document.getElementById(scriptId) as HTMLScriptElement;
46223
- // if (initScript) return { loaded: true, element: initScript };
46224
- // const tag = document.createElement('script');
46225
- const cdnUrl = `https://cdn.jsdelivr.net/npm/@imtbl/sdk@${validVersion}/dist/browser/checkout/widgets.js`;
46226
- // if (useLocalBundle()) cdnUrl = `http://${window.location.host}/lib/js/widgets.js`;
46227
- // tag.setAttribute('id', scriptId);
46228
- // tag.setAttribute('data-version', validVersion);
46229
- // tag.setAttribute('type', 'module');
46230
- // tag.setAttribute('src', cdnUrl);
46231
- // document.head.appendChild(tag);
46232
- return { loaded: false, cdnUrl };
46223
+ const initScript = document.getElementById(scriptId);
46224
+ if (initScript)
46225
+ return { loaded: true, element: initScript };
46226
+ const tag = document.createElement('script');
46227
+ let cdnUrl = `https://cdn.jsdelivr.net/npm/@imtbl/sdk@${validVersion}/dist/browser/checkout/widgets.js`;
46228
+ tag.setAttribute('id', scriptId);
46229
+ tag.setAttribute('data-version', validVersion);
46230
+ tag.setAttribute('src', cdnUrl);
46231
+ document.head.appendChild(tag);
46232
+ return { loaded: false, element: tag };
46233
+ }
46234
+ // Gets the CDN url for the split checkout widgets bundle
46235
+ function getCdnUrl(version) {
46236
+ const validVersion = validateAndBuildVersion(version);
46237
+ let cdnUrl = `https://cdn.jsdelivr.net/npm/@imtbl/sdk@${validVersion}/dist/browser/checkout/widgets-esm.js`;
46238
+ return cdnUrl;
46233
46239
  }
46234
46240
 
46235
46241
  const PUBLISHABLE_KEY_PREFIX = 'pk_imapik-';
@@ -46308,6 +46314,7 @@ const SANDBOX_CONFIGURATION = {
46308
46314
  },
46309
46315
  passport: undefined,
46310
46316
  };
46317
+ const WIDGETS_SCRIPT_TIMEOUT = 100;
46311
46318
  // Checkout SDK
46312
46319
  class Checkout {
46313
46320
  readOnlyProviders;
@@ -46337,19 +46344,46 @@ class Checkout {
46337
46344
  const checkout = this;
46338
46345
  // Preload the configurations
46339
46346
  await checkout.config.remote.getConfig();
46340
- const load = loadUnresolved(init.version);
46341
- const checkoutWidgetsModule = await import(/* webpackIgnore: true */ load.cdnUrl);
46342
- const factory = new Promise((resolve, reject) => {
46343
- try {
46347
+ // Resolves the factory for the esm build of the widgets
46348
+ if (init.useEsModules) {
46349
+ const cdnUrl = getCdnUrl(init.version);
46350
+ // WebpackIgnore comment required to prevent webpack modifying the import statement and
46351
+ // breaking the dynamic import in certain applications integrating checkout
46352
+ const checkoutWidgetsModule = await import(/* webpackIgnore: true */ cdnUrl);
46353
+ const factory = new Promise((resolve, reject) => {
46344
46354
  if (checkoutWidgetsModule && checkoutWidgetsModule.WidgetsFactory) {
46345
46355
  resolve(new checkoutWidgetsModule.WidgetsFactory(checkout, init.config));
46346
46356
  }
46347
46357
  else {
46348
- throw new Error('WidgetsFactory is not found in the imported module.');
46358
+ reject(new CheckoutError('Unable to resolve the WidgetsFactory from the checkout widgets module', CheckoutErrorType.WIDGETS_SCRIPT_LOAD_ERROR));
46359
+ }
46360
+ });
46361
+ return factory;
46362
+ }
46363
+ // Resolves the factory for the umd build of the widgets
46364
+ const factory = new Promise((resolve, reject) => {
46365
+ function checkForWidgetsBundleLoaded() {
46366
+ if (typeof ImmutableCheckoutWidgets !== 'undefined') {
46367
+ resolve(new ImmutableCheckoutWidgets.WidgetsFactory(checkout, init.config));
46368
+ }
46369
+ else {
46370
+ // If ImmutableCheckoutWidgets is not defined, wait for set amount of time.
46371
+ // When time has elapsed, check again if ImmutableCheckoutWidgets is defined.
46372
+ // Once it's defined, the promise will resolve and setTimeout won't be called again.
46373
+ setTimeout(checkForWidgetsBundleLoaded, WIDGETS_SCRIPT_TIMEOUT);
46349
46374
  }
46350
46375
  }
46351
- catch (error) {
46352
- reject(error);
46376
+ try {
46377
+ const script = loadUnresolvedBundle(init.version);
46378
+ if (script.loaded && typeof ImmutableCheckoutWidgets !== 'undefined') {
46379
+ resolve(new ImmutableCheckoutWidgets.WidgetsFactory(checkout, init.config));
46380
+ }
46381
+ else {
46382
+ checkForWidgetsBundleLoaded();
46383
+ }
46384
+ }
46385
+ catch (err) {
46386
+ reject(new CheckoutError('Failed to load widgets script', CheckoutErrorType.WIDGETS_SCRIPT_LOAD_ERROR, { error: err }));
46353
46387
  }
46354
46388
  });
46355
46389
  return factory;
package/dist/orderbook.js CHANGED
@@ -131,7 +131,7 @@ const flattenProperties = (properties) => {
131
131
  };
132
132
 
133
133
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
134
- const SDK_VERSION = '1.5.3-alpha.5';
134
+ const SDK_VERSION = '1.5.4-alpha.1';
135
135
  const getReferrer = () => {
136
136
  if (isNode()) {
137
137
  return '';
package/dist/passport.js CHANGED
@@ -9138,7 +9138,7 @@ class MultiRollupApiClients {
9138
9138
  }
9139
9139
 
9140
9140
  // eslint-disable-next-line @typescript-eslint/naming-convention
9141
- const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.5.3-alpha.5' };
9141
+ const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.5.4-alpha.1' };
9142
9142
  const createConfig = ({ basePath, headers, }) => {
9143
9143
  if (!basePath.trim()) {
9144
9144
  throw Error('basePath can not be empty');
@@ -9317,7 +9317,7 @@ const flattenProperties = (properties) => {
9317
9317
  };
9318
9318
 
9319
9319
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
9320
- const SDK_VERSION = '1.5.3-alpha.5';
9320
+ const SDK_VERSION = '1.5.4-alpha.1';
9321
9321
  const getReferrer = () => {
9322
9322
  if (isNode()) {
9323
9323
  return '';
@@ -9529,7 +9529,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
9529
9529
  chainID,
9530
9530
  coreContractAddress,
9531
9531
  registrationContractAddress,
9532
- sdkVersion: 'ts-immutable-sdk-1.5.3-alpha.5',
9532
+ sdkVersion: 'ts-immutable-sdk-1.5.4-alpha.1',
9533
9533
  });
9534
9534
  /**
9535
9535
  * Sets `sdkVersion` at the time of build
package/dist/x.js CHANGED
@@ -136,7 +136,7 @@ const flattenProperties = (properties) => {
136
136
  };
137
137
 
138
138
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
139
- const SDK_VERSION = '1.5.3-alpha.5';
139
+ const SDK_VERSION = '1.5.4-alpha.1';
140
140
  const getReferrer = () => {
141
141
  if (isNode()) {
142
142
  return '';
@@ -327,7 +327,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
327
327
  chainID,
328
328
  coreContractAddress,
329
329
  registrationContractAddress,
330
- sdkVersion: 'ts-immutable-sdk-1.5.3-alpha.5',
330
+ sdkVersion: 'ts-immutable-sdk-1.5.4-alpha.1',
331
331
  });
332
332
  /**
333
333
  * Sets `sdkVersion` at the time of build
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@imtbl/sdk",
3
3
  "description": "Immutable Unified SDK",
4
- "version": "1.5.3-alpha.5",
4
+ "version": "1.5.4-alpha.1",
5
5
  "author": "Immutable",
6
6
  "browser": "./dist/index.browser.js",
7
7
  "bugs": "https://github.com/immutable/ts-immutable-sdk/issues",