@whop/react-native 0.0.6 → 0.0.8
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/{chunk-AXIFUFN6.mjs → chunk-KIXXMEFR.mjs} +2 -1
- package/dist/cli/babel.config.js +4 -1
- package/dist/cli/index.js +1 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +2 -1
- package/dist/cli/index.mjs.map +1 -1
- package/dist/lib/index.d.mts +7 -0
- package/dist/lib/index.d.ts +7 -0
- package/dist/lib/index.js +1 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +2 -1
- package/dist/lib/index.mjs.map +1 -1
- package/package.json +5 -3
- /package/dist/{chunk-AXIFUFN6.mjs.map → chunk-KIXXMEFR.mjs.map} +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -27,4 +28,4 @@ export {
|
|
|
27
28
|
__export,
|
|
28
29
|
__reExport
|
|
29
30
|
};
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
31
|
+
//# sourceMappingURL=chunk-KIXXMEFR.mjs.map
|
package/dist/cli/babel.config.js
CHANGED
package/dist/cli/index.js
CHANGED
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/index.ts","../../src/cli/mobile.ts","../../src/cli/file.ts","../../src/cli/sdk.ts","../../src/cli/valid-view-type.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { parseArgs } from \"node:util\";\nimport { findUp } from \"find-up\";\nimport { rimraf } from \"rimraf\";\nimport { buildAndPublish } from \"./mobile\";\n\nasync function main() {\n\tconst args = parseArgs({\n\t\toptions: {\n\t\t\tios: {\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\tandroid: {\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\tweb: {\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t},\n\t\tstrict: true,\n\t\tallowPositionals: true,\n\t\targs: process.argv.slice(2),\n\t});\n\n\tconst [command] = args.positionals;\n\n\tlet shouldBuild = true;\n\tlet shouldUpload = true;\n\tlet shouldClean = true;\n\tif (command === \"build\") {\n\t\tshouldUpload = false;\n\t} else if (command === \"ship\") {\n\t\tshouldBuild = true;\n\t\tshouldUpload = true;\n\t} else if (command === \"upload\") {\n\t\tshouldBuild = false;\n\t\tshouldClean = false;\n\t} else if (command === \"clean\") {\n\t\tshouldBuild = false;\n\t\tshouldUpload = false;\n\t} else {\n\t\tconsole.error(\n\t\t\t`Usage:\n\twhop-react-native ship [--ios] [--android] [--web] # runs build and then publishes it as a dev build to whop.\n\twhop-react-native build [--ios] [--android] [--web] # builds your app into a distributable bundle in the build/ directory.\n\twhop-react-native upload [--ios] [--android] [--web] # uploads the existing build directory to whop.\n\twhop-react-native clean # cleans the build directory.`,\n\t\t);\n\t\tprocess.exit(1);\n\t}\n\n\tconst root = await getRootProjectDirectory();\n\n\tif (shouldClean) {\n\t\tawait cleanBuildDirectory(root);\n\t}\n\n\tconst didProvidePlatform =\n\t\targs.values.ios || args.values.android || args.values.web;\n\n\tconst opts = { shouldBuild, shouldUpload };\n\tconst promises: Promise<void>[] = [];\n\n\tif (args.values.ios || !didProvidePlatform) {\n\t\tpromises.push(buildAndPublish(root, \"ios\", opts));\n\t}\n\tif (args.values.android || !didProvidePlatform) {\n\t\tpromises.push(buildAndPublish(root, \"android\", opts));\n\t}\n\tif (args.values.web || !didProvidePlatform) {\n\t\tconsole.warn(\" - [web] builds for web are not supported yet - coming soon\");\n\t}\n\n\tawait Promise.all(promises);\n}\n\nasync function cleanBuildDirectory(root: string) {\n\tconst buildDirectory = path.join(root, \"build\");\n\tif (existsSync(buildDirectory)) {\n\t\tawait rimraf(buildDirectory);\n\t}\n\tconsole.log(\" ✔︎ cleaned build directory\");\n}\n\nasync function getRootProjectDirectory() {\n\tconst file = await findUp(\"package.json\", { cwd: process.cwd() });\n\tif (!file) {\n\t\tthrow new Error(\n\t\t\t\"please run this command inside a whop react native project\",\n\t\t);\n\t}\n\tconst root = path.dirname(file);\n\treturn root;\n}\n\nmain()\n\t.catch((err) => {\n\t\tconsole.error(err);\n\t\tprocess.exit(1);\n\t})\n\t.then(() => {\n\t\tprocess.exit(0);\n\t});\n","import { existsSync, readFileSync, readdirSync, statSync } from \"node:fs\";\nimport { mkdir, readdir, rename, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { getDefaultConfig } from \"@react-native/metro-config\";\nimport { findUp } from \"find-up\";\nimport JSZip from \"jszip\";\nimport { type ReportableEvent, type Reporter, runBuild } from \"metro\";\nimport { getChecksum, uploadFile } from \"./file\";\nimport { APP_ID, COMPANY_ID, whopSdk } from \"./sdk\";\nimport { VALID_VIEW_TYPES } from \"./valid-view-type\";\n\nexport async function buildAndPublish(\n\troot: string,\n\tplatform: \"ios\" | \"android\",\n\t{\n\t\tshouldBuild = true,\n\t\tshouldUpload = true,\n\t}: { shouldBuild: boolean; shouldUpload: boolean } = {\n\t\tshouldBuild: true,\n\t\tshouldUpload: true,\n\t},\n) {\n\tif (shouldBuild) {\n\t\tawait bundle(root, platform);\n\t}\n\tif (shouldUpload) {\n\t\tawait createMobileBuild(root, platform);\n\t}\n}\n\nexport async function bundle(root: string, platform: \"ios\" | \"android\") {\n\tawait makeEntrypoint(root, platform);\n\n\tconst outputFile = path.join(\n\t\troot,\n\t\t\"build\",\n\t\t\"output\",\n\t\tplatform,\n\t\t\"main_js_bundle\",\n\t);\n\tawait mkdir(path.dirname(outputFile), { recursive: true });\n\n\tconst defaultConfig = getDefaultConfig(root);\n\n\tconst babelLocation = require.resolve(\"@babel/runtime/package\");\n\n\tconst bableNodeModules = await findUp(\"node_modules\", {\n\t\tcwd: babelLocation,\n\t\ttype: \"directory\",\n\t});\n\tif (!bableNodeModules) {\n\t\tthrow new Error(\"babel node_modules parent folder not found\");\n\t}\n\n\tawait runBuild(\n\t\t{\n\t\t\t...defaultConfig,\n\t\t\tprojectRoot: root,\n\t\t\ttransformer: {\n\t\t\t\t...defaultConfig.transformer,\n\t\t\t\tbabelTransformerPath: require.resolve(\n\t\t\t\t\t\"./whop-react-native-babel-transformer.js\",\n\t\t\t\t),\n\t\t\t},\n\t\t\twatchFolders: [\n\t\t\t\troot,\n\t\t\t\tpath.resolve(root, \"node_modules\"),\n\t\t\t\tbableNodeModules,\n\t\t\t],\n\t\t\treporter: new CustomReporter(),\n\t\t\tresolver: {\n\t\t\t\t...defaultConfig.resolver,\n\t\t\t\tnodeModulesPaths: [\n\t\t\t\t\t...(defaultConfig.resolver?.nodeModulesPaths ?? []),\n\t\t\t\t\tbableNodeModules,\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tdev: false,\n\t\t\tentry: `build/entrypoints/${platform}/index.js`,\n\t\t\tminify: false,\n\t\t\tplatform: platform,\n\t\t\tsourceMap: false,\n\t\t\tout: outputFile,\n\t\t},\n\t);\n\n\tawait rename(\n\t\t`${outputFile}.js`,\n\t\tpath.join(root, \"build\", \"output\", platform, \"main_js_bundle.hbc\"),\n\t);\n\n\tconsole.log(` ✔︎ [${platform}] bundle created`);\n}\n\nasync function getSupportedAppViewTypes(\n\troot: string,\n): Promise<(typeof VALID_VIEW_TYPES)[number][]> {\n\tconst views = await readdir(path.join(root, \"src\", \"views\"), {\n\t\twithFileTypes: true,\n\t\trecursive: false,\n\t});\n\tconst files = views\n\t\t.filter((file) => file.isFile())\n\t\t.map((file) => file.name.split(\".\")[0])\n\t\t.filter((file) => !!file);\n\n\tconst validViews = files.filter((file) =>\n\t\tVALID_VIEW_TYPES.includes(file as (typeof VALID_VIEW_TYPES)[number]),\n\t) as (typeof VALID_VIEW_TYPES)[number][];\n\n\tif (validViews.length === 0) {\n\t\tthrow new Error(\n\t\t\t`No valid views found, please create a view in the src/views folder and name it with a valid view type: ${VALID_VIEW_TYPES.join(\", \")}`,\n\t\t);\n\t}\n\n\treturn validViews;\n}\n\nasync function makeEntrypoint(\n\troot: string,\n\tplatform: \"ios\" | \"android\",\n): Promise<string> {\n\tconst entrypoint = path.join(\n\t\troot,\n\t\t\"build\",\n\t\t\"entrypoints\",\n\t\tplatform,\n\t\t\"index.js\",\n\t);\n\n\tconst files = await getSupportedAppViewTypes(root);\n\n\tconst pascalCase = (str: string) =>\n\t\tstr\n\t\t\t.split(\"-\")\n\t\t\t.map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n\t\t\t.join(\"\");\n\n\tconst imports = files.map(\n\t\t(file) =>\n\t\t\t`import { ${pascalCase(file)} } from \"../../../src/views/${file}\";`,\n\t);\n\tconst registry = files.map(\n\t\t(file) =>\n\t\t\t`AppRegistry.registerComponent(\"${pascalCase(file)}\", () => ${pascalCase(file)});`,\n\t);\n\n\tconst entrypointContent = `import { AppRegistry } from \"react-native\";\n${imports.join(\"\\n\")}\n\n${registry.join(\"\\n\")}\n`;\n\n\tconst entrypointDir = path.dirname(entrypoint);\n\tawait mkdir(entrypointDir, { recursive: true });\n\tawait writeFile(entrypoint, entrypointContent, \"utf-8\");\n\n\tconsole.log(` ✔︎ [${platform}] entrypoint created`);\n\n\treturn entrypoint;\n}\n\nexport async function createMobileBuild(\n\troot: string,\n\tplatform: \"ios\" | \"android\",\n) {\n\tconst viewTypes = await getSupportedAppViewTypes(root);\n\n\tconst fullDirectory = path.join(root, \"build\", \"output\", platform);\n\n\t// Check if the directory contains a file called `main_js_bundle.hbc`\n\tconst mainJsBundle = path.join(fullDirectory, \"main_js_bundle.hbc\");\n\n\tif (!existsSync(mainJsBundle)) {\n\t\tthrow new Error(`main_js_bundle.hbc not found in ${fullDirectory}`);\n\t}\n\n\t// check that that folder only contains the main_js_bundle.hbc file and an optional `assets` folder\n\tconst files = readdirSync(fullDirectory);\n\tif (\n\t\tfiles.length > 2 ||\n\t\tfiles.length < 1 ||\n\t\t!files.includes(\"main_js_bundle.hbc\")\n\t) {\n\t\tthrow new Error(\n\t\t\t\"Directory must contain only the main_js_bundle.hbc file and an optional `assets` folder\",\n\t\t);\n\t}\n\tif (files.length === 2 && !files.includes(\"assets\")) {\n\t\tthrow new Error(\n\t\t\t\"Directory must contain only the main_js_bundle.hbc file and an optional `assets` folder\",\n\t\t);\n\t}\n\n\t// Zip the directory\n\tconst zipData = await zipDirectory(fullDirectory);\n\n\tconst checksum = await getChecksum(zipData);\n\n\tconsole.log(` ✔︎ [${platform}] build zipped with checksum: ${checksum}`);\n\n\tconst fileName = `app_build_${platform}.zip`;\n\tconst uploadedFile = await uploadFile(zipData, fileName, \"application/zip\");\n\n\tconsole.log(\n\t\t` ✔︎ [${platform}] uploaded build: ${fileName} (${(zipData.length / 1024).toFixed(0)} KB)`,\n\t);\n\n\tconst build = await whopSdk.apps.createAppBuild({\n\t\tattachment: { directUploadId: uploadedFile.directUploadId },\n\t\tchecksum,\n\t\tplatform,\n\t\tsupportedAppViewTypes: viewTypes.map(\n\t\t\t(view) =>\n\t\t\t\t({\n\t\t\t\t\t\"experience-view\": \"hub\" as const,\n\t\t\t\t\t\"discover-view\": \"discover\" as const,\n\t\t\t\t})[view],\n\t\t),\n\t});\n\n\tif (!build) {\n\t\tthrow new Error(\"Failed to create app build\");\n\t}\n\n\tconst dashboardUrl = `https://whop.com/dashboard/${COMPANY_ID}/developer/apps/${APP_ID}/builds/`;\n\n\tconsole.log(`\\n ✔︎ [${platform}] deployed as development build ✔︎\n - build id: ${build.id}\n - view types: ${viewTypes.join(\", \")}\n - promote to production here: ${dashboardUrl}\\n`);\n\n\treturn build;\n}\n\nasync function zipDirectory(\n\tdirectory: string,\n): Promise<Buffer<ArrayBufferLike>> {\n\tconst zip = new JSZip();\n\n\t// Recursively add files to zip\n\tfunction addFilesToZip(currentPath: string, relativePath = \"\") {\n\t\tconst items = readdirSync(currentPath);\n\n\t\tfor (const item of items) {\n\t\t\tconst fullPath = path.join(currentPath, item);\n\t\t\tconst zipPath = relativePath ? path.join(relativePath, item) : item;\n\t\t\tconst stats = statSync(fullPath);\n\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\taddFilesToZip(fullPath, zipPath);\n\t\t\t} else {\n\t\t\t\tconst fileContent = readFileSync(fullPath);\n\t\t\t\tzip.file(zipPath, fileContent);\n\t\t\t}\n\t\t}\n\t}\n\n\taddFilesToZip(directory);\n\n\t// Generate zip file\n\tconst zipData = await zip.generateAsync({ type: \"nodebuffer\" });\n\n\treturn zipData;\n}\n\nclass CustomReporter implements Reporter {\n\tupdate(event: ReportableEvent) {\n\t\t// Do nothing.\n\t}\n}\n","import { createHash } from \"node:crypto\";\nimport { AGENT_USER_ID, APP_ID, whopSdk } from \"./sdk\";\n\nexport async function uploadFile(\n\tdata: Buffer<ArrayBufferLike>,\n\tname: string,\n\tcontentType: string,\n) {\n\tconst file = new File([data], name, {\n\t\ttype: contentType,\n\t});\n\n\tconst uploadedFile = await whopSdk\n\t\t.withUser(AGENT_USER_ID)\n\t\t.attachments.uploadAttachment({\n\t\t\tfile,\n\t\t\trecord: \"app\",\n\t\t\tid: APP_ID,\n\t\t});\n\n\treturn uploadedFile;\n}\n\nexport async function getChecksum(data: Buffer<ArrayBufferLike>) {\n\tconst hash = createHash(\"sha256\");\n\thash.update(data);\n\treturn hash.digest(\"hex\");\n}\n","import { WhopServerSdk } from \"@whop/api\";\nimport { config } from \"dotenv\";\n\nconfig({\n\tpath: [\".env\", \".env.local\", \".env.development\", \".env.production\"],\n});\n\nfunction env(key: string) {\n\tconst value = process.env[key];\n\tif (!value) {\n\t\tthrow new Error(`Missing environment variable: ${key}`);\n\t}\n\treturn value;\n}\n\nexport const AGENT_USER_ID = env(\"NEXT_PUBLIC_WHOP_AGENT_USER_ID\");\nexport const COMPANY_ID = env(\"NEXT_PUBLIC_WHOP_COMPANY_ID\");\nexport const APP_ID = env(\"NEXT_PUBLIC_WHOP_APP_ID\");\n\nexport const whopSdk: WhopServerSdk = WhopServerSdk({\n\tappApiKey: env(\"WHOP_API_KEY\"),\n\tappId: APP_ID,\n\tcompanyId: COMPANY_ID,\n\tonBehalfOfUserId: AGENT_USER_ID,\n});\n","export const VALID_VIEW_TYPES = [\"experience-view\", \"discover-view\"] as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,kBAA2B;AAC3B,IAAAC,oBAAiB;AACjB,uBAA0B;AAC1B,IAAAC,kBAAuB;AACvB,oBAAuB;;;ACJvB,qBAAgE;AAChE,sBAAkD;AAClD,uBAAiB;AACjB,0BAAiC;AACjC,qBAAuB;AACvB,mBAAkB;AAClB,mBAA8D;;;ACN9D,yBAA2B;;;ACA3B,iBAA8B;AAC9B,oBAAuB;AAAA,IAEvB,sBAAO;AAAA,EACN,MAAM,CAAC,QAAQ,cAAc,oBAAoB,iBAAiB;AACnE,CAAC;AAED,SAAS,IAAI,KAAa;AACzB,QAAM,QAAQ,QAAQ,IAAI,GAAG;AAC7B,MAAI,CAAC,OAAO;AACX,UAAM,IAAI,MAAM,iCAAiC,GAAG,EAAE;AAAA,EACvD;AACA,SAAO;AACR;AAEO,IAAM,gBAAgB,IAAI,gCAAgC;AAC1D,IAAM,aAAa,IAAI,6BAA6B;AACpD,IAAM,SAAS,IAAI,yBAAyB;AAE5C,IAAM,cAAyB,0BAAc;AAAA,EACnD,WAAW,IAAI,cAAc;AAAA,EAC7B,OAAO;AAAA,EACP,WAAW;AAAA,EACX,kBAAkB;AACnB,CAAC;;;ADrBD,eAAsB,WACrB,MACA,MACA,aACC;AACD,QAAM,OAAO,IAAI,KAAK,CAAC,IAAI,GAAG,MAAM;AAAA,IACnC,MAAM;AAAA,EACP,CAAC;AAED,QAAM,eAAe,MAAM,QACzB,SAAS,aAAa,EACtB,YAAY,iBAAiB;AAAA,IAC7B;AAAA,IACA,QAAQ;AAAA,IACR,IAAI;A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BAAoB;AAC/C,aAAS,KAAK,gBAAgB,MAAM,WAAW,IAAI,CAAC;AAAA,EACrD;AACA,MAAI,KAAK,OAAO,OAAO,CAAC,oBAAoB;AAC3C,YAAQ,KAAK,6DAA6D;AAAA,EAC3E;AAEA,QAAM,QAAQ,IAAI,QAAQ;AAC3B;AAEA,eAAe,oBAAoB,MAAc;AAChD,QAAM,iBAAiB,kBAAAE,QAAK,KAAK,MAAM,OAAO;AAC9C,UAAI,4BAAW,cAAc,GAAG;AAC/B,cAAM,sBAAO,cAAc;AAAA,EAC5B;AACA,UAAQ,IAAI,uCAA6B;AAC1C;AAEA,eAAe,0BAA0B;AACxC,QAAM,OAAO,UAAM,wBAAO,gBAAgB,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC;AAChE,MAAI,CAAC,MAAM;AACV,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AACA,QAAM,OAAO,kBAAAA,QAAK,QAAQ,IAAI;AAC9B,SAAO;AACR;AAEA,KAAK,EACH,MAAM,CAAC,QAAQ;AACf,UAAQ,MAAM,GAAG;AACjB,UAAQ,KAAK,CAAC;AACf,CAAC,EACA,KAAK,MAAM;AACX,UAAQ,KAAK,CAAC;AACf,CAAC;","names":["import_node_fs","import_node_path","import_find_up","path","JSZip","path"]}
|
|
1
|
+
{"version":3,"sources":["../../src/cli/index.ts","../../src/cli/mobile.ts","../../src/cli/file.ts","../../src/cli/sdk.ts","../../src/cli/valid-view-type.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { parseArgs } from \"node:util\";\nimport { findUp } from \"find-up\";\nimport { rimraf } from \"rimraf\";\nimport { buildAndPublish } from \"./mobile\";\n\nasync function main() {\n\tconst args = parseArgs({\n\t\toptions: {\n\t\t\tios: {\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\tandroid: {\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\tweb: {\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t},\n\t\tstrict: true,\n\t\tallowPositionals: true,\n\t\targs: process.argv.slice(2),\n\t});\n\n\tconst [command] = args.positionals;\n\n\tlet shouldBuild = true;\n\tlet shouldUpload = true;\n\tlet shouldClean = true;\n\tif (command === \"build\") {\n\t\tshouldUpload = false;\n\t} else if (command === \"ship\") {\n\t\tshouldBuild = true;\n\t\tshouldUpload = true;\n\t} else if (command === \"upload\") {\n\t\tshouldBuild = false;\n\t\tshouldClean = false;\n\t} else if (command === \"clean\") {\n\t\tshouldBuild = false;\n\t\tshouldUpload = false;\n\t} else {\n\t\tconsole.error(\n\t\t\t`Usage:\n\twhop-react-native ship [--ios] [--android] [--web] # runs build and then publishes it as a dev build to whop.\n\twhop-react-native build [--ios] [--android] [--web] # builds your app into a distributable bundle in the build/ directory.\n\twhop-react-native upload [--ios] [--android] [--web] # uploads the existing build directory to whop.\n\twhop-react-native clean # cleans the build directory.`,\n\t\t);\n\t\tprocess.exit(1);\n\t}\n\n\tconst root = await getRootProjectDirectory();\n\n\tif (shouldClean) {\n\t\tawait cleanBuildDirectory(root);\n\t}\n\n\tconst didProvidePlatform =\n\t\targs.values.ios || args.values.android || args.values.web;\n\n\tconst opts = { shouldBuild, shouldUpload };\n\tconst promises: Promise<void>[] = [];\n\n\tif (args.values.ios || !didProvidePlatform) {\n\t\tpromises.push(buildAndPublish(root, \"ios\", opts));\n\t}\n\tif (args.values.android || !didProvidePlatform) {\n\t\tpromises.push(buildAndPublish(root, \"android\", opts));\n\t}\n\tif (args.values.web || !didProvidePlatform) {\n\t\tconsole.warn(\" - [web] builds for web are not supported yet - coming soon\");\n\t}\n\n\tawait Promise.all(promises);\n}\n\nasync function cleanBuildDirectory(root: string) {\n\tconst buildDirectory = path.join(root, \"build\");\n\tif (existsSync(buildDirectory)) {\n\t\tawait rimraf(buildDirectory);\n\t}\n\tconsole.log(\" ✔︎ cleaned build directory\");\n}\n\nasync function getRootProjectDirectory() {\n\tconst file = await findUp(\"package.json\", { cwd: process.cwd() });\n\tif (!file) {\n\t\tthrow new Error(\n\t\t\t\"please run this command inside a whop react native project\",\n\t\t);\n\t}\n\tconst root = path.dirname(file);\n\treturn root;\n}\n\nmain()\n\t.catch((err) => {\n\t\tconsole.error(err);\n\t\tprocess.exit(1);\n\t})\n\t.then(() => {\n\t\tprocess.exit(0);\n\t});\n","import { existsSync, readFileSync, readdirSync, statSync } from \"node:fs\";\nimport { mkdir, readdir, rename, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { getDefaultConfig } from \"@react-native/metro-config\";\nimport { findUp } from \"find-up\";\nimport JSZip from \"jszip\";\nimport { type ReportableEvent, type Reporter, runBuild } from \"metro\";\nimport { getChecksum, uploadFile } from \"./file\";\nimport { APP_ID, COMPANY_ID, whopSdk } from \"./sdk\";\nimport { VALID_VIEW_TYPES } from \"./valid-view-type\";\n\nexport async function buildAndPublish(\n\troot: string,\n\tplatform: \"ios\" | \"android\",\n\t{\n\t\tshouldBuild = true,\n\t\tshouldUpload = true,\n\t}: { shouldBuild: boolean; shouldUpload: boolean } = {\n\t\tshouldBuild: true,\n\t\tshouldUpload: true,\n\t},\n) {\n\tif (shouldBuild) {\n\t\tawait bundle(root, platform);\n\t}\n\tif (shouldUpload) {\n\t\tawait createMobileBuild(root, platform);\n\t}\n}\n\nexport async function bundle(root: string, platform: \"ios\" | \"android\") {\n\tawait makeEntrypoint(root, platform);\n\n\tconst outputFile = path.join(\n\t\troot,\n\t\t\"build\",\n\t\t\"output\",\n\t\tplatform,\n\t\t\"main_js_bundle\",\n\t);\n\tawait mkdir(path.dirname(outputFile), { recursive: true });\n\n\tconst defaultConfig = getDefaultConfig(root);\n\n\tconst babelLocation = require.resolve(\"@babel/runtime/package\");\n\n\tconst bableNodeModules = await findUp(\"node_modules\", {\n\t\tcwd: babelLocation,\n\t\ttype: \"directory\",\n\t});\n\tif (!bableNodeModules) {\n\t\tthrow new Error(\"babel node_modules parent folder not found\");\n\t}\n\n\tawait runBuild(\n\t\t{\n\t\t\t...defaultConfig,\n\t\t\tprojectRoot: root,\n\t\t\ttransformer: {\n\t\t\t\t...defaultConfig.transformer,\n\t\t\t\tbabelTransformerPath: require.resolve(\n\t\t\t\t\t\"./whop-react-native-babel-transformer.js\",\n\t\t\t\t),\n\t\t\t},\n\t\t\twatchFolders: [\n\t\t\t\troot,\n\t\t\t\tpath.resolve(root, \"node_modules\"),\n\t\t\t\tbableNodeModules,\n\t\t\t],\n\t\t\treporter: new CustomReporter(),\n\t\t\tresolver: {\n\t\t\t\t...defaultConfig.resolver,\n\t\t\t\tnodeModulesPaths: [\n\t\t\t\t\t...(defaultConfig.resolver?.nodeModulesPaths ?? []),\n\t\t\t\t\tbableNodeModules,\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tdev: false,\n\t\t\tentry: `build/entrypoints/${platform}/index.js`,\n\t\t\tminify: false,\n\t\t\tplatform: platform,\n\t\t\tsourceMap: false,\n\t\t\tout: outputFile,\n\t\t},\n\t);\n\n\tawait rename(\n\t\t`${outputFile}.js`,\n\t\tpath.join(root, \"build\", \"output\", platform, \"main_js_bundle.hbc\"),\n\t);\n\n\tconsole.log(` ✔︎ [${platform}] bundle created`);\n}\n\nasync function getSupportedAppViewTypes(\n\troot: string,\n): Promise<(typeof VALID_VIEW_TYPES)[number][]> {\n\tconst views = await readdir(path.join(root, \"src\", \"views\"), {\n\t\twithFileTypes: true,\n\t\trecursive: false,\n\t});\n\tconst files = views\n\t\t.filter((file) => file.isFile())\n\t\t.map((file) => file.name.split(\".\")[0])\n\t\t.filter((file) => !!file);\n\n\tconst validViews = files.filter((file) =>\n\t\tVALID_VIEW_TYPES.includes(file as (typeof VALID_VIEW_TYPES)[number]),\n\t) as (typeof VALID_VIEW_TYPES)[number][];\n\n\tif (validViews.length === 0) {\n\t\tthrow new Error(\n\t\t\t`No valid views found, please create a view in the src/views folder and name it with a valid view type: ${VALID_VIEW_TYPES.join(\", \")}`,\n\t\t);\n\t}\n\n\treturn validViews;\n}\n\nasync function makeEntrypoint(\n\troot: string,\n\tplatform: \"ios\" | \"android\",\n): Promise<string> {\n\tconst entrypoint = path.join(\n\t\troot,\n\t\t\"build\",\n\t\t\"entrypoints\",\n\t\tplatform,\n\t\t\"index.js\",\n\t);\n\n\tconst files = await getSupportedAppViewTypes(root);\n\n\tconst pascalCase = (str: string) =>\n\t\tstr\n\t\t\t.split(\"-\")\n\t\t\t.map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n\t\t\t.join(\"\");\n\n\tconst imports = files.map(\n\t\t(file) =>\n\t\t\t`import { ${pascalCase(file)} } from \"../../../src/views/${file}\";`,\n\t);\n\tconst registry = files.map(\n\t\t(file) =>\n\t\t\t`AppRegistry.registerComponent(\"${pascalCase(file)}\", () => ${pascalCase(file)});`,\n\t);\n\n\tconst entrypointContent = `import { AppRegistry } from \"react-native\";\n${imports.join(\"\\n\")}\n\n${registry.join(\"\\n\")}\n`;\n\n\tconst entrypointDir = path.dirname(entrypoint);\n\tawait mkdir(entrypointDir, { recursive: true });\n\tawait writeFile(entrypoint, entrypointContent, \"utf-8\");\n\n\tconsole.log(` ✔︎ [${platform}] entrypoint created`);\n\n\treturn entrypoint;\n}\n\nexport async function createMobileBuild(\n\troot: string,\n\tplatform: \"ios\" | \"android\",\n) {\n\tconst viewTypes = await getSupportedAppViewTypes(root);\n\n\tconst fullDirectory = path.join(root, \"build\", \"output\", platform);\n\n\t// Check if the directory contains a file called `main_js_bundle.hbc`\n\tconst mainJsBundle = path.join(fullDirectory, \"main_js_bundle.hbc\");\n\n\tif (!existsSync(mainJsBundle)) {\n\t\tthrow new Error(`main_js_bundle.hbc not found in ${fullDirectory}`);\n\t}\n\n\t// check that that folder only contains the main_js_bundle.hbc file and an optional `assets` folder\n\tconst files = readdirSync(fullDirectory);\n\tif (\n\t\tfiles.length > 2 ||\n\t\tfiles.length < 1 ||\n\t\t!files.includes(\"main_js_bundle.hbc\")\n\t) {\n\t\tthrow new Error(\n\t\t\t\"Directory must contain only the main_js_bundle.hbc file and an optional `assets` folder\",\n\t\t);\n\t}\n\tif (files.length === 2 && !files.includes(\"assets\")) {\n\t\tthrow new Error(\n\t\t\t\"Directory must contain only the main_js_bundle.hbc file and an optional `assets` folder\",\n\t\t);\n\t}\n\n\t// Zip the directory\n\tconst zipData = await zipDirectory(fullDirectory);\n\n\tconst checksum = await getChecksum(zipData);\n\n\tconsole.log(` ✔︎ [${platform}] build zipped with checksum: ${checksum}`);\n\n\tconst fileName = `app_build_${platform}.zip`;\n\tconst uploadedFile = await uploadFile(zipData, fileName, \"application/zip\");\n\n\tconsole.log(\n\t\t` ✔︎ [${platform}] uploaded build: ${fileName} (${(zipData.length / 1024).toFixed(0)} KB)`,\n\t);\n\n\tconst build = await whopSdk.apps.createAppBuild({\n\t\tattachment: { directUploadId: uploadedFile.directUploadId },\n\t\tchecksum,\n\t\tplatform,\n\t\tsupportedAppViewTypes: viewTypes.map(\n\t\t\t(view) =>\n\t\t\t\t({\n\t\t\t\t\t\"experience-view\": \"hub\" as const,\n\t\t\t\t\t\"discover-view\": \"discover\" as const,\n\t\t\t\t})[view],\n\t\t),\n\t});\n\n\tif (!build) {\n\t\tthrow new Error(\"Failed to create app build\");\n\t}\n\n\tconst dashboardUrl = `https://whop.com/dashboard/${COMPANY_ID}/developer/apps/${APP_ID}/builds/`;\n\n\tconsole.log(`\\n ✔︎ [${platform}] deployed as development build ✔︎\n - build id: ${build.id}\n - view types: ${viewTypes.join(\", \")}\n - promote to production here: ${dashboardUrl}\\n`);\n\n\treturn build;\n}\n\nasync function zipDirectory(\n\tdirectory: string,\n): Promise<Buffer<ArrayBufferLike>> {\n\tconst zip = new JSZip();\n\n\t// Recursively add files to zip\n\tfunction addFilesToZip(currentPath: string, relativePath = \"\") {\n\t\tconst items = readdirSync(currentPath);\n\n\t\tfor (const item of items) {\n\t\t\tconst fullPath = path.join(currentPath, item);\n\t\t\tconst zipPath = relativePath ? path.join(relativePath, item) : item;\n\t\t\tconst stats = statSync(fullPath);\n\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\taddFilesToZip(fullPath, zipPath);\n\t\t\t} else {\n\t\t\t\tconst fileContent = readFileSync(fullPath);\n\t\t\t\tzip.file(zipPath, fileContent);\n\t\t\t}\n\t\t}\n\t}\n\n\taddFilesToZip(directory);\n\n\t// Generate zip file\n\tconst zipData = await zip.generateAsync({ type: \"nodebuffer\" });\n\n\treturn zipData;\n}\n\nclass CustomReporter implements Reporter {\n\tupdate(event: ReportableEvent) {\n\t\t// Do nothing.\n\t}\n}\n","import { createHash } from \"node:crypto\";\nimport { AGENT_USER_ID, APP_ID, whopSdk } from \"./sdk\";\n\nexport async function uploadFile(\n\tdata: Buffer<ArrayBufferLike>,\n\tname: string,\n\tcontentType: string,\n) {\n\tconst file = new File([data], name, {\n\t\ttype: contentType,\n\t});\n\n\tconst uploadedFile = await whopSdk\n\t\t.withUser(AGENT_USER_ID)\n\t\t.attachments.uploadAttachment({\n\t\t\tfile,\n\t\t\trecord: \"app\",\n\t\t\tid: APP_ID,\n\t\t});\n\n\treturn uploadedFile;\n}\n\nexport async function getChecksum(data: Buffer<ArrayBufferLike>) {\n\tconst hash = createHash(\"sha256\");\n\thash.update(data);\n\treturn hash.digest(\"hex\");\n}\n","import { WhopServerSdk } from \"@whop/api\";\nimport { config } from \"dotenv\";\n\nconfig({\n\tpath: [\".env\", \".env.local\", \".env.development\", \".env.production\"],\n});\n\nfunction env(key: string) {\n\tconst value = process.env[key];\n\tif (!value) {\n\t\tthrow new Error(`Missing environment variable: ${key}`);\n\t}\n\treturn value;\n}\n\nexport const AGENT_USER_ID = env(\"NEXT_PUBLIC_WHOP_AGENT_USER_ID\");\nexport const COMPANY_ID = env(\"NEXT_PUBLIC_WHOP_COMPANY_ID\");\nexport const APP_ID = env(\"NEXT_PUBLIC_WHOP_APP_ID\");\n\nexport const whopSdk: WhopServerSdk = WhopServerSdk({\n\tappApiKey: env(\"WHOP_API_KEY\"),\n\tappId: APP_ID,\n\tcompanyId: COMPANY_ID,\n\tonBehalfOfUserId: AGENT_USER_ID,\n});\n","export const VALID_VIEW_TYPES = [\"experience-view\", \"discover-view\"] as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,kBAA2B;AAC3B,IAAAC,oBAAiB;AACjB,uBAA0B;AAC1B,IAAAC,kBAAuB;AACvB,oBAAuB;;;ACJvB,qBAAgE;AAChE,sBAAkD;AAClD,uBAAiB;AACjB,0BAAiC;AACjC,qBAAuB;AACvB,mBAAkB;AAClB,mBAA8D;;;ACN9D,yBAA2B;;;ACA3B,iBAA8B;AAC9B,oBAAuB;AAAA,IAEvB,sBAAO;AAAA,EACN,MAAM,CAAC,QAAQ,cAAc,oBAAoB,iBAAiB;AACnE,CAAC;AAED,SAAS,IAAI,KAAa;AACzB,QAAM,QAAQ,QAAQ,IAAI,GAAG;AAC7B,MAAI,CAAC,OAAO;AACX,UAAM,IAAI,MAAM,iCAAiC,GAAG,EAAE;AAAA,EACvD;AACA,SAAO;AACR;AAEO,IAAM,gBAAgB,IAAI,gCAAgC;AAC1D,IAAM,aAAa,IAAI,6BAA6B;AACpD,IAAM,SAAS,IAAI,yBAAyB;AAE5C,IAAM,cAAyB,0BAAc;AAAA,EACnD,WAAW,IAAI,cAAc;AAAA,EAC7B,OAAO;AAAA,EACP,WAAW;AAAA,EACX,kBAAkB;AACnB,CAAC;;;ADrBD,eAAsB,WACrB,MACA,MACA,aACC;AACD,QAAM,OAAO,IAAI,KAAK,CAAC,IAAI,GAAG,MAAM;AAAA,IACnC,MAAM;AAAA,EACP,CAAC;AAED,QAAM,eAAe,MAAM,QACzB,SAAS,aAAa,EACtB,YAAY,iBAAiB;AAAA,IAC7B;AAAA,IACA,QAAQ;AAAA,IACR,IAAI;AAAA,EACL,CAAC;AAEF,SAAO;AACR;AAEA,eAAsB,YAAY,MAA+B;AAChE,QAAM,WAAO,+BAAW,QAAQ;AAChC,OAAK,OAAO,IAAI;AAChB,SAAO,KA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AAK,6DAA6D;AAAA,EAC3E;AAEA,QAAM,QAAQ,IAAI,QAAQ;AAC3B;AAEA,eAAe,oBAAoB,MAAc;AAChD,QAAM,iBAAiB,kBAAAE,QAAK,KAAK,MAAM,OAAO;AAC9C,UAAI,4BAAW,cAAc,GAAG;AAC/B,cAAM,sBAAO,cAAc;AAAA,EAC5B;AACA,UAAQ,IAAI,uCAA6B;AAC1C;AAEA,eAAe,0BAA0B;AACxC,QAAM,OAAO,UAAM,wBAAO,gBAAgB,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC;AAChE,MAAI,CAAC,MAAM;AACV,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AACA,QAAM,OAAO,kBAAAA,QAAK,QAAQ,IAAI;AAC9B,SAAO;AACR;AAEA,KAAK,EACH,MAAM,CAAC,QAAQ;AACf,UAAQ,MAAM,GAAG;AACjB,UAAQ,KAAK,CAAC;AACf,CAAC,EACA,KAAK,MAAM;AACX,UAAQ,KAAK,CAAC;AACf,CAAC;","names":["import_node_fs","import_node_path","import_find_up","path","JSZip","path"]}
|
package/dist/cli/index.mjs
CHANGED
package/dist/cli/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/index.ts","../../src/cli/mobile.ts","../../src/cli/file.ts","../../src/cli/sdk.ts","../../src/cli/valid-view-type.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { parseArgs } from \"node:util\";\nimport { findUp } from \"find-up\";\nimport { rimraf } from \"rimraf\";\nimport { buildAndPublish } from \"./mobile\";\n\nasync function main() {\n\tconst args = parseArgs({\n\t\toptions: {\n\t\t\tios: {\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\tandroid: {\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\tweb: {\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t},\n\t\tstrict: true,\n\t\tallowPositionals: true,\n\t\targs: process.argv.slice(2),\n\t});\n\n\tconst [command] = args.positionals;\n\n\tlet shouldBuild = true;\n\tlet shouldUpload = true;\n\tlet shouldClean = true;\n\tif (command === \"build\") {\n\t\tshouldUpload = false;\n\t} else if (command === \"ship\") {\n\t\tshouldBuild = true;\n\t\tshouldUpload = true;\n\t} else if (command === \"upload\") {\n\t\tshouldBuild = false;\n\t\tshouldClean = false;\n\t} else if (command === \"clean\") {\n\t\tshouldBuild = false;\n\t\tshouldUpload = false;\n\t} else {\n\t\tconsole.error(\n\t\t\t`Usage:\n\twhop-react-native ship [--ios] [--android] [--web] # runs build and then publishes it as a dev build to whop.\n\twhop-react-native build [--ios] [--android] [--web] # builds your app into a distributable bundle in the build/ directory.\n\twhop-react-native upload [--ios] [--android] [--web] # uploads the existing build directory to whop.\n\twhop-react-native clean # cleans the build directory.`,\n\t\t);\n\t\tprocess.exit(1);\n\t}\n\n\tconst root = await getRootProjectDirectory();\n\n\tif (shouldClean) {\n\t\tawait cleanBuildDirectory(root);\n\t}\n\n\tconst didProvidePlatform =\n\t\targs.values.ios || args.values.android || args.values.web;\n\n\tconst opts = { shouldBuild, shouldUpload };\n\tconst promises: Promise<void>[] = [];\n\n\tif (args.values.ios || !didProvidePlatform) {\n\t\tpromises.push(buildAndPublish(root, \"ios\", opts));\n\t}\n\tif (args.values.android || !didProvidePlatform) {\n\t\tpromises.push(buildAndPublish(root, \"android\", opts));\n\t}\n\tif (args.values.web || !didProvidePlatform) {\n\t\tconsole.warn(\" - [web] builds for web are not supported yet - coming soon\");\n\t}\n\n\tawait Promise.all(promises);\n}\n\nasync function cleanBuildDirectory(root: string) {\n\tconst buildDirectory = path.join(root, \"build\");\n\tif (existsSync(buildDirectory)) {\n\t\tawait rimraf(buildDirectory);\n\t}\n\tconsole.log(\" ✔︎ cleaned build directory\");\n}\n\nasync function getRootProjectDirectory() {\n\tconst file = await findUp(\"package.json\", { cwd: process.cwd() });\n\tif (!file) {\n\t\tthrow new Error(\n\t\t\t\"please run this command inside a whop react native project\",\n\t\t);\n\t}\n\tconst root = path.dirname(file);\n\treturn root;\n}\n\nmain()\n\t.catch((err) => {\n\t\tconsole.error(err);\n\t\tprocess.exit(1);\n\t})\n\t.then(() => {\n\t\tprocess.exit(0);\n\t});\n","import { existsSync, readFileSync, readdirSync, statSync } from \"node:fs\";\nimport { mkdir, readdir, rename, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { getDefaultConfig } from \"@react-native/metro-config\";\nimport { findUp } from \"find-up\";\nimport JSZip from \"jszip\";\nimport { type ReportableEvent, type Reporter, runBuild } from \"metro\";\nimport { getChecksum, uploadFile } from \"./file\";\nimport { APP_ID, COMPANY_ID, whopSdk } from \"./sdk\";\nimport { VALID_VIEW_TYPES } from \"./valid-view-type\";\n\nexport async function buildAndPublish(\n\troot: string,\n\tplatform: \"ios\" | \"android\",\n\t{\n\t\tshouldBuild = true,\n\t\tshouldUpload = true,\n\t}: { shouldBuild: boolean; shouldUpload: boolean } = {\n\t\tshouldBuild: true,\n\t\tshouldUpload: true,\n\t},\n) {\n\tif (shouldBuild) {\n\t\tawait bundle(root, platform);\n\t}\n\tif (shouldUpload) {\n\t\tawait createMobileBuild(root, platform);\n\t}\n}\n\nexport async function bundle(root: string, platform: \"ios\" | \"android\") {\n\tawait makeEntrypoint(root, platform);\n\n\tconst outputFile = path.join(\n\t\troot,\n\t\t\"build\",\n\t\t\"output\",\n\t\tplatform,\n\t\t\"main_js_bundle\",\n\t);\n\tawait mkdir(path.dirname(outputFile), { recursive: true });\n\n\tconst defaultConfig = getDefaultConfig(root);\n\n\tconst babelLocation = require.resolve(\"@babel/runtime/package\");\n\n\tconst bableNodeModules = await findUp(\"node_modules\", {\n\t\tcwd: babelLocation,\n\t\ttype: \"directory\",\n\t});\n\tif (!bableNodeModules) {\n\t\tthrow new Error(\"babel node_modules parent folder not found\");\n\t}\n\n\tawait runBuild(\n\t\t{\n\t\t\t...defaultConfig,\n\t\t\tprojectRoot: root,\n\t\t\ttransformer: {\n\t\t\t\t...defaultConfig.transformer,\n\t\t\t\tbabelTransformerPath: require.resolve(\n\t\t\t\t\t\"./whop-react-native-babel-transformer.js\",\n\t\t\t\t),\n\t\t\t},\n\t\t\twatchFolders: [\n\t\t\t\troot,\n\t\t\t\tpath.resolve(root, \"node_modules\"),\n\t\t\t\tbableNodeModules,\n\t\t\t],\n\t\t\treporter: new CustomReporter(),\n\t\t\tresolver: {\n\t\t\t\t...defaultConfig.resolver,\n\t\t\t\tnodeModulesPaths: [\n\t\t\t\t\t...(defaultConfig.resolver?.nodeModulesPaths ?? []),\n\t\t\t\t\tbableNodeModules,\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tdev: false,\n\t\t\tentry: `build/entrypoints/${platform}/index.js`,\n\t\t\tminify: false,\n\t\t\tplatform: platform,\n\t\t\tsourceMap: false,\n\t\t\tout: outputFile,\n\t\t},\n\t);\n\n\tawait rename(\n\t\t`${outputFile}.js`,\n\t\tpath.join(root, \"build\", \"output\", platform, \"main_js_bundle.hbc\"),\n\t);\n\n\tconsole.log(` ✔︎ [${platform}] bundle created`);\n}\n\nasync function getSupportedAppViewTypes(\n\troot: string,\n): Promise<(typeof VALID_VIEW_TYPES)[number][]> {\n\tconst views = await readdir(path.join(root, \"src\", \"views\"), {\n\t\twithFileTypes: true,\n\t\trecursive: false,\n\t});\n\tconst files = views\n\t\t.filter((file) => file.isFile())\n\t\t.map((file) => file.name.split(\".\")[0])\n\t\t.filter((file) => !!file);\n\n\tconst validViews = files.filter((file) =>\n\t\tVALID_VIEW_TYPES.includes(file as (typeof VALID_VIEW_TYPES)[number]),\n\t) as (typeof VALID_VIEW_TYPES)[number][];\n\n\tif (validViews.length === 0) {\n\t\tthrow new Error(\n\t\t\t`No valid views found, please create a view in the src/views folder and name it with a valid view type: ${VALID_VIEW_TYPES.join(\", \")}`,\n\t\t);\n\t}\n\n\treturn validViews;\n}\n\nasync function makeEntrypoint(\n\troot: string,\n\tplatform: \"ios\" | \"android\",\n): Promise<string> {\n\tconst entrypoint = path.join(\n\t\troot,\n\t\t\"build\",\n\t\t\"entrypoints\",\n\t\tplatform,\n\t\t\"index.js\",\n\t);\n\n\tconst files = await getSupportedAppViewTypes(root);\n\n\tconst pascalCase = (str: string) =>\n\t\tstr\n\t\t\t.split(\"-\")\n\t\t\t.map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n\t\t\t.join(\"\");\n\n\tconst imports = files.map(\n\t\t(file) =>\n\t\t\t`import { ${pascalCase(file)} } from \"../../../src/views/${file}\";`,\n\t);\n\tconst registry = files.map(\n\t\t(file) =>\n\t\t\t`AppRegistry.registerComponent(\"${pascalCase(file)}\", () => ${pascalCase(file)});`,\n\t);\n\n\tconst entrypointContent = `import { AppRegistry } from \"react-native\";\n${imports.join(\"\\n\")}\n\n${registry.join(\"\\n\")}\n`;\n\n\tconst entrypointDir = path.dirname(entrypoint);\n\tawait mkdir(entrypointDir, { recursive: true });\n\tawait writeFile(entrypoint, entrypointContent, \"utf-8\");\n\n\tconsole.log(` ✔︎ [${platform}] entrypoint created`);\n\n\treturn entrypoint;\n}\n\nexport async function createMobileBuild(\n\troot: string,\n\tplatform: \"ios\" | \"android\",\n) {\n\tconst viewTypes = await getSupportedAppViewTypes(root);\n\n\tconst fullDirectory = path.join(root, \"build\", \"output\", platform);\n\n\t// Check if the directory contains a file called `main_js_bundle.hbc`\n\tconst mainJsBundle = path.join(fullDirectory, \"main_js_bundle.hbc\");\n\n\tif (!existsSync(mainJsBundle)) {\n\t\tthrow new Error(`main_js_bundle.hbc not found in ${fullDirectory}`);\n\t}\n\n\t// check that that folder only contains the main_js_bundle.hbc file and an optional `assets` folder\n\tconst files = readdirSync(fullDirectory);\n\tif (\n\t\tfiles.length > 2 ||\n\t\tfiles.length < 1 ||\n\t\t!files.includes(\"main_js_bundle.hbc\")\n\t) {\n\t\tthrow new Error(\n\t\t\t\"Directory must contain only the main_js_bundle.hbc file and an optional `assets` folder\",\n\t\t);\n\t}\n\tif (files.length === 2 && !files.includes(\"assets\")) {\n\t\tthrow new Error(\n\t\t\t\"Directory must contain only the main_js_bundle.hbc file and an optional `assets` folder\",\n\t\t);\n\t}\n\n\t// Zip the directory\n\tconst zipData = await zipDirectory(fullDirectory);\n\n\tconst checksum = await getChecksum(zipData);\n\n\tconsole.log(` ✔︎ [${platform}] build zipped with checksum: ${checksum}`);\n\n\tconst fileName = `app_build_${platform}.zip`;\n\tconst uploadedFile = await uploadFile(zipData, fileName, \"application/zip\");\n\n\tconsole.log(\n\t\t` ✔︎ [${platform}] uploaded build: ${fileName} (${(zipData.length / 1024).toFixed(0)} KB)`,\n\t);\n\n\tconst build = await whopSdk.apps.createAppBuild({\n\t\tattachment: { directUploadId: uploadedFile.directUploadId },\n\t\tchecksum,\n\t\tplatform,\n\t\tsupportedAppViewTypes: viewTypes.map(\n\t\t\t(view) =>\n\t\t\t\t({\n\t\t\t\t\t\"experience-view\": \"hub\" as const,\n\t\t\t\t\t\"discover-view\": \"discover\" as const,\n\t\t\t\t})[view],\n\t\t),\n\t});\n\n\tif (!build) {\n\t\tthrow new Error(\"Failed to create app build\");\n\t}\n\n\tconst dashboardUrl = `https://whop.com/dashboard/${COMPANY_ID}/developer/apps/${APP_ID}/builds/`;\n\n\tconsole.log(`\\n ✔︎ [${platform}] deployed as development build ✔︎\n - build id: ${build.id}\n - view types: ${viewTypes.join(\", \")}\n - promote to production here: ${dashboardUrl}\\n`);\n\n\treturn build;\n}\n\nasync function zipDirectory(\n\tdirectory: string,\n): Promise<Buffer<ArrayBufferLike>> {\n\tconst zip = new JSZip();\n\n\t// Recursively add files to zip\n\tfunction addFilesToZip(currentPath: string, relativePath = \"\") {\n\t\tconst items = readdirSync(currentPath);\n\n\t\tfor (const item of items) {\n\t\t\tconst fullPath = path.join(currentPath, item);\n\t\t\tconst zipPath = relativePath ? path.join(relativePath, item) : item;\n\t\t\tconst stats = statSync(fullPath);\n\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\taddFilesToZip(fullPath, zipPath);\n\t\t\t} else {\n\t\t\t\tconst fileContent = readFileSync(fullPath);\n\t\t\t\tzip.file(zipPath, fileContent);\n\t\t\t}\n\t\t}\n\t}\n\n\taddFilesToZip(directory);\n\n\t// Generate zip file\n\tconst zipData = await zip.generateAsync({ type: \"nodebuffer\" });\n\n\treturn zipData;\n}\n\nclass CustomReporter implements Reporter {\n\tupdate(event: ReportableEvent) {\n\t\t// Do nothing.\n\t}\n}\n","import { createHash } from \"node:crypto\";\nimport { AGENT_USER_ID, APP_ID, whopSdk } from \"./sdk\";\n\nexport async function uploadFile(\n\tdata: Buffer<ArrayBufferLike>,\n\tname: string,\n\tcontentType: string,\n) {\n\tconst file = new File([data], name, {\n\t\ttype: contentType,\n\t});\n\n\tconst uploadedFile = await whopSdk\n\t\t.withUser(AGENT_USER_ID)\n\t\t.attachments.uploadAttachment({\n\t\t\tfile,\n\t\t\trecord: \"app\",\n\t\t\tid: APP_ID,\n\t\t});\n\n\treturn uploadedFile;\n}\n\nexport async function getChecksum(data: Buffer<ArrayBufferLike>) {\n\tconst hash = createHash(\"sha256\");\n\thash.update(data);\n\treturn hash.digest(\"hex\");\n}\n","import { WhopServerSdk } from \"@whop/api\";\nimport { config } from \"dotenv\";\n\nconfig({\n\tpath: [\".env\", \".env.local\", \".env.development\", \".env.production\"],\n});\n\nfunction env(key: string) {\n\tconst value = process.env[key];\n\tif (!value) {\n\t\tthrow new Error(`Missing environment variable: ${key}`);\n\t}\n\treturn value;\n}\n\nexport const AGENT_USER_ID = env(\"NEXT_PUBLIC_WHOP_AGENT_USER_ID\");\nexport const COMPANY_ID = env(\"NEXT_PUBLIC_WHOP_COMPANY_ID\");\nexport const APP_ID = env(\"NEXT_PUBLIC_WHOP_APP_ID\");\n\nexport const whopSdk: WhopServerSdk = WhopServerSdk({\n\tappApiKey: env(\"WHOP_API_KEY\"),\n\tappId: APP_ID,\n\tcompanyId: COMPANY_ID,\n\tonBehalfOfUserId: AGENT_USER_ID,\n});\n","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,oBAAoB,MAAc;AAChD,QAAM,iBAAiBC,MAAK,KAAK,MAAM,OAAO;AAC9C,MAAIC,YAAW,cAAc,GAAG;AAC/B,UAAM,OAAO,cAAc;AAAA,EAC5B;AACA,UAAQ,IAAI,uCAA6B;AAC1C;AAEA,eAAe,0BAA0B;AACxC,QAAM,OAAO,MAAMC,QAAO,gBAAgB,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC;AAChE,MAAI,CAAC,MAAM;AACV,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AACA,QAAM,OAAOF,MAAK,QAAQ,IAAI;AAC9B,SAAO;AACR;AAEA,KAAK,EACH,MAAM,CAAC,QAAQ;AACf,UAAQ,MAAM,GAAG;AACjB,UAAQ,KAAK,CAAC;AACf,CAAC,EACA,KAAK,MAAM;AACX,UAAQ,KAAK,CAAC;AACf,CAAC;","names":["existsSync","path","findUp","path","existsSync","findUp"]}
|
|
1
|
+
{"version":3,"sources":["../../src/cli/index.ts","../../src/cli/mobile.ts","../../src/cli/file.ts","../../src/cli/sdk.ts","../../src/cli/valid-view-type.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { parseArgs } from \"node:util\";\nimport { findUp } from \"find-up\";\nimport { rimraf } from \"rimraf\";\nimport { buildAndPublish } from \"./mobile\";\n\nasync function main() {\n\tconst args = parseArgs({\n\t\toptions: {\n\t\t\tios: {\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\tandroid: {\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\tweb: {\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t},\n\t\tstrict: true,\n\t\tallowPositionals: true,\n\t\targs: process.argv.slice(2),\n\t});\n\n\tconst [command] = args.positionals;\n\n\tlet shouldBuild = true;\n\tlet shouldUpload = true;\n\tlet shouldClean = true;\n\tif (command === \"build\") {\n\t\tshouldUpload = false;\n\t} else if (command === \"ship\") {\n\t\tshouldBuild = true;\n\t\tshouldUpload = true;\n\t} else if (command === \"upload\") {\n\t\tshouldBuild = false;\n\t\tshouldClean = false;\n\t} else if (command === \"clean\") {\n\t\tshouldBuild = false;\n\t\tshouldUpload = false;\n\t} else {\n\t\tconsole.error(\n\t\t\t`Usage:\n\twhop-react-native ship [--ios] [--android] [--web] # runs build and then publishes it as a dev build to whop.\n\twhop-react-native build [--ios] [--android] [--web] # builds your app into a distributable bundle in the build/ directory.\n\twhop-react-native upload [--ios] [--android] [--web] # uploads the existing build directory to whop.\n\twhop-react-native clean # cleans the build directory.`,\n\t\t);\n\t\tprocess.exit(1);\n\t}\n\n\tconst root = await getRootProjectDirectory();\n\n\tif (shouldClean) {\n\t\tawait cleanBuildDirectory(root);\n\t}\n\n\tconst didProvidePlatform =\n\t\targs.values.ios || args.values.android || args.values.web;\n\n\tconst opts = { shouldBuild, shouldUpload };\n\tconst promises: Promise<void>[] = [];\n\n\tif (args.values.ios || !didProvidePlatform) {\n\t\tpromises.push(buildAndPublish(root, \"ios\", opts));\n\t}\n\tif (args.values.android || !didProvidePlatform) {\n\t\tpromises.push(buildAndPublish(root, \"android\", opts));\n\t}\n\tif (args.values.web || !didProvidePlatform) {\n\t\tconsole.warn(\" - [web] builds for web are not supported yet - coming soon\");\n\t}\n\n\tawait Promise.all(promises);\n}\n\nasync function cleanBuildDirectory(root: string) {\n\tconst buildDirectory = path.join(root, \"build\");\n\tif (existsSync(buildDirectory)) {\n\t\tawait rimraf(buildDirectory);\n\t}\n\tconsole.log(\" ✔︎ cleaned build directory\");\n}\n\nasync function getRootProjectDirectory() {\n\tconst file = await findUp(\"package.json\", { cwd: process.cwd() });\n\tif (!file) {\n\t\tthrow new Error(\n\t\t\t\"please run this command inside a whop react native project\",\n\t\t);\n\t}\n\tconst root = path.dirname(file);\n\treturn root;\n}\n\nmain()\n\t.catch((err) => {\n\t\tconsole.error(err);\n\t\tprocess.exit(1);\n\t})\n\t.then(() => {\n\t\tprocess.exit(0);\n\t});\n","import { existsSync, readFileSync, readdirSync, statSync } from \"node:fs\";\nimport { mkdir, readdir, rename, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { getDefaultConfig } from \"@react-native/metro-config\";\nimport { findUp } from \"find-up\";\nimport JSZip from \"jszip\";\nimport { type ReportableEvent, type Reporter, runBuild } from \"metro\";\nimport { getChecksum, uploadFile } from \"./file\";\nimport { APP_ID, COMPANY_ID, whopSdk } from \"./sdk\";\nimport { VALID_VIEW_TYPES } from \"./valid-view-type\";\n\nexport async function buildAndPublish(\n\troot: string,\n\tplatform: \"ios\" | \"android\",\n\t{\n\t\tshouldBuild = true,\n\t\tshouldUpload = true,\n\t}: { shouldBuild: boolean; shouldUpload: boolean } = {\n\t\tshouldBuild: true,\n\t\tshouldUpload: true,\n\t},\n) {\n\tif (shouldBuild) {\n\t\tawait bundle(root, platform);\n\t}\n\tif (shouldUpload) {\n\t\tawait createMobileBuild(root, platform);\n\t}\n}\n\nexport async function bundle(root: string, platform: \"ios\" | \"android\") {\n\tawait makeEntrypoint(root, platform);\n\n\tconst outputFile = path.join(\n\t\troot,\n\t\t\"build\",\n\t\t\"output\",\n\t\tplatform,\n\t\t\"main_js_bundle\",\n\t);\n\tawait mkdir(path.dirname(outputFile), { recursive: true });\n\n\tconst defaultConfig = getDefaultConfig(root);\n\n\tconst babelLocation = require.resolve(\"@babel/runtime/package\");\n\n\tconst bableNodeModules = await findUp(\"node_modules\", {\n\t\tcwd: babelLocation,\n\t\ttype: \"directory\",\n\t});\n\tif (!bableNodeModules) {\n\t\tthrow new Error(\"babel node_modules parent folder not found\");\n\t}\n\n\tawait runBuild(\n\t\t{\n\t\t\t...defaultConfig,\n\t\t\tprojectRoot: root,\n\t\t\ttransformer: {\n\t\t\t\t...defaultConfig.transformer,\n\t\t\t\tbabelTransformerPath: require.resolve(\n\t\t\t\t\t\"./whop-react-native-babel-transformer.js\",\n\t\t\t\t),\n\t\t\t},\n\t\t\twatchFolders: [\n\t\t\t\troot,\n\t\t\t\tpath.resolve(root, \"node_modules\"),\n\t\t\t\tbableNodeModules,\n\t\t\t],\n\t\t\treporter: new CustomReporter(),\n\t\t\tresolver: {\n\t\t\t\t...defaultConfig.resolver,\n\t\t\t\tnodeModulesPaths: [\n\t\t\t\t\t...(defaultConfig.resolver?.nodeModulesPaths ?? []),\n\t\t\t\t\tbableNodeModules,\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tdev: false,\n\t\t\tentry: `build/entrypoints/${platform}/index.js`,\n\t\t\tminify: false,\n\t\t\tplatform: platform,\n\t\t\tsourceMap: false,\n\t\t\tout: outputFile,\n\t\t},\n\t);\n\n\tawait rename(\n\t\t`${outputFile}.js`,\n\t\tpath.join(root, \"build\", \"output\", platform, \"main_js_bundle.hbc\"),\n\t);\n\n\tconsole.log(` ✔︎ [${platform}] bundle created`);\n}\n\nasync function getSupportedAppViewTypes(\n\troot: string,\n): Promise<(typeof VALID_VIEW_TYPES)[number][]> {\n\tconst views = await readdir(path.join(root, \"src\", \"views\"), {\n\t\twithFileTypes: true,\n\t\trecursive: false,\n\t});\n\tconst files = views\n\t\t.filter((file) => file.isFile())\n\t\t.map((file) => file.name.split(\".\")[0])\n\t\t.filter((file) => !!file);\n\n\tconst validViews = files.filter((file) =>\n\t\tVALID_VIEW_TYPES.includes(file as (typeof VALID_VIEW_TYPES)[number]),\n\t) as (typeof VALID_VIEW_TYPES)[number][];\n\n\tif (validViews.length === 0) {\n\t\tthrow new Error(\n\t\t\t`No valid views found, please create a view in the src/views folder and name it with a valid view type: ${VALID_VIEW_TYPES.join(\", \")}`,\n\t\t);\n\t}\n\n\treturn validViews;\n}\n\nasync function makeEntrypoint(\n\troot: string,\n\tplatform: \"ios\" | \"android\",\n): Promise<string> {\n\tconst entrypoint = path.join(\n\t\troot,\n\t\t\"build\",\n\t\t\"entrypoints\",\n\t\tplatform,\n\t\t\"index.js\",\n\t);\n\n\tconst files = await getSupportedAppViewTypes(root);\n\n\tconst pascalCase = (str: string) =>\n\t\tstr\n\t\t\t.split(\"-\")\n\t\t\t.map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n\t\t\t.join(\"\");\n\n\tconst imports = files.map(\n\t\t(file) =>\n\t\t\t`import { ${pascalCase(file)} } from \"../../../src/views/${file}\";`,\n\t);\n\tconst registry = files.map(\n\t\t(file) =>\n\t\t\t`AppRegistry.registerComponent(\"${pascalCase(file)}\", () => ${pascalCase(file)});`,\n\t);\n\n\tconst entrypointContent = `import { AppRegistry } from \"react-native\";\n${imports.join(\"\\n\")}\n\n${registry.join(\"\\n\")}\n`;\n\n\tconst entrypointDir = path.dirname(entrypoint);\n\tawait mkdir(entrypointDir, { recursive: true });\n\tawait writeFile(entrypoint, entrypointContent, \"utf-8\");\n\n\tconsole.log(` ✔︎ [${platform}] entrypoint created`);\n\n\treturn entrypoint;\n}\n\nexport async function createMobileBuild(\n\troot: string,\n\tplatform: \"ios\" | \"android\",\n) {\n\tconst viewTypes = await getSupportedAppViewTypes(root);\n\n\tconst fullDirectory = path.join(root, \"build\", \"output\", platform);\n\n\t// Check if the directory contains a file called `main_js_bundle.hbc`\n\tconst mainJsBundle = path.join(fullDirectory, \"main_js_bundle.hbc\");\n\n\tif (!existsSync(mainJsBundle)) {\n\t\tthrow new Error(`main_js_bundle.hbc not found in ${fullDirectory}`);\n\t}\n\n\t// check that that folder only contains the main_js_bundle.hbc file and an optional `assets` folder\n\tconst files = readdirSync(fullDirectory);\n\tif (\n\t\tfiles.length > 2 ||\n\t\tfiles.length < 1 ||\n\t\t!files.includes(\"main_js_bundle.hbc\")\n\t) {\n\t\tthrow new Error(\n\t\t\t\"Directory must contain only the main_js_bundle.hbc file and an optional `assets` folder\",\n\t\t);\n\t}\n\tif (files.length === 2 && !files.includes(\"assets\")) {\n\t\tthrow new Error(\n\t\t\t\"Directory must contain only the main_js_bundle.hbc file and an optional `assets` folder\",\n\t\t);\n\t}\n\n\t// Zip the directory\n\tconst zipData = await zipDirectory(fullDirectory);\n\n\tconst checksum = await getChecksum(zipData);\n\n\tconsole.log(` ✔︎ [${platform}] build zipped with checksum: ${checksum}`);\n\n\tconst fileName = `app_build_${platform}.zip`;\n\tconst uploadedFile = await uploadFile(zipData, fileName, \"application/zip\");\n\n\tconsole.log(\n\t\t` ✔︎ [${platform}] uploaded build: ${fileName} (${(zipData.length / 1024).toFixed(0)} KB)`,\n\t);\n\n\tconst build = await whopSdk.apps.createAppBuild({\n\t\tattachment: { directUploadId: uploadedFile.directUploadId },\n\t\tchecksum,\n\t\tplatform,\n\t\tsupportedAppViewTypes: viewTypes.map(\n\t\t\t(view) =>\n\t\t\t\t({\n\t\t\t\t\t\"experience-view\": \"hub\" as const,\n\t\t\t\t\t\"discover-view\": \"discover\" as const,\n\t\t\t\t})[view],\n\t\t),\n\t});\n\n\tif (!build) {\n\t\tthrow new Error(\"Failed to create app build\");\n\t}\n\n\tconst dashboardUrl = `https://whop.com/dashboard/${COMPANY_ID}/developer/apps/${APP_ID}/builds/`;\n\n\tconsole.log(`\\n ✔︎ [${platform}] deployed as development build ✔︎\n - build id: ${build.id}\n - view types: ${viewTypes.join(\", \")}\n - promote to production here: ${dashboardUrl}\\n`);\n\n\treturn build;\n}\n\nasync function zipDirectory(\n\tdirectory: string,\n): Promise<Buffer<ArrayBufferLike>> {\n\tconst zip = new JSZip();\n\n\t// Recursively add files to zip\n\tfunction addFilesToZip(currentPath: string, relativePath = \"\") {\n\t\tconst items = readdirSync(currentPath);\n\n\t\tfor (const item of items) {\n\t\t\tconst fullPath = path.join(currentPath, item);\n\t\t\tconst zipPath = relativePath ? path.join(relativePath, item) : item;\n\t\t\tconst stats = statSync(fullPath);\n\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\taddFilesToZip(fullPath, zipPath);\n\t\t\t} else {\n\t\t\t\tconst fileContent = readFileSync(fullPath);\n\t\t\t\tzip.file(zipPath, fileContent);\n\t\t\t}\n\t\t}\n\t}\n\n\taddFilesToZip(directory);\n\n\t// Generate zip file\n\tconst zipData = await zip.generateAsync({ type: \"nodebuffer\" });\n\n\treturn zipData;\n}\n\nclass CustomReporter implements Reporter {\n\tupdate(event: ReportableEvent) {\n\t\t// Do nothing.\n\t}\n}\n","import { createHash } from \"node:crypto\";\nimport { AGENT_USER_ID, APP_ID, whopSdk } from \"./sdk\";\n\nexport async function uploadFile(\n\tdata: Buffer<ArrayBufferLike>,\n\tname: string,\n\tcontentType: string,\n) {\n\tconst file = new File([data], name, {\n\t\ttype: contentType,\n\t});\n\n\tconst uploadedFile = await whopSdk\n\t\t.withUser(AGENT_USER_ID)\n\t\t.attachments.uploadAttachment({\n\t\t\tfile,\n\t\t\trecord: \"app\",\n\t\t\tid: APP_ID,\n\t\t});\n\n\treturn uploadedFile;\n}\n\nexport async function getChecksum(data: Buffer<ArrayBufferLike>) {\n\tconst hash = createHash(\"sha256\");\n\thash.update(data);\n\treturn hash.digest(\"hex\");\n}\n","import { WhopServerSdk } from \"@whop/api\";\nimport { config } from \"dotenv\";\n\nconfig({\n\tpath: [\".env\", \".env.local\", \".env.development\", \".env.production\"],\n});\n\nfunction env(key: string) {\n\tconst value = process.env[key];\n\tif (!value) {\n\t\tthrow new Error(`Missing environment variable: ${key}`);\n\t}\n\treturn value;\n}\n\nexport const AGENT_USER_ID = env(\"NEXT_PUBLIC_WHOP_AGENT_USER_ID\");\nexport const COMPANY_ID = env(\"NEXT_PUBLIC_WHOP_COMPANY_ID\");\nexport const APP_ID = env(\"NEXT_PUBLIC_WHOP_APP_ID\");\n\nexport const whopSdk: WhopServerSdk = WhopServerSdk({\n\tappApiKey: env(\"WHOP_API_KEY\"),\n\tappId: APP_ID,\n\tcompanyId: COMPANY_ID,\n\tonBehalfOfUserId: AGENT_USER_ID,\n});\n","export const VALID_VIEW_TYPES = [\"experience-view\", \"discover-view\"] as const;\n"],"mappings":";;;;;;AAAA,SAAS,cAAAA,mBAAkB;AAC3B,OAAOC,WAAU;AACjB,SAAS,iBAAiB;AAC1B,SAAS,UAAAC,eAAc;AACvB,SAAS,cA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,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,KAAK,EACH,MAAM,CAAC,QAAQ;AACf,UAAQ,MAAM,GAAG;AACjB,UAAQ,KAAK,CAAC;AACf,CAAC,EACA,KAAK,MAAM;AACX,UAAQ,KAAK,CAAC;AACf,CAAC;","names":["existsSync","path","findUp","path","existsSync","findUp"]}
|
package/dist/lib/index.d.mts
CHANGED
|
@@ -41,6 +41,13 @@ interface ExecSyncApi {
|
|
|
41
41
|
routerPresentSheet(params: PathParams): EmptyObject;
|
|
42
42
|
routerDismissSheet(params: EmptyObject): EmptyObject;
|
|
43
43
|
routerGetCurrentSheet(params: EmptyObject): PathParams | null | undefined;
|
|
44
|
+
downgradeToWebView(params: EmptyObject): EmptyObject;
|
|
45
|
+
getHostAppDetails(params: EmptyObject): {
|
|
46
|
+
build: string;
|
|
47
|
+
version: string;
|
|
48
|
+
platform: "ios" | "android" | "web";
|
|
49
|
+
buildType: "appstore" | "testflight" | "debug";
|
|
50
|
+
};
|
|
44
51
|
}
|
|
45
52
|
interface ExecAsyncApi extends ExecSyncApi {
|
|
46
53
|
}
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -41,6 +41,13 @@ interface ExecSyncApi {
|
|
|
41
41
|
routerPresentSheet(params: PathParams): EmptyObject;
|
|
42
42
|
routerDismissSheet(params: EmptyObject): EmptyObject;
|
|
43
43
|
routerGetCurrentSheet(params: EmptyObject): PathParams | null | undefined;
|
|
44
|
+
downgradeToWebView(params: EmptyObject): EmptyObject;
|
|
45
|
+
getHostAppDetails(params: EmptyObject): {
|
|
46
|
+
build: string;
|
|
47
|
+
version: string;
|
|
48
|
+
platform: "ios" | "android" | "web";
|
|
49
|
+
buildType: "appstore" | "testflight" | "debug";
|
|
50
|
+
};
|
|
44
51
|
}
|
|
45
52
|
interface ExecAsyncApi extends ExecSyncApi {
|
|
46
53
|
}
|
package/dist/lib/index.js
CHANGED
package/dist/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/index.ts","../../src/lib/client-sdk.ts","../../src/lib/native-whop-core.ts","../../src/lib/native-whop-core-wrapper.ts"],"sourcesContent":["export * from \"./client-sdk\";\nexport * from \"./native-whop-core-wrapper\";\nexport * from \"./props\";\n","import { WhopClientSdk } from \"@whop/api\";\nimport { Platform } from \"react-native\";\nimport { __internal_execSync } from \"./native-whop-core-wrapper\";\n\nfunction getAppOrigin() {\n\tif (Platform.OS === \"android\" || Platform.OS === \"ios\") {\n\t\treturn __internal_execSync(\"getAppApiOrigin\", {}).apiOrigin;\n\t}\n\n\tif (Platform.OS === \"web\" && typeof window !== \"undefined\") {\n\t\treturn window.location.origin;\n\t}\n\n\tthrow new Error(`Unsupported platform: ${Platform.OS}`);\n}\n\nconst appOrigin = getAppOrigin();\n\nexport const whopSdk: WhopClientSdk = WhopClientSdk({\n\tapiOrigin: appOrigin,\n\tapiPath: \"/_whop/public-graphql/\",\n});\n\nexport * from \"@whop/api\";\n","import type { TurboModule } from \"react-native\";\nimport { TurboModuleRegistry } from \"react-native\";\n\nexport type FunctionCallResult = {\n\tisOk: boolean;\n\tdata: string | null;\n\terrorMessage: string | null;\n};\n\nexport interface Spec extends TurboModule {\n\texecSync(name: string, paramsJson: string): FunctionCallResult;\n\texecAsync(name: string, paramsJson: string): Promise<FunctionCallResult>;\n}\n\nexport default TurboModuleRegistry.getEnforcing<Spec>(\"NativeWhopCore\");\n","import nativeWhopCore from \"./native-whop-core\";\nimport type { PathParams } from \"./props\";\n\n// biome-ignore lint/complexity/noBannedTypes: allow here\ntype EmptyObject = {};\n\nexport interface ExecSyncApi {\n\tgetAppApiOrigin(params: EmptyObject): { apiOrigin: string };\n\tcacheGet(params: { key?: string | null }): { data?: string | null };\n\tcacheSet(params: { key?: string | null; data?: string | null }): EmptyObject;\n\trouterPush(params: PathParams): EmptyObject;\n\trouterPop(params: EmptyObject): EmptyObject;\n\trouterGetCurrent(params: EmptyObject): PathParams;\n\tsetNavigationBarData(params: {\n\t\ttitle?: string | null;\n\t\tdescription?: string | null;\n\t}): EmptyObject;\n\trouterPresentSheet(params: PathParams): EmptyObject;\n\trouterDismissSheet(params: EmptyObject): EmptyObject;\n\trouterGetCurrentSheet(params: EmptyObject): PathParams | null | undefined;\n}\n\nexport interface ExecAsyncApi extends ExecSyncApi {}\n\nexport function __internal_execSync<F extends keyof ExecSyncApi>(\n\tname: F,\n\tparams: Parameters<ExecSyncApi[F]>[0],\n): ReturnType<ExecSyncApi[F]> {\n\tconst resultJson = nativeWhopCore.execSync(name, JSON.stringify(params));\n\tif (!resultJson.isOk) {\n\t\tthrow new Error(`Failed to execute ${name}: ${resultJson.errorMessage}`);\n\t}\n\n\treturn JSON.parse(resultJson.data || \"{}\") as ReturnType<ExecSyncApi[F]>;\n}\n\nexport async function __internal_execAsync<F extends keyof ExecAsyncApi>(\n\tname: F,\n\tparams: Parameters<ExecAsyncApi[F]>[0],\n): Promise<ReturnType<ExecAsyncApi[F]>> {\n\tconst resultJson = await nativeWhopCore.execAsync(\n\t\tname,\n\t\tJSON.stringify(params),\n\t);\n\n\tif (!resultJson.isOk) {\n\t\tthrow new Error(`Failed to execute ${name}: ${resultJson.errorMessage}`);\n\t}\n\n\treturn JSON.parse(resultJson.data || \"{}\") as ReturnType<ExecAsyncApi[F]>;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/lib/index.ts","../../src/lib/client-sdk.ts","../../src/lib/native-whop-core.ts","../../src/lib/native-whop-core-wrapper.ts"],"sourcesContent":["export * from \"./client-sdk\";\nexport * from \"./native-whop-core-wrapper\";\nexport * from \"./props\";\n","import { WhopClientSdk } from \"@whop/api\";\nimport { Platform } from \"react-native\";\nimport { __internal_execSync } from \"./native-whop-core-wrapper\";\n\nfunction getAppOrigin() {\n\tif (Platform.OS === \"android\" || Platform.OS === \"ios\") {\n\t\treturn __internal_execSync(\"getAppApiOrigin\", {}).apiOrigin;\n\t}\n\n\tif (Platform.OS === \"web\" && typeof window !== \"undefined\") {\n\t\treturn window.location.origin;\n\t}\n\n\tthrow new Error(`Unsupported platform: ${Platform.OS}`);\n}\n\nconst appOrigin = getAppOrigin();\n\nexport const whopSdk: WhopClientSdk = WhopClientSdk({\n\tapiOrigin: appOrigin,\n\tapiPath: \"/_whop/public-graphql/\",\n});\n\nexport * from \"@whop/api\";\n","import type { TurboModule } from \"react-native\";\nimport { TurboModuleRegistry } from \"react-native\";\n\nexport type FunctionCallResult = {\n\tisOk: boolean;\n\tdata: string | null;\n\terrorMessage: string | null;\n};\n\nexport interface Spec extends TurboModule {\n\texecSync(name: string, paramsJson: string): FunctionCallResult;\n\texecAsync(name: string, paramsJson: string): Promise<FunctionCallResult>;\n}\n\nexport default TurboModuleRegistry.getEnforcing<Spec>(\"NativeWhopCore\");\n","import nativeWhopCore from \"./native-whop-core\";\nimport type { PathParams } from \"./props\";\n\n// biome-ignore lint/complexity/noBannedTypes: allow here\ntype EmptyObject = {};\n\nexport interface ExecSyncApi {\n\tgetAppApiOrigin(params: EmptyObject): { apiOrigin: string };\n\tcacheGet(params: { key?: string | null }): { data?: string | null };\n\tcacheSet(params: { key?: string | null; data?: string | null }): EmptyObject;\n\trouterPush(params: PathParams): EmptyObject;\n\trouterPop(params: EmptyObject): EmptyObject;\n\trouterGetCurrent(params: EmptyObject): PathParams;\n\tsetNavigationBarData(params: {\n\t\ttitle?: string | null;\n\t\tdescription?: string | null;\n\t}): EmptyObject;\n\trouterPresentSheet(params: PathParams): EmptyObject;\n\trouterDismissSheet(params: EmptyObject): EmptyObject;\n\trouterGetCurrentSheet(params: EmptyObject): PathParams | null | undefined;\n\tdowngradeToWebView(params: EmptyObject): EmptyObject;\n\tgetHostAppDetails(params: EmptyObject): {\n\t\tbuild: string;\n\t\tversion: string;\n\t\tplatform: \"ios\" | \"android\" | \"web\";\n\t\tbuildType: \"appstore\" | \"testflight\" | \"debug\";\n\t};\n}\n\nexport interface ExecAsyncApi extends ExecSyncApi {}\n\nexport function __internal_execSync<F extends keyof ExecSyncApi>(\n\tname: F,\n\tparams: Parameters<ExecSyncApi[F]>[0],\n): ReturnType<ExecSyncApi[F]> {\n\tconst resultJson = nativeWhopCore.execSync(name, JSON.stringify(params));\n\tif (!resultJson.isOk) {\n\t\tthrow new Error(`Failed to execute ${name}: ${resultJson.errorMessage}`);\n\t}\n\n\treturn JSON.parse(resultJson.data || \"{}\") as ReturnType<ExecSyncApi[F]>;\n}\n\nexport async function __internal_execAsync<F extends keyof ExecAsyncApi>(\n\tname: F,\n\tparams: Parameters<ExecAsyncApi[F]>[0],\n): Promise<ReturnType<ExecAsyncApi[F]>> {\n\tconst resultJson = await nativeWhopCore.execAsync(\n\t\tname,\n\t\tJSON.stringify(params),\n\t);\n\n\tif (!resultJson.isOk) {\n\t\tthrow new Error(`Failed to execute ${name}: ${resultJson.errorMessage}`);\n\t}\n\n\treturn JSON.parse(resultJson.data || \"{}\") as ReturnType<ExecAsyncApi[F]>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA,iBAA8B;AAC9B,IAAAA,uBAAyB;;;ACAzB,0BAAoC;AAapC,IAAO,2BAAQ,wCAAoB,aAAmB,gBAAgB;;;ACiB/D,SAAS,oBACf,MACA,QAC6B;AAC7B,QAAM,aAAa,yBAAe,SAAS,MAAM,KAAK,UAAU,MAAM,CAAC;AACvE,MAAI,CAAC,WAAW,MAAM;AACrB,UAAM,IAAI,MAAM,qBAAqB,IAAI,KAAK,WAAW,YAAY,EAAE;AAAA,EACxE;AAEA,SAAO,KAAK,MAAM,WAAW,QAAQ,IAAI;AAC1C;AAEA,eAAsB,qBACrB,MACA,QACuC;AACvC,QAAM,aAAa,MAAM,yBAAe;AAAA,IACvC;AAAA,IACA,KAAK,UAAU,MAAM;AAAA,EACtB;AAEA,MAAI,CAAC,WAAW,MAAM;AACrB,UAAM,IAAI,MAAM,qBAAqB,IAAI,KAAK,WAAW,YAAY,EAAE;AAAA,EACxE;AAEA,SAAO,KAAK,MAAM,WAAW,QAAQ,IAAI;AAC1C;;;AFlCA,+BAAc;AAnBd,SAAS,eAAe;AACvB,MAAI,8BAAS,OAAO,aAAa,8BAAS,OAAO,OAAO;AACvD,WAAO,oBAAoB,mBAAmB,CAAC,CAAC,EAAE;AAAA,EACnD;AAEA,MAAI,8BAAS,OAAO,SAAS,OAAO,WAAW,aAAa;AAC3D,WAAO,OAAO,SAAS;AAAA,EACxB;AAEA,QAAM,IAAI,MAAM,yBAAyB,8BAAS,EAAE,EAAE;AACvD;AAEA,IAAM,YAAY,aAAa;AAExB,IAAM,cAAyB,0BAAc;AAAA,EACnD,WAAW;AAAA,EACX,SAAS;AACV,CAAC;;;ADrBD,wBAAc,oBAAd;","names":["import_react_native"]}
|
package/dist/lib/index.mjs
CHANGED
package/dist/lib/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/index.ts","../../src/lib/client-sdk.ts","../../src/lib/native-whop-core.ts","../../src/lib/native-whop-core-wrapper.ts"],"sourcesContent":["export * from \"./client-sdk\";\nexport * from \"./native-whop-core-wrapper\";\nexport * from \"./props\";\n","import { WhopClientSdk } from \"@whop/api\";\nimport { Platform } from \"react-native\";\nimport { __internal_execSync } from \"./native-whop-core-wrapper\";\n\nfunction getAppOrigin() {\n\tif (Platform.OS === \"android\" || Platform.OS === \"ios\") {\n\t\treturn __internal_execSync(\"getAppApiOrigin\", {}).apiOrigin;\n\t}\n\n\tif (Platform.OS === \"web\" && typeof window !== \"undefined\") {\n\t\treturn window.location.origin;\n\t}\n\n\tthrow new Error(`Unsupported platform: ${Platform.OS}`);\n}\n\nconst appOrigin = getAppOrigin();\n\nexport const whopSdk: WhopClientSdk = WhopClientSdk({\n\tapiOrigin: appOrigin,\n\tapiPath: \"/_whop/public-graphql/\",\n});\n\nexport * from \"@whop/api\";\n","import type { TurboModule } from \"react-native\";\nimport { TurboModuleRegistry } from \"react-native\";\n\nexport type FunctionCallResult = {\n\tisOk: boolean;\n\tdata: string | null;\n\terrorMessage: string | null;\n};\n\nexport interface Spec extends TurboModule {\n\texecSync(name: string, paramsJson: string): FunctionCallResult;\n\texecAsync(name: string, paramsJson: string): Promise<FunctionCallResult>;\n}\n\nexport default TurboModuleRegistry.getEnforcing<Spec>(\"NativeWhopCore\");\n","import nativeWhopCore from \"./native-whop-core\";\nimport type { PathParams } from \"./props\";\n\n// biome-ignore lint/complexity/noBannedTypes: allow here\ntype EmptyObject = {};\n\nexport interface ExecSyncApi {\n\tgetAppApiOrigin(params: EmptyObject): { apiOrigin: string };\n\tcacheGet(params: { key?: string | null }): { data?: string | null };\n\tcacheSet(params: { key?: string | null; data?: string | null }): EmptyObject;\n\trouterPush(params: PathParams): EmptyObject;\n\trouterPop(params: EmptyObject): EmptyObject;\n\trouterGetCurrent(params: EmptyObject): PathParams;\n\tsetNavigationBarData(params: {\n\t\ttitle?: string | null;\n\t\tdescription?: string | null;\n\t}): EmptyObject;\n\trouterPresentSheet(params: PathParams): EmptyObject;\n\trouterDismissSheet(params: EmptyObject): EmptyObject;\n\trouterGetCurrentSheet(params: EmptyObject): PathParams | null | undefined;\n}\n\nexport interface ExecAsyncApi extends ExecSyncApi {}\n\nexport function __internal_execSync<F extends keyof ExecSyncApi>(\n\tname: F,\n\tparams: Parameters<ExecSyncApi[F]>[0],\n): ReturnType<ExecSyncApi[F]> {\n\tconst resultJson = nativeWhopCore.execSync(name, JSON.stringify(params));\n\tif (!resultJson.isOk) {\n\t\tthrow new Error(`Failed to execute ${name}: ${resultJson.errorMessage}`);\n\t}\n\n\treturn JSON.parse(resultJson.data || \"{}\") as ReturnType<ExecSyncApi[F]>;\n}\n\nexport async function __internal_execAsync<F extends keyof ExecAsyncApi>(\n\tname: F,\n\tparams: Parameters<ExecAsyncApi[F]>[0],\n): Promise<ReturnType<ExecAsyncApi[F]>> {\n\tconst resultJson = await nativeWhopCore.execAsync(\n\t\tname,\n\t\tJSON.stringify(params),\n\t);\n\n\tif (!resultJson.isOk) {\n\t\tthrow new Error(`Failed to execute ${name}: ${resultJson.errorMessage}`);\n\t}\n\n\treturn JSON.parse(resultJson.data || \"{}\") as ReturnType<ExecAsyncApi[F]>;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/lib/index.ts","../../src/lib/client-sdk.ts","../../src/lib/native-whop-core.ts","../../src/lib/native-whop-core-wrapper.ts"],"sourcesContent":["export * from \"./client-sdk\";\nexport * from \"./native-whop-core-wrapper\";\nexport * from \"./props\";\n","import { WhopClientSdk } from \"@whop/api\";\nimport { Platform } from \"react-native\";\nimport { __internal_execSync } from \"./native-whop-core-wrapper\";\n\nfunction getAppOrigin() {\n\tif (Platform.OS === \"android\" || Platform.OS === \"ios\") {\n\t\treturn __internal_execSync(\"getAppApiOrigin\", {}).apiOrigin;\n\t}\n\n\tif (Platform.OS === \"web\" && typeof window !== \"undefined\") {\n\t\treturn window.location.origin;\n\t}\n\n\tthrow new Error(`Unsupported platform: ${Platform.OS}`);\n}\n\nconst appOrigin = getAppOrigin();\n\nexport const whopSdk: WhopClientSdk = WhopClientSdk({\n\tapiOrigin: appOrigin,\n\tapiPath: \"/_whop/public-graphql/\",\n});\n\nexport * from \"@whop/api\";\n","import type { TurboModule } from \"react-native\";\nimport { TurboModuleRegistry } from \"react-native\";\n\nexport type FunctionCallResult = {\n\tisOk: boolean;\n\tdata: string | null;\n\terrorMessage: string | null;\n};\n\nexport interface Spec extends TurboModule {\n\texecSync(name: string, paramsJson: string): FunctionCallResult;\n\texecAsync(name: string, paramsJson: string): Promise<FunctionCallResult>;\n}\n\nexport default TurboModuleRegistry.getEnforcing<Spec>(\"NativeWhopCore\");\n","import nativeWhopCore from \"./native-whop-core\";\nimport type { PathParams } from \"./props\";\n\n// biome-ignore lint/complexity/noBannedTypes: allow here\ntype EmptyObject = {};\n\nexport interface ExecSyncApi {\n\tgetAppApiOrigin(params: EmptyObject): { apiOrigin: string };\n\tcacheGet(params: { key?: string | null }): { data?: string | null };\n\tcacheSet(params: { key?: string | null; data?: string | null }): EmptyObject;\n\trouterPush(params: PathParams): EmptyObject;\n\trouterPop(params: EmptyObject): EmptyObject;\n\trouterGetCurrent(params: EmptyObject): PathParams;\n\tsetNavigationBarData(params: {\n\t\ttitle?: string | null;\n\t\tdescription?: string | null;\n\t}): EmptyObject;\n\trouterPresentSheet(params: PathParams): EmptyObject;\n\trouterDismissSheet(params: EmptyObject): EmptyObject;\n\trouterGetCurrentSheet(params: EmptyObject): PathParams | null | undefined;\n\tdowngradeToWebView(params: EmptyObject): EmptyObject;\n\tgetHostAppDetails(params: EmptyObject): {\n\t\tbuild: string;\n\t\tversion: string;\n\t\tplatform: \"ios\" | \"android\" | \"web\";\n\t\tbuildType: \"appstore\" | \"testflight\" | \"debug\";\n\t};\n}\n\nexport interface ExecAsyncApi extends ExecSyncApi {}\n\nexport function __internal_execSync<F extends keyof ExecSyncApi>(\n\tname: F,\n\tparams: Parameters<ExecSyncApi[F]>[0],\n): ReturnType<ExecSyncApi[F]> {\n\tconst resultJson = nativeWhopCore.execSync(name, JSON.stringify(params));\n\tif (!resultJson.isOk) {\n\t\tthrow new Error(`Failed to execute ${name}: ${resultJson.errorMessage}`);\n\t}\n\n\treturn JSON.parse(resultJson.data || \"{}\") as ReturnType<ExecSyncApi[F]>;\n}\n\nexport async function __internal_execAsync<F extends keyof ExecAsyncApi>(\n\tname: F,\n\tparams: Parameters<ExecAsyncApi[F]>[0],\n): Promise<ReturnType<ExecAsyncApi[F]>> {\n\tconst resultJson = await nativeWhopCore.execAsync(\n\t\tname,\n\t\tJSON.stringify(params),\n\t);\n\n\tif (!resultJson.isOk) {\n\t\tthrow new Error(`Failed to execute ${name}: ${resultJson.errorMessage}`);\n\t}\n\n\treturn JSON.parse(resultJson.data || \"{}\") as ReturnType<ExecAsyncApi[F]>;\n}\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;;;ACAzB,SAAS,2BAA2B;AAapC,IAAO,2BAAQ,oBAAoB,aAAmB,gBAAgB;;;ACiB/D,SAAS,oBACf,MACA,QAC6B;AAC7B,QAAM,aAAa,yBAAe,SAAS,MAAM,KAAK,UAAU,MAAM,CAAC;AACvE,MAAI,CAAC,WAAW,MAAM;AACrB,UAAM,IAAI,MAAM,qBAAqB,IAAI,KAAK,WAAW,YAAY,EAAE;AAAA,EACxE;AAEA,SAAO,KAAK,MAAM,WAAW,QAAQ,IAAI;AAC1C;AAEA,eAAsB,qBACrB,MACA,QACuC;AACvC,QAAM,aAAa,MAAM,yBAAe;AAAA,IACvC;AAAA,IACA,KAAK,UAAU,MAAM;AAAA,EACtB;AAEA,MAAI,CAAC,WAAW,MAAM;AACrB,UAAM,IAAI,MAAM,qBAAqB,IAAI,KAAK,WAAW,YAAY,EAAE;AAAA,EACxE;AAEA,SAAO,KAAK,MAAM,WAAW,QAAQ,IAAI;AAC1C;;;AFlCA;AAAA,0BAAc;AAnBd,SAAS,eAAe;AACvB,MAAI,SAAS,OAAO,aAAa,SAAS,OAAO,OAAO;AACvD,WAAO,oBAAoB,mBAAmB,CAAC,CAAC,EAAE;AAAA,EACnD;AAEA,MAAI,SAAS,OAAO,SAAS,OAAO,WAAW,aAAa;AAC3D,WAAO,OAAO,SAAS;AAAA,EACxB;AAEA,QAAM,IAAI,MAAM,yBAAyB,SAAS,EAAE,EAAE;AACvD;AAEA,IAAM,YAAY,aAAa;AAExB,IAAM,UAAyB,cAAc;AAAA,EACnD,WAAW;AAAA,EACX,SAAS;AACV,CAAC;;;ADrBD,wBAAc;","names":[]}
|
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.0.
|
|
4
|
+
"version": "0.0.8",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/whopio/whop-sdk-ts",
|
|
@@ -48,13 +48,14 @@
|
|
|
48
48
|
"metro": "^0.83.0",
|
|
49
49
|
"metro-react-native-babel-transformer": "^0.77.0",
|
|
50
50
|
"rimraf": "^6.0.1",
|
|
51
|
-
"@whop/api": "0.0.
|
|
51
|
+
"@whop/api": "0.0.40"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/node": "latest",
|
|
55
55
|
"@types/react": "19.1.5",
|
|
56
56
|
"react": "^19.0.0",
|
|
57
57
|
"react-native": "0.80.0",
|
|
58
|
+
"react-native-reanimated": "3.18.0",
|
|
58
59
|
"tsup": "8.5.0",
|
|
59
60
|
"typescript": "latest"
|
|
60
61
|
},
|
|
@@ -67,7 +68,8 @@
|
|
|
67
68
|
},
|
|
68
69
|
"peerDependencies": {
|
|
69
70
|
"react": "^19.0.0",
|
|
70
|
-
"react-native": "0.80.0"
|
|
71
|
+
"react-native": "0.80.0",
|
|
72
|
+
"react-native-reanimated": "3.18.0"
|
|
71
73
|
},
|
|
72
74
|
"scripts": {
|
|
73
75
|
"build": "pnpm run clean && tsup && cp src/cli/*.js dist/cli",
|
|
File without changes
|