one 2.0.0-beta.61.1 → 2.0.0-beta.66.1

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.
@@ -31,6 +31,14 @@ var import_node_fs = require("node:fs");
31
31
  var import_node_path = require("node:path");
32
32
  var import_appManifest = require("../native/appManifest.cjs");
33
33
  var import_loadConfig = require("../vite/loadConfig.cjs");
34
+ const REACT_NATIVE_CONFIG = `module.exports = require('one/react-native-config')
35
+ `;
36
+ const REACT_NATIVE_CONFIG_NAMES = [
37
+ "react-native.config.js",
38
+ "react-native.config.cjs",
39
+ "react-native.config.mjs",
40
+ "react-native.config.ts"
41
+ ];
34
42
  async function run(args) {
35
43
  const root = process.cwd();
36
44
  const packageJson = JSON.parse((0, import_node_fs.readFileSync)((0, import_node_path.join)(root, "package.json"), "utf8"));
@@ -45,6 +53,12 @@ async function run(args) {
45
53
  throw new Error("[one] native.app is required: configure one({ native: { app } }) with name, ios.bundleId, and android.applicationId");
46
54
  }
47
55
  (0, import_appManifest.validateNativeApp)(app);
56
+ const present = REACT_NATIVE_CONFIG_NAMES.filter((name) => (0, import_node_fs.existsSync)((0, import_node_path.join)(root, name)));
57
+ if (present.length === 0) {
58
+ (0, import_node_fs.writeFileSync)((0, import_node_path.join)(root, "react-native.config.cjs"), REACT_NATIVE_CONFIG);
59
+ } else if (!present.some((name) => (0, import_node_fs.readFileSync)((0, import_node_path.join)(root, name), "utf8").includes("one/react-native-config"))) {
60
+ 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.`);
61
+ }
48
62
  const { prebuild } = await import("vxrn");
49
63
  await prebuild({
50
64
  root: process.cwd(),
@@ -33,6 +33,14 @@ var import_fs = require("fs");
33
33
  var import_path = require("path");
34
34
  var import_appManifest = require("../native/appManifest.native.js");
35
35
  var import_loadConfig = require("../vite/loadConfig.native.js");
36
+ var REACT_NATIVE_CONFIG = `module.exports = require('one/react-native-config')
37
+ `;
38
+ var REACT_NATIVE_CONFIG_NAMES = [
39
+ "react-native.config.js",
40
+ "react-native.config.cjs",
41
+ "react-native.config.mjs",
42
+ "react-native.config.ts"
43
+ ];
36
44
  async function run(args) {
37
45
  var _packageJson_dependencies, _packageJson_devDependencies;
38
46
  var root = process.cwd();
@@ -48,6 +56,16 @@ async function run(args) {
48
56
  throw new Error("[one] native.app is required: configure one({ native: { app } }) with name, ios.bundleId, and android.applicationId");
49
57
  }
50
58
  (0, import_appManifest.validateNativeApp)(app);
59
+ var present = REACT_NATIVE_CONFIG_NAMES.filter(function(name) {
60
+ return (0, import_fs.existsSync)((0, import_path.join)(root, name));
61
+ });
62
+ if (present.length === 0) {
63
+ (0, import_fs.writeFileSync)((0, import_path.join)(root, "react-native.config.cjs"), REACT_NATIVE_CONFIG);
64
+ } else if (!present.some(function(name) {
65
+ return (0, import_fs.readFileSync)((0, import_path.join)(root, name), "utf8").includes("one/react-native-config");
66
+ })) {
67
+ 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.`);
68
+ }
51
69
  var { prebuild } = await import("vxrn");
52
70
  await prebuild({
53
71
  root: process.cwd(),
@@ -33,6 +33,14 @@ var import_fs = require("fs");
33
33
  var import_path = require("path");
34
34
  var import_appManifest = require("../native/appManifest.native.js");
35
35
  var import_loadConfig = require("../vite/loadConfig.native.js");
36
+ var REACT_NATIVE_CONFIG = `module.exports = require('one/react-native-config')
37
+ `;
38
+ var REACT_NATIVE_CONFIG_NAMES = [
39
+ "react-native.config.js",
40
+ "react-native.config.cjs",
41
+ "react-native.config.mjs",
42
+ "react-native.config.ts"
43
+ ];
36
44
  async function run(args) {
37
45
  var _packageJson_dependencies, _packageJson_devDependencies;
38
46
  var root = process.cwd();
@@ -48,6 +56,16 @@ async function run(args) {
48
56
  throw new Error("[one] native.app is required: configure one({ native: { app } }) with name, ios.bundleId, and android.applicationId");
49
57
  }
50
58
  (0, import_appManifest.validateNativeApp)(app);
59
+ var present = REACT_NATIVE_CONFIG_NAMES.filter(function(name) {
60
+ return (0, import_fs.existsSync)((0, import_path.join)(root, name));
61
+ });
62
+ if (present.length === 0) {
63
+ (0, import_fs.writeFileSync)((0, import_path.join)(root, "react-native.config.cjs"), REACT_NATIVE_CONFIG);
64
+ } else if (!present.some(function(name) {
65
+ return (0, import_fs.readFileSync)((0, import_path.join)(root, name), "utf8").includes("one/react-native-config");
66
+ })) {
67
+ 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.`);
68
+ }
51
69
  var { prebuild } = await import("vxrn");
52
70
  await prebuild({
53
71
  root: process.cwd(),
@@ -1 +1 @@
1
- {"version":3,"file":"prebuild.native.js","names":[],"sources":["cjs/cli/prebuild.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar prebuild_exports = {};\n__export(prebuild_exports, {\n run: () => run\n});\nmodule.exports = __toCommonJS(prebuild_exports);\nvar import_fs = require(\"fs\");\nvar import_path = require(\"path\");\nvar import_appManifest = require(\"../native/appManifest\");\nvar import_loadConfig = require(\"../vite/loadConfig\");\nasync function run(args) {\n var _packageJson_dependencies, _packageJson_devDependencies;\n var root = process.cwd();\n var packageJson = JSON.parse((0, import_fs.readFileSync)((0, import_path.join)(root, \"package.json\"), \"utf8\"));\n 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\");\n if (hasExpo) {\n 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.');\n }\n var { oneOptions } = await (0, import_loadConfig.loadUserOneOptions)(\"build\", true);\n var native = oneOptions === null || oneOptions === void 0 ? void 0 : oneOptions.native;\n var app = typeof native === \"object\" ? native.app : void 0;\n if (!app) {\n throw new Error(\"[one] native.app is required: configure one({ native: { app } }) with name, ios.bundleId, and android.applicationId\");\n }\n (0, import_appManifest.validateNativeApp)(app);\n var { prebuild } = await import(\"vxrn\");\n await prebuild({\n root: process.cwd(),\n ...args,\n app\n });\n}\n//# sourceMappingURL=prebuild.js.map\n"],"mappings":";;;AACA,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO;AAC1B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,WAAW,KAAK,YAAY,YAAY,SAAS,OAAO,OAAO,SAAS,aAAa,GAAG,CAAC,IAAI,CAAC,GAAG,YAKnG,cAAc,CAAC,OAAO,CAAC,IAAI,aAAa,UAAU,QAAQ,WAAW;CAAE,OAAO;CAAK,YAAY;AAAK,CAAC,IAAI,QACzG,GACF;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,mBAAmB,CAAC;AACxB,SAAS,kBAAkB,EACzB,WAAW,IACb,CAAC;AACD,OAAO,UAAU,aAAa,gBAAgB;AAC9C,IAAI,YAAY,QAAQ,IAAI;AAC5B,IAAI,cAAc,QAAQ,MAAM;AAChC,IAAI,qBAAqB,QAAQ,iCAAuB;AACxD,IAAI,oBAAoB,QAAQ,8BAAoB;AACpD,eAAe,IAAI,MAAM;CACvB,IAAI,2BAA2B;CAC/B,IAAI,OAAO,QAAQ,IAAI;CACvB,IAAI,cAAc,KAAK,OAAO,GAAG,UAAU,aAAY,EAAG,GAAG,YAAY,KAAI,CAAE,MAAM,cAAc,GAAG,MAAM,CAAC;CAC7G,IAAI,UAAU,OAAO,QAAQ,4BAA4B,YAAY,kBAAkB,QAAQ,8BAA8B,KAAK,IAAI,4BAA4B,CAAC,GAAG,MAAM,KAAK,OAAO,QAAQ,+BAA+B,YAAY,qBAAqB,QAAQ,iCAAiC,KAAK,IAAI,+BAA+B,CAAC,GAAG,MAAM;CAC3V,IAAI,SAAS;EACX,MAAM,IAAI,MAAM,mJAAiJ;CACnK;CACA,IAAI,EAAE,eAAe,OAAO,GAAG,kBAAkB,mBAAkB,CAAE,SAAS,IAAI;CAClF,IAAI,SAAS,eAAe,QAAQ,eAAe,KAAK,IAAI,KAAK,IAAI,WAAW;CAChF,IAAI,MAAM,OAAO,WAAW,WAAW,OAAO,MAAM,KAAK;CACzD,IAAI,CAAC,KAAK;EACR,MAAM,IAAI,MAAM,qHAAqH;CACvI;CACA,CAAC,GAAG,mBAAmB,kBAAiB,CAAE,GAAG;CAC7C,IAAI,EAAE,aAAa,MAAM,OAAO;CAChC,MAAM,SAAS;EACb,MAAM,QAAQ,IAAI;EAClB,GAAG;EACH;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"prebuild.native.js","names":[],"sources":["cjs/cli/prebuild.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar prebuild_exports = {};\n__export(prebuild_exports, {\n run: () => run\n});\nmodule.exports = __toCommonJS(prebuild_exports);\nvar import_fs = require(\"fs\");\nvar import_path = require(\"path\");\nvar import_appManifest = require(\"../native/appManifest\");\nvar import_loadConfig = require(\"../vite/loadConfig\");\nvar REACT_NATIVE_CONFIG = `module.exports = require('one/react-native-config')\n`;\nvar 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 var _packageJson_dependencies, _packageJson_devDependencies;\n var root = process.cwd();\n var packageJson = JSON.parse((0, import_fs.readFileSync)((0, import_path.join)(root, \"package.json\"), \"utf8\"));\n 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\");\n if (hasExpo) {\n 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.');\n }\n var { oneOptions } = await (0, import_loadConfig.loadUserOneOptions)(\"build\", true);\n var native = oneOptions === null || oneOptions === void 0 ? void 0 : oneOptions.native;\n var app = typeof native === \"object\" ? native.app : void 0;\n if (!app) {\n throw new Error(\"[one] native.app is required: configure one({ native: { app } }) with name, ios.bundleId, and android.applicationId\");\n }\n (0, import_appManifest.validateNativeApp)(app);\n var present = REACT_NATIVE_CONFIG_NAMES.filter(function(name) {\n return (0, import_fs.existsSync)((0, import_path.join)(root, name));\n });\n if (present.length === 0) {\n (0, import_fs.writeFileSync)((0, import_path.join)(root, \"react-native.config.cjs\"), REACT_NATIVE_CONFIG);\n } else if (!present.some(function(name) {\n return (0, import_fs.readFileSync)((0, import_path.join)(root, name), \"utf8\").includes(\"one/react-native-config\");\n })) {\n 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.`);\n }\n var { prebuild } = await import(\"vxrn\");\n await prebuild({\n root: process.cwd(),\n ...args,\n app\n });\n}\n//# sourceMappingURL=prebuild.js.map\n"],"mappings":"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"}
@@ -1,8 +1,16 @@
1
- import { readFileSync } from "node:fs";
1
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import { validateNativeApp } from "../native/appManifest.mjs";
4
4
  import { loadUserOneOptions } from "../vite/loadConfig.mjs";
5
5
 
6
+ const REACT_NATIVE_CONFIG = `module.exports = require('one/react-native-config')
7
+ `;
8
+ const REACT_NATIVE_CONFIG_NAMES = [
9
+ "react-native.config.js",
10
+ "react-native.config.cjs",
11
+ "react-native.config.mjs",
12
+ "react-native.config.ts"
13
+ ];
6
14
  async function run(args) {
7
15
  const root = process.cwd();
8
16
  const packageJson = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
@@ -17,6 +25,12 @@ async function run(args) {
17
25
  throw new Error("[one] native.app is required: configure one({ native: { app } }) with name, ios.bundleId, and android.applicationId");
18
26
  }
19
27
  validateNativeApp(app);
28
+ const present = REACT_NATIVE_CONFIG_NAMES.filter((name) => existsSync(join(root, name)));
29
+ if (present.length === 0) {
30
+ writeFileSync(join(root, "react-native.config.cjs"), REACT_NATIVE_CONFIG);
31
+ } else if (!present.some((name) => readFileSync(join(root, name), "utf8").includes("one/react-native-config"))) {
32
+ 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.`);
33
+ }
20
34
  const { prebuild } = await import("vxrn");
21
35
  await prebuild({
22
36
  root: process.cwd(),
@@ -1 +1 @@
1
- {"version":3,"file":"prebuild.js","names":[],"sources":["esm/cli/prebuild.js"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { validateNativeApp } from \"../native/appManifest\";\nimport { loadUserOneOptions } from \"../vite/loadConfig\";\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);\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,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,GAAG;CACrB,MAAM,EAAE,aAAa,MAAM,OAAO;CAClC,MAAM,SAAS;EACb,MAAM,QAAQ,IAAI;EAClB,GAAG;EACH;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"prebuild.js","names":[],"sources":["esm/cli/prebuild.js"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { join } 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);\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,GAAG;CACrB,MAAM,UAAU,0BAA0B,QAAQ,SAAS,WAAW,KAAK,MAAM,IAAI,CAAC,CAAC;CACvF,IAAI,QAAQ,WAAW,GAAG;EACxB,cAAc,KAAK,MAAM,yBAAyB,GAAG,mBAAmB;CAC1E,OAAO,IAAI,CAAC,QAAQ,MACjB,SAAS,aAAa,KAAK,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,SAAS,yBAAyB,CACrF,GAAG;EACD,MAAM,IAAI,MACR,SAAS,QAAQ,KAAK,IAAI,EAAE,kPAC9B;CACF;CACA,MAAM,EAAE,aAAa,MAAM,OAAO;CAClC,MAAM,SAAS;EACb,MAAM,QAAQ,IAAI;EAClB,GAAG;EACH;CACF,CAAC;AACH"}
@@ -1,8 +1,16 @@
1
- import { readFileSync } from "fs";
1
+ import { existsSync, readFileSync, writeFileSync } from "fs";
2
2
  import { join } from "path";
3
3
  import { validateNativeApp } from "../native/appManifest.native.js";
4
4
  import { loadUserOneOptions } from "../vite/loadConfig.native.js";
5
5
 
6
+ var REACT_NATIVE_CONFIG = `module.exports = require('one/react-native-config')
7
+ `;
8
+ var REACT_NATIVE_CONFIG_NAMES = [
9
+ "react-native.config.js",
10
+ "react-native.config.cjs",
11
+ "react-native.config.mjs",
12
+ "react-native.config.ts"
13
+ ];
6
14
  async function run(args) {
7
15
  var _packageJson_dependencies, _packageJson_devDependencies;
8
16
  var root = process.cwd();
@@ -18,6 +26,16 @@ async function run(args) {
18
26
  throw new Error("[one] native.app is required: configure one({ native: { app } }) with name, ios.bundleId, and android.applicationId");
19
27
  }
20
28
  validateNativeApp(app);
29
+ var present = REACT_NATIVE_CONFIG_NAMES.filter(function(name) {
30
+ return existsSync(join(root, name));
31
+ });
32
+ if (present.length === 0) {
33
+ writeFileSync(join(root, "react-native.config.cjs"), REACT_NATIVE_CONFIG);
34
+ } else if (!present.some(function(name) {
35
+ return readFileSync(join(root, name), "utf8").includes("one/react-native-config");
36
+ })) {
37
+ 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.`);
38
+ }
21
39
  var { prebuild } = await import("vxrn");
22
40
  await prebuild({
23
41
  root: process.cwd(),
@@ -1 +1 @@
1
- {"version":3,"file":"prebuild.native.js","names":[],"sources":["esm/cli/prebuild.native.js"],"sourcesContent":["import { readFileSync } from \"fs\";\nimport { join } from \"path\";\nimport { validateNativeApp } from \"../native/appManifest\";\nimport { loadUserOneOptions } from \"../vite/loadConfig\";\nasync function run(args) {\n var _packageJson_dependencies, _packageJson_devDependencies;\n var root = process.cwd();\n var packageJson = JSON.parse(readFileSync(join(root, \"package.json\"), \"utf8\"));\n 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\");\n if (hasExpo) {\n 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.');\n }\n var { oneOptions } = await loadUserOneOptions(\"build\", true);\n var native = oneOptions === null || oneOptions === void 0 ? void 0 : oneOptions.native;\n var app = typeof native === \"object\" ? native.app : void 0;\n if (!app) {\n throw new Error(\"[one] native.app is required: configure one({ native: { app } }) with name, ios.bundleId, and android.applicationId\");\n }\n validateNativeApp(app);\n var { 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,eAAe,IAAI,MAAM;CACvB,IAAI,2BAA2B;CAC/B,IAAI,OAAO,QAAQ,IAAI;CACvB,IAAI,cAAc,KAAK,MAAM,aAAa,KAAK,MAAM,cAAc,GAAG,MAAM,CAAC;CAC7E,IAAI,UAAU,OAAO,QAAQ,4BAA4B,YAAY,kBAAkB,QAAQ,8BAA8B,KAAK,IAAI,4BAA4B,CAAC,GAAG,MAAM,KAAK,OAAO,QAAQ,+BAA+B,YAAY,qBAAqB,QAAQ,iCAAiC,KAAK,IAAI,+BAA+B,CAAC,GAAG,MAAM;CAC3V,IAAI,SAAS;EACX,MAAM,IAAI,MAAM,mJAAiJ;CACnK;CACA,IAAI,EAAE,eAAe,MAAM,mBAAmB,SAAS,IAAI;CAC3D,IAAI,SAAS,eAAe,QAAQ,eAAe,KAAK,IAAI,KAAK,IAAI,WAAW;CAChF,IAAI,MAAM,OAAO,WAAW,WAAW,OAAO,MAAM,KAAK;CACzD,IAAI,CAAC,KAAK;EACR,MAAM,IAAI,MAAM,qHAAqH;CACvI;CACA,kBAAkB,GAAG;CACrB,IAAI,EAAE,aAAa,MAAM,OAAO;CAChC,MAAM,SAAS;EACb,MAAM,QAAQ,IAAI;EAClB,GAAG;EACH;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"prebuild.native.js","names":[],"sources":["esm/cli/prebuild.native.js"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from \"fs\";\nimport { join } from \"path\";\nimport { validateNativeApp } from \"../native/appManifest\";\nimport { loadUserOneOptions } from \"../vite/loadConfig\";\nvar REACT_NATIVE_CONFIG = `module.exports = require('one/react-native-config')\n`;\nvar 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 var _packageJson_dependencies, _packageJson_devDependencies;\n var root = process.cwd();\n var packageJson = JSON.parse(readFileSync(join(root, \"package.json\"), \"utf8\"));\n 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\");\n if (hasExpo) {\n 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.');\n }\n var { oneOptions } = await loadUserOneOptions(\"build\", true);\n var native = oneOptions === null || oneOptions === void 0 ? void 0 : oneOptions.native;\n var app = typeof native === \"object\" ? native.app : void 0;\n if (!app) {\n throw new Error(\"[one] native.app is required: configure one({ native: { app } }) with name, ios.bundleId, and android.applicationId\");\n }\n validateNativeApp(app);\n var present = REACT_NATIVE_CONFIG_NAMES.filter(function(name) {\n return existsSync(join(root, name));\n });\n if (present.length === 0) {\n writeFileSync(join(root, \"react-native.config.cjs\"), REACT_NATIVE_CONFIG);\n } else if (!present.some(function(name) {\n return readFileSync(join(root, name), \"utf8\").includes(\"one/react-native-config\");\n })) {\n 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.`);\n }\n var { 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,IAAI,sBAAsB;;AAE1B,IAAI,4BAA4B;CAC9B;CACA;CACA;CACA;AACF;AACA,eAAe,IAAI,MAAM;CACvB,IAAI,2BAA2B;CAC/B,IAAI,OAAO,QAAQ,IAAI;CACvB,IAAI,cAAc,KAAK,MAAM,aAAa,KAAK,MAAM,cAAc,GAAG,MAAM,CAAC;CAC7E,IAAI,UAAU,OAAO,QAAQ,4BAA4B,YAAY,kBAAkB,QAAQ,8BAA8B,KAAK,IAAI,4BAA4B,CAAC,GAAG,MAAM,KAAK,OAAO,QAAQ,+BAA+B,YAAY,qBAAqB,QAAQ,iCAAiC,KAAK,IAAI,+BAA+B,CAAC,GAAG,MAAM;CAC3V,IAAI,SAAS;EACX,MAAM,IAAI,MAAM,mJAAiJ;CACnK;CACA,IAAI,EAAE,eAAe,MAAM,mBAAmB,SAAS,IAAI;CAC3D,IAAI,SAAS,eAAe,QAAQ,eAAe,KAAK,IAAI,KAAK,IAAI,WAAW;CAChF,IAAI,MAAM,OAAO,WAAW,WAAW,OAAO,MAAM,KAAK;CACzD,IAAI,CAAC,KAAK;EACR,MAAM,IAAI,MAAM,qHAAqH;CACvI;CACA,kBAAkB,GAAG;CACrB,IAAI,UAAU,0BAA0B,OAAO,SAAS,MAAM;EAC5D,OAAO,WAAW,KAAK,MAAM,IAAI,CAAC;CACpC,CAAC;CACD,IAAI,QAAQ,WAAW,GAAG;EACxB,cAAc,KAAK,MAAM,yBAAyB,GAAG,mBAAmB;CAC1E,OAAO,IAAI,CAAC,QAAQ,KAAK,SAAS,MAAM;EACtC,OAAO,aAAa,KAAK,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,SAAS,yBAAyB;CAClF,CAAC,GAAG;EACF,MAAM,IAAI,MAAM,SAAS,QAAQ,KAAK,IAAI,EAAE,kPAAkP;CAChS;CACA,IAAI,EAAE,aAAa,MAAM,OAAO;CAChC,MAAM,SAAS;EACb,MAAM,QAAQ,IAAI;EAClB,GAAG;EACH;CACF,CAAC;AACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "one",
3
- "version": "2.0.0-beta.61.1",
3
+ "version": "2.0.0-beta.66.1",
4
4
  "license": "BSD-3-Clause",
5
5
  "sideEffects": [
6
6
  "setup.mjs",
@@ -190,20 +190,20 @@
190
190
  "@react-navigation/routers": "~8.0.0-alpha.17",
191
191
  "@cloudflare/vite-plugin": "^1.33.1",
192
192
  "@ungap/structured-clone": "^1.2.0",
193
- "@vxrn/color-scheme": "2.0.0-beta.61.1",
194
- "@vxrn/compiler": "2.0.0-beta.61.1",
195
- "@vxrn/native": "2.0.0-beta.61.1",
196
- "@vxrn/resolve": "2.0.0-beta.61.1",
197
- "@vxrn/safe-area": "2.0.0-beta.61.1",
198
- "@vxrn/tslib-lite": "2.0.0-beta.61.1",
199
- "@vxrn/use-isomorphic-layout-effect": "2.0.0-beta.61.1",
200
- "@vxrn/utils": "2.0.0-beta.61.1",
201
- "@vxrn/vite-plugin-metro": "2.0.0-beta.61.1",
193
+ "@vxrn/color-scheme": "2.0.0-beta.66.1",
194
+ "@vxrn/compiler": "2.0.0-beta.66.1",
195
+ "@vxrn/native": "2.0.0-beta.66.1",
196
+ "@vxrn/resolve": "2.0.0-beta.66.1",
197
+ "@vxrn/safe-area": "2.0.0-beta.66.1",
198
+ "@vxrn/tslib-lite": "2.0.0-beta.66.1",
199
+ "@vxrn/use-isomorphic-layout-effect": "2.0.0-beta.66.1",
200
+ "@vxrn/utils": "2.0.0-beta.66.1",
201
+ "@vxrn/vite-plugin-metro": "2.0.0-beta.66.1",
202
202
  "babel-dead-code-elimination": "1.0.10",
203
203
  "babel-plugin-module-resolver": "^5.0.2",
204
204
  "citty": "^0.1.6",
205
205
  "core-js": "^3.38.1",
206
- "create-vxrn": "2.0.0-beta.61.1",
206
+ "create-vxrn": "2.0.0-beta.66.1",
207
207
  "escape-string-regexp": "^5.0.0",
208
208
  "fast-deep-equal": "^3.1.3",
209
209
  "fast-glob": "^3.3.3",
@@ -222,7 +222,7 @@
222
222
  "tsconfig-paths": "^4",
223
223
  "use-latest-callback": "^0.2.3",
224
224
  "vite": "^8.2.2",
225
- "vxrn": "2.0.0-beta.61.1",
225
+ "vxrn": "2.0.0-beta.66.1",
226
226
  "web-streams-polyfill": "^4.3.0",
227
227
  "ws": "^8.21.0",
228
228
  "xxhashjs": "^0.2.2"
@@ -1,4 +1,11 @@
1
- import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
1
+ import {
2
+ existsSync,
3
+ mkdirSync,
4
+ mkdtempSync,
5
+ readFileSync,
6
+ rmSync,
7
+ writeFileSync,
8
+ } from 'node:fs'
2
9
  import { tmpdir } from 'node:os'
3
10
  import { join } from 'node:path'
4
11
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
@@ -57,6 +64,57 @@ describe('one prebuild', () => {
57
64
  })
58
65
  })
59
66
 
67
+ it('writes the release-bundle react-native config', async () => {
68
+ loadUserOneOptionsMock.mockResolvedValueOnce({ oneOptions: { native: { app } } })
69
+
70
+ await run({ platform: 'ios', 'no-install': true })
71
+
72
+ expect(readFileSync(join(projectRoot, 'react-native.config.cjs'), 'utf8')).toBe(
73
+ `module.exports = require('one/react-native-config')\n`
74
+ )
75
+ })
76
+
77
+ it('keeps an app-owned config that already loads one/react-native-config', async () => {
78
+ writeFileSync(
79
+ join(projectRoot, 'react-native.config.js'),
80
+ `module.exports = {...require('one/react-native-config'), assets: ['./assets']}\n`
81
+ )
82
+ loadUserOneOptionsMock.mockResolvedValueOnce({ oneOptions: { native: { app } } })
83
+
84
+ await run({ platform: 'ios', 'no-install': true })
85
+
86
+ expect(prebuildMock).toHaveBeenCalled()
87
+ expect(existsSync(join(projectRoot, 'react-native.config.cjs'))).toBe(false)
88
+ expect(readFileSync(join(projectRoot, 'react-native.config.js'), 'utf8')).toContain(
89
+ `assets: ['./assets']`
90
+ )
91
+ })
92
+
93
+ it('leaves a byte-equal generated config in place', async () => {
94
+ writeFileSync(
95
+ join(projectRoot, 'react-native.config.cjs'),
96
+ `module.exports = require('one/react-native-config')\n`
97
+ )
98
+ loadUserOneOptionsMock.mockResolvedValueOnce({ oneOptions: { native: { app } } })
99
+
100
+ await run({ platform: 'ios', 'no-install': true })
101
+
102
+ expect(prebuildMock).toHaveBeenCalled()
103
+ expect(readFileSync(join(projectRoot, 'react-native.config.cjs'), 'utf8')).toBe(
104
+ `module.exports = require('one/react-native-config')\n`
105
+ )
106
+ })
107
+
108
+ it('fails when an app-owned config drops one/react-native-config', async () => {
109
+ writeFileSync(join(projectRoot, 'react-native.config.cjs'), `module.exports = {}\n`)
110
+ loadUserOneOptionsMock.mockResolvedValueOnce({ oneOptions: { native: { app } } })
111
+
112
+ await expect(run({ platform: 'ios', 'no-install': true })).rejects.toThrow(
113
+ 'one/react-native-config'
114
+ )
115
+ expect(prebuildMock).not.toHaveBeenCalled()
116
+ })
117
+
60
118
  it('rejects a missing native.app before calling vxrn', async () => {
61
119
  loadUserOneOptionsMock.mockResolvedValueOnce({ oneOptions: {} })
62
120
 
@@ -1,8 +1,22 @@
1
- import { readFileSync } from 'node:fs'
1
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs'
2
2
  import { join } from 'node:path'
3
3
  import { validateNativeApp } from '../native/appManifest'
4
4
  import { loadUserOneOptions } from '../vite/loadConfig'
5
5
 
6
+ // default react-native config: xcodebuild's bundle phase and gradle's react
7
+ // block both invoke `react-native bundle` via react-native/cli.js, which
8
+ // loads its `bundle` command override from here. without it the stock bundle
9
+ // command runs: it rejects the --config-cmd xcode passes and needs a
10
+ // metro.config.js One apps do not have. constant bytes, no per-app inputs.
11
+ const REACT_NATIVE_CONFIG = `module.exports = require('one/react-native-config')\n`
12
+
13
+ const REACT_NATIVE_CONFIG_NAMES = [
14
+ 'react-native.config.js',
15
+ 'react-native.config.cjs',
16
+ 'react-native.config.mjs',
17
+ 'react-native.config.ts',
18
+ ]
19
+
6
20
  export async function run(args: { platform?: string; 'no-install'?: boolean }) {
7
21
  const root = process.cwd()
8
22
  const packageJson = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'))
@@ -23,6 +37,21 @@ export async function run(args: { platform?: string; 'no-install'?: boolean }) {
23
37
  )
24
38
  }
25
39
  validateNativeApp(app)
40
+ // an app-owned react-native config wins; only generate ours when the app
41
+ // has none. a present config that drops One's bundle override would
42
+ // silently Release-build with the stock bundler, so fail and say the fix.
43
+ const present = REACT_NATIVE_CONFIG_NAMES.filter((name) => existsSync(join(root, name)))
44
+ if (present.length === 0) {
45
+ writeFileSync(join(root, 'react-native.config.cjs'), REACT_NATIVE_CONFIG)
46
+ } else if (
47
+ !present.some((name) =>
48
+ readFileSync(join(root, name), 'utf8').includes('one/react-native-config')
49
+ )
50
+ ) {
51
+ throw new Error(
52
+ `[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.`
53
+ )
54
+ }
26
55
  const { prebuild } = await import('vxrn')
27
56
 
28
57
  await prebuild({
@@ -1 +1 @@
1
- {"version":3,"file":"prebuild.d.ts","sourceRoot":"","sources":["../../src/cli/prebuild.ts"],"names":[],"mappings":"AAKA,wBAAsB,GAAG,CAAC,IAAI,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,iBA2B5E"}
1
+ {"version":3,"file":"prebuild.d.ts","sourceRoot":"","sources":["../../src/cli/prebuild.ts"],"names":[],"mappings":"AAmBA,wBAAsB,GAAG,CAAC,IAAI,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,iBA0C5E"}