one
Version:
One is a React framework for web, iOS, and Android apps.
1 lines • 4.26 kB
Source Map (JSON)
{"version":3,"file":"prebuild.js","names":[],"sources":["esm/cli/prebuild.js"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { validateNativeApp } from \"../native/appManifest\";\nimport { loadUserOneOptions } from \"../vite/loadConfig\";\nconst REACT_NATIVE_CONFIG = `module.exports = require('one/react-native-config')\n`;\nconst REACT_NATIVE_CONFIG_NAMES = [\n \"react-native.config.js\",\n \"react-native.config.cjs\",\n \"react-native.config.mjs\",\n \"react-native.config.ts\"\n];\nasync function run(args) {\n const root = process.cwd();\n const packageJson = JSON.parse(readFileSync(join(root, \"package.json\"), \"utf8\"));\n const hasExpo = Object.hasOwn(packageJson.dependencies ?? {}, \"expo\") || Object.hasOwn(packageJson.devDependencies ?? {}, \"expo\");\n if (hasExpo) {\n throw new Error(\n '[one] one prebuild only generates Expo-free projects. This app declares expo; run Expo prebuild and list \"vxrn/expo-plugin\" in the Expo config.'\n );\n }\n const { oneOptions } = await loadUserOneOptions(\"build\", true);\n const native = oneOptions?.native;\n const app = typeof native === \"object\" ? native.app : void 0;\n if (!app) {\n throw new Error(\n \"[one] native.app is required: configure one({ native: { app } }) with name, ios.bundleId, and android.applicationId\"\n );\n }\n validateNativeApp(app, args.platform);\n if ((app.ios?.backgroundTasks || app.ios?.appIntents) && args.platform !== \"android\") {\n const configured = oneOptions?.setupFile;\n const setupFile = typeof configured === \"string\" ? configured : configured && \"native\" in configured ? configured.native : configured && \"ios\" in configured ? configured.ios : void 0;\n if (!setupFile || !existsSync(resolve(root, setupFile))) {\n throw new Error(\n app.ios?.backgroundTasks ? \"[one] native.app.ios.backgroundTasks requires an existing iOS native setupFile that defines every task handler before the app renders\" : \"[one] native.app.ios.appIntents requires an existing iOS native setupFile that defines every action handler before the app renders\"\n );\n }\n }\n const present = REACT_NATIVE_CONFIG_NAMES.filter((name) => existsSync(join(root, name)));\n if (present.length === 0) {\n writeFileSync(join(root, \"react-native.config.cjs\"), REACT_NATIVE_CONFIG);\n } else if (!present.some(\n (name) => readFileSync(join(root, name), \"utf8\").includes(\"one/react-native-config\")\n )) {\n throw new Error(\n `[one] ${present.join(\", \")} does not load one/react-native-config, so Release builds would run the stock React Native bundler instead of One's. Set it to \\`module.exports = require('one/react-native-config')\\` or spread that into your config, then re-run one prebuild.`\n );\n }\n const { prebuild } = await import(\"vxrn\");\n await prebuild({\n root: process.cwd(),\n ...args,\n app\n });\n}\nexport {\n run\n};\n//# sourceMappingURL=prebuild.js.map\n"],"mappings":";;;;;;AAIA,MAAM,sBAAsB;;AAE5B,MAAM,4BAA4B;CAChC;CACA;CACA;CACA;AACF;AACA,eAAe,IAAI,MAAM;CACvB,MAAM,OAAO,QAAQ,IAAI;CACzB,MAAM,cAAc,KAAK,MAAM,aAAa,KAAK,MAAM,cAAc,GAAG,MAAM,CAAC;CAC/E,MAAM,UAAU,OAAO,OAAO,YAAY,gBAAgB,CAAC,GAAG,MAAM,KAAK,OAAO,OAAO,YAAY,mBAAmB,CAAC,GAAG,MAAM;CAChI,IAAI,SAAS;EACX,MAAM,IAAI,MACR,mJACF;CACF;CACA,MAAM,EAAE,eAAe,MAAM,mBAAmB,SAAS,IAAI;CAC7D,MAAM,SAAS,YAAY;CAC3B,MAAM,MAAM,OAAO,WAAW,WAAW,OAAO,MAAM,KAAK;CAC3D,IAAI,CAAC,KAAK;EACR,MAAM,IAAI,MACR,qHACF;CACF;CACA,kBAAkB,KAAK,KAAK,QAAQ;CACpC,KAAK,IAAI,KAAK,mBAAmB,IAAI,KAAK,eAAe,KAAK,aAAa,WAAW;EACpF,MAAM,aAAa,YAAY;EAC/B,MAAM,YAAY,OAAO,eAAe,WAAW,aAAa,cAAc,YAAY,aAAa,WAAW,SAAS,cAAc,SAAS,aAAa,WAAW,MAAM,KAAK;EACrL,IAAI,CAAC,aAAa,CAAC,WAAW,QAAQ,MAAM,SAAS,CAAC,GAAG;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