@superwall/paywalls-react 0.1.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.
@@ -0,0 +1,2 @@
1
+ $ echo 'no-op for v0; consumers import .ts directly via Bun/Vite/Next ESM'
2
+ no-op for v0; consumers import .ts directly via Bun/Vite/Next ESM
@@ -0,0 +1,231 @@
1
+ $ bun test
2
+ bun test v1.3.11 (af24e281)
3
+
4
+ src/index.test.ts:
5
+ (pass) re-exports SDK_VERSION from @superwall/paywalls-js [0.86ms]
6
+
7
+ src/hooks.test.tsx:
8
+ (pass) useSignal returns the current value and re-renders on change [87.55ms]
9
+ 244 | }, !keepOpen)
10
+ 245 | handleResponse();
11
+ 246 | onEnd();
12
+ 247 | }), !softFail)
13
+ 248 | this[kFetchRequest].catch((err) => {
14
+ 249 | err = Error("ECONNREFUSED"), err.code = "ECONNREFUSED";
15
+ ^
16
+ error: ECONNREFUSED
17
+ code: "ECONNREFUSED"
18
+
19
+ at <anonymous> (node:_http_client:249:24)
20
+
21
+ 535 | * @param error Error.
22
+ 536 | */
23
+ 537 | onError(error) {
24
+ 538 | this.finalizeRequest();
25
+ 539 | this.#browserFrame.page.console.error(error);
26
+ 540 | this.reject(new this.#window.DOMException(`Failed to execute "fetch()" on "Window" with URL "${this.request.url}": ${error.message}`, DOMExceptionNameEnum.networkError));
27
+ ^
28
+ NetworkError: Failed to execute "fetch()" on "Window" with URL "https://paywalls.test/pw_default?platform=web&transport=web&debug=false": ECONNREFUSED
29
+ at onError (/Users/ianrumac/Workspace/Superwall/Superwall-Web/node_modules/.bun/happy-dom@20.9.0/node_modules/happy-dom/lib/fetch/Fetch.js:540:21)
30
+ at emitError (node:events:43:23)
31
+ at <anonymous> (node:_http_client:253:22)
32
+
33
+ error: Was there a typo in the url or port?
34
+ path: "https://paywalls.test/pw_default?platform=web&transport=web&debug=false",
35
+ errno: 0,
36
+ code: "FailedToOpenSocket"
37
+
38
+
39
+ 535 | * @param error Error.
40
+ 536 | */
41
+ 537 | onError(error) {
42
+ 538 | this.finalizeRequest();
43
+ 539 | this.#browserFrame.page.console.error(error);
44
+ 540 | this.reject(new this.#window.DOMException(`Failed to execute "fetch()" on "Window" with URL "${this.request.url}": ${error.message}`, DOMExceptionNameEnum.networkError));
45
+ ^
46
+ NetworkError: Failed to execute "fetch()" on "Window" with URL "https://paywalls.test/pw_default?platform=web&transport=web&debug=false": Was there a typo in the url or port?
47
+ at onError (/Users/ianrumac/Workspace/Superwall/Superwall-Web/node_modules/.bun/happy-dom@20.9.0/node_modules/happy-dom/lib/fetch/Fetch.js:540:21)
48
+ at emitError (node:events:43:23)
49
+ at <anonymous> (node:_http_client:253:22)
50
+
51
+ [Superwall:transactions] entitlements GET failed entitlements JSON decode failed: JSON Parse error: Unexpected EOF
52
+ (pass) useUser exposes id/aliasId/effectiveId/isLoggedIn and updates on identify/signOut [40.45ms]
53
+ 244 | }, !keepOpen)
54
+ 245 | handleResponse();
55
+ 246 | onEnd();
56
+ 247 | }), !softFail)
57
+ 248 | this[kFetchRequest].catch((err) => {
58
+ 249 | err = Error("ECONNREFUSED"), err.code = "ECONNREFUSED";
59
+ ^
60
+ error: ECONNREFUSED
61
+ code: "ECONNREFUSED"
62
+
63
+ at <anonymous> (node:_http_client:249:24)
64
+
65
+ 535 | * @param error Error.
66
+ 536 | */
67
+ 537 | onError(error) {
68
+ 538 | this.finalizeRequest();
69
+ 539 | this.#browserFrame.page.console.error(error);
70
+ 540 | this.reject(new this.#window.DOMException(`Failed to execute "fetch()" on "Window" with URL "${this.request.url}": ${error.message}`, DOMExceptionNameEnum.networkError));
71
+ ^
72
+ NetworkError: Failed to execute "fetch()" on "Window" with URL "https://paywalls.test/pw_default?platform=web&transport=web&debug=false": ECONNREFUSED
73
+ at onError (/Users/ianrumac/Workspace/Superwall/Superwall-Web/node_modules/.bun/happy-dom@20.9.0/node_modules/happy-dom/lib/fetch/Fetch.js:540:21)
74
+ at emitError (node:events:43:23)
75
+ at <anonymous> (node:_http_client:253:22)
76
+
77
+ [Superwall:transactions] entitlements GET failed entitlements JSON decode failed: JSON Parse error: Unexpected EOF
78
+ (pass) useUser.subscriptionStatus + entitlements update after setSubscriptionStatus [19.96ms]
79
+ error: Was there a typo in the url or port?
80
+ path: "https://paywalls.test/pw_default?platform=web&transport=web&debug=false",
81
+ errno: 0,
82
+ code: "FailedToOpenSocket"
83
+
84
+
85
+ 535 | * @param error Error.
86
+ 536 | */
87
+ 537 | onError(error) {
88
+ 538 | this.finalizeRequest();
89
+ 539 | this.#browserFrame.page.console.error(error);
90
+ 540 | this.reject(new this.#window.DOMException(`Failed to execute "fetch()" on "Window" with URL "${this.request.url}": ${error.message}`, DOMExceptionNameEnum.networkError));
91
+ ^
92
+ NetworkError: Failed to execute "fetch()" on "Window" with URL "https://paywalls.test/pw_default?platform=web&transport=web&debug=false": Was there a typo in the url or port?
93
+ at onError (/Users/ianrumac/Workspace/Superwall/Superwall-Web/node_modules/.bun/happy-dom@20.9.0/node_modules/happy-dom/lib/fetch/Fetch.js:540:21)
94
+ at emitError (node:events:43:23)
95
+ at <anonymous> (node:_http_client:253:22)
96
+
97
+ [Superwall:transactions] entitlements GET failed entitlements JSON decode failed: JSON Parse error: Unexpected EOF
98
+ (pass) usePlacement reflects presented + dismissed state and routes handler callbacks [38.22ms]
99
+ 244 | }, !keepOpen)
100
+ 245 | handleResponse();
101
+ 246 | onEnd();
102
+ 247 | }), !softFail)
103
+ 248 | this[kFetchRequest].catch((err) => {
104
+ 249 | err = Error("ECONNREFUSED"), err.code = "ECONNREFUSED";
105
+ ^
106
+ error: ECONNREFUSED
107
+ code: "ECONNREFUSED"
108
+
109
+ at <anonymous> (node:_http_client:249:24)
110
+
111
+ 535 | * @param error Error.
112
+ 536 | */
113
+ 537 | onError(error) {
114
+ 538 | this.finalizeRequest();
115
+ 539 | this.#browserFrame.page.console.error(error);
116
+ 540 | this.reject(new this.#window.DOMException(`Failed to execute "fetch()" on "Window" with URL "${this.request.url}": ${error.message}`, DOMExceptionNameEnum.networkError));
117
+ ^
118
+ NetworkError: Failed to execute "fetch()" on "Window" with URL "https://paywalls.test/pw_default?platform=web&transport=web&debug=false": ECONNREFUSED
119
+ at onError (/Users/ianrumac/Workspace/Superwall/Superwall-Web/node_modules/.bun/happy-dom@20.9.0/node_modules/happy-dom/lib/fetch/Fetch.js:540:21)
120
+ at emitError (node:events:43:23)
121
+ at <anonymous> (node:_http_client:253:22)
122
+
123
+ [Superwall:transactions] entitlements GET failed entitlements JSON decode failed: JSON Parse error: Unexpected EOF
124
+ (pass) usePlacement: ACTIVE subscription → register returns skipped(userSubscribed) [21.88ms]
125
+ error: Was there a typo in the url or port?
126
+ path: "https://paywalls.test/pw_default?platform=web&transport=web&debug=false",
127
+ errno: 0,
128
+ code: "FailedToOpenSocket"
129
+
130
+
131
+ 535 | * @param error Error.
132
+ 536 | */
133
+ 537 | onError(error) {
134
+ 538 | this.finalizeRequest();
135
+ 539 | this.#browserFrame.page.console.error(error);
136
+ 540 | this.reject(new this.#window.DOMException(`Failed to execute "fetch()" on "Window" with URL "${this.request.url}": ${error.message}`, DOMExceptionNameEnum.networkError));
137
+ ^
138
+ NetworkError: Failed to execute "fetch()" on "Window" with URL "https://paywalls.test/pw_default?platform=web&transport=web&debug=false": Was there a typo in the url or port?
139
+ at onError (/Users/ianrumac/Workspace/Superwall/Superwall-Web/node_modules/.bun/happy-dom@20.9.0/node_modules/happy-dom/lib/fetch/Fetch.js:540:21)
140
+ at emitError (node:events:43:23)
141
+ at <anonymous> (node:_http_client:253:22)
142
+
143
+ [Superwall:transactions] entitlements GET failed entitlements JSON decode failed: JSON Parse error: Unexpected EOF
144
+ (pass) useSuperwallEvent attaches a typed listener and auto-detaches on unmount [17.06ms]
145
+ 244 | }, !keepOpen)
146
+ 245 | handleResponse();
147
+ 246 | onEnd();
148
+ 247 | }), !softFail)
149
+ 248 | this[kFetchRequest].catch((err) => {
150
+ 249 | err = Error("ECONNREFUSED"), err.code = "ECONNREFUSED";
151
+ ^
152
+ error: ECONNREFUSED
153
+ code: "ECONNREFUSED"
154
+
155
+ at <anonymous> (node:_http_client:249:24)
156
+
157
+ 535 | * @param error Error.
158
+ 536 | */
159
+ 537 | onError(error) {
160
+ 538 | this.finalizeRequest();
161
+ 539 | this.#browserFrame.page.console.error(error);
162
+ 540 | this.reject(new this.#window.DOMException(`Failed to execute "fetch()" on "Window" with URL "${this.request.url}": ${error.message}`, DOMExceptionNameEnum.networkError));
163
+ ^
164
+ NetworkError: Failed to execute "fetch()" on "Window" with URL "https://paywalls.test/pw_default?platform=web&transport=web&debug=false": ECONNREFUSED
165
+ at onError (/Users/ianrumac/Workspace/Superwall/Superwall-Web/node_modules/.bun/happy-dom@20.9.0/node_modules/happy-dom/lib/fetch/Fetch.js:540:21)
166
+ at emitError (node:events:43:23)
167
+ at <anonymous> (node:_http_client:253:22)
168
+
169
+ [Superwall:transactions] entitlements GET failed entitlements JSON decode failed: JSON Parse error: Unexpected EOF
170
+ (pass) useDelegate installs a delegate for the lifetime of the component [22.59ms]
171
+ error: Was there a typo in the url or port?
172
+ path: "https://paywalls.test/pw_default?platform=web&transport=web&debug=false",
173
+ errno: 0,
174
+ code: "FailedToOpenSocket"
175
+
176
+
177
+ 535 | * @param error Error.
178
+ 536 | */
179
+ 537 | onError(error) {
180
+ 538 | this.finalizeRequest();
181
+ 539 | this.#browserFrame.page.console.error(error);
182
+ 540 | this.reject(new this.#window.DOMException(`Failed to execute "fetch()" on "Window" with URL "${this.request.url}": ${error.message}`, DOMExceptionNameEnum.networkError));
183
+ ^
184
+ NetworkError: Failed to execute "fetch()" on "Window" with URL "https://paywalls.test/pw_default?platform=web&transport=web&debug=false": Was there a typo in the url or port?
185
+ at onError (/Users/ianrumac/Workspace/Superwall/Superwall-Web/node_modules/.bun/happy-dom@20.9.0/node_modules/happy-dom/lib/fetch/Fetch.js:540:21)
186
+ at emitError (node:events:43:23)
187
+ at <anonymous> (node:_http_client:253:22)
188
+
189
+ [Superwall:transactions] entitlements GET failed entitlements JSON decode failed: JSON Parse error: Unexpected EOF
190
+ (pass) useSignal: unstable signal identity per render doesn't trigger infinite re-render [16.51ms]
191
+ 244 | }, !keepOpen)
192
+ 245 | handleResponse();
193
+ 246 | onEnd();
194
+ 247 | }), !softFail)
195
+ 248 | this[kFetchRequest].catch((err) => {
196
+ 249 | err = Error("ECONNREFUSED"), err.code = "ECONNREFUSED";
197
+ ^
198
+ error: ECONNREFUSED
199
+ code: "ECONNREFUSED"
200
+
201
+ at <anonymous> (node:_http_client:249:24)
202
+
203
+ 535 | * @param error Error.
204
+ 536 | */
205
+ 537 | onError(error) {
206
+ 538 | this.finalizeRequest();
207
+ 539 | this.#browserFrame.page.console.error(error);
208
+ 540 | this.reject(new this.#window.DOMException(`Failed to execute "fetch()" on "Window" with URL "${this.request.url}": ${error.message}`, DOMExceptionNameEnum.networkError));
209
+ ^
210
+ NetworkError: Failed to execute "fetch()" on "Window" with URL "https://paywalls.test/pw_default?platform=web&transport=web&debug=false": ECONNREFUSED
211
+ at onError (/Users/ianrumac/Workspace/Superwall/Superwall-Web/node_modules/.bun/happy-dom@20.9.0/node_modules/happy-dom/lib/fetch/Fetch.js:540:21)
212
+ at emitError (node:events:43:23)
213
+ at <anonymous> (node:_http_client:253:22)
214
+
215
+ [Superwall:transactions] entitlements GET failed entitlements JSON decode failed: JSON Parse error: Unexpected EOF
216
+ (pass) useDelegate: unmounting one of two stacked hooks leaves the other installed [43.03ms]
217
+
218
+ src/provider.test.tsx:
219
+ [Superwall:transactions] entitlements GET failed entitlements JSON decode failed: JSON Parse error: Unexpected EOF
220
+ (pass) SuperwallProvider provides a Superwall instance via context [8.13ms]
221
+ (pass) useSuperwall outside <SuperwallProvider> throws a clear error [1.58ms]
222
+ [Superwall:transactions] entitlements GET failed entitlements JSON decode failed: JSON Parse error: Unexpected EOF
223
+ (pass) registry reuses the instance across re-mounts with the same apiKey (HMR) [25.73ms]
224
+ [Superwall:transactions] entitlements GET failed entitlements JSON decode failed: JSON Parse error: Unexpected EOF
225
+ [Superwall:transactions] entitlements GET failed entitlements JSON decode failed: JSON Parse error: Unexpected EOF
226
+ (pass) different apiKeys produce different instances [14.89ms]
227
+
228
+ 14 pass
229
+ 0 fail
230
+ 40 expect() calls
231
+ Ran 14 tests across 3 files. [711.00ms]
@@ -0,0 +1,46 @@
1
+ $ tsc --noEmit
2
+ ../paywalls-js/src/internal/audience.ts(32,3): error TS2322: Type 'Promise<typeof import("/Users/ianrumac/Workspace/Superwall/Superwall-Web/node_modules/.bun/@superwall+superscript@0.2.5/node_modules/@superwall/superscript/dist/types/browser")>' is not assignable to type 'Promise<{ evaluateWithContext: (input: ExecutionContext, host: SuperscriptHostContext) => string | boolean; }>'.
3
+ Type 'typeof import("/Users/ianrumac/Workspace/Superwall/Superwall-Web/node_modules/.bun/@superwall+superscript@0.2.5/node_modules/@superwall/superscript/dist/types/browser")' is not assignable to type '{ evaluateWithContext: (input: ExecutionContext, host: SuperscriptHostContext) => string | boolean; }'.
4
+ The types returned by 'evaluateWithContext(...)' are incompatible between these types.
5
+ Type 'Promise<string>' is not assignable to type 'string | boolean'.
6
+ ../paywalls-js/src/internal/audience.ts(232,18): error TS18047: 'mod' is possibly 'null'.
7
+ ../paywalls-js/src/internal/redemption.ts(133,21): error TS2379: Argument of type '{ deviceId: string; appUserId: string | undefined; aliasId: string; codes: { code: string; firstRedemption?: boolean; }[]; }' is not assignable to parameter of type 'RedeemRequest' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
8
+ Types of property 'appUserId' are incompatible.
9
+ Type 'string | undefined' is not assignable to type 'string'.
10
+ Type 'undefined' is not assignable to type 'string'.
11
+ ../paywalls-js/src/superwall.ts(947,7): error TS2379: Argument of type 'Effect<void, StorageSetError, StorageService>' is not assignable to parameter of type 'Effect<unknown, unknown, never>' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
12
+ Type 'StorageService' is not assignable to type 'never'.
13
+ ../paywalls-js/src/superwall.ts(1046,38): error TS2551: Property 'activeSubscriptions' does not exist on type 'CustomerInfo'. Did you mean 'subscriptions'?
14
+ ../paywalls-js/src/superwall.ts(1050,11): error TS2375: Type '{ publicApiKey: string; aliasId: string; appUserId: string; vendorId: string; deviceId: string; bundleId: string | undefined; appVersion: string | undefined; isSandbox: boolean; isFirstAppOpen: boolean; ... 6 more ...; activeProducts: any; }' is not assignable to type 'DeviceAttributesInput' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
15
+ Types of property 'bundleId' are incompatible.
16
+ Type 'string | undefined' is not assignable to type 'string'.
17
+ Type 'undefined' is not assignable to type 'string'.
18
+ ../paywalls-js/src/superwall.ts(1208,9): error TS2379: Argument of type 'Effect<void, never, EventBus>' is not assignable to parameter of type 'Effect<unknown, unknown, never>' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
19
+ Type 'EventBus' is not assignable to type 'never'.
20
+ ../paywalls-js/src/superwall.ts(1608,15): error TS2379: Argument of type 'Effect<void, never, EventBus>' is not assignable to parameter of type 'Effect<unknown, unknown, never>' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
21
+ Type 'EventBus' is not assignable to type 'never'.
22
+ ../paywalls-js/src/superwall.ts(1722,17): error TS2379: Argument of type 'Effect<void, never, EventBus>' is not assignable to parameter of type 'Effect<unknown, unknown, never>' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
23
+ Type 'EventBus' is not assignable to type 'never'.
24
+ ../paywalls-js/src/superwall.ts(1737,17): error TS2379: Argument of type 'Effect<void, never, EventBus>' is not assignable to parameter of type 'Effect<unknown, unknown, never>' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
25
+ Type 'EventBus' is not assignable to type 'never'.
26
+ ../paywalls-js/src/superwall.ts(1949,11): error TS2379: Argument of type 'Effect<void, never, EventBus>' is not assignable to parameter of type 'Effect<unknown, unknown, never>' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
27
+ Type 'EventBus' is not assignable to type 'never'.
28
+ ../paywalls-js/src/superwall.ts(1969,13): error TS2379: Argument of type 'Effect<void, never, EventBus>' is not assignable to parameter of type 'Effect<unknown, unknown, never>' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
29
+ Type 'EventBus' is not assignable to type 'never'.
30
+ ../paywalls-js/src/superwall.ts(2050,11): error TS2379: Argument of type 'Effect<void, never, EventBus>' is not assignable to parameter of type 'Effect<unknown, unknown, never>' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
31
+ Type 'EventBus' is not assignable to type 'never'.
32
+ ../paywalls-js/src/superwall.ts(2112,9): error TS2379: Argument of type 'Effect<void, never, EventBus>' is not assignable to parameter of type 'Effect<unknown, unknown, never>' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
33
+ Type 'EventBus' is not assignable to type 'never'.
34
+ ../paywalls-js/src/superwall.ts(2303,9): error TS2379: Argument of type 'Effect<void, never, Logger>' is not assignable to parameter of type 'Effect<unknown, unknown, never>' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
35
+ Type 'Logger' is not assignable to type 'never'.
36
+ ../paywalls-js/src/superwall.ts(2317,9): error TS2379: Argument of type 'Effect<void, never, EventBus>' is not assignable to parameter of type 'Effect<unknown, unknown, never>' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
37
+ Type 'EventBus' is not assignable to type 'never'.
38
+ ../paywalls-js/src/superwall.ts(2392,9): error TS2352: Conversion of type 'Effect<void, never, NetworkService | ConfigService | AssignmentService>' to type 'Effect<void, unknown, never>' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
39
+ Type 'NetworkService | ConfigService | AssignmentService' is not comparable to type 'never'.
40
+ Type 'AssignmentService' is not comparable to type 'never'.
41
+ src/hooks.test.tsx(417,26): error TS2345: Argument of type '{ readonly value: string; subscribe: (run: () => void) => () => void; }' is not assignable to parameter of type 'Readable<string>'.
42
+ Types of property 'subscribe' are incompatible.
43
+ Type '(run: () => void) => () => void' is not assignable to type '(run: (value: string) => void) => () => void'.
44
+ Types of parameters 'run' and 'run' are incompatible.
45
+ Target signature provides too few arguments. Expected 1 or more, but got 0.
46
+ src/hooks.ts(185,11): error TS2367: This comparison appears to be unintentional because the types '"error" | "presented" | "skipped"' and '"entitled"' have no overlap.
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@superwall/paywalls-react",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./src/index.ts",
9
+ "default": "./src/index.ts"
10
+ }
11
+ },
12
+ "scripts": {
13
+ "test": "bun test",
14
+ "typecheck": "tsc --noEmit",
15
+ "build": "echo 'no-op for v0; consumers import .ts directly via Bun/Vite/Next ESM'",
16
+ "clean": "rm -rf node_modules .turbo *.tsbuildinfo"
17
+ },
18
+ "peerDependencies": {
19
+ "react": "^19.0.0",
20
+ "@superwall/paywalls-js": "0.0.0"
21
+ },
22
+ "dependencies": {
23
+ "@superwall/paywalls-js": "0.0.0"
24
+ },
25
+ "devDependencies": {
26
+ "@happy-dom/global-registrator": "^20.0.0",
27
+ "@testing-library/react": "^16.1.0",
28
+ "@types/bun": "latest",
29
+ "@types/react": "^19.0.0",
30
+ "@types/react-dom": "^19.0.0",
31
+ "react": "^19.0.0",
32
+ "react-dom": "^19.0.0",
33
+ "typescript": "^5.6.0"
34
+ }
35
+ }