UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

87 lines (84 loc) • 4.8 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var prebuild_exports = {}; __export(prebuild_exports, { run: () => run }); module.exports = __toCommonJS(prebuild_exports); var import_fs = require("fs"); var import_path = require("path"); var import_appManifest = require("../native/appManifest.native.js"); var import_loadConfig = require("../vite/loadConfig.native.js"); var REACT_NATIVE_CONFIG = `module.exports = require('one/react-native-config') `; var REACT_NATIVE_CONFIG_NAMES = [ "react-native.config.js", "react-native.config.cjs", "react-native.config.mjs", "react-native.config.ts" ]; async function run(args) { var _packageJson_dependencies, _packageJson_devDependencies; var _app_ios, _app_ios1; var root = process.cwd(); var packageJson = JSON.parse((0, import_fs.readFileSync)((0, import_path.join)(root, "package.json"), "utf8")); var hasExpo = Object.hasOwn((_packageJson_dependencies = packageJson.dependencies) !== null && _packageJson_dependencies !== void 0 ? _packageJson_dependencies : {}, "expo") || Object.hasOwn((_packageJson_devDependencies = packageJson.devDependencies) !== null && _packageJson_devDependencies !== void 0 ? _packageJson_devDependencies : {}, "expo"); if (hasExpo) { throw new Error("[one] one prebuild only generates Expo-free projects. This app declares expo; run Expo prebuild and list \"vxrn/expo-plugin\" in the Expo config."); } var { oneOptions } = await (0, import_loadConfig.loadUserOneOptions)("build", true); var native = oneOptions === null || oneOptions === void 0 ? void 0 : oneOptions.native; var app = typeof native === "object" ? native.app : void 0; if (!app) { throw new Error("[one] native.app is required: configure one({ native: { app } }) with name, ios.bundleId, and android.applicationId"); } (0, import_appManifest.validateNativeApp)(app, args.platform); if ((((_app_ios = app.ios) === null || _app_ios === void 0 ? void 0 : _app_ios.backgroundTasks) || ((_app_ios1 = app.ios) === null || _app_ios1 === void 0 ? void 0 : _app_ios1.appIntents)) && args.platform !== "android") { var configured = oneOptions === null || oneOptions === void 0 ? void 0 : oneOptions.setupFile; var setupFile = typeof configured === "string" ? configured : configured && "native" in configured ? configured.native : configured && "ios" in configured ? configured.ios : void 0; if (!setupFile || !(0, import_fs.existsSync)((0, import_path.resolve)(root, setupFile))) { var _app_ios2; throw new Error(((_app_ios2 = app.ios) === null || _app_ios2 === void 0 ? void 0 : _app_ios2.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"); } } var present = REACT_NATIVE_CONFIG_NAMES.filter(function(name) { return (0, import_fs.existsSync)((0, import_path.join)(root, name)); }); if (present.length === 0) { (0, import_fs.writeFileSync)((0, import_path.join)(root, "react-native.config.cjs"), REACT_NATIVE_CONFIG); } else if (!present.some(function(name) { return (0, import_fs.readFileSync)((0, import_path.join)(root, name), "utf8").includes("one/react-native-config"); })) { throw new Error(`[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.`); } var { prebuild } = await import("vxrn"); await prebuild({ root: process.cwd(), ...args, app }); } //# sourceMappingURL=prebuild.native.js.map