UNPKG

@whop/iframe

Version:

Powers communication between Whop and your embedded app

1 lines 1.5 kB
{"version":3,"sources":["../src/host.ts"],"sourcesContent":["import { appsServerSchema } from \"@/sdk/apps-server\";\nimport {\n\ttype ServerImplementation,\n\tcreateSDK as createPostmessageSdk,\n\tpostmessageTransport,\n} from \"@/sdk/transport\";\nimport { whopServerSchema } from \"@/sdk/whop-server\";\n\n/**\n * Create an iframe SDK for the container whop.com app.\n * This will implement the functions required by client apps.\n * Do not use this function when building apps\n */\nexport function createSdkHost({\n\tappId,\n\tonMessage,\n\tremoteWindow,\n\tremoteOrigin,\n}: {\n\tappId: string;\n\tremoteWindow: Window;\n\tremoteOrigin: string;\n\tonMessage: ServerImplementation<typeof whopServerSchema, true>;\n\tisDevelopment?: boolean;\n}) {\n\treturn createPostmessageSdk({\n\t\tclientSchema: appsServerSchema,\n\t\tserverSchema: whopServerSchema,\n\t\tforceCompleteness: true,\n\t\tserverImplementation: onMessage,\n\t\tlocalAppId: \"app_whop\",\n\t\tremoteAppId: appId,\n\t\ttransport: postmessageTransport({\n\t\t\tremoteWindow: remoteWindow,\n\t\t\ttargetOrigins: [remoteOrigin],\n\t\t}),\n\t\tserverComplete: false,\n\t\ttimeout: 200,\n\t});\n}\n"],"mappings":";;;;;;;;AAaO,SAAS,cAAc;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAMG;AACF,SAAO,UAAqB;AAAA,IAC3B,cAAc;AAAA,IACd,cAAc;AAAA,IACd,mBAAmB;AAAA,IACnB,sBAAsB;AAAA,IACtB,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,WAAW,qBAAqB;AAAA,MAC/B;AAAA,MACA,eAAe,CAAC,YAAY;AAAA,IAC7B,CAAC;AAAA,IACD,gBAAgB;AAAA,IAChB,SAAS;AAAA,EACV,CAAC;AACF;","names":[]}