@paypercut/checkout-js 1.4.4 → 1.4.5

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.mjs CHANGED
@@ -100,7 +100,7 @@ class Emitter {
100
100
  }
101
101
  }
102
102
 
103
- const SDK_VERSION = "1.4.4";
103
+ const SDK_VERSION = "1.4.5";
104
104
 
105
105
  /**
106
106
  * Build-time configuration
@@ -4769,6 +4769,7 @@ class CardElementImpl {
4769
4769
  this.handleInitializationTimeout();
4770
4770
  return;
4771
4771
  }
4772
+ this.group.retryStalledControllerInitialization();
4772
4773
  const replacement = this.createFrame();
4773
4774
  const previousGeneration = this.componentGeneration;
4774
4775
  this.componentGeneration += 1;
@@ -5730,6 +5731,7 @@ class ExpressCheckoutElementImpl {
5730
5731
  }
5731
5732
  createFrame(options = this.options) {
5732
5733
  const iframe = document.createElement('iframe');
5734
+ const disableAnimations = this.group.getRenderableElementsOptions().appearance?.disableAnimations === true;
5733
5735
  iframe.id = `paypercut-express-checkout-element-${this.componentId}`;
5734
5736
  iframe.title = 'Express checkout';
5735
5737
  iframe.referrerPolicy = 'origin';
@@ -5758,8 +5760,8 @@ class ExpressCheckoutElementImpl {
5758
5760
  display: 'block',
5759
5761
  overflow: 'hidden',
5760
5762
  colorScheme: 'light dark',
5761
- transition: 'height 250ms ease-in-out, opacity 250ms ease-in-out',
5762
- willChange: 'height, opacity',
5763
+ transition: disableAnimations ? 'none' : 'height 250ms ease-in-out, opacity 250ms ease-in-out',
5764
+ willChange: disableAnimations ? 'auto' : 'height, opacity',
5763
5765
  });
5764
5766
  return iframe;
5765
5767
  }
@@ -11750,6 +11752,29 @@ class ElementsGroupImpl {
11750
11752
  window.addEventListener('message', this.windowMessageHandler);
11751
11753
  (document.body ?? document.documentElement).appendChild(iframe);
11752
11754
  }
11755
+ retryStalledControllerInitialization() {
11756
+ const current = this.controllerIframe;
11757
+ const parent = current?.parentNode;
11758
+ if (this.destroyed || this.controllerInitialized || !current || !parent)
11759
+ return false;
11760
+ // A component-only reload cannot recover a controller whose session request
11761
+ // or bootstrap never completed. Keep the group and its pending components,
11762
+ // but give the controller a fresh browsing context and navigation identity.
11763
+ let replacement;
11764
+ try {
11765
+ replacement = current.cloneNode(false);
11766
+ replacement.src = withElementsFrameNavigationIdentity(current.src, generateId());
11767
+ parent.replaceChild(replacement, current);
11768
+ }
11769
+ catch {
11770
+ return false;
11771
+ }
11772
+ this.controlPort?.close();
11773
+ this.controlPort = null;
11774
+ this.controllerBootstrapped = false;
11775
+ this.controllerIframe = replacement;
11776
+ return true;
11777
+ }
11753
11778
  attachComponent(element, port) {
11754
11779
  if (this.destroyed || !this.elements.has(element.componentId)) {
11755
11780
  port.close();