@superlogic/spree-pay 0.1.25 → 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 CHANGED
@@ -43,6 +43,9 @@ var import_react18 = require("react");
43
43
  var import_nice_modal_react7 = __toESM(require("@ebay/nice-modal-react"), 1);
44
44
  var import_swr5 = require("swr");
45
45
 
46
+ // package.json
47
+ var version = "0.1.27";
48
+
46
49
  // src/context/SpreePayActionsContext.tsx
47
50
  var import_react = require("react");
48
51
 
@@ -3251,19 +3254,27 @@ var Crypto = () => {
3251
3254
  // src/components/CryptoTab/Crypto/CryptoWrapper.tsx
3252
3255
  var import_jsx_runtime38 = require("react/jsx-runtime");
3253
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
+ }
3254
3268
  var CryptoWrapper = () => {
3255
- const { spreePayConfig } = useSpreePayConfig();
3256
- const config = (0, import_react16.useMemo)(() => {
3257
- if (!spreePayConfig) return null;
3258
- return (0, import_rainbowkit2.getDefaultConfig)({
3259
- appName: spreePayConfig.rainbowAppName,
3260
- projectId: spreePayConfig.rainbowProjectId,
3261
- chains: [import_chains.base],
3262
- ssr: true
3263
- });
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);
3264
3275
  }, [spreePayConfig]);
3265
- if (!config) return null;
3266
- 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, {}) }) }) }) });
3267
3278
  };
3268
3279
 
3269
3280
  // src/components/CryptoTab/CryptoTab.tsx
@@ -3453,6 +3464,9 @@ var SpreePayInner = () => {
3453
3464
  const el = rootRef.current.querySelector(":scope > .sl-spreepay__portal");
3454
3465
  setPortalEl(el ?? null);
3455
3466
  }, []);
3467
+ (0, import_react18.useEffect)(() => {
3468
+ console.log(`[spree-pay] v${version}`);
3469
+ }, []);
3456
3470
  const { env } = useSpreePayEnv();
3457
3471
  const { staticConfig, appProps } = useStaticConfig();
3458
3472
  const tenantId = env?.tenantId || "bookit";
package/build/index.js CHANGED
@@ -1,8 +1,11 @@
1
1
  // src/SpreePay.tsx
2
- import { useLayoutEffect as useLayoutEffect3, useMemo as useMemo10, useRef as useRef7, useState as useState14 } from "react";
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
+ // package.json
7
+ var version = "0.1.27";
8
+
6
9
  // src/context/SpreePayActionsContext.tsx
7
10
  import { createContext, useCallback, useContext, useRef, useState } from "react";
8
11
 
@@ -2512,7 +2515,7 @@ var CreditCardTab = () => {
2512
2515
  };
2513
2516
 
2514
2517
  // src/components/CryptoTab/Crypto/CryptoWrapper.tsx
2515
- import { useMemo as useMemo9 } from "react";
2518
+ import { useEffect as useEffect10, useState as useState13 } from "react";
2516
2519
  import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
2517
2520
  import NiceModal6 from "@ebay/nice-modal-react";
2518
2521
  import { RainbowKitProvider, getDefaultConfig, lightTheme } from "@rainbow-me/rainbowkit";
@@ -3211,19 +3214,27 @@ var Crypto = () => {
3211
3214
  // src/components/CryptoTab/Crypto/CryptoWrapper.tsx
3212
3215
  import { jsx as jsx38 } from "react/jsx-runtime";
3213
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
+ }
3214
3228
  var CryptoWrapper = () => {
3215
- const { spreePayConfig } = useSpreePayConfig();
3216
- const config = useMemo9(() => {
3217
- if (!spreePayConfig) return null;
3218
- return getDefaultConfig({
3219
- appName: spreePayConfig.rainbowAppName,
3220
- projectId: spreePayConfig.rainbowProjectId,
3221
- chains: [base],
3222
- ssr: true
3223
- });
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);
3224
3235
  }, [spreePayConfig]);
3225
- if (!config) return null;
3226
- 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, {}) }) }) }) });
3227
3238
  };
3228
3239
 
3229
3240
  // src/components/CryptoTab/CryptoTab.tsx
@@ -3337,7 +3348,7 @@ var SpreePayContent = ({ isLoggedIn }) => {
3337
3348
  };
3338
3349
 
3339
3350
  // src/hooks/useKeycloakSSO.ts
3340
- import { useCallback as useCallback7, useEffect as useEffect10, useRef as useRef6, useState as useState13 } from "react";
3351
+ import { useCallback as useCallback7, useEffect as useEffect11, useRef as useRef6, useState as useState14 } from "react";
3341
3352
  import Keycloak from "keycloak-js";
3342
3353
  var refreshAheadSeconds = 60;
3343
3354
  function useKeycloakSSO(config) {
@@ -3345,9 +3356,9 @@ function useKeycloakSSO(config) {
3345
3356
  const initRef = useRef6(false);
3346
3357
  const kcRef = useRef6(null);
3347
3358
  const refreshTimerRef = useRef6(null);
3348
- const [error, setError] = useState13(null);
3349
- const [isChecking, setIsChecking] = useState13(enabled);
3350
- const [accessToken, setAccessToken] = useState13(null);
3359
+ const [error, setError] = useState14(null);
3360
+ const [isChecking, setIsChecking] = useState14(enabled);
3361
+ const [accessToken, setAccessToken] = useState14(null);
3351
3362
  const scheduleRefresh = useCallback7(() => {
3352
3363
  const kc = kcRef.current;
3353
3364
  if (!kc || !kc.tokenParsed || !kc.tokenParsed.exp) {
@@ -3369,7 +3380,7 @@ function useKeycloakSSO(config) {
3369
3380
  });
3370
3381
  }, delayMs);
3371
3382
  }, []);
3372
- useEffect10(() => {
3383
+ useEffect11(() => {
3373
3384
  if (initRef.current || !enabled) return;
3374
3385
  initRef.current = true;
3375
3386
  setIsChecking(true);
@@ -3407,12 +3418,15 @@ function useKeycloakSSO(config) {
3407
3418
  import { jsx as jsx43, jsxs as jsxs27 } from "react/jsx-runtime";
3408
3419
  var SpreePayInner = () => {
3409
3420
  const rootRef = useRef7(null);
3410
- const [portalEl, setPortalEl] = useState14(null);
3421
+ const [portalEl, setPortalEl] = useState15(null);
3411
3422
  useLayoutEffect3(() => {
3412
3423
  if (!rootRef.current) return;
3413
3424
  const el = rootRef.current.querySelector(":scope > .sl-spreepay__portal");
3414
3425
  setPortalEl(el ?? null);
3415
3426
  }, []);
3427
+ useEffect12(() => {
3428
+ console.log(`[spree-pay] v${version}`);
3429
+ }, []);
3416
3430
  const { env } = useSpreePayEnv();
3417
3431
  const { staticConfig, appProps } = useStaticConfig();
3418
3432
  const tenantId = env?.tenantId || "bookit";
@@ -3423,7 +3437,7 @@ var SpreePayInner = () => {
3423
3437
  ssoPageURI: env?.ssoPageURI,
3424
3438
  enabled: !env?.accessToken
3425
3439
  });
3426
- const slapiFetcher = useMemo10(() => {
3440
+ const slapiFetcher = useMemo9(() => {
3427
3441
  if (accessToken || env.accessToken) {
3428
3442
  return registerApi({
3429
3443
  accessToken: env.accessToken || accessToken,
@@ -3463,9 +3477,9 @@ var SpreePay = (props) => {
3463
3477
  };
3464
3478
 
3465
3479
  // src/hooks/useCapture3DS.ts
3466
- import { useEffect as useEffect11 } from "react";
3480
+ import { useEffect as useEffect13 } from "react";
3467
3481
  var useCapture3DS = (searchParams) => {
3468
- useEffect11(() => {
3482
+ useEffect13(() => {
3469
3483
  if (typeof window !== "undefined" && window.parent && searchParams?.paymentIntent) {
3470
3484
  window.parent.SP_EVENT_BUS?.emit("paymentIntent", { paymentIntent: searchParams.paymentIntent });
3471
3485
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superlogic/spree-pay",
3
- "version": "0.1.25",
3
+ "version": "0.1.27",
4
4
  "description": "Spree-pay React component and utilities",
5
5
  "private": false,
6
6
  "type": "module",