@whop/react-native 0.1.9 → 0.1.11
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/lib/index.js +60 -11
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +60 -11
- package/dist/lib/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/lib/index.js
CHANGED
|
@@ -75,25 +75,39 @@ var WhopCoreObservable = class {
|
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
var WhopCoreNavigation = class {
|
|
78
|
-
path = new WhopCoreObservable(
|
|
78
|
+
path = new WhopCoreObservable({
|
|
79
|
+
stack: [],
|
|
80
|
+
currentIndex: 0
|
|
81
|
+
});
|
|
79
82
|
sheet = new WhopCoreObservable(null);
|
|
80
83
|
constructor() {
|
|
81
84
|
this.getFullStack = this.getFullStack.bind(this);
|
|
82
85
|
this.getCurrentSheet = this.getCurrentSheet.bind(this);
|
|
83
86
|
this.subscribeToPath = this.subscribeToPath.bind(this);
|
|
84
87
|
this.subscribeToSheet = this.subscribeToSheet.bind(this);
|
|
88
|
+
this.path.subscribe((value) => {
|
|
89
|
+
loadIframeSdk().then(
|
|
90
|
+
(sdk) => sdk.onNavigationStackChange({
|
|
91
|
+
stack: value.stack,
|
|
92
|
+
currentIndex: value.currentIndex
|
|
93
|
+
})
|
|
94
|
+
).catch(() => {
|
|
95
|
+
});
|
|
96
|
+
});
|
|
85
97
|
}
|
|
86
98
|
push(route) {
|
|
87
99
|
if (this.getCurrent().path.join("/") === route.path.join("/")) {
|
|
88
100
|
return;
|
|
89
101
|
}
|
|
90
|
-
this.path.
|
|
102
|
+
const { stack } = this.path.getValue();
|
|
103
|
+
const newStack = [...stack, route];
|
|
104
|
+
this.path.setValue({ stack: newStack, currentIndex: newStack.length - 1 });
|
|
91
105
|
if (typeof window !== "undefined" && window.history) {
|
|
92
106
|
try {
|
|
93
107
|
const pathBits = route.path.join("/");
|
|
94
108
|
const paramsBits = Object.entries(route.params).map(([key, value]) => `${key}=${value}`).join("&");
|
|
95
109
|
window.history.pushState(
|
|
96
|
-
{ route, index:
|
|
110
|
+
{ route, index: newStack.length },
|
|
97
111
|
"",
|
|
98
112
|
`#${pathBits}?${paramsBits}`
|
|
99
113
|
);
|
|
@@ -102,18 +116,26 @@ var WhopCoreNavigation = class {
|
|
|
102
116
|
}
|
|
103
117
|
}
|
|
104
118
|
pop() {
|
|
119
|
+
if (!this.canPop()) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
105
122
|
if (typeof window !== "undefined" && window.history) {
|
|
106
123
|
try {
|
|
107
124
|
window.history.back();
|
|
108
125
|
} catch {
|
|
109
126
|
}
|
|
110
127
|
}
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
canPop() {
|
|
131
|
+
return this.path.getValue().stack.length > 0;
|
|
111
132
|
}
|
|
112
133
|
getFullStack() {
|
|
113
|
-
return this.path.getValue();
|
|
134
|
+
return this.path.getValue().stack;
|
|
114
135
|
}
|
|
115
136
|
getCurrent() {
|
|
116
|
-
|
|
137
|
+
const { stack } = this.path.getValue();
|
|
138
|
+
return stack[stack.length - 1] ?? {
|
|
117
139
|
path: [],
|
|
118
140
|
params: {}
|
|
119
141
|
};
|
|
@@ -128,7 +150,7 @@ var WhopCoreNavigation = class {
|
|
|
128
150
|
return this.sheet.getValue() ?? null;
|
|
129
151
|
}
|
|
130
152
|
subscribeToPath(callback) {
|
|
131
|
-
return this.path.subscribe(callback);
|
|
153
|
+
return this.path.subscribe((value) => callback(value.stack));
|
|
132
154
|
}
|
|
133
155
|
subscribeToSheet(callback) {
|
|
134
156
|
return this.sheet.subscribe(callback);
|
|
@@ -138,17 +160,30 @@ var navigation = new WhopCoreNavigation();
|
|
|
138
160
|
if (typeof window !== "undefined" && import_react_native.Platform.OS === "web") {
|
|
139
161
|
window.whopCoreNavigation = navigation;
|
|
140
162
|
window.addEventListener("popstate", (e) => {
|
|
141
|
-
const
|
|
163
|
+
const { stack: currentStack, currentIndex } = navigation.path.getValue();
|
|
164
|
+
const currentLength = currentStack.length;
|
|
142
165
|
if (!e.state) {
|
|
143
|
-
|
|
166
|
+
const newStack = currentStack.slice(0, -1);
|
|
167
|
+
navigation.path.setValue({
|
|
168
|
+
stack: newStack,
|
|
169
|
+
currentIndex: Math.max(0, currentIndex - 1)
|
|
170
|
+
});
|
|
144
171
|
return;
|
|
145
172
|
}
|
|
146
173
|
const index = e.state.index;
|
|
147
174
|
const route = e.state.route;
|
|
148
175
|
if (index < currentLength) {
|
|
149
|
-
|
|
176
|
+
const newStack = currentStack.slice(0, -1);
|
|
177
|
+
navigation.path.setValue({
|
|
178
|
+
stack: newStack,
|
|
179
|
+
currentIndex: Math.max(0, currentIndex - 1)
|
|
180
|
+
});
|
|
150
181
|
} else {
|
|
151
|
-
|
|
182
|
+
const newStack = [...currentStack, route];
|
|
183
|
+
navigation.path.setValue({
|
|
184
|
+
stack: newStack,
|
|
185
|
+
currentIndex: newStack.length - 1
|
|
186
|
+
});
|
|
152
187
|
}
|
|
153
188
|
});
|
|
154
189
|
}
|
|
@@ -256,8 +291,22 @@ async function loadIframeSdk() {
|
|
|
256
291
|
const module2 = await loadIframeModule();
|
|
257
292
|
iframeSdk = module2.createSdk({
|
|
258
293
|
appId: process.env.NEXT_PUBLIC_WHOP_APP_ID,
|
|
259
|
-
overrideParentOrigins: ["https://whop.com", "http://localhost:8004"]
|
|
294
|
+
overrideParentOrigins: ["https://whop.com", "http://localhost:8004"],
|
|
295
|
+
onMessage: {
|
|
296
|
+
navigateBack: () => {
|
|
297
|
+
navigation.pop();
|
|
298
|
+
return "ok";
|
|
299
|
+
}
|
|
300
|
+
}
|
|
260
301
|
});
|
|
302
|
+
const { stack, currentIndex } = navigation.path.getValue();
|
|
303
|
+
if (stack.length > 0) {
|
|
304
|
+
iframeSdk.onNavigationStackChange({
|
|
305
|
+
stack,
|
|
306
|
+
currentIndex
|
|
307
|
+
}).catch(() => {
|
|
308
|
+
});
|
|
309
|
+
}
|
|
261
310
|
}
|
|
262
311
|
return iframeSdk;
|
|
263
312
|
}
|
package/dist/lib/index.js.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-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 Whop from \"@whop/sdk\";\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 = new Whop({\n\tapiKey: \"client\",\n\tappID: \"client\",\n\tbaseURL: new URL(\"/_whop/api/v1/\", appOrigin).href,\n});\n\nexport * from \"@whop/sdk\";\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) {\n\t\tif (route.origin) {\n\t\t\tconst path = `/${route.path.join(\"/\")}`;\n\t\t\tconst url = new URL(path, route.origin);\n\t\t\tfor (const [k, v] of Object.entries(route.params ?? {})) {\n\t\t\t\turl.searchParams.set(k, v);\n\t\t\t}\n\t\t\tloadIframeSdk().then((sdk) => sdk.openExternalUrl({ url: url.href }));\n\t\t} else {\n\t\t\tnavigation.push(route);\n\t\t}\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\tsetScreenOrientationMode() {\n\t\treturn {};\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\toverrideParentOrigins: [\"https://whop.com\", \"http://localhost:8004\"],\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, PathParamsWithOrigin } 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: PathParamsWithOrigin): 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\tsetScreenOrientationMode(params: {\n\t\ttargetScreenOrientationMode: \"portrait\" | \"landscape\" | \"rotate\";\n\t}): EmptyObject;\n}\n\nexport interface ExecAsyncApi extends ExecSyncApi {\n\tinAppPurchase(params: { id?: string | null; planId: string }): {\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;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA,iBAAiB;AACjB,IAAAA,uBAAyB;;;ACAzB,IAAAC,uBAAoC;;;ACDpC,0BAAyB;AAWzB,IAAM,qBAAN,MAA4B;AAAA,EACnB,cAAuC,oBAAI,IAAI;AAAA,EAC/C;AAAA,EAER,YAAY,OAAU;AACrB,SAAK,QAAQ;AAAA,EACd;AAAA,EAEA,SAAS,OA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Ad;;;AKqBA,IAAI,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":["import_react_native","import_react_native","module","Whop"]}
|
|
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 Whop from \"@whop/sdk\";\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 = new Whop({\n\tapiKey: \"client\",\n\tappID: \"client\",\n\tbaseURL: new URL(\"/_whop/api/v1/\", appOrigin).href,\n});\n\nexport * from \"@whop/sdk\";\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<{\n\t\tstack: Route[];\n\t\tcurrentIndex: number;\n\t}>({\n\t\tstack: [],\n\t\tcurrentIndex: 0,\n\t});\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\n\t\t// Subscribe to path changes and emit to SDK\n\t\tthis.path.subscribe((value) => {\n\t\t\tloadIframeSdk()\n\t\t\t\t.then((sdk) =>\n\t\t\t\t\tsdk.onNavigationStackChange({\n\t\t\t\t\t\tstack: value.stack,\n\t\t\t\t\t\tcurrentIndex: value.currentIndex,\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\t.catch(() => {});\n\t\t});\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\tconst { stack } = this.path.getValue();\n\t\tconst newStack = [...stack, route];\n\t\tthis.path.setValue({ stack: newStack, currentIndex: newStack.length - 1 });\n\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: newStack.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(): boolean {\n\t\tif (!this.canPop()) {\n\t\t\treturn false;\n\t\t}\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\treturn true;\n\t}\n\n\tcanPop(): boolean {\n\t\treturn this.path.getValue().stack.length > 0;\n\t}\n\n\tgetFullStack() {\n\t\treturn this.path.getValue().stack;\n\t}\n\n\tgetCurrent() {\n\t\tconst { stack } = this.path.getValue();\n\t\treturn (\n\t\t\tstack[stack.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((value) => callback(value.stack));\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 { stack: currentStack, currentIndex } = navigation.path.getValue();\n\t\tconst currentLength = currentStack.length;\n\n\t\tif (!e.state) {\n\t\t\t// Browser back with no state - pop from stack\n\t\t\tconst newStack = currentStack.slice(0, -1);\n\t\t\tnavigation.path.setValue({\n\t\t\t\tstack: newStack,\n\t\t\t\tcurrentIndex: Math.max(0, currentIndex - 1),\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst index = e.state.index;\n\t\tconst route = e.state.route;\n\n\t\tif (index < currentLength) {\n\t\t\t// Going back\n\t\t\tconst newStack = currentStack.slice(0, -1);\n\t\t\tnavigation.path.setValue({\n\t\t\t\tstack: newStack,\n\t\t\t\tcurrentIndex: Math.max(0, currentIndex - 1),\n\t\t\t});\n\t\t} else {\n\t\t\t// Going forward\n\t\t\tconst newStack = [...currentStack, route];\n\t\t\tnavigation.path.setValue({\n\t\t\t\tstack: newStack,\n\t\t\t\tcurrentIndex: newStack.length - 1,\n\t\t\t});\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) {\n\t\tif (route.origin) {\n\t\t\tconst path = `/${route.path.join(\"/\")}`;\n\t\t\tconst url = new URL(path, route.origin);\n\t\t\tfor (const [k, v] of Object.entries(route.params ?? {})) {\n\t\t\t\turl.searchParams.set(k, v);\n\t\t\t}\n\t\t\tloadIframeSdk().then((sdk) => sdk.openExternalUrl({ url: url.href }));\n\t\t} else {\n\t\t\tnavigation.push(route);\n\t\t}\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\tsetScreenOrientationMode() {\n\t\treturn {};\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\toverrideParentOrigins: [\"https://whop.com\", \"http://localhost:8004\"],\n\t\t\tonMessage: {\n\t\t\t\tnavigateBack: () => {\n\t\t\t\t\tnavigation.pop();\n\t\t\t\t\treturn \"ok\" as const;\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\t// Emit initial stack state after SDK is ready\n\t\tconst { stack, currentIndex } = navigation.path.getValue();\n\t\tif (stack.length > 0) {\n\t\t\tiframeSdk\n\t\t\t\t.onNavigationStackChange({\n\t\t\t\t\tstack,\n\t\t\t\t\tcurrentIndex,\n\t\t\t\t})\n\t\t\t\t.catch(() => {});\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, PathParamsWithOrigin } 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: PathParamsWithOrigin): 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\tsetScreenOrientationMode(params: {\n\t\ttargetScreenOrientationMode: \"portrait\" | \"landscape\" | \"rotate\";\n\t}): EmptyObject;\n}\n\nexport interface ExecAsyncApi extends ExecSyncApi {\n\tinAppPurchase(params: { id?: string | null; planId: string }): {\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;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA,iBAAiB;AACjB,IAAAA,uBAAyB;;;ACAzB,IAAAC,uBAAoC;;;ACDpC,0BAAyB;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,mBAGf;AAAA,IACF,OAAO,CAAC;AAAA,IACR,cAAc;AAAA,EACf,CAAC;AAAA,EACM,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,mBAAm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AAQ;","names":["import_react_native","import_react_native","module","Whop"]}
|
package/dist/lib/index.mjs
CHANGED
|
@@ -49,25 +49,39 @@ var WhopCoreObservable = class {
|
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
var WhopCoreNavigation = class {
|
|
52
|
-
path = new WhopCoreObservable(
|
|
52
|
+
path = new WhopCoreObservable({
|
|
53
|
+
stack: [],
|
|
54
|
+
currentIndex: 0
|
|
55
|
+
});
|
|
53
56
|
sheet = new WhopCoreObservable(null);
|
|
54
57
|
constructor() {
|
|
55
58
|
this.getFullStack = this.getFullStack.bind(this);
|
|
56
59
|
this.getCurrentSheet = this.getCurrentSheet.bind(this);
|
|
57
60
|
this.subscribeToPath = this.subscribeToPath.bind(this);
|
|
58
61
|
this.subscribeToSheet = this.subscribeToSheet.bind(this);
|
|
62
|
+
this.path.subscribe((value) => {
|
|
63
|
+
loadIframeSdk().then(
|
|
64
|
+
(sdk) => sdk.onNavigationStackChange({
|
|
65
|
+
stack: value.stack,
|
|
66
|
+
currentIndex: value.currentIndex
|
|
67
|
+
})
|
|
68
|
+
).catch(() => {
|
|
69
|
+
});
|
|
70
|
+
});
|
|
59
71
|
}
|
|
60
72
|
push(route) {
|
|
61
73
|
if (this.getCurrent().path.join("/") === route.path.join("/")) {
|
|
62
74
|
return;
|
|
63
75
|
}
|
|
64
|
-
this.path.
|
|
76
|
+
const { stack } = this.path.getValue();
|
|
77
|
+
const newStack = [...stack, route];
|
|
78
|
+
this.path.setValue({ stack: newStack, currentIndex: newStack.length - 1 });
|
|
65
79
|
if (typeof window !== "undefined" && window.history) {
|
|
66
80
|
try {
|
|
67
81
|
const pathBits = route.path.join("/");
|
|
68
82
|
const paramsBits = Object.entries(route.params).map(([key, value]) => `${key}=${value}`).join("&");
|
|
69
83
|
window.history.pushState(
|
|
70
|
-
{ route, index:
|
|
84
|
+
{ route, index: newStack.length },
|
|
71
85
|
"",
|
|
72
86
|
`#${pathBits}?${paramsBits}`
|
|
73
87
|
);
|
|
@@ -76,18 +90,26 @@ var WhopCoreNavigation = class {
|
|
|
76
90
|
}
|
|
77
91
|
}
|
|
78
92
|
pop() {
|
|
93
|
+
if (!this.canPop()) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
79
96
|
if (typeof window !== "undefined" && window.history) {
|
|
80
97
|
try {
|
|
81
98
|
window.history.back();
|
|
82
99
|
} catch {
|
|
83
100
|
}
|
|
84
101
|
}
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
canPop() {
|
|
105
|
+
return this.path.getValue().stack.length > 0;
|
|
85
106
|
}
|
|
86
107
|
getFullStack() {
|
|
87
|
-
return this.path.getValue();
|
|
108
|
+
return this.path.getValue().stack;
|
|
88
109
|
}
|
|
89
110
|
getCurrent() {
|
|
90
|
-
|
|
111
|
+
const { stack } = this.path.getValue();
|
|
112
|
+
return stack[stack.length - 1] ?? {
|
|
91
113
|
path: [],
|
|
92
114
|
params: {}
|
|
93
115
|
};
|
|
@@ -102,7 +124,7 @@ var WhopCoreNavigation = class {
|
|
|
102
124
|
return this.sheet.getValue() ?? null;
|
|
103
125
|
}
|
|
104
126
|
subscribeToPath(callback) {
|
|
105
|
-
return this.path.subscribe(callback);
|
|
127
|
+
return this.path.subscribe((value) => callback(value.stack));
|
|
106
128
|
}
|
|
107
129
|
subscribeToSheet(callback) {
|
|
108
130
|
return this.sheet.subscribe(callback);
|
|
@@ -112,17 +134,30 @@ var navigation = new WhopCoreNavigation();
|
|
|
112
134
|
if (typeof window !== "undefined" && Platform.OS === "web") {
|
|
113
135
|
window.whopCoreNavigation = navigation;
|
|
114
136
|
window.addEventListener("popstate", (e) => {
|
|
115
|
-
const
|
|
137
|
+
const { stack: currentStack, currentIndex } = navigation.path.getValue();
|
|
138
|
+
const currentLength = currentStack.length;
|
|
116
139
|
if (!e.state) {
|
|
117
|
-
|
|
140
|
+
const newStack = currentStack.slice(0, -1);
|
|
141
|
+
navigation.path.setValue({
|
|
142
|
+
stack: newStack,
|
|
143
|
+
currentIndex: Math.max(0, currentIndex - 1)
|
|
144
|
+
});
|
|
118
145
|
return;
|
|
119
146
|
}
|
|
120
147
|
const index = e.state.index;
|
|
121
148
|
const route = e.state.route;
|
|
122
149
|
if (index < currentLength) {
|
|
123
|
-
|
|
150
|
+
const newStack = currentStack.slice(0, -1);
|
|
151
|
+
navigation.path.setValue({
|
|
152
|
+
stack: newStack,
|
|
153
|
+
currentIndex: Math.max(0, currentIndex - 1)
|
|
154
|
+
});
|
|
124
155
|
} else {
|
|
125
|
-
|
|
156
|
+
const newStack = [...currentStack, route];
|
|
157
|
+
navigation.path.setValue({
|
|
158
|
+
stack: newStack,
|
|
159
|
+
currentIndex: newStack.length - 1
|
|
160
|
+
});
|
|
126
161
|
}
|
|
127
162
|
});
|
|
128
163
|
}
|
|
@@ -230,8 +265,22 @@ async function loadIframeSdk() {
|
|
|
230
265
|
const module = await loadIframeModule();
|
|
231
266
|
iframeSdk = module.createSdk({
|
|
232
267
|
appId: process.env.NEXT_PUBLIC_WHOP_APP_ID,
|
|
233
|
-
overrideParentOrigins: ["https://whop.com", "http://localhost:8004"]
|
|
268
|
+
overrideParentOrigins: ["https://whop.com", "http://localhost:8004"],
|
|
269
|
+
onMessage: {
|
|
270
|
+
navigateBack: () => {
|
|
271
|
+
navigation.pop();
|
|
272
|
+
return "ok";
|
|
273
|
+
}
|
|
274
|
+
}
|
|
234
275
|
});
|
|
276
|
+
const { stack, currentIndex } = navigation.path.getValue();
|
|
277
|
+
if (stack.length > 0) {
|
|
278
|
+
iframeSdk.onNavigationStackChange({
|
|
279
|
+
stack,
|
|
280
|
+
currentIndex
|
|
281
|
+
}).catch(() => {
|
|
282
|
+
});
|
|
283
|
+
}
|
|
235
284
|
}
|
|
236
285
|
return iframeSdk;
|
|
237
286
|
}
|
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-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 Whop from \"@whop/sdk\";\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 = new Whop({\n\tapiKey: \"client\",\n\tappID: \"client\",\n\tbaseURL: new URL(\"/_whop/api/v1/\", appOrigin).href,\n});\n\nexport * from \"@whop/sdk\";\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) {\n\t\tif (route.origin) {\n\t\t\tconst path = `/${route.path.join(\"/\")}`;\n\t\t\tconst url = new URL(path, route.origin);\n\t\t\tfor (const [k, v] of Object.entries(route.params ?? {})) {\n\t\t\t\turl.searchParams.set(k, v);\n\t\t\t}\n\t\t\tloadIframeSdk().then((sdk) => sdk.openExternalUrl({ url: url.href }));\n\t\t} else {\n\t\t\tnavigation.push(route);\n\t\t}\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\tsetScreenOrientationMode() {\n\t\treturn {};\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\toverrideParentOrigins: [\"https://whop.com\", \"http://localhost:8004\"],\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, PathParamsWithOrigin } 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: PathParamsWithOrigin): 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\tsetScreenOrientationMode(params: {\n\t\ttargetScreenOrientationMode: \"portrait\" | \"landscape\" | \"rotate\";\n\t}): EmptyObject;\n}\n\nexport interface ExecAsyncApi extends ExecSyncApi {\n\tinAppPurchase(params: { id?: string | null; planId: string }): {\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,OAAO,UAAU;AACjB,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,MA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B,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"]}
|
|
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 Whop from \"@whop/sdk\";\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 = new Whop({\n\tapiKey: \"client\",\n\tappID: \"client\",\n\tbaseURL: new URL(\"/_whop/api/v1/\", appOrigin).href,\n});\n\nexport * from \"@whop/sdk\";\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<{\n\t\tstack: Route[];\n\t\tcurrentIndex: number;\n\t}>({\n\t\tstack: [],\n\t\tcurrentIndex: 0,\n\t});\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\n\t\t// Subscribe to path changes and emit to SDK\n\t\tthis.path.subscribe((value) => {\n\t\t\tloadIframeSdk()\n\t\t\t\t.then((sdk) =>\n\t\t\t\t\tsdk.onNavigationStackChange({\n\t\t\t\t\t\tstack: value.stack,\n\t\t\t\t\t\tcurrentIndex: value.currentIndex,\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\t.catch(() => {});\n\t\t});\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\tconst { stack } = this.path.getValue();\n\t\tconst newStack = [...stack, route];\n\t\tthis.path.setValue({ stack: newStack, currentIndex: newStack.length - 1 });\n\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: newStack.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(): boolean {\n\t\tif (!this.canPop()) {\n\t\t\treturn false;\n\t\t}\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\treturn true;\n\t}\n\n\tcanPop(): boolean {\n\t\treturn this.path.getValue().stack.length > 0;\n\t}\n\n\tgetFullStack() {\n\t\treturn this.path.getValue().stack;\n\t}\n\n\tgetCurrent() {\n\t\tconst { stack } = this.path.getValue();\n\t\treturn (\n\t\t\tstack[stack.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((value) => callback(value.stack));\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 { stack: currentStack, currentIndex } = navigation.path.getValue();\n\t\tconst currentLength = currentStack.length;\n\n\t\tif (!e.state) {\n\t\t\t// Browser back with no state - pop from stack\n\t\t\tconst newStack = currentStack.slice(0, -1);\n\t\t\tnavigation.path.setValue({\n\t\t\t\tstack: newStack,\n\t\t\t\tcurrentIndex: Math.max(0, currentIndex - 1),\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst index = e.state.index;\n\t\tconst route = e.state.route;\n\n\t\tif (index < currentLength) {\n\t\t\t// Going back\n\t\t\tconst newStack = currentStack.slice(0, -1);\n\t\t\tnavigation.path.setValue({\n\t\t\t\tstack: newStack,\n\t\t\t\tcurrentIndex: Math.max(0, currentIndex - 1),\n\t\t\t});\n\t\t} else {\n\t\t\t// Going forward\n\t\t\tconst newStack = [...currentStack, route];\n\t\t\tnavigation.path.setValue({\n\t\t\t\tstack: newStack,\n\t\t\t\tcurrentIndex: newStack.length - 1,\n\t\t\t});\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) {\n\t\tif (route.origin) {\n\t\t\tconst path = `/${route.path.join(\"/\")}`;\n\t\t\tconst url = new URL(path, route.origin);\n\t\t\tfor (const [k, v] of Object.entries(route.params ?? {})) {\n\t\t\t\turl.searchParams.set(k, v);\n\t\t\t}\n\t\t\tloadIframeSdk().then((sdk) => sdk.openExternalUrl({ url: url.href }));\n\t\t} else {\n\t\t\tnavigation.push(route);\n\t\t}\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\tsetScreenOrientationMode() {\n\t\treturn {};\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\toverrideParentOrigins: [\"https://whop.com\", \"http://localhost:8004\"],\n\t\t\tonMessage: {\n\t\t\t\tnavigateBack: () => {\n\t\t\t\t\tnavigation.pop();\n\t\t\t\t\treturn \"ok\" as const;\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\t// Emit initial stack state after SDK is ready\n\t\tconst { stack, currentIndex } = navigation.path.getValue();\n\t\tif (stack.length > 0) {\n\t\t\tiframeSdk\n\t\t\t\t.onNavigationStackChange({\n\t\t\t\t\tstack,\n\t\t\t\t\tcurrentIndex,\n\t\t\t\t})\n\t\t\t\t.catch(() => {});\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, PathParamsWithOrigin } 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: PathParamsWithOrigin): 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\tsetScreenOrientationMode(params: {\n\t\ttargetScreenOrientationMode: \"portrait\" | \"landscape\" | \"rotate\";\n\t}): EmptyObject;\n}\n\nexport interface ExecAsyncApi extends ExecSyncApi {\n\tinAppPurchase(params: { id?: string | null; planId: string }): {\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\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M,IAAI,MAAM,yBAAyBA,UAAS,EAAE,EAAE;AACvD;AAEA,IAAM,YAAY,aAAa;AAExB,IAAM,UAAU,IAAI,KAAK;AAAA,EAC/B,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,SAAS,IAAI,IAAI,kBAAkB,SAAS,EAAE;AAC/C,CAAC;;;ADtBD,wBAAc;;;AKqBd,IAAI,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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whop/react-native",
|
|
3
3
|
"description": "React Native SDK for building embedded apps on Whop",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.11",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/whopio/whop-sdk-ts",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@babel/runtime": "7.27.6",
|
|
46
46
|
"@react-native/babel-preset": "0.80.1",
|
|
47
47
|
"@react-native/metro-config": "0.80.1",
|
|
48
|
-
"@whop/sdk": "0.0.
|
|
48
|
+
"@whop/sdk": "0.0.20",
|
|
49
49
|
"dotenv": "16.5.0",
|
|
50
50
|
"esbuild": "0.25.9",
|
|
51
51
|
"events": "3.3.0",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"metro-react-native-babel-transformer": "0.77.0",
|
|
56
56
|
"qrcode-terminal": "0.12.0",
|
|
57
57
|
"rimraf": "6.0.1",
|
|
58
|
-
"@whop/
|
|
59
|
-
"@whop/
|
|
58
|
+
"@whop/iframe": "0.0.4",
|
|
59
|
+
"@whop/api": "0.0.51"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/babel__core": "7.20.5",
|