@solvapay/react 1.1.2 → 1.1.3-preview-5c041557cfab501e35bc232a2864d80c96afdb92
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/CHANGELOG.md +12 -0
- package/dist/{chunk-ZUITUQXA.js → chunk-65ZUT5BW.js} +1 -1
- package/dist/{chunk-XYBKLHT2.js → chunk-OMQXXYD4.js} +1 -1
- package/dist/{chunk-BB6F7RRD.js → chunk-WQ3P3PK7.js} +11 -25
- package/dist/index.cjs +9 -25
- package/dist/index.js +3 -3
- package/dist/mcp/index.cjs +1 -15
- package/dist/mcp/index.js +2 -2
- package/dist/primitives/index.cjs +9 -23
- package/dist/primitives/index.js +2 -2
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @solvapay/react changelog
|
|
2
2
|
|
|
3
|
+
## 1.1.3-preview-5c041557cfab501e35bc232a2864d80c96afdb92
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9c66d68: Fix `usePlan` so it no longer fires a raw `fetch('/api/list-plans')` when an MCP transport is configured. The hook now routes through `defaultListPlans`, which is transport-aware and falls back to the seeded `plansCache` when the MCP adapter omits `listPlans` (the Phase 2c shape, where plans arrive in the bootstrap snapshot).
|
|
8
|
+
|
|
9
|
+
This was the second symptom on Goldberg's ChatGPT App: the iframe sandbox returned 404 for `/api/list-plans` because the MCP origin doesn't serve that route. New regression test in `usePlan.test.tsx` covers the iframe-sandbox 404 pattern, and `ActivationFlow.test.tsx` was updated to seed `plansCache` directly to match the production MCP bootstrap pattern.
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [36ac2ad]
|
|
12
|
+
- Updated dependencies [9c66d68]
|
|
13
|
+
- @solvapay/mcp-core@0.2.4-preview-5c041557cfab501e35bc232a2864d80c96afdb92
|
|
14
|
+
|
|
3
15
|
## 1.1.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -1489,7 +1489,13 @@ function usePlans(options) {
|
|
|
1489
1489
|
|
|
1490
1490
|
// src/hooks/usePlan.ts
|
|
1491
1491
|
import { useCallback as useCallback4, useEffect as useEffect3, useState as useState4 } from "react";
|
|
1492
|
-
|
|
1492
|
+
|
|
1493
|
+
// src/transport/list-plans.ts
|
|
1494
|
+
async function defaultListPlans(productRef, config) {
|
|
1495
|
+
const transport = config?.transport;
|
|
1496
|
+
if (transport) {
|
|
1497
|
+
return transport.listPlans ? transport.listPlans(productRef) : plansCache.get(productRef)?.plans ?? [];
|
|
1498
|
+
}
|
|
1493
1499
|
const base = config?.api?.listPlans || "/api/list-plans";
|
|
1494
1500
|
const url = `${base}?productRef=${encodeURIComponent(productRef)}`;
|
|
1495
1501
|
const fetchFn = config?.fetch || fetch;
|
|
@@ -1503,6 +1509,8 @@ async function listPlans(productRef, config) {
|
|
|
1503
1509
|
const data = await res.json();
|
|
1504
1510
|
return data.plans ?? [];
|
|
1505
1511
|
}
|
|
1512
|
+
|
|
1513
|
+
// src/hooks/usePlan.ts
|
|
1506
1514
|
function usePlan(options) {
|
|
1507
1515
|
const { planRef, productRef } = options;
|
|
1508
1516
|
const { _config } = useSolvaPay();
|
|
@@ -1570,7 +1578,7 @@ function usePlan(options) {
|
|
|
1570
1578
|
try {
|
|
1571
1579
|
setLoading(true);
|
|
1572
1580
|
setError(null);
|
|
1573
|
-
const promise =
|
|
1581
|
+
const promise = defaultListPlans(productRef, _config);
|
|
1574
1582
|
plansCache.set(productRef, { plans: [], timestamp: now, promise });
|
|
1575
1583
|
const plans = await promise;
|
|
1576
1584
|
plansCache.set(productRef, { plans, timestamp: now, promise: null });
|
|
@@ -3830,28 +3838,6 @@ import {
|
|
|
3830
3838
|
useContext as useContext11,
|
|
3831
3839
|
useMemo as useMemo10
|
|
3832
3840
|
} from "react";
|
|
3833
|
-
|
|
3834
|
-
// src/transport/list-plans.ts
|
|
3835
|
-
async function defaultListPlans(productRef, config) {
|
|
3836
|
-
const transport = config?.transport;
|
|
3837
|
-
if (transport) {
|
|
3838
|
-
return transport.listPlans ? transport.listPlans(productRef) : plansCache.get(productRef)?.plans ?? [];
|
|
3839
|
-
}
|
|
3840
|
-
const base = config?.api?.listPlans || "/api/list-plans";
|
|
3841
|
-
const url = `${base}?productRef=${encodeURIComponent(productRef)}`;
|
|
3842
|
-
const fetchFn = config?.fetch || fetch;
|
|
3843
|
-
const { headers } = await buildRequestHeaders(config);
|
|
3844
|
-
const res = await fetchFn(url, { method: "GET", headers });
|
|
3845
|
-
if (!res.ok) {
|
|
3846
|
-
const error = new Error(`Failed to fetch plans: ${res.statusText || res.status}`);
|
|
3847
|
-
config?.onError?.(error, "listPlans");
|
|
3848
|
-
throw error;
|
|
3849
|
-
}
|
|
3850
|
-
const data = await res.json();
|
|
3851
|
-
return data.plans ?? [];
|
|
3852
|
-
}
|
|
3853
|
-
|
|
3854
|
-
// src/primitives/PlanSelector.tsx
|
|
3855
3841
|
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
3856
3842
|
var PlanSelectorContext = createContext8(null);
|
|
3857
3843
|
function usePlanSelectorContext(part) {
|
|
@@ -4817,6 +4803,7 @@ export {
|
|
|
4817
4803
|
useCustomer,
|
|
4818
4804
|
plansCache,
|
|
4819
4805
|
usePlans,
|
|
4806
|
+
defaultListPlans,
|
|
4820
4807
|
usePlan,
|
|
4821
4808
|
createTransportCacheKey,
|
|
4822
4809
|
productCache,
|
|
@@ -4877,7 +4864,6 @@ export {
|
|
|
4877
4864
|
TopupForm,
|
|
4878
4865
|
useTopupForm,
|
|
4879
4866
|
BalanceBadge,
|
|
4880
|
-
defaultListPlans,
|
|
4881
4867
|
PlanSelectorRoot2 as PlanSelectorRoot,
|
|
4882
4868
|
PlanSelectorHeading2 as PlanSelectorHeading,
|
|
4883
4869
|
PlanSelectorGrid2 as PlanSelectorGrid,
|
package/dist/index.cjs
CHANGED
|
@@ -1673,8 +1673,12 @@ function usePlans(options) {
|
|
|
1673
1673
|
};
|
|
1674
1674
|
}
|
|
1675
1675
|
|
|
1676
|
-
// src/
|
|
1677
|
-
async function
|
|
1676
|
+
// src/transport/list-plans.ts
|
|
1677
|
+
async function defaultListPlans(productRef, config) {
|
|
1678
|
+
const transport = config?.transport;
|
|
1679
|
+
if (transport) {
|
|
1680
|
+
return transport.listPlans ? transport.listPlans(productRef) : plansCache.get(productRef)?.plans ?? [];
|
|
1681
|
+
}
|
|
1678
1682
|
const base = config?.api?.listPlans || "/api/list-plans";
|
|
1679
1683
|
const url = `${base}?productRef=${encodeURIComponent(productRef)}`;
|
|
1680
1684
|
const fetchFn = config?.fetch || fetch;
|
|
@@ -1688,6 +1692,8 @@ async function listPlans(productRef, config) {
|
|
|
1688
1692
|
const data = await res.json();
|
|
1689
1693
|
return data.plans ?? [];
|
|
1690
1694
|
}
|
|
1695
|
+
|
|
1696
|
+
// src/hooks/usePlan.ts
|
|
1691
1697
|
function usePlan(options) {
|
|
1692
1698
|
const { planRef, productRef } = options;
|
|
1693
1699
|
const { _config } = useSolvaPay();
|
|
@@ -1755,7 +1761,7 @@ function usePlan(options) {
|
|
|
1755
1761
|
try {
|
|
1756
1762
|
setLoading(true);
|
|
1757
1763
|
setError(null);
|
|
1758
|
-
const promise =
|
|
1764
|
+
const promise = defaultListPlans(productRef, _config);
|
|
1759
1765
|
plansCache.set(productRef, { plans: [], timestamp: now, promise });
|
|
1760
1766
|
const plans = await promise;
|
|
1761
1767
|
plansCache.set(productRef, { plans, timestamp: now, promise: null });
|
|
@@ -4218,28 +4224,6 @@ var import_react28 = require("react");
|
|
|
4218
4224
|
|
|
4219
4225
|
// src/primitives/PlanSelector.tsx
|
|
4220
4226
|
var import_react26 = require("react");
|
|
4221
|
-
|
|
4222
|
-
// src/transport/list-plans.ts
|
|
4223
|
-
async function defaultListPlans(productRef, config) {
|
|
4224
|
-
const transport = config?.transport;
|
|
4225
|
-
if (transport) {
|
|
4226
|
-
return transport.listPlans ? transport.listPlans(productRef) : plansCache.get(productRef)?.plans ?? [];
|
|
4227
|
-
}
|
|
4228
|
-
const base = config?.api?.listPlans || "/api/list-plans";
|
|
4229
|
-
const url = `${base}?productRef=${encodeURIComponent(productRef)}`;
|
|
4230
|
-
const fetchFn = config?.fetch || fetch;
|
|
4231
|
-
const { headers } = await buildRequestHeaders(config);
|
|
4232
|
-
const res = await fetchFn(url, { method: "GET", headers });
|
|
4233
|
-
if (!res.ok) {
|
|
4234
|
-
const error = new Error(`Failed to fetch plans: ${res.statusText || res.status}`);
|
|
4235
|
-
config?.onError?.(error, "listPlans");
|
|
4236
|
-
throw error;
|
|
4237
|
-
}
|
|
4238
|
-
const data = await res.json();
|
|
4239
|
-
return data.plans ?? [];
|
|
4240
|
-
}
|
|
4241
|
-
|
|
4242
|
-
// src/primitives/PlanSelector.tsx
|
|
4243
4227
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
4244
4228
|
var PlanSelectorContext = (0, import_react26.createContext)(null);
|
|
4245
4229
|
function usePlanSelectorContext(part) {
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
LaunchCustomerPortalButton,
|
|
4
4
|
UpdatePaymentMethodButton,
|
|
5
5
|
usePaymentMethod
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-OMQXXYD4.js";
|
|
7
7
|
import {
|
|
8
8
|
ActivationFlow,
|
|
9
9
|
CreditGate,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
useActivationFlow,
|
|
15
15
|
useCreditGate,
|
|
16
16
|
usePaywallResolver
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-65ZUT5BW.js";
|
|
18
18
|
import {
|
|
19
19
|
AmountPicker,
|
|
20
20
|
BalanceBadge,
|
|
@@ -82,7 +82,7 @@ import {
|
|
|
82
82
|
useTopupAmountSelector,
|
|
83
83
|
useTransport,
|
|
84
84
|
useUsage
|
|
85
|
-
} from "./chunk-
|
|
85
|
+
} from "./chunk-WQ3P3PK7.js";
|
|
86
86
|
import {
|
|
87
87
|
defaultAuthAdapter
|
|
88
88
|
} from "./chunk-OUSEQRCT.js";
|
package/dist/mcp/index.cjs
CHANGED
|
@@ -4460,20 +4460,6 @@ var import_react32 = require("react");
|
|
|
4460
4460
|
|
|
4461
4461
|
// src/hooks/usePlan.ts
|
|
4462
4462
|
var import_react31 = require("react");
|
|
4463
|
-
async function listPlans(productRef, config) {
|
|
4464
|
-
const base = config?.api?.listPlans || "/api/list-plans";
|
|
4465
|
-
const url = `${base}?productRef=${encodeURIComponent(productRef)}`;
|
|
4466
|
-
const fetchFn = config?.fetch || fetch;
|
|
4467
|
-
const { headers } = await buildRequestHeaders(config);
|
|
4468
|
-
const res = await fetchFn(url, { method: "GET", headers });
|
|
4469
|
-
if (!res.ok) {
|
|
4470
|
-
const error = new Error(`Failed to fetch plans: ${res.statusText || res.status}`);
|
|
4471
|
-
config?.onError?.(error, "listPlans");
|
|
4472
|
-
throw error;
|
|
4473
|
-
}
|
|
4474
|
-
const data = await res.json();
|
|
4475
|
-
return data.plans ?? [];
|
|
4476
|
-
}
|
|
4477
4463
|
function usePlan(options) {
|
|
4478
4464
|
const { planRef, productRef } = options;
|
|
4479
4465
|
const { _config } = useSolvaPay();
|
|
@@ -4541,7 +4527,7 @@ function usePlan(options) {
|
|
|
4541
4527
|
try {
|
|
4542
4528
|
setLoading(true);
|
|
4543
4529
|
setError(null);
|
|
4544
|
-
const promise =
|
|
4530
|
+
const promise = defaultListPlans(productRef, _config);
|
|
4545
4531
|
plansCache.set(productRef, { plans: [], timestamp: now, promise });
|
|
4546
4532
|
const plans = await promise;
|
|
4547
4533
|
plansCache.set(productRef, { plans, timestamp: now, promise: null });
|
package/dist/mcp/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
ExternalLinkGlyph,
|
|
4
4
|
LaunchCustomerPortalButton,
|
|
5
5
|
paymentMethodCache
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-OMQXXYD4.js";
|
|
7
7
|
import {
|
|
8
8
|
isPaygPlan
|
|
9
9
|
} from "../chunk-PLPNLBDA.js";
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
usePurchase,
|
|
34
34
|
usePurchaseStatus,
|
|
35
35
|
useTransport
|
|
36
|
-
} from "../chunk-
|
|
36
|
+
} from "../chunk-WQ3P3PK7.js";
|
|
37
37
|
import "../chunk-OUSEQRCT.js";
|
|
38
38
|
|
|
39
39
|
// src/mcp/adapter.ts
|
|
@@ -971,8 +971,12 @@ function usePlans(options) {
|
|
|
971
971
|
};
|
|
972
972
|
}
|
|
973
973
|
|
|
974
|
-
// src/
|
|
975
|
-
async function
|
|
974
|
+
// src/transport/list-plans.ts
|
|
975
|
+
async function defaultListPlans(productRef, config) {
|
|
976
|
+
const transport = config?.transport;
|
|
977
|
+
if (transport) {
|
|
978
|
+
return transport.listPlans ? transport.listPlans(productRef) : plansCache.get(productRef)?.plans ?? [];
|
|
979
|
+
}
|
|
976
980
|
const base = config?.api?.listPlans || "/api/list-plans";
|
|
977
981
|
const url = `${base}?productRef=${encodeURIComponent(productRef)}`;
|
|
978
982
|
const fetchFn = config?.fetch || fetch;
|
|
@@ -986,6 +990,8 @@ async function listPlans(productRef, config) {
|
|
|
986
990
|
const data = await res.json();
|
|
987
991
|
return data.plans ?? [];
|
|
988
992
|
}
|
|
993
|
+
|
|
994
|
+
// src/hooks/usePlan.ts
|
|
989
995
|
function usePlan(options) {
|
|
990
996
|
const { planRef, productRef } = options;
|
|
991
997
|
const { _config } = useSolvaPay();
|
|
@@ -1053,7 +1059,7 @@ function usePlan(options) {
|
|
|
1053
1059
|
try {
|
|
1054
1060
|
setLoading(true);
|
|
1055
1061
|
setError(null);
|
|
1056
|
-
const promise =
|
|
1062
|
+
const promise = defaultListPlans(productRef, _config);
|
|
1057
1063
|
plansCache.set(productRef, { plans: [], timestamp: now, promise });
|
|
1058
1064
|
const plans = await promise;
|
|
1059
1065
|
plansCache.set(productRef, { plans, timestamp: now, promise: null });
|
|
@@ -1414,26 +1420,6 @@ function useCheckoutSummary() {
|
|
|
1414
1420
|
// src/primitives/PlanSelector.tsx
|
|
1415
1421
|
var import_react10 = require("react");
|
|
1416
1422
|
|
|
1417
|
-
// src/transport/list-plans.ts
|
|
1418
|
-
async function defaultListPlans(productRef, config) {
|
|
1419
|
-
const transport = config?.transport;
|
|
1420
|
-
if (transport) {
|
|
1421
|
-
return transport.listPlans ? transport.listPlans(productRef) : plansCache.get(productRef)?.plans ?? [];
|
|
1422
|
-
}
|
|
1423
|
-
const base = config?.api?.listPlans || "/api/list-plans";
|
|
1424
|
-
const url = `${base}?productRef=${encodeURIComponent(productRef)}`;
|
|
1425
|
-
const fetchFn = config?.fetch || fetch;
|
|
1426
|
-
const { headers } = await buildRequestHeaders(config);
|
|
1427
|
-
const res = await fetchFn(url, { method: "GET", headers });
|
|
1428
|
-
if (!res.ok) {
|
|
1429
|
-
const error = new Error(`Failed to fetch plans: ${res.statusText || res.status}`);
|
|
1430
|
-
config?.onError?.(error, "listPlans");
|
|
1431
|
-
throw error;
|
|
1432
|
-
}
|
|
1433
|
-
const data = await res.json();
|
|
1434
|
-
return data.plans ?? [];
|
|
1435
|
-
}
|
|
1436
|
-
|
|
1437
1423
|
// src/hooks/usePurchase.ts
|
|
1438
1424
|
function usePurchase() {
|
|
1439
1425
|
const { purchase, refetchPurchase } = useSolvaPay();
|
package/dist/primitives/index.js
CHANGED
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
useCreditGate,
|
|
29
29
|
usePaywallResolver,
|
|
30
30
|
usePurchaseGate
|
|
31
|
-
} from "../chunk-
|
|
31
|
+
} from "../chunk-65ZUT5BW.js";
|
|
32
32
|
import {
|
|
33
33
|
isPaygPlan
|
|
34
34
|
} from "../chunk-PLPNLBDA.js";
|
|
@@ -110,7 +110,7 @@ import {
|
|
|
110
110
|
usePlanSelector,
|
|
111
111
|
useTopupForm,
|
|
112
112
|
useUsageMeter
|
|
113
|
-
} from "../chunk-
|
|
113
|
+
} from "../chunk-WQ3P3PK7.js";
|
|
114
114
|
import "../chunk-OUSEQRCT.js";
|
|
115
115
|
|
|
116
116
|
// src/primitives/PaywallNotice.tsx
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solvapay/react",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3-preview-5c041557cfab501e35bc232a2864d80c96afdb92",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"react": "^18.2.0 || ^19.0.0",
|
|
56
56
|
"react-dom": "^18.2.0 || ^19.0.0",
|
|
57
|
-
"@solvapay/mcp-core": "0.2.
|
|
57
|
+
"@solvapay/mcp-core": "0.2.4-preview-5c041557cfab501e35bc232a2864d80c96afdb92"
|
|
58
58
|
},
|
|
59
59
|
"peerDependenciesMeta": {
|
|
60
60
|
"@solvapay/mcp-core": {
|
|
@@ -79,9 +79,9 @@
|
|
|
79
79
|
"react-dom": "^19.2.4",
|
|
80
80
|
"typescript": "^5.9.3",
|
|
81
81
|
"vitest": "^4.1.2",
|
|
82
|
-
"@solvapay/mcp-core": "0.2.
|
|
83
|
-
"@solvapay/
|
|
84
|
-
"@solvapay/
|
|
82
|
+
"@solvapay/mcp-core": "0.2.4-preview-5c041557cfab501e35bc232a2864d80c96afdb92",
|
|
83
|
+
"@solvapay/test-utils": "0.0.0",
|
|
84
|
+
"@solvapay/server": "1.0.11"
|
|
85
85
|
},
|
|
86
86
|
"scripts": {
|
|
87
87
|
"build": "tsup src/index.tsx src/primitives/index.ts src/adapters/auth.ts src/mcp/index.ts --format esm,cjs --dts --tsconfig tsconfig.build.json && cp src/styles.css dist/styles.css && mkdir -p dist/mcp && cp src/mcp/styles.css dist/mcp/styles.css",
|