@stripe/connect-js 3.3.22 → 3.3.23
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/connect.esm.js +10 -5
- package/dist/connect.js +10 -5
- package/dist/pure.esm.js +10 -5
- package/dist/pure.js +10 -5
- package/dist/src/shared.d.ts +1 -0
- package/package.json +1 -1
- package/src/shared.ts +15 -5
package/dist/connect.esm.js
CHANGED
|
@@ -90,6 +90,13 @@ const injectScript = () => {
|
|
|
90
90
|
return script;
|
|
91
91
|
};
|
|
92
92
|
let stripePromise$1 = null;
|
|
93
|
+
const isWindowStripeConnectDefined = stripeConnect => {
|
|
94
|
+
// We only consider `StripeConnect` defined if `init` is a function
|
|
95
|
+
// Why? HTML markup like:
|
|
96
|
+
// <a id="StripeConnect"><a id="StripeConnect" name="init" href="stripe"></a></a> in the <head> of the page
|
|
97
|
+
// can end up "contaminating" the window.StripeConnect object and cause issues in connect.js initialization
|
|
98
|
+
return !!(stripeConnect && typeof stripeConnect === "object" && "init" in stripeConnect && typeof stripeConnect.init === "function");
|
|
99
|
+
};
|
|
93
100
|
const loadScript = () => {
|
|
94
101
|
// Ensure that we only attempt to load Connect.js at most once
|
|
95
102
|
if (stripePromise$1 !== null) {
|
|
@@ -100,10 +107,8 @@ const loadScript = () => {
|
|
|
100
107
|
reject("ConnectJS won't load when rendering code in the server - it can only be loaded on a browser. This error is expected when loading ConnectJS in SSR environments, like NextJS. It will have no impact in the UI, however if you wish to avoid it, you can switch to the `pure` version of the connect.js loader: https://github.com/stripe/connect-js#importing-loadconnect-without-side-effects.");
|
|
101
108
|
return;
|
|
102
109
|
}
|
|
103
|
-
if (window.StripeConnect) {
|
|
110
|
+
if (isWindowStripeConnectDefined(window.StripeConnect)) {
|
|
104
111
|
console.warn(EXISTING_SCRIPT_MESSAGE);
|
|
105
|
-
}
|
|
106
|
-
if (window.StripeConnect) {
|
|
107
112
|
const wrapper = createWrapper(window.StripeConnect);
|
|
108
113
|
resolve(wrapper);
|
|
109
114
|
return;
|
|
@@ -116,7 +121,7 @@ const loadScript = () => {
|
|
|
116
121
|
script = injectScript();
|
|
117
122
|
}
|
|
118
123
|
script.addEventListener("load", () => {
|
|
119
|
-
if (window.StripeConnect) {
|
|
124
|
+
if (isWindowStripeConnectDefined(window.StripeConnect)) {
|
|
120
125
|
const wrapper = createWrapper(window.StripeConnect);
|
|
121
126
|
resolve(wrapper);
|
|
122
127
|
} else {
|
|
@@ -214,7 +219,7 @@ const createWrapper = stripeConnect => {
|
|
|
214
219
|
sdk: true,
|
|
215
220
|
sdkOptions: {
|
|
216
221
|
// This will be replaced by the npm package version when bundling
|
|
217
|
-
sdkVersion: "3.3.
|
|
222
|
+
sdkVersion: "3.3.23"
|
|
218
223
|
}
|
|
219
224
|
})
|
|
220
225
|
}));
|
package/dist/connect.js
CHANGED
|
@@ -94,6 +94,13 @@ const injectScript = () => {
|
|
|
94
94
|
return script;
|
|
95
95
|
};
|
|
96
96
|
let stripePromise$1 = null;
|
|
97
|
+
const isWindowStripeConnectDefined = stripeConnect => {
|
|
98
|
+
// We only consider `StripeConnect` defined if `init` is a function
|
|
99
|
+
// Why? HTML markup like:
|
|
100
|
+
// <a id="StripeConnect"><a id="StripeConnect" name="init" href="stripe"></a></a> in the <head> of the page
|
|
101
|
+
// can end up "contaminating" the window.StripeConnect object and cause issues in connect.js initialization
|
|
102
|
+
return !!(stripeConnect && typeof stripeConnect === "object" && "init" in stripeConnect && typeof stripeConnect.init === "function");
|
|
103
|
+
};
|
|
97
104
|
const loadScript = () => {
|
|
98
105
|
// Ensure that we only attempt to load Connect.js at most once
|
|
99
106
|
if (stripePromise$1 !== null) {
|
|
@@ -104,10 +111,8 @@ const loadScript = () => {
|
|
|
104
111
|
reject("ConnectJS won't load when rendering code in the server - it can only be loaded on a browser. This error is expected when loading ConnectJS in SSR environments, like NextJS. It will have no impact in the UI, however if you wish to avoid it, you can switch to the `pure` version of the connect.js loader: https://github.com/stripe/connect-js#importing-loadconnect-without-side-effects.");
|
|
105
112
|
return;
|
|
106
113
|
}
|
|
107
|
-
if (window.StripeConnect) {
|
|
114
|
+
if (isWindowStripeConnectDefined(window.StripeConnect)) {
|
|
108
115
|
console.warn(EXISTING_SCRIPT_MESSAGE);
|
|
109
|
-
}
|
|
110
|
-
if (window.StripeConnect) {
|
|
111
116
|
const wrapper = createWrapper(window.StripeConnect);
|
|
112
117
|
resolve(wrapper);
|
|
113
118
|
return;
|
|
@@ -120,7 +125,7 @@ const loadScript = () => {
|
|
|
120
125
|
script = injectScript();
|
|
121
126
|
}
|
|
122
127
|
script.addEventListener("load", () => {
|
|
123
|
-
if (window.StripeConnect) {
|
|
128
|
+
if (isWindowStripeConnectDefined(window.StripeConnect)) {
|
|
124
129
|
const wrapper = createWrapper(window.StripeConnect);
|
|
125
130
|
resolve(wrapper);
|
|
126
131
|
} else {
|
|
@@ -218,7 +223,7 @@ const createWrapper = stripeConnect => {
|
|
|
218
223
|
sdk: true,
|
|
219
224
|
sdkOptions: {
|
|
220
225
|
// This will be replaced by the npm package version when bundling
|
|
221
|
-
sdkVersion: "3.3.
|
|
226
|
+
sdkVersion: "3.3.23"
|
|
222
227
|
}
|
|
223
228
|
})
|
|
224
229
|
}));
|
package/dist/pure.esm.js
CHANGED
|
@@ -90,6 +90,13 @@ const injectScript = () => {
|
|
|
90
90
|
return script;
|
|
91
91
|
};
|
|
92
92
|
let stripePromise = null;
|
|
93
|
+
const isWindowStripeConnectDefined = stripeConnect => {
|
|
94
|
+
// We only consider `StripeConnect` defined if `init` is a function
|
|
95
|
+
// Why? HTML markup like:
|
|
96
|
+
// <a id="StripeConnect"><a id="StripeConnect" name="init" href="stripe"></a></a> in the <head> of the page
|
|
97
|
+
// can end up "contaminating" the window.StripeConnect object and cause issues in connect.js initialization
|
|
98
|
+
return !!(stripeConnect && typeof stripeConnect === "object" && "init" in stripeConnect && typeof stripeConnect.init === "function");
|
|
99
|
+
};
|
|
93
100
|
const loadScript = () => {
|
|
94
101
|
// Ensure that we only attempt to load Connect.js at most once
|
|
95
102
|
if (stripePromise !== null) {
|
|
@@ -100,10 +107,8 @@ const loadScript = () => {
|
|
|
100
107
|
reject("ConnectJS won't load when rendering code in the server - it can only be loaded on a browser. This error is expected when loading ConnectJS in SSR environments, like NextJS. It will have no impact in the UI, however if you wish to avoid it, you can switch to the `pure` version of the connect.js loader: https://github.com/stripe/connect-js#importing-loadconnect-without-side-effects.");
|
|
101
108
|
return;
|
|
102
109
|
}
|
|
103
|
-
if (window.StripeConnect) {
|
|
110
|
+
if (isWindowStripeConnectDefined(window.StripeConnect)) {
|
|
104
111
|
console.warn(EXISTING_SCRIPT_MESSAGE);
|
|
105
|
-
}
|
|
106
|
-
if (window.StripeConnect) {
|
|
107
112
|
const wrapper = createWrapper(window.StripeConnect);
|
|
108
113
|
resolve(wrapper);
|
|
109
114
|
return;
|
|
@@ -116,7 +121,7 @@ const loadScript = () => {
|
|
|
116
121
|
script = injectScript();
|
|
117
122
|
}
|
|
118
123
|
script.addEventListener("load", () => {
|
|
119
|
-
if (window.StripeConnect) {
|
|
124
|
+
if (isWindowStripeConnectDefined(window.StripeConnect)) {
|
|
120
125
|
const wrapper = createWrapper(window.StripeConnect);
|
|
121
126
|
resolve(wrapper);
|
|
122
127
|
} else {
|
|
@@ -214,7 +219,7 @@ const createWrapper = stripeConnect => {
|
|
|
214
219
|
sdk: true,
|
|
215
220
|
sdkOptions: {
|
|
216
221
|
// This will be replaced by the npm package version when bundling
|
|
217
|
-
sdkVersion: "3.3.
|
|
222
|
+
sdkVersion: "3.3.23"
|
|
218
223
|
}
|
|
219
224
|
})
|
|
220
225
|
}));
|
package/dist/pure.js
CHANGED
|
@@ -94,6 +94,13 @@ const injectScript = () => {
|
|
|
94
94
|
return script;
|
|
95
95
|
};
|
|
96
96
|
let stripePromise = null;
|
|
97
|
+
const isWindowStripeConnectDefined = stripeConnect => {
|
|
98
|
+
// We only consider `StripeConnect` defined if `init` is a function
|
|
99
|
+
// Why? HTML markup like:
|
|
100
|
+
// <a id="StripeConnect"><a id="StripeConnect" name="init" href="stripe"></a></a> in the <head> of the page
|
|
101
|
+
// can end up "contaminating" the window.StripeConnect object and cause issues in connect.js initialization
|
|
102
|
+
return !!(stripeConnect && typeof stripeConnect === "object" && "init" in stripeConnect && typeof stripeConnect.init === "function");
|
|
103
|
+
};
|
|
97
104
|
const loadScript = () => {
|
|
98
105
|
// Ensure that we only attempt to load Connect.js at most once
|
|
99
106
|
if (stripePromise !== null) {
|
|
@@ -104,10 +111,8 @@ const loadScript = () => {
|
|
|
104
111
|
reject("ConnectJS won't load when rendering code in the server - it can only be loaded on a browser. This error is expected when loading ConnectJS in SSR environments, like NextJS. It will have no impact in the UI, however if you wish to avoid it, you can switch to the `pure` version of the connect.js loader: https://github.com/stripe/connect-js#importing-loadconnect-without-side-effects.");
|
|
105
112
|
return;
|
|
106
113
|
}
|
|
107
|
-
if (window.StripeConnect) {
|
|
114
|
+
if (isWindowStripeConnectDefined(window.StripeConnect)) {
|
|
108
115
|
console.warn(EXISTING_SCRIPT_MESSAGE);
|
|
109
|
-
}
|
|
110
|
-
if (window.StripeConnect) {
|
|
111
116
|
const wrapper = createWrapper(window.StripeConnect);
|
|
112
117
|
resolve(wrapper);
|
|
113
118
|
return;
|
|
@@ -120,7 +125,7 @@ const loadScript = () => {
|
|
|
120
125
|
script = injectScript();
|
|
121
126
|
}
|
|
122
127
|
script.addEventListener("load", () => {
|
|
123
|
-
if (window.StripeConnect) {
|
|
128
|
+
if (isWindowStripeConnectDefined(window.StripeConnect)) {
|
|
124
129
|
const wrapper = createWrapper(window.StripeConnect);
|
|
125
130
|
resolve(wrapper);
|
|
126
131
|
} else {
|
|
@@ -218,7 +223,7 @@ const createWrapper = stripeConnect => {
|
|
|
218
223
|
sdk: true,
|
|
219
224
|
sdkOptions: {
|
|
220
225
|
// This will be replaced by the npm package version when bundling
|
|
221
|
-
sdkVersion: "3.3.
|
|
226
|
+
sdkVersion: "3.3.23"
|
|
222
227
|
}
|
|
223
228
|
})
|
|
224
229
|
}));
|
package/dist/src/shared.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ interface StripeConnectWrapper {
|
|
|
9
9
|
initialize: (params: IStripeConnectInitParams) => StripeConnectInstance;
|
|
10
10
|
}
|
|
11
11
|
export declare const findScript: () => HTMLScriptElement | null;
|
|
12
|
+
export declare const isWindowStripeConnectDefined: (stripeConnect: unknown) => boolean;
|
|
12
13
|
export declare const loadScript: () => Promise<StripeConnectWrapper>;
|
|
13
14
|
export declare const initStripeConnect: (stripePromise: Promise<StripeConnectWrapper>, initParams: IStripeConnectInitParams) => StripeConnectInstanceExtended;
|
|
14
15
|
export {};
|
package/package.json
CHANGED
package/src/shared.ts
CHANGED
|
@@ -96,6 +96,19 @@ const injectScript = (): HTMLScriptElement => {
|
|
|
96
96
|
|
|
97
97
|
let stripePromise: Promise<StripeConnectWrapper> | null = null;
|
|
98
98
|
|
|
99
|
+
export const isWindowStripeConnectDefined = (stripeConnect: unknown) => {
|
|
100
|
+
// We only consider `StripeConnect` defined if `init` is a function
|
|
101
|
+
// Why? HTML markup like:
|
|
102
|
+
// <a id="StripeConnect"><a id="StripeConnect" name="init" href="stripe"></a></a> in the <head> of the page
|
|
103
|
+
// can end up "contaminating" the window.StripeConnect object and cause issues in connect.js initialization
|
|
104
|
+
return !!(
|
|
105
|
+
stripeConnect &&
|
|
106
|
+
typeof stripeConnect === "object" &&
|
|
107
|
+
"init" in stripeConnect &&
|
|
108
|
+
typeof stripeConnect.init === "function"
|
|
109
|
+
);
|
|
110
|
+
};
|
|
111
|
+
|
|
99
112
|
export const loadScript = (): Promise<StripeConnectWrapper> => {
|
|
100
113
|
// Ensure that we only attempt to load Connect.js at most once
|
|
101
114
|
if (stripePromise !== null) {
|
|
@@ -110,11 +123,8 @@ export const loadScript = (): Promise<StripeConnectWrapper> => {
|
|
|
110
123
|
return;
|
|
111
124
|
}
|
|
112
125
|
|
|
113
|
-
if ((window as any).StripeConnect) {
|
|
126
|
+
if (isWindowStripeConnectDefined((window as any).StripeConnect)) {
|
|
114
127
|
console.warn(EXISTING_SCRIPT_MESSAGE);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if ((window as any).StripeConnect) {
|
|
118
128
|
const wrapper = createWrapper((window as any).StripeConnect);
|
|
119
129
|
resolve(wrapper);
|
|
120
130
|
return;
|
|
@@ -130,7 +140,7 @@ export const loadScript = (): Promise<StripeConnectWrapper> => {
|
|
|
130
140
|
}
|
|
131
141
|
|
|
132
142
|
script.addEventListener("load", () => {
|
|
133
|
-
if ((window as any).StripeConnect) {
|
|
143
|
+
if (isWindowStripeConnectDefined((window as any).StripeConnect)) {
|
|
134
144
|
const wrapper = createWrapper((window as any).StripeConnect);
|
|
135
145
|
resolve(wrapper);
|
|
136
146
|
} else {
|