one 2.0.0-beta.56.1 → 2.0.0-beta.58.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.
Files changed (38) hide show
  1. package/dist/cjs/babel-preset/index.cjs +18 -8
  2. package/dist/cjs/babel-preset/index.native.cjs +18 -8
  3. package/dist/cjs/babel-preset/index.native.js +18 -8
  4. package/dist/cjs/babel-preset/index.native.js.map +1 -1
  5. package/dist/cjs/cli/generateBundlerConfig.cjs +7 -8
  6. package/dist/cjs/cli/generateBundlerConfig.native.cjs +7 -8
  7. package/dist/cjs/cli/generateBundlerConfig.native.js +7 -8
  8. package/dist/cjs/cli/generateBundlerConfig.native.js.map +1 -1
  9. package/dist/cjs/one.cjs +5 -1
  10. package/dist/cjs/one.native.cjs +5 -1
  11. package/dist/cjs/one.native.js +5 -1
  12. package/dist/cjs/one.native.js.map +1 -1
  13. package/dist/esm/babel-preset/index.mjs +18 -8
  14. package/dist/esm/babel-preset/index.mjs.map +1 -1
  15. package/dist/esm/babel-preset/index.native.js +18 -8
  16. package/dist/esm/babel-preset/index.native.js.map +1 -1
  17. package/dist/esm/cli/generateBundlerConfig.mjs +7 -8
  18. package/dist/esm/cli/generateBundlerConfig.mjs.map +1 -1
  19. package/dist/esm/cli/generateBundlerConfig.native.js +7 -8
  20. package/dist/esm/cli/generateBundlerConfig.native.js.map +1 -1
  21. package/dist/esm/one.mjs +6 -2
  22. package/dist/esm/one.mjs.map +1 -1
  23. package/dist/esm/one.native.js +6 -2
  24. package/dist/esm/one.native.js.map +1 -1
  25. package/package.json +16 -12
  26. package/src/babel-preset/index.test.ts +5 -0
  27. package/src/babel-preset/index.ts +20 -5
  28. package/src/babel-preset/integration.test.ts +59 -5
  29. package/src/cli/generateBundlerConfig.test.ts +6 -2
  30. package/src/cli/generateBundlerConfig.ts +7 -8
  31. package/src/native/packedClosure.test.ts +4 -5
  32. package/src/one.test.ts +10 -0
  33. package/src/one.ts +12 -0
  34. package/types/babel-preset/index.d.ts +5 -5
  35. package/types/babel-preset/index.d.ts.map +1 -1
  36. package/types/cli/generateBundlerConfig.d.ts.map +1 -1
  37. package/types/one.d.ts +5 -1
  38. package/types/one.d.ts.map +1 -1
@@ -6,23 +6,22 @@ import { getRouterRootFromOneOptions } from "../utils/getRouterRootFromOneOption
6
6
  const ONE_GENERATED_MARKER = "@one/generated bundler-config";
7
7
  function buildBabelConfigContent({ eject, options }) {
8
8
  const header = eject ? `// you own this file. edit freely. \`one\` will not regenerate it.
9
- // composes React Native's Metro preset with One's canonical plugin chain.
9
+ // delegates to one/babel-preset which holds the canonical plugin chain.
10
10
  ` : `// ${ONE_GENERATED_MARKER}
11
11
  //
12
- // auto-generated by \`one metro-eject\`. composes React Native's Metro
13
- // preset with One's router/setup transforms.
12
+ // auto-generated by \`one metro-eject\`. delegates to one/babel-preset so
13
+ // Metro uses the same router/setup options as \`one dev\` and \`one build\`.
14
14
  //
15
15
  // to customize, delete this header and edit freely. re-runs will then
16
16
  // leave this file alone.
17
17
  `;
18
18
  return `${header}
19
+ const oneBabelPreset = require('one/babel-preset')
20
+ const preset = oneBabelPreset.default || oneBabelPreset
19
21
  const oneBundlerOptions = ${serializeBundlerConfigOptions(options)}
20
22
 
21
- module.exports = {
22
- presets: [
23
- '@react-native/babel-preset',
24
- ['one/babel-preset', oneBundlerOptions],
25
- ],
23
+ module.exports = function (api) {
24
+ return preset(api, oneBundlerOptions)
26
25
  }
27
26
  `;
28
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"generateBundlerConfig.js","names":[],"sources":["esm/cli/generateBundlerConfig.js"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport colors from \"picocolors\";\nimport { getRouterRootFromOneOptions } from \"../utils/getRouterRootFromOneOptions\";\nconst ONE_GENERATED_MARKER = \"@one/generated bundler-config\";\nfunction buildBabelConfigContent({\n eject,\n options\n}) {\n const header = eject ? `// you own this file. edit freely. \\`one\\` will not regenerate it.\n// composes React Native's Metro preset with One's canonical plugin chain.\n` : `// ${ONE_GENERATED_MARKER}\n//\n// auto-generated by \\`one metro-eject\\`. composes React Native's Metro\n// preset with One's router/setup transforms.\n//\n// to customize, delete this header and edit freely. re-runs will then\n// leave this file alone.\n`;\n return `${header}\nconst oneBundlerOptions = ${serializeBundlerConfigOptions(options)}\n\nmodule.exports = {\n presets: [\n '@react-native/babel-preset',\n ['one/babel-preset', oneBundlerOptions],\n ],\n}\n`;\n}\nfunction buildMetroConfigContent({\n eject,\n options\n}) {\n const header = eject ? `// you own this file. edit freely. \\`one\\` will not regenerate it.\n// withOne() invokes the same Metro pipeline One uses for production bundles.\n` : `// ${ONE_GENERATED_MARKER}\n//\n// auto-generated by \\`one metro-eject\\`. delegates to one/metro-config,\n// which invokes the same metro pipeline One uses for production native\n// bundles with your router and setup options.\n//\n// to customize, delete this header and edit freely. re-runs will then\n// leave this file alone.\n`;\n return `${header}\nconst { withOne } = require('one/metro-config')\nconst oneBundlerOptions = ${serializeBundlerConfigOptions(options)}\n\nmodule.exports = withOne(__dirname, oneBundlerOptions)\n`;\n}\nconst FILES = [\n {\n name: \"babel.config.cjs\",\n getContent: buildBabelConfigContent,\n conflicting: [\"babel.config.js\", \"babel.config.mjs\", \".babelrc\", \".babelrc.js\"]\n },\n {\n name: \"metro.config.cjs\",\n getContent: buildMetroConfigContent,\n conflicting: [\"metro.config.js\", \"metro.config.mjs\"]\n }\n];\nfunction stripUndefined(value) {\n if (Array.isArray(value)) {\n return value.map(stripUndefined);\n }\n if (value && typeof value === \"object\") {\n return Object.fromEntries(\n Object.entries(value).filter(([, entry]) => entry !== void 0).map(([key, entry]) => [key, stripUndefined(entry)])\n );\n }\n return value;\n}\nfunction assertSerializable(value, keyPath = \"one bundler options\") {\n if (typeof value === \"function\" || typeof value === \"symbol\" || typeof value === \"bigint\") {\n throw new Error(\n `[one] ${keyPath} must be JSON-serializable to generate Babel/Metro config files. Move function-valued native linking/customization into an ejected config.`\n );\n }\n if (Array.isArray(value)) {\n value.forEach((entry, index) => assertSerializable(entry, `${keyPath}[${index}]`));\n return;\n }\n if (value && typeof value === \"object\") {\n for (const [key, entry] of Object.entries(value)) {\n assertSerializable(entry, `${keyPath}.${key}`);\n }\n }\n}\nfunction serializeBundlerConfigOptions(options) {\n const clean = stripUndefined(options);\n assertSerializable(clean);\n return JSON.stringify(clean, null, 2);\n}\nfunction getBundlerConfigOptionsFromOneOptions(oneOptions = {}) {\n return stripUndefined({\n routerRoot: getRouterRootFromOneOptions(oneOptions),\n ignoredRouteFiles: oneOptions.router?.ignoredRouteFiles,\n linking: oneOptions.router?.linking,\n setupFile: oneOptions.setupFile\n });\n}\nfunction generateBundlerConfig(args = {}) {\n const cwd = path.resolve(args.cwd ?? process.cwd());\n const force = !!args.force;\n const check = !!args.check;\n const quiet = !!args.quiet;\n const log = (msg) => {\n if (!quiet) console.info(msg);\n };\n const warn = (msg) => {\n if (!quiet) console.warn(msg);\n };\n const results = [];\n const eject = !!args.eject;\n const bundlerOptions = getBundlerConfigOptionsFromOneOptions(args.oneOptions);\n for (const file of FILES) {\n const filePath = path.join(cwd, file.name);\n const targetContent = file.getContent({ eject, options: bundlerOptions });\n const conflict = file.conflicting.find((alt) => existsSync(path.join(cwd, alt)));\n if (conflict && !existsSync(filePath)) {\n results.push({\n filePath: path.join(cwd, conflict),\n action: \"skipped-other-format\",\n reason: `Found ${conflict}; not creating ${file.name}. To switch, delete ${conflict} and re-run with --force.`\n });\n warn(\n colors.yellow(\n `[one] found ${conflict}. Leaving it alone. Delete it and re-run with --force to switch to ${file.name}.`\n )\n );\n continue;\n }\n if (!existsSync(filePath)) {\n if (check) {\n results.push({ filePath, action: \"would-write\" });\n log(colors.yellow(`[one] missing: ${file.name}`));\n continue;\n }\n writeFileSync(filePath, targetContent);\n results.push({ filePath, action: \"wrote\" });\n log(colors.green(`[one] wrote ${file.name}`));\n continue;\n }\n const existing = readFileSync(filePath, \"utf8\");\n if (existing === targetContent) {\n results.push({ filePath, action: \"kept\" });\n log(colors.dim(`[one] up to date: ${file.name}`));\n continue;\n }\n const hasMarker = existing.includes(ONE_GENERATED_MARKER);\n if (!hasMarker && !force) {\n results.push({\n filePath,\n action: \"skipped-customized\",\n reason: `${file.name} has been customized (no @one marker). Re-add the marker comment or pass --force to overwrite.`\n });\n warn(\n colors.yellow(\n `[one] ${file.name} appears customized. Skipping. Pass --force to overwrite.`\n )\n );\n continue;\n }\n if (check) {\n results.push({ filePath, action: \"would-overwrite\" });\n log(colors.yellow(`[one] out of date: ${file.name}`));\n continue;\n }\n writeFileSync(filePath, targetContent);\n results.push({ filePath, action: \"wrote\" });\n log(colors.green(`[one] updated ${file.name}`));\n }\n const acceptableAlways = /* @__PURE__ */ new Set([\n \"wrote\",\n \"kept\",\n \"skipped-other-format\",\n \"skipped-customized\"\n ]);\n const acceptableInCheck = /* @__PURE__ */ new Set([\n \"kept\",\n \"skipped-other-format\",\n \"skipped-customized\"\n ]);\n const ok = (check ? acceptableInCheck : acceptableAlways).size ? results.every((r) => (check ? acceptableInCheck : acceptableAlways).has(r.action)) : false;\n return { results, ok };\n}\nexport {\n ONE_GENERATED_MARKER,\n generateBundlerConfig,\n getBundlerConfigOptionsFromOneOptions\n};\n//# sourceMappingURL=generateBundlerConfig.js.map\n"],"mappings":";;;;;;AAIA,MAAM,uBAAuB;AAC7B,SAAS,wBAAwB,EAC/B,OACA,WACC;CACD,MAAM,SAAS,QAAQ;;IAErB,MAAM,qBAAqB;;;;;;;;CAQ7B,OAAO,GAAG,OAAO;4BACS,8BAA8B,OAAO,EAAE;;;;;;;;;AASnE;AACA,SAAS,wBAAwB,EAC/B,OACA,WACC;CACD,MAAM,SAAS,QAAQ;;IAErB,MAAM,qBAAqB;;;;;;;;;CAS7B,OAAO,GAAG,OAAO;;4BAES,8BAA8B,OAAO,EAAE;;;;AAInE;AACA,MAAM,QAAQ,CACZ;CACE,MAAM;CACN,YAAY;CACZ,aAAa;EAAC;EAAmB;EAAoB;E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GAC9B,QAAQ,KAAK;IAAE;IAAU,QAAQ;GAAO,CAAC;GACzC,IAAI,OAAO,IAAI,qBAAqB,KAAK,MAAM,CAAC;GAChD;EACF;EACA,MAAM,YAAY,SAAS,SAAS,oBAAoB;EACxD,IAAI,CAAC,aAAa,CAAC,OAAO;GACxB,QAAQ,KAAK;IACX;IACA,QAAQ;IACR,QAAQ,GAAG,KAAK,KAAK;GACvB,CAAC;GACD,KACE,OAAO,OACL,SAAS,KAAK,KAAK,0DACrB,CACF;GACA;EACF;EACA,IAAI,OAAO;GACT,QAAQ,KAAK;IAAE;IAAU,QAAQ;GAAkB,CAAC;GACpD,IAAI,OAAO,OAAO,sBAAsB,KAAK,MAAM,CAAC;GACpD;EACF;EACA,cAAc,UAAU,aAAa;EACrC,QAAQ,KAAK;GAAE;GAAU,QAAQ;EAAQ,CAAC;EAC1C,IAAI,OAAO,MAAM,iBAAiB,KAAK,MAAM,CAAC;CAChD;CACA,MAAM,mCAAmC,IAAI,IAAI;EAC/C;EACA;EACA;EACA;CACF,CAAC;CACD,MAAM,oCAAoC,IAAI,IAAI;EAChD;EACA;EACA;CACF,CAAC;CACD,MAAM,MAAM,QAAQ,oBAAoB,iBAAgB,CAAE,OAAO,QAAQ,OAAO,OAAO,QAAQ,oBAAoB,iBAAgB,CAAE,IAAI,EAAE,MAAM,CAAC,IAAI;CACtJ,OAAO;EAAE;EAAS;CAAG;AACvB"}
1
+ {"version":3,"file":"generateBundlerConfig.js","names":[],"sources":["esm/cli/generateBundlerConfig.js"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport colors from \"picocolors\";\nimport { getRouterRootFromOneOptions } from \"../utils/getRouterRootFromOneOptions\";\nconst ONE_GENERATED_MARKER = \"@one/generated bundler-config\";\nfunction buildBabelConfigContent({\n eject,\n options\n}) {\n const header = eject ? `// you own this file. edit freely. \\`one\\` will not regenerate it.\n// delegates to one/babel-preset which holds the canonical plugin chain.\n` : `// ${ONE_GENERATED_MARKER}\n//\n// auto-generated by \\`one metro-eject\\`. delegates to one/babel-preset so\n// Metro uses the same router/setup options as \\`one dev\\` and \\`one build\\`.\n//\n// to customize, delete this header and edit freely. re-runs will then\n// leave this file alone.\n`;\n return `${header}\nconst oneBabelPreset = require('one/babel-preset')\nconst preset = oneBabelPreset.default || oneBabelPreset\nconst oneBundlerOptions = ${serializeBundlerConfigOptions(options)}\n\nmodule.exports = function (api) {\n return preset(api, oneBundlerOptions)\n}\n`;\n}\nfunction buildMetroConfigContent({\n eject,\n options\n}) {\n const header = eject ? `// you own this file. edit freely. \\`one\\` will not regenerate it.\n// withOne() invokes the same Metro pipeline One uses for production bundles.\n` : `// ${ONE_GENERATED_MARKER}\n//\n// auto-generated by \\`one metro-eject\\`. delegates to one/metro-config,\n// which invokes the same metro pipeline One uses for production native\n// bundles with your router and setup options.\n//\n// to customize, delete this header and edit freely. re-runs will then\n// leave this file alone.\n`;\n return `${header}\nconst { withOne } = require('one/metro-config')\nconst oneBundlerOptions = ${serializeBundlerConfigOptions(options)}\n\nmodule.exports = withOne(__dirname, oneBundlerOptions)\n`;\n}\nconst FILES = [\n {\n name: \"babel.config.cjs\",\n getContent: buildBabelConfigContent,\n conflicting: [\"babel.config.js\", \"babel.config.mjs\", \".babelrc\", \".babelrc.js\"]\n },\n {\n name: \"metro.config.cjs\",\n getContent: buildMetroConfigContent,\n conflicting: [\"metro.config.js\", \"metro.config.mjs\"]\n }\n];\nfunction stripUndefined(value) {\n if (Array.isArray(value)) {\n return value.map(stripUndefined);\n }\n if (value && typeof value === \"object\") {\n return Object.fromEntries(\n Object.entries(value).filter(([, entry]) => entry !== void 0).map(([key, entry]) => [key, stripUndefined(entry)])\n );\n }\n return value;\n}\nfunction assertSerializable(value, keyPath = \"one bundler options\") {\n if (typeof value === \"function\" || typeof value === \"symbol\" || typeof value === \"bigint\") {\n throw new Error(\n `[one] ${keyPath} must be JSON-serializable to generate Babel/Metro config files. Move function-valued native linking/customization into an ejected config.`\n );\n }\n if (Array.isArray(value)) {\n value.forEach((entry, index) => assertSerializable(entry, `${keyPath}[${index}]`));\n return;\n }\n if (value && typeof value === \"object\") {\n for (const [key, entry] of Object.entries(value)) {\n assertSerializable(entry, `${keyPath}.${key}`);\n }\n }\n}\nfunction serializeBundlerConfigOptions(options) {\n const clean = stripUndefined(options);\n assertSerializable(clean);\n return JSON.stringify(clean, null, 2);\n}\nfunction getBundlerConfigOptionsFromOneOptions(oneOptions = {}) {\n return stripUndefined({\n routerRoot: getRouterRootFromOneOptions(oneOptions),\n ignoredRouteFiles: oneOptions.router?.ignoredRouteFiles,\n linking: oneOptions.router?.linking,\n setupFile: oneOptions.setupFile\n });\n}\nfunction generateBundlerConfig(args = {}) {\n const cwd = path.resolve(args.cwd ?? process.cwd());\n const force = !!args.force;\n const check = !!args.check;\n const quiet = !!args.quiet;\n const log = (msg) => {\n if (!quiet) console.info(msg);\n };\n const warn = (msg) => {\n if (!quiet) console.warn(msg);\n };\n const results = [];\n const eject = !!args.eject;\n const bundlerOptions = getBundlerConfigOptionsFromOneOptions(args.oneOptions);\n for (const file of FILES) {\n const filePath = path.join(cwd, file.name);\n const targetContent = file.getContent({ eject, options: bundlerOptions });\n const conflict = file.conflicting.find((alt) => existsSync(path.join(cwd, alt)));\n if (conflict && !existsSync(filePath)) {\n results.push({\n filePath: path.join(cwd, conflict),\n action: \"skipped-other-format\",\n reason: `Found ${conflict}; not creating ${file.name}. To switch, delete ${conflict} and re-run with --force.`\n });\n warn(\n colors.yellow(\n `[one] found ${conflict}. Leaving it alone. Delete it and re-run with --force to switch to ${file.name}.`\n )\n );\n continue;\n }\n if (!existsSync(filePath)) {\n if (check) {\n results.push({ filePath, action: \"would-write\" });\n log(colors.yellow(`[one] missing: ${file.name}`));\n continue;\n }\n writeFileSync(filePath, targetContent);\n results.push({ filePath, action: \"wrote\" });\n log(colors.green(`[one] wrote ${file.name}`));\n continue;\n }\n const existing = readFileSync(filePath, \"utf8\");\n if (existing === targetContent) {\n results.push({ filePath, action: \"kept\" });\n log(colors.dim(`[one] up to date: ${file.name}`));\n continue;\n }\n const hasMarker = existing.includes(ONE_GENERATED_MARKER);\n if (!hasMarker && !force) {\n results.push({\n filePath,\n action: \"skipped-customized\",\n reason: `${file.name} has been customized (no @one marker). Re-add the marker comment or pass --force to overwrite.`\n });\n warn(\n colors.yellow(\n `[one] ${file.name} appears customized. Skipping. Pass --force to overwrite.`\n )\n );\n continue;\n }\n if (check) {\n results.push({ filePath, action: \"would-overwrite\" });\n log(colors.yellow(`[one] out of date: ${file.name}`));\n continue;\n }\n writeFileSync(filePath, targetContent);\n results.push({ filePath, action: \"wrote\" });\n log(colors.green(`[one] updated ${file.name}`));\n }\n const acceptableAlways = /* @__PURE__ */ new Set([\n \"wrote\",\n \"kept\",\n \"skipped-other-format\",\n \"skipped-customized\"\n ]);\n const acceptableInCheck = /* @__PURE__ */ new Set([\n \"kept\",\n \"skipped-other-format\",\n \"skipped-customized\"\n ]);\n const ok = (check ? acceptableInCheck : acceptableAlways).size ? results.every((r) => (check ? acceptableInCheck : acceptableAlways).has(r.action)) : false;\n return { results, ok };\n}\nexport {\n ONE_GENERATED_MARKER,\n generateBundlerConfig,\n getBundlerConfigOptionsFromOneOptions\n};\n//# sourceMappingURL=generateBundlerConfig.js.map\n"],"mappings":";;;;;;AAIA,MAAM,uBAAuB;AAC7B,SAAS,wBAAwB,EAC/B,OACA,WACC;CACD,MAAM,SAAS,QAAQ;;IAErB,MAAM,qBAAqB;;;;;;;;CAQ7B,OAAO,GAAG,OAAO;;;4BAGS,8BAA8B,OAAO,EAAE;;;;;;AAMnE;AACA,SAAS,wBAAwB,EAC/B,OACA,WACC;CACD,MAAM,SAAS,QAAQ;;IAErB,MAAM,qBAAqB;;;;;;;;;CAS7B,OAAO,GAAG,OAAO;;4BAES,8BAA8B,OAAO,EAAE;;;;AAInE;AACA,MAAM,QAAQ,CACZ;CACE,MAAM;CACN,YAAY;CACZ,aAAa;EAAC;EAAmB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Aa,eAAe;GAC9B,QAAQ,KAAK;IAAE;IAAU,QAAQ;GAAO,CAAC;GACzC,IAAI,OAAO,IAAI,qBAAqB,KAAK,MAAM,CAAC;GAChD;EACF;EACA,MAAM,YAAY,SAAS,SAAS,oBAAoB;EACxD,IAAI,CAAC,aAAa,CAAC,OAAO;GACxB,QAAQ,KAAK;IACX;IACA,QAAQ;IACR,QAAQ,GAAG,KAAK,KAAK;GACvB,CAAC;GACD,KACE,OAAO,OACL,SAAS,KAAK,KAAK,0DACrB,CACF;GACA;EACF;EACA,IAAI,OAAO;GACT,QAAQ,KAAK;IAAE;IAAU,QAAQ;GAAkB,CAAC;GACpD,IAAI,OAAO,OAAO,sBAAsB,KAAK,MAAM,CAAC;GACpD;EACF;EACA,cAAc,UAAU,aAAa;EACrC,QAAQ,KAAK;GAAE;GAAU,QAAQ;EAAQ,CAAC;EAC1C,IAAI,OAAO,MAAM,iBAAiB,KAAK,MAAM,CAAC;CAChD;CACA,MAAM,mCAAmC,IAAI,IAAI;EAC/C;EACA;EACA;EACA;CACF,CAAC;CACD,MAAM,oCAAoC,IAAI,IAAI;EAChD;EACA;EACA;CACF,CAAC;CACD,MAAM,MAAM,QAAQ,oBAAoB,iBAAgB,CAAE,OAAO,QAAQ,OAAO,OAAO,QAAQ,oBAAoB,iBAAgB,CAAE,IAAI,EAAE,MAAM,CAAC,IAAI;CACtJ,OAAO;EAAE;EAAS;CAAG;AACvB"}
@@ -7,23 +7,22 @@ var ONE_GENERATED_MARKER = "@one/generated bundler-config";
7
7
  function buildBabelConfigContent(param) {
8
8
  var { eject, options } = param;
9
9
  var header = eject ? `// you own this file. edit freely. \`one\` will not regenerate it.
10
- // composes React Native's Metro preset with One's canonical plugin chain.
10
+ // delegates to one/babel-preset which holds the canonical plugin chain.
11
11
  ` : `// ${ONE_GENERATED_MARKER}
12
12
  //
13
- // auto-generated by \`one metro-eject\`. composes React Native's Metro
14
- // preset with One's router/setup transforms.
13
+ // auto-generated by \`one metro-eject\`. delegates to one/babel-preset so
14
+ // Metro uses the same router/setup options as \`one dev\` and \`one build\`.
15
15
  //
16
16
  // to customize, delete this header and edit freely. re-runs will then
17
17
  // leave this file alone.
18
18
  `;
19
19
  return `${header}
20
+ const oneBabelPreset = require('one/babel-preset')
21
+ const preset = oneBabelPreset.default || oneBabelPreset
20
22
  const oneBundlerOptions = ${serializeBundlerConfigOptions(options)}
21
23
 
22
- module.exports = {
23
- presets: [
24
- '@react-native/babel-preset',
25
- ['one/babel-preset', oneBundlerOptions],
26
- ],
24
+ module.exports = function (api) {
25
+ return preset(api, oneBundlerOptions)
27
26
  }
28
27
  `;
29
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"generateBundlerConfig.native.js","names":[],"sources":["esm/cli/generateBundlerConfig.native.js"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from \"fs\";\nimport path from \"path\";\nimport colors from \"picocolors\";\nimport { getRouterRootFromOneOptions } from \"../utils/getRouterRootFromOneOptions\";\nvar ONE_GENERATED_MARKER = \"@one/generated bundler-config\";\nfunction buildBabelConfigContent(param) {\n var { eject, options } = param;\n var header = eject ? `// you own this file. edit freely. \\`one\\` will not regenerate it.\n// composes React Native's Metro preset with One's canonical plugin chain.\n` : `// ${ONE_GENERATED_MARKER}\n//\n// auto-generated by \\`one metro-eject\\`. composes React Native's Metro\n// preset with One's router/setup transforms.\n//\n// to customize, delete this header and edit freely. re-runs will then\n// leave this file alone.\n`;\n return `${header}\nconst oneBundlerOptions = ${serializeBundlerConfigOptions(options)}\n\nmodule.exports = {\n presets: [\n '@react-native/babel-preset',\n ['one/babel-preset', oneBundlerOptions],\n ],\n}\n`;\n}\nfunction buildMetroConfigContent(param) {\n var { eject, options } = param;\n var header = eject ? `// you own this file. edit freely. \\`one\\` will not regenerate it.\n// withOne() invokes the same Metro pipeline One uses for production bundles.\n` : `// ${ONE_GENERATED_MARKER}\n//\n// auto-generated by \\`one metro-eject\\`. delegates to one/metro-config,\n// which invokes the same metro pipeline One uses for production native\n// bundles with your router and setup options.\n//\n// to customize, delete this header and edit freely. re-runs will then\n// leave this file alone.\n`;\n return `${header}\nconst { withOne } = require('one/metro-config')\nconst oneBundlerOptions = ${serializeBundlerConfigOptions(options)}\n\nmodule.exports = withOne(__dirname, oneBundlerOptions)\n`;\n}\nvar FILES = [\n {\n name: \"babel.config.cjs\",\n getContent: buildBabelConfigContent,\n conflicting: [\n \"babel.config.js\",\n \"babel.config.mjs\",\n \".babelrc\",\n \".babelrc.js\"\n ]\n },\n {\n name: \"metro.config.cjs\",\n getContent: buildMetroConfigContent,\n conflicting: [\n \"metro.config.js\",\n \"metro.config.mjs\"\n ]\n }\n];\nfunction stripUndefined(value) {\n if (Array.isArray(value)) {\n return value.map(stripUndefined);\n }\n if (value && typeof value === \"object\") {\n return Object.fromEntries(Object.entries(value).filter(function(param) {\n var [, entry] = param;\n return entry !== void 0;\n }).map(function(param) {\n var [key, entry] = param;\n return [\n key,\n stripUndefined(entry)\n ];\n }));\n }\n return value;\n}\nfunction assertSerializable(value) {\n var keyPath = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : \"one bundler options\";\n if (typeof value === \"function\" || typeof value === \"symbol\" || typeof value === \"bigint\") {\n throw new Error(`[one] ${keyPath} must be JSON-serializable to generate Babel/Metro config files. Move function-valued native linking/customization into an ejected config.`);\n }\n if (Array.isArray(value)) {\n value.forEach(function(entry2, index) {\n return assertSerializable(entry2, `${keyPath}[${index}]`);\n });\n return;\n }\n if (value && typeof value === \"object\") {\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = Object.entries(value)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var [key, entry] = _step.value;\n assertSerializable(entry, `${keyPath}.${key}`);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n }\n}\nfunction serializeBundlerConfigOptions(options) {\n var clean = stripUndefined(options);\n assertSerializable(clean);\n return JSON.stringify(clean, null, 2);\n}\nfunction getBundlerConfigOptionsFromOneOptions() {\n var oneOptions = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};\n var _oneOptions_router, _oneOptions_router1;\n return stripUndefined({\n routerRoot: getRouterRootFromOneOptions(oneOptions),\n ignoredRouteFiles: (_oneOptions_router = oneOptions.router) === null || _oneOptions_router === void 0 ? void 0 : _oneOptions_router.ignoredRouteFiles,\n linking: (_oneOptions_router1 = oneOptions.router) === null || _oneOptions_router1 === void 0 ? void 0 : _oneOptions_router1.linking,\n setupFile: oneOptions.setupFile\n });\n}\nfunction generateBundlerConfig() {\n var args = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};\n var _args_cwd;\n var cwd = path.resolve((_args_cwd = args.cwd) !== null && _args_cwd !== void 0 ? _args_cwd : process.cwd());\n var force = !!args.force;\n var check = !!args.check;\n var quiet = !!args.quiet;\n var log = function(msg) {\n if (!quiet) console.info(msg);\n };\n var warn = function(msg) {\n if (!quiet) console.warn(msg);\n };\n var results = [];\n var eject = !!args.eject;\n var bundlerOptions = getBundlerConfigOptionsFromOneOptions(args.oneOptions);\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = FILES[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var file = _step.value;\n var filePath = path.join(cwd, file.name);\n var targetContent = file.getContent({\n eject,\n options: bundlerOptions\n });\n var conflict = file.conflicting.find(function(alt) {\n return existsSync(path.join(cwd, alt));\n });\n if (conflict && !existsSync(filePath)) {\n results.push({\n filePath: path.join(cwd, conflict),\n action: \"skipped-other-format\",\n reason: `Found ${conflict}; not creating ${file.name}. To switch, delete ${conflict} and re-run with --force.`\n });\n warn(colors.yellow(`[one] found ${conflict}. Leaving it alone. Delete it and re-run with --force to switch to ${file.name}.`));\n continue;\n }\n if (!existsSync(filePath)) {\n if (check) {\n results.push({\n filePath,\n action: \"would-write\"\n });\n log(colors.yellow(`[one] missing: ${file.name}`));\n continue;\n }\n writeFileSync(filePath, targetContent);\n results.push({\n filePath,\n action: \"wrote\"\n });\n log(colors.green(`[one] wrote ${file.name}`));\n continue;\n }\n var existing = readFileSync(filePath, \"utf8\");\n if (existing === targetContent) {\n results.push({\n filePath,\n action: \"kept\"\n });\n log(colors.dim(`[one] up to date: ${file.name}`));\n continue;\n }\n var hasMarker = existing.includes(ONE_GENERATED_MARKER);\n if (!hasMarker && !force) {\n results.push({\n filePath,\n action: \"skipped-customized\",\n reason: `${file.name} has been customized (no @one marker). Re-add the marker comment or pass --force to overwrite.`\n });\n warn(colors.yellow(`[one] ${file.name} appears customized. Skipping. Pass --force to overwrite.`));\n continue;\n }\n if (check) {\n results.push({\n filePath,\n action: \"would-overwrite\"\n });\n log(colors.yellow(`[one] out of date: ${file.name}`));\n continue;\n }\n writeFileSync(filePath, targetContent);\n results.push({\n filePath,\n action: \"wrote\"\n });\n log(colors.green(`[one] updated ${file.name}`));\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n var acceptableAlways = /* @__PURE__ */ new Set([\n \"wrote\",\n \"kept\",\n \"skipped-other-format\",\n \"skipped-customized\"\n ]);\n var acceptableInCheck = /* @__PURE__ */ new Set([\n \"kept\",\n \"skipped-other-format\",\n \"skipped-customized\"\n ]);\n var ok = (check ? acceptableInCheck : acceptableAlways).size ? results.every(function(r) {\n return (check ? acceptableInCheck : acceptableAlways).has(r.action);\n }) : false;\n return {\n results,\n ok\n };\n}\nexport {\n ONE_GENERATED_MARKER,\n generateBundlerConfig,\n getBundlerConfigOptionsFromOneOptions\n};\n//# s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oBAAoB,iBAAgB,CAAE,OAAO,QAAQ,MAAM,SAAS,GAAG;EACvF,QAAQ,QAAQ,oBAAoB,iBAAgB,CAAE,IAAI,EAAE,MAAM;CACpE,CAAC,IAAI;CACL,OAAO;EACL;EACA;CACF;AACF"}
1
+ {"version":3,"file":"generateBundlerConfig.native.js","names":[],"sources":["esm/cli/generateBundlerConfig.native.js"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from \"fs\";\nimport path from \"path\";\nimport colors from \"picocolors\";\nimport { getRouterRootFromOneOptions } from \"../utils/getRouterRootFromOneOptions\";\nvar ONE_GENERATED_MARKER = \"@one/generated bundler-config\";\nfunction buildBabelConfigContent(param) {\n var { eject, options } = param;\n var header = eject ? `// you own this file. edit freely. \\`one\\` will not regenerate it.\n// delegates to one/babel-preset which holds the canonical plugin chain.\n` : `// ${ONE_GENERATED_MARKER}\n//\n// auto-generated by \\`one metro-eject\\`. delegates to one/babel-preset so\n// Metro uses the same router/setup options as \\`one dev\\` and \\`one build\\`.\n//\n// to customize, delete this header and edit freely. re-runs will then\n// leave this file alone.\n`;\n return `${header}\nconst oneBabelPreset = require('one/babel-preset')\nconst preset = oneBabelPreset.default || oneBabelPreset\nconst oneBundlerOptions = ${serializeBundlerConfigOptions(options)}\n\nmodule.exports = function (api) {\n return preset(api, oneBundlerOptions)\n}\n`;\n}\nfunction buildMetroConfigContent(param) {\n var { eject, options } = param;\n var header = eject ? `// you own this file. edit freely. \\`one\\` will not regenerate it.\n// withOne() invokes the same Metro pipeline One uses for production bundles.\n` : `// ${ONE_GENERATED_MARKER}\n//\n// auto-generated by \\`one metro-eject\\`. delegates to one/metro-config,\n// which invokes the same metro pipeline One uses for production native\n// bundles with your router and setup options.\n//\n// to customize, delete this header and edit freely. re-runs will then\n// leave this file alone.\n`;\n return `${header}\nconst { withOne } = require('one/metro-config')\nconst oneBundlerOptions = ${serializeBundlerConfigOptions(options)}\n\nmodule.exports = withOne(__dirname, oneBundlerOptions)\n`;\n}\nvar FILES = [\n {\n name: \"babel.config.cjs\",\n getContent: buildBabelConfigContent,\n conflicting: [\n \"babel.config.js\",\n \"babel.config.mjs\",\n \".babelrc\",\n \".babelrc.js\"\n ]\n },\n {\n name: \"metro.config.cjs\",\n getContent: buildMetroConfigContent,\n conflicting: [\n \"metro.config.js\",\n \"metro.config.mjs\"\n ]\n }\n];\nfunction stripUndefined(value) {\n if (Array.isArray(value)) {\n return value.map(stripUndefined);\n }\n if (value && typeof value === \"object\") {\n return Object.fromEntries(Object.entries(value).filter(function(param) {\n var [, entry] = param;\n return entry !== void 0;\n }).map(function(param) {\n var [key, entry] = param;\n return [\n key,\n stripUndefined(entry)\n ];\n }));\n }\n return value;\n}\nfunction assertSerializable(value) {\n var keyPath = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : \"one bundler options\";\n if (typeof value === \"function\" || typeof value === \"symbol\" || typeof value === \"bigint\") {\n throw new Error(`[one] ${keyPath} must be JSON-serializable to generate Babel/Metro config files. Move function-valued native linking/customization into an ejected config.`);\n }\n if (Array.isArray(value)) {\n value.forEach(function(entry2, index) {\n return assertSerializable(entry2, `${keyPath}[${index}]`);\n });\n return;\n }\n if (value && typeof value === \"object\") {\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = Object.entries(value)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var [key, entry] = _step.value;\n assertSerializable(entry, `${keyPath}.${key}`);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n }\n}\nfunction serializeBundlerConfigOptions(options) {\n var clean = stripUndefined(options);\n assertSerializable(clean);\n return JSON.stringify(clean, null, 2);\n}\nfunction getBundlerConfigOptionsFromOneOptions() {\n var oneOptions = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};\n var _oneOptions_router, _oneOptions_router1;\n return stripUndefined({\n routerRoot: getRouterRootFromOneOptions(oneOptions),\n ignoredRouteFiles: (_oneOptions_router = oneOptions.router) === null || _oneOptions_router === void 0 ? void 0 : _oneOptions_router.ignoredRouteFiles,\n linking: (_oneOptions_router1 = oneOptions.router) === null || _oneOptions_router1 === void 0 ? void 0 : _oneOptions_router1.linking,\n setupFile: oneOptions.setupFile\n });\n}\nfunction generateBundlerConfig() {\n var args = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};\n var _args_cwd;\n var cwd = path.resolve((_args_cwd = args.cwd) !== null && _args_cwd !== void 0 ? _args_cwd : process.cwd());\n var force = !!args.force;\n var check = !!args.check;\n var quiet = !!args.quiet;\n var log = function(msg) {\n if (!quiet) console.info(msg);\n };\n var warn = function(msg) {\n if (!quiet) console.warn(msg);\n };\n var results = [];\n var eject = !!args.eject;\n var bundlerOptions = getBundlerConfigOptionsFromOneOptions(args.oneOptions);\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = FILES[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var file = _step.value;\n var filePath = path.join(cwd, file.name);\n var targetContent = file.getContent({\n eject,\n options: bundlerOptions\n });\n var conflict = file.conflicting.find(function(alt) {\n return existsSync(path.join(cwd, alt));\n });\n if (conflict && !existsSync(filePath)) {\n results.push({\n filePath: path.join(cwd, conflict),\n action: \"skipped-other-format\",\n reason: `Found ${conflict}; not creating ${file.name}. To switch, delete ${conflict} and re-run with --force.`\n });\n warn(colors.yellow(`[one] found ${conflict}. Leaving it alone. Delete it and re-run with --force to switch to ${file.name}.`));\n continue;\n }\n if (!existsSync(filePath)) {\n if (check) {\n results.push({\n filePath,\n action: \"would-write\"\n });\n log(colors.yellow(`[one] missing: ${file.name}`));\n continue;\n }\n writeFileSync(filePath, targetContent);\n results.push({\n filePath,\n action: \"wrote\"\n });\n log(colors.green(`[one] wrote ${file.name}`));\n continue;\n }\n var existing = readFileSync(filePath, \"utf8\");\n if (existing === targetContent) {\n results.push({\n filePath,\n action: \"kept\"\n });\n log(colors.dim(`[one] up to date: ${file.name}`));\n continue;\n }\n var hasMarker = existing.includes(ONE_GENERATED_MARKER);\n if (!hasMarker && !force) {\n results.push({\n filePath,\n action: \"skipped-customized\",\n reason: `${file.name} has been customized (no @one marker). Re-add the marker comment or pass --force to overwrite.`\n });\n warn(colors.yellow(`[one] ${file.name} appears customized. Skipping. Pass --force to overwrite.`));\n continue;\n }\n if (check) {\n results.push({\n filePath,\n action: \"would-overwrite\"\n });\n log(colors.yellow(`[one] out of date: ${file.name}`));\n continue;\n }\n writeFileSync(filePath, targetContent);\n results.push({\n filePath,\n action: \"wrote\"\n });\n log(colors.green(`[one] updated ${file.name}`));\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n var acceptableAlways = /* @__PURE__ */ new Set([\n \"wrote\",\n \"kept\",\n \"skipped-other-format\",\n \"skipped-customized\"\n ]);\n var acceptableInCheck = /* @__PURE__ */ new Set([\n \"kept\",\n \"skipped-other-format\",\n \"skipped-customized\"\n ]);\n var ok = (check ? acceptableInCheck : acceptableAlways).size ? results.every(function(r) {\n return (check ? acceptableInCheck : acceptableAlways).has(r.action);\n }) : false;\n return {\n results,\n ok\n };\n}\nexport {\n ONE_GENERATED_MARKER,\n generateBundlerConfig,\n getBundlerConfigOptionsFromOneOptions\n};\n//# sourceMappingURL=generateBundlerConfig.js.map\n"],"mappings":";;;;;;AAIA,IAAI,uBAAuB;AAC3B,SAAS,wBAAwB,OAAO;CACtC,IAAI,EAAE,OAAO,YAAY;CACzB,IAAI,SAAS,QAAQ;;IAEnB,MAAM,qBAAqB;;;;;;;;CAQ7B,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GED
@@ -1,4 +1,4 @@
1
- import { Color, Compose, MenuAction, SplitView, Swift, TextInput, ToolbarHost, ToolbarItem, UI, ZoomTransitionAlignmentRectDetector, ZoomTransitionEnabler, ZoomTransitionSource, useNativeState } from "@vxrn/native";
1
+ import { Browser, Clipboard, Color, Compose, MenuAction, Network, SplitView, Swift, TextInput, ToolbarHost, ToolbarItem, UI, ZoomTransitionAlignmentRectDetector, ZoomTransitionEnabler, ZoomTransitionSource, useNativeState, useNetworkState } from "@vxrn/native";
2
2
  import { SafeAreaProvider, SafeAreaView, initialWindowMetrics, useSafeAreaFrame, useSafeAreaInsets } from "@vxrn/safe-area";
3
3
 
4
4
  function currentPlatform() {
@@ -36,7 +36,11 @@ const One = Object.freeze({
36
36
  },
37
37
  iOS,
38
38
  Android,
39
- UI: UI$1
39
+ UI: UI$1,
40
+ Clipboard,
41
+ Network,
42
+ Browser,
43
+ useNetworkState
40
44
  });
41
45
 
42
46
  export { One };
@@ -1 +1 @@
1
- {"version":3,"file":"one.js","names":["UI","NativeUI"],"sources":["esm/one.js"],"sourcesContent":["import {\n Color,\n Compose,\n MenuAction,\n SplitView,\n Swift,\n TextInput,\n ToolbarHost,\n ToolbarItem,\n UI as NativeUI,\n ZoomTransitionAlignmentRectDetector,\n ZoomTransitionEnabler,\n ZoomTransitionSource,\n useNativeState\n} from \"@vxrn/native\";\nimport {\n SafeAreaProvider,\n SafeAreaView,\n initialWindowMetrics,\n useSafeAreaFrame,\n useSafeAreaInsets\n} from \"@vxrn/safe-area\";\nfunction currentPlatform() {\n const defined = Reflect.get(globalThis, \"__ONE_PLATFORM__\") ?? (typeof process !== \"undefined\" ? process.env.ONE_PLATFORM : void 0);\n return defined === \"ios\" || defined === \"android\" || defined === \"rnx\" ? defined : \"web\";\n}\nconst iOS = Object.freeze({\n ...Swift,\n Color: Color.ios,\n MenuAction,\n SplitView,\n ToolbarHost,\n ToolbarItem,\n ZoomTransitionAlignmentRectDetector,\n ZoomTransitionEnabler,\n ZoomTransitionSource\n});\nconst Android = Object.freeze({\n ...Compose\n});\nconst SafeArea = Object.freeze({\n Provider: SafeAreaProvider,\n View: SafeAreaView,\n initialMetrics: initialWindowMetrics,\n useFrame: useSafeAreaFrame,\n useInsets: useSafeAreaInsets\n});\nconst UI = Object.freeze({\n ...NativeUI,\n SafeArea,\n TextInput,\n useNativeState\n});\nconst One = Object.freeze({\n get platform() {\n return currentPlatform();\n },\n iOS,\n Android,\n UI\n});\nexport {\n One\n};\n//# sourceMappingURL=one.js.map\n"],"mappings":";;;;AAsBA,SAAS,kBAAkB;CACzB,MAAM,UAAU,QAAQ,IAAI,YAAY,kBAAkB,MAAM,OAAO,YAAY,cAAc,QAAQ,IAAI,eAAe,KAAK;CACjI,OAAO,YAAY,SAAS,YAAY,aAAa,YAAY,QAAQ,UAAU;AACrF;AACA,MAAM,MAAM,OAAO,OAAO;CACxB,GAAG;CACH,OAAO,MAAM;CACb;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,MAAM,UAAU,OAAO,OAAO,EAC5B,GAAG,QACL,CAAC;AACD,MAAM,WAAW,OAAO,OAAO;CAC7B,UAAU;CACV,MAAM;CACN,gBAAgB;CAChB,UAAU;CACV,WAAW;AACb,CAAC;AACD,MAAMA,OAAK,OAAO,OAAO;CACvB,GAAGC;CACH;CACA;CACA;AACF,CAAC;AACD,MAAM,MAAM,OAAO,OAAO;CACxB,IAAI,WAAW;EACb,OAAO,gBAAgB;CACzB;CACA;CACA;CACA;AACF,CAAC"}
1
+ {"version":3,"file":"one.js","names":["UI","NativeUI","NativeClipboard","NativeNetwork","NativeBrowser"],"sources":["esm/one.js"],"sourcesContent":["import {\n Browser as NativeBrowser,\n Clipboard as NativeClipboard,\n Color,\n Compose,\n MenuAction,\n Network as NativeNetwork,\n SplitView,\n Swift,\n TextInput,\n ToolbarHost,\n ToolbarItem,\n UI as NativeUI,\n ZoomTransitionAlignmentRectDetector,\n ZoomTransitionEnabler,\n ZoomTransitionSource,\n useNativeState,\n useNetworkState\n} from \"@vxrn/native\";\nimport {\n SafeAreaProvider,\n SafeAreaView,\n initialWindowMetrics,\n useSafeAreaFrame,\n useSafeAreaInsets\n} from \"@vxrn/safe-area\";\nfunction currentPlatform() {\n const defined = Reflect.get(globalThis, \"__ONE_PLATFORM__\") ?? (typeof process !== \"undefined\" ? process.env.ONE_PLATFORM : void 0);\n return defined === \"ios\" || defined === \"android\" || defined === \"rnx\" ? defined : \"web\";\n}\nconst iOS = Object.freeze({\n ...Swift,\n Color: Color.ios,\n MenuAction,\n SplitView,\n ToolbarHost,\n ToolbarItem,\n ZoomTransitionAlignmentRectDetector,\n ZoomTransitionEnabler,\n ZoomTransitionSource\n});\nconst Android = Object.freeze({\n ...Compose\n});\nconst SafeArea = Object.freeze({\n Provider: SafeAreaProvider,\n View: SafeAreaView,\n initialMetrics: initialWindowMetrics,\n useFrame: useSafeAreaFrame,\n useInsets: useSafeAreaInsets\n});\nconst UI = Object.freeze({\n ...NativeUI,\n SafeArea,\n TextInput,\n useNativeState\n});\nconst One = Object.freeze({\n get platform() {\n return currentPlatform();\n },\n iOS,\n Android,\n UI,\n Clipboard: NativeClipboard,\n Network: NativeNetwork,\n Browser: NativeBrowser,\n useNetworkState\n});\nexport {\n One\n};\n//# sourceMappingURL=one.js.map\n"],"mappings":";;;;AA0BA,SAAS,kBAAkB;CACzB,MAAM,UAAU,QAAQ,IAAI,YAAY,kBAAkB,MAAM,OAAO,YAAY,cAAc,QAAQ,IAAI,eAAe,KAAK;CACjI,OAAO,YAAY,SAAS,YAAY,aAAa,YAAY,QAAQ,UAAU;AACrF;AACA,MAAM,MAAM,OAAO,OAAO;CACxB,GAAG;CACH,OAAO,MAAM;CACb;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,MAAM,UAAU,OAAO,OAAO,EAC5B,GAAG,QACL,CAAC;AACD,MAAM,WAAW,OAAO,OAAO;CAC7B,UAAU;CACV,MAAM;CACN,gBAAgB;CAChB,UAAU;CACV,WAAW;AACb,CAAC;AACD,MAAMA,OAAK,OAAO,OAAO;CACvB,GAAGC;CACH;CACA;CACA;AACF,CAAC;AACD,MAAM,MAAM,OAAO,OAAO;CACxB,IAAI,WAAW;EACb,OAAO,gBAAgB;CACzB;CACA;CACA;CACA;CACWC;CACFC;CACAC;CACT;AACF,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Color, Compose, MenuAction, SplitView, Swift, TextInput, ToolbarHost, ToolbarItem, UI, ZoomTransitionAlignmentRectDetector, ZoomTransitionEnabler, ZoomTransitionSource, useNativeState } from "@vxrn/native";
1
+ import { Browser, Clipboard, Color, Compose, MenuAction, Network, SplitView, Swift, TextInput, ToolbarHost, ToolbarItem, UI, ZoomTransitionAlignmentRectDetector, ZoomTransitionEnabler, ZoomTransitionSource, useNativeState, useNetworkState } from "@vxrn/native";
2
2
  import { SafeAreaProvider, SafeAreaView, initialWindowMetrics, useSafeAreaFrame, useSafeAreaInsets } from "@vxrn/safe-area";
3
3
 
4
4
  function currentPlatform() {
@@ -37,7 +37,11 @@ var One = Object.freeze({
37
37
  },
38
38
  iOS,
39
39
  Android,
40
- UI: UI$1
40
+ UI: UI$1,
41
+ Clipboard,
42
+ Network,
43
+ Browser,
44
+ useNetworkState
41
45
  });
42
46
 
43
47
  export { One };
@@ -1 +1 @@
1
- {"version":3,"file":"one.native.js","names":["UI","NativeUI"],"sources":["esm/one.native.js"],"sourcesContent":["import { Color, Compose, MenuAction, SplitView, Swift, TextInput, ToolbarHost, ToolbarItem, UI as NativeUI, ZoomTransitionAlignmentRectDetector, ZoomTransitionEnabler, ZoomTransitionSource, useNativeState } from \"@vxrn/native\";\nimport { SafeAreaProvider, SafeAreaView, initialWindowMetrics, useSafeAreaFrame, useSafeAreaInsets } from \"@vxrn/safe-area\";\nfunction currentPlatform() {\n var _Reflect_get;\n var defined = (_Reflect_get = Reflect.get(globalThis, \"__ONE_PLATFORM__\")) !== null && _Reflect_get !== void 0 ? _Reflect_get : typeof process !== \"undefined\" ? process.env.ONE_PLATFORM : void 0;\n return defined === \"ios\" || defined === \"android\" || defined === \"rnx\" ? defined : \"web\";\n}\nvar iOS = Object.freeze({\n ...Swift,\n Color: Color.ios,\n MenuAction,\n SplitView,\n ToolbarHost,\n ToolbarItem,\n ZoomTransitionAlignmentRectDetector,\n ZoomTransitionEnabler,\n ZoomTransitionSource\n});\nvar Android = Object.freeze({\n ...Compose\n});\nvar SafeArea = Object.freeze({\n Provider: SafeAreaProvider,\n View: SafeAreaView,\n initialMetrics: initialWindowMetrics,\n useFrame: useSafeAreaFrame,\n useInsets: useSafeAreaInsets\n});\nvar UI = Object.freeze({\n ...NativeUI,\n SafeArea,\n TextInput,\n useNativeState\n});\nvar One = Object.freeze({\n get platform() {\n return currentPlatform();\n },\n iOS,\n Android,\n UI\n});\nexport {\n One\n};\n//# sourceMappingURL=one.js.map\n"],"mappings":";;;;AAEA,SAAS,kBAAkB;CACzB,IAAI;CACJ,IAAI,WAAW,eAAe,QAAQ,IAAI,YAAY,kBAAkB,OAAO,QAAQ,iBAAiB,KAAK,IAAI,eAAe,OAAO,YAAY,cAAc,QAAQ,IAAI,eAAe,KAAK;CACjM,OAAO,YAAY,SAAS,YAAY,aAAa,YAAY,QAAQ,UAAU;AACrF;AACA,IAAI,MAAM,OAAO,OAAO;CACtB,GAAG;CACH,OAAO,MAAM;CACb;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,IAAI,UAAU,OAAO,OAAO,EAC1B,GAAG,QACL,CAAC;AACD,IAAI,WAAW,OAAO,OAAO;CAC3B,UAAU;CACV,MAAM;CACN,gBAAgB;CAChB,UAAU;CACV,WAAW;AACb,CAAC;AACD,IAAIA,OAAK,OAAO,OAAO;CACrB,GAAGC;CACH;CACA;CACA;AACF,CAAC;AACD,IAAI,MAAM,OAAO,OAAO;CACtB,IAAI,WAAW;EACb,OAAO,gBAAgB;CACzB;CACA;CACA;CACA;AACF,CAAC"}
1
+ {"version":3,"file":"one.native.js","names":["UI","NativeUI","NativeClipboard","NativeNetwork","NativeBrowser"],"sources":["esm/one.native.js"],"sourcesContent":["import { Browser as NativeBrowser, Clipboard as NativeClipboard, Color, Compose, MenuAction, Network as NativeNetwork, SplitView, Swift, TextInput, ToolbarHost, ToolbarItem, UI as NativeUI, ZoomTransitionAlignmentRectDetector, ZoomTransitionEnabler, ZoomTransitionSource, useNativeState, useNetworkState } from \"@vxrn/native\";\nimport { SafeAreaProvider, SafeAreaView, initialWindowMetrics, useSafeAreaFrame, useSafeAreaInsets } from \"@vxrn/safe-area\";\nfunction currentPlatform() {\n var _Reflect_get;\n var defined = (_Reflect_get = Reflect.get(globalThis, \"__ONE_PLATFORM__\")) !== null && _Reflect_get !== void 0 ? _Reflect_get : typeof process !== \"undefined\" ? process.env.ONE_PLATFORM : void 0;\n return defined === \"ios\" || defined === \"android\" || defined === \"rnx\" ? defined : \"web\";\n}\nvar iOS = Object.freeze({\n ...Swift,\n Color: Color.ios,\n MenuAction,\n SplitView,\n ToolbarHost,\n ToolbarItem,\n ZoomTransitionAlignmentRectDetector,\n ZoomTransitionEnabler,\n ZoomTransitionSource\n});\nvar Android = Object.freeze({\n ...Compose\n});\nvar SafeArea = Object.freeze({\n Provider: SafeAreaProvider,\n View: SafeAreaView,\n initialMetrics: initialWindowMetrics,\n useFrame: useSafeAreaFrame,\n useInsets: useSafeAreaInsets\n});\nvar UI = Object.freeze({\n ...NativeUI,\n SafeArea,\n TextInput,\n useNativeState\n});\nvar One = Object.freeze({\n get platform() {\n return currentPlatform();\n },\n iOS,\n Android,\n UI,\n Clipboard: NativeClipboard,\n Network: NativeNetwork,\n Browser: NativeBrowser,\n useNetworkState\n});\nexport {\n One\n};\n//# sourceMappingURL=one.js.map\n"],"mappings":";;;;AAEA,SAAS,kBAAkB;CACzB,IAAI;CACJ,IAAI,WAAW,eAAe,QAAQ,IAAI,YAAY,kBAAkB,OAAO,QAAQ,iBAAiB,KAAK,IAAI,eAAe,OAAO,YAAY,cAAc,QAAQ,IAAI,eAAe,KAAK;CACjM,OAAO,YAAY,SAAS,YAAY,aAAa,YAAY,QAAQ,UAAU;AACrF;AACA,IAAI,MAAM,OAAO,OAAO;CACtB,GAAG;CACH,OAAO,MAAM;CACb;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,IAAI,UAAU,OAAO,OAAO,EAC1B,GAAG,QACL,CAAC;AACD,IAAI,WAAW,OAAO,OAAO;CAC3B,UAAU;CACV,MAAM;CACN,gBAAgB;CAChB,UAAU;CACV,WAAW;AACb,CAAC;AACD,IAAIA,OAAK,OAAO,OAAO;CACrB,GAAGC;CACH;CACA;CACA;AACF,CAAC;AACD,IAAI,MAAM,OAAO,OAAO;CACtB,IAAI,WAAW;EACb,OAAO,gBAAgB;CACzB;CACA;CACA;CACA;CACWC;CACFC;CACAC;CACT;AACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "one",
3
- "version": "2.0.0-beta.56.1",
3
+ "version": "2.0.0-beta.58.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.56.1",
194
- "@vxrn/compiler": "2.0.0-beta.56.1",
195
- "@vxrn/native": "2.0.0-beta.56.1",
196
- "@vxrn/resolve": "2.0.0-beta.56.1",
197
- "@vxrn/safe-area": "2.0.0-beta.56.1",
198
- "@vxrn/tslib-lite": "2.0.0-beta.56.1",
199
- "@vxrn/use-isomorphic-layout-effect": "2.0.0-beta.56.1",
200
- "@vxrn/utils": "2.0.0-beta.56.1",
201
- "@vxrn/vite-plugin-metro": "2.0.0-beta.56.1",
193
+ "@vxrn/color-scheme": "2.0.0-beta.58.1",
194
+ "@vxrn/compiler": "2.0.0-beta.58.1",
195
+ "@vxrn/native": "2.0.0-beta.58.1",
196
+ "@vxrn/resolve": "2.0.0-beta.58.1",
197
+ "@vxrn/safe-area": "2.0.0-beta.58.1",
198
+ "@vxrn/tslib-lite": "2.0.0-beta.58.1",
199
+ "@vxrn/use-isomorphic-layout-effect": "2.0.0-beta.58.1",
200
+ "@vxrn/utils": "2.0.0-beta.58.1",
201
+ "@vxrn/vite-plugin-metro": "2.0.0-beta.58.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.56.1",
206
+ "create-vxrn": "2.0.0-beta.58.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,13 +222,14 @@
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.56.1",
225
+ "vxrn": "2.0.0-beta.58.1",
226
226
  "web-streams-polyfill": "^4.3.0",
227
227
  "ws": "^8.21.0",
228
228
  "xxhashjs": "^0.2.2"
229
229
  },
230
230
  "peerDependencies": {
231
231
  "@callstack/liquid-glass": ">=0.6.0",
232
+ "@react-native/babel-preset": "^0.87.1",
232
233
  "@react-navigation/drawer": "~8.0.0-alpha.51",
233
234
  "@react-navigation/native": "8.0.0-alpha.44",
234
235
  "react": "^19.2.3",
@@ -241,6 +242,9 @@
241
242
  "sharp": "^0.35.4"
242
243
  },
243
244
  "peerDependenciesMeta": {
245
+ "@react-native/babel-preset": {
246
+ "optional": true
247
+ },
244
248
  "@react-navigation/drawer": {
245
249
  "optional": true
246
250
  },
@@ -21,6 +21,8 @@ describe('one/babel-preset', () => {
21
21
  expect(Array.isArray(result.plugins)).toBe(true)
22
22
  // 5 One plugins + import-meta-env-plugin baked in for standalone Metro
23
23
  expect(result.plugins).toHaveLength(6)
24
+ // @react-native/babel-preset base for TS/Flow syntax + platform transforms
25
+ expect(result.presets).toHaveLength(1)
24
26
  })
25
27
 
26
28
  it('orders the plugin chain so server code is removed before router transforms', () => {
@@ -80,6 +82,9 @@ describe('one/babel-preset', () => {
80
82
  )
81
83
 
82
84
  expect(result.plugins).toEqual([])
85
+ // the one dev path still needs the RN base: the Vite plugin only
86
+ // injected the One chain, not syntax transforms
87
+ expect(result.presets).toHaveLength(1)
83
88
  })
84
89
 
85
90
  it('adds nothing when @vxrn/compiler applies it inside the vite and rolldown pipeline', () => {
@@ -51,15 +51,15 @@ export type OneBabelPresetOptions = {
51
51
  }
52
52
 
53
53
  /**
54
- * one's semantic plugin chain for babel-based Metro transforms. compose it
55
- * after `@react-native/babel-preset`; one's default Rolldown path does not use babel.
54
+ * Standalone babel preset that drops the same plugin chain that the
55
+ * Vite-driven Metro path applies into any `babel.config.{cjs,js,mjs}` file.
56
+ * Builds on `@react-native/babel-preset` for syntax and platform transforms;
57
+ * one's default Rolldown path does not use babel.
56
58
  *
57
59
  * @example
58
60
  * ```js
59
61
  * // babel.config.cjs
60
- * module.exports = {
61
- * presets: ['@react-native/babel-preset', 'one/babel-preset'],
62
- * }
62
+ * module.exports = require('one/babel-preset')
63
63
  * ```
64
64
  */
65
65
  export default function oneBabelPreset(
@@ -89,7 +89,22 @@ export default function oneBabelPreset(
89
89
  options.projectRoot ?? (typeof api?.cwd === 'function' ? api.cwd() : process.cwd())
90
90
  )
91
91
 
92
+ // Babel is the opt-in path, so the RN base resolves from the project, not
93
+ // from one's own dependencies. only the resolve is guarded: a throw from
94
+ // inside the preset itself must surface as-is, not as "not installed".
95
+ const require = createRequire(projectRoot + '/')
96
+ let reactNativePresetPath: string
97
+ try {
98
+ reactNativePresetPath = require.resolve('@react-native/babel-preset')
99
+ } catch {
100
+ throw new Error(
101
+ `[one/babel-preset] Could not resolve '@react-native/babel-preset' from ${projectRoot}. ` +
102
+ `Install it as a project dependency (it ships with every React Native app template).`
103
+ )
104
+ }
105
+
92
106
  return {
107
+ presets: [require(reactNativePresetPath)],
93
108
  plugins: hasViteInjectedOnePlugins
94
109
  ? []
95
110
  : buildOneBabelPlugins({
@@ -1,7 +1,7 @@
1
1
  import path from 'node:path'
2
2
  import { transformSync } from '@babel/core'
3
3
  import { describe, expect, it } from 'vitest'
4
- import oneBabelPreset from './index'
4
+ import oneBabelPreset, { buildOneBabelPlugins } from './index'
5
5
 
6
6
  const projectRoot = path.resolve(__dirname, '../../')
7
7
 
@@ -16,7 +16,20 @@ const projectRoot = path.resolve(__dirname, '../../')
16
16
  * verifies that the preset wires them up correctly.
17
17
  */
18
18
  describe('one/babel-preset integration', () => {
19
- const presetWithOpts = [oneBabelPreset, { projectRoot }] as const
19
+ // wiring tests run the One chain directly so assertions see untransformed
20
+ // modules; syntax tests below run the full preset with its RN base.
21
+ const onePlugins = buildOneBabelPlugins({ projectRoot, relativeRouterRoot: 'app' })
22
+ const presetWithBase = [oneBabelPreset, { projectRoot }] as const
23
+
24
+ // caller the Metro babel transformer sets on the `one dev` path, where the
25
+ // Vite plugin already injected the One chain via customTransformOptions.
26
+ const metroViteCaller = {
27
+ name: 'metro',
28
+ bundler: 'metro',
29
+ platform: 'ios',
30
+ projectRoot,
31
+ oneViteMetroBabelConfig: true,
32
+ }
20
33
 
21
34
  it('runs against a route file without throwing', () => {
22
35
  const code = `
@@ -28,7 +41,7 @@ describe('one/babel-preset integration', () => {
28
41
  const result = transformSync(code, {
29
42
  filename: path.join(projectRoot, 'app/index.tsx'),
30
43
  cwd: projectRoot,
31
- presets: [presetWithOpts],
44
+ plugins: onePlugins,
32
45
  parserOpts: { sourceType: 'module', plugins: ['jsx'] },
33
46
  })
34
47
 
@@ -54,7 +67,7 @@ describe('one/babel-preset integration', () => {
54
67
  const result = transformSync(code, {
55
68
  filename: path.join(projectRoot, 'metro-entry-ctx.js'),
56
69
  cwd: projectRoot,
57
- presets: [presetWithOpts],
70
+ plugins: onePlugins,
58
71
  parserOpts: { sourceType: 'module' },
59
72
  })
60
73
 
@@ -81,10 +94,51 @@ describe('one/babel-preset integration', () => {
81
94
  const result = transformSync(code, {
82
95
  filename: path.join(projectRoot, 'src/utils/x.ts'),
83
96
  cwd: projectRoot,
84
- presets: [presetWithOpts],
97
+ plugins: onePlugins,
85
98
  parserOpts: { sourceType: 'module' },
86
99
  })
87
100
 
88
101
  expect(result?.code).toContain('const x = 1')
89
102
  })
103
+
104
+ it('strips `import type` on the one dev Metro path', () => {
105
+ // every route file is TS. with no base preset Metro dies with
106
+ // `TransformError: Unexpected token, expected "from"` on this line.
107
+ const code = `
108
+ import { Tabs } from 'one'
109
+ import type { BottomTabNavigationOptions } from '@react-navigation/bottom-tabs'
110
+ export default function Layout() {
111
+ return null
112
+ }
113
+ `
114
+ const result = transformSync(code, {
115
+ filename: path.join(projectRoot, 'app/(tabs)/_layout.tsx'),
116
+ cwd: projectRoot,
117
+ presets: [presetWithBase],
118
+ caller: metroViteCaller,
119
+ })
120
+
121
+ expect(result?.code).toBeTruthy()
122
+ expect(result?.code).not.toContain('import type')
123
+ expect(result?.code).toContain('Layout')
124
+ })
125
+
126
+ it('strips flow `import typeof` on the one dev Metro path', () => {
127
+ // react-native/index.js ships `import typeof ... from './index.js.flow'`.
128
+ // unstripped, Metro tries to resolve the .flow file and the iOS bundle
129
+ // 500s with UnableToResolveError.
130
+ const code = `import typeof * as ReactNativePublicAPI from './index.js.flow'
131
+ const x = 1
132
+ module.exports = x
133
+ `
134
+ const result = transformSync(code, {
135
+ filename: path.join(projectRoot, 'node_modules/react-native/index.js'),
136
+ cwd: projectRoot,
137
+ presets: [presetWithBase],
138
+ caller: metroViteCaller,
139
+ })
140
+
141
+ expect(result?.code).toBeTruthy()
142
+ expect(result?.code).not.toContain('index.js.flow')
143
+ })
90
144
  })
@@ -23,8 +23,12 @@ describe('generateBundlerConfig', () => {
23
23
 
24
24
  const babel = fs.readFileSync(path.join(tmpDir, 'babel.config.cjs'), 'utf8')
25
25
  expect(babel).toContain(ONE_GENERATED_MARKER)
26
- expect(babel).toContain("'one/babel-preset'")
27
- expect(babel).toContain("'@react-native/babel-preset'")
26
+ // delegating form: the base preset lives in one/babel-preset, so the
27
+ // generated file must not list @react-native/babel-preset itself or
28
+ // every transform would run the RN chain twice
29
+ expect(babel).toContain("require('one/babel-preset')")
30
+ expect(babel).toContain('preset(api, oneBundlerOptions)')
31
+ expect(babel).not.toContain('@react-native/babel-preset')
28
32
  expect(babel).toContain('oneBundlerOptions')
29
33
 
30
34
  const metro = fs.readFileSync(path.join(tmpDir, 'metro.config.cjs'), 'utf8')
@@ -27,25 +27,24 @@ function buildBabelConfigContent({
27
27
  }) {
28
28
  const header = eject
29
29
  ? `// you own this file. edit freely. \`one\` will not regenerate it.
30
- // composes React Native's Metro preset with One's canonical plugin chain.
30
+ // delegates to one/babel-preset which holds the canonical plugin chain.
31
31
  `
32
32
  : `// ${ONE_GENERATED_MARKER}
33
33
  //
34
- // auto-generated by \`one metro-eject\`. composes React Native's Metro
35
- // preset with One's router/setup transforms.
34
+ // auto-generated by \`one metro-eject\`. delegates to one/babel-preset so
35
+ // Metro uses the same router/setup options as \`one dev\` and \`one build\`.
36
36
  //
37
37
  // to customize, delete this header and edit freely. re-runs will then
38
38
  // leave this file alone.
39
39
  `
40
40
 
41
41
  return `${header}
42
+ const oneBabelPreset = require('one/babel-preset')
43
+ const preset = oneBabelPreset.default || oneBabelPreset
42
44
  const oneBundlerOptions = ${serializeBundlerConfigOptions(options)}
43
45
 
44
- module.exports = {
45
- presets: [
46
- '@react-native/babel-preset',
47
- ['one/babel-preset', oneBundlerOptions],
48
- ],
46
+ module.exports = function (api) {
47
+ return preset(api, oneBundlerOptions)
49
48
  }
50
49
  `
51
50
  }
@@ -255,11 +255,10 @@ console.log('one/native ok ' + url);
255
255
  )
256
256
  writeFileSync(
257
257
  join(appDir, 'babel.config.cjs'),
258
- `module.exports = {
259
- presets: [
260
- '@react-native/babel-preset',
261
- ['one/babel-preset', { projectRoot: __dirname }],
262
- ],
258
+ `const oneBabelPreset = require('one/babel-preset')
259
+ const preset = oneBabelPreset.default || oneBabelPreset
260
+ module.exports = function (api) {
261
+ return preset(api, { projectRoot: __dirname })
263
262
  }\n`
264
263
  )
265
264
  writeFileSync(
package/src/one.test.ts CHANGED
@@ -19,6 +19,16 @@ describe('root One export', () => {
19
19
  expect(One.UI.SafeArea.Provider).toBeTypeOf('function')
20
20
  expect(One.UI.SafeArea.View).toBeTypeOf('object')
21
21
  expect(One.UI.SafeArea.useInsets).toBeTypeOf('function')
22
+ expect(One.Clipboard.getString).toBeTypeOf('function')
23
+ expect(One.Clipboard.setString).toBeTypeOf('function')
24
+ expect(One.Clipboard.hasString).toBeTypeOf('function')
25
+ expect(One.Network.getState).toBeTypeOf('function')
26
+ expect(One.Network.addStateListener).toBeTypeOf('function')
27
+ expect(One.useNetworkState).toBeTypeOf('function')
28
+ expect(One.Browser.open).toBeTypeOf('function')
29
+ expect(One.Browser.dismiss).toBeTypeOf('function')
30
+ expect(One.Browser.openAuthSession).toBeTypeOf('function')
31
+ expect(One.Browser.dismissAuthSession).toBeTypeOf('function')
22
32
  })
23
33
 
24
34
  test('reports the build-time platform without reshaping the API', () => {
package/src/one.ts CHANGED
@@ -2,9 +2,12 @@
2
2
  // contracts of their native frameworks; shared components live under UI.
3
3
 
4
4
  import {
5
+ Browser as NativeBrowser,
6
+ Clipboard as NativeClipboard,
5
7
  Color,
6
8
  Compose,
7
9
  MenuAction,
10
+ Network as NativeNetwork,
8
11
  SplitView,
9
12
  Swift,
10
13
  TextInput,
@@ -16,6 +19,7 @@ import {
16
19
  ZoomTransitionSource,
17
20
  type ColorType,
18
21
  useNativeState,
22
+ useNetworkState,
19
23
  } from '@vxrn/native'
20
24
  import {
21
25
  SafeAreaProvider,
@@ -59,6 +63,10 @@ export type OneAPI = {
59
63
  readonly iOS: Readonly<OneIOS>
60
64
  readonly Android: Readonly<OneAndroid>
61
65
  readonly UI: Readonly<OneUI>
66
+ readonly Clipboard: typeof NativeClipboard
67
+ readonly Network: typeof NativeNetwork
68
+ readonly Browser: typeof NativeBrowser
69
+ readonly useNetworkState: typeof useNetworkState
62
70
  }
63
71
 
64
72
  function currentPlatform(): OnePlatform {
@@ -106,4 +114,8 @@ export const One: OneAPI = Object.freeze({
106
114
  iOS,
107
115
  Android,
108
116
  UI,
117
+ Clipboard: NativeClipboard,
118
+ Network: NativeNetwork,
119
+ Browser: NativeBrowser,
120
+ useNetworkState,
109
121
  })
@@ -34,15 +34,15 @@ export type OneBabelPresetOptions = {
34
34
  includeImportMetaEnv?: boolean;
35
35
  };
36
36
  /**
37
- * one's semantic plugin chain for babel-based Metro transforms. compose it
38
- * after `@react-native/babel-preset`; one's default Rolldown path does not use babel.
37
+ * Standalone babel preset that drops the same plugin chain that the
38
+ * Vite-driven Metro path applies into any `babel.config.{cjs,js,mjs}` file.
39
+ * Builds on `@react-native/babel-preset` for syntax and platform transforms;
40
+ * one's default Rolldown path does not use babel.
39
41
  *
40
42
  * @example
41
43
  * ```js
42
44
  * // babel.config.cjs
43
- * module.exports = {
44
- * presets: ['@react-native/babel-preset', 'one/babel-preset'],
45
- * }
45
+ * module.exports = require('one/babel-preset')
46
46
  * ```
47
47
  */
48
48
  export default function oneBabelPreset(api: BabelConfigAPI, options?: OneBabelPresetOptions): TransformOptions;