vxrn 2.7.7 → 2.8.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.
- package/dist/config/getBaseViteConfigOnly.mjs +1 -1
- package/dist/config/getBaseViteConfigOnly.mjs.map +1 -1
- package/dist/config/getBaseViteConfigOnly.native.js +1 -1
- package/dist/config/getBaseViteConfigOnly.native.js.map +1 -1
- package/dist/config/getReactNativePlugins.mjs +1 -2
- package/dist/config/getReactNativePlugins.mjs.map +1 -1
- package/dist/config/getReactNativePlugins.native.js +4 -2
- package/dist/config/getReactNativePlugins.native.js.map +1 -1
- package/dist/exports/prebuildWithoutExpo.mjs +26 -97
- package/dist/exports/prebuildWithoutExpo.mjs.map +1 -1
- package/dist/exports/prebuildWithoutExpo.native.js +47 -133
- package/dist/exports/prebuildWithoutExpo.native.js.map +1 -1
- package/dist/plugins/autoDepOptimizePlugin.mjs +5 -2
- package/dist/plugins/autoDepOptimizePlugin.mjs.map +1 -1
- package/dist/plugins/autoDepOptimizePlugin.native.js +10 -7
- package/dist/plugins/autoDepOptimizePlugin.native.js.map +1 -1
- package/dist/rn-commands/bundle/buildBundle.mjs +5 -4
- package/dist/rn-commands/bundle/buildBundle.mjs.map +1 -1
- package/dist/rn-commands/bundle/buildBundle.native.js +5 -4
- package/dist/rn-commands/bundle/buildBundle.native.js.map +1 -1
- package/dist/utils/createNativeDevEngine.mjs +17 -5
- package/dist/utils/createNativeDevEngine.mjs.map +1 -1
- package/dist/utils/createNativeDevEngine.native.js +17 -5
- package/dist/utils/createNativeDevEngine.native.js.map +1 -1
- package/package.json +27 -20
- package/src/config/getBaseViteConfigOnly.ts +1 -1
- package/src/config/getReactNativePlugins.ts +8 -4
- package/src/exports/prebuildWithoutExpo.test.ts +62 -157
- package/src/exports/prebuildWithoutExpo.ts +31 -125
- package/src/plugins/autoDepOptimizeExternal.test.ts +101 -0
- package/src/plugins/autoDepOptimizePlugin.ts +12 -6
- package/src/plugins/rnCodegenPlugin.ts +1 -2
- package/src/rn-commands/bundle/buildBundle.ts +8 -7
- package/src/utils/createNativeDevEngine.test.ts +234 -11
- package/src/utils/createNativeDevEngine.ts +35 -22
- package/types/config/getReactNativePlugins.d.ts +3 -2
- package/types/config/getReactNativePlugins.d.ts.map +1 -1
- package/types/exports/prebuildWithoutExpo.d.ts.map +1 -1
- package/types/plugins/autoDepOptimizePlugin.d.ts +1 -0
- package/types/plugins/autoDepOptimizePlugin.d.ts.map +1 -1
- package/types/plugins/rnCodegenPlugin.d.ts.map +1 -1
- package/types/rn-commands/bundle/buildBundle.d.ts +1 -1
- package/types/rn-commands/bundle/buildBundle.d.ts.map +1 -1
- package/types/utils/createNativeDevEngine.d.ts +3 -4
- package/types/utils/createNativeDevEngine.d.ts.map +1 -1
- package/src/plugins/autoDepOptimizePlugin.test.ts +0 -42
|
@@ -52,7 +52,7 @@ async function getBaseViteConfig(config) {
|
|
|
52
52
|
alias: [
|
|
53
53
|
{
|
|
54
54
|
find: /^react-native\/Libraries\/.*/,
|
|
55
|
-
replacement: resolvePath("@vxrn/
|
|
55
|
+
replacement: resolvePath("@vxrn/utils/empty", import.meta.dirname)
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
58
|
find: /^(react-native\/asset-registry|@react-native\/assets-registry\/registry)$/,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBaseViteConfigOnly.js","names":[],"sources":["config/getBaseViteConfigOnly.js"],"sourcesContent":["import { resolvePath } from \"@vxrn/resolve\";\nimport FSExtra from \"fs-extra\";\nimport { join } from \"node:path\";\nconst dedupe = [\n \"one\",\n \"react\",\n \"react-dom\",\n \"react-dom/client\",\n \"react-native-web\",\n \"react-native-web-lite\",\n \"@react-navigation/core\",\n \"@react-navigation/native\",\n \"@react-navigation/elements\",\n \"@react-navigation/native-stack\",\n \"@react-navigation/bottom-tabs\",\n \"@tamagui/core\",\n \"@tamagui/web\",\n \"@tamagui/adapt\",\n \"@tamagui/react-native-web\",\n \"@tamagui/react-native-web-lite\",\n \"tamagui\",\n \"react-native-reanimated\"\n];\nasync function getBaseViteConfig(config) {\n const { root, mode } = config;\n const postCSSPaths = [\n join(root, \"postcss.config.js\"),\n join(root, \"postcss.config.ts\"),\n join(root, \"postcss.config.json\")\n ];\n const postCSSConfigPath = (await Promise.all(\n postCSSPaths.map(async (x) => {\n if (await FSExtra.pathExists(x)) {\n return x;\n }\n })\n )).find((x) => typeof x === \"string\");\n const reactNativePackageJsonPath = resolvePath(\"react-native/package.json\", root);\n const { version } = await FSExtra.readJSON(reactNativePackageJsonPath);\n return {\n mode,\n assetsInclude: [\"**/*.glb\"],\n // we load the config ourselves\n // if you disable this is disables auto-reloading config changes\n // configFile: false,\n // TODO make this documented / configurable through the plugins\n css: postCSSConfigPath ? {\n postcss: postCSSConfigPath\n } : {\n transformer: \"lightningcss\",\n lightningcss: {\n targets: {\n safari: 15 << 16 | 2 << 8\n }\n }\n },\n define: {\n __DEV__: `${mode === \"development\"}`,\n \"process.env.NODE_ENV\": `\"${mode}\"`,\n \"process.env.REACT_NATIVE_VERSION\": `\"${version}\"`\n },\n resolve: {\n alias: [\n // deep react-native/Libraries/* paths must be caught BEFORE the general\n // react-native → react-native-web alias, since react-native-web doesn't\n // have these native-only subpaths\n {\n find: /^react-native\\/Libraries\\/.*/,\n replacement: resolvePath(\"@vxrn/
|
|
1
|
+
{"version":3,"file":"getBaseViteConfigOnly.js","names":[],"sources":["config/getBaseViteConfigOnly.js"],"sourcesContent":["import { resolvePath } from \"@vxrn/resolve\";\nimport FSExtra from \"fs-extra\";\nimport { join } from \"node:path\";\nconst dedupe = [\n \"one\",\n \"react\",\n \"react-dom\",\n \"react-dom/client\",\n \"react-native-web\",\n \"react-native-web-lite\",\n \"@react-navigation/core\",\n \"@react-navigation/native\",\n \"@react-navigation/elements\",\n \"@react-navigation/native-stack\",\n \"@react-navigation/bottom-tabs\",\n \"@tamagui/core\",\n \"@tamagui/web\",\n \"@tamagui/adapt\",\n \"@tamagui/react-native-web\",\n \"@tamagui/react-native-web-lite\",\n \"tamagui\",\n \"react-native-reanimated\"\n];\nasync function getBaseViteConfig(config) {\n const { root, mode } = config;\n const postCSSPaths = [\n join(root, \"postcss.config.js\"),\n join(root, \"postcss.config.ts\"),\n join(root, \"postcss.config.json\")\n ];\n const postCSSConfigPath = (await Promise.all(\n postCSSPaths.map(async (x) => {\n if (await FSExtra.pathExists(x)) {\n return x;\n }\n })\n )).find((x) => typeof x === \"string\");\n const reactNativePackageJsonPath = resolvePath(\"react-native/package.json\", root);\n const { version } = await FSExtra.readJSON(reactNativePackageJsonPath);\n return {\n mode,\n assetsInclude: [\"**/*.glb\"],\n // we load the config ourselves\n // if you disable this is disables auto-reloading config changes\n // configFile: false,\n // TODO make this documented / configurable through the plugins\n css: postCSSConfigPath ? {\n postcss: postCSSConfigPath\n } : {\n transformer: \"lightningcss\",\n lightningcss: {\n targets: {\n safari: 15 << 16 | 2 << 8\n }\n }\n },\n define: {\n __DEV__: `${mode === \"development\"}`,\n \"process.env.NODE_ENV\": `\"${mode}\"`,\n \"process.env.REACT_NATIVE_VERSION\": `\"${version}\"`\n },\n resolve: {\n alias: [\n // deep react-native/Libraries/* paths must be caught BEFORE the general\n // react-native → react-native-web alias, since react-native-web doesn't\n // have these native-only subpaths\n {\n find: /^react-native\\/Libraries\\/.*/,\n replacement: resolvePath(\"@vxrn/utils/empty\", import.meta.dirname)\n },\n {\n // react native 0.87 removed @react-native/assets-registry, but libraries\n // like react-native-svg still import its registry\n find: /^(react-native\\/asset-registry|@react-native\\/assets-registry\\/registry)$/,\n replacement: \"react-native-web/dist/modules/AssetRegistry\"\n },\n {\n find: \"react-native/package.json\",\n replacement: \"react-native-web/package.json\"\n },\n // named by package so it resolves (from the root, through dedupe) only\n // once something imports react-native: an app with no react-native\n // imports needs no react-native-web.\n {\n find: \"react-native\",\n replacement: \"react-native-web\"\n },\n // bundle size optimizations\n {\n find: \"query-string\",\n replacement: resolvePath(\"@vxrn/query-string\", root)\n },\n {\n find: \"url-parse\",\n replacement: resolvePath(\"@vxrn/url-parse\", root)\n }\n ],\n // TODO auto dedupe all include optimize deps?\n dedupe\n },\n build: {},\n // enable OXC React Refresh so component registration ($RefreshReg$) is\n // injected into TSX/JSX output; the one:react-refresh-web compiler plugin\n // then wraps the output with the runtime preamble and import.meta.hot.accept\n // only enable in dev mode - in production the refresh plugin doesn't run,\n // leaving $RefreshReg$ undefined which crashes client-side JS\n oxc: {\n jsx: {\n refresh: mode === \"development\"\n }\n }\n };\n}\nexport {\n dedupe,\n getBaseViteConfig\n};\n//# sourceMappingURL=getBaseViteConfigOnly.js.map\n"],"mappings":";;;;;AAGA,MAAM,SAAS;CACb;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AACA,eAAe,kBAAkB,QAAQ;CACvC,MAAM,EAAE,MAAM,SAAS;CACvB,MAAM,eAAe;EACnB,KAAK,MAAM,mBAAmB;EAC9B,KAAK,MAAM,mBAAmB;EAC9B,KAAK,MAAM,qBAAqB;CAClC;CACA,MAAM,qBAAqB,MAAM,QAAQ,IACvC,aAAa,IAAI,OAAO,MAAM;EAC5B,IAAI,MAAM,QAAQ,WAAW,CAAC,GAAG;GAC/B,OAAO;EACT;CACF,CAAC,CACH,EAAC,CAAE,MAAM,MAAM,OAAO,MAAM,QAAQ;CACpC,MAAM,6BAA6B,YAAY,6BAA6B,IAAI;CAChF,MAAM,EAAE,YAAY,MAAM,QAAQ,SAAS,0BAA0B;CACrE,OAAO;EACL;EACA,eAAe,CAAC,UAAU;EAK1B,KAAK,oBAAoB,EACvB,SAAS,kBACX,IAAI;GACF,aAAa;GACb,cAAc,EACZ,SAAS,EACP,QAAQ,MAAM,KAAK,KAAK,EAC1B,EACF;EACF;EACA,QAAQ;GACN,SAAS,GAAG,SAAS;GACrB,wBAAwB,IAAI,KAAK;GACjC,oCAAoC,IAAI,QAAQ;EAClD;EACA,SAAS;GACP,OAAO;IAIL;KACE,MAAM;KACN,aAAa,YAAY,qBAAqB,YAAY,OAAO;IACnE;IACA;KAGE,MAAM;KACN,aAAa;IACf;IACA;KACE,MAAM;KACN,aAAa;IACf;IAIA;KACE,MAAM;KACN,aAAa;IACf;IAEA;KACE,MAAM;KACN,aAAa,YAAY,sBAAsB,IAAI;IACrD;IACA;KACE,MAAM;KACN,aAAa,YAAY,mBAAmB,IAAI;IAClD;GACF;GAEA;EACF;EACA,OAAO,CAAC;EAMR,KAAK,EACH,KAAK,EACH,SAAS,SAAS,cACpB,EACF;CACF;AACF"}
|
|
@@ -54,7 +54,7 @@ async function getBaseViteConfig(config) {
|
|
|
54
54
|
alias: [
|
|
55
55
|
{
|
|
56
56
|
find: /^react-native\/Libraries\/.*/,
|
|
57
|
-
replacement: resolvePath("@vxrn/
|
|
57
|
+
replacement: resolvePath("@vxrn/utils/empty", import.meta.dirname)
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
find: /^(react-native\/asset-registry|@react-native\/assets-registry\/registry)$/,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBaseViteConfigOnly.native.js","names":[],"sources":["config/getBaseViteConfigOnly.native.js"],"sourcesContent":["import { resolvePath } from \"@vxrn/resolve\";\nimport FSExtra from \"fs-extra\";\nimport { join } from \"path\";\nvar dedupe = [\n \"one\",\n \"react\",\n \"react-dom\",\n \"react-dom/client\",\n \"react-native-web\",\n \"react-native-web-lite\",\n \"@react-navigation/core\",\n \"@react-navigation/native\",\n \"@react-navigation/elements\",\n \"@react-navigation/native-stack\",\n \"@react-navigation/bottom-tabs\",\n \"@tamagui/core\",\n \"@tamagui/web\",\n \"@tamagui/adapt\",\n \"@tamagui/react-native-web\",\n \"@tamagui/react-native-web-lite\",\n \"tamagui\",\n \"react-native-reanimated\"\n];\nasync function getBaseViteConfig(config) {\n var { root, mode } = config;\n var postCSSPaths = [\n join(root, \"postcss.config.js\"),\n join(root, \"postcss.config.ts\"),\n join(root, \"postcss.config.json\")\n ];\n var postCSSConfigPath = (await Promise.all(postCSSPaths.map(async function(x) {\n if (await FSExtra.pathExists(x)) {\n return x;\n }\n }))).find(function(x) {\n return typeof x === \"string\";\n });\n var reactNativePackageJsonPath = resolvePath(\"react-native/package.json\", root);\n var { version } = await FSExtra.readJSON(reactNativePackageJsonPath);\n return {\n mode,\n assetsInclude: [\n \"**/*.glb\"\n ],\n // we load the config ourselves\n // if you disable this is disables auto-reloading config changes\n // configFile: false,\n // TODO make this documented / configurable through the plugins\n css: postCSSConfigPath ? {\n postcss: postCSSConfigPath\n } : {\n transformer: \"lightningcss\",\n lightningcss: {\n targets: {\n safari: 15 << 16 | 2 << 8\n }\n }\n },\n define: {\n __DEV__: `${mode === \"development\"}`,\n \"process.env.NODE_ENV\": `\"${mode}\"`,\n \"process.env.REACT_NATIVE_VERSION\": `\"${version}\"`\n },\n resolve: {\n alias: [\n // deep react-native/Libraries/* paths must be caught BEFORE the general\n // react-native → react-native-web alias, since react-native-web doesn't\n // have these native-only subpaths\n {\n find: /^react-native\\/Libraries\\/.*/,\n replacement: resolvePath(\"@vxrn/
|
|
1
|
+
{"version":3,"file":"getBaseViteConfigOnly.native.js","names":[],"sources":["config/getBaseViteConfigOnly.native.js"],"sourcesContent":["import { resolvePath } from \"@vxrn/resolve\";\nimport FSExtra from \"fs-extra\";\nimport { join } from \"path\";\nvar dedupe = [\n \"one\",\n \"react\",\n \"react-dom\",\n \"react-dom/client\",\n \"react-native-web\",\n \"react-native-web-lite\",\n \"@react-navigation/core\",\n \"@react-navigation/native\",\n \"@react-navigation/elements\",\n \"@react-navigation/native-stack\",\n \"@react-navigation/bottom-tabs\",\n \"@tamagui/core\",\n \"@tamagui/web\",\n \"@tamagui/adapt\",\n \"@tamagui/react-native-web\",\n \"@tamagui/react-native-web-lite\",\n \"tamagui\",\n \"react-native-reanimated\"\n];\nasync function getBaseViteConfig(config) {\n var { root, mode } = config;\n var postCSSPaths = [\n join(root, \"postcss.config.js\"),\n join(root, \"postcss.config.ts\"),\n join(root, \"postcss.config.json\")\n ];\n var postCSSConfigPath = (await Promise.all(postCSSPaths.map(async function(x) {\n if (await FSExtra.pathExists(x)) {\n return x;\n }\n }))).find(function(x) {\n return typeof x === \"string\";\n });\n var reactNativePackageJsonPath = resolvePath(\"react-native/package.json\", root);\n var { version } = await FSExtra.readJSON(reactNativePackageJsonPath);\n return {\n mode,\n assetsInclude: [\n \"**/*.glb\"\n ],\n // we load the config ourselves\n // if you disable this is disables auto-reloading config changes\n // configFile: false,\n // TODO make this documented / configurable through the plugins\n css: postCSSConfigPath ? {\n postcss: postCSSConfigPath\n } : {\n transformer: \"lightningcss\",\n lightningcss: {\n targets: {\n safari: 15 << 16 | 2 << 8\n }\n }\n },\n define: {\n __DEV__: `${mode === \"development\"}`,\n \"process.env.NODE_ENV\": `\"${mode}\"`,\n \"process.env.REACT_NATIVE_VERSION\": `\"${version}\"`\n },\n resolve: {\n alias: [\n // deep react-native/Libraries/* paths must be caught BEFORE the general\n // react-native → react-native-web alias, since react-native-web doesn't\n // have these native-only subpaths\n {\n find: /^react-native\\/Libraries\\/.*/,\n replacement: resolvePath(\"@vxrn/utils/empty\", import.meta.dirname)\n },\n {\n // react native 0.87 removed @react-native/assets-registry, but libraries\n // like react-native-svg still import its registry\n find: /^(react-native\\/asset-registry|@react-native\\/assets-registry\\/registry)$/,\n replacement: \"react-native-web/dist/modules/AssetRegistry\"\n },\n {\n find: \"react-native/package.json\",\n replacement: \"react-native-web/package.json\"\n },\n // named by package so it resolves (from the root, through dedupe) only\n // once something imports react-native: an app with no react-native\n // imports needs no react-native-web.\n {\n find: \"react-native\",\n replacement: \"react-native-web\"\n },\n // bundle size optimizations\n {\n find: \"query-string\",\n replacement: resolvePath(\"@vxrn/query-string\", root)\n },\n {\n find: \"url-parse\",\n replacement: resolvePath(\"@vxrn/url-parse\", root)\n }\n ],\n // TODO auto dedupe all include optimize deps?\n dedupe\n },\n build: {},\n // enable OXC React Refresh so component registration ($RefreshReg$) is\n // injected into TSX/JSX output; the one:react-refresh-web compiler plugin\n // then wraps the output with the runtime preamble and import.meta.hot.accept\n // only enable in dev mode - in production the refresh plugin doesn't run,\n // leaving $RefreshReg$ undefined which crashes client-side JS\n oxc: {\n jsx: {\n refresh: mode === \"development\"\n }\n }\n };\n}\nexport {\n dedupe,\n getBaseViteConfig\n};\n//# sourceMappingURL=getBaseViteConfigOnly.js.map\n"],"mappings":";;;;;AAGA,IAAI,SAAS;CACX;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AACA,eAAe,kBAAkB,QAAQ;CACvC,IAAI,EAAE,MAAM,SAAS;CACrB,IAAI,eAAe;EACjB,KAAK,MAAM,mBAAmB;EAC9B,KAAK,MAAM,mBAAmB;EAC9B,KAAK,MAAM,qBAAqB;CAClC;CACA,IAAI,qBAAqB,MAAM,QAAQ,IAAI,aAAa,IAAI,eAAe,GAAG;EAC5E,IAAI,MAAM,QAAQ,WAAW,CAAC,GAAG;GAC/B,OAAO;EACT;CACF,CAAC,CAAC,EAAC,CAAE,KAAK,SAAS,GAAG;EACpB,OAAO,OAAO,MAAM;CACtB,CAAC;CACD,IAAI,6BAA6B,YAAY,6BAA6B,IAAI;CAC9E,IAAI,EAAE,YAAY,MAAM,QAAQ,SAAS,0BAA0B;CACnE,OAAO;EACL;EACA,eAAe,CACb,UACF;EAKA,KAAK,oBAAoB,EACvB,SAAS,kBACX,IAAI;GACF,aAAa;GACb,cAAc,EACZ,SAAS,EACP,QAAQ,MAAM,KAAK,KAAK,EAC1B,EACF;EACF;EACA,QAAQ;GACN,SAAS,GAAG,SAAS;GACrB,wBAAwB,IAAI,KAAK;GACjC,oCAAoC,IAAI,QAAQ;EAClD;EACA,SAAS;GACP,OAAO;IAIL;KACE,MAAM;KACN,aAAa,YAAY,qBAAqB,YAAY,OAAO;IACnE;IACA;KAGE,MAAM;KACN,aAAa;IACf;IACA;KACE,MAAM;KACN,aAAa;IACf;IAIA;KACE,MAAM;KACN,aAAa;IACf;IAEA;KACE,MAAM;KACN,aAAa,YAAY,sBAAsB,IAAI;IACrD;IACA;KACE,MAAM;KACN,aAAa,YAAY,mBAAmB,IAAI;IAClD;GACF;GAEA;EACF;EACA,OAAO,CAAC;EAMR,KAAK,EACH,KAAK,EACH,SAAS,SAAS,cACpB,EACF;CACF;AACF"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { metroPlugin } from "@vxrn/vite-plugin-metro";
|
|
2
1
|
import { DEFAULT_ASSET_EXTS } from "../constants/defaults.mjs";
|
|
3
2
|
import { getServerConfigPlugin } from "../plugins/clientInjectPlugin.mjs";
|
|
4
3
|
import { reactNativeDevAssetPlugin } from "../plugins/reactNativeDevAssetPlugin.mjs";
|
|
@@ -11,7 +10,7 @@ function getReactNativePlugins(config, { metro } = {}) {
|
|
|
11
10
|
}
|
|
12
11
|
const metroOptions = metro || globalThis["__vxrnMetroOptions__"];
|
|
13
12
|
if (metroOptions) {
|
|
14
|
-
return [applyBuiltInPatchesPlugin(), metroPlugin(metroOptions)];
|
|
13
|
+
return [applyBuiltInPatchesPlugin(), import("@vxrn/vite-plugin-metro").then(({ metroPlugin }) => metroPlugin(metroOptions))];
|
|
15
14
|
}
|
|
16
15
|
return [
|
|
17
16
|
createReactNativeDevServerPlugin(config),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getReactNativePlugins.js","names":[],"sources":["config/getReactNativePlugins.js"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"getReactNativePlugins.js","names":[],"sources":["config/getReactNativePlugins.js"],"sourcesContent":["import { DEFAULT_ASSET_EXTS } from \"../constants/defaults\";\nimport { getServerConfigPlugin } from \"../plugins/clientInjectPlugin\";\nimport { reactNativeDevAssetPlugin } from \"../plugins/reactNativeDevAssetPlugin\";\nimport { createReactNativeDevServerPlugin } from \"../plugins/reactNativeDevServer\";\nimport { applyBuiltInPatchesPlugin } from \"../plugins/applyBuiltInPatchesPlugin\";\nfunction getReactNativePlugins(config, {\n metro\n} = {}) {\n if (globalThis[\"__vxrnEnableNativeEnv\"] === false) {\n return [];\n }\n const metroOptions = metro || globalThis[\"__vxrnMetroOptions__\"];\n if (metroOptions) {\n return [\n applyBuiltInPatchesPlugin(),\n import(\"@vxrn/vite-plugin-metro\").then(({ metroPlugin }) => metroPlugin(metroOptions))\n ];\n }\n return [\n createReactNativeDevServerPlugin(config),\n getServerConfigPlugin(),\n applyBuiltInPatchesPlugin(),\n reactNativeDevAssetPlugin({\n assetExts: DEFAULT_ASSET_EXTS\n })\n ];\n}\nexport {\n getReactNativePlugins\n};\n//# sourceMappingURL=getReactNativePlugins.js.map\n"],"mappings":";;;;;;;AAKA,SAAS,sBAAsB,QAAQ,EACrC,UACE,CAAC,GAAG;CACN,IAAI,WAAW,6BAA6B,OAAO;EACjD,OAAO,CAAC;CACV;CACA,MAAM,eAAe,SAAS,WAAW;CACzC,IAAI,cAAc;EAChB,OAAO,CACL,0BAA0B,GAC1B,OAAO,0BAA0B,CAAC,MAAM,EAAE,kBAAkB,YAAY,YAAY,CAAC,CACvF;CACF;CACA,OAAO;EACL,iCAAiC,MAAM;EACvC,sBAAsB;EACtB,0BAA0B;EAC1B,0BAA0B,EACxB,WAAW,mBACb,CAAC;CACH;AACF"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { metroPlugin } from "@vxrn/vite-plugin-metro";
|
|
2
1
|
import { DEFAULT_ASSET_EXTS } from "../constants/defaults.native.js";
|
|
3
2
|
import { getServerConfigPlugin } from "../plugins/clientInjectPlugin.native.js";
|
|
4
3
|
import { reactNativeDevAssetPlugin } from "../plugins/reactNativeDevAssetPlugin.native.js";
|
|
@@ -14,7 +13,10 @@ function getReactNativePlugins(config) {
|
|
|
14
13
|
}
|
|
15
14
|
var metroOptions = metro || globalThis["__vxrnMetroOptions__"];
|
|
16
15
|
if (metroOptions) {
|
|
17
|
-
return [applyBuiltInPatchesPlugin(),
|
|
16
|
+
return [applyBuiltInPatchesPlugin(), import("@vxrn/vite-plugin-metro").then(function(param) {
|
|
17
|
+
var { metroPlugin } = param;
|
|
18
|
+
return metroPlugin(metroOptions);
|
|
19
|
+
})];
|
|
18
20
|
}
|
|
19
21
|
return [
|
|
20
22
|
createReactNativeDevServerPlugin(config),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getReactNativePlugins.native.js","names":[],"sources":["config/getReactNativePlugins.native.js"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"getReactNativePlugins.native.js","names":[],"sources":["config/getReactNativePlugins.native.js"],"sourcesContent":["import { DEFAULT_ASSET_EXTS } from \"../constants/defaults\";\nimport { getServerConfigPlugin } from \"../plugins/clientInjectPlugin\";\nimport { reactNativeDevAssetPlugin } from \"../plugins/reactNativeDevAssetPlugin\";\nimport { createReactNativeDevServerPlugin } from \"../plugins/reactNativeDevServer\";\nimport { applyBuiltInPatchesPlugin } from \"../plugins/applyBuiltInPatchesPlugin\";\nfunction getReactNativePlugins(config) {\n var { metro } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : (\n /** Passing a non-null value will enable metro mode */\n {}\n );\n if (globalThis[\"__vxrnEnableNativeEnv\"] === false) {\n return [];\n }\n var metroOptions = metro || globalThis[\"__vxrnMetroOptions__\"];\n if (metroOptions) {\n return [\n applyBuiltInPatchesPlugin(),\n import(\"@vxrn/vite-plugin-metro\").then(function(param) {\n var { metroPlugin } = param;\n return metroPlugin(metroOptions);\n })\n ];\n }\n return [\n createReactNativeDevServerPlugin(config),\n getServerConfigPlugin(),\n applyBuiltInPatchesPlugin(),\n reactNativeDevAssetPlugin({\n assetExts: DEFAULT_ASSET_EXTS\n })\n ];\n}\nexport {\n getReactNativePlugins\n};\n//# sourceMappingURL=getReactNativePlugins.js.map\n"],"mappings":";;;;;;;AAKA,SAAS,sBAAsB,QAAQ;CACrC,IAAI,EAAE,UAAU,UAAU,SAAS,KAAK,UAAU,OAAO,KAAK,IAAI,UAAU;;CAE1E,CAAC;CAEH,IAAI,WAAW,6BAA6B,OAAO;EACjD,OAAO,CAAC;CACV;CACA,IAAI,eAAe,SAAS,WAAW;CACvC,IAAI,cAAc;EAChB,OAAO,CACL,0BAA0B,GAC1B,OAAO,0BAA0B,CAAC,KAAK,SAAS,OAAO;GACrD,IAAI,EAAE,gBAAgB;GACtB,OAAO,YAAY,YAAY;EACjC,CAAC,CACH;CACF;CACA,OAAO;EACL,iCAAiC,MAAM;EACvC,sBAAsB;EACtB,0BAA0B;EAC1B,0BAA0B,EACxB,WAAW,mBACb,CAAC;CACH;AACF"}
|
|
@@ -61,8 +61,6 @@ function patchIosBundlePhase(project, updatesRuntimeVersion) {
|
|
|
61
61
|
function escapeXml(value) {
|
|
62
62
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
63
63
|
}
|
|
64
|
-
const SCENE_DELEGATE_FILE_REF_ID = "1A2B3C4D5E6F7A8B9C0D1E2F";
|
|
65
|
-
const SCENE_DELEGATE_BUILD_FILE_ID = "2B3C4D5E6F7A8B9C0D1E2F1A";
|
|
66
64
|
const PUSH_ENTITLEMENTS_FILE_REF_ID = "3C4D5E6F7A8B9C0D1E2F1A2B";
|
|
67
65
|
function renderSceneDelegateSwift(appName) {
|
|
68
66
|
return `import UIKit
|
|
@@ -88,40 +86,19 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|
|
88
86
|
let window = UIWindow(windowScene: windowScene)
|
|
89
87
|
self.window = window
|
|
90
88
|
|
|
91
|
-
// cold-start links arrive in connectionOptions under scenes, never in
|
|
92
|
-
// the app launchOptions, so they are translated into the launchOptions
|
|
93
|
-
// shape RCTLinkingManager.getInitialURL reads.
|
|
94
|
-
var launchOptions: [UIApplication.LaunchOptionsKey: Any] = [:]
|
|
95
|
-
if let url = connectionOptions.urlContexts.first?.url {
|
|
96
|
-
launchOptions[.url] = url
|
|
97
|
-
}
|
|
98
|
-
if let activity = connectionOptions.userActivities.first(where: {
|
|
99
|
-
$0.activityType == NSUserActivityTypeBrowsingWeb
|
|
100
|
-
}) {
|
|
101
|
-
launchOptions[.userActivityDictionary] = [
|
|
102
|
-
"UIApplicationLaunchOptionsUserActivityTypeKey": activity.activityType,
|
|
103
|
-
"UIApplicationLaunchOptionsUserActivityKey": activity,
|
|
104
|
-
]
|
|
105
|
-
}
|
|
106
|
-
|
|
107
89
|
factory.startReactNative(
|
|
108
90
|
withModuleName: "${appName}",
|
|
109
91
|
in: window,
|
|
110
|
-
|
|
92
|
+
connectionOptions: connectionOptions
|
|
111
93
|
)
|
|
112
94
|
}
|
|
113
95
|
|
|
114
96
|
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
|
|
115
|
-
|
|
116
|
-
RCTLinkingManager.application(UIApplication.shared, open: url, options: [:])
|
|
97
|
+
RCTLinkingManager.scene(scene, openURLContexts: URLContexts)
|
|
117
98
|
}
|
|
118
99
|
|
|
119
100
|
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
|
|
120
|
-
RCTLinkingManager.
|
|
121
|
-
UIApplication.shared,
|
|
122
|
-
continue: userActivity,
|
|
123
|
-
restorationHandler: { _ in }
|
|
124
|
-
)
|
|
101
|
+
RCTLinkingManager.scene(scene, continue: userActivity)
|
|
125
102
|
}
|
|
126
103
|
}
|
|
127
104
|
`;
|
|
@@ -135,64 +112,24 @@ ${insertion}`;
|
|
|
135
112
|
return `${haystack.slice(0, lineEnd + 1)}${insertion}
|
|
136
113
|
${haystack.slice(lineEnd + 1)}`;
|
|
137
114
|
}
|
|
138
|
-
function
|
|
139
|
-
const anchor = " <key>LSRequiresIPhoneOS</key>";
|
|
140
|
-
if (!rendered.includes(anchor)) {
|
|
141
|
-
throw new Error("[vxrn] prebuild template Info.plist lost its LSRequiresIPhoneOS anchor");
|
|
142
|
-
}
|
|
143
|
-
return rendered.replace(anchor, ` <key>UIApplicationSceneManifest</key>
|
|
144
|
-
<dict>
|
|
145
|
-
<key>UIApplicationSupportsMultipleScenes</key>
|
|
146
|
-
<false/>
|
|
147
|
-
<key>UISceneConfigurations</key>
|
|
148
|
-
<dict>
|
|
149
|
-
<key>UIWindowSceneSessionRoleApplication</key>
|
|
150
|
-
<array>
|
|
151
|
-
<dict>
|
|
152
|
-
<key>UISceneConfigurationName</key>
|
|
153
|
-
<string>Default Configuration</string>
|
|
154
|
-
<key>UISceneDelegateClassName</key>
|
|
155
|
-
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
|
|
156
|
-
</dict>
|
|
157
|
-
</array>
|
|
158
|
-
</dict>
|
|
159
|
-
</dict>
|
|
160
|
-
${anchor}`);
|
|
161
|
-
}
|
|
162
|
-
function patchIosAppDelegateSceneLifecycle(rendered, appName, backgroundTasks, appIntents) {
|
|
115
|
+
function patchIosAppDelegateSceneLifecycle(rendered, backgroundTasks, appIntents) {
|
|
163
116
|
const anchor = `@main
|
|
164
117
|
class AppDelegate: UIResponder, UIApplicationDelegate {
|
|
165
|
-
var window: UIWindow?
|
|
166
|
-
|
|
167
|
-
var reactNativeDelegate: ReactNativeDelegate?
|
|
168
|
-
var reactNativeFactory: RCTReactNativeFactory?
|
|
169
|
-
|
|
170
118
|
func application(
|
|
171
119
|
_ application: UIApplication,
|
|
172
120
|
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
|
|
173
121
|
) -> Bool {
|
|
174
|
-
|
|
175
|
-
let factory = RCTReactNativeFactory(delegate: delegate)
|
|
176
|
-
delegate.dependencyProvider = RCTAppDependencyProvider()
|
|
177
|
-
|
|
178
|
-
reactNativeDelegate = delegate
|
|
179
|
-
reactNativeFactory = factory
|
|
180
|
-
|
|
181
|
-
window = UIWindow(frame: UIScreen.main.bounds)
|
|
182
|
-
|
|
183
|
-
factory.startReactNative(
|
|
184
|
-
withModuleName: "${appName}",
|
|
185
|
-
in: window,
|
|
186
|
-
launchOptions: launchOptions
|
|
187
|
-
)
|
|
188
|
-
|
|
189
|
-
return true
|
|
122
|
+
true
|
|
190
123
|
}
|
|
191
124
|
}`;
|
|
192
125
|
if (!rendered.includes(anchor)) {
|
|
193
|
-
throw new Error("[vxrn] prebuild template AppDelegate.swift changed shape: cannot
|
|
126
|
+
throw new Error("[vxrn] prebuild template AppDelegate.swift changed shape: cannot register the app-level React Native factory");
|
|
194
127
|
}
|
|
195
|
-
return rendered.replace(anchor,
|
|
128
|
+
return rendered.replace(anchor, `import React
|
|
129
|
+
import React_RCTAppDelegate
|
|
130
|
+
import ReactAppDependencyProvider
|
|
131
|
+
|
|
132
|
+
@main
|
|
196
133
|
class AppDelegate: UIResponder, UIApplicationDelegate {
|
|
197
134
|
var reactNativeDelegate: ReactNativeDelegate?
|
|
198
135
|
var reactNativeFactory: RCTReactNativeFactory?
|
|
@@ -210,6 +147,16 @@ ${backgroundTasks ? ` OneBackgroundTasksRegisterHost(factory, launchOptions)
|
|
|
210
147
|
` : ""}${appIntents ? ` OneAppIntentsRegisterHost(factory, launchOptions)
|
|
211
148
|
` : ""} return true
|
|
212
149
|
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {
|
|
153
|
+
override func bundleURL() -> URL? {
|
|
154
|
+
#if DEBUG
|
|
155
|
+
RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
|
|
156
|
+
#else
|
|
157
|
+
Bundle.main.url(forResource: "main", withExtension: "jsbundle")
|
|
158
|
+
#endif
|
|
159
|
+
}
|
|
213
160
|
}`);
|
|
214
161
|
}
|
|
215
162
|
const ONE_BRIDGING_HEADER_NAME = "One-Bridging-Header.h";
|
|
@@ -236,23 +183,6 @@ function patchIosPbxprojOneBridgingHeader(project, appName) {
|
|
|
236
183
|
return project.split(anchor).join(`${anchor}
|
|
237
184
|
${setting}`);
|
|
238
185
|
}
|
|
239
|
-
function patchIosPbxprojSceneDelegate(rendered, appName) {
|
|
240
|
-
const edits = [
|
|
241
|
-
["/* AppDelegate.swift in Sources */ = {isa = PBXBuildFile;", ` ${SCENE_DELEGATE_BUILD_FILE_ID} /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = ${SCENE_DELEGATE_FILE_REF_ID} /* SceneDelegate.swift */; };`],
|
|
242
|
-
["/* AppDelegate.swift */ = {isa = PBXFileReference;", ` ${SCENE_DELEGATE_FILE_REF_ID} /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SceneDelegate.swift; path = ${appName}/SceneDelegate.swift; sourceTree = "<group>"; };`],
|
|
243
|
-
["/* AppDelegate.swift */,", ` ${SCENE_DELEGATE_FILE_REF_ID} /* SceneDelegate.swift */,`],
|
|
244
|
-
["/* AppDelegate.swift in Sources */,", ` ${SCENE_DELEGATE_BUILD_FILE_ID} /* SceneDelegate.swift in Sources */,`]
|
|
245
|
-
];
|
|
246
|
-
let patched = rendered;
|
|
247
|
-
for (const [anchor, insertion] of edits) {
|
|
248
|
-
const next = insertAfterLine(patched, anchor, insertion);
|
|
249
|
-
if (next === patched) {
|
|
250
|
-
throw new Error(`[vxrn] prebuild template project.pbxproj lost its AppDelegate.swift anchor (${anchor})`);
|
|
251
|
-
}
|
|
252
|
-
patched = next;
|
|
253
|
-
}
|
|
254
|
-
return patched;
|
|
255
|
-
}
|
|
256
186
|
function patchIosPbxprojAppIntents(rendered, appName) {
|
|
257
187
|
const name = "OneAppIntents.swift";
|
|
258
188
|
const fileRef = pbxprojId("one-app-intents-file");
|
|
@@ -1942,10 +1872,9 @@ ${schemes.map((scheme) => ` <data android:scheme="${scheme}" />`).joi
|
|
|
1942
1872
|
`).join("")}${anchor}`);
|
|
1943
1873
|
}
|
|
1944
1874
|
rendered = rendered.replace(/\t<key>NS\w+UsageDescription<\/key>\s*<string><\/string>\n/g, "");
|
|
1945
|
-
rendered = patchIosInfoPlistSceneManifest(rendered);
|
|
1946
1875
|
}
|
|
1947
1876
|
if (platform === "ios" && relativePath.endsWith("/AppDelegate.swift")) {
|
|
1948
|
-
rendered = patchIosAppDelegateSceneLifecycle(rendered,
|
|
1877
|
+
rendered = patchIosAppDelegateSceneLifecycle(rendered, !!app.ios?.backgroundTasks, !!app.ios?.appIntents);
|
|
1949
1878
|
rendered = nativeProjectPatches.holdLaunchScreenOverRootView(rendered);
|
|
1950
1879
|
const bundleURLProvider = "RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: \"index\")";
|
|
1951
1880
|
if (!rendered.includes(bundleURLProvider)) {
|
|
@@ -1960,14 +1889,15 @@ ${schemes.map((scheme) => ` <data android:scheme="${scheme}" />`).joi
|
|
|
1960
1889
|
rendered = nativeProjectPatches.pointReleaseBundleURLAtOneUpdates(rendered);
|
|
1961
1890
|
}
|
|
1962
1891
|
}
|
|
1963
|
-
if (platform === "ios"
|
|
1964
|
-
|
|
1892
|
+
if (platform === "ios") {
|
|
1893
|
+
const deploymentTarget = app.ios?.deploymentTarget ?? "17.0";
|
|
1894
|
+
rendered = rendered.replace("platform :ios, min_ios_version_supported", `platform :ios, '${deploymentTarget}'`).replace(/IPHONEOS_DEPLOYMENT_TARGET = \d+(?:\.\d+)?;/g, `IPHONEOS_DEPLOYMENT_TARGET = ${deploymentTarget};`);
|
|
1965
1895
|
if (relativePath === "Podfile") {
|
|
1966
1896
|
rendered = rendered.replace(" )\n end\nend", ` )
|
|
1967
1897
|
|
|
1968
1898
|
installer.pods_project.targets.each do |target|
|
|
1969
1899
|
target.build_configurations.each do |config|
|
|
1970
|
-
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '${
|
|
1900
|
+
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '${deploymentTarget}'
|
|
1971
1901
|
end
|
|
1972
1902
|
end
|
|
1973
1903
|
end
|
|
@@ -1976,7 +1906,6 @@ end`);
|
|
|
1976
1906
|
}
|
|
1977
1907
|
if (platform === "ios" && relativePath.endsWith(".xcodeproj/project.pbxproj")) {
|
|
1978
1908
|
rendered = patchIosBundlePhase(rendered, app.updates?.runtimeVersion);
|
|
1979
|
-
rendered = patchIosPbxprojSceneDelegate(rendered, appName);
|
|
1980
1909
|
if (app.ios?.appIntents) rendered = patchIosPbxprojAppIntents(rendered, appName);
|
|
1981
1910
|
rendered = patchIosPbxprojOneBridgingHeader(rendered, appName);
|
|
1982
1911
|
if (Object.keys(appEntitlements(app)).length && !app.ios?.widgets) {
|