@whop/react-native 0.0.11 → 0.0.12
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/dist/cli/index.js +353 -40
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +350 -37
- package/dist/cli/index.mjs.map +1 -1
- package/dist/lib/index.d.mts +15 -1
- package/dist/lib/index.d.ts +15 -1
- package/dist/lib/index.js +305 -5
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +295 -5
- package/dist/lib/index.mjs.map +1 -1
- package/dist/lib/web.mjs +214 -0
- package/dist/lib/web.mjs.map +1 -0
- package/package.json +63 -5
package/dist/lib/index.mjs
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
// src/lib/index.ts
|
|
8
8
|
var lib_exports = {};
|
|
9
9
|
__export(lib_exports, {
|
|
10
|
+
Haptics: () => haptics_default,
|
|
10
11
|
__internal_execAsync: () => __internal_execAsync,
|
|
11
12
|
__internal_execSync: () => __internal_execSync,
|
|
12
13
|
whopSdk: () => whopSdk
|
|
@@ -18,11 +19,263 @@ __export(client_sdk_exports, {
|
|
|
18
19
|
whopSdk: () => whopSdk
|
|
19
20
|
});
|
|
20
21
|
import { WhopClientSdk } from "@whop/api";
|
|
21
|
-
import { Platform } from "react-native";
|
|
22
|
+
import { Platform as Platform2 } from "react-native";
|
|
22
23
|
|
|
23
24
|
// src/lib/native-whop-core.ts
|
|
24
25
|
import { TurboModuleRegistry } from "react-native";
|
|
25
|
-
|
|
26
|
+
|
|
27
|
+
// src/lib/native-whop-core-stub.ts
|
|
28
|
+
import { Platform } from "react-native";
|
|
29
|
+
var WhopCoreObservable = class {
|
|
30
|
+
subscribers = /* @__PURE__ */ new Set();
|
|
31
|
+
value;
|
|
32
|
+
constructor(value) {
|
|
33
|
+
this.value = value;
|
|
34
|
+
}
|
|
35
|
+
setValue(value) {
|
|
36
|
+
this.value = value;
|
|
37
|
+
for (const callback of this.subscribers) {
|
|
38
|
+
callback(value);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
getValue() {
|
|
42
|
+
return this.value;
|
|
43
|
+
}
|
|
44
|
+
subscribe(callback) {
|
|
45
|
+
this.subscribers.add(callback);
|
|
46
|
+
return () => {
|
|
47
|
+
this.subscribers.delete(callback);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var WhopCoreNavigation = class {
|
|
52
|
+
path = new WhopCoreObservable([]);
|
|
53
|
+
sheet = new WhopCoreObservable(null);
|
|
54
|
+
constructor() {
|
|
55
|
+
this.getFullStack = this.getFullStack.bind(this);
|
|
56
|
+
this.getCurrentSheet = this.getCurrentSheet.bind(this);
|
|
57
|
+
this.subscribeToPath = this.subscribeToPath.bind(this);
|
|
58
|
+
this.subscribeToSheet = this.subscribeToSheet.bind(this);
|
|
59
|
+
}
|
|
60
|
+
push(route) {
|
|
61
|
+
if (this.getCurrent().path.join("/") === route.path.join("/")) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
this.path.setValue([...this.path.getValue(), route]);
|
|
65
|
+
if (typeof window !== "undefined" && window.history) {
|
|
66
|
+
try {
|
|
67
|
+
const pathBits = route.path.join("/");
|
|
68
|
+
const paramsBits = Object.entries(route.params).map(([key, value]) => `${key}=${value}`).join("&");
|
|
69
|
+
window.history.pushState(
|
|
70
|
+
{ route, index: this.path.getValue().length },
|
|
71
|
+
"",
|
|
72
|
+
`#${pathBits}?${paramsBits}`
|
|
73
|
+
);
|
|
74
|
+
} catch {
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
pop() {
|
|
79
|
+
if (typeof window !== "undefined" && window.history) {
|
|
80
|
+
try {
|
|
81
|
+
window.history.back();
|
|
82
|
+
} catch {
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
getFullStack() {
|
|
87
|
+
return this.path.getValue();
|
|
88
|
+
}
|
|
89
|
+
getCurrent() {
|
|
90
|
+
return this.path.getValue()[this.path.getValue().length - 1] ?? {
|
|
91
|
+
path: [],
|
|
92
|
+
params: {}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
presentSheet(route) {
|
|
96
|
+
this.sheet.setValue(route);
|
|
97
|
+
}
|
|
98
|
+
dismissSheet() {
|
|
99
|
+
this.sheet.setValue(null);
|
|
100
|
+
}
|
|
101
|
+
getCurrentSheet() {
|
|
102
|
+
return this.sheet.getValue() ?? null;
|
|
103
|
+
}
|
|
104
|
+
subscribeToPath(callback) {
|
|
105
|
+
return this.path.subscribe(callback);
|
|
106
|
+
}
|
|
107
|
+
subscribeToSheet(callback) {
|
|
108
|
+
return this.sheet.subscribe(callback);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
var navigation = new WhopCoreNavigation();
|
|
112
|
+
if (typeof window !== "undefined" && Platform.OS === "web") {
|
|
113
|
+
window.whopCoreNavigation = navigation;
|
|
114
|
+
window.addEventListener("popstate", (e) => {
|
|
115
|
+
const currentLength = navigation.path.getValue().length;
|
|
116
|
+
if (!e.state) {
|
|
117
|
+
navigation.path.setValue(navigation.path.getValue().slice(0, -1));
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const index = e.state.index;
|
|
121
|
+
const route = e.state.route;
|
|
122
|
+
if (index < currentLength) {
|
|
123
|
+
navigation.path.setValue(navigation.path.getValue().slice(0, -1));
|
|
124
|
+
} else {
|
|
125
|
+
navigation.path.setValue([...navigation.path.getValue(), route]);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function ok(data) {
|
|
130
|
+
return { isOk: true, data: JSON.stringify(data), errorMessage: null };
|
|
131
|
+
}
|
|
132
|
+
function err(message) {
|
|
133
|
+
return { isOk: false, data: null, errorMessage: message };
|
|
134
|
+
}
|
|
135
|
+
function getOrigin() {
|
|
136
|
+
if (typeof window !== "undefined" && window.location) {
|
|
137
|
+
return window.location.origin;
|
|
138
|
+
}
|
|
139
|
+
return "";
|
|
140
|
+
}
|
|
141
|
+
var syncHandlers = {
|
|
142
|
+
getAppApiOrigin() {
|
|
143
|
+
return { apiOrigin: getOrigin() };
|
|
144
|
+
},
|
|
145
|
+
cacheGet({ key }) {
|
|
146
|
+
try {
|
|
147
|
+
if (typeof window !== "undefined" && window.localStorage && key) {
|
|
148
|
+
return { data: window.localStorage.getItem(key) };
|
|
149
|
+
}
|
|
150
|
+
return { data: null };
|
|
151
|
+
} catch {
|
|
152
|
+
return { data: null };
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
cacheSet({ key, data }) {
|
|
156
|
+
try {
|
|
157
|
+
if (typeof window !== "undefined" && window.localStorage && key != null) {
|
|
158
|
+
if (data == null) {
|
|
159
|
+
window.localStorage.removeItem(key);
|
|
160
|
+
} else {
|
|
161
|
+
window.localStorage.setItem(key, data);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
} catch {
|
|
165
|
+
}
|
|
166
|
+
return {};
|
|
167
|
+
},
|
|
168
|
+
routerPush(route) {
|
|
169
|
+
navigation.push(route);
|
|
170
|
+
return {};
|
|
171
|
+
},
|
|
172
|
+
routerPop() {
|
|
173
|
+
navigation.pop();
|
|
174
|
+
return {};
|
|
175
|
+
},
|
|
176
|
+
routerGetCurrent() {
|
|
177
|
+
return navigation.getCurrent();
|
|
178
|
+
},
|
|
179
|
+
setNavigationBarData() {
|
|
180
|
+
return {};
|
|
181
|
+
},
|
|
182
|
+
routerPresentSheet({ path, params }) {
|
|
183
|
+
navigation.presentSheet({
|
|
184
|
+
path: Array.from(path ?? []),
|
|
185
|
+
params: params ?? {}
|
|
186
|
+
});
|
|
187
|
+
return {};
|
|
188
|
+
},
|
|
189
|
+
routerDismissSheet() {
|
|
190
|
+
navigation.dismissSheet();
|
|
191
|
+
return {};
|
|
192
|
+
},
|
|
193
|
+
routerGetCurrentSheet() {
|
|
194
|
+
return navigation.getCurrentSheet() ?? null;
|
|
195
|
+
},
|
|
196
|
+
downgradeToWebView() {
|
|
197
|
+
return {};
|
|
198
|
+
},
|
|
199
|
+
getHostAppDetails() {
|
|
200
|
+
return {
|
|
201
|
+
build: "web",
|
|
202
|
+
version: "0.0.0",
|
|
203
|
+
platform: "web",
|
|
204
|
+
buildType: "appstore"
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
var iframeModulePromise = null;
|
|
209
|
+
async function loadIframeModule() {
|
|
210
|
+
if (!iframeModulePromise) {
|
|
211
|
+
iframeModulePromise = import("@whop/iframe");
|
|
212
|
+
}
|
|
213
|
+
return await iframeModulePromise;
|
|
214
|
+
}
|
|
215
|
+
var iframeSdk = null;
|
|
216
|
+
async function loadIframeSdk() {
|
|
217
|
+
if (!iframeSdk) {
|
|
218
|
+
const module = await loadIframeModule();
|
|
219
|
+
iframeSdk = module.createSdk({
|
|
220
|
+
appId: process.env.NEXT_PUBLIC_WHOP_APP_ID
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
return iframeSdk;
|
|
224
|
+
}
|
|
225
|
+
var asyncHandlers = {
|
|
226
|
+
inAppPurchase: async ({ planId, id }) => {
|
|
227
|
+
const sdk = await loadIframeSdk();
|
|
228
|
+
const result = await sdk.inAppPurchase({ planId, id: id ?? void 0 });
|
|
229
|
+
if (result.status === "ok") {
|
|
230
|
+
return {
|
|
231
|
+
sessionId: result.data.sessionId,
|
|
232
|
+
receiptId: result.data.receiptId
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
throw new Error(result.error);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
var nativeWhopCoreStub = {
|
|
239
|
+
execSync(name, paramsJson) {
|
|
240
|
+
try {
|
|
241
|
+
const params = paramsJson ? JSON.parse(paramsJson) : {};
|
|
242
|
+
const handler = syncHandlers[name];
|
|
243
|
+
if (!handler) return err(`Unknown sync method: ${name}`);
|
|
244
|
+
const result = handler(params);
|
|
245
|
+
return ok(result);
|
|
246
|
+
} catch (e) {
|
|
247
|
+
return err(e instanceof Error ? e.message : "Unknown error");
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
async execAsync(name, paramsJson) {
|
|
251
|
+
try {
|
|
252
|
+
const params = paramsJson ? JSON.parse(paramsJson) : {};
|
|
253
|
+
const handler = asyncHandlers[name];
|
|
254
|
+
if (!handler) return err(`Unknown async method: ${name}`);
|
|
255
|
+
const result = await handler(params);
|
|
256
|
+
return ok(result);
|
|
257
|
+
} catch (e) {
|
|
258
|
+
return err(e instanceof Error ? e.message : "Unknown error");
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
var native_whop_core_stub_default = nativeWhopCoreStub;
|
|
263
|
+
|
|
264
|
+
// src/lib/native-whop-core.ts
|
|
265
|
+
function resolveNative() {
|
|
266
|
+
try {
|
|
267
|
+
const registry = TurboModuleRegistry;
|
|
268
|
+
const get = registry?.getEnforcing ?? registry?.get;
|
|
269
|
+
if (typeof get === "function") {
|
|
270
|
+
return get.call(registry, "NativeWhopCore");
|
|
271
|
+
}
|
|
272
|
+
return null;
|
|
273
|
+
} catch {
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
var native = resolveNative();
|
|
278
|
+
var native_whop_core_default = native ?? native_whop_core_stub_default;
|
|
26
279
|
|
|
27
280
|
// src/lib/native-whop-core-wrapper.ts
|
|
28
281
|
function __internal_execSync(name, params) {
|
|
@@ -47,13 +300,13 @@ async function __internal_execAsync(name, params) {
|
|
|
47
300
|
__reExport(client_sdk_exports, api_star);
|
|
48
301
|
import * as api_star from "@whop/api";
|
|
49
302
|
function getAppOrigin() {
|
|
50
|
-
if (
|
|
303
|
+
if (Platform2.OS === "android" || Platform2.OS === "ios") {
|
|
51
304
|
return __internal_execSync("getAppApiOrigin", {}).apiOrigin;
|
|
52
305
|
}
|
|
53
|
-
if (
|
|
306
|
+
if (Platform2.OS === "web" && typeof window !== "undefined") {
|
|
54
307
|
return window.location.origin;
|
|
55
308
|
}
|
|
56
|
-
throw new Error(`Unsupported platform: ${
|
|
309
|
+
throw new Error(`Unsupported platform: ${Platform2.OS}`);
|
|
57
310
|
}
|
|
58
311
|
var appOrigin = getAppOrigin();
|
|
59
312
|
var whopSdk = WhopClientSdk({
|
|
@@ -63,7 +316,44 @@ var whopSdk = WhopClientSdk({
|
|
|
63
316
|
|
|
64
317
|
// src/lib/index.ts
|
|
65
318
|
__reExport(lib_exports, client_sdk_exports);
|
|
319
|
+
|
|
320
|
+
// src/lib/haptics.ts
|
|
321
|
+
var nativeModule = null;
|
|
322
|
+
var loadingPromise = null;
|
|
323
|
+
async function ensureNativeLoaded() {
|
|
324
|
+
const isWeb = typeof document !== "undefined" && typeof window !== "undefined";
|
|
325
|
+
if (isWeb) return;
|
|
326
|
+
if (nativeModule || loadingPromise) {
|
|
327
|
+
return loadingPromise ?? Promise.resolve();
|
|
328
|
+
}
|
|
329
|
+
loadingPromise = import("react-native-haptic-feedback").then((mod) => {
|
|
330
|
+
nativeModule = { trigger: mod.default.trigger };
|
|
331
|
+
}).catch(() => {
|
|
332
|
+
}).finally(() => {
|
|
333
|
+
loadingPromise = null;
|
|
334
|
+
});
|
|
335
|
+
return loadingPromise;
|
|
336
|
+
}
|
|
337
|
+
var HAPTIC_NOOP = {
|
|
338
|
+
trigger: (_type, _options) => {
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
var Haptics = {
|
|
342
|
+
async trigger(type, options) {
|
|
343
|
+
await ensureNativeLoaded();
|
|
344
|
+
if (nativeModule) {
|
|
345
|
+
try {
|
|
346
|
+
nativeModule.trigger(type, options);
|
|
347
|
+
} catch {
|
|
348
|
+
}
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
HAPTIC_NOOP.trigger(type, options);
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
var haptics_default = Haptics;
|
|
66
355
|
export {
|
|
356
|
+
haptics_default as Haptics,
|
|
67
357
|
__internal_execAsync,
|
|
68
358
|
__internal_execSync,
|
|
69
359
|
whopSdk
|
package/dist/lib/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/index.ts","../../src/lib/client-sdk.ts","../../src/lib/native-whop-core.ts","../../src/lib/native-whop-core-wrapper.ts"],"sourcesContent":["export * from \"./client-sdk\";\nexport * from \"./native-whop-core-wrapper\";\nexport * from \"./props\";\n","import { WhopClientSdk } from \"@whop/api\";\nimport { Platform } from \"react-native\";\nimport { __internal_execSync } from \"./native-whop-core-wrapper\";\n\nfunction getAppOrigin() {\n\tif (Platform.OS === \"android\" || Platform.OS === \"ios\") {\n\t\treturn __internal_execSync(\"getAppApiOrigin\", {}).apiOrigin;\n\t}\n\n\tif (Platform.OS === \"web\" && typeof window !== \"undefined\") {\n\t\treturn window.location.origin;\n\t}\n\n\tthrow new Error(`Unsupported platform: ${Platform.OS}`);\n}\n\nconst appOrigin = getAppOrigin();\n\nexport const whopSdk: WhopClientSdk = WhopClientSdk({\n\tapiOrigin: appOrigin,\n\tapiPath: \"/_whop/public-graphql/\",\n});\n\nexport * from \"@whop/api\";\n","import type { TurboModule } from \"react-native\";\nimport { TurboModuleRegistry } from \"react-native\";\n\nexport type FunctionCallResult = {\n\tisOk: boolean;\n\tdata: string | null;\n\terrorMessage: string | null;\n};\n\nexport interface Spec extends TurboModule {\n\texecSync(name: string, paramsJson: string): FunctionCallResult;\n\texecAsync(name: string, paramsJson: string): Promise<FunctionCallResult>;\n}\n\nexport default TurboModuleRegistry.getEnforcing<Spec>(\"NativeWhopCore\");\n","import nativeWhopCore from \"./native-whop-core\";\nimport type { PathParams } from \"./props\";\n\n// biome-ignore lint/complexity/noBannedTypes: allow here\ntype EmptyObject = {};\n\nexport interface ExecSyncApi {\n\tgetAppApiOrigin(params: EmptyObject): { apiOrigin: string };\n\tcacheGet(params: { key?: string | null }): { data?: string | null };\n\tcacheSet(params: { key?: string | null; data?: string | null }): EmptyObject;\n\trouterPush(params: PathParams): EmptyObject;\n\trouterPop(params: EmptyObject): EmptyObject;\n\trouterGetCurrent(params: EmptyObject): PathParams;\n\tsetNavigationBarData(params: {\n\t\ttitle?: string | null;\n\t\tdescription?: string | null;\n\t}): EmptyObject;\n\trouterPresentSheet(params: PathParams): EmptyObject;\n\trouterDismissSheet(params: EmptyObject): EmptyObject;\n\trouterGetCurrentSheet(params: EmptyObject): PathParams | null | undefined;\n\tdowngradeToWebView(params: EmptyObject): EmptyObject;\n\tgetHostAppDetails(params: EmptyObject): {\n\t\tbuild: string;\n\t\tversion: string;\n\t\tplatform: \"ios\" | \"android\" | \"web\";\n\t\tbuildType: \"appstore\" | \"testflight\" | \"debug\";\n\t};\n}\n\nexport interface ExecAsyncApi extends ExecSyncApi {\n\tinAppPurchase(params: {\n\t\tid?: string | null;\n\t\tplanId: string;\n\t}): {\n\t\tsessionId: string;\n\t\treceiptId: string;\n\t};\n}\n\nexport function __internal_execSync<F extends keyof ExecSyncApi>(\n\tname: F,\n\tparams: Parameters<ExecSyncApi[F]>[0],\n): ReturnType<ExecSyncApi[F]> {\n\tconst resultJson = nativeWhopCore.execSync(name, JSON.stringify(params));\n\tif (!resultJson.isOk) {\n\t\tthrow new Error(`Failed to execute ${name}: ${resultJson.errorMessage}`);\n\t}\n\n\treturn JSON.parse(resultJson.data || \"{}\") as ReturnType<ExecSyncApi[F]>;\n}\n\nexport async function __internal_execAsync<F extends keyof ExecAsyncApi>(\n\tname: F,\n\tparams: Parameters<ExecAsyncApi[F]>[0],\n): Promise<ReturnType<ExecAsyncApi[F]>> {\n\tconst resultJson = await nativeWhopCore.execAsync(\n\t\tname,\n\t\tJSON.stringify(params),\n\t);\n\n\tif (!resultJson.isOk) {\n\t\tthrow new Error(`Failed to execute ${name}: ${resultJson.errorMessage}`);\n\t}\n\n\treturn JSON.parse(resultJson.data || \"{}\") as ReturnType<ExecAsyncApi[F]>;\n}\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;;;ACAzB,SAAS,2BAA2B;AAapC,IAAO,2BAAQ,oBAAoB,aAAmB,gBAAgB;;;ACyB/D,SAAS,oBACf,MACA,QAC6B;AAC7B,QAAM,aAAa,yBAAe,SAAS,MAAM,KAAK,UAAU,MAAM,CAAC;AACvE,MAAI,CAAC,WAAW,MAAM;AACrB,UAAM,IAAI,MAAM,qBAAqB,IAAI,KAAK,WAAW,YAAY,EAAE;AAAA,EACxE;AAEA,SAAO,KAAK,MAAM,WAAW,QAAQ,IAAI;AAC1C;AAEA,eAAsB,qBACrB,MACA,QACuC;AACvC,QAAM,aAAa,MAAM,yBAAe;AAAA,IACvC;AAAA,IACA,KAAK,UAAU,MAAM;AAAA,EACtB;AAEA,MAAI,CAAC,WAAW,MAAM;AACrB,UAAM,IAAI,MAAM,qBAAqB,IAAI,KAAK,WAAW,YAAY,EAAE;AAAA,EACxE;AAEA,SAAO,KAAK,MAAM,WAAW,QAAQ,IAAI;AAC1C;;;AF1CA;AAAA,0BAAc;AAnBd,SAAS,eAAe;AACvB,MAAI,SAAS,OAAO,aAAa,SAAS,OAAO,OAAO;AACvD,WAAO,oBAAoB,mBAAmB,CAAC,CAAC,EAAE;AAAA,EACnD;AAEA,MAAI,SAAS,OAAO,SAAS,OAAO,WAAW,aAAa;AAC3D,WAAO,OAAO,SAAS;AAAA,EACxB;AAEA,QAAM,IAAI,MAAM,yBAAyB,SAAS,EAAE,EAAE;AACvD;AAEA,IAAM,YAAY,aAAa;AAExB,IAAM,UAAyB,cAAc;AAAA,EACnD,WAAW;AAAA,EACX,SAAS;AACV,CAAC;;;ADrBD,wBAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/lib/index.ts","../../src/lib/client-sdk.ts","../../src/lib/native-whop-core.ts","../../src/lib/native-whop-core-stub.ts","../../src/lib/native-whop-core-wrapper.ts","../../src/lib/haptics.ts"],"sourcesContent":["export * from \"./client-sdk\";\nexport * from \"./native-whop-core-wrapper\";\nexport * from \"./props\";\nimport Haptics from \"./haptics\";\n\nexport { Haptics };\n","import { WhopClientSdk } from \"@whop/api\";\nimport { Platform } from \"react-native\";\nimport { __internal_execSync } from \"./native-whop-core-wrapper\";\n\nfunction getAppOrigin() {\n\tif (Platform.OS === \"android\" || Platform.OS === \"ios\") {\n\t\treturn __internal_execSync(\"getAppApiOrigin\", {}).apiOrigin;\n\t}\n\n\tif (Platform.OS === \"web\" && typeof window !== \"undefined\") {\n\t\treturn window.location.origin;\n\t}\n\n\tthrow new Error(`Unsupported platform: ${Platform.OS}`);\n}\n\nconst appOrigin = getAppOrigin();\n\nexport const whopSdk: WhopClientSdk = WhopClientSdk({\n\tapiOrigin: appOrigin,\n\tapiPath: \"/_whop/public-graphql/\",\n});\n\nexport * from \"@whop/api\";\n","import type { TurboModule } from \"react-native\";\nimport { TurboModuleRegistry } from \"react-native\";\nimport stub from \"./native-whop-core-stub\";\n\nexport type FunctionCallResult = {\n\tisOk: boolean;\n\tdata: string | null;\n\terrorMessage: string | null;\n};\n\nexport interface Spec extends TurboModule {\n\texecSync(name: string, paramsJson: string): FunctionCallResult;\n\texecAsync(name: string, paramsJson: string): Promise<FunctionCallResult>;\n}\n\nfunction resolveNative(): Spec | null {\n\ttry {\n\t\t// biome-ignore lint/suspicious/noExplicitAny: <explanation>\n\t\tconst registry: any = TurboModuleRegistry as any;\n\t\tconst get = registry?.getEnforcing ?? registry?.get;\n\t\tif (typeof get === \"function\") {\n\t\t\treturn get.call(registry, \"NativeWhopCore\") as Spec;\n\t\t}\n\t\treturn null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nconst native = resolveNative();\n\nexport default native ?? (stub as Spec);\n","import { Platform } from \"react-native\";\nimport type { ExecAsyncApi, ExecSyncApi } from \"./native-whop-core-wrapper\";\n\nexport type FunctionCallResult = {\n\tisOk: boolean;\n\tdata: string | null;\n\terrorMessage: string | null;\n};\n\ntype Route = { path: string[]; params: Record<string, string> };\n\nclass WhopCoreObservable<T> {\n\tprivate subscribers: Set<(value: T) => void> = new Set();\n\tprivate value: T;\n\n\tconstructor(value: T) {\n\t\tthis.value = value;\n\t}\n\n\tsetValue(value: T) {\n\t\tthis.value = value;\n\t\tfor (const callback of this.subscribers) {\n\t\t\tcallback(value);\n\t\t}\n\t}\n\n\tgetValue() {\n\t\treturn this.value;\n\t}\n\n\tsubscribe(callback: (value: T) => void) {\n\t\tthis.subscribers.add(callback);\n\t\treturn () => {\n\t\t\tthis.subscribers.delete(callback);\n\t\t};\n\t}\n}\n\nclass WhopCoreNavigation {\n\tpublic path = new WhopCoreObservable<Route[]>([]);\n\tpublic sheet = new WhopCoreObservable<Route | null>(null);\n\n\tconstructor() {\n\t\tthis.getFullStack = this.getFullStack.bind(this);\n\t\tthis.getCurrentSheet = this.getCurrentSheet.bind(this);\n\t\tthis.subscribeToPath = this.subscribeToPath.bind(this);\n\t\tthis.subscribeToSheet = this.subscribeToSheet.bind(this);\n\t}\n\n\tpush(route: Route) {\n\t\tif (this.getCurrent().path.join(\"/\") === route.path.join(\"/\")) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.path.setValue([...this.path.getValue(), route]);\n\t\tif (typeof window !== \"undefined\" && window.history) {\n\t\t\ttry {\n\t\t\t\tconst pathBits = route.path.join(\"/\");\n\t\t\t\tconst paramsBits = Object.entries(route.params)\n\t\t\t\t\t.map(([key, value]) => `${key}=${value}`)\n\t\t\t\t\t.join(\"&\");\n\t\t\t\twindow.history.pushState(\n\t\t\t\t\t{ route, index: this.path.getValue().length },\n\t\t\t\t\t\"\",\n\t\t\t\t\t`#${pathBits}?${paramsBits}`,\n\t\t\t\t);\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\tpop() {\n\t\tif (typeof window !== \"undefined\" && window.history) {\n\t\t\ttry {\n\t\t\t\twindow.history.back();\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\tgetFullStack() {\n\t\treturn this.path.getValue();\n\t}\n\n\tgetCurrent() {\n\t\treturn (\n\t\t\tthis.path.getValue()[this.path.getValue().length - 1] ?? {\n\t\t\t\tpath: [],\n\t\t\t\tparams: {},\n\t\t\t}\n\t\t);\n\t}\n\n\tpresentSheet(route: Route) {\n\t\tthis.sheet.setValue(route);\n\t}\n\n\tdismissSheet() {\n\t\tthis.sheet.setValue(null);\n\t}\n\n\tgetCurrentSheet() {\n\t\treturn this.sheet.getValue() ?? null;\n\t}\n\n\tsubscribeToPath(callback: (route: Route[]) => void) {\n\t\treturn this.path.subscribe(callback);\n\t}\n\n\tsubscribeToSheet(callback: (route: Route | null) => void) {\n\t\treturn this.sheet.subscribe(callback);\n\t}\n}\n\nexport type TWhopCoreNavigation = WhopCoreNavigation;\n\nconst navigation = new WhopCoreNavigation();\nif (typeof window !== \"undefined\" && Platform.OS === \"web\") {\n\t// biome-ignore lint/suspicious/noExplicitAny: <explanation>\n\t(window as any).whopCoreNavigation = navigation;\n\n\twindow.addEventListener(\"popstate\", (e) => {\n\t\tconst currentLength = navigation.path.getValue().length;\n\t\tif (!e.state) {\n\t\t\tnavigation.path.setValue(navigation.path.getValue().slice(0, -1));\n\t\t\treturn;\n\t\t}\n\t\tconst index = e.state.index;\n\t\tconst route = e.state.route;\n\t\tif (index < currentLength) {\n\t\t\tnavigation.path.setValue(navigation.path.getValue().slice(0, -1));\n\t\t} else {\n\t\t\tnavigation.path.setValue([...navigation.path.getValue(), route]);\n\t\t}\n\t});\n}\n\nfunction ok(data: unknown): FunctionCallResult {\n\treturn { isOk: true, data: JSON.stringify(data), errorMessage: null };\n}\n\nfunction err(message: string): FunctionCallResult {\n\treturn { isOk: false, data: null, errorMessage: message };\n}\n\nfunction getOrigin(): string {\n\tif (typeof window !== \"undefined\" && window.location) {\n\t\treturn window.location.origin;\n\t}\n\treturn \"\";\n}\n\nconst syncHandlers: ExecSyncApi = {\n\tgetAppApiOrigin() {\n\t\treturn { apiOrigin: getOrigin() };\n\t},\n\tcacheGet({ key }: { key?: string | null }) {\n\t\ttry {\n\t\t\tif (typeof window !== \"undefined\" && window.localStorage && key) {\n\t\t\t\treturn { data: window.localStorage.getItem(key) };\n\t\t\t}\n\t\t\treturn { data: null };\n\t\t} catch {\n\t\t\treturn { data: null };\n\t\t}\n\t},\n\tcacheSet({ key, data }: { key?: string | null; data?: string | null }) {\n\t\ttry {\n\t\t\tif (typeof window !== \"undefined\" && window.localStorage && key != null) {\n\t\t\t\tif (data == null) {\n\t\t\t\t\twindow.localStorage.removeItem(key);\n\t\t\t\t} else {\n\t\t\t\t\twindow.localStorage.setItem(key, data);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {}\n\t\treturn {};\n\t},\n\trouterPush(route: Route) {\n\t\tnavigation.push(route);\n\t\treturn {};\n\t},\n\trouterPop() {\n\t\tnavigation.pop();\n\t\treturn {};\n\t},\n\trouterGetCurrent() {\n\t\treturn navigation.getCurrent();\n\t},\n\tsetNavigationBarData() {\n\t\treturn {};\n\t},\n\trouterPresentSheet({ path, params }: Route) {\n\t\tnavigation.presentSheet({\n\t\t\tpath: Array.from(path ?? []),\n\t\t\tparams: params ?? {},\n\t\t});\n\t\treturn {};\n\t},\n\trouterDismissSheet() {\n\t\tnavigation.dismissSheet();\n\t\treturn {};\n\t},\n\trouterGetCurrentSheet() {\n\t\treturn navigation.getCurrentSheet() ?? null;\n\t},\n\tdowngradeToWebView() {\n\t\treturn {};\n\t},\n\tgetHostAppDetails() {\n\t\treturn {\n\t\t\tbuild: \"web\",\n\t\t\tversion: \"0.0.0\",\n\t\t\tplatform: \"web\",\n\t\t\tbuildType: \"appstore\",\n\t\t};\n\t},\n};\n\nlet iframeModulePromise: Promise<typeof import(\"@whop/iframe\")> | null = null;\n\nasync function loadIframeModule() {\n\tif (!iframeModulePromise) {\n\t\tiframeModulePromise = import(\"@whop/iframe\");\n\t}\n\treturn await iframeModulePromise;\n}\n\nlet iframeSdk: ReturnType<typeof import(\"@whop/iframe\").createSdk> | null =\n\tnull;\n\nasync function loadIframeSdk() {\n\tif (!iframeSdk) {\n\t\tconst module = await loadIframeModule();\n\t\tiframeSdk = module.createSdk({\n\t\t\tappId: process.env.NEXT_PUBLIC_WHOP_APP_ID,\n\t\t});\n\t}\n\treturn iframeSdk;\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: <explanation>\ntype MakeAsync<T extends Record<string, any>> = {\n\t[K in keyof T]: (params: Parameters<T[K]>[0]) => Promise<ReturnType<T[K]>>;\n};\n\nconst asyncHandlers: MakeAsync<Pick<ExecAsyncApi, \"inAppPurchase\">> = {\n\tinAppPurchase: async ({ planId, id }) => {\n\t\tconst sdk = await loadIframeSdk();\n\t\tconst result = await sdk.inAppPurchase({ planId, id: id ?? undefined });\n\t\tif (result.status === \"ok\") {\n\t\t\treturn {\n\t\t\t\tsessionId: result.data.sessionId,\n\t\t\t\treceiptId: result.data.receiptId,\n\t\t\t};\n\t\t}\n\t\tthrow new Error(result.error);\n\t},\n};\n\nconst nativeWhopCoreStub = {\n\texecSync(name: string, paramsJson: string): FunctionCallResult {\n\t\ttry {\n\t\t\tconst params = paramsJson ? JSON.parse(paramsJson) : {};\n\t\t\tconst handler = syncHandlers[name as keyof typeof syncHandlers];\n\t\t\tif (!handler) return err(`Unknown sync method: ${name}`);\n\t\t\tconst result = handler(params);\n\t\t\treturn ok(result);\n\t\t} catch (e) {\n\t\t\treturn err(e instanceof Error ? e.message : \"Unknown error\");\n\t\t}\n\t},\n\tasync execAsync(\n\t\tname: string,\n\t\tparamsJson: string,\n\t): Promise<FunctionCallResult> {\n\t\ttry {\n\t\t\tconst params = paramsJson ? JSON.parse(paramsJson) : {};\n\t\t\tconst handler = (\n\t\t\t\tasyncHandlers as Record<string, (p: unknown) => Promise<unknown>>\n\t\t\t)[name];\n\t\t\tif (!handler) return err(`Unknown async method: ${name}`);\n\t\t\tconst result = await handler(params);\n\t\t\treturn ok(result);\n\t\t} catch (e) {\n\t\t\treturn err(e instanceof Error ? e.message : \"Unknown error\");\n\t\t}\n\t},\n};\n\nexport default nativeWhopCoreStub;\n","import nativeWhopCore from \"./native-whop-core\";\nimport type { PathParams } from \"./props\";\n\n// biome-ignore lint/complexity/noBannedTypes: allow here\ntype EmptyObject = {};\n\nexport interface ExecSyncApi {\n\tgetAppApiOrigin(params: EmptyObject): { apiOrigin: string };\n\tcacheGet(params: { key?: string | null }): { data?: string | null };\n\tcacheSet(params: { key?: string | null; data?: string | null }): EmptyObject;\n\trouterPush(params: PathParams): EmptyObject;\n\trouterPop(params: EmptyObject): EmptyObject;\n\trouterGetCurrent(params: EmptyObject): PathParams;\n\tsetNavigationBarData(params: {\n\t\ttitle?: string | null;\n\t\tdescription?: string | null;\n\t}): EmptyObject;\n\trouterPresentSheet(params: PathParams): EmptyObject;\n\trouterDismissSheet(params: EmptyObject): EmptyObject;\n\trouterGetCurrentSheet(params: EmptyObject): PathParams | null | undefined;\n\tdowngradeToWebView(params: EmptyObject): EmptyObject;\n\tgetHostAppDetails(params: EmptyObject): {\n\t\tbuild: string;\n\t\tversion: string;\n\t\tplatform: \"ios\" | \"android\" | \"web\";\n\t\tbuildType: \"appstore\" | \"testflight\" | \"debug\";\n\t};\n}\n\nexport interface ExecAsyncApi extends ExecSyncApi {\n\tinAppPurchase(params: {\n\t\tid?: string | null;\n\t\tplanId: string;\n\t}): {\n\t\tsessionId: string;\n\t\treceiptId: string;\n\t};\n}\n\nexport function __internal_execSync<F extends keyof ExecSyncApi>(\n\tname: F,\n\tparams: Parameters<ExecSyncApi[F]>[0],\n): ReturnType<ExecSyncApi[F]> {\n\tconst resultJson = nativeWhopCore.execSync(name, JSON.stringify(params));\n\tif (!resultJson.isOk) {\n\t\tthrow new Error(`Failed to execute ${name}: ${resultJson.errorMessage}`);\n\t}\n\n\treturn JSON.parse(resultJson.data || \"{}\") as ReturnType<ExecSyncApi[F]>;\n}\n\nexport async function __internal_execAsync<F extends keyof ExecAsyncApi>(\n\tname: F,\n\tparams: Parameters<ExecAsyncApi[F]>[0],\n): Promise<ReturnType<ExecAsyncApi[F]>> {\n\tconst resultJson = await nativeWhopCore.execAsync(\n\t\tname,\n\t\tJSON.stringify(params),\n\t);\n\n\tif (!resultJson.isOk) {\n\t\tthrow new Error(`Failed to execute ${name}: ${resultJson.errorMessage}`);\n\t}\n\n\treturn JSON.parse(resultJson.data || \"{}\") as ReturnType<ExecAsyncApi[F]>;\n}\n","/**\n * Web-safe wrapper for react-native-haptic-feedback.\n * - Lazily imports the native module only in native environments.\n * - Provides a no-op fallback on web to avoid runtime crashes.\n */\n\ntype HapticType =\n\t| \"selection\"\n\t| \"impactLight\"\n\t| \"impactMedium\"\n\t| \"impactHeavy\"\n\t| \"notificationSuccess\"\n\t| \"notificationWarning\"\n\t| \"notificationError\";\n\ntype HapticOptions = {\n\tenableVibrateFallback?: boolean;\n\tignoreAndroidSystemSettings?: boolean;\n};\n\n// Singleton holder for the native module once loaded\nlet nativeModule: {\n\ttrigger: (type: HapticType, options?: HapticOptions) => void;\n} | null = null;\nlet loadingPromise: Promise<void> | null = null;\n\nasync function ensureNativeLoaded(): Promise<void> {\n\t// If on web, skip loading entirely\n\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t// @ts-ignore - process may not be typed in RN web builds\n\tconst isWeb =\n\t\ttypeof document !== \"undefined\" && typeof window !== \"undefined\";\n\tif (isWeb) return;\n\n\tif (nativeModule || loadingPromise) {\n\t\treturn loadingPromise ?? Promise.resolve();\n\t}\n\n\tloadingPromise = import(\"react-native-haptic-feedback\")\n\t\t.then((mod) => {\n\t\t\tnativeModule = { trigger: mod.default.trigger };\n\t\t})\n\t\t.catch(() => {\n\t\t\t// Keep nativeModule null; fall back to noop\n\t\t})\n\t\t.finally(() => {\n\t\t\tloadingPromise = null;\n\t\t});\n\n\treturn loadingPromise;\n}\n\nconst HAPTIC_NOOP = {\n\ttrigger: (_type: HapticType, _options?: HapticOptions) => {\n\t\t// no-op on web\n\t},\n};\n\nconst Haptics = {\n\tasync trigger(type: HapticType, options?: HapticOptions): Promise<void> {\n\t\tawait ensureNativeLoaded();\n\t\tif (nativeModule) {\n\t\t\ttry {\n\t\t\t\tnativeModule.trigger(type, options);\n\t\t\t} catch {\n\t\t\t\t// ignore\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tHAPTIC_NOOP.trigger(type, options);\n\t},\n};\n\nexport default Haptics;\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA,SAAS,qBAAqB;AAC9B,SAAS,YAAAA,iBAAgB;;;ACAzB,SAAS,2BAA2B;;;ACDpC,SAAS,gBAAgB;AAWzB,IAAM,qBAAN,MAA4B;AAAA,EACnB,cAAuC,oBAAI,IAAI;AAAA,EAC/C;AAAA,EAER,YAAY,OAAU;AACrB,SAAK,QAAQ;AAAA,EACd;AAAA,EAEA,SAAS,OAAU;AAClB,SAAK,QAAQ;AACb,eAAW,YAAY,KAAK,aAAa;AACxC,eAAS,KAAK;AAAA,IACf;AAAA,EACD;AAAA,EAEA,WAAW;AACV,WAAO,KAAK;AAAA,EACb;AAAA,EAEA,UAAU,UAA8B;AACvC,SAAK,YAAY,IAAI,QAAQ;AAC7B,WAAO,MAAM;AACZ,WAAK,YAAY,OAAO,QAAQ;AAAA,IACjC;AAAA,EACD;AACD;AAEA,IAAM,qBAAN,MAAyB;AAAA,EACjB,OAAO,IAAI,mBAA4B,CAAC,CAAC;AAAA,EACzC,QAAQ,IAAI,mBAAiC,IAAI;AAAA,EAExD,cAAc;AACb,SAAK,eAAe,KAAK,aAAa,KAAK,IAAI;AAC/C,SAAK,kBAAkB,KAAK,gBAAgB,KAAK,IAAI;AACrD,SAAK,kBAAkB,KAAK,gBAAgB,KAAK,IAAI;AACrD,SAAK,mBAAmB,KAAK,iBAAiB,KAAK,IAAI;AAAA,EACxD;AAAA,EAEA,KAAK,OAAc;AAClB,QAAI,KAAK,WAAW,EAAE,KAAK,KAAK,GAAG,MAAM,MAAM,KAAK,KAAK,GAAG,GAAG;AAC9D;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I,eAEO;AACX,IAAI,iBAAuC;AAE3C,eAAe,qBAAoC;AAIlD,QAAM,QACL,OAAO,aAAa,eAAe,OAAO,WAAW;AACtD,MAAI,MAAO;AAEX,MAAI,gBAAgB,gBAAgB;AACnC,WAAO,kBAAkB,QAAQ,QAAQ;AAAA,EAC1C;AAEA,mBAAiB,OAAO,8BAA8B,EACpD,KAAK,CAAC,QAAQ;AACd,mBAAe,EAAE,SAAS,IAAI,QAAQ,QAAQ;AAAA,EAC/C,CAAC,EACA,MAAM,MAAM;AAAA,EAEb,CAAC,EACA,QAAQ,MAAM;AACd,qBAAiB;AAAA,EAClB,CAAC;AAEF,SAAO;AACR;AAEA,IAAM,cAAc;AAAA,EACnB,SAAS,CAAC,OAAmB,aAA6B;AAAA,EAE1D;AACD;AAEA,IAAM,UAAU;AAAA,EACf,MAAM,QAAQ,MAAkB,SAAwC;AACvE,UAAM,mBAAmB;AACzB,QAAI,cAAc;AACjB,UAAI;AACH,qBAAa,QAAQ,MAAM,OAAO;AAAA,MACnC,QAAQ;AAAA,MAER;AACA;AAAA,IACD;AACA,gBAAY,QAAQ,MAAM,OAAO;AAAA,EAClC;AACD;AAEA,IAAO,kBAAQ;","names":["Platform","Platform"]}
|
package/dist/lib/web.mjs
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
// src/lib/web-router.ts
|
|
2
|
+
function getNavigation() {
|
|
3
|
+
const anyWindow = window;
|
|
4
|
+
if (typeof anyWindow !== "undefined" && anyWindow.whopCoreNavigation) {
|
|
5
|
+
return anyWindow.whopCoreNavigation;
|
|
6
|
+
}
|
|
7
|
+
throw new Error(
|
|
8
|
+
"window.whopCoreNavigation is not defined. this method is only available in a web build"
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
function parseQueryParams() {
|
|
12
|
+
const params = new URLSearchParams(window.location.search);
|
|
13
|
+
const experienceId = params.get("experienceId");
|
|
14
|
+
const companyId = params.get("companyId");
|
|
15
|
+
const currentUserId = params.get("currentUserId");
|
|
16
|
+
const restPath = params.get("restPath");
|
|
17
|
+
const queryStr = params.get("query");
|
|
18
|
+
let path = [];
|
|
19
|
+
if (restPath) path = restPath.split("/").filter(Boolean);
|
|
20
|
+
const appParams = {};
|
|
21
|
+
if (queryStr) {
|
|
22
|
+
const obj = new URLSearchParams(queryStr);
|
|
23
|
+
for (const [key, value] of obj.entries()) {
|
|
24
|
+
appParams[key] = value;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
experienceId,
|
|
29
|
+
companyId,
|
|
30
|
+
currentUserId,
|
|
31
|
+
path,
|
|
32
|
+
params: appParams
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function usePath(R, initialPath, initialParams) {
|
|
36
|
+
const navigation = getNavigation();
|
|
37
|
+
const path = R.useSyncExternalStore(
|
|
38
|
+
navigation.subscribeToPath,
|
|
39
|
+
navigation.getFullStack
|
|
40
|
+
);
|
|
41
|
+
const route = path.at(path.length - 1);
|
|
42
|
+
const actualPath = route ?? { path: initialPath, params: initialParams };
|
|
43
|
+
return actualPath;
|
|
44
|
+
}
|
|
45
|
+
function useSheet(R) {
|
|
46
|
+
const navigation = getNavigation();
|
|
47
|
+
const sheet = R.useSyncExternalStore(
|
|
48
|
+
navigation.subscribeToSheet,
|
|
49
|
+
navigation.getCurrentSheet
|
|
50
|
+
);
|
|
51
|
+
return sheet;
|
|
52
|
+
}
|
|
53
|
+
function WhopNavigationWrapper(R, name, Component) {
|
|
54
|
+
const {
|
|
55
|
+
experienceId,
|
|
56
|
+
companyId,
|
|
57
|
+
currentUserId,
|
|
58
|
+
path: initialPath,
|
|
59
|
+
params
|
|
60
|
+
} = parseQueryParams();
|
|
61
|
+
const ModalComponent = makeModalComponent(R);
|
|
62
|
+
let render;
|
|
63
|
+
if (name === "ExperienceView") {
|
|
64
|
+
if (!experienceId || !companyId) {
|
|
65
|
+
throw new Error("Missing required query params");
|
|
66
|
+
}
|
|
67
|
+
const C = Component;
|
|
68
|
+
render = (route) => {
|
|
69
|
+
return R.createElement(C, {
|
|
70
|
+
experienceId,
|
|
71
|
+
companyId,
|
|
72
|
+
currentUserId,
|
|
73
|
+
path: route.path,
|
|
74
|
+
params: route.params
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (name === "DiscoverView") {
|
|
79
|
+
const C = Component;
|
|
80
|
+
render = (route) => {
|
|
81
|
+
return R.createElement(C, {
|
|
82
|
+
currentUserId,
|
|
83
|
+
path: route.path,
|
|
84
|
+
params: route.params
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return function AppWrapper() {
|
|
89
|
+
const path = usePath(R, initialPath, params);
|
|
90
|
+
const sheet = useSheet(R);
|
|
91
|
+
const sheetElement = R.createElement(ModalComponent, {
|
|
92
|
+
route: sheet,
|
|
93
|
+
render
|
|
94
|
+
});
|
|
95
|
+
return R.createElement(R.Fragment, null, [render(path), sheetElement]);
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function makeModalComponent(R) {
|
|
99
|
+
const STYLE_ID = "whop-rn-modal-styles";
|
|
100
|
+
const ANIMATION_MS = 220;
|
|
101
|
+
function ensureStylesInjected() {
|
|
102
|
+
if (typeof document === "undefined") return;
|
|
103
|
+
if (document.getElementById(STYLE_ID)) return;
|
|
104
|
+
const styleEl = document.createElement("style");
|
|
105
|
+
styleEl.id = STYLE_ID;
|
|
106
|
+
styleEl.textContent = `
|
|
107
|
+
.whop-rn-modal-overlay{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,0.45);opacity:0;pointer-events:none;transition:opacity ${ANIMATION_MS}ms ease;z-index:2147483647}
|
|
108
|
+
.whop-rn-modal-overlay.open{opacity:1;pointer-events:auto}
|
|
109
|
+
.whop-rn-modal-panel{background:var(--modal-bg,#fff);color:var(--modal-fg,#111);border-radius:12px;box-shadow:0 10px 30px rgba(0,0,0,0.2);max-width:min(calc(100vw - 32px),720px);width:100%;max-height:min(calc(100vh - 32px),85vh);overflow:auto;transform:translateY(8px) scale(0.98);opacity:0.98;transition:transform ${ANIMATION_MS + 20}ms ease,opacity ${ANIMATION_MS + 20}ms ease}
|
|
110
|
+
.whop-rn-modal-overlay.open .whop-rn-modal-panel{transform:translateY(0) scale(1);opacity:1}
|
|
111
|
+
.whop-rn-modal-header{display:flex;justify-content:flex-end}
|
|
112
|
+
.whop-rn-modal-close{height:36px;width:36px;display:inline-flex;align-items:center;justify-content:center;border:none;border-radius:8px;background:rgba(0,0,0,0.04);color:inherit;cursor:pointer;transition:background ${ANIMATION_MS}ms ease}
|
|
113
|
+
.whop-rn-modal-close:hover{background:rgba(0,0,0,0.08)}
|
|
114
|
+
.whop-rn-modal-close:focus{outline:2px solid rgba(59,130,246,0.6);outline-offset:2px}
|
|
115
|
+
.whop-rn-modal-panel-inner{padding:0}
|
|
116
|
+
@media (prefers-color-scheme: dark){.whop-rn-modal-panel{--modal-bg:#111416;--modal-fg:#e6e7e8;box-shadow:0 10px 30px rgba(0,0,0,0.7)}}
|
|
117
|
+
`;
|
|
118
|
+
document.head.appendChild(styleEl);
|
|
119
|
+
}
|
|
120
|
+
return function ModalComponent(props) {
|
|
121
|
+
const isOpen = !!props.route;
|
|
122
|
+
const [shouldRender, setShouldRender] = R.useState(isOpen);
|
|
123
|
+
const [isVisible, setIsVisible] = R.useState(isOpen);
|
|
124
|
+
const closeTimerRef = R.useRef(null);
|
|
125
|
+
const mostRecentRouteRef = R.useRef(null);
|
|
126
|
+
if (props.route) mostRecentRouteRef.current = props.route;
|
|
127
|
+
R.useEffect(() => {
|
|
128
|
+
ensureStylesInjected();
|
|
129
|
+
return () => {
|
|
130
|
+
if (closeTimerRef.current !== null) {
|
|
131
|
+
window.clearTimeout(closeTimerRef.current);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}, []);
|
|
135
|
+
R.useEffect(() => {
|
|
136
|
+
if (isOpen) {
|
|
137
|
+
setShouldRender(true);
|
|
138
|
+
window.requestAnimationFrame(() => setIsVisible(true));
|
|
139
|
+
if (closeTimerRef.current !== null) {
|
|
140
|
+
window.clearTimeout(closeTimerRef.current);
|
|
141
|
+
closeTimerRef.current = null;
|
|
142
|
+
}
|
|
143
|
+
} else if (shouldRender) {
|
|
144
|
+
setIsVisible(false);
|
|
145
|
+
if (closeTimerRef.current !== null) {
|
|
146
|
+
window.clearTimeout(closeTimerRef.current);
|
|
147
|
+
}
|
|
148
|
+
closeTimerRef.current = window.setTimeout(() => {
|
|
149
|
+
setShouldRender(false);
|
|
150
|
+
closeTimerRef.current = null;
|
|
151
|
+
}, ANIMATION_MS);
|
|
152
|
+
}
|
|
153
|
+
}, [isOpen, shouldRender]);
|
|
154
|
+
const overlayClass = isVisible ? "whop-rn-modal-overlay open" : "whop-rn-modal-overlay";
|
|
155
|
+
const dismiss = R.useCallback(() => {
|
|
156
|
+
try {
|
|
157
|
+
getNavigation().dismissSheet();
|
|
158
|
+
} catch {
|
|
159
|
+
}
|
|
160
|
+
}, []);
|
|
161
|
+
R.useEffect(() => {
|
|
162
|
+
if (!isOpen) return;
|
|
163
|
+
const onKeyDown = (e) => {
|
|
164
|
+
if (e.key === "Escape") dismiss();
|
|
165
|
+
};
|
|
166
|
+
document.addEventListener("keydown", onKeyDown);
|
|
167
|
+
return () => document.removeEventListener("keydown", onKeyDown);
|
|
168
|
+
}, [isOpen, dismiss]);
|
|
169
|
+
if (!shouldRender) return null;
|
|
170
|
+
const route = mostRecentRouteRef.current;
|
|
171
|
+
const panelInner = R.createElement(
|
|
172
|
+
"div",
|
|
173
|
+
{ className: "whop-rn-modal-panel-inner" },
|
|
174
|
+
[route ? props.render(route) : null]
|
|
175
|
+
);
|
|
176
|
+
const closeButton = R.createElement(
|
|
177
|
+
"button",
|
|
178
|
+
{
|
|
179
|
+
type: "button",
|
|
180
|
+
className: "whop-rn-modal-close",
|
|
181
|
+
"aria-label": "Close modal",
|
|
182
|
+
onClick: dismiss
|
|
183
|
+
},
|
|
184
|
+
"\xD7"
|
|
185
|
+
);
|
|
186
|
+
const header = R.createElement(
|
|
187
|
+
"div",
|
|
188
|
+
{ className: "whop-rn-modal-header" },
|
|
189
|
+
[closeButton]
|
|
190
|
+
);
|
|
191
|
+
const panel = R.createElement(
|
|
192
|
+
"div",
|
|
193
|
+
{ className: "whop-rn-modal-panel", role: "document" },
|
|
194
|
+
[header, panelInner]
|
|
195
|
+
);
|
|
196
|
+
const onOverlayClick = (e) => {
|
|
197
|
+
if (e.target === e.currentTarget) dismiss();
|
|
198
|
+
};
|
|
199
|
+
return R.createElement(
|
|
200
|
+
"div",
|
|
201
|
+
{
|
|
202
|
+
className: overlayClass,
|
|
203
|
+
role: "dialog",
|
|
204
|
+
"aria-modal": "true",
|
|
205
|
+
onClick: onOverlayClick
|
|
206
|
+
},
|
|
207
|
+
[panel]
|
|
208
|
+
);
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
export {
|
|
212
|
+
WhopNavigationWrapper
|
|
213
|
+
};
|
|
214
|
+
//# sourceMappingURL=web.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/web-router.ts"],"sourcesContent":["import type React from \"react\";\nimport type { FC } from \"react\";\nimport type { TWhopCoreNavigation } from \"./native-whop-core-stub\";\nimport type { DiscoverViewProps, ExperienceViewProps } from \"./props\";\n\ntype AppReactComponent = {\n\tExperienceView: FC<ExperienceViewProps>;\n\tDiscoverView: FC<DiscoverViewProps>;\n};\n\nfunction getNavigation(): TWhopCoreNavigation {\n\t// biome-ignore lint/suspicious/noExplicitAny: <explanation>\n\tconst anyWindow = window as any;\n\tif (typeof anyWindow !== \"undefined\" && anyWindow.whopCoreNavigation) {\n\t\treturn anyWindow.whopCoreNavigation;\n\t}\n\n\tthrow new Error(\n\t\t\"window.whopCoreNavigation is not defined. this method is only available in a web build\",\n\t);\n}\n\nfunction parseQueryParams() {\n\tconst params = new URLSearchParams(window.location.search);\n\tconst experienceId = params.get(\"experienceId\");\n\tconst companyId = params.get(\"companyId\");\n\tconst currentUserId = params.get(\"currentUserId\");\n\tconst restPath = params.get(\"restPath\");\n\tconst queryStr = params.get(\"query\");\n\n\tlet path: string[] = [];\n\tif (restPath) path = restPath.split(\"/\").filter(Boolean);\n\n\tconst appParams: Record<string, string> = {};\n\tif (queryStr) {\n\t\tconst obj = new URLSearchParams(queryStr);\n\t\tfor (const [key, value] of obj.entries()) {\n\t\t\tappParams[key] = value;\n\t\t}\n\t}\n\n\treturn {\n\t\texperienceId,\n\t\tcompanyId,\n\t\tcurrentUserId,\n\t\tpath,\n\t\tparams: appParams,\n\t};\n}\n\nfunction usePath(\n\tR: typeof React,\n\tinitialPath: string[],\n\tinitialParams: Record<string, string>,\n): { path: string[]; params: Record<string, string> } {\n\tconst navigation = getNavigation();\n\tconst path = R.useSyncExternalStore(\n\t\tnavigation.subscribeToPath,\n\t\tnavigation.getFullStack,\n\t);\n\tconst route = path.at(path.length - 1);\n\tconst actualPath = route ?? { path: initialPath, params: initialParams };\n\treturn actualPath;\n}\n\nfunction useSheet(R: typeof React) {\n\tconst navigation = getNavigation();\n\tconst sheet = R.useSyncExternalStore(\n\t\tnavigation.subscribeToSheet,\n\t\tnavigation.getCurrentSheet,\n\t);\n\treturn sheet;\n}\n\nexport function WhopNavigationWrapper<T extends keyof AppReactComponent>(\n\tR: typeof React,\n\tname: T,\n\tComponent: AppReactComponent[T],\n) {\n\tconst {\n\t\texperienceId,\n\t\tcompanyId,\n\t\tcurrentUserId,\n\t\tpath: initialPath,\n\t\tparams,\n\t} = parseQueryParams();\n\n\tconst ModalComponent = makeModalComponent(R);\n\n\tlet render: (route: {\n\t\tpath: string[];\n\t\tparams: Record<string, string>;\n\t}) => React.ReactNode;\n\n\tif (name === \"ExperienceView\") {\n\t\tif (!experienceId || !companyId) {\n\t\t\tthrow new Error(\"Missing required query params\");\n\t\t}\n\n\t\tconst C = Component as FC<ExperienceViewProps>;\n\n\t\trender = (route: {\n\t\t\tpath: string[];\n\t\t\tparams: Record<string, string>;\n\t\t}) => {\n\t\t\treturn R.createElement(C, {\n\t\t\t\texperienceId,\n\t\t\t\tcompanyId,\n\t\t\t\tcurrentUserId,\n\t\t\t\tpath: route.path,\n\t\t\t\tparams: route.params,\n\t\t\t});\n\t\t};\n\t}\n\n\tif (name === \"DiscoverView\") {\n\t\tconst C = Component as FC<DiscoverViewProps>;\n\t\trender = (route: {\n\t\t\tpath: string[];\n\t\t\tparams: Record<string, string>;\n\t\t}) => {\n\t\t\treturn R.createElement(C, {\n\t\t\t\tcurrentUserId,\n\t\t\t\tpath: route.path,\n\t\t\t\tparams: route.params,\n\t\t\t});\n\t\t};\n\t}\n\n\treturn function AppWrapper() {\n\t\tconst path = usePath(R, initialPath, params);\n\t\tconst sheet = useSheet(R);\n\t\tconst sheetElement = R.createElement(ModalComponent, {\n\t\t\troute: sheet,\n\t\t\trender,\n\t\t});\n\t\treturn R.createElement(R.Fragment, null, [render(path), sheetElement]);\n\t};\n}\n\nfunction makeModalComponent(R: typeof React) {\n\tconst STYLE_ID = \"whop-rn-modal-styles\";\n\tconst ANIMATION_MS = 220;\n\n\tfunction ensureStylesInjected() {\n\t\tif (typeof document === \"undefined\") return;\n\t\tif (document.getElementById(STYLE_ID)) return;\n\t\tconst styleEl = document.createElement(\"style\");\n\t\tstyleEl.id = STYLE_ID;\n\t\tstyleEl.textContent = `\n\t\t\t.whop-rn-modal-overlay{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,0.45);opacity:0;pointer-events:none;transition:opacity ${ANIMATION_MS}ms ease;z-index:2147483647}\n\t\t\t.whop-rn-modal-overlay.open{opacity:1;pointer-events:auto}\n\t\t\t.whop-rn-modal-panel{background:var(--modal-bg,#fff);color:var(--modal-fg,#111);border-radius:12px;box-shadow:0 10px 30px rgba(0,0,0,0.2);max-width:min(calc(100vw - 32px),720px);width:100%;max-height:min(calc(100vh - 32px),85vh);overflow:auto;transform:translateY(8px) scale(0.98);opacity:0.98;transition:transform ${ANIMATION_MS + 20}ms ease,opacity ${ANIMATION_MS + 20}ms ease}\n\t\t\t.whop-rn-modal-overlay.open .whop-rn-modal-panel{transform:translateY(0) scale(1);opacity:1}\n\t\t\t.whop-rn-modal-header{display:flex;justify-content:flex-end}\n\t\t\t.whop-rn-modal-close{height:36px;width:36px;display:inline-flex;align-items:center;justify-content:center;border:none;border-radius:8px;background:rgba(0,0,0,0.04);color:inherit;cursor:pointer;transition:background ${ANIMATION_MS}ms ease}\n\t\t\t.whop-rn-modal-close:hover{background:rgba(0,0,0,0.08)}\n\t\t\t.whop-rn-modal-close:focus{outline:2px solid rgba(59,130,246,0.6);outline-offset:2px}\n\t\t\t.whop-rn-modal-panel-inner{padding:0}\n\t\t\t@media (prefers-color-scheme: dark){.whop-rn-modal-panel{--modal-bg:#111416;--modal-fg:#e6e7e8;box-shadow:0 10px 30px rgba(0,0,0,0.7)}}\n\t\t`;\n\t\tdocument.head.appendChild(styleEl);\n\t}\n\n\treturn function ModalComponent(props: {\n\t\troute:\n\t\t\t| {\n\t\t\t\t\tpath: string[];\n\t\t\t\t\tparams: Record<string, string>;\n\t\t\t }\n\t\t\t| undefined\n\t\t\t| null;\n\t\trender: (route: {\n\t\t\tpath: string[];\n\t\t\tparams: Record<string, string>;\n\t\t}) => React.ReactNode;\n\t}) {\n\t\t// Manage mount/unmount to allow exit animations\n\t\tconst isOpen = !!props.route;\n\t\tconst [shouldRender, setShouldRender] = R.useState<boolean>(isOpen);\n\t\tconst [isVisible, setIsVisible] = R.useState<boolean>(isOpen);\n\t\tconst closeTimerRef = R.useRef<number | null>(null);\n\t\tconst mostRecentRouteRef = R.useRef<{\n\t\t\tpath: string[];\n\t\t\tparams: Record<string, string>;\n\t\t} | null>(null);\n\n\t\tif (props.route) mostRecentRouteRef.current = props.route;\n\n\t\tR.useEffect(() => {\n\t\t\tensureStylesInjected();\n\t\t\treturn () => {\n\t\t\t\tif (closeTimerRef.current !== null) {\n\t\t\t\t\twindow.clearTimeout(closeTimerRef.current);\n\t\t\t\t}\n\t\t\t};\n\t\t}, []);\n\n\t\tR.useEffect(() => {\n\t\t\tif (isOpen) {\n\t\t\t\tsetShouldRender(true);\n\t\t\t\t// Ensure next frame so transitions apply\n\t\t\t\twindow.requestAnimationFrame(() => setIsVisible(true));\n\t\t\t\tif (closeTimerRef.current !== null) {\n\t\t\t\t\twindow.clearTimeout(closeTimerRef.current);\n\t\t\t\t\tcloseTimerRef.current = null;\n\t\t\t\t}\n\t\t\t} else if (shouldRender) {\n\t\t\t\tsetIsVisible(false);\n\t\t\t\tif (closeTimerRef.current !== null) {\n\t\t\t\t\twindow.clearTimeout(closeTimerRef.current);\n\t\t\t\t}\n\t\t\t\tcloseTimerRef.current = window.setTimeout(() => {\n\t\t\t\t\tsetShouldRender(false);\n\t\t\t\t\tcloseTimerRef.current = null;\n\t\t\t\t}, ANIMATION_MS);\n\t\t\t}\n\t\t}, [isOpen, shouldRender]);\n\n\t\tconst overlayClass = isVisible\n\t\t\t? \"whop-rn-modal-overlay open\"\n\t\t\t: \"whop-rn-modal-overlay\";\n\n\t\tconst dismiss = R.useCallback((): void => {\n\t\t\ttry {\n\t\t\t\tgetNavigation().dismissSheet();\n\t\t\t} catch {\n\t\t\t\t// no-op when navigation is not available\n\t\t\t}\n\t\t}, []);\n\n\t\tR.useEffect(() => {\n\t\t\tif (!isOpen) return;\n\t\t\tconst onKeyDown = (e: KeyboardEvent) => {\n\t\t\t\tif (e.key === \"Escape\") dismiss();\n\t\t\t};\n\t\t\tdocument.addEventListener(\"keydown\", onKeyDown);\n\t\t\treturn () => document.removeEventListener(\"keydown\", onKeyDown);\n\t\t}, [isOpen, dismiss]);\n\n\t\tif (!shouldRender) return null;\n\n\t\tconst route = mostRecentRouteRef.current;\n\n\t\tconst panelInner = R.createElement(\n\t\t\t\"div\",\n\t\t\t{ className: \"whop-rn-modal-panel-inner\" },\n\t\t\t[route ? props.render(route) : null],\n\t\t);\n\n\t\tconst closeButton = R.createElement(\n\t\t\t\"button\",\n\t\t\t{\n\t\t\t\ttype: \"button\",\n\t\t\t\tclassName: \"whop-rn-modal-close\",\n\t\t\t\t\"aria-label\": \"Close modal\",\n\t\t\t\tonClick: dismiss,\n\t\t\t},\n\t\t\t\"×\",\n\t\t);\n\n\t\tconst header = R.createElement(\n\t\t\t\"div\",\n\t\t\t{ className: \"whop-rn-modal-header\" },\n\t\t\t[closeButton],\n\t\t);\n\n\t\tconst panel = R.createElement(\n\t\t\t\"div\",\n\t\t\t{ className: \"whop-rn-modal-panel\", role: \"document\" },\n\t\t\t[header, panelInner],\n\t\t);\n\n\t\tconst onOverlayClick = (e: React.MouseEvent<HTMLDivElement>): void => {\n\t\t\tif (e.target === e.currentTarget) dismiss();\n\t\t};\n\n\t\treturn R.createElement(\n\t\t\t\"div\",\n\t\t\t{\n\t\t\t\tclassName: overlayClass,\n\t\t\t\trole: \"dialog\",\n\t\t\t\t\"aria-modal\": \"true\",\n\t\t\t\tonClick: onOverlayClick,\n\t\t\t},\n\t\t\t[panel],\n\t\t);\n\t};\n}\n"],"mappings":";AAUA,SAAS,gBAAqC;AAE7C,QAAM,YAAY;AAClB,MAAI,OAAO,cAAc,eAAe,UAAU,oBAAoB;AACrE,WAAO,UAAU;AAAA,EAClB;AAEA,QAAM,IAAI;AAAA,IACT;AAAA,EACD;AACD;AAEA,SAAS,mBAAmB;AAC3B,QAAM,SAAS,IAAI,gBAAgB,OAAO,SAAS,MAAM;AACzD,QAAM,eAAe,OAAO,IAAI,cAAc;AAC9C,QAAM,YAAY,OAAO,IAAI,WAAW;AACxC,QAAM,gBAAgB,OAAO,IAAI,eAAe;AAChD,QAAM,WAAW,OAAO,IAAI,UAAU;AACtC,QAAM,WAAW,OAAO,IAAI,OAAO;AAEnC,MAAI,OAAiB,CAAC;AACtB,MAAI,SAAU,QAAO,SAAS,MAAM,GAAG,EAAE,OAAO,OAAO;AAEvD,QAAM,YAAoC,CAAC;AAC3C,MAAI,UAAU;AACb,UAAM,M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