@fragno-dev/stripe 0.1.2 → 2.0.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 +63 -12
- package/dist/browser/client/react.d.ts +4 -4
- package/dist/browser/client/react.js +2 -2
- package/dist/browser/client/react.js.map +1 -1
- package/dist/browser/client/solid.d.ts +4 -4
- package/dist/browser/client/solid.js +2 -2
- package/dist/browser/client/solid.js.map +1 -1
- package/dist/browser/client/svelte.d.ts +4 -4
- package/dist/browser/client/svelte.js +1 -1
- package/dist/browser/client/vanilla.d.ts +4 -4
- package/dist/browser/client/vanilla.js +1 -1
- package/dist/browser/client/vue.js +15 -1
- package/dist/browser/client/vue.js.map +1 -1
- package/dist/browser/index.d.ts +25 -20
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/{src-CitTJF-J.js → src-D1l5aeYY.js} +182 -19
- package/dist/browser/src-D1l5aeYY.js.map +1 -0
- package/dist/node/index.d.ts +25 -20
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -11
- package/dist/browser/src-CitTJF-J.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,17 +1,36 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="./assets/stripe-integration.png" alt="Stripe integration example" width="600" />
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
# @fragno-dev/stripe
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
Stripe subscriptions library for Fragno.
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
It manages customers, subscriptions, and billing portal access, and handles Stripe webhooks for you.
|
|
8
10
|
|
|
9
|
-
##
|
|
11
|
+
## Who is this for?
|
|
12
|
+
|
|
13
|
+
- **App developers** who want a batteries-included Stripe subscriptions integration without wiring
|
|
14
|
+
up all webhooks, routes, and client calls by hand.
|
|
15
|
+
|
|
16
|
+
You configure Stripe keys; the library provides routes and client helpers.
|
|
17
|
+
|
|
18
|
+
## Quick start
|
|
19
|
+
|
|
20
|
+
### 1. Install
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @fragno-dev/stripe
|
|
24
|
+
# or
|
|
25
|
+
pnpm add @fragno-dev/stripe
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 2. Configure on the server
|
|
10
29
|
|
|
11
30
|
```ts
|
|
12
31
|
import { createStripeFragment } from "@fragno-dev/stripe";
|
|
13
32
|
|
|
14
|
-
const
|
|
33
|
+
export const stripe = createStripeFragment({
|
|
15
34
|
stripeSecretKey: process.env.STRIPE_SECRET_KEY,
|
|
16
35
|
webhookSecret: process.env.STRIPE_WEBHOOK_SECRET,
|
|
17
36
|
stripeClientOptions: {
|
|
@@ -21,7 +40,7 @@ const fragment = createStripeFragment({
|
|
|
21
40
|
});
|
|
22
41
|
```
|
|
23
42
|
|
|
24
|
-
|
|
43
|
+
### 3. Client helpers
|
|
25
44
|
|
|
26
45
|
```ts
|
|
27
46
|
import { createStripeFragmentClient } from "@fragno-dev/stripe/react";
|
|
@@ -29,12 +48,44 @@ import { createStripeFragmentClient } from "@fragno-dev/stripe/react";
|
|
|
29
48
|
export const stripeClient = createStripeFragmentClient();
|
|
30
49
|
```
|
|
31
50
|
|
|
32
|
-
The client
|
|
51
|
+
The client exposes helpers to manage subscriptions and billing flows from your frontend.
|
|
52
|
+
|
|
53
|
+
Example (React):
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import { stripeClient } from "@/lib/stripe-client";
|
|
57
|
+
|
|
58
|
+
export function UpgradeButton() {
|
|
59
|
+
const { upgradeSubscription } = stripeClient;
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<button
|
|
63
|
+
type="button"
|
|
64
|
+
onClick={() => {
|
|
65
|
+
return upgradeSubscription({
|
|
66
|
+
priceId: "price_123",
|
|
67
|
+
});
|
|
68
|
+
}}
|
|
69
|
+
>
|
|
70
|
+
Upgrade
|
|
71
|
+
</button>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Features
|
|
77
|
+
|
|
78
|
+
- **Customers and subscriptions**: create and manage customer subscriptions in your app.
|
|
79
|
+
- **Billing portal redirect**: send users to Stripe's billing portal for payment methods and
|
|
80
|
+
invoices.
|
|
81
|
+
- **Webhook handling**: verify and process Stripe webhooks in one place.
|
|
82
|
+
- **Typed client helpers**: simple helpers for common subscription flows.
|
|
83
|
+
|
|
84
|
+
## Documentation
|
|
85
|
+
|
|
86
|
+
For a full walkthrough and framework-specific setup (Next.js, React Router, etc.), see:
|
|
33
87
|
|
|
34
|
-
-
|
|
35
|
-
- `cancelSubscription()`: Cancel an existing subscription
|
|
36
|
-
- `useBillingPortal()`: Redirect to Stripe's billing portal for managing payment methods and billing
|
|
37
|
-
details
|
|
88
|
+
- [Stripe Quick Start](https://fragno.dev/docs/stripe/quickstart)
|
|
38
89
|
|
|
39
90
|
## Build
|
|
40
91
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as zod619 from "zod";
|
|
2
2
|
import * as zod_v4_core48 from "zod/v4/core";
|
|
3
3
|
import * as _fragno_dev_core_react0 from "@fragno-dev/core/react";
|
|
4
|
-
import * as
|
|
4
|
+
import * as _fragno_dev_core_api6 from "@fragno-dev/core/api";
|
|
5
5
|
import { FragnoPublicClientConfig } from "@fragno-dev/core/client";
|
|
6
6
|
|
|
7
7
|
//#region src/client/react.d.ts
|
|
@@ -123,13 +123,13 @@ declare function createStripeFragmentClient(config?: FragnoPublicClientConfig):
|
|
|
123
123
|
updatedAt: zod619.ZodDate;
|
|
124
124
|
}, zod_v4_core48.$strip>>;
|
|
125
125
|
}, zod_v4_core48.$strip>, string, string>;
|
|
126
|
-
useBillingPortal: _fragno_dev_core_react0.FragnoReactMutator<
|
|
126
|
+
useBillingPortal: _fragno_dev_core_react0.FragnoReactMutator<_fragno_dev_core_api6.NonGetHTTPMethod, "/portal", zod619.ZodObject<{
|
|
127
127
|
returnUrl: zod619.ZodURL;
|
|
128
128
|
}, zod_v4_core48.$strip> | undefined, zod619.ZodObject<{
|
|
129
129
|
url: zod619.ZodURL;
|
|
130
130
|
redirect: zod619.ZodBoolean;
|
|
131
131
|
}, zod_v4_core48.$strip> | undefined, "NO_STRIPE_CUSTOMER_FOR_ENTITY", string>;
|
|
132
|
-
upgradeSubscription: _fragno_dev_core_react0.FragnoReactMutator<
|
|
132
|
+
upgradeSubscription: _fragno_dev_core_react0.FragnoReactMutator<_fragno_dev_core_api6.NonGetHTTPMethod, "/subscription/upgrade", zod619.ZodObject<{
|
|
133
133
|
priceId: zod619.ZodString;
|
|
134
134
|
quantity: zod619.ZodNumber;
|
|
135
135
|
successUrl: zod619.ZodURL;
|
|
@@ -142,7 +142,7 @@ declare function createStripeFragmentClient(config?: FragnoPublicClientConfig):
|
|
|
142
142
|
redirect: zod619.ZodBoolean;
|
|
143
143
|
sessionId: zod619.ZodOptional<zod619.ZodString>;
|
|
144
144
|
}, zod_v4_core48.$strip> | undefined, "MISSING_CUSTOMER_INFO" | "SUBSCRIPTION_NOT_FOUND" | "CUSTOMER_SUBSCRIPTION_MISMATCH" | "UPGRADE_HAS_NO_EFFECT" | "SUBSCRIPTION_UPDATE_NOT_ALLOWED" | "SUBSCRIPTION_UPDATE_PROMO_CODE_NOT_ALLOWED" | "PROMOTION_CODE_CUSTOMER_NOT_FIRST_TIME" | "MULTIPLE_ACTIVE_SUBSCRIPTIONS" | "NO_ACTIVE_SUBSCRIPTIONS", string>;
|
|
145
|
-
cancelSubscription: _fragno_dev_core_react0.FragnoReactMutator<
|
|
145
|
+
cancelSubscription: _fragno_dev_core_react0.FragnoReactMutator<_fragno_dev_core_api6.NonGetHTTPMethod, "/subscription/cancel", zod619.ZodObject<{
|
|
146
146
|
returnUrl: zod619.ZodURL;
|
|
147
147
|
subscriptionId: zod619.ZodOptional<zod619.ZodString>;
|
|
148
148
|
}, zod_v4_core48.$strip> | undefined, zod619.ZodObject<{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createStripeFragmentClients, isGetHook, isMutatorHook, isReadableAtom, isStore } from "../src-
|
|
1
|
+
import { createStripeFragmentClients, isGetHook, isMutatorHook, isReadableAtom, isStore } from "../src-D1l5aeYY.js";
|
|
2
2
|
import { useCallback, useMemo, useRef, useSyncExternalStore } from "react";
|
|
3
3
|
|
|
4
|
-
//#region ../../node_modules/.pnpm/nanostores@1.0
|
|
4
|
+
//#region ../../node_modules/.pnpm/nanostores@1.1.0/node_modules/nanostores/listen-keys/index.js
|
|
5
5
|
function listenKeys($store, keys, listener) {
|
|
6
6
|
let keysSet = new Set(keys).add(void 0);
|
|
7
7
|
return $store.listen((value, oldValue, changed) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","names":["listenKeys","$store","keys","listener","keysSet","Set","add","undefined","listen","value","oldValue","changed","has","subscribeKeys","unbind","hydrateFromWindow","isReadableAtom","isGetHook","isMutatorHook","isStore","listenKeys","useCallback","useMemo","useRef","useSyncExternalStore","createReactHook","hook","path","query","pathParamValues","Object","values","queryParamValues","store","window","get","useStore","createReactMutator","mutatorStore","createReactStore","obj","result","key","prototype","hasOwnProperty","call","value","useFragno","clientObj","options","snapshotRef","keys","deps","subscribe","onChange","emitChange","current","length","listen","FragnoHydrator","children","useFragno","createStripeFragmentClients","FragnoPublicClientConfig","createStripeFragmentClient","config"],"sources":["../../../../../node_modules/.pnpm/nanostores@1.0
|
|
1
|
+
{"version":3,"file":"react.js","names":["listenKeys","$store","keys","listener","keysSet","Set","add","undefined","listen","value","oldValue","changed","has","subscribeKeys","unbind","hydrateFromWindow","isReadableAtom","isGetHook","isMutatorHook","isStore","listenKeys","useCallback","useMemo","useRef","useSyncExternalStore","createReactHook","hook","path","query","pathParamValues","Object","values","queryParamValues","store","window","get","useStore","createReactMutator","mutatorStore","createReactStore","obj","result","key","prototype","hasOwnProperty","call","value","useFragno","clientObj","options","snapshotRef","keys","deps","subscribe","onChange","emitChange","current","length","listen","FragnoHydrator","children","useFragno","createStripeFragmentClients","FragnoPublicClientConfig","createStripeFragmentClient","config"],"sources":["../../../../../node_modules/.pnpm/nanostores@1.1.0/node_modules/nanostores/listen-keys/index.js","../../../../fragno/dist/client/react.js","../../../src/client/react.ts"],"sourcesContent":["export function listenKeys($store, keys, listener) {\n let keysSet = new Set(keys).add(undefined)\n return $store.listen((value, oldValue, changed) => {\n if (keysSet.has(changed)) {\n listener(value, oldValue, changed)\n }\n })\n}\n\nexport function subscribeKeys($store, keys, listener) {\n let unbind = listenKeys($store, keys, listener)\n listener($store.value)\n return unbind\n}\n","import { hydrateFromWindow } from \"../util/ssr.js\";\nimport { isReadableAtom } from \"../util/nanostores.js\";\nimport { isGetHook, isMutatorHook, isStore } from \"./client.js\";\nimport { listenKeys } from \"nanostores\";\nimport { useCallback, useMemo, useRef, useSyncExternalStore } from \"react\";\n\n//#region src/client/react.ts\nfunction createReactHook(hook) {\n\treturn ({ path, query } = {}) => {\n\t\tconst pathParamValues = path ? Object.values(path) : [];\n\t\tconst queryParamValues = query ? Object.values(query) : [];\n\t\tconst store = useMemo(() => hook.store({\n\t\t\tpath,\n\t\t\tquery\n\t\t}), [hook, ...[...pathParamValues, ...queryParamValues]]);\n\t\tif (typeof window === \"undefined\") return store.get();\n\t\treturn useStore(store);\n\t};\n}\nfunction createReactMutator(hook) {\n\treturn () => {\n\t\treturn useStore(useMemo(() => hook.mutatorStore, [hook]));\n\t};\n}\nfunction createReactStore(hook) {\n\tif (isReadableAtom(hook.obj)) return () => useStore(hook.obj);\n\treturn () => {\n\t\tconst result = {};\n\t\tfor (const key in hook.obj) {\n\t\t\tif (!Object.prototype.hasOwnProperty.call(hook.obj, key)) continue;\n\t\t\tconst value = hook.obj[key];\n\t\t\tif (isReadableAtom(value)) result[key] = useStore(value);\n\t\t\telse result[key] = value;\n\t\t}\n\t\treturn result;\n\t};\n}\nfunction useFragno(clientObj) {\n\tconst result = {};\n\tfor (const key in clientObj) {\n\t\tif (!Object.prototype.hasOwnProperty.call(clientObj, key)) continue;\n\t\tconst hook = clientObj[key];\n\t\tif (isGetHook(hook)) result[key] = createReactHook(hook);\n\t\telse if (isMutatorHook(hook)) result[key] = createReactMutator(hook);\n\t\telse if (isStore(hook)) result[key] = createReactStore(hook);\n\t\telse result[key] = hook;\n\t}\n\treturn result;\n}\nfunction useStore(store, options = {}) {\n\tconst snapshotRef = useRef(store.get());\n\tconst { keys, deps = [store, keys] } = options;\n\tconst subscribe = useCallback((onChange) => {\n\t\tconst emitChange = (value) => {\n\t\t\tif (snapshotRef.current === value) return;\n\t\t\tsnapshotRef.current = value;\n\t\t\tonChange();\n\t\t};\n\t\temitChange(store.value);\n\t\tif (keys?.length) return listenKeys(store, keys, emitChange);\n\t\treturn store.listen(emitChange);\n\t}, deps);\n\tconst get = () => snapshotRef.current;\n\treturn useSyncExternalStore(subscribe, get, () => {\n\t\treturn get();\n\t});\n}\nfunction FragnoHydrator({ children }) {\n\tuseMemo(() => {\n\t\thydrateFromWindow();\n\t}, []);\n\treturn children;\n}\n\n//#endregion\nexport { FragnoHydrator, useFragno, useStore };\n//# sourceMappingURL=react.js.map","import { useFragno } from \"@fragno-dev/core/react\";\nimport { createStripeFragmentClients } from \"..\";\nimport type { FragnoPublicClientConfig } from \"@fragno-dev/core/client\";\n\nexport function createStripeFragmentClient(config: FragnoPublicClientConfig = {}) {\n return useFragno(createStripeFragmentClients(config));\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;AAAA,SAAgBA,WAAWC,QAAQC,MAAMC,UAAU;CACjD,IAAIC,UAAU,IAAIC,IAAIH,MAAMI,WAAc;AAC1C,QAAOL,OAAOO,OAAO,CAACC,OAAOC,UAAUC,YAAY;AACjD,MAAIP,QAAQQ,IAAID,QAAQ,CACtBR,UAASM,OAAOC,UAAUC,QAAQ;CAErC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K;WAC/CR,cAAcQ,KAAK,CAAEe,QAAOC,OAAOL,mBAAmBX,KAAK;WAC3DP,QAAQO,KAAK,CAAEe,QAAOC,OAAOH,iBAAiBb,KAAK;MACvDe,QAAOC,OAAOhB;CACpB;AACA,QAAOe;AACR;AACA,SAASL,SAASH,OAAOgB,UAAU,CAAE,GAAE;CACtC,MAAMC,cAAc3B,OAAOU,MAAME,KAAK,CAAC;CACvC,MAAM,EAAEgB,MAAMC,OAAO,CAACnB,OAAOkB,IAAI,GAAG,GAAGF;CACvC,MAAMI,YAAYhC,YAAaiC,cAAa;EAC3C,MAAMC,aAAcT,WAAU;AAC7B,OAAII,YAAYM,YAAYV,MAAO;AACnCI,eAAYM,UAAUV;AACtBQ,aAAU;EACV;AACDC,aAAWtB,MAAMa,MAAM;AACvB,MAAIK,MAAMM,OAAQ,QAAOrC,WAAWa,OAAOkB,MAAMI,WAAW;AAC5D,SAAOtB,MAAMyB,OAAOH,WAAW;CAC/B,GAAEH,KAAK;CACR,MAAMjB,MAAMA,MAAMe,YAAYM;AAC9B,QAAOhC,qBAAqB6B,WAAWlB,KAAK,MAAM;AACjD,SAAOA,KAAK;CACZ,EAAC;AACH;;;;AC9DA,SAAgB6B,2BAA2BC,SAAmC,CAAE,GAAE;AAChF,QAAOJ,UAAUC,4BAA4BG,OAAO,CAAC;AACvD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as zod819 from "zod";
|
|
2
2
|
import * as zod_v4_core63 from "zod/v4/core";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _fragno_dev_core_api9 from "@fragno-dev/core/api";
|
|
4
4
|
import { FragnoPublicClientConfig } from "@fragno-dev/core/client";
|
|
5
5
|
import * as _fragno_dev_core_solid0 from "@fragno-dev/core/solid";
|
|
6
6
|
|
|
@@ -123,13 +123,13 @@ declare function createStripeFragmentClient(config?: FragnoPublicClientConfig):
|
|
|
123
123
|
updatedAt: zod819.ZodDate;
|
|
124
124
|
}, zod_v4_core63.$strip>>;
|
|
125
125
|
}, zod_v4_core63.$strip>, string, string>;
|
|
126
|
-
useBillingPortal: _fragno_dev_core_solid0.FragnoSolidMutator<
|
|
126
|
+
useBillingPortal: _fragno_dev_core_solid0.FragnoSolidMutator<_fragno_dev_core_api9.NonGetHTTPMethod, "/portal", zod819.ZodObject<{
|
|
127
127
|
returnUrl: zod819.ZodURL;
|
|
128
128
|
}, zod_v4_core63.$strip> | undefined, zod819.ZodObject<{
|
|
129
129
|
url: zod819.ZodURL;
|
|
130
130
|
redirect: zod819.ZodBoolean;
|
|
131
131
|
}, zod_v4_core63.$strip> | undefined, "NO_STRIPE_CUSTOMER_FOR_ENTITY", string>;
|
|
132
|
-
upgradeSubscription: _fragno_dev_core_solid0.FragnoSolidMutator<
|
|
132
|
+
upgradeSubscription: _fragno_dev_core_solid0.FragnoSolidMutator<_fragno_dev_core_api9.NonGetHTTPMethod, "/subscription/upgrade", zod819.ZodObject<{
|
|
133
133
|
priceId: zod819.ZodString;
|
|
134
134
|
quantity: zod819.ZodNumber;
|
|
135
135
|
successUrl: zod819.ZodURL;
|
|
@@ -142,7 +142,7 @@ declare function createStripeFragmentClient(config?: FragnoPublicClientConfig):
|
|
|
142
142
|
redirect: zod819.ZodBoolean;
|
|
143
143
|
sessionId: zod819.ZodOptional<zod819.ZodString>;
|
|
144
144
|
}, zod_v4_core63.$strip> | undefined, "MISSING_CUSTOMER_INFO" | "SUBSCRIPTION_NOT_FOUND" | "CUSTOMER_SUBSCRIPTION_MISMATCH" | "UPGRADE_HAS_NO_EFFECT" | "SUBSCRIPTION_UPDATE_NOT_ALLOWED" | "SUBSCRIPTION_UPDATE_PROMO_CODE_NOT_ALLOWED" | "PROMOTION_CODE_CUSTOMER_NOT_FIRST_TIME" | "MULTIPLE_ACTIVE_SUBSCRIPTIONS" | "NO_ACTIVE_SUBSCRIPTIONS", string>;
|
|
145
|
-
cancelSubscription: _fragno_dev_core_solid0.FragnoSolidMutator<
|
|
145
|
+
cancelSubscription: _fragno_dev_core_solid0.FragnoSolidMutator<_fragno_dev_core_api9.NonGetHTTPMethod, "/subscription/cancel", zod819.ZodObject<{
|
|
146
146
|
returnUrl: zod819.ZodURL;
|
|
147
147
|
subscriptionId: zod819.ZodOptional<zod819.ZodString>;
|
|
148
148
|
}, zod_v4_core63.$strip> | undefined, zod819.ZodObject<{
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { atom, createStripeFragmentClients, isGetHook, isMutatorHook, isReadableAtom, isStore } from "../src-
|
|
1
|
+
import { atom, createStripeFragmentClients, isGetHook, isMutatorHook, isReadableAtom, isStore } from "../src-D1l5aeYY.js";
|
|
2
2
|
import { createStore, reconcile } from "solid-js/store";
|
|
3
3
|
import { createEffect, onCleanup } from "solid-js";
|
|
4
4
|
|
|
5
|
-
//#region ../../node_modules/.pnpm/@nanostores+solid@1.1.1_nanostores@1.
|
|
5
|
+
//#region ../../node_modules/.pnpm/@nanostores+solid@1.1.1_nanostores@1.1.0_solid-js@1.9.10/node_modules/@nanostores/solid/dist/index.js
|
|
6
6
|
function m(e, o = {}) {
|
|
7
7
|
let t = e.listen(() => {}), [r, s] = createStore({ value: e.get() }), n = e.subscribe((i) => {
|
|
8
8
|
s("value", reconcile(i, o));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solid.js","names":["createStore","c","reconcile","u","onCleanup","S","m","e","o","t","listen","r","s","value","get","n","subscribe","i","useStore","isReadableAtom","isGetHook","isMutatorHook","isStore","atom","useStore","createEffect","isAccessor","value","accessorToAtom","accessor","a","set","createSolidHook","hook","path","query","pathParams","queryParams","key","Object","entries","v","storeValue","store","data","loading","error","createSolidMutator","mutatorStore","mutate","args","body","createSolidStore","obj","result","prototype","hasOwnProperty","call","useFragno","clientObj","useFragno","createStripeFragmentClients","FragnoPublicClientConfig","createStripeFragmentClient","config"],"sources":["../../../../../node_modules/.pnpm/@nanostores+solid@1.1.1_nanostores@1.
|
|
1
|
+
{"version":3,"file":"solid.js","names":["createStore","c","reconcile","u","onCleanup","S","m","e","o","t","listen","r","s","value","get","n","subscribe","i","useStore","isReadableAtom","isGetHook","isMutatorHook","isStore","atom","useStore","createEffect","isAccessor","value","accessorToAtom","accessor","a","set","createSolidHook","hook","path","query","pathParams","queryParams","key","Object","entries","v","storeValue","store","data","loading","error","createSolidMutator","mutatorStore","mutate","args","body","createSolidStore","obj","result","prototype","hasOwnProperty","call","useFragno","clientObj","useFragno","createStripeFragmentClients","FragnoPublicClientConfig","createStripeFragmentClient","config"],"sources":["../../../../../node_modules/.pnpm/@nanostores+solid@1.1.1_nanostores@1.1.0_solid-js@1.9.10/node_modules/@nanostores/solid/dist/index.js","../../../../fragno/dist/client/solid.js","../../../src/client/solid.ts"],"sourcesContent":["import{createStore as c,reconcile as u}from\"solid-js/store\";import{onCleanup as S}from\"solid-js\";function m(e,o={}){let t=e.listen(()=>{}),[r,s]=c({value:e.get()}),n=e.subscribe(i=>{s(\"value\",u(i,o))});return S(()=>n()),t(),()=>r.value}export{m as useStore};\n","import { isReadableAtom } from \"../util/nanostores.js\";\nimport { isGetHook, isMutatorHook, isStore } from \"./client.js\";\nimport { atom } from \"nanostores\";\nimport { useStore } from \"@nanostores/solid\";\nimport { createEffect } from \"solid-js\";\n\n//#region src/client/solid.ts\n/**\n* Type guard to check if a value is a SolidJS Accessor.\n*\n* @private\n*/\nfunction isAccessor(value) {\n\treturn typeof value === \"function\";\n}\n/**\n* Converts a SolidJS Accessor to a NanoStore Atom.\n*\n* This is used to convert SolidJS accessors to atoms, so that we can use them in the store.\n*\n* @private\n*/\nfunction accessorToAtom(accessor) {\n\tconst a = atom(accessor());\n\tcreateEffect(() => {\n\t\ta.set(accessor());\n\t});\n\treturn a;\n}\nfunction createSolidHook(hook) {\n\treturn ({ path, query } = {}) => {\n\t\tconst pathParams = {};\n\t\tconst queryParams = {};\n\t\tfor (const [key, value] of Object.entries(path ?? {})) {\n\t\t\tconst v = value;\n\t\t\tpathParams[key] = isAccessor(v) ? accessorToAtom(v) : v;\n\t\t}\n\t\tfor (const [key, value] of Object.entries(query ?? {})) {\n\t\t\tconst v = value;\n\t\t\tqueryParams[key] = isAccessor(v) ? accessorToAtom(v) : v;\n\t\t}\n\t\tconst storeValue = useStore(hook.store({\n\t\t\tpath: pathParams,\n\t\t\tquery: queryParams\n\t\t}));\n\t\treturn {\n\t\t\tdata: () => storeValue().data,\n\t\t\tloading: () => storeValue().loading,\n\t\t\terror: () => storeValue().error\n\t\t};\n\t};\n}\nfunction createSolidMutator(hook) {\n\treturn () => {\n\t\tconst store = useStore(hook.mutatorStore);\n\t\tconst mutate = async (args) => {\n\t\t\tconst { body, path, query } = args;\n\t\t\tconst pathParams = {};\n\t\t\tconst queryParams = {};\n\t\t\tfor (const [key, value] of Object.entries(path ?? {})) {\n\t\t\t\tconst v = value;\n\t\t\t\tpathParams[key] = isAccessor(v) ? v() : v;\n\t\t\t}\n\t\t\tfor (const [key, value] of Object.entries(query ?? {})) {\n\t\t\t\tconst v = value;\n\t\t\t\tqueryParams[key] = isAccessor(v) ? v() : v;\n\t\t\t}\n\t\t\treturn hook.mutatorStore.mutate({\n\t\t\t\tbody,\n\t\t\t\tpath: pathParams,\n\t\t\t\tquery: queryParams\n\t\t\t});\n\t\t};\n\t\treturn {\n\t\t\tmutate,\n\t\t\tdata: () => store().data,\n\t\t\tloading: () => store().loading,\n\t\t\terror: () => store().error\n\t\t};\n\t};\n}\nfunction createSolidStore(hook) {\n\tif (isReadableAtom(hook.obj)) return useStore(hook.obj);\n\tconst result = {};\n\tfor (const key in hook.obj) {\n\t\tif (!Object.prototype.hasOwnProperty.call(hook.obj, key)) continue;\n\t\tconst value = hook.obj[key];\n\t\tif (isReadableAtom(value)) result[key] = useStore(value);\n\t\telse result[key] = value;\n\t}\n\treturn () => result;\n}\nfunction useFragno(clientObj) {\n\tconst result = {};\n\tfor (const key in clientObj) {\n\t\tif (!Object.prototype.hasOwnProperty.call(clientObj, key)) continue;\n\t\tconst hook = clientObj[key];\n\t\tif (isGetHook(hook)) result[key] = createSolidHook(hook);\n\t\telse if (isMutatorHook(hook)) result[key] = createSolidMutator(hook);\n\t\telse if (isStore(hook)) result[key] = createSolidStore(hook);\n\t\telse result[key] = hook;\n\t}\n\treturn result;\n}\n\n//#endregion\nexport { accessorToAtom, isAccessor, useFragno };\n//# sourceMappingURL=solid.js.map","import { useFragno } from \"@fragno-dev/core/solid\";\nimport { createStripeFragmentClients } from \"..\";\nimport type { FragnoPublicClientConfig } from \"@fragno-dev/core/client\";\n\nexport function createStripeFragmentClient(config: FragnoPublicClientConfig = {}) {\n return useFragno(createStripeFragmentClients(config));\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;AAAiG,SAASM,EAAEC,GAAEC,IAAE,CAAE,GAAC;CAAC,IAAIC,IAAEF,EAAEG,OAAO,MAAI,CAAE,EAAC,EAAC,CAACC,GAAEC,EAAE,GAACX,YAAE,EAACY,OAAMN,EAAEO,KAAI,CAAE,EAAC,EAACC,IAAER,EAAES,UAAUC,OAAG;AAACL,IAAE,SAAQT,UAAEc,GAAET,EAAE,CAAC;CAAC,EAAC;AAAC,QAAOH,UAAE,MAAIU,GAAG,CAAC,EAACN,GAAG,EAAC,MAAIE,EAAEE;AAAK;;;;;;;;;ACY3O,SAASa,WAAWC,OAAO;AAC1B,eAAcA,UAAU;AACzB;;;;;;;;AAQA,SAASC,eAAeC,UAAU;CACjC,MAAMC,IAAIP,KAAKM,UAAU,CAAC;AAC1BJ,cAAa,MAAM;AAClBK,IAAEC,IAAIF,UAAU,CAAC;CACjB,EAAC;AACF,QAAOC;AACR;AACA,SAASE,gBAAgBC,MAAM;AAC9B,QAAO,CAAC,EAAEC,MAAMC,OAAO,GAAG,CAAE,MAAK;EAChC,MAAMC,aAAa,CAAE;EACrB,MAAMC,cAAc,CAAE;AACtB,OAAK,MAAM,CAACC,KAAKX,MAAM,IAAIY,OAAOC,QAAQN,QAAQ,CAAE,EAAC,EAAE;GACtD,MAAMO,IAAId;AACVS,cAAWE,OAAOZ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,KAAKoB,IAAI,CAAE,QAAO7B,EAASS,KAAKoB,IAAI;CACvD,MAAMC,SAAS,CAAE;AACjB,MAAK,MAAMhB,OAAOL,KAAKoB,KAAK;AAC3B,OAAKd,OAAOgB,UAAUC,eAAeC,KAAKxB,KAAKoB,KAAKf,IAAI,CAAE;EAC1D,MAAMX,QAAQM,KAAKoB,IAAIf;AACvB,MAAInB,eAAeQ,MAAM,CAAE2B,QAAOhB,OAAOd,EAASG,MAAM;MACnD2B,QAAOhB,OAAOX;CACpB;AACA,QAAO,MAAM2B;AACd;AACA,SAASI,UAAUC,WAAW;CAC7B,MAAML,SAAS,CAAE;AACjB,MAAK,MAAMhB,OAAOqB,WAAW;AAC5B,OAAKpB,OAAOgB,UAAUC,eAAeC,KAAKE,WAAWrB,IAAI,CAAE;EAC3D,MAAML,OAAO0B,UAAUrB;AACvB,MAAIlB,UAAUa,KAAK,CAAEqB,QAAOhB,OAAON,gBAAgBC,KAAK;WAC/CZ,cAAcY,KAAK,CAAEqB,QAAOhB,OAAOS,mBAAmBd,KAAK;WAC3DX,QAAQW,KAAK,CAAEqB,QAAOhB,OAAOc,iBAAiBnB,KAAK;MACvDqB,QAAOhB,OAAOL;CACpB;AACA,QAAOqB;AACR;;;;ACnGA,SAAgBS,2BAA2BC,SAAmC,CAAE,GAAE;AAChF,QAAOJ,UAAUC,4BAA4BG,OAAO,CAAC;AACvD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as zod1019 from "zod";
|
|
2
2
|
import * as zod_v4_core78 from "zod/v4/core";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _fragno_dev_core_api12 from "@fragno-dev/core/api";
|
|
4
4
|
import { FragnoPublicClientConfig } from "@fragno-dev/core/client";
|
|
5
5
|
import * as _fragno_dev_core_svelte0 from "@fragno-dev/core/svelte";
|
|
6
6
|
|
|
@@ -123,13 +123,13 @@ declare function createStripeFragmentClient(config?: FragnoPublicClientConfig):
|
|
|
123
123
|
updatedAt: zod1019.ZodDate;
|
|
124
124
|
}, zod_v4_core78.$strip>>;
|
|
125
125
|
}, zod_v4_core78.$strip>, string, string>;
|
|
126
|
-
useBillingPortal: _fragno_dev_core_svelte0.FragnoSvelteMutator<
|
|
126
|
+
useBillingPortal: _fragno_dev_core_svelte0.FragnoSvelteMutator<_fragno_dev_core_api12.NonGetHTTPMethod, "/portal", zod1019.ZodObject<{
|
|
127
127
|
returnUrl: zod1019.ZodURL;
|
|
128
128
|
}, zod_v4_core78.$strip> | undefined, zod1019.ZodObject<{
|
|
129
129
|
url: zod1019.ZodURL;
|
|
130
130
|
redirect: zod1019.ZodBoolean;
|
|
131
131
|
}, zod_v4_core78.$strip> | undefined, "NO_STRIPE_CUSTOMER_FOR_ENTITY", string>;
|
|
132
|
-
upgradeSubscription: _fragno_dev_core_svelte0.FragnoSvelteMutator<
|
|
132
|
+
upgradeSubscription: _fragno_dev_core_svelte0.FragnoSvelteMutator<_fragno_dev_core_api12.NonGetHTTPMethod, "/subscription/upgrade", zod1019.ZodObject<{
|
|
133
133
|
priceId: zod1019.ZodString;
|
|
134
134
|
quantity: zod1019.ZodNumber;
|
|
135
135
|
successUrl: zod1019.ZodURL;
|
|
@@ -142,7 +142,7 @@ declare function createStripeFragmentClient(config?: FragnoPublicClientConfig):
|
|
|
142
142
|
redirect: zod1019.ZodBoolean;
|
|
143
143
|
sessionId: zod1019.ZodOptional<zod1019.ZodString>;
|
|
144
144
|
}, zod_v4_core78.$strip> | undefined, "MISSING_CUSTOMER_INFO" | "SUBSCRIPTION_NOT_FOUND" | "CUSTOMER_SUBSCRIPTION_MISMATCH" | "UPGRADE_HAS_NO_EFFECT" | "SUBSCRIPTION_UPDATE_NOT_ALLOWED" | "SUBSCRIPTION_UPDATE_PROMO_CODE_NOT_ALLOWED" | "PROMOTION_CODE_CUSTOMER_NOT_FIRST_TIME" | "MULTIPLE_ACTIVE_SUBSCRIPTIONS" | "NO_ACTIVE_SUBSCRIPTIONS", string>;
|
|
145
|
-
cancelSubscription: _fragno_dev_core_svelte0.FragnoSvelteMutator<
|
|
145
|
+
cancelSubscription: _fragno_dev_core_svelte0.FragnoSvelteMutator<_fragno_dev_core_api12.NonGetHTTPMethod, "/subscription/cancel", zod1019.ZodObject<{
|
|
146
146
|
returnUrl: zod1019.ZodURL;
|
|
147
147
|
subscriptionId: zod1019.ZodOptional<zod1019.ZodString>;
|
|
148
148
|
}, zod_v4_core78.$strip> | undefined, zod1019.ZodObject<{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { atom, createStripeFragmentClients, isGetHook, isMutatorHook, isStore } from "../src-
|
|
1
|
+
import { atom, createStripeFragmentClients, isGetHook, isMutatorHook, isStore } from "../src-D1l5aeYY.js";
|
|
2
2
|
import { get, writable } from "svelte/store";
|
|
3
3
|
import { onDestroy } from "svelte";
|
|
4
4
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as zod1219 from "zod";
|
|
2
2
|
import * as zod_v4_core93 from "zod/v4/core";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _fragno_dev_core_api15 from "@fragno-dev/core/api";
|
|
4
4
|
import { FragnoPublicClientConfig } from "@fragno-dev/core/client";
|
|
5
5
|
import * as _fragno_dev_core_vanilla0 from "@fragno-dev/core/vanilla";
|
|
6
6
|
|
|
@@ -123,13 +123,13 @@ declare function createStripeFragmentClient(config?: FragnoPublicClientConfig):
|
|
|
123
123
|
updatedAt: zod1219.ZodDate;
|
|
124
124
|
}, zod_v4_core93.$strip>>;
|
|
125
125
|
}, zod_v4_core93.$strip>, string, string>;
|
|
126
|
-
useBillingPortal: _fragno_dev_core_vanilla0.FragnoVanillaMutator<
|
|
126
|
+
useBillingPortal: _fragno_dev_core_vanilla0.FragnoVanillaMutator<_fragno_dev_core_api15.NonGetHTTPMethod, "/portal", zod1219.ZodObject<{
|
|
127
127
|
returnUrl: zod1219.ZodURL;
|
|
128
128
|
}, zod_v4_core93.$strip> | undefined, zod1219.ZodObject<{
|
|
129
129
|
url: zod1219.ZodURL;
|
|
130
130
|
redirect: zod1219.ZodBoolean;
|
|
131
131
|
}, zod_v4_core93.$strip> | undefined, "NO_STRIPE_CUSTOMER_FOR_ENTITY", string>;
|
|
132
|
-
upgradeSubscription: _fragno_dev_core_vanilla0.FragnoVanillaMutator<
|
|
132
|
+
upgradeSubscription: _fragno_dev_core_vanilla0.FragnoVanillaMutator<_fragno_dev_core_api15.NonGetHTTPMethod, "/subscription/upgrade", zod1219.ZodObject<{
|
|
133
133
|
priceId: zod1219.ZodString;
|
|
134
134
|
quantity: zod1219.ZodNumber;
|
|
135
135
|
successUrl: zod1219.ZodURL;
|
|
@@ -142,7 +142,7 @@ declare function createStripeFragmentClient(config?: FragnoPublicClientConfig):
|
|
|
142
142
|
redirect: zod1219.ZodBoolean;
|
|
143
143
|
sessionId: zod1219.ZodOptional<zod1219.ZodString>;
|
|
144
144
|
}, zod_v4_core93.$strip> | undefined, "MISSING_CUSTOMER_INFO" | "SUBSCRIPTION_NOT_FOUND" | "CUSTOMER_SUBSCRIPTION_MISMATCH" | "UPGRADE_HAS_NO_EFFECT" | "SUBSCRIPTION_UPDATE_NOT_ALLOWED" | "SUBSCRIPTION_UPDATE_PROMO_CODE_NOT_ALLOWED" | "PROMOTION_CODE_CUSTOMER_NOT_FIRST_TIME" | "MULTIPLE_ACTIVE_SUBSCRIPTIONS" | "NO_ACTIVE_SUBSCRIPTIONS", string>;
|
|
145
|
-
cancelSubscription: _fragno_dev_core_vanilla0.FragnoVanillaMutator<
|
|
145
|
+
cancelSubscription: _fragno_dev_core_vanilla0.FragnoVanillaMutator<_fragno_dev_core_api15.NonGetHTTPMethod, "/subscription/cancel", zod1219.ZodObject<{
|
|
146
146
|
returnUrl: zod1219.ZodURL;
|
|
147
147
|
subscriptionId: zod1219.ZodOptional<zod1219.ZodString>;
|
|
148
148
|
}, zod_v4_core93.$strip> | undefined, zod1219.ZodObject<{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { atom, createStripeFragmentClients, isGetHook, isMutatorHook } from "../src-
|
|
1
|
+
import { atom, createStripeFragmentClients, isGetHook, isMutatorHook, isReadableAtom, isStore } from "../src-D1l5aeYY.js";
|
|
2
2
|
import { computed, getCurrentScope, isRef, onScopeDispose, ref, shallowRef, watch } from "vue";
|
|
3
3
|
|
|
4
4
|
//#region ../fragno/dist/client/vue.js
|
|
@@ -79,6 +79,19 @@ function createVueMutator(hook) {
|
|
|
79
79
|
};
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
+
function createVueStore(hook) {
|
|
83
|
+
if (isReadableAtom(hook.obj)) return () => useStore(hook.obj).value;
|
|
84
|
+
return () => {
|
|
85
|
+
const result = {};
|
|
86
|
+
for (const key in hook.obj) {
|
|
87
|
+
if (!Object.prototype.hasOwnProperty.call(hook.obj, key)) continue;
|
|
88
|
+
const value = hook.obj[key];
|
|
89
|
+
if (isReadableAtom(value)) result[key] = useStore(value).value;
|
|
90
|
+
else result[key] = value;
|
|
91
|
+
}
|
|
92
|
+
return result;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
82
95
|
function useFragno(clientObj) {
|
|
83
96
|
const result = {};
|
|
84
97
|
for (const key in clientObj) {
|
|
@@ -86,6 +99,7 @@ function useFragno(clientObj) {
|
|
|
86
99
|
const hook = clientObj[key];
|
|
87
100
|
if (isGetHook(hook)) result[key] = createVueHook(hook);
|
|
88
101
|
else if (isMutatorHook(hook)) result[key] = createVueMutator(hook);
|
|
102
|
+
else if (isStore(hook)) result[key] = createVueStore(hook);
|
|
89
103
|
else result[key] = hook;
|
|
90
104
|
}
|
|
91
105
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vue.js","names":["isGetHook","isMutatorHook","atom","computed","computed$1","getCurrentScope","isRef","onScopeDispose","ref","shallowRef","watch","refToAtom","ref$1","a","value","newVal","set","createVueHook","hook","path","query","pathParams","queryParams","key","Object","entries","v","store","data","loading","error","unsubscribe","subscribe","updatedStoreValue","createVueMutator","useStore","mutatorStore","mutate","args","body","
|
|
1
|
+
{"version":3,"file":"vue.js","names":["isReadableAtom","isGetHook","isMutatorHook","isStore","atom","computed","computed$1","getCurrentScope","isRef","onScopeDispose","ref","shallowRef","watch","refToAtom","ref$1","a","value","newVal","set","createVueHook","hook","path","query","pathParams","queryParams","key","Object","entries","v","store","data","loading","error","unsubscribe","subscribe","updatedStoreValue","createVueMutator","useStore","mutatorStore","mutate","args","body","createVueStore","obj","result","prototype","hasOwnProperty","call","useFragno","clientObj","state","useFragno","createStripeFragmentClients","FragnoPublicClientConfig","createStripeFragmentClient","config"],"sources":["../../../../fragno/dist/client/vue.js","../../../src/client/vue.ts"],"sourcesContent":["import { isReadableAtom } from \"../util/nanostores.js\";\nimport { isGetHook, isMutatorHook, isStore } from \"./client.js\";\nimport { atom } from \"nanostores\";\nimport { computed as computed$1, getCurrentScope, isRef, onScopeDispose, ref, shallowRef, watch } from \"vue\";\n\n//#region src/client/vue.ts\n/**\n* Converts a Vue Ref to a NanoStore Atom.\n*\n* This is used to convert Vue refs to atoms, so that we can use them in the store.\n*\n* @private\n*/\nfunction refToAtom(ref$1) {\n\tconst a = atom(ref$1.value);\n\twatch(ref$1, (newVal) => {\n\t\ta.set(newVal);\n\t});\n\treturn a;\n}\nfunction createVueHook(hook) {\n\treturn ({ path, query } = {}) => {\n\t\tconst pathParams = {};\n\t\tconst queryParams = {};\n\t\tfor (const [key, value] of Object.entries(path ?? {})) {\n\t\t\tconst v = value;\n\t\t\tpathParams[key] = isRef(v) ? refToAtom(v) : v;\n\t\t}\n\t\tfor (const [key, value] of Object.entries(query ?? {})) {\n\t\t\tconst v = value;\n\t\t\tqueryParams[key] = isRef(v) ? refToAtom(v) : v;\n\t\t}\n\t\tconst store = hook.store({\n\t\t\tpath: pathParams,\n\t\t\tquery: queryParams\n\t\t});\n\t\tconst data = ref();\n\t\tconst loading = ref();\n\t\tconst error = ref();\n\t\tconst unsubscribe = store.subscribe((updatedStoreValue) => {\n\t\t\tdata.value = updatedStoreValue.data;\n\t\t\tloading.value = updatedStoreValue.loading;\n\t\t\terror.value = updatedStoreValue.error;\n\t\t});\n\t\tif (getCurrentScope()) onScopeDispose(() => {\n\t\t\tunsubscribe();\n\t\t});\n\t\treturn {\n\t\t\tdata,\n\t\t\tloading,\n\t\t\terror\n\t\t};\n\t};\n}\nfunction createVueMutator(hook) {\n\treturn () => {\n\t\tconst store = useStore(hook.mutatorStore);\n\t\tconst mutate = async (args) => {\n\t\t\tconst { body, path, query } = args;\n\t\t\tconst pathParams = {};\n\t\t\tconst queryParams = {};\n\t\t\tfor (const [key, value] of Object.entries(path ?? {})) {\n\t\t\t\tconst v = value;\n\t\t\t\tpathParams[key] = isRef(v) ? v.value : v;\n\t\t\t}\n\t\t\tfor (const [key, value] of Object.entries(query ?? {})) {\n\t\t\t\tconst v = value;\n\t\t\t\tqueryParams[key] = isRef(v) ? v.value : v;\n\t\t\t}\n\t\t\treturn store.value.mutate({\n\t\t\t\tbody,\n\t\t\t\tpath: pathParams,\n\t\t\t\tquery: queryParams\n\t\t\t});\n\t\t};\n\t\treturn {\n\t\t\tmutate,\n\t\t\tloading: computed$1(() => store.value.loading),\n\t\t\terror: computed$1(() => store.value.error),\n\t\t\tdata: computed$1(() => store.value.data)\n\t\t};\n\t};\n}\nfunction createVueStore(hook) {\n\tif (isReadableAtom(hook.obj)) return (() => useStore(hook.obj).value);\n\treturn (() => {\n\t\tconst result = {};\n\t\tfor (const key in hook.obj) {\n\t\t\tif (!Object.prototype.hasOwnProperty.call(hook.obj, key)) continue;\n\t\t\tconst value = hook.obj[key];\n\t\t\tif (isReadableAtom(value)) result[key] = useStore(value).value;\n\t\t\telse result[key] = value;\n\t\t}\n\t\treturn result;\n\t});\n}\nfunction useFragno(clientObj) {\n\tconst result = {};\n\tfor (const key in clientObj) {\n\t\tif (!Object.prototype.hasOwnProperty.call(clientObj, key)) continue;\n\t\tconst hook = clientObj[key];\n\t\tif (isGetHook(hook)) result[key] = createVueHook(hook);\n\t\telse if (isMutatorHook(hook)) result[key] = createVueMutator(hook);\n\t\telse if (isStore(hook)) result[key] = createVueStore(hook);\n\t\telse result[key] = hook;\n\t}\n\treturn result;\n}\nfunction useStore(store) {\n\tconst state = shallowRef();\n\tconst unsubscribe = store.subscribe((value) => {\n\t\tstate.value = value;\n\t});\n\tif (getCurrentScope()) onScopeDispose(unsubscribe);\n\treturn state;\n}\n\n//#endregion\nexport { refToAtom, useFragno, useStore };\n//# sourceMappingURL=vue.js.map","import { useFragno } from \"@fragno-dev/core/vue\";\nimport { createStripeFragmentClients } from \"..\";\nimport type { FragnoPublicClientConfig } from \"@fragno-dev/core/client\";\n\nexport function createStripeFragmentClient(config: FragnoPublicClientConfig = {}) {\n return useFragno(createStripeFragmentClients(config));\n}\n"],"mappings":";;;;;;;;;;;AAaA,SAASa,UAAUC,OAAO;CACzB,MAAMC,IAAIX,KAAKU,MAAME,MAAM;AAC3BJ,OAAME,OAAQG,YAAW;AACxBF,IAAEG,IAAID,OAAO;CACb,EAAC;AACF,QAAOF;AACR;AACA,SAASI,cAAcC,MAAM;AAC5B,QAAO,CAAC,EAAEC,MAAMC,OAAO,GAAG,CAAE,MAAK;EAChC,MAAMC,aAAa,CAAE;EACrB,MAAMC,cAAc,CAAE;AACtB,OAAK,MAAM,CAACC,KAAKT,MAAM,IAAIU,OAAOC,QAAQN,QAAQ,CAAE,EAAC,EAAE;GACtD,MAAMO,IAAIZ;AACVO,cAAWE,OAAOjB,MAAMoB,EAAE,GAAGf,UAAUe,EAAE,GAAGA;EAC7C;AACA,OAAK,MAAM,CAACH,KAAKT,MAAM,IAAIU,OAAOC,QAAQL,SAAS,CAAE,EAAC,EAAE;GACvD,MAAMM,IAAIZ;AACVQ,eAAYC,OAAOjB,MAAMoB,EAAE,GAAGf,UAAUe,EAAE,GAAGA;EAC9C;EACA,MAAMC,QAAQT,KAAKS,MAAM;GACxBR,MAAME;GACND,OAAOE;EACP,EAAC;EACF,MAAMM,OAAOpB,KAAK;EAClB,MAAMqB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