@stripe/stripe-js 10.0.0 → 10.1.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/README.md +1 -0
- package/dist/index.js +11 -12
- package/dist/index.mjs +11 -12
- package/dist/pure.js +11 -12
- package/dist/pure.mjs +11 -12
- package/dist/stripe-js/elements-group.d.mts +5 -0
- package/dist/stripe-js/elements-group.d.ts +5 -0
- package/dist/stripe-js/payment-intents.d.mts +1 -1
- package/dist/stripe-js/payment-intents.d.ts +1 -1
- package/package.json +1 -1
- package/src/index.test.ts +26 -0
- package/src/shared.ts +7 -4
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -71,7 +71,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
|
|
|
71
71
|
|
|
72
72
|
stripe._registerWrapper({
|
|
73
73
|
name: 'stripe-js',
|
|
74
|
-
version: "10.
|
|
74
|
+
version: "10.1.0",
|
|
75
75
|
startTime: startTime
|
|
76
76
|
});
|
|
77
77
|
};
|
|
@@ -150,19 +150,18 @@ var loadScript = function loadScript(params) {
|
|
|
150
150
|
return;
|
|
151
151
|
}
|
|
152
152
|
});
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return load()["catch"](function (error) {
|
|
157
|
-
stripePromise$1 = null;
|
|
158
|
-
return Promise.reject(error);
|
|
159
|
-
});
|
|
160
|
-
}; // Resets stripePromise on error
|
|
153
|
+
}; // Cache the in-flight load (including its single retry) so that concurrent
|
|
154
|
+
// calls share it, and only clear the cache once the load has finally failed
|
|
155
|
+
// so that a later call can try again.
|
|
161
156
|
|
|
162
157
|
|
|
163
|
-
|
|
164
|
-
return
|
|
158
|
+
stripePromise$1 = load()["catch"](function () {
|
|
159
|
+
return load();
|
|
160
|
+
})["catch"](function (error) {
|
|
161
|
+
stripePromise$1 = null;
|
|
162
|
+
return Promise.reject(error);
|
|
165
163
|
});
|
|
164
|
+
return stripePromise$1;
|
|
166
165
|
};
|
|
167
166
|
var initStripe = function initStripe(maybeStripe, args, startTime) {
|
|
168
167
|
if (maybeStripe === null) {
|
|
@@ -181,7 +180,7 @@ var initStripe = function initStripe(maybeStripe, args, startTime) {
|
|
|
181
180
|
var expectedVersion = RELEASE_TRAIN;
|
|
182
181
|
|
|
183
182
|
if (isTestKey && version !== expectedVersion) {
|
|
184
|
-
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("10.
|
|
183
|
+
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("10.1.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
185
184
|
}
|
|
186
185
|
|
|
187
186
|
var stripe = maybeStripe.apply(undefined, args);
|
package/dist/index.mjs
CHANGED
|
@@ -67,7 +67,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
|
|
|
67
67
|
|
|
68
68
|
stripe._registerWrapper({
|
|
69
69
|
name: 'stripe-js',
|
|
70
|
-
version: "10.
|
|
70
|
+
version: "10.1.0",
|
|
71
71
|
startTime: startTime
|
|
72
72
|
});
|
|
73
73
|
};
|
|
@@ -146,19 +146,18 @@ var loadScript = function loadScript(params) {
|
|
|
146
146
|
return;
|
|
147
147
|
}
|
|
148
148
|
});
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return load()["catch"](function (error) {
|
|
153
|
-
stripePromise$1 = null;
|
|
154
|
-
return Promise.reject(error);
|
|
155
|
-
});
|
|
156
|
-
}; // Resets stripePromise on error
|
|
149
|
+
}; // Cache the in-flight load (including its single retry) so that concurrent
|
|
150
|
+
// calls share it, and only clear the cache once the load has finally failed
|
|
151
|
+
// so that a later call can try again.
|
|
157
152
|
|
|
158
153
|
|
|
159
|
-
|
|
160
|
-
return
|
|
154
|
+
stripePromise$1 = load()["catch"](function () {
|
|
155
|
+
return load();
|
|
156
|
+
})["catch"](function (error) {
|
|
157
|
+
stripePromise$1 = null;
|
|
158
|
+
return Promise.reject(error);
|
|
161
159
|
});
|
|
160
|
+
return stripePromise$1;
|
|
162
161
|
};
|
|
163
162
|
var initStripe = function initStripe(maybeStripe, args, startTime) {
|
|
164
163
|
if (maybeStripe === null) {
|
|
@@ -177,7 +176,7 @@ var initStripe = function initStripe(maybeStripe, args, startTime) {
|
|
|
177
176
|
var expectedVersion = RELEASE_TRAIN;
|
|
178
177
|
|
|
179
178
|
if (isTestKey && version !== expectedVersion) {
|
|
180
|
-
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("10.
|
|
179
|
+
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("10.1.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
181
180
|
}
|
|
182
181
|
|
|
183
182
|
var stripe = maybeStripe.apply(undefined, args);
|
package/dist/pure.js
CHANGED
|
@@ -71,7 +71,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
|
|
|
71
71
|
|
|
72
72
|
stripe._registerWrapper({
|
|
73
73
|
name: 'stripe-js',
|
|
74
|
-
version: "10.
|
|
74
|
+
version: "10.1.0",
|
|
75
75
|
startTime: startTime
|
|
76
76
|
});
|
|
77
77
|
};
|
|
@@ -150,19 +150,18 @@ var loadScript = function loadScript(params) {
|
|
|
150
150
|
return;
|
|
151
151
|
}
|
|
152
152
|
});
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return load()["catch"](function (error) {
|
|
157
|
-
stripePromise = null;
|
|
158
|
-
return Promise.reject(error);
|
|
159
|
-
});
|
|
160
|
-
}; // Resets stripePromise on error
|
|
153
|
+
}; // Cache the in-flight load (including its single retry) so that concurrent
|
|
154
|
+
// calls share it, and only clear the cache once the load has finally failed
|
|
155
|
+
// so that a later call can try again.
|
|
161
156
|
|
|
162
157
|
|
|
163
|
-
|
|
164
|
-
return
|
|
158
|
+
stripePromise = load()["catch"](function () {
|
|
159
|
+
return load();
|
|
160
|
+
})["catch"](function (error) {
|
|
161
|
+
stripePromise = null;
|
|
162
|
+
return Promise.reject(error);
|
|
165
163
|
});
|
|
164
|
+
return stripePromise;
|
|
166
165
|
};
|
|
167
166
|
var initStripe = function initStripe(maybeStripe, args, startTime) {
|
|
168
167
|
if (maybeStripe === null) {
|
|
@@ -181,7 +180,7 @@ var initStripe = function initStripe(maybeStripe, args, startTime) {
|
|
|
181
180
|
var expectedVersion = RELEASE_TRAIN;
|
|
182
181
|
|
|
183
182
|
if (isTestKey && version !== expectedVersion) {
|
|
184
|
-
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("10.
|
|
183
|
+
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("10.1.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
185
184
|
}
|
|
186
185
|
|
|
187
186
|
var stripe = maybeStripe.apply(undefined, args);
|
package/dist/pure.mjs
CHANGED
|
@@ -67,7 +67,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
|
|
|
67
67
|
|
|
68
68
|
stripe._registerWrapper({
|
|
69
69
|
name: 'stripe-js',
|
|
70
|
-
version: "10.
|
|
70
|
+
version: "10.1.0",
|
|
71
71
|
startTime: startTime
|
|
72
72
|
});
|
|
73
73
|
};
|
|
@@ -146,19 +146,18 @@ var loadScript = function loadScript(params) {
|
|
|
146
146
|
return;
|
|
147
147
|
}
|
|
148
148
|
});
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return load()["catch"](function (error) {
|
|
153
|
-
stripePromise = null;
|
|
154
|
-
return Promise.reject(error);
|
|
155
|
-
});
|
|
156
|
-
}; // Resets stripePromise on error
|
|
149
|
+
}; // Cache the in-flight load (including its single retry) so that concurrent
|
|
150
|
+
// calls share it, and only clear the cache once the load has finally failed
|
|
151
|
+
// so that a later call can try again.
|
|
157
152
|
|
|
158
153
|
|
|
159
|
-
|
|
160
|
-
return
|
|
154
|
+
stripePromise = load()["catch"](function () {
|
|
155
|
+
return load();
|
|
156
|
+
})["catch"](function (error) {
|
|
157
|
+
stripePromise = null;
|
|
158
|
+
return Promise.reject(error);
|
|
161
159
|
});
|
|
160
|
+
return stripePromise;
|
|
162
161
|
};
|
|
163
162
|
var initStripe = function initStripe(maybeStripe, args, startTime) {
|
|
164
163
|
if (maybeStripe === null) {
|
|
@@ -177,7 +176,7 @@ var initStripe = function initStripe(maybeStripe, args, startTime) {
|
|
|
177
176
|
var expectedVersion = RELEASE_TRAIN;
|
|
178
177
|
|
|
179
178
|
if (isTestKey && version !== expectedVersion) {
|
|
180
|
-
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("10.
|
|
179
|
+
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("10.1.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
181
180
|
}
|
|
182
181
|
|
|
183
182
|
var stripe = maybeStripe.apply(undefined, args);
|
|
@@ -1212,6 +1212,11 @@ export interface Appearance {
|
|
|
1212
1212
|
accordionItemLabelSelectedColorText?: string;
|
|
1213
1213
|
accordionItemLabelSelectedFontWeight?: string;
|
|
1214
1214
|
|
|
1215
|
+
// AccordionItem triggers
|
|
1216
|
+
accordionItemTriggerColor?: string;
|
|
1217
|
+
accordionItemTriggerSelectedColor?: string;
|
|
1218
|
+
accordionItemTriggerHoverColor?: string;
|
|
1219
|
+
|
|
1215
1220
|
// Colors
|
|
1216
1221
|
colorPrimary?: string;
|
|
1217
1222
|
colorBackground?: string;
|
|
@@ -1212,6 +1212,11 @@ export interface Appearance {
|
|
|
1212
1212
|
accordionItemLabelSelectedColorText?: string;
|
|
1213
1213
|
accordionItemLabelSelectedFontWeight?: string;
|
|
1214
1214
|
|
|
1215
|
+
// AccordionItem triggers
|
|
1216
|
+
accordionItemTriggerColor?: string;
|
|
1217
|
+
accordionItemTriggerSelectedColor?: string;
|
|
1218
|
+
accordionItemTriggerHoverColor?: string;
|
|
1219
|
+
|
|
1215
1220
|
// Colors
|
|
1216
1221
|
colorPrimary?: string;
|
|
1217
1222
|
colorBackground?: string;
|
package/package.json
CHANGED
package/src/index.test.ts
CHANGED
|
@@ -225,6 +225,32 @@ describe('Stripe module loader', () => {
|
|
|
225
225
|
});
|
|
226
226
|
});
|
|
227
227
|
|
|
228
|
+
describe.each(['./index', './pure'])(
|
|
229
|
+
'concurrent loadStripe calls (%s.ts)',
|
|
230
|
+
(requirePath) => {
|
|
231
|
+
beforeEach(() => {
|
|
232
|
+
jest.spyOn(console, 'warn').mockReturnValue();
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
it('resolves every call made while Stripe.js is loading', async () => {
|
|
236
|
+
const {loadStripe} = require(requirePath);
|
|
237
|
+
const first = loadStripe('pk_test_foo');
|
|
238
|
+
const second = loadStripe('pk_test_bar');
|
|
239
|
+
|
|
240
|
+
await new Promise((resolve) => setTimeout(resolve));
|
|
241
|
+
expect(
|
|
242
|
+
document.querySelectorAll(`script[src="${SCRIPT_SRC}"]`)
|
|
243
|
+
).toHaveLength(1);
|
|
244
|
+
|
|
245
|
+
window.Stripe = jest.fn((key) => ({key})) as any;
|
|
246
|
+
dispatchScriptEvent('load');
|
|
247
|
+
|
|
248
|
+
await expect(second).resolves.toEqual({key: 'pk_test_bar'});
|
|
249
|
+
await expect(first).resolves.toEqual({key: 'pk_test_foo'});
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
);
|
|
253
|
+
|
|
228
254
|
describe('loadStripe (index.ts)', () => {
|
|
229
255
|
beforeEach(() => {
|
|
230
256
|
jest.spyOn(console, 'warn').mockReturnValue();
|
package/src/shared.ts
CHANGED
|
@@ -154,14 +154,17 @@ export const loadScript = (
|
|
|
154
154
|
}
|
|
155
155
|
});
|
|
156
156
|
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
// Cache the in-flight load (including its single retry) so that concurrent
|
|
158
|
+
// calls share it, and only clear the cache once the load has finally failed
|
|
159
|
+
// so that a later call can try again.
|
|
160
|
+
stripePromise = load()
|
|
161
|
+
.catch(() => load())
|
|
162
|
+
.catch((error) => {
|
|
159
163
|
stripePromise = null;
|
|
160
164
|
return Promise.reject(error);
|
|
161
165
|
});
|
|
162
166
|
|
|
163
|
-
|
|
164
|
-
return retryableLoad().catch(() => retryableLoad());
|
|
167
|
+
return stripePromise;
|
|
165
168
|
};
|
|
166
169
|
|
|
167
170
|
export const initStripe = (
|