@whop/react-native 0.0.10 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +369 -40
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +366 -37
- package/dist/cli/index.mjs.map +1 -1
- package/dist/lib/index.d.mts +15 -1
- package/dist/lib/index.d.ts +15 -1
- package/dist/lib/index.js +305 -5
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +295 -5
- package/dist/lib/index.mjs.map +1 -1
- package/dist/lib/web.mjs +214 -0
- package/dist/lib/web.mjs.map +1 -0
- package/package.json +64 -4
package/dist/cli/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/index.ts","../../src/cli/mobile.ts","../../src/cli/file.ts","../../src/cli/sdk.ts","../../src/cli/valid-view-type.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { parseArgs } from \"node:util\";\nimport { findUp } from \"find-up\";\nimport { rimraf } from \"rimraf\";\nimport { buildAndPublish } from \"./mobile\";\n\nasync function main() {\n\tconst args = parseArgs({\n\t\toptions: {\n\t\t\tios: {\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\tandroid: {\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\tweb: {\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t},\n\t\tstrict: true,\n\t\tallowPositionals: true,\n\t\targs: process.argv.slice(2),\n\t});\n\n\tconst [command] = args.positionals;\n\n\tlet shouldBuild = true;\n\tlet shouldUpload = true;\n\tlet shouldClean = true;\n\tif (command === \"build\") {\n\t\tshouldUpload = false;\n\t} else if (command === \"ship\") {\n\t\tshouldBuild = true;\n\t\tshouldUpload = true;\n\t} else if (command === \"upload\") {\n\t\tshouldBuild = false;\n\t\tshouldClean = false;\n\t} else if (command === \"clean\") {\n\t\tshouldBuild = false;\n\t\tshouldUpload = false;\n\t} else {\n\t\tconsole.error(\n\t\t\t`Usage:\n\twhop-react-native ship [--ios] [--android] [--web] # runs build and then publishes it as a dev build to whop.\n\twhop-react-native build [--ios] [--android] [--web] # builds your app into a distributable bundle in the build/ directory.\n\twhop-react-native upload [--ios] [--android] [--web] # uploads the existing build directory to whop.\n\twhop-react-native clean # cleans the build directory.`,\n\t\t);\n\t\tprocess.exit(1);\n\t}\n\n\tconst root = await getRootProjectDirectory();\n\n\tif (shouldClean) {\n\t\tawait cleanBuildDirectory(root);\n\t}\n\n\tconst didProvidePlatform =\n\t\targs.values.ios || args.values.android || args.values.web;\n\n\tconst opts = { shouldBuild, shouldUpload };\n\tconst promises: Promise<void>[] = [];\n\n\tif (args.values.ios || !didProvidePlatform) {\n\t\tpromises.push(buildAndPublish(root, \"ios\", opts));\n\t}\n\tif (args.values.android || !didProvidePlatform) {\n\t\tpromises.push(buildAndPublish(root, \"android\", opts));\n\t}\n\tif (args.values.web || !didProvidePlatform) {\n\t\tconsole.warn(\" - [web] builds for web are not supported yet - coming soon\");\n\t}\n\n\tawait Promise.all(promises);\n}\n\nasync function cleanBuildDirectory(root: string) {\n\tconst buildDirectory = path.join(root, \"build\");\n\tif (existsSync(buildDirectory)) {\n\t\tawait rimraf(buildDirectory);\n\t}\n\tconsole.log(\" ✔︎ cleaned build directory\");\n}\n\nasync function getRootProjectDirectory() {\n\tconst file = await findUp(\"package.json\", { cwd: process.cwd() });\n\tif (!file) {\n\t\tthrow new Error(\n\t\t\t\"please run this command inside a whop react native project\",\n\t\t);\n\t}\n\tconst root = path.dirname(file);\n\treturn root;\n}\n\nmain()\n\t.catch((err) => {\n\t\tconsole.error(err);\n\t\tprocess.exit(1);\n\t})\n\t.then(() => {\n\t\tprocess.exit(0);\n\t});\n","import { existsSync, readFileSync, readdirSync, statSync } from \"node:fs\";\nimport { mkdir, readdir, rename, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { getDefaultConfig } from \"@react-native/metro-config\";\nimport { findUp } from \"find-up\";\nimport JSZip from \"jszip\";\nimport { type ReportableEvent, type Reporter, runBuild } from \"metro\";\nimport { getChecksum, uploadFile } from \"./file\";\nimport { APP_ID, COMPANY_ID, whopSdk } from \"./sdk\";\nimport { VALID_VIEW_TYPES } from \"./valid-view-type\";\n\nexport async function buildAndPublish(\n\troot: string,\n\tplatform: \"ios\" | \"android\",\n\t{\n\t\tshouldBuild = true,\n\t\tshouldUpload = true,\n\t}: { shouldBuild: boolean; shouldUpload: boolean } = {\n\t\tshouldBuild: true,\n\t\tshouldUpload: true,\n\t},\n) {\n\tif (shouldBuild) {\n\t\tawait bundle(root, platform);\n\t}\n\tif (shouldUpload) {\n\t\tawait createMobileBuild(root, platform);\n\t}\n}\n\nexport async function bundle(root: string, platform: \"ios\" | \"android\") {\n\tawait makeEntrypoint(root, platform);\n\n\tconst outputFile = path.join(\n\t\troot,\n\t\t\"build\",\n\t\t\"output\",\n\t\tplatform,\n\t\t\"main_js_bundle\",\n\t);\n\tawait mkdir(path.dirname(outputFile), { recursive: true });\n\n\tconst defaultConfig = getDefaultConfig(root);\n\n\tconst babelLocation = require.resolve(\"@babel/runtime/package\");\n\n\tconst bableNodeModules = await findUp(\"node_modules\", {\n\t\tcwd: babelLocation,\n\t\ttype: \"directory\",\n\t});\n\tif (!bableNodeModules) {\n\t\tthrow new Error(\"babel node_modules parent folder not found\");\n\t}\n\n\tawait runBuild(\n\t\t{\n\t\t\t...defaultConfig,\n\t\t\tprojectRoot: root,\n\t\t\ttransformer: {\n\t\t\t\t...defaultConfig.transformer,\n\t\t\t\tbabelTransformerPath: require.resolve(\n\t\t\t\t\t\"./whop-react-native-babel-transformer.js\",\n\t\t\t\t),\n\t\t\t},\n\t\t\twatchFolders: [\n\t\t\t\troot,\n\t\t\t\tpath.resolve(root, \"node_modules\"),\n\t\t\t\tbableNodeModules,\n\t\t\t],\n\t\t\treporter: new CustomReporter(),\n\t\t\tresolver: {\n\t\t\t\t...defaultConfig.resolver,\n\t\t\t\tnodeModulesPaths: [\n\t\t\t\t\t...(defaultConfig.resolver?.nodeModulesPaths ?? []),\n\t\t\t\t\tbableNodeModules,\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tdev: false,\n\t\t\tentry: `build/entrypoints/${platform}/index.js`,\n\t\t\tminify: false,\n\t\t\tplatform: platform,\n\t\t\tsourceMap: false,\n\t\t\tout: outputFile,\n\t\t},\n\t);\n\n\tawait rename(\n\t\t`${outputFile}.js`,\n\t\tpath.join(root, \"build\", \"output\", platform, \"main_js_bundle.hbc\"),\n\t);\n\n\tconsole.log(` ✔︎ [${platform}] bundle created`);\n}\n\nasync function getSupportedAppViewTypes(\n\troot: string,\n): Promise<(typeof VALID_VIEW_TYPES)[number][]> {\n\tconst views = await readdir(path.join(root, \"src\", \"views\"), {\n\t\twithFileTypes: true,\n\t\trecursive: false,\n\t});\n\tconst files = views\n\t\t.filter((file) => file.isFile())\n\t\t.map((file) => file.name.split(\".\")[0])\n\t\t.filter((file) => !!file);\n\n\tconst validViews = files.filter((file) =>\n\t\tVALID_VIEW_TYPES.includes(file as (typeof VALID_VIEW_TYPES)[number]),\n\t) as (typeof VALID_VIEW_TYPES)[number][];\n\n\tif (validViews.length === 0) {\n\t\tthrow new Error(\n\t\t\t`No valid views found, please create a view in the src/views folder and name it with a valid view type: ${VALID_VIEW_TYPES.join(\", \")}`,\n\t\t);\n\t}\n\n\treturn validViews;\n}\n\nasync function makeEntrypoint(\n\troot: string,\n\tplatform: \"ios\" | \"android\",\n): Promise<string> {\n\tconst entrypoint = path.join(\n\t\troot,\n\t\t\"build\",\n\t\t\"entrypoints\",\n\t\tplatform,\n\t\t\"index.js\",\n\t);\n\n\tconst files = await getSupportedAppViewTypes(root);\n\n\tconst pascalCase = (str: string) =>\n\t\tstr\n\t\t\t.split(\"-\")\n\t\t\t.map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n\t\t\t.join(\"\");\n\n\tconst imports = files.map(\n\t\t(file) =>\n\t\t\t`import { ${pascalCase(file)} } from \"../../../src/views/${file}\";`,\n\t);\n\tconst registry = files.map(\n\t\t(file) =>\n\t\t\t`AppRegistry.registerComponent(\"${pascalCase(file)}\", () => ${pascalCase(file)});`,\n\t);\n\n\tconst entrypointContent = `import { AppRegistry } from \"react-native\";\n${imports.join(\"\\n\")}\n\n${registry.join(\"\\n\")}\n`;\n\n\tconst entrypointDir = path.dirname(entrypoint);\n\tawait mkdir(entrypointDir, { recursive: true });\n\tawait writeFile(entrypoint, entrypointContent, \"utf-8\");\n\n\tconsole.log(` ✔︎ [${platform}] entrypoint created`);\n\n\treturn entrypoint;\n}\n\nexport async function createMobileBuild(\n\troot: string,\n\tplatform: \"ios\" | \"android\",\n) {\n\tconst viewTypes = await getSupportedAppViewTypes(root);\n\n\tconst fullDirectory = path.join(root, \"build\", \"output\", platform);\n\n\t// Check if the directory contains a file called `main_js_bundle.hbc`\n\tconst mainJsBundle = path.join(fullDirectory, \"main_js_bundle.hbc\");\n\n\tif (!existsSync(mainJsBundle)) {\n\t\tthrow new Error(`main_js_bundle.hbc not found in ${fullDirectory}`);\n\t}\n\n\t// check that that folder only contains the main_js_bundle.hbc file and an optional `assets` folder\n\tconst files = readdirSync(fullDirectory);\n\tif (\n\t\tfiles.length > 2 ||\n\t\tfiles.length < 1 ||\n\t\t!files.includes(\"main_js_bundle.hbc\")\n\t) {\n\t\tthrow new Error(\n\t\t\t\"Directory must contain only the main_js_bundle.hbc file and an optional `assets` folder\",\n\t\t);\n\t}\n\tif (files.length === 2 && !files.includes(\"assets\")) {\n\t\tthrow new Error(\n\t\t\t\"Directory must contain only the main_js_bundle.hbc file and an optional `assets` folder\",\n\t\t);\n\t}\n\n\t// Zip the directory\n\tconst zipData = await zipDirectory(fullDirectory);\n\n\tconst checksum = await getChecksum(zipData);\n\n\tconsole.log(` ✔︎ [${platform}] build zipped with checksum: ${checksum}`);\n\n\tconst fileName = `app_build_${platform}.zip`;\n\tconst uploadedFile = await uploadFile(zipData, fileName, \"application/zip\");\n\n\tconsole.log(\n\t\t` ✔︎ [${platform}] uploaded build: ${fileName} (${(zipData.length / 1024).toFixed(0)} KB)`,\n\t);\n\n\tconst build = await whopSdk.apps.createAppBuild({\n\t\tattachment: { directUploadId: uploadedFile.directUploadId },\n\t\tchecksum,\n\t\tplatform,\n\t\tsupportedAppViewTypes: viewTypes.map(\n\t\t\t(view) =>\n\t\t\t\t({\n\t\t\t\t\t\"experience-view\": \"hub\" as const,\n\t\t\t\t\t\"discover-view\": \"discover\" as const,\n\t\t\t\t})[view],\n\t\t),\n\t});\n\n\tif (!build) {\n\t\tthrow new Error(\"Failed to create app build\");\n\t}\n\n\tconst dashboardUrl = `https://whop.com/dashboard/${COMPANY_ID}/developer/apps/${APP_ID}/builds/`;\n\n\tconsole.log(`\\n ✔︎ [${platform}] deployed as development build ✔︎\n - build id: ${build.id}\n - view types: ${viewTypes.join(\", \")}\n - promote to production here: ${dashboardUrl}\\n`);\n\n\treturn build;\n}\n\nasync function zipDirectory(\n\tdirectory: string,\n): Promise<Buffer<ArrayBufferLike>> {\n\tconst zip = new JSZip();\n\n\t// Recursively add files to zip\n\tfunction addFilesToZip(currentPath: string, relativePath = \"\") {\n\t\tconst items = readdirSync(currentPath);\n\n\t\tfor (const item of items) {\n\t\t\tconst fullPath = path.join(currentPath, item);\n\t\t\tconst zipPath = relativePath ? path.join(relativePath, item) : item;\n\t\t\tconst stats = statSync(fullPath);\n\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\taddFilesToZip(fullPath, zipPath);\n\t\t\t} else {\n\t\t\t\tconst fileContent = readFileSync(fullPath);\n\t\t\t\tzip.file(zipPath, fileContent);\n\t\t\t}\n\t\t}\n\t}\n\n\taddFilesToZip(directory);\n\n\t// Generate zip file\n\tconst zipData = await zip.generateAsync({ type: \"nodebuffer\" });\n\n\treturn zipData;\n}\n\nclass CustomReporter implements Reporter {\n\tupdate(event: ReportableEvent) {\n\t\t// Do nothing.\n\t}\n}\n","import { createHash } from \"node:crypto\";\nimport { AGENT_USER_ID, APP_ID, whopSdk } from \"./sdk\";\n\nexport async function uploadFile(\n\tdata: Buffer<ArrayBufferLike>,\n\tname: string,\n\tcontentType: string,\n) {\n\tconst file = new File([data], name, {\n\t\ttype: contentType,\n\t});\n\n\tconst uploadedFile = await whopSdk\n\t\t.withUser(AGENT_USER_ID)\n\t\t.attachments.uploadAttachment({\n\t\t\tfile,\n\t\t\trecord: \"app\",\n\t\t\tid: APP_ID,\n\t\t});\n\n\treturn uploadedFile;\n}\n\nexport async function getChecksum(data: Buffer<ArrayBufferLike>) {\n\tconst hash = createHash(\"sha256\");\n\thash.update(data);\n\treturn hash.digest(\"hex\");\n}\n","import { WhopServerSdk } from \"@whop/api\";\nimport { config } from \"dotenv\";\n\nconfig({\n\tpath: [\".env\", \".env.local\", \".env.development\", \".env.production\"],\n});\n\nfunction env(key: string) {\n\tconst value = process.env[key];\n\tif (!value) {\n\t\tthrow new Error(`Missing environment variable: ${key}`);\n\t}\n\treturn value;\n}\n\nexport const AGENT_USER_ID = env(\"NEXT_PUBLIC_WHOP_AGENT_USER_ID\");\nexport const COMPANY_ID = env(\"NEXT_PUBLIC_WHOP_COMPANY_ID\");\nexport const APP_ID = env(\"NEXT_PUBLIC_WHOP_APP_ID\");\n\nexport const whopSdk: WhopServerSdk = WhopServerSdk({\n\tappApiKey: env(\"WHOP_API_KEY\"),\n\tappId: APP_ID,\n\tcompanyId: COMPANY_ID,\n\tonBehalfOfUserId: AGENT_USER_ID,\n});\n","export const VALID_VIEW_TYPES = [\"experience-view\", \"discover-view\"] as const;\n"],"mappings":";;;;;;AAAA,SAAS,cAAAA,mBAAkB;AAC3B,OAAOC,WAAU;AACjB,SAAS,iBAAiB;AAC1B,SAAS,UAAAC,eAAc;AACvB,SAAS,cAAc;;;ACJvB,SAAS,YAAY,cAAc,aAAa,gBAAgB;AAChE,SAAS,OAAO,SAAS,QAAQ,iBAAiB;AAClD,OAAO,UAAU;AACjB,SA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AAM;AACV,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AACA,QAAM,OAAOF,MAAK,QAAQ,IAAI;AAC9B,SAAO;AACR;AAEA,KAAK,EACH,MAAM,CAAC,QAAQ;AACf,UAAQ,MAAM,GAAG;AACjB,UAAQ,KAAK,CAAC;AACf,CAAC,EACA,KAAK,MAAM;AACX,UAAQ,KAAK,CAAC;AACf,CAAC;","names":["existsSync","path","findUp","path","existsSync","findUp"]}
|
|
1
|
+
{"version":3,"sources":["../../src/cli/index.ts","../../src/cli/mobile.ts","../../src/cli/file.ts","../../src/cli/sdk.ts","../../src/cli/valid-view-type.ts","../../src/cli/web.ts","../../src/cli/reanimated-bable.ts","../../src/cli/strip-flow.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { parseArgs } from \"node:util\";\nimport { findUp } from \"find-up\";\nimport qrcode from \"qrcode-terminal\";\nimport { rimraf } from \"rimraf\";\nimport { buildAndPublish } from \"./mobile\";\nimport { env } from \"./sdk\";\nimport { buildAndPublish as buildAndPublishWeb } from \"./web\";\n\nasync function main() {\n\tconst args = parseArgs({\n\t\toptions: {\n\t\t\tios: {\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\tandroid: {\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\tweb: {\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t},\n\t\tstrict: true,\n\t\tallowPositionals: true,\n\t\targs: process.argv.slice(2),\n\t});\n\n\tconst [command] = args.positionals;\n\n\tif (command === \"install\") {\n\t\tawait handleInstall();\n\t\treturn;\n\t}\n\n\tlet shouldBuild = true;\n\tlet shouldUpload = true;\n\tlet shouldClean = true;\n\tif (command === \"build\") {\n\t\tshouldUpload = false;\n\t} else if (command === \"ship\") {\n\t\tshouldBuild = true;\n\t\tshouldUpload = true;\n\t} else if (command === \"upload\") {\n\t\tshouldBuild = false;\n\t\tshouldClean = false;\n\t} else if (command === \"clean\") {\n\t\tshouldBuild = false;\n\t\tshouldUpload = false;\n\t} else {\n\t\tconsole.error(\n\t\t\t`Usage:\n\twhop-react-native ship [--ios] [--android] [--web] # runs build and then publishes it as a dev build to whop.\n\twhop-react-native build [--ios] [--android] [--web] # builds your app into a distributable bundle in the build/ directory.\n\twhop-react-native upload [--ios] [--android] [--web] # uploads the existing build directory to whop.\n\twhop-react-native clean # cleans the build directory.`,\n\t\t);\n\t\tprocess.exit(1);\n\t}\n\n\tconst root = await getRootProjectDirectory();\n\n\tif (shouldClean) {\n\t\tawait cleanBuildDirectory(root);\n\t}\n\n\tconst didProvidePlatform =\n\t\targs.values.ios || args.values.android || args.values.web;\n\n\tconst opts = { shouldBuild, shouldUpload };\n\tconst promises: Promise<void>[] = [];\n\n\tif (args.values.ios || !didProvidePlatform) {\n\t\tpromises.push(buildAndPublish(root, \"ios\", opts));\n\t}\n\tif (args.values.android || !didProvidePlatform) {\n\t\tpromises.push(buildAndPublish(root, \"android\", opts));\n\t}\n\tif (args.values.web || !didProvidePlatform) {\n\t\tpromises.push(buildAndPublishWeb(root, opts));\n\t}\n\n\tawait Promise.all(promises);\n}\n\nasync function cleanBuildDirectory(root: string) {\n\tconst buildDirectory = path.join(root, \"build\");\n\tif (existsSync(buildDirectory)) {\n\t\tawait rimraf(buildDirectory);\n\t}\n\tconsole.log(\" ✔︎ cleaned build directory\");\n}\n\nasync function getRootProjectDirectory() {\n\tconst file = await findUp(\"package.json\", { cwd: process.cwd() });\n\tif (!file) {\n\t\tthrow new Error(\n\t\t\t\"please run this command inside a whop react native project\",\n\t\t);\n\t}\n\tconst root = path.dirname(file);\n\treturn root;\n}\n\nasync function handleInstall() {\n\tconst appId = env(\"NEXT_PUBLIC_WHOP_APP_ID\");\n\tconst installLink = `https://whop.com/apps/${appId}/install`;\n\n\tconsole.log(`\nOpen this link in your browser to install the app into your whop.\n${installLink}\n\nOr scan the QR code with your iPhone:\n\t`);\n\n\tqrcode.generate(installLink, { small: true });\n}\n\nmain()\n\t.catch((err) => {\n\t\tconsole.error(err);\n\t\tprocess.exit(1);\n\t})\n\t.then(() => {\n\t\tprocess.exit(0);\n\t});\n","import { existsSync, readFileSync, readdirSync, statSync } from \"node:fs\";\nimport { mkdir, rename, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { getDefaultConfig } from \"@react-native/metro-config\";\nimport { findUp } from \"find-up\";\nimport JSZip from \"jszip\";\nimport { type ReportableEvent, type Reporter, runBuild } from \"metro\";\nimport { getChecksum, uploadFile } from \"./file\";\nimport { APP_ID, COMPANY_ID, whopSdk } from \"./sdk\";\nimport { getSupportedAppViewTypes } from \"./valid-view-type\";\n\nexport async function buildAndPublish(\n\troot: string,\n\tplatform: \"ios\" | \"android\",\n\t{\n\t\tshouldBuild = true,\n\t\tshouldUpload = true,\n\t}: { shouldBuild: boolean; shouldUpload: boolean } = {\n\t\tshouldBuild: true,\n\t\tshouldUpload: true,\n\t},\n) {\n\tif (shouldBuild) {\n\t\tawait bundle(root, platform);\n\t}\n\tif (shouldUpload) {\n\t\tawait createMobileBuild(root, platform);\n\t}\n}\n\nexport async function bundle(root: string, platform: \"ios\" | \"android\") {\n\tawait makeEntrypoint(root, platform);\n\n\tconst outputFile = path.join(\n\t\troot,\n\t\t\"build\",\n\t\t\"output\",\n\t\tplatform,\n\t\t\"main_js_bundle\",\n\t);\n\tawait mkdir(path.dirname(outputFile), { recursive: true });\n\n\tconst defaultConfig = getDefaultConfig(root);\n\n\tconst babelLocation = require.resolve(\"@babel/runtime/package\");\n\n\tconst bableNodeModules = await findUp(\"node_modules\", {\n\t\tcwd: babelLocation,\n\t\ttype: \"directory\",\n\t});\n\tif (!bableNodeModules) {\n\t\tthrow new Error(\"babel node_modules parent folder not found\");\n\t}\n\n\tawait runBuild(\n\t\t{\n\t\t\t...defaultConfig,\n\t\t\tprojectRoot: root,\n\t\t\ttransformer: {\n\t\t\t\t...defaultConfig.transformer,\n\t\t\t\tbabelTransformerPath: require.resolve(\n\t\t\t\t\t\"./whop-react-native-babel-transformer.js\",\n\t\t\t\t),\n\t\t\t},\n\t\t\twatchFolders: [\n\t\t\t\troot,\n\t\t\t\tpath.resolve(root, \"node_modules\"),\n\t\t\t\tbableNodeModules,\n\t\t\t],\n\t\t\treporter: new CustomReporter(),\n\t\t\tresolver: {\n\t\t\t\t...defaultConfig.resolver,\n\t\t\t\tnodeModulesPaths: [\n\t\t\t\t\t...(defaultConfig.resolver?.nodeModulesPaths ?? []),\n\t\t\t\t\tbableNodeModules,\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tdev: false,\n\t\t\tentry: `build/entrypoints/${platform}/index.js`,\n\t\t\tminify: false,\n\t\t\tplatform: platform,\n\t\t\tsourceMap: false,\n\t\t\tout: outputFile,\n\t\t},\n\t);\n\n\tawait rename(\n\t\t`${outputFile}.js`,\n\t\tpath.join(root, \"build\", \"output\", platform, \"main_js_bundle.hbc\"),\n\t);\n\n\tconsole.log(` ✔︎ [${platform}] bundle created`);\n}\n\n// getSupportedAppViewTypes moved to valid-view-type.ts\n\nasync function makeEntrypoint(\n\troot: string,\n\tplatform: \"ios\" | \"android\",\n): Promise<string> {\n\tconst entrypoint = path.join(\n\t\troot,\n\t\t\"build\",\n\t\t\"entrypoints\",\n\t\tplatform,\n\t\t\"index.js\",\n\t);\n\n\tconst files = await getSupportedAppViewTypes(root);\n\n\tconst pascalCase = (str: string) =>\n\t\tstr\n\t\t\t.split(\"-\")\n\t\t\t.map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n\t\t\t.join(\"\");\n\n\tconst imports = files.map(\n\t\t(file) =>\n\t\t\t`import { ${pascalCase(file)} } from \"../../../src/views/${file}\";`,\n\t);\n\tconst registry = files.map(\n\t\t(file) =>\n\t\t\t`AppRegistry.registerComponent(\"${pascalCase(file)}\", () => ${pascalCase(file)});`,\n\t);\n\n\tconst entrypointContent = `import { AppRegistry } from \"react-native\";\n${imports.join(\"\\n\")}\n\n${registry.join(\"\\n\")}\n`;\n\n\tconst entrypointDir = path.dirname(entrypoint);\n\tawait mkdir(entrypointDir, { recursive: true });\n\tawait writeFile(entrypoint, entrypointContent, \"utf-8\");\n\n\tconsole.log(` ✔︎ [${platform}] entrypoint created`);\n\n\treturn entrypoint;\n}\n\nexport async function createMobileBuild(\n\troot: string,\n\tplatform: \"ios\" | \"android\",\n) {\n\tconst viewTypes = await getSupportedAppViewTypes(root);\n\n\tconst fullDirectory = path.join(root, \"build\", \"output\", platform);\n\n\t// Check if the directory contains a file called `main_js_bundle.hbc`\n\tconst mainJsBundle = path.join(fullDirectory, \"main_js_bundle.hbc\");\n\n\tif (!existsSync(mainJsBundle)) {\n\t\tthrow new Error(`main_js_bundle.hbc not found in ${fullDirectory}`);\n\t}\n\n\t// check that that folder only contains the main_js_bundle.hbc file and an optional `assets` folder\n\tconst files = readdirSync(fullDirectory);\n\tif (\n\t\tfiles.length > 2 ||\n\t\tfiles.length < 1 ||\n\t\t!files.includes(\"main_js_bundle.hbc\")\n\t) {\n\t\tthrow new Error(\n\t\t\t\"Directory must contain only the main_js_bundle.hbc file and an optional `assets` folder\",\n\t\t);\n\t}\n\tif (files.length === 2 && !files.includes(\"assets\")) {\n\t\tthrow new Error(\n\t\t\t\"Directory must contain only the main_js_bundle.hbc file and an optional `assets` folder\",\n\t\t);\n\t}\n\n\t// Zip the directory\n\tconst zipData = await zipDirectory(fullDirectory);\n\n\tconst checksum = await getChecksum(zipData);\n\n\tconsole.log(` ✔︎ [${platform}] build zipped with checksum: ${checksum}`);\n\n\tconst fileName = `app_build_${platform}.zip`;\n\tconst uploadedFile = await uploadFile(zipData, fileName, \"application/zip\");\n\n\tconsole.log(\n\t\t` ✔︎ [${platform}] uploaded build: ${fileName} (${(zipData.length / 1024).toFixed(0)} KB)`,\n\t);\n\n\tconst build = await whopSdk.apps.createAppBuild({\n\t\tattachment: { directUploadId: uploadedFile.directUploadId },\n\t\tchecksum,\n\t\tplatform,\n\t\tsupportedAppViewTypes: viewTypes.map(\n\t\t\t(view) =>\n\t\t\t\t({\n\t\t\t\t\t\"experience-view\": \"hub\" as const,\n\t\t\t\t\t\"discover-view\": \"discover\" as const,\n\t\t\t\t})[view],\n\t\t),\n\t});\n\n\tif (!build) {\n\t\tthrow new Error(\"Failed to create app build\");\n\t}\n\n\tconst dashboardUrl = `https://whop.com/dashboard/${COMPANY_ID}/developer/apps/${APP_ID}/builds/?platform=${platform}`;\n\n\tconsole.log(`\\n ✔︎ [${platform}] deployed as development build ✔︎\n - build id: ${build.id}\n - view types: ${viewTypes.join(\", \")}\n - promote to production here: ${dashboardUrl}\\n`);\n\n\treturn build;\n}\n\nasync function zipDirectory(\n\tdirectory: string,\n): Promise<Buffer<ArrayBufferLike>> {\n\tconst zip = new JSZip();\n\n\t// Recursively add files to zip\n\tfunction addFilesToZip(currentPath: string, relativePath = \"\") {\n\t\tconst items = readdirSync(currentPath);\n\n\t\tfor (const item of items) {\n\t\t\tconst fullPath = path.join(currentPath, item);\n\t\t\tconst zipPath = relativePath ? path.join(relativePath, item) : item;\n\t\t\tconst stats = statSync(fullPath);\n\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\taddFilesToZip(fullPath, zipPath);\n\t\t\t} else {\n\t\t\t\tconst fileContent = readFileSync(fullPath);\n\t\t\t\tzip.file(zipPath, fileContent);\n\t\t\t}\n\t\t}\n\t}\n\n\taddFilesToZip(directory);\n\n\t// Generate zip file\n\tconst zipData = await zip.generateAsync({ type: \"nodebuffer\" });\n\n\treturn zipData;\n}\n\nclass CustomReporter implements Reporter {\n\tupdate(event: ReportableEvent) {\n\t\t// Do nothing.\n\t}\n}\n","import { createHash } from \"node:crypto\";\nimport { AGENT_USER_ID, APP_ID, whopSdk } from \"./sdk\";\n\nexport async function uploadFile(\n\tdata: Buffer<ArrayBufferLike>,\n\tname: string,\n\tcontentType: string,\n) {\n\tconst file = new File([data], name, {\n\t\ttype: contentType,\n\t});\n\n\tconst uploadedFile = await whopSdk\n\t\t.withUser(AGENT_USER_ID)\n\t\t.attachments.uploadAttachment({\n\t\t\tfile,\n\t\t\trecord: \"app\",\n\t\t\tid: APP_ID,\n\t\t});\n\n\treturn uploadedFile;\n}\n\nexport async function getChecksum(data: Buffer<ArrayBufferLike>) {\n\tconst hash = createHash(\"sha256\");\n\thash.update(data);\n\treturn hash.digest(\"hex\");\n}\n","import { WhopServerSdk } from \"@whop/api\";\nimport { config } from \"dotenv\";\n\nconfig({\n\tpath: [\".env\", \".env.local\", \".env.development\", \".env.production\"],\n});\n\nexport function env(key: string) {\n\tconst value = process.env[key];\n\tif (!value) {\n\t\tthrow new Error(`Missing environment variable: ${key}`);\n\t}\n\treturn value;\n}\n\nexport const AGENT_USER_ID = env(\"NEXT_PUBLIC_WHOP_AGENT_USER_ID\");\nexport const COMPANY_ID = env(\"NEXT_PUBLIC_WHOP_COMPANY_ID\");\nexport const APP_ID = env(\"NEXT_PUBLIC_WHOP_APP_ID\");\n\nexport const whopSdk: WhopServerSdk = WhopServerSdk({\n\tappApiKey: env(\"WHOP_API_KEY\"),\n\tappId: APP_ID,\n\tcompanyId: COMPANY_ID,\n\tonBehalfOfUserId: AGENT_USER_ID,\n});\n","import { readdir } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nexport const VALID_VIEW_TYPES = [\"experience-view\", \"discover-view\"] as const;\n\nexport async function getSupportedAppViewTypes(\n\troot: string,\n): Promise<(typeof VALID_VIEW_TYPES)[number][]> {\n\tconst views = await readdir(path.join(root, \"src\", \"views\"), {\n\t\twithFileTypes: true,\n\t\trecursive: false,\n\t});\n\tconst files = views\n\t\t.filter((file) => file.isFile())\n\t\t.map((file) => file.name.split(\".\")[0])\n\t\t.filter((file) => !!file);\n\n\tconst validViews = files.filter((file) =>\n\t\tVALID_VIEW_TYPES.includes(file as (typeof VALID_VIEW_TYPES)[number]),\n\t) as (typeof VALID_VIEW_TYPES)[number][];\n\n\tif (validViews.length === 0) {\n\t\tthrow new Error(\n\t\t\t`No valid views found, please create a view in the src/views folder and name it with a valid view type: ${VALID_VIEW_TYPES.join(\", \")}`,\n\t\t);\n\t}\n\n\treturn validViews;\n}\n","import { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { build } from \"esbuild\";\nimport { getChecksum, uploadFile } from \"./file\";\nimport { reanimatedBabelPlugin } from \"./reanimated-bable\";\nimport { APP_ID, COMPANY_ID, whopSdk } from \"./sdk\";\nimport { stripFlowWithBabel } from \"./strip-flow\";\nimport { getSupportedAppViewTypes } from \"./valid-view-type\";\n\nfunction aliasReactNativePlugin() {\n\treturn {\n\t\tname: \"alias-react-native\",\n\t\tsetup(b: import(\"esbuild\").PluginBuild) {\n\t\t\tb.onResolve({ filter: /^react-native$/ }, () => ({\n\t\t\t\tpath: require.resolve(\"react-native-web\"),\n\t\t\t}));\n\t\t},\n\t} satisfies import(\"esbuild\").Plugin;\n}\n\nfunction forceSingleReact() {\n\tconst map = new Map<string, string>([\n\t\t[\"react\", require.resolve(\"react\")],\n\t\t[\"react/jsx-runtime\", require.resolve(\"react/jsx-runtime\")],\n\t\t[\"react/jsx-dev-runtime\", require.resolve(\"react/jsx-dev-runtime\")],\n\t\t[\"react-dom\", require.resolve(\"react-dom\")],\n\t\t[\"react-dom/client\", require.resolve(\"react-dom/client\")],\n\t]);\n\n\tconst rx = /^(react(?:\\/jsx-(?:dev-)?runtime)?|react-dom(?:\\/client)?)$/;\n\n\treturn {\n\t\tname: \"force-single-react\",\n\t\tsetup(b: import(\"esbuild\").PluginBuild) {\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: <explanation>\n\t\t\tb.onResolve({ filter: rx }, (args) => ({ path: map.get(args.path)! }));\n\t\t},\n\t} satisfies import(\"esbuild\").Plugin;\n}\n\nfunction toPascalCase(str: string) {\n\treturn str\n\t\t.split(\"-\")\n\t\t.map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n\t\t.join(\"\");\n}\n\nasync function makeWebEntrypoint(root: string) {\n\tconst files = await getSupportedAppViewTypes(root);\n\n\tconst packageJsonPath = path.join(root, \"package.json\");\n\tconst packageJson = JSON.parse(await readFile(packageJsonPath, \"utf-8\"));\n\tconst hasReactNativeReanimated =\n\t\tpackageJson.dependencies?.[\"react-native-reanimated\"];\n\n\tconst imports = files.map(\n\t\t(file) =>\n\t\t\t`import { ${toPascalCase(file)} } from \"../../../src/views/${file}\";`,\n\t);\n\tconst registry = files.map(\n\t\t(file) =>\n\t\t\t`AppRegistry.registerComponent(\"${toPascalCase(file)}\", () => WhopNavigationWrapper(React, \"${toPascalCase(file)}\", ${toPascalCase(file)}));`,\n\t);\n\n\tconst defaultKey = toPascalCase(files[0] ?? \"experience-view\");\n\tconst reanimatedImport = hasReactNativeReanimated\n\t\t? `import \"react-native-reanimated\";`\n\t\t: \"\";\n\n\tconst entry = `import { AppRegistry } from \"react-native\";\nimport * as React from \"react\";\nimport { WhopNavigationWrapper } from \"@whop/react-native/web\";\n${reanimatedImport}\n\n${imports.join(\"\\n\")} \n\n${registry.join(\"\\n\")} \n\nconst root = document.getElementById(\"root\") || (() => {\n\tconst d = document.createElement(\"div\");\n\td.id = \"root\";\n\tdocument.body.appendChild(d);\n\treturn d;\n})();\nAppRegistry.runApplication(\"${defaultKey}\", { rootTag: root });\n`;\n\n\tconst entryFile = path.join(root, \"build\", \"entrypoints\", \"web\", \"index.tsx\");\n\tawait mkdir(path.dirname(entryFile), { recursive: true });\n\tawait writeFile(entryFile, entry, \"utf-8\");\n\n\treturn entryFile;\n}\n\nexport async function bundleWeb(root: string) {\n\tconst entry = await makeWebEntrypoint(root);\n\n\tconst outDir = path.join(root, \"build\", \"output\", \"web\");\n\tawait mkdir(outDir, { recursive: true });\n\n\tawait build({\n\t\tentryPoints: [entry],\n\t\toutfile: path.join(outDir, \"main.js\"),\n\t\tbundle: true,\n\t\tminify: false,\n\t\tformat: \"esm\",\n\t\tplatform: \"browser\",\n\t\tsourcemap: false,\n\t\tjsx: \"automatic\",\n\t\tmainFields: [\"browser\", \"module\", \"main\"],\n\t\tconditions: [\"browser\", \"import\", \"default\"],\n\t\tdefine: {\n\t\t\tprocess: \"{}\",\n\t\t\t\"process.env\": \"{}\",\n\t\t\t\"process.env.NODE_ENV\": '\"production\"',\n\t\t\t__DEV__: \"false\",\n\t\t\t\"process.env.NEXT_PUBLIC_WHOP_APP_ID\": `\"${APP_ID}\"`,\n\t\t\t// Some RN libraries (e.g., RNGH) expect a Node-like global in the browser\n\t\t\tglobal: \"globalThis\",\n\t\t},\n\t\tresolveExtensions: [\n\t\t\t\".web.tsx\",\n\t\t\t\".web.ts\",\n\t\t\t\".web.js\",\n\t\t\t\".tsx\",\n\t\t\t\".ts\",\n\t\t\t\".jsx\",\n\t\t\t\".js\",\n\t\t],\n\t\tloader: {\n\t\t\t\".png\": \"dataurl\",\n\t\t\t\".jpg\": \"dataurl\",\n\t\t\t\".jpeg\": \"dataurl\",\n\t\t\t\".svg\": \"dataurl\",\n\t\t\t\".ttf\": \"dataurl\",\n\t\t\t\".woff\": \"dataurl\",\n\t\t\t\".woff2\": \"dataurl\",\n\t\t\t\".js\": \"jsx\",\n\t\t\t\".jsx\": \"jsx\",\n\t\t},\n\t\tplugins: [\n\t\t\tforceSingleReact(),\n\t\t\taliasReactNativePlugin(),\n\t\t\treanimatedBabelPlugin(),\n\t\t\tstripFlowWithBabel(),\n\t\t\t{\n\t\t\t\tname: \"force-native-web-stub\",\n\t\t\t\tsetup(b) {\n\t\t\t\t\t// biome-ignore lint/suspicious/noExplicitAny: <explanation>\n\t\t\t\t\tb.onResolve({ filter: /^\\.\\/native-whop-core$/ }, (args: any) => {\n\t\t\t\t\t\t// Always resolve the local source file so extension resolution (.web.ts) applies\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tpath: path.join(args.resolveDir, \"native-whop-core\"),\n\t\t\t\t\t\t\tnamespace: \"file\",\n\t\t\t\t\t\t};\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t});\n\n\tconst html = `<!doctype html>\n<html>\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t<title>Whop App (Web)</title>\n\t\t<style>\n\t\t\t#root {\n\t\t\t\twidth: 100vw;\n\t\t\t\theight: 100vh;\n\t\t\t\tmargin: 0;\n\t\t\t\tpadding: 0;\n\t\t\t\toverflow: hidden;\n\t\t\t\tdisplay: flex;\n\t\t\t\tflex-direction: column;\n\t\t\t\talign-items: stretch;\n\t\t\t\tjustify-content: start;\n\t\t\t}\n\t\t</style>\n\t</head>\n\t<body>\n\t\t<div id=\"root\"></div>\n\t\t<script type=\"module\" src=\"./main.js\"></script>\n\t</body>\n</html>`;\n\tawait writeFile(path.join(outDir, \"index.html\"), html, \"utf-8\");\n\n\tconsole.log(\" ✔︎ [web] bundle created at build/output/web/main.js\");\n}\n\nexport async function buildAndPublish(\n\troot: string,\n\t{\n\t\tshouldBuild = true,\n\t\tshouldUpload = true,\n\t}: { shouldBuild: boolean; shouldUpload: boolean } = {\n\t\tshouldBuild: true,\n\t\tshouldUpload: true,\n\t},\n) {\n\tif (shouldBuild) {\n\t\tawait bundleWeb(root);\n\t}\n\tif (shouldUpload) {\n\t\tawait createWebBuild(root);\n\t}\n}\n\nexport async function createWebBuild(root: string) {\n\tconst fullDirectory = path.join(root, \"build\", \"output\", \"web\");\n\tconst mainJsFile = path.join(fullDirectory, \"main.js\");\n\n\t// Verify bundle exists\n\ttry {\n\t\tawait readFile(mainJsFile);\n\t} catch {\n\t\tthrow new Error(`main.js not found in ${fullDirectory}`);\n\t}\n\n\tconst buf = await readFile(mainJsFile);\n\tconst checksum = await getChecksum(buf);\n\n\tconsole.log(` ✔︎ [web] build checksummed: ${checksum}`);\n\n\tconst fileName = `rnweb_${checksum}.js`;\n\tconst uploadedFile = await uploadFile(\n\t\tbuf,\n\t\tfileName,\n\t\t\"application/javascript\",\n\t);\n\n\tconsole.log(\n\t\t` ✔︎ [web] uploaded build: ${fileName} (${(buf.length / 1024).toFixed(0)} KB)`,\n\t);\n\n\tconst build = await whopSdk.apps.createAppBuild({\n\t\tattachment: { directUploadId: uploadedFile.directUploadId },\n\t\tchecksum,\n\t\tplatform: \"web\",\n\t\tsupportedAppViewTypes: [\"hub\"],\n\t});\n\n\tif (!build) {\n\t\tthrow new Error(\"Failed to create app build\");\n\t}\n\n\tconst dashboardUrl = `https://whop.com/dashboard/${COMPANY_ID}/developer/apps/${APP_ID}/builds/?platform=web`;\n\n\tconsole.log(\n\t\t`\\n ✔︎ [web] deployed as development build ✔︎\\n - build id: ${build.id}\\n - view types: hub\\n - promote to production here: ${dashboardUrl}\\n`,\n\t);\n\n\treturn build;\n}\n","import * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n// build/plugins/reanimatedBabel.ts\nimport * as babel from \"@babel/core\";\n\nconst JS_RE = /\\.(m|c)?(t|j)sx?$/;\n\nexport function reanimatedBabelPlugin() {\n\t// Transform only: your app source (outside node_modules) and reanimated itself.\n\tconst shouldTransform = (p: string) => {\n\t\tif (!JS_RE.test(p)) return false;\n\t\t// Always run on reanimated’s files\n\t\tif (p.includes(`${path.sep}react-native-reanimated${path.sep}`))\n\t\t\treturn true;\n\t\t// Never touch third-party deps\n\t\tif (p.includes(`${path.sep}node_modules${path.sep}`)) return false;\n\t\t// Run on app code under src/\n\t\treturn p.includes(`${path.sep}src${path.sep}`);\n\t};\n\n\treturn {\n\t\tname: \"reanimated-babel\",\n\t\tsetup(b: import(\"esbuild\").PluginBuild) {\n\t\t\tb.onLoad({ filter: JS_RE }, async (args) => {\n\t\t\t\tif (!shouldTransform(args.path)) {\n\t\t\t\t\t// Skip non-target files so other plugins (and esbuild) can process them\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tconst code = await fs.readFile(args.path, \"utf8\");\n\t\t\t\tconst result = await babel.transformAsync(code, {\n\t\t\t\t\tfilename: args.path,\n\t\t\t\t\tsourceMaps: false,\n\t\t\t\t\tbabelrc: false,\n\t\t\t\t\tconfigFile: false,\n\t\t\t\t\t// ORDER MATTERS: Reanimated plugin MUST BE LAST\n\t\t\t\t\tplugins: [\n\t\t\t\t\t\t// Needed by Reanimated on web per docs\n\t\t\t\t\t\t\"@babel/plugin-transform-export-namespace-from\",\n\t\t\t\t\t\t// Handle Flow types present in some RN libs\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"@babel/plugin-transform-flow-strip-types\",\n\t\t\t\t\t\t\t{ allowDeclareFields: true },\n\t\t\t\t\t\t],\n\t\t\t\t\t\t// MUST be last\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"react-native-reanimated/plugin\",\n\t\t\t\t\t\t\t{ relativeSourceLocation: true },\n\t\t\t\t\t\t],\n\t\t\t\t\t],\n\t\t\t\t\tpresets: [], // esbuild handles TS/JSX syntax; no preset-env/preset-react\n\t\t\t\t\tcaller: { name: \"esbuild\" },\n\t\t\t\t\t// Let Babel parse TS/JSX/Flow; keep it broad\n\t\t\t\t\tparserOpts: { plugins: [\"jsx\", \"typescript\"] },\n\t\t\t\t\tgeneratorOpts: { decoratorsBeforeExport: true },\n\t\t\t\t});\n\n\t\t\t\treturn {\n\t\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: <explanation>\n\t\t\t\t\tcontents: result!.code!,\n\t\t\t\t\t// biome-ignore lint/suspicious/noExplicitAny: <explanation>\n\t\t\t\t\tloader: pickLoader(args.path) as any,\n\t\t\t\t};\n\t\t\t});\n\t\t},\n\t};\n}\n\nfunction pickLoader(file: string) {\n\tconst ext = path.extname(file).toLowerCase();\n\tif (ext === \".tsx\") return \"tsx\";\n\tif (ext === \".ts\") return \"ts\";\n\tif (ext === \".jsx\") return \"jsx\";\n\t// For .js: many RN libs contain JSX; be permissive\n\treturn \"jsx\";\n}\n","import * as fs from \"node:fs/promises\";\n// stripFlowWithBabel.ts\nimport * as babel from \"@babel/core\";\n\nexport function stripFlowWithBabel() {\n\tconst filter = /\\.(m|c)?jsx?$/;\n\treturn {\n\t\tname: \"strip-flow-with-babel\",\n\t\t// biome-ignore lint/suspicious/noExplicitAny: <explanation>\n\t\tsetup(b: any) {\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: <explanation>\n\t\t\tb.onLoad({ filter }, async (args: any) => {\n\t\t\t\tconst code = await fs.readFile(args.path, \"utf8\");\n\t\t\t\tconst out = await babel.transformAsync(code, {\n\t\t\t\t\tfilename: args.path,\n\t\t\t\t\tbabelrc: false,\n\t\t\t\t\tconfigFile: false,\n\t\t\t\t\tplugins: [\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"@babel/plugin-transform-flow-strip-types\",\n\t\t\t\t\t\t\t{ allowDeclareFields: true },\n\t\t\t\t\t\t],\n\t\t\t\t\t],\n\t\t\t\t\tparserOpts: { plugins: [\"jsx\", \"flow\"] },\n\t\t\t\t\tsourceMaps: false,\n\t\t\t\t});\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: <explanation>\n\t\t\t\treturn { contents: out!.code!, loader: \"jsx\" };\n\t\t\t});\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;AAAA,SAAS,cAAAA,mBAAkB;AAC3B,OAAOC,WAAU;AACjB,SAAS,iBAAiB;AAC1B,SAAS,UAAAC,eAAc;AACvB,OAAO,YAAY;AACnB,SAAS,cAAc;;;ACLvB,SAAS,YAAY,cAAc,aAAa,gBAAgB;AAChE,SAAS,OAAO,QAAQ,iBAAiB;AACzC,OAAOC,WAAU;AACjB,SAAS,wBAAwB;AACjC,SAAS,cAAc;AACvB,OAAO,WAAW;AAClB,SAA8C,gBAAgB;;;ACN9D,SAAS,kBAAkB;;;ACA3B,SAAS,qBAAqB;AAC9B,SAAS,cAAc;AAEvB,OAAO;AAAA,EACN,MAAM,CAAC,QAAQ,cAAc,oBAAoB,iBAAiB;AACnE,CAAC;AAEM,SAAS,IAAI,KAAa;AAChC,QAAM,QAAQ,QAAQ,IAAI,GAAG;AAC7B,MAAI,CAAC,OAAO;AACX,UAAM,IAAI,MAAM,iCAAiC,GAAG,EAAE;AAA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mB,MAAM,IAAI,CAAC;AAAA,EAC7C;AAEA,QAAM,QAAQ,IAAI,QAAQ;AAC3B;AAEA,eAAe,oBAAoB,MAAc;AAChD,QAAM,iBAAiBC,MAAK,KAAK,MAAM,OAAO;AAC9C,MAAIC,YAAW,cAAc,GAAG;AAC/B,UAAM,OAAO,cAAc;AAAA,EAC5B;AACA,UAAQ,IAAI,uCAA6B;AAC1C;AAEA,eAAe,0BAA0B;AACxC,QAAM,OAAO,MAAMC,QAAO,gBAAgB,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC;AAChE,MAAI,CAAC,MAAM;AACV,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AACA,QAAM,OAAOF,MAAK,QAAQ,IAAI;AAC9B,SAAO;AACR;AAEA,eAAe,gBAAgB;AAC9B,QAAM,QAAQ,IAAI,yBAAyB;AAC3C,QAAM,cAAc,yBAAyB,KAAK;AAElD,UAAQ,IAAI;AAAA;AAAA,EAEX,WAAW;AAAA;AAAA;AAAA,EAGX;AAED,SAAO,SAAS,aAAa,EAAE,OAAO,KAAK,CAAC;AAC7C;AAEA,KAAK,EACH,MAAM,CAAC,QAAQ;AACf,UAAQ,MAAM,GAAG;AACjB,UAAQ,KAAK,CAAC;AACf,CAAC,EACA,KAAK,MAAM;AACX,UAAQ,KAAK,CAAC;AACf,CAAC;","names":["existsSync","path","findUp","path","path","build","mkdir","readFile","writeFile","path","path","fs","babel","path","readFile","mkdir","writeFile","buildAndPublish","build","buildAndPublish","path","existsSync","findUp"]}
|
package/dist/lib/index.d.mts
CHANGED
|
@@ -61,4 +61,18 @@ interface ExecAsyncApi extends ExecSyncApi {
|
|
|
61
61
|
declare function __internal_execSync<F extends keyof ExecSyncApi>(name: F, params: Parameters<ExecSyncApi[F]>[0]): ReturnType<ExecSyncApi[F]>;
|
|
62
62
|
declare function __internal_execAsync<F extends keyof ExecAsyncApi>(name: F, params: Parameters<ExecAsyncApi[F]>[0]): Promise<ReturnType<ExecAsyncApi[F]>>;
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Web-safe wrapper for react-native-haptic-feedback.
|
|
66
|
+
* - Lazily imports the native module only in native environments.
|
|
67
|
+
* - Provides a no-op fallback on web to avoid runtime crashes.
|
|
68
|
+
*/
|
|
69
|
+
type HapticType = "selection" | "impactLight" | "impactMedium" | "impactHeavy" | "notificationSuccess" | "notificationWarning" | "notificationError";
|
|
70
|
+
type HapticOptions = {
|
|
71
|
+
enableVibrateFallback?: boolean;
|
|
72
|
+
ignoreAndroidSystemSettings?: boolean;
|
|
73
|
+
};
|
|
74
|
+
declare const Haptics: {
|
|
75
|
+
trigger(type: HapticType, options?: HapticOptions): Promise<void>;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export { type DiscoverViewProps, type ExecAsyncApi, type ExecSyncApi, type ExperienceViewProps, Haptics, type PathParams, __internal_execAsync, __internal_execSync, whopSdk };
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -61,4 +61,18 @@ interface ExecAsyncApi extends ExecSyncApi {
|
|
|
61
61
|
declare function __internal_execSync<F extends keyof ExecSyncApi>(name: F, params: Parameters<ExecSyncApi[F]>[0]): ReturnType<ExecSyncApi[F]>;
|
|
62
62
|
declare function __internal_execAsync<F extends keyof ExecAsyncApi>(name: F, params: Parameters<ExecAsyncApi[F]>[0]): Promise<ReturnType<ExecAsyncApi[F]>>;
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Web-safe wrapper for react-native-haptic-feedback.
|
|
66
|
+
* - Lazily imports the native module only in native environments.
|
|
67
|
+
* - Provides a no-op fallback on web to avoid runtime crashes.
|
|
68
|
+
*/
|
|
69
|
+
type HapticType = "selection" | "impactLight" | "impactMedium" | "impactHeavy" | "notificationSuccess" | "notificationWarning" | "notificationError";
|
|
70
|
+
type HapticOptions = {
|
|
71
|
+
enableVibrateFallback?: boolean;
|
|
72
|
+
ignoreAndroidSystemSettings?: boolean;
|
|
73
|
+
};
|
|
74
|
+
declare const Haptics: {
|
|
75
|
+
trigger(type: HapticType, options?: HapticOptions): Promise<void>;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export { type DiscoverViewProps, type ExecAsyncApi, type ExecSyncApi, type ExperienceViewProps, Haptics, type PathParams, __internal_execAsync, __internal_execSync, whopSdk };
|
package/dist/lib/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
9
|
var __export = (target, all) => {
|
|
8
10
|
for (var name in all)
|
|
@@ -17,11 +19,20 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
19
|
return to;
|
|
18
20
|
};
|
|
19
21
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
+
mod
|
|
29
|
+
));
|
|
20
30
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
31
|
|
|
22
32
|
// src/lib/index.ts
|
|
23
33
|
var lib_exports = {};
|
|
24
34
|
__export(lib_exports, {
|
|
35
|
+
Haptics: () => haptics_default,
|
|
25
36
|
__internal_execAsync: () => __internal_execAsync,
|
|
26
37
|
__internal_execSync: () => __internal_execSync,
|
|
27
38
|
whopSdk: () => whopSdk
|
|
@@ -34,11 +45,263 @@ __export(client_sdk_exports, {
|
|
|
34
45
|
whopSdk: () => whopSdk
|
|
35
46
|
});
|
|
36
47
|
var import_api = require("@whop/api");
|
|
37
|
-
var
|
|
48
|
+
var import_react_native3 = require("react-native");
|
|
38
49
|
|
|
39
50
|
// src/lib/native-whop-core.ts
|
|
51
|
+
var import_react_native2 = require("react-native");
|
|
52
|
+
|
|
53
|
+
// src/lib/native-whop-core-stub.ts
|
|
40
54
|
var import_react_native = require("react-native");
|
|
41
|
-
var
|
|
55
|
+
var WhopCoreObservable = class {
|
|
56
|
+
subscribers = /* @__PURE__ */ new Set();
|
|
57
|
+
value;
|
|
58
|
+
constructor(value) {
|
|
59
|
+
this.value = value;
|
|
60
|
+
}
|
|
61
|
+
setValue(value) {
|
|
62
|
+
this.value = value;
|
|
63
|
+
for (const callback of this.subscribers) {
|
|
64
|
+
callback(value);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
getValue() {
|
|
68
|
+
return this.value;
|
|
69
|
+
}
|
|
70
|
+
subscribe(callback) {
|
|
71
|
+
this.subscribers.add(callback);
|
|
72
|
+
return () => {
|
|
73
|
+
this.subscribers.delete(callback);
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
var WhopCoreNavigation = class {
|
|
78
|
+
path = new WhopCoreObservable([]);
|
|
79
|
+
sheet = new WhopCoreObservable(null);
|
|
80
|
+
constructor() {
|
|
81
|
+
this.getFullStack = this.getFullStack.bind(this);
|
|
82
|
+
this.getCurrentSheet = this.getCurrentSheet.bind(this);
|
|
83
|
+
this.subscribeToPath = this.subscribeToPath.bind(this);
|
|
84
|
+
this.subscribeToSheet = this.subscribeToSheet.bind(this);
|
|
85
|
+
}
|
|
86
|
+
push(route) {
|
|
87
|
+
if (this.getCurrent().path.join("/") === route.path.join("/")) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
this.path.setValue([...this.path.getValue(), route]);
|
|
91
|
+
if (typeof window !== "undefined" && window.history) {
|
|
92
|
+
try {
|
|
93
|
+
const pathBits = route.path.join("/");
|
|
94
|
+
const paramsBits = Object.entries(route.params).map(([key, value]) => `${key}=${value}`).join("&");
|
|
95
|
+
window.history.pushState(
|
|
96
|
+
{ route, index: this.path.getValue().length },
|
|
97
|
+
"",
|
|
98
|
+
`#${pathBits}?${paramsBits}`
|
|
99
|
+
);
|
|
100
|
+
} catch {
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
pop() {
|
|
105
|
+
if (typeof window !== "undefined" && window.history) {
|
|
106
|
+
try {
|
|
107
|
+
window.history.back();
|
|
108
|
+
} catch {
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
getFullStack() {
|
|
113
|
+
return this.path.getValue();
|
|
114
|
+
}
|
|
115
|
+
getCurrent() {
|
|
116
|
+
return this.path.getValue()[this.path.getValue().length - 1] ?? {
|
|
117
|
+
path: [],
|
|
118
|
+
params: {}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
presentSheet(route) {
|
|
122
|
+
this.sheet.setValue(route);
|
|
123
|
+
}
|
|
124
|
+
dismissSheet() {
|
|
125
|
+
this.sheet.setValue(null);
|
|
126
|
+
}
|
|
127
|
+
getCurrentSheet() {
|
|
128
|
+
return this.sheet.getValue() ?? null;
|
|
129
|
+
}
|
|
130
|
+
subscribeToPath(callback) {
|
|
131
|
+
return this.path.subscribe(callback);
|
|
132
|
+
}
|
|
133
|
+
subscribeToSheet(callback) {
|
|
134
|
+
return this.sheet.subscribe(callback);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
var navigation = new WhopCoreNavigation();
|
|
138
|
+
if (typeof window !== "undefined" && import_react_native.Platform.OS === "web") {
|
|
139
|
+
window.whopCoreNavigation = navigation;
|
|
140
|
+
window.addEventListener("popstate", (e) => {
|
|
141
|
+
const currentLength = navigation.path.getValue().length;
|
|
142
|
+
if (!e.state) {
|
|
143
|
+
navigation.path.setValue(navigation.path.getValue().slice(0, -1));
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const index = e.state.index;
|
|
147
|
+
const route = e.state.route;
|
|
148
|
+
if (index < currentLength) {
|
|
149
|
+
navigation.path.setValue(navigation.path.getValue().slice(0, -1));
|
|
150
|
+
} else {
|
|
151
|
+
navigation.path.setValue([...navigation.path.getValue(), route]);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
function ok(data) {
|
|
156
|
+
return { isOk: true, data: JSON.stringify(data), errorMessage: null };
|
|
157
|
+
}
|
|
158
|
+
function err(message) {
|
|
159
|
+
return { isOk: false, data: null, errorMessage: message };
|
|
160
|
+
}
|
|
161
|
+
function getOrigin() {
|
|
162
|
+
if (typeof window !== "undefined" && window.location) {
|
|
163
|
+
return window.location.origin;
|
|
164
|
+
}
|
|
165
|
+
return "";
|
|
166
|
+
}
|
|
167
|
+
var syncHandlers = {
|
|
168
|
+
getAppApiOrigin() {
|
|
169
|
+
return { apiOrigin: getOrigin() };
|
|
170
|
+
},
|
|
171
|
+
cacheGet({ key }) {
|
|
172
|
+
try {
|
|
173
|
+
if (typeof window !== "undefined" && window.localStorage && key) {
|
|
174
|
+
return { data: window.localStorage.getItem(key) };
|
|
175
|
+
}
|
|
176
|
+
return { data: null };
|
|
177
|
+
} catch {
|
|
178
|
+
return { data: null };
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
cacheSet({ key, data }) {
|
|
182
|
+
try {
|
|
183
|
+
if (typeof window !== "undefined" && window.localStorage && key != null) {
|
|
184
|
+
if (data == null) {
|
|
185
|
+
window.localStorage.removeItem(key);
|
|
186
|
+
} else {
|
|
187
|
+
window.localStorage.setItem(key, data);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
} catch {
|
|
191
|
+
}
|
|
192
|
+
return {};
|
|
193
|
+
},
|
|
194
|
+
routerPush(route) {
|
|
195
|
+
navigation.push(route);
|
|
196
|
+
return {};
|
|
197
|
+
},
|
|
198
|
+
routerPop() {
|
|
199
|
+
navigation.pop();
|
|
200
|
+
return {};
|
|
201
|
+
},
|
|
202
|
+
routerGetCurrent() {
|
|
203
|
+
return navigation.getCurrent();
|
|
204
|
+
},
|
|
205
|
+
setNavigationBarData() {
|
|
206
|
+
return {};
|
|
207
|
+
},
|
|
208
|
+
routerPresentSheet({ path, params }) {
|
|
209
|
+
navigation.presentSheet({
|
|
210
|
+
path: Array.from(path ?? []),
|
|
211
|
+
params: params ?? {}
|
|
212
|
+
});
|
|
213
|
+
return {};
|
|
214
|
+
},
|
|
215
|
+
routerDismissSheet() {
|
|
216
|
+
navigation.dismissSheet();
|
|
217
|
+
return {};
|
|
218
|
+
},
|
|
219
|
+
routerGetCurrentSheet() {
|
|
220
|
+
return navigation.getCurrentSheet() ?? null;
|
|
221
|
+
},
|
|
222
|
+
downgradeToWebView() {
|
|
223
|
+
return {};
|
|
224
|
+
},
|
|
225
|
+
getHostAppDetails() {
|
|
226
|
+
return {
|
|
227
|
+
build: "web",
|
|
228
|
+
version: "0.0.0",
|
|
229
|
+
platform: "web",
|
|
230
|
+
buildType: "appstore"
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
var iframeModulePromise = null;
|
|
235
|
+
async function loadIframeModule() {
|
|
236
|
+
if (!iframeModulePromise) {
|
|
237
|
+
iframeModulePromise = import("@whop/iframe");
|
|
238
|
+
}
|
|
239
|
+
return await iframeModulePromise;
|
|
240
|
+
}
|
|
241
|
+
var iframeSdk = null;
|
|
242
|
+
async function loadIframeSdk() {
|
|
243
|
+
if (!iframeSdk) {
|
|
244
|
+
const module2 = await loadIframeModule();
|
|
245
|
+
iframeSdk = module2.createSdk({
|
|
246
|
+
appId: process.env.NEXT_PUBLIC_WHOP_APP_ID
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
return iframeSdk;
|
|
250
|
+
}
|
|
251
|
+
var asyncHandlers = {
|
|
252
|
+
inAppPurchase: async ({ planId, id }) => {
|
|
253
|
+
const sdk = await loadIframeSdk();
|
|
254
|
+
const result = await sdk.inAppPurchase({ planId, id: id ?? void 0 });
|
|
255
|
+
if (result.status === "ok") {
|
|
256
|
+
return {
|
|
257
|
+
sessionId: result.data.sessionId,
|
|
258
|
+
receiptId: result.data.receiptId
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
throw new Error(result.error);
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
var nativeWhopCoreStub = {
|
|
265
|
+
execSync(name, paramsJson) {
|
|
266
|
+
try {
|
|
267
|
+
const params = paramsJson ? JSON.parse(paramsJson) : {};
|
|
268
|
+
const handler = syncHandlers[name];
|
|
269
|
+
if (!handler) return err(`Unknown sync method: ${name}`);
|
|
270
|
+
const result = handler(params);
|
|
271
|
+
return ok(result);
|
|
272
|
+
} catch (e) {
|
|
273
|
+
return err(e instanceof Error ? e.message : "Unknown error");
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
async execAsync(name, paramsJson) {
|
|
277
|
+
try {
|
|
278
|
+
const params = paramsJson ? JSON.parse(paramsJson) : {};
|
|
279
|
+
const handler = asyncHandlers[name];
|
|
280
|
+
if (!handler) return err(`Unknown async method: ${name}`);
|
|
281
|
+
const result = await handler(params);
|
|
282
|
+
return ok(result);
|
|
283
|
+
} catch (e) {
|
|
284
|
+
return err(e instanceof Error ? e.message : "Unknown error");
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
var native_whop_core_stub_default = nativeWhopCoreStub;
|
|
289
|
+
|
|
290
|
+
// src/lib/native-whop-core.ts
|
|
291
|
+
function resolveNative() {
|
|
292
|
+
try {
|
|
293
|
+
const registry = import_react_native2.TurboModuleRegistry;
|
|
294
|
+
const get = registry?.getEnforcing ?? registry?.get;
|
|
295
|
+
if (typeof get === "function") {
|
|
296
|
+
return get.call(registry, "NativeWhopCore");
|
|
297
|
+
}
|
|
298
|
+
return null;
|
|
299
|
+
} catch {
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
var native = resolveNative();
|
|
304
|
+
var native_whop_core_default = native ?? native_whop_core_stub_default;
|
|
42
305
|
|
|
43
306
|
// src/lib/native-whop-core-wrapper.ts
|
|
44
307
|
function __internal_execSync(name, params) {
|
|
@@ -62,13 +325,13 @@ async function __internal_execAsync(name, params) {
|
|
|
62
325
|
// src/lib/client-sdk.ts
|
|
63
326
|
__reExport(client_sdk_exports, require("@whop/api"));
|
|
64
327
|
function getAppOrigin() {
|
|
65
|
-
if (
|
|
328
|
+
if (import_react_native3.Platform.OS === "android" || import_react_native3.Platform.OS === "ios") {
|
|
66
329
|
return __internal_execSync("getAppApiOrigin", {}).apiOrigin;
|
|
67
330
|
}
|
|
68
|
-
if (
|
|
331
|
+
if (import_react_native3.Platform.OS === "web" && typeof window !== "undefined") {
|
|
69
332
|
return window.location.origin;
|
|
70
333
|
}
|
|
71
|
-
throw new Error(`Unsupported platform: ${
|
|
334
|
+
throw new Error(`Unsupported platform: ${import_react_native3.Platform.OS}`);
|
|
72
335
|
}
|
|
73
336
|
var appOrigin = getAppOrigin();
|
|
74
337
|
var whopSdk = (0, import_api.WhopClientSdk)({
|
|
@@ -78,8 +341,45 @@ var whopSdk = (0, import_api.WhopClientSdk)({
|
|
|
78
341
|
|
|
79
342
|
// src/lib/index.ts
|
|
80
343
|
__reExport(lib_exports, client_sdk_exports, module.exports);
|
|
344
|
+
|
|
345
|
+
// src/lib/haptics.ts
|
|
346
|
+
var nativeModule = null;
|
|
347
|
+
var loadingPromise = null;
|
|
348
|
+
async function ensureNativeLoaded() {
|
|
349
|
+
const isWeb = typeof document !== "undefined" && typeof window !== "undefined";
|
|
350
|
+
if (isWeb) return;
|
|
351
|
+
if (nativeModule || loadingPromise) {
|
|
352
|
+
return loadingPromise ?? Promise.resolve();
|
|
353
|
+
}
|
|
354
|
+
loadingPromise = import("react-native-haptic-feedback").then((mod) => {
|
|
355
|
+
nativeModule = { trigger: mod.default.trigger };
|
|
356
|
+
}).catch(() => {
|
|
357
|
+
}).finally(() => {
|
|
358
|
+
loadingPromise = null;
|
|
359
|
+
});
|
|
360
|
+
return loadingPromise;
|
|
361
|
+
}
|
|
362
|
+
var HAPTIC_NOOP = {
|
|
363
|
+
trigger: (_type, _options) => {
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
var Haptics = {
|
|
367
|
+
async trigger(type, options) {
|
|
368
|
+
await ensureNativeLoaded();
|
|
369
|
+
if (nativeModule) {
|
|
370
|
+
try {
|
|
371
|
+
nativeModule.trigger(type, options);
|
|
372
|
+
} catch {
|
|
373
|
+
}
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
HAPTIC_NOOP.trigger(type, options);
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
var haptics_default = Haptics;
|
|
81
380
|
// Annotate the CommonJS export names for ESM import in node:
|
|
82
381
|
0 && (module.exports = {
|
|
382
|
+
Haptics,
|
|
83
383
|
__internal_execAsync,
|
|
84
384
|
__internal_execSync,
|
|
85
385
|
whopSdk
|
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-wrapper.ts"],"sourcesContent":["export * from \"./client-sdk\";\nexport * from \"./native-whop-core-wrapper\";\nexport * from \"./props\";\n","import { WhopClientSdk } from \"@whop/api\";\nimport { Platform } from \"react-native\";\nimport { __internal_execSync } from \"./native-whop-core-wrapper\";\n\nfunction getAppOrigin() {\n\tif (Platform.OS === \"android\" || Platform.OS === \"ios\") {\n\t\treturn __internal_execSync(\"getAppApiOrigin\", {}).apiOrigin;\n\t}\n\n\tif (Platform.OS === \"web\" && typeof window !== \"undefined\") {\n\t\treturn window.location.origin;\n\t}\n\n\tthrow new Error(`Unsupported platform: ${Platform.OS}`);\n}\n\nconst appOrigin = getAppOrigin();\n\nexport const whopSdk: WhopClientSdk = WhopClientSdk({\n\tapiOrigin: appOrigin,\n\tapiPath: \"/_whop/public-graphql/\",\n});\n\nexport * from \"@whop/api\";\n","import type { TurboModule } from \"react-native\";\nimport { TurboModuleRegistry } from \"react-native\";\n\nexport type FunctionCallResult = {\n\tisOk: boolean;\n\tdata: string | null;\n\terrorMessage: string | null;\n};\n\nexport interface Spec extends TurboModule {\n\texecSync(name: string, paramsJson: string): FunctionCallResult;\n\texecAsync(name: string, paramsJson: string): Promise<FunctionCallResult>;\n}\n\nexport default TurboModuleRegistry.getEnforcing<Spec>(\"NativeWhopCore\");\n","import nativeWhopCore from \"./native-whop-core\";\nimport type { PathParams } from \"./props\";\n\n// biome-ignore lint/complexity/noBannedTypes: allow here\ntype EmptyObject = {};\n\nexport interface ExecSyncApi {\n\tgetAppApiOrigin(params: EmptyObject): { apiOrigin: string };\n\tcacheGet(params: { key?: string | null }): { data?: string | null };\n\tcacheSet(params: { key?: string | null; data?: string | null }): EmptyObject;\n\trouterPush(params: PathParams): EmptyObject;\n\trouterPop(params: EmptyObject): EmptyObject;\n\trouterGetCurrent(params: EmptyObject): PathParams;\n\tsetNavigationBarData(params: {\n\t\ttitle?: string | null;\n\t\tdescription?: string | null;\n\t}): EmptyObject;\n\trouterPresentSheet(params: PathParams): EmptyObject;\n\trouterDismissSheet(params: EmptyObject): EmptyObject;\n\trouterGetCurrentSheet(params: EmptyObject): PathParams | null | undefined;\n\tdowngradeToWebView(params: EmptyObject): EmptyObject;\n\tgetHostAppDetails(params: EmptyObject): {\n\t\tbuild: string;\n\t\tversion: string;\n\t\tplatform: \"ios\" | \"android\" | \"web\";\n\t\tbuildType: \"appstore\" | \"testflight\" | \"debug\";\n\t};\n}\n\nexport interface ExecAsyncApi extends ExecSyncApi {\n\tinAppPurchase(params: {\n\t\tid?: string | null;\n\t\tplanId: string;\n\t}): {\n\t\tsessionId: string;\n\t\treceiptId: string;\n\t};\n}\n\nexport function __internal_execSync<F extends keyof ExecSyncApi>(\n\tname: F,\n\tparams: Parameters<ExecSyncApi[F]>[0],\n): ReturnType<ExecSyncApi[F]> {\n\tconst resultJson = nativeWhopCore.execSync(name, JSON.stringify(params));\n\tif (!resultJson.isOk) {\n\t\tthrow new Error(`Failed to execute ${name}: ${resultJson.errorMessage}`);\n\t}\n\n\treturn JSON.parse(resultJson.data || \"{}\") as ReturnType<ExecSyncApi[F]>;\n}\n\nexport async function __internal_execAsync<F extends keyof ExecAsyncApi>(\n\tname: F,\n\tparams: Parameters<ExecAsyncApi[F]>[0],\n): Promise<ReturnType<ExecAsyncApi[F]>> {\n\tconst resultJson = await nativeWhopCore.execAsync(\n\t\tname,\n\t\tJSON.stringify(params),\n\t);\n\n\tif (!resultJson.isOk) {\n\t\tthrow new Error(`Failed to execute ${name}: ${resultJson.errorMessage}`);\n\t}\n\n\treturn JSON.parse(resultJson.data || \"{}\") as ReturnType<ExecAsyncApi[F]>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA,iBAA8B;AAC9B,IAAAA,uBAAyB;;;ACAzB,0BAAoC;AAapC,IAAO,2BAAQ,wCAAoB,aAAmB,gBAAgB;;;ACyB/D,SAAS,oBACf,MACA,QAC6B;AAC7B,QAAM,aAAa,yBAAe,SAAS,MAAM,KAAK,UAAU,MAAM,CAAC;AACvE,MAAI,CAAC,WAAW,MAAM;AACrB,UAAM,IAAI,MAAM,qBAAqB,IAAI,KAAK,WAAW,YAAY,EAAE;AAAA,EACxE;AAEA,SAAO,KAAK,MAAM,WAAW,QAAQ,IAAI;AAC1C;AAEA,eAAsB,qBACrB,MACA,QACuC;AACvC,QAAM,aAAa,MAAM,yBAAe;AAAA,IACvC;AAAA,IACA,KAAK,UAAU,MAAM;AAAA,EACtB;AAEA,MAAI,CAAC,WAAW,MAAM;AACrB,UAAM,IAAI,MAAM,qBAAqB,IAAI,KAAK,WAAW,YAAY,EAAE;AAAA,EACxE;AAEA,SAAO,KAAK,MAAM,WAAW,QAAQ,IAAI;AAC1C;;;AF1CA,+BAAc;AAnBd,SAAS,eAAe;AACvB,MAAI,8BAAS,OAAO,aAAa,8BAAS,OAAO,OAAO;AACvD,WAAO,oBAAoB,mBAAmB,CAAC,CAAC,EAAE;AAAA,EACnD;AAEA,MAAI,8BAAS,OAAO,SAAS,OAAO,WAAW,aAAa;AAC3D,WAAO,OAAO,SAAS;AAAA,EACxB;AAEA,QAAM,IAAI,MAAM,yBAAyB,8BAAS,EAAE,EAAE;AACvD;AAEA,IAAM,YAAY,aAAa;AAExB,IAAM,cAAyB,0BAAc;AAAA,EACnD,WAAW;AAAA,EACX,SAAS;AACV,CAAC;;;ADrBD,wBAAc,oBAAd;","names":["import_react_native"]}
|
|
1
|
+
{"version":3,"sources":["../../src/lib/index.ts","../../src/lib/client-sdk.ts","../../src/lib/native-whop-core.ts","../../src/lib/native-whop-core-stub.ts","../../src/lib/native-whop-core-wrapper.ts","../../src/lib/haptics.ts"],"sourcesContent":["export * from \"./client-sdk\";\nexport * from \"./native-whop-core-wrapper\";\nexport * from \"./props\";\nimport Haptics from \"./haptics\";\n\nexport { Haptics };\n","import { WhopClientSdk } from \"@whop/api\";\nimport { Platform } from \"react-native\";\nimport { __internal_execSync } from \"./native-whop-core-wrapper\";\n\nfunction getAppOrigin() {\n\tif (Platform.OS === \"android\" || Platform.OS === \"ios\") {\n\t\treturn __internal_execSync(\"getAppApiOrigin\", {}).apiOrigin;\n\t}\n\n\tif (Platform.OS === \"web\" && typeof window !== \"undefined\") {\n\t\treturn window.location.origin;\n\t}\n\n\tthrow new Error(`Unsupported platform: ${Platform.OS}`);\n}\n\nconst appOrigin = getAppOrigin();\n\nexport const whopSdk: WhopClientSdk = WhopClientSdk({\n\tapiOrigin: appOrigin,\n\tapiPath: \"/_whop/public-graphql/\",\n});\n\nexport * from \"@whop/api\";\n","import type { TurboModule } from \"react-native\";\nimport { TurboModuleRegistry } from \"react-native\";\nimport stub from \"./native-whop-core-stub\";\n\nexport type FunctionCallResult = {\n\tisOk: boolean;\n\tdata: string | null;\n\terrorMessage: string | null;\n};\n\nexport interface Spec extends TurboModule {\n\texecSync(name: string, paramsJson: string): FunctionCallResult;\n\texecAsync(name: string, paramsJson: string): Promise<FunctionCallResult>;\n}\n\nfunction resolveNative(): Spec | null {\n\ttry {\n\t\t// biome-ignore lint/suspicious/noExplicitAny: <explanation>\n\t\tconst registry: any = TurboModuleRegistry as any;\n\t\tconst get = registry?.getEnforcing ?? registry?.get;\n\t\tif (typeof get === \"function\") {\n\t\t\treturn get.call(registry, \"NativeWhopCore\") as Spec;\n\t\t}\n\t\treturn null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nconst native = resolveNative();\n\nexport default native ?? (stub as Spec);\n","import { Platform } from \"react-native\";\nimport type { ExecAsyncApi, ExecSyncApi } from \"./native-whop-core-wrapper\";\n\nexport type FunctionCallResult = {\n\tisOk: boolean;\n\tdata: string | null;\n\terrorMessage: string | null;\n};\n\ntype Route = { path: string[]; params: Record<string, string> };\n\nclass WhopCoreObservable<T> {\n\tprivate subscribers: Set<(value: T) => void> = new Set();\n\tprivate value: T;\n\n\tconstructor(value: T) {\n\t\tthis.value = value;\n\t}\n\n\tsetValue(value: T) {\n\t\tthis.value = value;\n\t\tfor (const callback of this.subscribers) {\n\t\t\tcallback(value);\n\t\t}\n\t}\n\n\tgetValue() {\n\t\treturn this.value;\n\t}\n\n\tsubscribe(callback: (value: T) => void) {\n\t\tthis.subscribers.add(callback);\n\t\treturn () => {\n\t\t\tthis.subscribers.delete(callback);\n\t\t};\n\t}\n}\n\nclass WhopCoreNavigation {\n\tpublic path = new WhopCoreObservable<Route[]>([]);\n\tpublic sheet = new WhopCoreObservable<Route | null>(null);\n\n\tconstructor() {\n\t\tthis.getFullStack = this.getFullStack.bind(this);\n\t\tthis.getCurrentSheet = this.getCurrentSheet.bind(this);\n\t\tthis.subscribeToPath = this.subscribeToPath.bind(this);\n\t\tthis.subscribeToSheet = this.subscribeToSheet.bind(this);\n\t}\n\n\tpush(route: Route) {\n\t\tif (this.getCurrent().path.join(\"/\") === route.path.join(\"/\")) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.path.setValue([...this.path.getValue(), route]);\n\t\tif (typeof window !== \"undefined\" && window.history) {\n\t\t\ttry {\n\t\t\t\tconst pathBits = route.path.join(\"/\");\n\t\t\t\tconst paramsBits = Object.entries(route.params)\n\t\t\t\t\t.map(([key, value]) => `${key}=${value}`)\n\t\t\t\t\t.join(\"&\");\n\t\t\t\twindow.history.pushState(\n\t\t\t\t\t{ route, index: this.path.getValue().length },\n\t\t\t\t\t\"\",\n\t\t\t\t\t`#${pathBits}?${paramsBits}`,\n\t\t\t\t);\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\tpop() {\n\t\tif (typeof window !== \"undefined\" && window.history) {\n\t\t\ttry {\n\t\t\t\twindow.history.back();\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\tgetFullStack() {\n\t\treturn this.path.getValue();\n\t}\n\n\tgetCurrent() {\n\t\treturn (\n\t\t\tthis.path.getValue()[this.path.getValue().length - 1] ?? {\n\t\t\t\tpath: [],\n\t\t\t\tparams: {},\n\t\t\t}\n\t\t);\n\t}\n\n\tpresentSheet(route: Route) {\n\t\tthis.sheet.setValue(route);\n\t}\n\n\tdismissSheet() {\n\t\tthis.sheet.setValue(null);\n\t}\n\n\tgetCurrentSheet() {\n\t\treturn this.sheet.getValue() ?? null;\n\t}\n\n\tsubscribeToPath(callback: (route: Route[]) => void) {\n\t\treturn this.path.subscribe(callback);\n\t}\n\n\tsubscribeToSheet(callback: (route: Route | null) => void) {\n\t\treturn this.sheet.subscribe(callback);\n\t}\n}\n\nexport type TWhopCoreNavigation = WhopCoreNavigation;\n\nconst navigation = new WhopCoreNavigation();\nif (typeof window !== \"undefined\" && Platform.OS === \"web\") {\n\t// biome-ignore lint/suspicious/noExplicitAny: <explanation>\n\t(window as any).whopCoreNavigation = navigation;\n\n\twindow.addEventListener(\"popstate\", (e) => {\n\t\tconst currentLength = navigation.path.getValue().length;\n\t\tif (!e.state) {\n\t\t\tnavigation.path.setValue(navigation.path.getValue().slice(0, -1));\n\t\t\treturn;\n\t\t}\n\t\tconst index = e.state.index;\n\t\tconst route = e.state.route;\n\t\tif (index < currentLength) {\n\t\t\tnavigation.path.setValue(navigation.path.getValue().slice(0, -1));\n\t\t} else {\n\t\t\tnavigation.path.setValue([...navigation.path.getValue(), route]);\n\t\t}\n\t});\n}\n\nfunction ok(data: unknown): FunctionCallResult {\n\treturn { isOk: true, data: JSON.stringify(data), errorMessage: null };\n}\n\nfunction err(message: string): FunctionCallResult {\n\treturn { isOk: false, data: null, errorMessage: message };\n}\n\nfunction getOrigin(): string {\n\tif (typeof window !== \"undefined\" && window.location) {\n\t\treturn window.location.origin;\n\t}\n\treturn \"\";\n}\n\nconst syncHandlers: ExecSyncApi = {\n\tgetAppApiOrigin() {\n\t\treturn { apiOrigin: getOrigin() };\n\t},\n\tcacheGet({ key }: { key?: string | null }) {\n\t\ttry {\n\t\t\tif (typeof window !== \"undefined\" && window.localStorage && key) {\n\t\t\t\treturn { data: window.localStorage.getItem(key) };\n\t\t\t}\n\t\t\treturn { data: null };\n\t\t} catch {\n\t\t\treturn { data: null };\n\t\t}\n\t},\n\tcacheSet({ key, data }: { key?: string | null; data?: string | null }) {\n\t\ttry {\n\t\t\tif (typeof window !== \"undefined\" && window.localStorage && key != null) {\n\t\t\t\tif (data == null) {\n\t\t\t\t\twindow.localStorage.removeItem(key);\n\t\t\t\t} else {\n\t\t\t\t\twindow.localStorage.setItem(key, data);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {}\n\t\treturn {};\n\t},\n\trouterPush(route: Route) {\n\t\tnavigation.push(route);\n\t\treturn {};\n\t},\n\trouterPop() {\n\t\tnavigation.pop();\n\t\treturn {};\n\t},\n\trouterGetCurrent() {\n\t\treturn navigation.getCurrent();\n\t},\n\tsetNavigationBarData() {\n\t\treturn {};\n\t},\n\trouterPresentSheet({ path, params }: Route) {\n\t\tnavigation.presentSheet({\n\t\t\tpath: Array.from(path ?? []),\n\t\t\tparams: params ?? {},\n\t\t});\n\t\treturn {};\n\t},\n\trouterDismissSheet() {\n\t\tnavigation.dismissSheet();\n\t\treturn {};\n\t},\n\trouterGetCurrentSheet() {\n\t\treturn navigation.getCurrentSheet() ?? null;\n\t},\n\tdowngradeToWebView() {\n\t\treturn {};\n\t},\n\tgetHostAppDetails() {\n\t\treturn {\n\t\t\tbuild: \"web\",\n\t\t\tversion: \"0.0.0\",\n\t\t\tplatform: \"web\",\n\t\t\tbuildType: \"appstore\",\n\t\t};\n\t},\n};\n\nlet iframeModulePromise: Promise<typeof import(\"@whop/iframe\")> | null = null;\n\nasync function loadIframeModule() {\n\tif (!iframeModulePromise) {\n\t\tiframeModulePromise = import(\"@whop/iframe\");\n\t}\n\treturn await iframeModulePromise;\n}\n\nlet iframeSdk: ReturnType<typeof import(\"@whop/iframe\").createSdk> | null =\n\tnull;\n\nasync function loadIframeSdk() {\n\tif (!iframeSdk) {\n\t\tconst module = await loadIframeModule();\n\t\tiframeSdk = module.createSdk({\n\t\t\tappId: process.env.NEXT_PUBLIC_WHOP_APP_ID,\n\t\t});\n\t}\n\treturn iframeSdk;\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: <explanation>\ntype MakeAsync<T extends Record<string, any>> = {\n\t[K in keyof T]: (params: Parameters<T[K]>[0]) => Promise<ReturnType<T[K]>>;\n};\n\nconst asyncHandlers: MakeAsync<Pick<ExecAsyncApi, \"inAppPurchase\">> = {\n\tinAppPurchase: async ({ planId, id }) => {\n\t\tconst sdk = await loadIframeSdk();\n\t\tconst result = await sdk.inAppPurchase({ planId, id: id ?? undefined });\n\t\tif (result.status === \"ok\") {\n\t\t\treturn {\n\t\t\t\tsessionId: result.data.sessionId,\n\t\t\t\treceiptId: result.data.receiptId,\n\t\t\t};\n\t\t}\n\t\tthrow new Error(result.error);\n\t},\n};\n\nconst nativeWhopCoreStub = {\n\texecSync(name: string, paramsJson: string): FunctionCallResult {\n\t\ttry {\n\t\t\tconst params = paramsJson ? JSON.parse(paramsJson) : {};\n\t\t\tconst handler = syncHandlers[name as keyof typeof syncHandlers];\n\t\t\tif (!handler) return err(`Unknown sync method: ${name}`);\n\t\t\tconst result = handler(params);\n\t\t\treturn ok(result);\n\t\t} catch (e) {\n\t\t\treturn err(e instanceof Error ? e.message : \"Unknown error\");\n\t\t}\n\t},\n\tasync execAsync(\n\t\tname: string,\n\t\tparamsJson: string,\n\t): Promise<FunctionCallResult> {\n\t\ttry {\n\t\t\tconst params = paramsJson ? JSON.parse(paramsJson) : {};\n\t\t\tconst handler = (\n\t\t\t\tasyncHandlers as Record<string, (p: unknown) => Promise<unknown>>\n\t\t\t)[name];\n\t\t\tif (!handler) return err(`Unknown async method: ${name}`);\n\t\t\tconst result = await handler(params);\n\t\t\treturn ok(result);\n\t\t} catch (e) {\n\t\t\treturn err(e instanceof Error ? e.message : \"Unknown error\");\n\t\t}\n\t},\n};\n\nexport default nativeWhopCoreStub;\n","import nativeWhopCore from \"./native-whop-core\";\nimport type { PathParams } from \"./props\";\n\n// biome-ignore lint/complexity/noBannedTypes: allow here\ntype EmptyObject = {};\n\nexport interface ExecSyncApi {\n\tgetAppApiOrigin(params: EmptyObject): { apiOrigin: string };\n\tcacheGet(params: { key?: string | null }): { data?: string | null };\n\tcacheSet(params: { key?: string | null; data?: string | null }): EmptyObject;\n\trouterPush(params: PathParams): EmptyObject;\n\trouterPop(params: EmptyObject): EmptyObject;\n\trouterGetCurrent(params: EmptyObject): PathParams;\n\tsetNavigationBarData(params: {\n\t\ttitle?: string | null;\n\t\tdescription?: string | null;\n\t}): EmptyObject;\n\trouterPresentSheet(params: PathParams): EmptyObject;\n\trouterDismissSheet(params: EmptyObject): EmptyObject;\n\trouterGetCurrentSheet(params: EmptyObject): PathParams | null | undefined;\n\tdowngradeToWebView(params: EmptyObject): EmptyObject;\n\tgetHostAppDetails(params: EmptyObject): {\n\t\tbuild: string;\n\t\tversion: string;\n\t\tplatform: \"ios\" | \"android\" | \"web\";\n\t\tbuildType: \"appstore\" | \"testflight\" | \"debug\";\n\t};\n}\n\nexport interface ExecAsyncApi extends ExecSyncApi {\n\tinAppPurchase(params: {\n\t\tid?: string | null;\n\t\tplanId: string;\n\t}): {\n\t\tsessionId: string;\n\t\treceiptId: string;\n\t};\n}\n\nexport function __internal_execSync<F extends keyof ExecSyncApi>(\n\tname: F,\n\tparams: Parameters<ExecSyncApi[F]>[0],\n): ReturnType<ExecSyncApi[F]> {\n\tconst resultJson = nativeWhopCore.execSync(name, JSON.stringify(params));\n\tif (!resultJson.isOk) {\n\t\tthrow new Error(`Failed to execute ${name}: ${resultJson.errorMessage}`);\n\t}\n\n\treturn JSON.parse(resultJson.data || \"{}\") as ReturnType<ExecSyncApi[F]>;\n}\n\nexport async function __internal_execAsync<F extends keyof ExecAsyncApi>(\n\tname: F,\n\tparams: Parameters<ExecAsyncApi[F]>[0],\n): Promise<ReturnType<ExecAsyncApi[F]>> {\n\tconst resultJson = await nativeWhopCore.execAsync(\n\t\tname,\n\t\tJSON.stringify(params),\n\t);\n\n\tif (!resultJson.isOk) {\n\t\tthrow new Error(`Failed to execute ${name}: ${resultJson.errorMessage}`);\n\t}\n\n\treturn JSON.parse(resultJson.data || \"{}\") as ReturnType<ExecAsyncApi[F]>;\n}\n","/**\n * Web-safe wrapper for react-native-haptic-feedback.\n * - Lazily imports the native module only in native environments.\n * - Provides a no-op fallback on web to avoid runtime crashes.\n */\n\ntype HapticType =\n\t| \"selection\"\n\t| \"impactLight\"\n\t| \"impactMedium\"\n\t| \"impactHeavy\"\n\t| \"notificationSuccess\"\n\t| \"notificationWarning\"\n\t| \"notificationError\";\n\ntype HapticOptions = {\n\tenableVibrateFallback?: boolean;\n\tignoreAndroidSystemSettings?: boolean;\n};\n\n// Singleton holder for the native module once loaded\nlet nativeModule: {\n\ttrigger: (type: HapticType, options?: HapticOptions) => void;\n} | null = null;\nlet loadingPromise: Promise<void> | null = null;\n\nasync function ensureNativeLoaded(): Promise<void> {\n\t// If on web, skip loading entirely\n\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t// @ts-ignore - process may not be typed in RN web builds\n\tconst isWeb =\n\t\ttypeof document !== \"undefined\" && typeof window !== \"undefined\";\n\tif (isWeb) return;\n\n\tif (nativeModule || loadingPromise) {\n\t\treturn loadingPromise ?? Promise.resolve();\n\t}\n\n\tloadingPromise = import(\"react-native-haptic-feedback\")\n\t\t.then((mod) => {\n\t\t\tnativeModule = { trigger: mod.default.trigger };\n\t\t})\n\t\t.catch(() => {\n\t\t\t// Keep nativeModule null; fall back to noop\n\t\t})\n\t\t.finally(() => {\n\t\t\tloadingPromise = null;\n\t\t});\n\n\treturn loadingPromise;\n}\n\nconst HAPTIC_NOOP = {\n\ttrigger: (_type: HapticType, _options?: HapticOptions) => {\n\t\t// no-op on web\n\t},\n};\n\nconst Haptics = {\n\tasync trigger(type: HapticType, options?: HapticOptions): Promise<void> {\n\t\tawait ensureNativeLoaded();\n\t\tif (nativeModule) {\n\t\t\ttry {\n\t\t\t\tnativeModule.trigger(type, options);\n\t\t\t} catch {\n\t\t\t\t// ignore\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tHAPTIC_NOOP.trigger(type, options);\n\t},\n};\n\nexport default Haptics;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA,iBAA8B;AAC9B,IAAAA,uBAAyB;;;ACAzB,IAAAC,uBAAoC;;;ACDpC,0BAAyB;AAWzB,IAAM,qBAAN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