@superwall/paywalls-react 0.1.1 → 0.1.3
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/.turbo/turbo-test.log +45 -27
- package/README.md +79 -0
- package/package.json +3 -3
package/.turbo/turbo-test.log
CHANGED
|
@@ -2,10 +2,11 @@ $ bun test
|
|
|
2
2
|
bun test v1.3.11 (af24e281)
|
|
3
3
|
|
|
4
4
|
src/index.test.ts:
|
|
5
|
-
(pass) re-exports SDK_VERSION from @superwall/paywalls-js [0.
|
|
5
|
+
(pass) re-exports SDK_VERSION from @superwall/paywalls-js [0.96ms]
|
|
6
6
|
|
|
7
7
|
src/hooks.test.tsx:
|
|
8
|
-
|
|
8
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
9
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
9
10
|
244 | }, !keepOpen)
|
|
10
11
|
245 | handleResponse();
|
|
11
12
|
246 | onEnd();
|
|
@@ -30,6 +31,9 @@ NetworkError: Failed to execute "fetch()" on "Window" with URL "https://paywalls
|
|
|
30
31
|
at emitError (node:events:43:23)
|
|
31
32
|
at <anonymous> (node:_http_client:253:22)
|
|
32
33
|
|
|
34
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
35
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
36
|
+
(pass) useSignal returns the current value and re-renders on change [217.28ms]
|
|
33
37
|
error: Was there a typo in the url or port?
|
|
34
38
|
path: "https://paywalls.test/pw_default?platform=web&transport=web&debug=false",
|
|
35
39
|
errno: 0,
|
|
@@ -48,8 +52,11 @@ NetworkError: Failed to execute "fetch()" on "Window" with URL "https://paywalls
|
|
|
48
52
|
at emitError (node:events:43:23)
|
|
49
53
|
at <anonymous> (node:_http_client:253:22)
|
|
50
54
|
|
|
51
|
-
[Superwall:transactions] entitlements GET failed entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
52
|
-
|
|
55
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
56
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
57
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
58
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
59
|
+
(pass) useUser exposes id/aliasId/effectiveId/isLoggedIn and updates on identify/signOut [66.09ms]
|
|
53
60
|
244 | }, !keepOpen)
|
|
54
61
|
245 | handleResponse();
|
|
55
62
|
246 | onEnd();
|
|
@@ -74,8 +81,9 @@ NetworkError: Failed to execute "fetch()" on "Window" with URL "https://paywalls
|
|
|
74
81
|
at emitError (node:events:43:23)
|
|
75
82
|
at <anonymous> (node:_http_client:253:22)
|
|
76
83
|
|
|
77
|
-
[Superwall:transactions] entitlements GET failed entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
78
|
-
|
|
84
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
85
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
86
|
+
(pass) useUser.subscriptionStatus + entitlements update after setSubscriptionStatus [71.45ms]
|
|
79
87
|
error: Was there a typo in the url or port?
|
|
80
88
|
path: "https://paywalls.test/pw_default?platform=web&transport=web&debug=false",
|
|
81
89
|
errno: 0,
|
|
@@ -94,8 +102,9 @@ NetworkError: Failed to execute "fetch()" on "Window" with URL "https://paywalls
|
|
|
94
102
|
at emitError (node:events:43:23)
|
|
95
103
|
at <anonymous> (node:_http_client:253:22)
|
|
96
104
|
|
|
97
|
-
[Superwall:transactions] entitlements GET failed entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
98
|
-
|
|
105
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
106
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
107
|
+
(pass) usePlacement reflects presented + dismissed state and routes handler callbacks [68.23ms]
|
|
99
108
|
244 | }, !keepOpen)
|
|
100
109
|
245 | handleResponse();
|
|
101
110
|
246 | onEnd();
|
|
@@ -120,8 +129,9 @@ NetworkError: Failed to execute "fetch()" on "Window" with URL "https://paywalls
|
|
|
120
129
|
at emitError (node:events:43:23)
|
|
121
130
|
at <anonymous> (node:_http_client:253:22)
|
|
122
131
|
|
|
123
|
-
[Superwall:transactions] entitlements GET failed entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
124
|
-
|
|
132
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
133
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
134
|
+
(pass) usePlacement: ACTIVE subscription → register returns skipped(userSubscribed) [43.31ms]
|
|
125
135
|
error: Was there a typo in the url or port?
|
|
126
136
|
path: "https://paywalls.test/pw_default?platform=web&transport=web&debug=false",
|
|
127
137
|
errno: 0,
|
|
@@ -140,8 +150,9 @@ NetworkError: Failed to execute "fetch()" on "Window" with URL "https://paywalls
|
|
|
140
150
|
at emitError (node:events:43:23)
|
|
141
151
|
at <anonymous> (node:_http_client:253:22)
|
|
142
152
|
|
|
143
|
-
[Superwall:transactions] entitlements GET failed entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
144
|
-
|
|
153
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
154
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
155
|
+
(pass) useSuperwallEvent attaches a typed listener and auto-detaches on unmount [37.92ms]
|
|
145
156
|
244 | }, !keepOpen)
|
|
146
157
|
245 | handleResponse();
|
|
147
158
|
246 | onEnd();
|
|
@@ -166,8 +177,9 @@ NetworkError: Failed to execute "fetch()" on "Window" with URL "https://paywalls
|
|
|
166
177
|
at emitError (node:events:43:23)
|
|
167
178
|
at <anonymous> (node:_http_client:253:22)
|
|
168
179
|
|
|
169
|
-
[Superwall:transactions] entitlements GET failed entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
170
|
-
|
|
180
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
181
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
182
|
+
(pass) useDelegate installs a delegate for the lifetime of the component [41.24ms]
|
|
171
183
|
error: Was there a typo in the url or port?
|
|
172
184
|
path: "https://paywalls.test/pw_default?platform=web&transport=web&debug=false",
|
|
173
185
|
errno: 0,
|
|
@@ -186,8 +198,9 @@ NetworkError: Failed to execute "fetch()" on "Window" with URL "https://paywalls
|
|
|
186
198
|
at emitError (node:events:43:23)
|
|
187
199
|
at <anonymous> (node:_http_client:253:22)
|
|
188
200
|
|
|
189
|
-
[Superwall:transactions] entitlements GET failed entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
190
|
-
|
|
201
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
202
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
203
|
+
(pass) useSignal: unstable signal identity per render doesn't trigger infinite re-render [38.58ms]
|
|
191
204
|
244 | }, !keepOpen)
|
|
192
205
|
245 | handleResponse();
|
|
193
206
|
246 | onEnd();
|
|
@@ -212,20 +225,25 @@ NetworkError: Failed to execute "fetch()" on "Window" with URL "https://paywalls
|
|
|
212
225
|
at emitError (node:events:43:23)
|
|
213
226
|
at <anonymous> (node:_http_client:253:22)
|
|
214
227
|
|
|
215
|
-
[Superwall:transactions] entitlements GET failed entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
216
|
-
|
|
228
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
229
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
230
|
+
(pass) useDelegate: unmounting one of two stacked hooks leaves the other installed [43.98ms]
|
|
217
231
|
|
|
218
232
|
src/provider.test.tsx:
|
|
219
|
-
[Superwall:transactions] entitlements GET failed entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
220
|
-
|
|
221
|
-
(pass)
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
[Superwall:transactions] entitlements GET failed entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
225
|
-
|
|
226
|
-
|
|
233
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
234
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
235
|
+
(pass) SuperwallProvider provides a Superwall instance via context [22.84ms]
|
|
236
|
+
(pass) useSuperwall outside <SuperwallProvider> throws a clear error [16.59ms]
|
|
237
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
238
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
239
|
+
(pass) registry reuses the instance across re-mounts with the same apiKey (HMR) [34.67ms]
|
|
240
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
241
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
242
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
243
|
+
[Superwall:transactions] entitlements GET failed NetworkDecodingError: entitlements JSON decode failed: JSON Parse error: Unexpected EOF
|
|
244
|
+
(pass) different apiKeys produce different instances [23.18ms]
|
|
227
245
|
|
|
228
246
|
14 pass
|
|
229
247
|
0 fail
|
|
230
248
|
40 expect() calls
|
|
231
|
-
Ran 14 tests across 3 files. [
|
|
249
|
+
Ran 14 tests across 3 files. [972.00ms]
|
package/README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# @superwall/paywalls-react
|
|
2
|
+
|
|
3
|
+
React 19 bindings for the Superwall web SDK — a provider + hooks over
|
|
4
|
+
[`@superwall/paywalls-js`](https://www.npmjs.com/package/@superwall/paywalls-js).
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
bun add @superwall/paywalls-react # or npm / pnpm / yarn
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Quick start
|
|
11
|
+
|
|
12
|
+
Wrap your app once:
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import { SuperwallProvider } from "@superwall/paywalls-react";
|
|
16
|
+
|
|
17
|
+
export function Root() {
|
|
18
|
+
return (
|
|
19
|
+
<SuperwallProvider apiKey="pk_your_public_key">
|
|
20
|
+
<App />
|
|
21
|
+
</SuperwallProvider>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`SuperwallProvider` takes the same config as `createSuperwall`
|
|
27
|
+
(`apiKey`, `storage`, `delegate`, `identity`, `options`).
|
|
28
|
+
|
|
29
|
+
## Placements
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { usePlacement } from "@superwall/paywalls-react";
|
|
33
|
+
|
|
34
|
+
function GoPro() {
|
|
35
|
+
const { register, state } = usePlacement({
|
|
36
|
+
onPresent: (info) => {},
|
|
37
|
+
onDismiss: (info, result) => {},
|
|
38
|
+
onSkip: (reason) => {},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<button onClick={() => register({ placement: "campaign_trigger" })}>
|
|
43
|
+
Go Pro {state.type === "presented" && "(open)"}
|
|
44
|
+
</button>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Subscription status & user
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
import { useUser } from "@superwall/paywalls-react";
|
|
53
|
+
|
|
54
|
+
function Status() {
|
|
55
|
+
const { id, isLoggedIn, subscriptionStatus, entitlements, identify, signOut } =
|
|
56
|
+
useUser();
|
|
57
|
+
|
|
58
|
+
if (subscriptionStatus.status === "ACTIVE") return <Pro />;
|
|
59
|
+
return <button onClick={() => identify("app_user_123")}>Log in</button>;
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Hooks
|
|
64
|
+
|
|
65
|
+
| Hook | What it gives you |
|
|
66
|
+
|------|-------------------|
|
|
67
|
+
| `useSuperwall()` | the raw `Superwall` instance |
|
|
68
|
+
| `usePlacement(handler?)` | `{ register, state }` |
|
|
69
|
+
| `useUser()` | reactive identity + subscription + `identify`/`signOut`/`setAttributes` |
|
|
70
|
+
| `useSignal(signal)` | subscribe to any SDK `Readable<T>` |
|
|
71
|
+
| `useSuperwallEvent(name, fn)` | typed event listener, auto-cleanup |
|
|
72
|
+
| `useDelegate(delegate)` | install [delegate callbacks](https://www.npmjs.com/package/@superwall/paywalls-js#delegate-methods) for the component's lifetime |
|
|
73
|
+
|
|
74
|
+
All of `@superwall/paywalls-js` is re-exported, so you don't need to depend on
|
|
75
|
+
both packages directly.
|
|
76
|
+
|
|
77
|
+
## License
|
|
78
|
+
|
|
79
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superwall/paywalls-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"exports": {
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"react": "^19.0.0",
|
|
20
|
-
"@superwall/paywalls-js": "0.
|
|
20
|
+
"@superwall/paywalls-js": "^0.1.3"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@superwall/paywalls-js": "0.
|
|
23
|
+
"@superwall/paywalls-js": "^0.1.3"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@happy-dom/global-registrator": "^20.0.0",
|