@whop/iframe 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,462 @@
1
+ import { z } from 'zod';
2
+ import { V as ValidZodEventSchema, S as ServerImplementation, T as Transport, C as ClientSDK, c as createSDK } from './whop-server-CCmOBRgb.js';
3
+ export { w as whopServerSchema } from './whop-server-CCmOBRgb.js';
4
+
5
+ declare function createHandler<Schema extends ValidZodEventSchema, ForceCompleteness extends boolean = false>({ schema, forceCompleteness, handlers, }: {
6
+ schema: Schema;
7
+ forceCompleteness?: ForceCompleteness;
8
+ handlers: Schema extends ValidZodEventSchema ? ServerImplementation<Schema, ForceCompleteness> : undefined;
9
+ }): (event: string, data: unknown) => Promise<(Schema extends ValidZodEventSchema ? z.TypeOf<Schema>["response"] : undefined) | undefined>;
10
+
11
+ declare const MESSAGE_TAG = "typed-transport";
12
+ declare function postmessageTransport<ServerSchema extends ValidZodEventSchema | undefined = undefined>({ remoteWindow, targetOrigins, }: {
13
+ remoteWindow: Window | undefined;
14
+ targetOrigins: string[];
15
+ }): Transport<ServerSchema>;
16
+
17
+ declare class TimeoutError extends Error {
18
+ constructor();
19
+ }
20
+
21
+ declare const index_ClientSDK: typeof ClientSDK;
22
+ declare const index_MESSAGE_TAG: typeof MESSAGE_TAG;
23
+ declare const index_ServerImplementation: typeof ServerImplementation;
24
+ type index_TimeoutError = TimeoutError;
25
+ declare const index_TimeoutError: typeof TimeoutError;
26
+ declare const index_Transport: typeof Transport;
27
+ declare const index_ValidZodEventSchema: typeof ValidZodEventSchema;
28
+ declare const index_createHandler: typeof createHandler;
29
+ declare const index_createSDK: typeof createSDK;
30
+ declare const index_postmessageTransport: typeof postmessageTransport;
31
+ declare namespace index {
32
+ export { index_ClientSDK as ClientSDK, index_MESSAGE_TAG as MESSAGE_TAG, index_ServerImplementation as ServerImplementation, index_TimeoutError as TimeoutError, index_Transport as Transport, index_ValidZodEventSchema as ValidZodEventSchema, index_createHandler as createHandler, index_createSDK as createSDK, index_postmessageTransport as postmessageTransport };
33
+ }
34
+
35
+ declare const appsServerSchema: z.ZodDiscriminatedUnion<"event", [z.ZodObject<{
36
+ event: z.ZodLiteral<"appPing">;
37
+ request: z.ZodLiteral<"app_ping">;
38
+ response: z.ZodLiteral<"app_pong">;
39
+ }, "strip", z.ZodTypeAny, {
40
+ event: "appPing";
41
+ request: "app_ping";
42
+ response: "app_pong";
43
+ }, {
44
+ event: "appPing";
45
+ request: "app_ping";
46
+ response: "app_pong";
47
+ }>, z.ZodObject<{
48
+ event: z.ZodLiteral<"onColorThemeChange">;
49
+ request: z.ZodObject<{
50
+ appearance: z.ZodOptional<z.ZodEnum<["light", "dark"]>>;
51
+ accentColor: z.ZodOptional<z.ZodString>;
52
+ dangerColor: z.ZodOptional<z.ZodString>;
53
+ grayColor: z.ZodOptional<z.ZodString>;
54
+ infoColor: z.ZodOptional<z.ZodString>;
55
+ successColor: z.ZodOptional<z.ZodString>;
56
+ warningColor: z.ZodOptional<z.ZodString>;
57
+ }, "strip", z.ZodTypeAny, {
58
+ appearance?: "light" | "dark" | undefined;
59
+ accentColor?: string | undefined;
60
+ dangerColor?: string | undefined;
61
+ grayColor?: string | undefined;
62
+ infoColor?: string | undefined;
63
+ successColor?: string | undefined;
64
+ warningColor?: string | undefined;
65
+ }, {
66
+ appearance?: "light" | "dark" | undefined;
67
+ accentColor?: string | undefined;
68
+ dangerColor?: string | undefined;
69
+ grayColor?: string | undefined;
70
+ infoColor?: string | undefined;
71
+ successColor?: string | undefined;
72
+ warningColor?: string | undefined;
73
+ }>;
74
+ response: z.ZodVoid;
75
+ }, "strip", z.ZodTypeAny, {
76
+ event: "onColorThemeChange";
77
+ request: {
78
+ appearance?: "light" | "dark" | undefined;
79
+ accentColor?: string | undefined;
80
+ dangerColor?: string | undefined;
81
+ grayColor?: string | undefined;
82
+ infoColor?: string | undefined;
83
+ successColor?: string | undefined;
84
+ warningColor?: string | undefined;
85
+ };
86
+ response?: void | undefined;
87
+ }, {
88
+ event: "onColorThemeChange";
89
+ request: {
90
+ appearance?: "light" | "dark" | undefined;
91
+ accentColor?: string | undefined;
92
+ dangerColor?: string | undefined;
93
+ grayColor?: string | undefined;
94
+ infoColor?: string | undefined;
95
+ successColor?: string | undefined;
96
+ warningColor?: string | undefined;
97
+ };
98
+ response?: void | undefined;
99
+ }>]>;
100
+
101
+ /**
102
+ * Create an iframe SDK for a client app. This will communicate with the parent
103
+ * window which is required to be whop.com.
104
+ */
105
+ declare function createSdk({ onMessage, appId, overrideParentOrigins, }: {
106
+ onMessage?: ServerImplementation<typeof appsServerSchema, false>;
107
+ appId?: string;
108
+ overrideParentOrigins?: string[];
109
+ }): ClientSDK<z.ZodDiscriminatedUnion<"event", [z.ZodObject<{
110
+ event: z.ZodLiteral<"ping">;
111
+ request: z.ZodLiteral<"ping">;
112
+ response: z.ZodLiteral<"pong">;
113
+ }, "strip", z.ZodTypeAny, {
114
+ event: "ping";
115
+ request: "ping";
116
+ response: "pong";
117
+ }, {
118
+ event: "ping";
119
+ request: "ping";
120
+ response: "pong";
121
+ }>, z.ZodObject<{
122
+ event: z.ZodLiteral<"getTopLevelUrlData">;
123
+ request: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
124
+ response: z.ZodObject<{
125
+ companyRoute: z.ZodString;
126
+ experienceRoute: z.ZodString;
127
+ experienceId: z.ZodString;
128
+ viewType: z.ZodEnum<["app", "admin", "analytics", "preview"]>;
129
+ baseHref: z.ZodString;
130
+ fullHref: z.ZodString;
131
+ }, "strip", z.ZodTypeAny, {
132
+ companyRoute: string;
133
+ experienceRoute: string;
134
+ experienceId: string;
135
+ viewType: "app" | "admin" | "analytics" | "preview";
136
+ baseHref: string;
137
+ fullHref: string;
138
+ }, {
139
+ companyRoute: string;
140
+ experienceRoute: string;
141
+ experienceId: string;
142
+ viewType: "app" | "admin" | "analytics" | "preview";
143
+ baseHref: string;
144
+ fullHref: string;
145
+ }>;
146
+ }, "strip", z.ZodTypeAny, {
147
+ event: "getTopLevelUrlData";
148
+ response: {
149
+ companyRoute: string;
150
+ experienceRoute: string;
151
+ experienceId: string;
152
+ viewType: "app" | "admin" | "analytics" | "preview";
153
+ baseHref: string;
154
+ fullHref: string;
155
+ };
156
+ request?: {} | undefined;
157
+ }, {
158
+ event: "getTopLevelUrlData";
159
+ response: {
160
+ companyRoute: string;
161
+ experienceRoute: string;
162
+ experienceId: string;
163
+ viewType: "app" | "admin" | "analytics" | "preview";
164
+ baseHref: string;
165
+ fullHref: string;
166
+ };
167
+ request?: {} | undefined;
168
+ }>, z.ZodObject<{
169
+ event: z.ZodLiteral<"openExternalUrl">;
170
+ request: z.ZodObject<{
171
+ newTab: z.ZodOptional<z.ZodBoolean>;
172
+ url: z.ZodString;
173
+ }, "strip", z.ZodTypeAny, {
174
+ url: string;
175
+ newTab?: boolean | undefined;
176
+ }, {
177
+ url: string;
178
+ newTab?: boolean | undefined;
179
+ }>;
180
+ response: z.ZodLiteral<"ok">;
181
+ }, "strip", z.ZodTypeAny, {
182
+ event: "openExternalUrl";
183
+ request: {
184
+ url: string;
185
+ newTab?: boolean | undefined;
186
+ };
187
+ response: "ok";
188
+ }, {
189
+ event: "openExternalUrl";
190
+ request: {
191
+ url: string;
192
+ newTab?: boolean | undefined;
193
+ };
194
+ response: "ok";
195
+ }>, z.ZodObject<{
196
+ event: z.ZodLiteral<"onHrefChange">;
197
+ request: z.ZodObject<{
198
+ href: z.ZodString;
199
+ }, "strip", z.ZodTypeAny, {
200
+ href: string;
201
+ }, {
202
+ href: string;
203
+ }>;
204
+ response: z.ZodLiteral<"ok">;
205
+ }, "strip", z.ZodTypeAny, {
206
+ event: "onHrefChange";
207
+ request: {
208
+ href: string;
209
+ };
210
+ response: "ok";
211
+ }, {
212
+ event: "onHrefChange";
213
+ request: {
214
+ href: string;
215
+ };
216
+ response: "ok";
217
+ }>, z.ZodObject<{
218
+ event: z.ZodLiteral<"inAppPurchase">;
219
+ request: z.ZodObject<{
220
+ id: z.ZodOptional<z.ZodString>;
221
+ planId: z.ZodString;
222
+ }, "strip", z.ZodTypeAny, {
223
+ planId: string;
224
+ id?: string | undefined;
225
+ }, {
226
+ planId: string;
227
+ id?: string | undefined;
228
+ }>;
229
+ response: z.ZodDiscriminatedUnion<"status", [z.ZodObject<{
230
+ status: z.ZodLiteral<"ok">;
231
+ data: z.ZodObject<{
232
+ sessionId: z.ZodString;
233
+ receiptId: z.ZodString;
234
+ }, "strip", z.ZodTypeAny, {
235
+ sessionId: string;
236
+ receiptId: string;
237
+ }, {
238
+ sessionId: string;
239
+ receiptId: string;
240
+ }>;
241
+ }, "strip", z.ZodTypeAny, {
242
+ status: "ok";
243
+ data: {
244
+ sessionId: string;
245
+ receiptId: string;
246
+ };
247
+ }, {
248
+ status: "ok";
249
+ data: {
250
+ sessionId: string;
251
+ receiptId: string;
252
+ };
253
+ }>, z.ZodObject<{
254
+ status: z.ZodLiteral<"error">;
255
+ error: z.ZodString;
256
+ }, "strip", z.ZodTypeAny, {
257
+ status: "error";
258
+ error: string;
259
+ }, {
260
+ status: "error";
261
+ error: string;
262
+ }>]>;
263
+ }, "strip", z.ZodTypeAny, {
264
+ event: "inAppPurchase";
265
+ request: {
266
+ planId: string;
267
+ id?: string | undefined;
268
+ };
269
+ response: {
270
+ status: "ok";
271
+ data: {
272
+ sessionId: string;
273
+ receiptId: string;
274
+ };
275
+ } | {
276
+ status: "error";
277
+ error: string;
278
+ };
279
+ }, {
280
+ event: "inAppPurchase";
281
+ request: {
282
+ planId: string;
283
+ id?: string | undefined;
284
+ };
285
+ response: {
286
+ status: "ok";
287
+ data: {
288
+ sessionId: string;
289
+ receiptId: string;
290
+ };
291
+ } | {
292
+ status: "error";
293
+ error: string;
294
+ };
295
+ }>, z.ZodObject<{
296
+ event: z.ZodLiteral<"closeApp">;
297
+ request: z.ZodNull;
298
+ response: z.ZodLiteral<"ok">;
299
+ }, "strip", z.ZodTypeAny, {
300
+ event: "closeApp";
301
+ request: null;
302
+ response: "ok";
303
+ }, {
304
+ event: "closeApp";
305
+ request: null;
306
+ response: "ok";
307
+ }>, z.ZodObject<{
308
+ event: z.ZodLiteral<"openHelpChat">;
309
+ request: z.ZodNull;
310
+ response: z.ZodLiteral<"ok">;
311
+ }, "strip", z.ZodTypeAny, {
312
+ event: "openHelpChat";
313
+ request: null;
314
+ response: "ok";
315
+ }, {
316
+ event: "openHelpChat";
317
+ request: null;
318
+ response: "ok";
319
+ }>, z.ZodObject<{
320
+ event: z.ZodLiteral<"getColorTheme">;
321
+ request: z.ZodVoid;
322
+ response: z.ZodObject<{
323
+ appearance: z.ZodOptional<z.ZodEnum<["light", "dark"]>>;
324
+ accentColor: z.ZodOptional<z.ZodString>;
325
+ dangerColor: z.ZodOptional<z.ZodString>;
326
+ grayColor: z.ZodOptional<z.ZodString>;
327
+ infoColor: z.ZodOptional<z.ZodString>;
328
+ successColor: z.ZodOptional<z.ZodString>;
329
+ warningColor: z.ZodOptional<z.ZodString>;
330
+ }, "strip", z.ZodTypeAny, {
331
+ appearance?: "light" | "dark" | undefined;
332
+ accentColor?: string | undefined;
333
+ dangerColor?: string | undefined;
334
+ grayColor?: string | undefined;
335
+ infoColor?: string | undefined;
336
+ successColor?: string | undefined;
337
+ warningColor?: string | undefined;
338
+ }, {
339
+ appearance?: "light" | "dark" | undefined;
340
+ accentColor?: string | undefined;
341
+ dangerColor?: string | undefined;
342
+ grayColor?: string | undefined;
343
+ infoColor?: string | undefined;
344
+ successColor?: string | undefined;
345
+ warningColor?: string | undefined;
346
+ }>;
347
+ }, "strip", z.ZodTypeAny, {
348
+ event: "getColorTheme";
349
+ response: {
350
+ appearance?: "light" | "dark" | undefined;
351
+ accentColor?: string | undefined;
352
+ dangerColor?: string | undefined;
353
+ grayColor?: string | undefined;
354
+ infoColor?: string | undefined;
355
+ successColor?: string | undefined;
356
+ warningColor?: string | undefined;
357
+ };
358
+ request?: void | undefined;
359
+ }, {
360
+ event: "getColorTheme";
361
+ response: {
362
+ appearance?: "light" | "dark" | undefined;
363
+ accentColor?: string | undefined;
364
+ dangerColor?: string | undefined;
365
+ grayColor?: string | undefined;
366
+ infoColor?: string | undefined;
367
+ successColor?: string | undefined;
368
+ warningColor?: string | undefined;
369
+ };
370
+ request?: void | undefined;
371
+ }>, z.ZodObject<{
372
+ event: z.ZodLiteral<"earliestUnreadNotification">;
373
+ request: z.ZodObject<{
374
+ experienceId: z.ZodString;
375
+ }, "strip", z.ZodTypeAny, {
376
+ experienceId: string;
377
+ }, {
378
+ experienceId: string;
379
+ }>;
380
+ response: z.ZodNullable<z.ZodObject<{
381
+ externalId: z.ZodString;
382
+ }, "strip", z.ZodTypeAny, {
383
+ externalId: string;
384
+ }, {
385
+ externalId: string;
386
+ }>>;
387
+ }, "strip", z.ZodTypeAny, {
388
+ event: "earliestUnreadNotification";
389
+ request: {
390
+ experienceId: string;
391
+ };
392
+ response: {
393
+ externalId: string;
394
+ } | null;
395
+ }, {
396
+ event: "earliestUnreadNotification";
397
+ request: {
398
+ experienceId: string;
399
+ };
400
+ response: {
401
+ externalId: string;
402
+ } | null;
403
+ }>, z.ZodObject<{
404
+ event: z.ZodLiteral<"markExperienceRead">;
405
+ request: z.ZodObject<{
406
+ experienceId: z.ZodString;
407
+ notificationExternalId: z.ZodOptional<z.ZodString>;
408
+ }, "strip", z.ZodTypeAny, {
409
+ experienceId: string;
410
+ notificationExternalId?: string | undefined;
411
+ }, {
412
+ experienceId: string;
413
+ notificationExternalId?: string | undefined;
414
+ }>;
415
+ response: z.ZodLiteral<"ok">;
416
+ }, "strip", z.ZodTypeAny, {
417
+ event: "markExperienceRead";
418
+ request: {
419
+ experienceId: string;
420
+ notificationExternalId?: string | undefined;
421
+ };
422
+ response: "ok";
423
+ }, {
424
+ event: "markExperienceRead";
425
+ request: {
426
+ experienceId: string;
427
+ notificationExternalId?: string | undefined;
428
+ };
429
+ response: "ok";
430
+ }>, z.ZodObject<{
431
+ event: z.ZodLiteral<"performHaptic">;
432
+ request: z.ZodObject<{
433
+ type: z.ZodEnum<["selection", "impact", "notification"]>;
434
+ style: z.ZodEnum<["light", "medium", "heavy"]>;
435
+ }, "strip", z.ZodTypeAny, {
436
+ type: "selection" | "impact" | "notification";
437
+ style: "light" | "medium" | "heavy";
438
+ }, {
439
+ type: "selection" | "impact" | "notification";
440
+ style: "light" | "medium" | "heavy";
441
+ }>;
442
+ response: z.ZodLiteral<"ok">;
443
+ }, "strip", z.ZodTypeAny, {
444
+ event: "performHaptic";
445
+ request: {
446
+ type: "selection" | "impact" | "notification";
447
+ style: "light" | "medium" | "heavy";
448
+ };
449
+ response: "ok";
450
+ }, {
451
+ event: "performHaptic";
452
+ request: {
453
+ type: "selection" | "impact" | "notification";
454
+ style: "light" | "medium" | "heavy";
455
+ };
456
+ response: "ok";
457
+ }>]>, true> & {
458
+ _cleanupTransport: () => void;
459
+ };
460
+ type WhopIframeSdk = ReturnType<typeof createSdk>;
461
+
462
+ export { type WhopIframeSdk, appsServerSchema, createSdk, index as transport };