@superlogic/spree-pay 0.1.26 → 0.1.27
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/build/index.cjs +20 -12
- package/build/index.js +32 -24
- package/package.json +1 -1
package/build/index.cjs
CHANGED
|
@@ -44,7 +44,7 @@ var import_nice_modal_react7 = __toESM(require("@ebay/nice-modal-react"), 1);
|
|
|
44
44
|
var import_swr5 = require("swr");
|
|
45
45
|
|
|
46
46
|
// package.json
|
|
47
|
-
var version = "0.1.
|
|
47
|
+
var version = "0.1.27";
|
|
48
48
|
|
|
49
49
|
// src/context/SpreePayActionsContext.tsx
|
|
50
50
|
var import_react = require("react");
|
|
@@ -3254,19 +3254,27 @@ var Crypto = () => {
|
|
|
3254
3254
|
// src/components/CryptoTab/Crypto/CryptoWrapper.tsx
|
|
3255
3255
|
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
3256
3256
|
var queryClient = new import_react_query.QueryClient();
|
|
3257
|
+
var CHAINS = [import_chains.base];
|
|
3258
|
+
var wagmiConfigCache = /* @__PURE__ */ new Map();
|
|
3259
|
+
function getCachedWagmiConfig(projectId, appName) {
|
|
3260
|
+
const key = `${projectId}::${appName}`;
|
|
3261
|
+
let cfg2 = wagmiConfigCache.get(key);
|
|
3262
|
+
if (!cfg2) {
|
|
3263
|
+
cfg2 = (0, import_rainbowkit2.getDefaultConfig)({ appName, projectId, chains: CHAINS, ssr: true });
|
|
3264
|
+
wagmiConfigCache.set(key, cfg2);
|
|
3265
|
+
}
|
|
3266
|
+
return cfg2;
|
|
3267
|
+
}
|
|
3257
3268
|
var CryptoWrapper = () => {
|
|
3258
|
-
const { spreePayConfig } = useSpreePayConfig();
|
|
3259
|
-
const
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
chains: [import_chains.base],
|
|
3265
|
-
ssr: false
|
|
3266
|
-
});
|
|
3269
|
+
const { spreePayConfig, configIsLoading } = useSpreePayConfig();
|
|
3270
|
+
const [wagmiConfig, setWagmiConfig] = (0, import_react16.useState)(null);
|
|
3271
|
+
(0, import_react16.useEffect)(() => {
|
|
3272
|
+
if (!spreePayConfig) return;
|
|
3273
|
+
const cfg2 = getCachedWagmiConfig(spreePayConfig.rainbowProjectId, spreePayConfig.rainbowAppName);
|
|
3274
|
+
setWagmiConfig((prev) => prev ? prev : cfg2);
|
|
3267
3275
|
}, [spreePayConfig]);
|
|
3268
|
-
if (!
|
|
3269
|
-
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_wagmi5.WagmiProvider, { config, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_react_query.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_rainbowkit2.RainbowKitProvider, { theme: (0, import_rainbowkit2.lightTheme)({ borderRadius: "large" }), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_nice_modal_react6.default.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Crypto, {}) }) }) }) });
|
|
3276
|
+
if (configIsLoading || !wagmiConfig) return null;
|
|
3277
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_wagmi5.WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_react_query.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_rainbowkit2.RainbowKitProvider, { theme: (0, import_rainbowkit2.lightTheme)({ borderRadius: "large" }), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_nice_modal_react6.default.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Crypto, {}) }) }) }) });
|
|
3270
3278
|
};
|
|
3271
3279
|
|
|
3272
3280
|
// src/components/CryptoTab/CryptoTab.tsx
|
package/build/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// src/SpreePay.tsx
|
|
2
|
-
import { useEffect as
|
|
2
|
+
import { useEffect as useEffect12, useLayoutEffect as useLayoutEffect3, useMemo as useMemo9, useRef as useRef7, useState as useState15 } from "react";
|
|
3
3
|
import NiceModal7 from "@ebay/nice-modal-react";
|
|
4
4
|
import { SWRConfig } from "swr";
|
|
5
5
|
|
|
6
6
|
// package.json
|
|
7
|
-
var version = "0.1.
|
|
7
|
+
var version = "0.1.27";
|
|
8
8
|
|
|
9
9
|
// src/context/SpreePayActionsContext.tsx
|
|
10
10
|
import { createContext, useCallback, useContext, useRef, useState } from "react";
|
|
@@ -2515,7 +2515,7 @@ var CreditCardTab = () => {
|
|
|
2515
2515
|
};
|
|
2516
2516
|
|
|
2517
2517
|
// src/components/CryptoTab/Crypto/CryptoWrapper.tsx
|
|
2518
|
-
import {
|
|
2518
|
+
import { useEffect as useEffect10, useState as useState13 } from "react";
|
|
2519
2519
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
2520
2520
|
import NiceModal6 from "@ebay/nice-modal-react";
|
|
2521
2521
|
import { RainbowKitProvider, getDefaultConfig, lightTheme } from "@rainbow-me/rainbowkit";
|
|
@@ -3214,19 +3214,27 @@ var Crypto = () => {
|
|
|
3214
3214
|
// src/components/CryptoTab/Crypto/CryptoWrapper.tsx
|
|
3215
3215
|
import { jsx as jsx38 } from "react/jsx-runtime";
|
|
3216
3216
|
var queryClient = new QueryClient();
|
|
3217
|
+
var CHAINS = [base];
|
|
3218
|
+
var wagmiConfigCache = /* @__PURE__ */ new Map();
|
|
3219
|
+
function getCachedWagmiConfig(projectId, appName) {
|
|
3220
|
+
const key = `${projectId}::${appName}`;
|
|
3221
|
+
let cfg2 = wagmiConfigCache.get(key);
|
|
3222
|
+
if (!cfg2) {
|
|
3223
|
+
cfg2 = getDefaultConfig({ appName, projectId, chains: CHAINS, ssr: true });
|
|
3224
|
+
wagmiConfigCache.set(key, cfg2);
|
|
3225
|
+
}
|
|
3226
|
+
return cfg2;
|
|
3227
|
+
}
|
|
3217
3228
|
var CryptoWrapper = () => {
|
|
3218
|
-
const { spreePayConfig } = useSpreePayConfig();
|
|
3219
|
-
const
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
chains: [base],
|
|
3225
|
-
ssr: false
|
|
3226
|
-
});
|
|
3229
|
+
const { spreePayConfig, configIsLoading } = useSpreePayConfig();
|
|
3230
|
+
const [wagmiConfig, setWagmiConfig] = useState13(null);
|
|
3231
|
+
useEffect10(() => {
|
|
3232
|
+
if (!spreePayConfig) return;
|
|
3233
|
+
const cfg2 = getCachedWagmiConfig(spreePayConfig.rainbowProjectId, spreePayConfig.rainbowAppName);
|
|
3234
|
+
setWagmiConfig((prev) => prev ? prev : cfg2);
|
|
3227
3235
|
}, [spreePayConfig]);
|
|
3228
|
-
if (!
|
|
3229
|
-
return /* @__PURE__ */ jsx38(WagmiProvider, { config, children: /* @__PURE__ */ jsx38(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx38(RainbowKitProvider, { theme: lightTheme({ borderRadius: "large" }), children: /* @__PURE__ */ jsx38(NiceModal6.Provider, { children: /* @__PURE__ */ jsx38(Crypto, {}) }) }) }) });
|
|
3236
|
+
if (configIsLoading || !wagmiConfig) return null;
|
|
3237
|
+
return /* @__PURE__ */ jsx38(WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ jsx38(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx38(RainbowKitProvider, { theme: lightTheme({ borderRadius: "large" }), children: /* @__PURE__ */ jsx38(NiceModal6.Provider, { children: /* @__PURE__ */ jsx38(Crypto, {}) }) }) }) });
|
|
3230
3238
|
};
|
|
3231
3239
|
|
|
3232
3240
|
// src/components/CryptoTab/CryptoTab.tsx
|
|
@@ -3340,7 +3348,7 @@ var SpreePayContent = ({ isLoggedIn }) => {
|
|
|
3340
3348
|
};
|
|
3341
3349
|
|
|
3342
3350
|
// src/hooks/useKeycloakSSO.ts
|
|
3343
|
-
import { useCallback as useCallback7, useEffect as
|
|
3351
|
+
import { useCallback as useCallback7, useEffect as useEffect11, useRef as useRef6, useState as useState14 } from "react";
|
|
3344
3352
|
import Keycloak from "keycloak-js";
|
|
3345
3353
|
var refreshAheadSeconds = 60;
|
|
3346
3354
|
function useKeycloakSSO(config) {
|
|
@@ -3348,9 +3356,9 @@ function useKeycloakSSO(config) {
|
|
|
3348
3356
|
const initRef = useRef6(false);
|
|
3349
3357
|
const kcRef = useRef6(null);
|
|
3350
3358
|
const refreshTimerRef = useRef6(null);
|
|
3351
|
-
const [error, setError] =
|
|
3352
|
-
const [isChecking, setIsChecking] =
|
|
3353
|
-
const [accessToken, setAccessToken] =
|
|
3359
|
+
const [error, setError] = useState14(null);
|
|
3360
|
+
const [isChecking, setIsChecking] = useState14(enabled);
|
|
3361
|
+
const [accessToken, setAccessToken] = useState14(null);
|
|
3354
3362
|
const scheduleRefresh = useCallback7(() => {
|
|
3355
3363
|
const kc = kcRef.current;
|
|
3356
3364
|
if (!kc || !kc.tokenParsed || !kc.tokenParsed.exp) {
|
|
@@ -3372,7 +3380,7 @@ function useKeycloakSSO(config) {
|
|
|
3372
3380
|
});
|
|
3373
3381
|
}, delayMs);
|
|
3374
3382
|
}, []);
|
|
3375
|
-
|
|
3383
|
+
useEffect11(() => {
|
|
3376
3384
|
if (initRef.current || !enabled) return;
|
|
3377
3385
|
initRef.current = true;
|
|
3378
3386
|
setIsChecking(true);
|
|
@@ -3410,13 +3418,13 @@ function useKeycloakSSO(config) {
|
|
|
3410
3418
|
import { jsx as jsx43, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
3411
3419
|
var SpreePayInner = () => {
|
|
3412
3420
|
const rootRef = useRef7(null);
|
|
3413
|
-
const [portalEl, setPortalEl] =
|
|
3421
|
+
const [portalEl, setPortalEl] = useState15(null);
|
|
3414
3422
|
useLayoutEffect3(() => {
|
|
3415
3423
|
if (!rootRef.current) return;
|
|
3416
3424
|
const el = rootRef.current.querySelector(":scope > .sl-spreepay__portal");
|
|
3417
3425
|
setPortalEl(el ?? null);
|
|
3418
3426
|
}, []);
|
|
3419
|
-
|
|
3427
|
+
useEffect12(() => {
|
|
3420
3428
|
console.log(`[spree-pay] v${version}`);
|
|
3421
3429
|
}, []);
|
|
3422
3430
|
const { env } = useSpreePayEnv();
|
|
@@ -3429,7 +3437,7 @@ var SpreePayInner = () => {
|
|
|
3429
3437
|
ssoPageURI: env?.ssoPageURI,
|
|
3430
3438
|
enabled: !env?.accessToken
|
|
3431
3439
|
});
|
|
3432
|
-
const slapiFetcher =
|
|
3440
|
+
const slapiFetcher = useMemo9(() => {
|
|
3433
3441
|
if (accessToken || env.accessToken) {
|
|
3434
3442
|
return registerApi({
|
|
3435
3443
|
accessToken: env.accessToken || accessToken,
|
|
@@ -3469,9 +3477,9 @@ var SpreePay = (props) => {
|
|
|
3469
3477
|
};
|
|
3470
3478
|
|
|
3471
3479
|
// src/hooks/useCapture3DS.ts
|
|
3472
|
-
import { useEffect as
|
|
3480
|
+
import { useEffect as useEffect13 } from "react";
|
|
3473
3481
|
var useCapture3DS = (searchParams) => {
|
|
3474
|
-
|
|
3482
|
+
useEffect13(() => {
|
|
3475
3483
|
if (typeof window !== "undefined" && window.parent && searchParams?.paymentIntent) {
|
|
3476
3484
|
window.parent.SP_EVENT_BUS?.emit("paymentIntent", { paymentIntent: searchParams.paymentIntent });
|
|
3477
3485
|
}
|