@stripe/stripe-js 2.1.11 → 2.2.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/pure.esm.js CHANGED
@@ -54,12 +54,31 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
54
54
 
55
55
  stripe._registerWrapper({
56
56
  name: 'stripe-js',
57
- version: "2.1.11",
57
+ version: "2.2.1",
58
58
  startTime: startTime
59
59
  });
60
60
  };
61
61
 
62
62
  var stripePromise = null;
63
+ var onErrorListener = null;
64
+ var onLoadListener = null;
65
+
66
+ var onError = function onError(reject) {
67
+ return function () {
68
+ reject(new Error('Failed to load Stripe.js'));
69
+ };
70
+ };
71
+
72
+ var onLoad = function onLoad(resolve, reject) {
73
+ return function () {
74
+ if (window.Stripe) {
75
+ resolve(window.Stripe);
76
+ } else {
77
+ reject(new Error('Stripe.js not available'));
78
+ }
79
+ };
80
+ };
81
+
63
82
  var loadScript = function loadScript(params) {
64
83
  // Ensure that we only attempt to load Stripe.js at most once
65
84
  if (stripePromise !== null) {
@@ -90,24 +109,32 @@ var loadScript = function loadScript(params) {
90
109
  console.warn(EXISTING_SCRIPT_MESSAGE);
91
110
  } else if (!script) {
92
111
  script = injectScript(params);
112
+ } else if (script && onLoadListener !== null && onErrorListener !== null) {
113
+ var _script$parentNode;
114
+
115
+ // remove event listeners
116
+ script.removeEventListener('load', onLoadListener);
117
+ script.removeEventListener('error', onErrorListener); // if script exists, but we are reloading due to an error,
118
+ // reload script to trigger 'load' event
119
+
120
+ (_script$parentNode = script.parentNode) === null || _script$parentNode === void 0 ? void 0 : _script$parentNode.removeChild(script);
121
+ script = injectScript(params);
93
122
  }
94
123
 
95
- script.addEventListener('load', function () {
96
- if (window.Stripe) {
97
- resolve(window.Stripe);
98
- } else {
99
- reject(new Error('Stripe.js not available'));
100
- }
101
- });
102
- script.addEventListener('error', function () {
103
- reject(new Error('Failed to load Stripe.js'));
104
- });
124
+ onLoadListener = onLoad(resolve, reject);
125
+ onErrorListener = onError(reject);
126
+ script.addEventListener('load', onLoadListener);
127
+ script.addEventListener('error', onErrorListener);
105
128
  } catch (error) {
106
129
  reject(error);
107
130
  return;
108
131
  }
132
+ }); // Resets stripePromise on error
133
+
134
+ return stripePromise["catch"](function (error) {
135
+ stripePromise = null;
136
+ return Promise.reject(error);
109
137
  });
110
- return stripePromise;
111
138
  };
112
139
  var initStripe = function initStripe(maybeStripe, args, startTime) {
113
140
  if (maybeStripe === null) {
package/dist/pure.js CHANGED
@@ -58,12 +58,31 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
58
58
 
59
59
  stripe._registerWrapper({
60
60
  name: 'stripe-js',
61
- version: "2.1.11",
61
+ version: "2.2.1",
62
62
  startTime: startTime
63
63
  });
64
64
  };
65
65
 
66
66
  var stripePromise = null;
67
+ var onErrorListener = null;
68
+ var onLoadListener = null;
69
+
70
+ var onError = function onError(reject) {
71
+ return function () {
72
+ reject(new Error('Failed to load Stripe.js'));
73
+ };
74
+ };
75
+
76
+ var onLoad = function onLoad(resolve, reject) {
77
+ return function () {
78
+ if (window.Stripe) {
79
+ resolve(window.Stripe);
80
+ } else {
81
+ reject(new Error('Stripe.js not available'));
82
+ }
83
+ };
84
+ };
85
+
67
86
  var loadScript = function loadScript(params) {
68
87
  // Ensure that we only attempt to load Stripe.js at most once
69
88
  if (stripePromise !== null) {
@@ -94,24 +113,32 @@ var loadScript = function loadScript(params) {
94
113
  console.warn(EXISTING_SCRIPT_MESSAGE);
95
114
  } else if (!script) {
96
115
  script = injectScript(params);
116
+ } else if (script && onLoadListener !== null && onErrorListener !== null) {
117
+ var _script$parentNode;
118
+
119
+ // remove event listeners
120
+ script.removeEventListener('load', onLoadListener);
121
+ script.removeEventListener('error', onErrorListener); // if script exists, but we are reloading due to an error,
122
+ // reload script to trigger 'load' event
123
+
124
+ (_script$parentNode = script.parentNode) === null || _script$parentNode === void 0 ? void 0 : _script$parentNode.removeChild(script);
125
+ script = injectScript(params);
97
126
  }
98
127
 
99
- script.addEventListener('load', function () {
100
- if (window.Stripe) {
101
- resolve(window.Stripe);
102
- } else {
103
- reject(new Error('Stripe.js not available'));
104
- }
105
- });
106
- script.addEventListener('error', function () {
107
- reject(new Error('Failed to load Stripe.js'));
108
- });
128
+ onLoadListener = onLoad(resolve, reject);
129
+ onErrorListener = onError(reject);
130
+ script.addEventListener('load', onLoadListener);
131
+ script.addEventListener('error', onErrorListener);
109
132
  } catch (error) {
110
133
  reject(error);
111
134
  return;
112
135
  }
136
+ }); // Resets stripePromise on error
137
+
138
+ return stripePromise["catch"](function (error) {
139
+ stripePromise = null;
140
+ return Promise.reject(error);
113
141
  });
114
- return stripePromise;
115
142
  };
116
143
  var initStripe = function initStripe(maybeStripe, args, startTime) {
117
144
  if (maybeStripe === null) {
@@ -38,12 +38,31 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
38
38
 
39
39
  stripe._registerWrapper({
40
40
  name: 'stripe-js',
41
- version: "2.1.11",
41
+ version: "2.2.1",
42
42
  startTime: startTime
43
43
  });
44
44
  };
45
45
 
46
46
  var stripePromise = null;
47
+ var onErrorListener = null;
48
+ var onLoadListener = null;
49
+
50
+ var onError = function onError(reject) {
51
+ return function () {
52
+ reject(new Error('Failed to load Stripe.js'));
53
+ };
54
+ };
55
+
56
+ var onLoad = function onLoad(resolve, reject) {
57
+ return function () {
58
+ if (window.Stripe) {
59
+ resolve(window.Stripe);
60
+ } else {
61
+ reject(new Error('Stripe.js not available'));
62
+ }
63
+ };
64
+ };
65
+
47
66
  var loadScript = function loadScript(params) {
48
67
  // Ensure that we only attempt to load Stripe.js at most once
49
68
  if (stripePromise !== null) {
@@ -74,24 +93,32 @@ var loadScript = function loadScript(params) {
74
93
  console.warn(EXISTING_SCRIPT_MESSAGE);
75
94
  } else if (!script) {
76
95
  script = injectScript(params);
96
+ } else if (script && onLoadListener !== null && onErrorListener !== null) {
97
+ var _script$parentNode;
98
+
99
+ // remove event listeners
100
+ script.removeEventListener('load', onLoadListener);
101
+ script.removeEventListener('error', onErrorListener); // if script exists, but we are reloading due to an error,
102
+ // reload script to trigger 'load' event
103
+
104
+ (_script$parentNode = script.parentNode) === null || _script$parentNode === void 0 ? void 0 : _script$parentNode.removeChild(script);
105
+ script = injectScript(params);
77
106
  }
78
107
 
79
- script.addEventListener('load', function () {
80
- if (window.Stripe) {
81
- resolve(window.Stripe);
82
- } else {
83
- reject(new Error('Stripe.js not available'));
84
- }
85
- });
86
- script.addEventListener('error', function () {
87
- reject(new Error('Failed to load Stripe.js'));
88
- });
108
+ onLoadListener = onLoad(resolve, reject);
109
+ onErrorListener = onError(reject);
110
+ script.addEventListener('load', onLoadListener);
111
+ script.addEventListener('error', onErrorListener);
89
112
  } catch (error) {
90
113
  reject(error);
91
114
  return;
92
115
  }
116
+ }); // Resets stripePromise on error
117
+
118
+ return stripePromise["catch"](function (error) {
119
+ stripePromise = null;
120
+ return Promise.reject(error);
93
121
  });
94
- return stripePromise;
95
122
  };
96
123
  var initStripe = function initStripe(maybeStripe, args, startTime) {
97
124
  if (maybeStripe === null) {
package/dist/stripe.js CHANGED
@@ -42,12 +42,31 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
42
42
 
43
43
  stripe._registerWrapper({
44
44
  name: 'stripe-js',
45
- version: "2.1.11",
45
+ version: "2.2.1",
46
46
  startTime: startTime
47
47
  });
48
48
  };
49
49
 
50
50
  var stripePromise = null;
51
+ var onErrorListener = null;
52
+ var onLoadListener = null;
53
+
54
+ var onError = function onError(reject) {
55
+ return function () {
56
+ reject(new Error('Failed to load Stripe.js'));
57
+ };
58
+ };
59
+
60
+ var onLoad = function onLoad(resolve, reject) {
61
+ return function () {
62
+ if (window.Stripe) {
63
+ resolve(window.Stripe);
64
+ } else {
65
+ reject(new Error('Stripe.js not available'));
66
+ }
67
+ };
68
+ };
69
+
51
70
  var loadScript = function loadScript(params) {
52
71
  // Ensure that we only attempt to load Stripe.js at most once
53
72
  if (stripePromise !== null) {
@@ -78,24 +97,32 @@ var loadScript = function loadScript(params) {
78
97
  console.warn(EXISTING_SCRIPT_MESSAGE);
79
98
  } else if (!script) {
80
99
  script = injectScript(params);
100
+ } else if (script && onLoadListener !== null && onErrorListener !== null) {
101
+ var _script$parentNode;
102
+
103
+ // remove event listeners
104
+ script.removeEventListener('load', onLoadListener);
105
+ script.removeEventListener('error', onErrorListener); // if script exists, but we are reloading due to an error,
106
+ // reload script to trigger 'load' event
107
+
108
+ (_script$parentNode = script.parentNode) === null || _script$parentNode === void 0 ? void 0 : _script$parentNode.removeChild(script);
109
+ script = injectScript(params);
81
110
  }
82
111
 
83
- script.addEventListener('load', function () {
84
- if (window.Stripe) {
85
- resolve(window.Stripe);
86
- } else {
87
- reject(new Error('Stripe.js not available'));
88
- }
89
- });
90
- script.addEventListener('error', function () {
91
- reject(new Error('Failed to load Stripe.js'));
92
- });
112
+ onLoadListener = onLoad(resolve, reject);
113
+ onErrorListener = onError(reject);
114
+ script.addEventListener('load', onLoadListener);
115
+ script.addEventListener('error', onErrorListener);
93
116
  } catch (error) {
94
117
  reject(error);
95
118
  return;
96
119
  }
120
+ }); // Resets stripePromise on error
121
+
122
+ return stripePromise["catch"](function (error) {
123
+ stripePromise = null;
124
+ return Promise.reject(error);
97
125
  });
98
- return stripePromise;
99
126
  };
100
127
  var initStripe = function initStripe(maybeStripe, args, startTime) {
101
128
  if (maybeStripe === null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stripe/stripe-js",
3
- "version": "2.1.11",
3
+ "version": "2.2.1",
4
4
  "description": "Stripe.js loading utility",
5
5
  "repository": "github:stripe/stripe-js",
6
6
  "main": "dist/stripe.js",
package/src/shared.ts CHANGED
@@ -64,6 +64,26 @@ const registerWrapper = (stripe: any, startTime: number): void => {
64
64
 
65
65
  let stripePromise: Promise<StripeConstructor | null> | null = null;
66
66
 
67
+ let onErrorListener: (() => void) | null = null;
68
+ let onLoadListener: (() => void) | null = null;
69
+
70
+ const onError = (reject: (reason?: any) => void) => () => {
71
+ reject(new Error('Failed to load Stripe.js'));
72
+ };
73
+
74
+ const onLoad = (
75
+ resolve: (
76
+ value: StripeConstructor | PromiseLike<StripeConstructor | null> | null
77
+ ) => void,
78
+ reject: (reason?: any) => void
79
+ ) => () => {
80
+ if (window.Stripe) {
81
+ resolve(window.Stripe);
82
+ } else {
83
+ reject(new Error('Stripe.js not available'));
84
+ }
85
+ };
86
+
67
87
  export const loadScript = (
68
88
  params: null | LoadParams
69
89
  ): Promise<StripeConstructor | null> => {
@@ -96,26 +116,36 @@ export const loadScript = (
96
116
  console.warn(EXISTING_SCRIPT_MESSAGE);
97
117
  } else if (!script) {
98
118
  script = injectScript(params);
119
+ } else if (
120
+ script &&
121
+ onLoadListener !== null &&
122
+ onErrorListener !== null
123
+ ) {
124
+ // remove event listeners
125
+ script.removeEventListener('load', onLoadListener);
126
+ script.removeEventListener('error', onErrorListener);
127
+
128
+ // if script exists, but we are reloading due to an error,
129
+ // reload script to trigger 'load' event
130
+ script.parentNode?.removeChild(script);
131
+ script = injectScript(params);
99
132
  }
100
133
 
101
- script.addEventListener('load', () => {
102
- if (window.Stripe) {
103
- resolve(window.Stripe);
104
- } else {
105
- reject(new Error('Stripe.js not available'));
106
- }
107
- });
108
-
109
- script.addEventListener('error', () => {
110
- reject(new Error('Failed to load Stripe.js'));
111
- });
134
+ onLoadListener = onLoad(resolve, reject);
135
+ onErrorListener = onError(reject);
136
+ script.addEventListener('load', onLoadListener);
137
+
138
+ script.addEventListener('error', onErrorListener);
112
139
  } catch (error) {
113
140
  reject(error);
114
141
  return;
115
142
  }
116
143
  });
117
-
118
- return stripePromise;
144
+ // Resets stripePromise on error
145
+ return stripePromise.catch((error) => {
146
+ stripePromise = null;
147
+ return Promise.reject(error);
148
+ });
119
149
  };
120
150
 
121
151
  export const initStripe = (
@@ -778,11 +778,6 @@ export interface StripeElementsOptionsMode extends BaseStripeElementsOptions {
778
778
  */
779
779
  paymentMethodCreation?: 'manual';
780
780
 
781
- /**
782
- * Allows PaymentMethods to be created from the Elements instance.
783
- */
784
- payment_method_creation?: 'manual';
785
-
786
781
  /**
787
782
  * Additional payment-method-specific options for configuring Payment Element behavior.
788
783
  *
@@ -967,48 +962,114 @@ export interface Appearance {
967
962
 
968
963
  // Spacing
969
964
  spacingUnit?: string;
965
+ gridRowSpacing?: string;
966
+ gridColumnSpacing?: string;
967
+ tabSpacing?: string;
968
+ accordionItemSpacing?: string;
969
+ /** @deprecated Use gridRowSpacing instead. */
970
970
  spacingGridRow?: string;
971
+ /** @deprecated Use gridColumnSpacing instead. */
971
972
  spacingGridColumn?: string;
973
+ /** @deprecated Use tabSpacing instead. */
972
974
  spacingTab?: string;
975
+ /** @deprecated Use accordionItemSpacing instead. */
973
976
  spacingAccordionItem?: string;
974
977
 
975
978
  // Colors
976
979
  colorPrimary?: string;
977
- colorPrimaryText?: string;
978
980
  colorBackground?: string;
979
- colorBackgroundText?: string;
980
981
  colorText?: string;
981
982
  colorSuccess?: string;
982
- colorSuccessText?: string;
983
983
  colorDanger?: string;
984
- colorDangerText?: string;
985
984
  colorWarning?: string;
986
- colorWarningText?: string;
987
985
 
988
986
  // Text variations
989
987
  colorTextSecondary?: string;
990
988
  colorTextPlaceholder?: string;
991
989
 
990
+ // Accessible text
991
+ accessibleColorOnColorPrimary?: string;
992
+ accessibleColorOnColorBackground?: string;
993
+ accessibleColorOnColorSuccess?: string;
994
+ accessibleColorOnColorDanger?: string;
995
+ accessibleColorOnColorWarning?: string;
996
+ /** @deprecated Use accessibleColorOnColorPrimary instead. */
997
+ colorPrimaryText?: string;
998
+ /** @deprecated Use accessibleColorOnColorBackground instead. */
999
+ colorBackgroundText?: string;
1000
+ /** @deprecated Use accessibleColorOnColorSuccess instead. */
1001
+ colorSuccessText?: string;
1002
+ /** @deprecated Use accessibleColorOnColorDanger instead. */
1003
+ colorDangerText?: string;
1004
+ /** @deprecated Use accessibleColorOnColorWarning instead. */
1005
+ colorWarningText?: string;
1006
+
992
1007
  // Icons
1008
+ iconColor?: string;
1009
+ iconHoverColor?: string;
1010
+ iconCardErrorColor?: string;
1011
+ iconCardCvcColor?: string;
1012
+ iconCardCvcErrorColor?: string;
1013
+ iconCheckmarkColor?: string;
1014
+ iconChevronDownColor?: string;
1015
+ iconChevronDownHoverColor?: string;
1016
+ iconCloseColor?: string;
1017
+ iconCloseHoverColor?: string;
1018
+ iconLoadingIndicatorColor?: string;
1019
+ iconMenuColor?: string;
1020
+ iconMenuHoverColor?: string;
1021
+ iconPasscodeDeviceColor?: string;
1022
+ iconPasscodeDeviceHoverColor?: string;
1023
+ iconPasscodeDeviceNotificationColor?: string;
1024
+ iconRedirectColor?: string;
1025
+ /** @deprecated Use iconColor instead. */
993
1026
  colorIcon?: string;
1027
+ /** @deprecated Use iconHoverColor instead. */
994
1028
  colorIconHover?: string;
1029
+ /** @deprecated Use iconCardErrorColor instead. */
995
1030
  colorIconCardError?: string;
1031
+ /** @deprecated Use iconCardCvcColor instead. */
996
1032
  colorIconCardCvc?: string;
1033
+ /** @deprecated Use iconCardCvcErrorColor instead. */
997
1034
  colorIconCardCvcError?: string;
1035
+ /** @deprecated Use iconCheckmarkColor instead. */
998
1036
  colorIconCheckmark?: string;
1037
+ /** @deprecated Use iconChevronDownColor instead. */
999
1038
  colorIconChevronDown?: string;
1039
+ /** @deprecated Use iconChevronDownHoverColor instead. */
1000
1040
  colorIconChevronDownHover?: string;
1041
+ /** @deprecated Use iconRedirectColor instead. */
1001
1042
  colorIconRedirect?: string;
1043
+
1044
+ // TabIcons
1045
+ tabIconColor?: string;
1046
+ tabIconHoverColor?: string;
1047
+ tabIconSelectedColor?: string;
1048
+ tabIconMoreColor?: string;
1049
+ tabIconMoreHoverColor?: string;
1050
+ /** @deprecated Use tabIconColor instead. */
1002
1051
  colorIconTab?: string;
1052
+ /** @deprecated Use tabIconHoverColor instead. */
1003
1053
  colorIconTabHover?: string;
1054
+ /** @deprecated Use tabIconHoverColor instead. */
1004
1055
  colorIconTabSelected?: string;
1056
+ /** @deprecated Use tabIconMoreColor instead. */
1005
1057
  colorIconTabMore?: string;
1058
+ /** @deprecated Use tabIconMoreHoverColor instead. */
1006
1059
  colorIconTabMoreHover?: string;
1007
1060
 
1008
1061
  // Logos
1062
+ logoColor?: string;
1063
+ tabLogoColor?: string;
1064
+ tabLogoSelectedColor?: string;
1065
+ blockLogoColor?: string;
1066
+ /** @deprecated Use logoColor instead. */
1009
1067
  colorLogo?: string;
1068
+ /** @deprecated Use tabLogoColor instead. */
1010
1069
  colorLogoTab?: string;
1070
+ /** @deprecated Use tabLogoSelectedColor instead. */
1011
1071
  colorLogoTabSelected?: string;
1072
+ /** @deprecated Use blockLogoColor instead. */
1012
1073
  colorLogoBlock?: string;
1013
1074
 
1014
1075
  // Focus