@whop/react-native 0.1.12 → 0.1.14

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 CHANGED
@@ -50,7 +50,6 @@ var import_metro2 = require("metro");
50
50
  var import_node_crypto = require("crypto");
51
51
 
52
52
  // src/cli/sdk.ts
53
- var import_api = require("@whop/api");
54
53
  var import_sdk = __toESM(require("@whop/sdk"));
55
54
  var import_dotenv = require("dotenv");
56
55
  (0, import_dotenv.config)({
@@ -67,25 +66,25 @@ var BASE_URL = process.env.WHOP_BASE_URL;
67
66
  var COMPANY_ID = process.env.NEXT_PUBLIC_WHOP_COMPANY_ID;
68
67
  var APP_ID = env("NEXT_PUBLIC_WHOP_APP_ID");
69
68
  var AI_PROMPT_ID = process.env.AI_PROMPT_ID;
70
- var oldWhopSdk = (0, import_api.WhopServerSdk)({
71
- appApiKey: env("WHOP_API_KEY"),
72
- appId: APP_ID,
73
- apiOrigin: BASE_URL ? new URL(BASE_URL).origin : void 0
74
- });
69
+ var headersJSON = process.env.WHOP_EXTRA_API_HEADERS_JSON;
70
+ var parsedExtraHeaders = void 0;
71
+ try {
72
+ if (headersJSON) {
73
+ parsedExtraHeaders = JSON.parse(headersJSON);
74
+ }
75
+ } catch (e) {
76
+ console.error("FAILED TO PARSE EXTRA WHOP API HEADERS", e);
77
+ }
75
78
  var whopSdk = new import_sdk.default({
76
79
  appID: APP_ID,
77
- baseURL: BASE_URL ? new URL("/api/v1", BASE_URL).href : void 0
80
+ baseURL: BASE_URL ? new URL("/api/v1", BASE_URL).href : void 0,
81
+ defaultHeaders: parsedExtraHeaders
78
82
  });
79
83
 
80
84
  // src/cli/file.ts
81
- async function uploadFile(data, name, contentType) {
82
- const file = new File([data], name, {
83
- type: contentType
84
- });
85
- const uploadedFile = await oldWhopSdk.attachments.uploadAttachment({
86
- file,
87
- record: "app",
88
- id: APP_ID
85
+ async function uploadFile(data, name, _contentType) {
86
+ const uploadedFile = await whopSdk.files.upload(data, {
87
+ filename: name
89
88
  });
90
89
  return uploadedFile;
91
90
  }
@@ -266,7 +265,7 @@ async function createMobileBuild(root, platform) {
266
265
  ` \u2714\uFE0E [${platform}] uploaded build: ${fileName} (${(zipData.length / 1024).toFixed(0)} KB)`
267
266
  );
268
267
  const build2 = await whopSdk.appBuilds.create({
269
- attachment: { direct_upload_id: uploadedFile.directUploadId },
268
+ attachment: { id: uploadedFile.id },
270
269
  checksum,
271
270
  app_id: APP_ID,
272
271
  platform,
@@ -624,7 +623,7 @@ async function createWebBuild(root) {
624
623
  )} KB)`
625
624
  );
626
625
  const build2 = await whopSdk.appBuilds.create({
627
- attachment: { direct_upload_id: uploadedFile.directUploadId },
626
+ attachment: { id: uploadedFile.id },
628
627
  checksum,
629
628
  app_id: APP_ID,
630
629
  platform: "web",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cli/index.ts","../../src/cli/env-bool.ts","../../src/cli/mobile.ts","../../src/cli/file.ts","../../src/cli/sdk.ts","../../src/cli/load-metro-config.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 { envBool } from \"./env-bool\";\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\tif (envBool(\"WRN_FULL_CLEAN\")) {\n\t\t\tawait cleanBuildDirectory(root);\n\t\t} else {\n\t\t\tawait cleanEntrypointsDirectory(root);\n\t\t}\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 cleanEntrypointsDirectory(root: string) {\n\tconst buildDirectory = path.join(root, \"build\", \"entrypoints\");\n\tif (existsSync(buildDirectory)) {\n\t\tawait rimraf(buildDirectory);\n\t}\n\tconsole.log(\" ✔︎ cleaned build entrypoints 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","/**\n * Check if an environment variable is set to a truthy value.\n * Accepts: \"1\", \"true\", \"yes\" (case-insensitive)\n */\nexport function envBool(name: string): boolean {\n\tconst value = process.env[name]?.toLowerCase();\n\treturn value === \"1\" || value === \"true\" || value === \"yes\";\n}\n","import { existsSync, readFileSync, readdirSync, statSync } from \"node:fs\";\nimport { mkdir, rename, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { getDefaultConfig, mergeConfig } from \"@react-native/metro-config\";\nimport { findUp } from \"find-up\";\nimport JSZip from \"jszip\";\nimport { type ReportableEvent, type Reporter, runBuild } from \"metro\";\nimport { envBool } from \"./env-bool\";\nimport { getChecksum, uploadFile } from \"./file\";\nimport { loadMetroConfig } from \"./load-metro-config\";\nimport { AI_PROMPT_ID, 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\n\tconst cacheDir =\n\t\tprocess.env.WRN_METRO_CACHE_DIRECTORY || path.join(root, \"build\", \"cache\");\n\tconst isCacheDisabled = envBool(\"WRN_DISABLE_METRO_CACHE\");\n\tconst remoteCacheUrl = process.env.WRN_REMOTE_METRO_CACHE_URL;\n\n\tawait mkdir(path.dirname(outputFile), { recursive: true });\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\n\tif (!bableNodeModules) {\n\t\tthrow new Error(\"babel node_modules parent folder not found\");\n\t}\n\n\tconst defaultConfig = getDefaultConfig(root);\n\tconst projectConfig = await loadMetroConfig(root);\n\n\tconst defaultMetroConfig = mergeConfig(defaultConfig, projectConfig);\n\n\tconst metroConfig = mergeConfig(defaultMetroConfig, {\n\t\tprojectRoot: root,\n\t\ttransformer: {\n\t\t\tbabelTransformerPath: require.resolve(\n\t\t\t\t\"./whop-react-native-babel-transformer.js\",\n\t\t\t),\n\t\t},\n\t\tcacheStores: ({ FileStore, HttpStore }) => {\n\t\t\tif (isCacheDisabled) return [];\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: types are cooked here\n\t\t\tconst caches: any[] = [\n\t\t\t\tnew FileStore({\n\t\t\t\t\troot: cacheDir,\n\t\t\t\t}),\n\t\t\t];\n\t\t\tif (remoteCacheUrl) {\n\t\t\t\tcaches.push(new HttpStore({ endpoint: remoteCacheUrl }));\n\t\t\t}\n\t\t\treturn caches;\n\t\t},\n\t\tcacheVersion: process.env.WRN_METRO_CACHE_VERSION,\n\t\twatchFolders: [root, path.resolve(root, \"node_modules\"), bableNodeModules],\n\t\treporter: new CustomReporter(),\n\t\tresolver: {\n\t\t\tnodeModulesPaths: [\n\t\t\t\t...(defaultMetroConfig.resolver?.nodeModulesPaths ?? []),\n\t\t\t\tbableNodeModules,\n\t\t\t],\n\t\t},\n\t});\n\n\tawait runBuild(metroConfig, {\n\t\tdev: false,\n\t\tentry: `build/entrypoints/${platform}/index.js`,\n\t\tminify: false,\n\t\tplatform: platform,\n\t\tsourceMap: false,\n\t\tout: outputFile,\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(\n\t\t\t\tfile,\n\t\t\t)});`,\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} (${(\n\t\t\tzipData.length / 1024\n\t\t).toFixed(0)} KB)`,\n\t);\n\n\tconst build = await whopSdk.appBuilds.create({\n\t\tattachment: { direct_upload_id: uploadedFile.directUploadId },\n\t\tchecksum,\n\t\tapp_id: APP_ID,\n\t\tplatform,\n\t\tai_prompt_id: AI_PROMPT_ID,\n\t\tsupported_app_view_types: 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\t\"dashboard-view\": \"dashboard\" 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 companyPart = COMPANY_ID ? `${COMPANY_ID}/` : \"\";\n\tconst dashboardUrl = `https://whop.com/dashboard/${companyPart}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: ${build.supported_app_view_types.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 { APP_ID, oldWhopSdk } 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 oldWhopSdk.attachments.uploadAttachment({\n\t\tfile,\n\t\trecord: \"app\",\n\t\tid: APP_ID,\n\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 Whop from \"@whop/sdk\";\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\nconst BASE_URL = process.env.WHOP_BASE_URL;\n\nexport const COMPANY_ID = process.env.NEXT_PUBLIC_WHOP_COMPANY_ID;\nexport const APP_ID = env(\"NEXT_PUBLIC_WHOP_APP_ID\");\nexport const AI_PROMPT_ID = process.env.AI_PROMPT_ID;\n\nexport const oldWhopSdk: WhopServerSdk = WhopServerSdk({\n\tappApiKey: env(\"WHOP_API_KEY\"),\n\tappId: APP_ID,\n\tapiOrigin: BASE_URL ? new URL(BASE_URL).origin : undefined,\n});\n\nexport const whopSdk = new Whop({\n\tappID: APP_ID,\n\tbaseURL: BASE_URL ? new URL(\"/api/v1\", BASE_URL).href : undefined,\n});\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { loadConfig } from \"metro\";\n\nexport async function loadMetroConfig(projectRoot: string) {\n\tconst file = fs.existsSync(path.join(projectRoot, \"metro.config.js\"));\n\tif (!file) return {};\n\treturn await loadConfig({ cwd: projectRoot }, {});\n}\n","import { readdir } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nexport const VALID_VIEW_TYPES = [\n\t\"experience-view\",\n\t\"discover-view\",\n\t\"dashboard-view\",\n] 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 { AI_PROMPT_ID, 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(\n\t\t\t\tfile,\n\t\t\t)}\", () => WhopNavigationWrapper(React, \"${toPascalCase(\n\t\t\t\tfile,\n\t\t\t)}\", ${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 viewType = new URLSearchParams(window.location.search).get(\"app_view\") ?? \"${defaultKey}\";\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(viewType, { 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\t\".mjs\",\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\t\".mjs\": \"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 viewTypes = await getSupportedAppViewTypes(root);\n\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(\n\t\t\t0,\n\t\t)} KB)`,\n\t);\n\n\tconst build = await whopSdk.appBuilds.create({\n\t\tattachment: { direct_upload_id: uploadedFile.directUploadId },\n\t\tchecksum,\n\t\tapp_id: APP_ID,\n\t\tplatform: \"web\",\n\t\tai_prompt_id: AI_PROMPT_ID,\n\t\tsupported_app_view_types: 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\t\"dashboard-view\": \"dashboard\" 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 companyPart = COMPANY_ID ? `${COMPANY_ID}/` : \"\";\n\tconst dashboardUrl = `https://whop.com/dashboard/${companyPart}developer/apps/${APP_ID}/builds/?platform=web`;\n\n\tconsole.log(\n\t\t`\\n ✔︎ [web] deployed as development build ✔︎\\n - build id: ${\n\t\t\tbuild.id\n\t\t}\\n - view types: ${build.supported_app_view_types.join(\n\t\t\t\", \",\n\t\t)}\\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\";\nimport * as path from \"node:path\";\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\t// Only process react-native core files that contain Flow\n\t\t\t\tif (!args.path.includes(`${path.sep}react-native${path.sep}`)) {\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 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// Use Hermes parser to handle modern Flow syntax (as casts, type predicates, mapped types, etc.)\n\t\t\t\t\t\t\"babel-plugin-syntax-hermes-parser\",\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\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,IAAAA,kBAA2B;AAC3B,IAAAC,oBAAiB;AACjB,uBAA0B;AAC1B,IAAAC,kBAAuB;AACvB,6BAAmB;AACnB,oBAAuB;;;ACDhB,SAAS,QAAQ,MAAuB;AAC9C,QAAM,QAAQ,QAAQ,IAAI,IAAI,GAAG,YAAY;AAC7C,SAAO,UAAU,OAAO,UAAU,UAAU,UAAU;AACvD;;;ACPA,IAAAC,kBAAgE;AAChE,IAAAC,mBAAyC;AACzC,IAAAC,oBAAiB;AACjB,0BAA8C;AAC9C,qBAAuB;AACvB,mBAAkB;AAClB,IAAAC,gBAA8D;;;ACN9D,yBAA2B;;;ACA3B,iBAA8B;AAC9B,iBAAiB;AACjB,oBAAuB;AAAA,IAEvB,sBAAO;AAAA,EACN,MAAM,CAAC,QAAQ,cAAc,oBAAoB,iBAAiB;AACnE,CAAC;AAEM,SAAS,IAAI,KAAa;AAChC,QAAM,QAAQ,QAAQ,IAAI,GAAG;AAC7B,MAAI,CA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AyB,KAAK;AAElD,UAAQ,IAAI;AAAA;AAAA,EAEX,WAAW;AAAA;AAAA;AAAA,EAGX;AAED,yBAAAC,QAAO,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":["import_node_fs","import_node_path","import_find_up","import_node_fs","import_promises","import_node_path","import_metro","Whop","fs","path","import_node_path","path","path","build","JSZip","import_promises","import_node_path","fs","path","fs","path","babel","path","buildAndPublish","build","buildAndPublish","path","qrcode"]}
1
+ {"version":3,"sources":["../../src/cli/index.ts","../../src/cli/env-bool.ts","../../src/cli/mobile.ts","../../src/cli/file.ts","../../src/cli/sdk.ts","../../src/cli/load-metro-config.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 { envBool } from \"./env-bool\";\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\tif (envBool(\"WRN_FULL_CLEAN\")) {\n\t\t\tawait cleanBuildDirectory(root);\n\t\t} else {\n\t\t\tawait cleanEntrypointsDirectory(root);\n\t\t}\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 cleanEntrypointsDirectory(root: string) {\n\tconst buildDirectory = path.join(root, \"build\", \"entrypoints\");\n\tif (existsSync(buildDirectory)) {\n\t\tawait rimraf(buildDirectory);\n\t}\n\tconsole.log(\" ✔︎ cleaned build entrypoints 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","/**\n * Check if an environment variable is set to a truthy value.\n * Accepts: \"1\", \"true\", \"yes\" (case-insensitive)\n */\nexport function envBool(name: string): boolean {\n\tconst value = process.env[name]?.toLowerCase();\n\treturn value === \"1\" || value === \"true\" || value === \"yes\";\n}\n","import { existsSync, readFileSync, readdirSync, statSync } from \"node:fs\";\nimport { mkdir, rename, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { getDefaultConfig, mergeConfig } from \"@react-native/metro-config\";\nimport { findUp } from \"find-up\";\nimport JSZip from \"jszip\";\nimport { type ReportableEvent, type Reporter, runBuild } from \"metro\";\nimport { envBool } from \"./env-bool\";\nimport { getChecksum, uploadFile } from \"./file\";\nimport { loadMetroConfig } from \"./load-metro-config\";\nimport { AI_PROMPT_ID, 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\n\tconst cacheDir =\n\t\tprocess.env.WRN_METRO_CACHE_DIRECTORY || path.join(root, \"build\", \"cache\");\n\tconst isCacheDisabled = envBool(\"WRN_DISABLE_METRO_CACHE\");\n\tconst remoteCacheUrl = process.env.WRN_REMOTE_METRO_CACHE_URL;\n\n\tawait mkdir(path.dirname(outputFile), { recursive: true });\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\n\tif (!bableNodeModules) {\n\t\tthrow new Error(\"babel node_modules parent folder not found\");\n\t}\n\n\tconst defaultConfig = getDefaultConfig(root);\n\tconst projectConfig = await loadMetroConfig(root);\n\n\tconst defaultMetroConfig = mergeConfig(defaultConfig, projectConfig);\n\n\tconst metroConfig = mergeConfig(defaultMetroConfig, {\n\t\tprojectRoot: root,\n\t\ttransformer: {\n\t\t\tbabelTransformerPath: require.resolve(\n\t\t\t\t\"./whop-react-native-babel-transformer.js\",\n\t\t\t),\n\t\t},\n\t\tcacheStores: ({ FileStore, HttpStore }) => {\n\t\t\tif (isCacheDisabled) return [];\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: types are cooked here\n\t\t\tconst caches: any[] = [\n\t\t\t\tnew FileStore({\n\t\t\t\t\troot: cacheDir,\n\t\t\t\t}),\n\t\t\t];\n\t\t\tif (remoteCacheUrl) {\n\t\t\t\tcaches.push(new HttpStore({ endpoint: remoteCacheUrl }));\n\t\t\t}\n\t\t\treturn caches;\n\t\t},\n\t\tcacheVersion: process.env.WRN_METRO_CACHE_VERSION,\n\t\twatchFolders: [root, path.resolve(root, \"node_modules\"), bableNodeModules],\n\t\treporter: new CustomReporter(),\n\t\tresolver: {\n\t\t\tnodeModulesPaths: [\n\t\t\t\t...(defaultMetroConfig.resolver?.nodeModulesPaths ?? []),\n\t\t\t\tbableNodeModules,\n\t\t\t],\n\t\t},\n\t});\n\n\tawait runBuild(metroConfig, {\n\t\tdev: false,\n\t\tentry: `build/entrypoints/${platform}/index.js`,\n\t\tminify: false,\n\t\tplatform: platform,\n\t\tsourceMap: false,\n\t\tout: outputFile,\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(\n\t\t\t\tfile,\n\t\t\t)});`,\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} (${(\n\t\t\tzipData.length / 1024\n\t\t).toFixed(0)} KB)`,\n\t);\n\n\tconst build = await whopSdk.appBuilds.create({\n\t\tattachment: { id: uploadedFile.id },\n\t\tchecksum,\n\t\tapp_id: APP_ID,\n\t\tplatform,\n\t\tai_prompt_id: AI_PROMPT_ID,\n\t\tsupported_app_view_types: 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\t\"dashboard-view\": \"dashboard\" 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 companyPart = COMPANY_ID ? `${COMPANY_ID}/` : \"\";\n\tconst dashboardUrl = `https://whop.com/dashboard/${companyPart}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: ${build.supported_app_view_types.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 { whopSdk } from \"./sdk\";\n\nexport async function uploadFile(\n\tdata: Buffer<ArrayBufferLike>,\n\tname: string,\n\t_contentType: string,\n) {\n\tconst uploadedFile = await whopSdk.files.upload(data, {\n\t\tfilename: name,\n\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 Whop from \"@whop/sdk\";\nimport { config } from \"dotenv\";\n\nconfig({\n path: [\".env\", \".env.local\", \".env.development\", \".env.production\"],\n});\n\nexport function env(key: string) {\n const value = process.env[key];\n if (!value) {\n throw new Error(`Missing environment variable: ${key}`);\n }\n return value;\n}\n\nconst BASE_URL = process.env.WHOP_BASE_URL;\n\nexport const COMPANY_ID = process.env.NEXT_PUBLIC_WHOP_COMPANY_ID;\nexport const APP_ID = env(\"NEXT_PUBLIC_WHOP_APP_ID\");\nexport const AI_PROMPT_ID = process.env.AI_PROMPT_ID;\n\nconst headersJSON = process.env.WHOP_EXTRA_API_HEADERS_JSON;\nlet parsedExtraHeaders: Record<string, string> | undefined = undefined;\n\ntry {\n if (headersJSON) {\n parsedExtraHeaders = JSON.parse(headersJSON);\n }\n} catch (e) {\n console.error(\"FAILED TO PARSE EXTRA WHOP API HEADERS\", e);\n}\n\nexport const whopSdk = new Whop({\n appID: APP_ID,\n baseURL: BASE_URL ? new URL(\"/api/v1\", BASE_URL).href : undefined,\n defaultHeaders: parsedExtraHeaders,\n});\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { loadConfig } from \"metro\";\n\nexport async function loadMetroConfig(projectRoot: string) {\n\tconst file = fs.existsSync(path.join(projectRoot, \"metro.config.js\"));\n\tif (!file) return {};\n\treturn await loadConfig({ cwd: projectRoot }, {});\n}\n","import { readdir } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nexport const VALID_VIEW_TYPES = [\n\t\"experience-view\",\n\t\"discover-view\",\n\t\"dashboard-view\",\n] 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 { AI_PROMPT_ID, 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(\n\t\t\t\tfile,\n\t\t\t)}\", () => WhopNavigationWrapper(React, \"${toPascalCase(\n\t\t\t\tfile,\n\t\t\t)}\", ${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 viewType = new URLSearchParams(window.location.search).get(\"app_view\") ?? \"${defaultKey}\";\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(viewType, { 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\t\".mjs\",\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\t\".mjs\": \"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 viewTypes = await getSupportedAppViewTypes(root);\n\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(\n\t\t\t0,\n\t\t)} KB)`,\n\t);\n\n\tconst build = await whopSdk.appBuilds.create({\n\t\tattachment: { id: uploadedFile.id },\n\t\tchecksum,\n\t\tapp_id: APP_ID,\n\t\tplatform: \"web\",\n\t\tai_prompt_id: AI_PROMPT_ID,\n\t\tsupported_app_view_types: 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\t\"dashboard-view\": \"dashboard\" 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 companyPart = COMPANY_ID ? `${COMPANY_ID}/` : \"\";\n\tconst dashboardUrl = `https://whop.com/dashboard/${companyPart}developer/apps/${APP_ID}/builds/?platform=web`;\n\n\tconsole.log(\n\t\t`\\n ✔︎ [web] deployed as development build ✔︎\\n - build id: ${\n\t\t\tbuild.id\n\t\t}\\n - view types: ${build.supported_app_view_types.join(\n\t\t\t\", \",\n\t\t)}\\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\";\nimport * as path from \"node:path\";\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\t// Only process react-native core files that contain Flow\n\t\t\t\tif (!args.path.includes(`${path.sep}react-native${path.sep}`)) {\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 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// Use Hermes parser to handle modern Flow syntax (as casts, type predicates, mapped types, etc.)\n\t\t\t\t\t\t\"babel-plugin-syntax-hermes-parser\",\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\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,IAAAA,kBAA2B;AAC3B,IAAAC,oBAAiB;AACjB,uBAA0B;AAC1B,IAAAC,kBAAuB;AACvB,6BAAmB;AACnB,oBAAuB;;;ACDhB,SAAS,QAAQ,MAAuB;AAC9C,QAAM,QAAQ,QAAQ,IAAI,IAAI,GAAG,YAAY;AAC7C,SAAO,UAAU,OAAO,UAAU,UAAU,UAAU;AACvD;;;ACPA,IAAAC,kBAAgE;AAChE,IAAAC,mBAAyC;AACzC,IAAAC,oBAAiB;AACjB,0BAA8C;AAC9C,qBAAuB;AACvB,mBAAkB;AAClB,IAAAC,gBAA8D;;;ACN9D,yBAA2B;;;ACA3B,iBAAiB;AACjB,oBAAuB;AAAA,IAEvB,sBAAO;AAAA,EACL,MAAM,CAAC,QAAQ,cAAc,oBAAoB,iBAAiB;AACpE,CAAC;AAEM,SAAS,IAAI,KAAa;AAC/B,QAAM,QAAQ,QAAQ,IAAI,GAAG;AAC7B,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,MAAM,iCAAiC,GAAG,EAAE;AAAA,EACxD;AACA,SAAO;AACT;AAEA,IAAM,WAAW,QAAQ,IAAI;AAEtB,IAAM,aAAa,QAAQ,IAAI;AAC/B,IAAM,SAAS,IAAI,yBAAyB;AAC5C,IA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MAAM;AACX,UAAQ,KAAK,CAAC;AACf,CAAC;","names":["import_node_fs","import_node_path","import_find_up","import_node_fs","import_promises","import_node_path","import_metro","Whop","fs","path","import_node_path","path","path","build","JSZip","import_promises","import_node_path","fs","path","fs","path","babel","path","buildAndPublish","build","buildAndPublish","path","qrcode"]}
@@ -30,7 +30,6 @@ import { runBuild } from "metro";
30
30
  import { createHash } from "crypto";
31
31
 
32
32
  // src/cli/sdk.ts
33
- import { WhopServerSdk } from "@whop/api";
34
33
  import Whop from "@whop/sdk";
35
34
  import { config } from "dotenv";
36
35
  config({
@@ -47,25 +46,25 @@ var BASE_URL = process.env.WHOP_BASE_URL;
47
46
  var COMPANY_ID = process.env.NEXT_PUBLIC_WHOP_COMPANY_ID;
48
47
  var APP_ID = env("NEXT_PUBLIC_WHOP_APP_ID");
49
48
  var AI_PROMPT_ID = process.env.AI_PROMPT_ID;
50
- var oldWhopSdk = WhopServerSdk({
51
- appApiKey: env("WHOP_API_KEY"),
52
- appId: APP_ID,
53
- apiOrigin: BASE_URL ? new URL(BASE_URL).origin : void 0
54
- });
49
+ var headersJSON = process.env.WHOP_EXTRA_API_HEADERS_JSON;
50
+ var parsedExtraHeaders = void 0;
51
+ try {
52
+ if (headersJSON) {
53
+ parsedExtraHeaders = JSON.parse(headersJSON);
54
+ }
55
+ } catch (e) {
56
+ console.error("FAILED TO PARSE EXTRA WHOP API HEADERS", e);
57
+ }
55
58
  var whopSdk = new Whop({
56
59
  appID: APP_ID,
57
- baseURL: BASE_URL ? new URL("/api/v1", BASE_URL).href : void 0
60
+ baseURL: BASE_URL ? new URL("/api/v1", BASE_URL).href : void 0,
61
+ defaultHeaders: parsedExtraHeaders
58
62
  });
59
63
 
60
64
  // src/cli/file.ts
61
- async function uploadFile(data, name, contentType) {
62
- const file = new File([data], name, {
63
- type: contentType
64
- });
65
- const uploadedFile = await oldWhopSdk.attachments.uploadAttachment({
66
- file,
67
- record: "app",
68
- id: APP_ID
65
+ async function uploadFile(data, name, _contentType) {
66
+ const uploadedFile = await whopSdk.files.upload(data, {
67
+ filename: name
69
68
  });
70
69
  return uploadedFile;
71
70
  }
@@ -248,7 +247,7 @@ async function createMobileBuild(root, platform) {
248
247
  ` \u2714\uFE0E [${platform}] uploaded build: ${fileName} (${(zipData.length / 1024).toFixed(0)} KB)`
249
248
  );
250
249
  const build2 = await whopSdk.appBuilds.create({
251
- attachment: { direct_upload_id: uploadedFile.directUploadId },
250
+ attachment: { id: uploadedFile.id },
252
251
  checksum,
253
252
  app_id: APP_ID,
254
253
  platform,
@@ -606,7 +605,7 @@ async function createWebBuild(root) {
606
605
  )} KB)`
607
606
  );
608
607
  const build2 = await whopSdk.appBuilds.create({
609
- attachment: { direct_upload_id: uploadedFile.directUploadId },
608
+ attachment: { id: uploadedFile.id },
610
609
  checksum,
611
610
  app_id: APP_ID,
612
611
  platform: "web",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cli/index.ts","../../src/cli/env-bool.ts","../../src/cli/mobile.ts","../../src/cli/file.ts","../../src/cli/sdk.ts","../../src/cli/load-metro-config.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 { envBool } from \"./env-bool\";\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\tif (envBool(\"WRN_FULL_CLEAN\")) {\n\t\t\tawait cleanBuildDirectory(root);\n\t\t} else {\n\t\t\tawait cleanEntrypointsDirectory(root);\n\t\t}\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 cleanEntrypointsDirectory(root: string) {\n\tconst buildDirectory = path.join(root, \"build\", \"entrypoints\");\n\tif (existsSync(buildDirectory)) {\n\t\tawait rimraf(buildDirectory);\n\t}\n\tconsole.log(\" ✔︎ cleaned build entrypoints 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","/**\n * Check if an environment variable is set to a truthy value.\n * Accepts: \"1\", \"true\", \"yes\" (case-insensitive)\n */\nexport function envBool(name: string): boolean {\n\tconst value = process.env[name]?.toLowerCase();\n\treturn value === \"1\" || value === \"true\" || value === \"yes\";\n}\n","import { existsSync, readFileSync, readdirSync, statSync } from \"node:fs\";\nimport { mkdir, rename, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { getDefaultConfig, mergeConfig } from \"@react-native/metro-config\";\nimport { findUp } from \"find-up\";\nimport JSZip from \"jszip\";\nimport { type ReportableEvent, type Reporter, runBuild } from \"metro\";\nimport { envBool } from \"./env-bool\";\nimport { getChecksum, uploadFile } from \"./file\";\nimport { loadMetroConfig } from \"./load-metro-config\";\nimport { AI_PROMPT_ID, 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\n\tconst cacheDir =\n\t\tprocess.env.WRN_METRO_CACHE_DIRECTORY || path.join(root, \"build\", \"cache\");\n\tconst isCacheDisabled = envBool(\"WRN_DISABLE_METRO_CACHE\");\n\tconst remoteCacheUrl = process.env.WRN_REMOTE_METRO_CACHE_URL;\n\n\tawait mkdir(path.dirname(outputFile), { recursive: true });\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\n\tif (!bableNodeModules) {\n\t\tthrow new Error(\"babel node_modules parent folder not found\");\n\t}\n\n\tconst defaultConfig = getDefaultConfig(root);\n\tconst projectConfig = await loadMetroConfig(root);\n\n\tconst defaultMetroConfig = mergeConfig(defaultConfig, projectConfig);\n\n\tconst metroConfig = mergeConfig(defaultMetroConfig, {\n\t\tprojectRoot: root,\n\t\ttransformer: {\n\t\t\tbabelTransformerPath: require.resolve(\n\t\t\t\t\"./whop-react-native-babel-transformer.js\",\n\t\t\t),\n\t\t},\n\t\tcacheStores: ({ FileStore, HttpStore }) => {\n\t\t\tif (isCacheDisabled) return [];\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: types are cooked here\n\t\t\tconst caches: any[] = [\n\t\t\t\tnew FileStore({\n\t\t\t\t\troot: cacheDir,\n\t\t\t\t}),\n\t\t\t];\n\t\t\tif (remoteCacheUrl) {\n\t\t\t\tcaches.push(new HttpStore({ endpoint: remoteCacheUrl }));\n\t\t\t}\n\t\t\treturn caches;\n\t\t},\n\t\tcacheVersion: process.env.WRN_METRO_CACHE_VERSION,\n\t\twatchFolders: [root, path.resolve(root, \"node_modules\"), bableNodeModules],\n\t\treporter: new CustomReporter(),\n\t\tresolver: {\n\t\t\tnodeModulesPaths: [\n\t\t\t\t...(defaultMetroConfig.resolver?.nodeModulesPaths ?? []),\n\t\t\t\tbableNodeModules,\n\t\t\t],\n\t\t},\n\t});\n\n\tawait runBuild(metroConfig, {\n\t\tdev: false,\n\t\tentry: `build/entrypoints/${platform}/index.js`,\n\t\tminify: false,\n\t\tplatform: platform,\n\t\tsourceMap: false,\n\t\tout: outputFile,\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(\n\t\t\t\tfile,\n\t\t\t)});`,\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} (${(\n\t\t\tzipData.length / 1024\n\t\t).toFixed(0)} KB)`,\n\t);\n\n\tconst build = await whopSdk.appBuilds.create({\n\t\tattachment: { direct_upload_id: uploadedFile.directUploadId },\n\t\tchecksum,\n\t\tapp_id: APP_ID,\n\t\tplatform,\n\t\tai_prompt_id: AI_PROMPT_ID,\n\t\tsupported_app_view_types: 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\t\"dashboard-view\": \"dashboard\" 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 companyPart = COMPANY_ID ? `${COMPANY_ID}/` : \"\";\n\tconst dashboardUrl = `https://whop.com/dashboard/${companyPart}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: ${build.supported_app_view_types.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 { APP_ID, oldWhopSdk } 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 oldWhopSdk.attachments.uploadAttachment({\n\t\tfile,\n\t\trecord: \"app\",\n\t\tid: APP_ID,\n\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 Whop from \"@whop/sdk\";\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\nconst BASE_URL = process.env.WHOP_BASE_URL;\n\nexport const COMPANY_ID = process.env.NEXT_PUBLIC_WHOP_COMPANY_ID;\nexport const APP_ID = env(\"NEXT_PUBLIC_WHOP_APP_ID\");\nexport const AI_PROMPT_ID = process.env.AI_PROMPT_ID;\n\nexport const oldWhopSdk: WhopServerSdk = WhopServerSdk({\n\tappApiKey: env(\"WHOP_API_KEY\"),\n\tappId: APP_ID,\n\tapiOrigin: BASE_URL ? new URL(BASE_URL).origin : undefined,\n});\n\nexport const whopSdk = new Whop({\n\tappID: APP_ID,\n\tbaseURL: BASE_URL ? new URL(\"/api/v1\", BASE_URL).href : undefined,\n});\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { loadConfig } from \"metro\";\n\nexport async function loadMetroConfig(projectRoot: string) {\n\tconst file = fs.existsSync(path.join(projectRoot, \"metro.config.js\"));\n\tif (!file) return {};\n\treturn await loadConfig({ cwd: projectRoot }, {});\n}\n","import { readdir } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nexport const VALID_VIEW_TYPES = [\n\t\"experience-view\",\n\t\"discover-view\",\n\t\"dashboard-view\",\n] 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 { AI_PROMPT_ID, 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(\n\t\t\t\tfile,\n\t\t\t)}\", () => WhopNavigationWrapper(React, \"${toPascalCase(\n\t\t\t\tfile,\n\t\t\t)}\", ${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 viewType = new URLSearchParams(window.location.search).get(\"app_view\") ?? \"${defaultKey}\";\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(viewType, { 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\t\".mjs\",\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\t\".mjs\": \"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 viewTypes = await getSupportedAppViewTypes(root);\n\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(\n\t\t\t0,\n\t\t)} KB)`,\n\t);\n\n\tconst build = await whopSdk.appBuilds.create({\n\t\tattachment: { direct_upload_id: uploadedFile.directUploadId },\n\t\tchecksum,\n\t\tapp_id: APP_ID,\n\t\tplatform: \"web\",\n\t\tai_prompt_id: AI_PROMPT_ID,\n\t\tsupported_app_view_types: 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\t\"dashboard-view\": \"dashboard\" 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 companyPart = COMPANY_ID ? `${COMPANY_ID}/` : \"\";\n\tconst dashboardUrl = `https://whop.com/dashboard/${companyPart}developer/apps/${APP_ID}/builds/?platform=web`;\n\n\tconsole.log(\n\t\t`\\n ✔︎ [web] deployed as development build ✔︎\\n - build id: ${\n\t\t\tbuild.id\n\t\t}\\n - view types: ${build.supported_app_view_types.join(\n\t\t\t\", \",\n\t\t)}\\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\";\nimport * as path from \"node:path\";\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\t// Only process react-native core files that contain Flow\n\t\t\t\tif (!args.path.includes(`${path.sep}react-native${path.sep}`)) {\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 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// Use Hermes parser to handle modern Flow syntax (as casts, type predicates, mapped types, etc.)\n\t\t\t\t\t\t\"babel-plugin-syntax-hermes-parser\",\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\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;;;ACDhB,SAAS,QAAQ,MAAuB;AAC9C,QAAM,QAAQ,QAAQ,IAAI,IAAI,GAAG,YAAY;AAC7C,SAAO,UAAU,OAAO,UAAU,UAAU,UAAU;AACvD;;;ACPA,SAAS,YAAY,cAAc,aAAa,gBAAgB;AAChE,SAAS,OAAO,QAAQ,iBAAiB;AACzC,OAAOC,WAAU;AACjB,SAAS,kBAAkB,mBAAmB;AAC9C,SAAS,cAAc;AACvB,OAAO,WAAW;AAClB,SAA8C,gBAAgB;;;ACN9D,SAAS,kBAAkB;;;ACA3B,SAAS,qBAAqB;AAC9B,OAAO,UAAU;AACjB,SAAS,cAAc;AAEvB,OAAO;AAAA,EACN,MAAM,CAAC,QAAQ,cAAc,oBAAoB,iBAAiB;AACnE,CAAC;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EX,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","path","build","mkdir","readFile","writeFile","path","fs","path","fs","path","babel","path","readFile","mkdir","writeFile","buildAndPublish","build","buildAndPublish","path","existsSync","findUp"]}
1
+ {"version":3,"sources":["../../src/cli/index.ts","../../src/cli/env-bool.ts","../../src/cli/mobile.ts","../../src/cli/file.ts","../../src/cli/sdk.ts","../../src/cli/load-metro-config.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 { envBool } from \"./env-bool\";\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\tif (envBool(\"WRN_FULL_CLEAN\")) {\n\t\t\tawait cleanBuildDirectory(root);\n\t\t} else {\n\t\t\tawait cleanEntrypointsDirectory(root);\n\t\t}\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 cleanEntrypointsDirectory(root: string) {\n\tconst buildDirectory = path.join(root, \"build\", \"entrypoints\");\n\tif (existsSync(buildDirectory)) {\n\t\tawait rimraf(buildDirectory);\n\t}\n\tconsole.log(\" ✔︎ cleaned build entrypoints 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","/**\n * Check if an environment variable is set to a truthy value.\n * Accepts: \"1\", \"true\", \"yes\" (case-insensitive)\n */\nexport function envBool(name: string): boolean {\n\tconst value = process.env[name]?.toLowerCase();\n\treturn value === \"1\" || value === \"true\" || value === \"yes\";\n}\n","import { existsSync, readFileSync, readdirSync, statSync } from \"node:fs\";\nimport { mkdir, rename, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { getDefaultConfig, mergeConfig } from \"@react-native/metro-config\";\nimport { findUp } from \"find-up\";\nimport JSZip from \"jszip\";\nimport { type ReportableEvent, type Reporter, runBuild } from \"metro\";\nimport { envBool } from \"./env-bool\";\nimport { getChecksum, uploadFile } from \"./file\";\nimport { loadMetroConfig } from \"./load-metro-config\";\nimport { AI_PROMPT_ID, 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\n\tconst cacheDir =\n\t\tprocess.env.WRN_METRO_CACHE_DIRECTORY || path.join(root, \"build\", \"cache\");\n\tconst isCacheDisabled = envBool(\"WRN_DISABLE_METRO_CACHE\");\n\tconst remoteCacheUrl = process.env.WRN_REMOTE_METRO_CACHE_URL;\n\n\tawait mkdir(path.dirname(outputFile), { recursive: true });\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\n\tif (!bableNodeModules) {\n\t\tthrow new Error(\"babel node_modules parent folder not found\");\n\t}\n\n\tconst defaultConfig = getDefaultConfig(root);\n\tconst projectConfig = await loadMetroConfig(root);\n\n\tconst defaultMetroConfig = mergeConfig(defaultConfig, projectConfig);\n\n\tconst metroConfig = mergeConfig(defaultMetroConfig, {\n\t\tprojectRoot: root,\n\t\ttransformer: {\n\t\t\tbabelTransformerPath: require.resolve(\n\t\t\t\t\"./whop-react-native-babel-transformer.js\",\n\t\t\t),\n\t\t},\n\t\tcacheStores: ({ FileStore, HttpStore }) => {\n\t\t\tif (isCacheDisabled) return [];\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: types are cooked here\n\t\t\tconst caches: any[] = [\n\t\t\t\tnew FileStore({\n\t\t\t\t\troot: cacheDir,\n\t\t\t\t}),\n\t\t\t];\n\t\t\tif (remoteCacheUrl) {\n\t\t\t\tcaches.push(new HttpStore({ endpoint: remoteCacheUrl }));\n\t\t\t}\n\t\t\treturn caches;\n\t\t},\n\t\tcacheVersion: process.env.WRN_METRO_CACHE_VERSION,\n\t\twatchFolders: [root, path.resolve(root, \"node_modules\"), bableNodeModules],\n\t\treporter: new CustomReporter(),\n\t\tresolver: {\n\t\t\tnodeModulesPaths: [\n\t\t\t\t...(defaultMetroConfig.resolver?.nodeModulesPaths ?? []),\n\t\t\t\tbableNodeModules,\n\t\t\t],\n\t\t},\n\t});\n\n\tawait runBuild(metroConfig, {\n\t\tdev: false,\n\t\tentry: `build/entrypoints/${platform}/index.js`,\n\t\tminify: false,\n\t\tplatform: platform,\n\t\tsourceMap: false,\n\t\tout: outputFile,\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(\n\t\t\t\tfile,\n\t\t\t)});`,\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} (${(\n\t\t\tzipData.length / 1024\n\t\t).toFixed(0)} KB)`,\n\t);\n\n\tconst build = await whopSdk.appBuilds.create({\n\t\tattachment: { id: uploadedFile.id },\n\t\tchecksum,\n\t\tapp_id: APP_ID,\n\t\tplatform,\n\t\tai_prompt_id: AI_PROMPT_ID,\n\t\tsupported_app_view_types: 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\t\"dashboard-view\": \"dashboard\" 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 companyPart = COMPANY_ID ? `${COMPANY_ID}/` : \"\";\n\tconst dashboardUrl = `https://whop.com/dashboard/${companyPart}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: ${build.supported_app_view_types.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 { whopSdk } from \"./sdk\";\n\nexport async function uploadFile(\n\tdata: Buffer<ArrayBufferLike>,\n\tname: string,\n\t_contentType: string,\n) {\n\tconst uploadedFile = await whopSdk.files.upload(data, {\n\t\tfilename: name,\n\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 Whop from \"@whop/sdk\";\nimport { config } from \"dotenv\";\n\nconfig({\n path: [\".env\", \".env.local\", \".env.development\", \".env.production\"],\n});\n\nexport function env(key: string) {\n const value = process.env[key];\n if (!value) {\n throw new Error(`Missing environment variable: ${key}`);\n }\n return value;\n}\n\nconst BASE_URL = process.env.WHOP_BASE_URL;\n\nexport const COMPANY_ID = process.env.NEXT_PUBLIC_WHOP_COMPANY_ID;\nexport const APP_ID = env(\"NEXT_PUBLIC_WHOP_APP_ID\");\nexport const AI_PROMPT_ID = process.env.AI_PROMPT_ID;\n\nconst headersJSON = process.env.WHOP_EXTRA_API_HEADERS_JSON;\nlet parsedExtraHeaders: Record<string, string> | undefined = undefined;\n\ntry {\n if (headersJSON) {\n parsedExtraHeaders = JSON.parse(headersJSON);\n }\n} catch (e) {\n console.error(\"FAILED TO PARSE EXTRA WHOP API HEADERS\", e);\n}\n\nexport const whopSdk = new Whop({\n appID: APP_ID,\n baseURL: BASE_URL ? new URL(\"/api/v1\", BASE_URL).href : undefined,\n defaultHeaders: parsedExtraHeaders,\n});\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { loadConfig } from \"metro\";\n\nexport async function loadMetroConfig(projectRoot: string) {\n\tconst file = fs.existsSync(path.join(projectRoot, \"metro.config.js\"));\n\tif (!file) return {};\n\treturn await loadConfig({ cwd: projectRoot }, {});\n}\n","import { readdir } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nexport const VALID_VIEW_TYPES = [\n\t\"experience-view\",\n\t\"discover-view\",\n\t\"dashboard-view\",\n] 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 { AI_PROMPT_ID, 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(\n\t\t\t\tfile,\n\t\t\t)}\", () => WhopNavigationWrapper(React, \"${toPascalCase(\n\t\t\t\tfile,\n\t\t\t)}\", ${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 viewType = new URLSearchParams(window.location.search).get(\"app_view\") ?? \"${defaultKey}\";\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(viewType, { 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\t\".mjs\",\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\t\".mjs\": \"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 viewTypes = await getSupportedAppViewTypes(root);\n\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(\n\t\t\t0,\n\t\t)} KB)`,\n\t);\n\n\tconst build = await whopSdk.appBuilds.create({\n\t\tattachment: { id: uploadedFile.id },\n\t\tchecksum,\n\t\tapp_id: APP_ID,\n\t\tplatform: \"web\",\n\t\tai_prompt_id: AI_PROMPT_ID,\n\t\tsupported_app_view_types: 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\t\"dashboard-view\": \"dashboard\" 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 companyPart = COMPANY_ID ? `${COMPANY_ID}/` : \"\";\n\tconst dashboardUrl = `https://whop.com/dashboard/${companyPart}developer/apps/${APP_ID}/builds/?platform=web`;\n\n\tconsole.log(\n\t\t`\\n ✔︎ [web] deployed as development build ✔︎\\n - build id: ${\n\t\t\tbuild.id\n\t\t}\\n - view types: ${build.supported_app_view_types.join(\n\t\t\t\", \",\n\t\t)}\\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\";\nimport * as path from \"node:path\";\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\t// Only process react-native core files that contain Flow\n\t\t\t\tif (!args.path.includes(`${path.sep}react-native${path.sep}`)) {\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 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// Use Hermes parser to handle modern Flow syntax (as casts, type predicates, mapped types, etc.)\n\t\t\t\t\t\t\"babel-plugin-syntax-hermes-parser\",\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\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;;;ACDhB,SAAS,QAAQ,MAAuB;AAC9C,QAAM,QAAQ,QAAQ,IAAI,IAAI,GAAG,YAAY;AAC7C,SAAO,UAAU,OAAO,UAAU,UAAU,UAAU;AACvD;;;ACPA,SAAS,YAAY,cAAc,aAAa,gBAAgB;AAChE,SAAS,OAAO,QAAQ,iBAAiB;AACzC,OAAOC,WAAU;AACjB,SAAS,kBAAkB,mBAAmB;AAC9C,SAAS,cAAc;AACvB,OAAO,WAAW;AAClB,SAA8C,gBAAgB;;;ACN9D,SAAS,kBAAkB;;;ACA3B,OAAO,UAAU;AACjB,SAAS,cAAc;AAEvB,OAAO;AAAA,EACL,MAAM,CAAC,QAAQ,cAAc,oBAAoB,iBAAiB;AACpE,CAAC;AAEM,SAAS,IAAI,KAAa;AAC/B,QAAM,QAAQ,QAAQ,IAAI,GAAG;AAC7B,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,MAAM,iCAAiC,GAAG,EAAE;AAAA,EACxD;AACA,SAAO;AACT;AAEA,IAAM,WAAW,QAAQ,IAAI;AAEtB,IAAM,aAAa,QAAQ,IAAI;AAC/B,IAAM,SAAS,IAAI,yBAAyB;AAC5C,IAAM,eAAe,QAAQ,IAAI;AAExC,IAAM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IAAI,CAAC;AAAA,EACrD;AACA,MAAI,KAAK,OAAO,OAAO,CAAC,oBAAoB;AAC3C,aAAS,KAAKC,iBAAmB,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,MAAc;AACtD,QAAM,iBAAiBD,MAAK,KAAK,MAAM,SAAS,aAAa;AAC7D,MAAIC,YAAW,cAAc,GAAG;AAC/B,UAAM,OAAO,cAAc;AAAA,EAC5B;AACA,UAAQ,IAAI,mDAAyC;AACtD;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","path","build","mkdir","readFile","writeFile","path","fs","path","fs","path","babel","path","readFile","mkdir","writeFile","buildAndPublish","build","buildAndPublish","path","existsSync","findUp"]}
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.12",
4
+ "version": "0.1.14",
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.20",
48
+ "@whop/sdk": "0.0.23",
49
49
  "dotenv": "16.5.0",
50
50
  "esbuild": "0.25.9",
51
51
  "events": "3.3.0",
@@ -55,7 +55,6 @@
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/api": "0.0.51",
59
58
  "@whop/iframe": "0.0.5"
60
59
  },
61
60
  "devDependencies": {