vxrn 2.0.0-beta.99.1 → 2.6.0
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/backgroundComputation.mjs +145 -0
- package/dist/backgroundComputation.mjs.map +1 -0
- package/dist/backgroundComputation.native.js +163 -0
- package/dist/backgroundComputation.native.js.map +1 -0
- package/dist/backgroundComputationNative.mjs +16 -0
- package/dist/backgroundComputationNative.mjs.map +1 -0
- package/dist/backgroundComputationNative.native.js +18 -0
- package/dist/backgroundComputationNative.native.js.map +1 -0
- package/dist/config/getBaseViteConfigOnly.mjs +6 -10
- package/dist/config/getBaseViteConfigOnly.mjs.map +1 -1
- package/dist/config/getBaseViteConfigOnly.native.js +6 -10
- package/dist/config/getBaseViteConfigOnly.native.js.map +1 -1
- package/dist/config/getOptimizeDeps.mjs +2 -1
- package/dist/config/getOptimizeDeps.mjs.map +1 -1
- package/dist/config/getOptimizeDeps.native.js +2 -1
- package/dist/config/getOptimizeDeps.native.js.map +1 -1
- package/dist/config/getViteServerConfig.mjs +13 -0
- package/dist/config/getViteServerConfig.mjs.map +1 -1
- package/dist/config/getViteServerConfig.native.js +15 -1
- package/dist/config/getViteServerConfig.native.js.map +1 -1
- package/dist/constants/defaults.mjs +4 -0
- package/dist/constants/defaults.mjs.map +1 -1
- package/dist/constants/defaults.native.js +4 -0
- package/dist/constants/defaults.native.js.map +1 -1
- package/dist/exports/build.native.js +1 -1
- package/dist/exports/build.native.js.map +1 -1
- package/dist/exports/clean.native.js +1 -1
- package/dist/exports/clean.native.js.map +1 -1
- package/dist/exports/createServer.native.js +2 -2
- package/dist/exports/createServer.native.js.map +1 -1
- package/dist/exports/dev.mjs +3 -0
- package/dist/exports/dev.mjs.map +1 -1
- package/dist/exports/dev.native.js +6 -3
- package/dist/exports/dev.native.js.map +1 -1
- package/dist/exports/loadEnv.native.js +1 -1
- package/dist/exports/loadEnv.native.js.map +1 -1
- package/dist/exports/patch.native.js +1 -1
- package/dist/exports/patch.native.js.map +1 -1
- package/dist/exports/prebuild.mjs +0 -22
- package/dist/exports/prebuild.mjs.map +1 -1
- package/dist/exports/prebuild.native.js +1 -23
- package/dist/exports/prebuild.native.js.map +1 -1
- package/dist/exports/prebuildWithoutExpo.mjs +1116 -178
- package/dist/exports/prebuildWithoutExpo.mjs.map +1 -1
- package/dist/exports/prebuildWithoutExpo.native.js +1592 -243
- package/dist/exports/prebuildWithoutExpo.native.js.map +1 -1
- package/dist/exports/runAndroid.native.js +1 -1
- package/dist/exports/runAndroid.native.js.map +1 -1
- package/dist/exports/runIos.native.js +1 -1
- package/dist/exports/runIos.native.js.map +1 -1
- package/dist/exports/serve.native.js +1 -1
- package/dist/exports/serve.native.js.map +1 -1
- package/dist/exports/serveStaticAssets.native.js +1 -1
- package/dist/exports/serveStaticAssets.native.js.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.mjs +4 -1
- package/dist/index.native.js +4 -1
- package/dist/native-source-contract.mjs +3 -0
- package/dist/native-source-contract.native.js +3 -0
- package/dist/patches/builtInDepPatches.mjs +0 -13
- package/dist/patches/builtInDepPatches.mjs.map +1 -1
- package/dist/patches/builtInDepPatches.native.js +0 -13
- package/dist/patches/builtInDepPatches.native.js.map +1 -1
- package/dist/plugins/autoDepOptimizePlugin.mjs +3 -2
- package/dist/plugins/autoDepOptimizePlugin.mjs.map +1 -1
- package/dist/plugins/autoDepOptimizePlugin.native.js +6 -3
- package/dist/plugins/autoDepOptimizePlugin.native.js.map +1 -1
- package/dist/plugins/backgroundComputationPlugin.mjs +27 -0
- package/dist/plugins/backgroundComputationPlugin.mjs.map +1 -0
- package/dist/plugins/backgroundComputationPlugin.native.js +32 -0
- package/dist/plugins/backgroundComputationPlugin.native.js.map +1 -0
- package/dist/plugins/reactNativeCommonJsPlugin.native.js +3 -3
- package/dist/plugins/reactNativeCommonJsPlugin.native.js.map +1 -1
- package/dist/plugins/reactNativeDevAssetPlugin.mjs +2 -1
- package/dist/plugins/reactNativeDevAssetPlugin.mjs.map +1 -1
- package/dist/plugins/reactNativeDevAssetPlugin.native.js +3 -2
- package/dist/plugins/reactNativeDevAssetPlugin.native.js.map +1 -1
- package/dist/plugins/reactNativeDevServer.mjs +87 -24
- package/dist/plugins/reactNativeDevServer.mjs.map +1 -1
- package/dist/plugins/reactNativeDevServer.native.js +162 -45
- package/dist/plugins/reactNativeDevServer.native.js.map +1 -1
- package/dist/plugins/workletImportsPlugin.mjs +9 -30
- package/dist/plugins/workletImportsPlugin.mjs.map +1 -1
- package/dist/plugins/workletImportsPlugin.native.js +10 -35
- package/dist/plugins/workletImportsPlugin.native.js.map +1 -1
- package/dist/rn-commands/bundle/buildBundle.mjs +3 -3
- package/dist/rn-commands/bundle/buildBundle.mjs.map +1 -1
- package/dist/rn-commands/bundle/buildBundle.native.js +3 -3
- package/dist/rn-commands/bundle/buildBundle.native.js.map +1 -1
- package/dist/runtime/hmr-client.native.js +3 -7
- package/dist/runtime/hmr-client.native.js.map +1 -1
- package/dist/runtime/hmr-runtime.native.js +32 -40
- package/dist/runtime/hmr-runtime.native.js.map +1 -1
- package/dist/serve/node.native.js +2 -2
- package/dist/serve/node.native.js.map +1 -1
- package/dist/swift-package-id.mjs +3 -0
- package/dist/swift-package-id.native.js +3 -0
- package/dist/user-interface/index.native.js +6 -6
- package/dist/user-interface/index.native.js.map +1 -1
- package/dist/utils/compileNativeDevBytecode.mjs +93 -0
- package/dist/utils/compileNativeDevBytecode.mjs.map +1 -0
- package/dist/utils/compileNativeDevBytecode.native.js +98 -0
- package/dist/utils/compileNativeDevBytecode.native.js.map +1 -0
- package/dist/utils/createNativeDevEngine.mjs +227 -20
- package/dist/utils/createNativeDevEngine.mjs.map +1 -1
- package/dist/utils/createNativeDevEngine.native.js +249 -37
- package/dist/utils/createNativeDevEngine.native.js.map +1 -1
- package/dist/utils/execSync.native.js +1 -1
- package/dist/utils/execSync.native.js.map +1 -1
- package/dist/utils/getServerEntry.native.js +2 -2
- package/dist/utils/getServerEntry.native.js.map +1 -1
- package/dist/utils/nativeRun.mjs +32 -16
- package/dist/utils/nativeRun.mjs.map +1 -1
- package/dist/utils/nativeRun.native.js +43 -18
- package/dist/utils/nativeRun.native.js.map +1 -1
- package/dist/utils/nativeSourceContract.mjs +1823 -0
- package/dist/utils/nativeSourceContract.mjs.map +1 -0
- package/dist/utils/nativeSourceContract.native.js +2425 -0
- package/dist/utils/nativeSourceContract.native.js.map +1 -0
- package/dist/utils/patches.native.js +15 -24
- package/dist/utils/patches.native.js.map +1 -1
- package/dist/utils/printServerUrls.native.js +1 -1
- package/dist/utils/printServerUrls.native.js.map +1 -1
- package/dist/utils/scanDepsToOptimize.mjs +7 -1
- package/dist/utils/scanDepsToOptimize.mjs.map +1 -1
- package/dist/utils/scanDepsToOptimize.native.js +27 -2
- package/dist/utils/scanDepsToOptimize.native.js.map +1 -1
- package/dist/utils/swiftPackageId.mjs +31 -2
- package/dist/utils/swiftPackageId.mjs.map +1 -1
- package/dist/utils/swiftPackageId.native.js +50 -2
- package/dist/utils/swiftPackageId.native.js.map +1 -1
- package/dist/vxrn-vite-plugin.native.js +1 -1
- package/dist/vxrn-vite-plugin.native.js.map +1 -1
- package/expo-plugin.cjs +792 -2
- package/native-project-patches.cjs +201 -10
- package/package.json +34 -15
- package/src/backgroundComputation.ts +220 -0
- package/src/backgroundComputationNative.ts +23 -0
- package/src/config/getBaseViteConfigOnly.ts +8 -9
- package/src/config/getOptimizeDeps.ts +3 -1
- package/src/config/getViteServerConfig.ts +16 -0
- package/src/config/glbAssets.test.ts +228 -0
- package/src/constants/defaults.ts +6 -0
- package/src/exports/dev.ts +5 -1
- package/src/exports/expoPlugin.test.mjs +337 -15
- package/src/exports/prebuild.ts +0 -31
- package/src/exports/prebuildWithoutExpo.test.ts +1588 -48
- package/src/exports/prebuildWithoutExpo.ts +1573 -213
- package/src/index.ts +8 -0
- package/src/native-source-contract.ts +16 -0
- package/src/patches/builtInDepPatches.ts +0 -21
- package/src/plugins/autoDepOptimizePlugin.ts +7 -2
- package/src/plugins/backgroundComputationPlugin.test.ts +77 -0
- package/src/plugins/backgroundComputationPlugin.ts +29 -0
- package/src/plugins/reactNativeDevAssetPlugin.ts +5 -1
- package/src/plugins/reactNativeDevServer.test.ts +74 -0
- package/src/plugins/reactNativeDevServer.ts +145 -28
- package/src/plugins/rnCodegenPlugin.test.ts +30 -0
- package/src/plugins/workletImportsPlugin.ts +19 -37
- package/src/rn-commands/bundle/buildBundle.ts +5 -3
- package/src/swift-package-id.ts +1 -0
- package/src/utils/compileNativeDevBytecode.test.ts +168 -0
- package/src/utils/compileNativeDevBytecode.ts +117 -0
- package/src/utils/createNativeDevEngine.test.ts +643 -18
- package/src/utils/createNativeDevEngine.ts +278 -48
- package/src/utils/nativeRun.test.ts +125 -23
- package/src/utils/nativeRun.ts +51 -23
- package/src/utils/nativeSourceArtifacts.test.ts +39 -0
- package/src/utils/nativeSourceContract.test.ts +600 -0
- package/src/utils/nativeSourceContract.ts +1897 -0
- package/src/utils/scanDepsToOptimize.test.ts +80 -0
- package/src/utils/scanDepsToOptimize.ts +18 -7
- package/src/utils/swiftPackageId.ts +25 -1
- package/types/backgroundComputation.d.ts +28 -0
- package/types/backgroundComputation.d.ts.map +1 -0
- package/types/backgroundComputationNative.d.ts +2 -0
- package/types/backgroundComputationNative.d.ts.map +1 -0
- package/types/config/getBaseViteConfigOnly.d.ts.map +1 -1
- package/types/config/getOptimizeDeps.d.ts.map +1 -1
- package/types/config/getViteServerConfig.d.ts.map +1 -1
- package/types/constants/defaults.d.ts.map +1 -1
- package/types/exports/dev.d.ts.map +1 -1
- package/types/exports/prebuild.d.ts.map +1 -1
- package/types/exports/prebuildWithoutExpo.d.ts +6 -0
- package/types/exports/prebuildWithoutExpo.d.ts.map +1 -1
- package/types/index.d.ts +2 -0
- package/types/index.d.ts.map +1 -1
- package/types/native-source-contract.d.ts +2 -0
- package/types/native-source-contract.d.ts.map +1 -0
- package/types/patches/builtInDepPatches.d.ts.map +1 -1
- package/types/plugins/autoDepOptimizePlugin.d.ts.map +1 -1
- package/types/plugins/backgroundComputationPlugin.d.ts +3 -0
- package/types/plugins/backgroundComputationPlugin.d.ts.map +1 -0
- package/types/plugins/reactNativeDevAssetPlugin.d.ts.map +1 -1
- package/types/plugins/reactNativeDevServer.d.ts.map +1 -1
- package/types/plugins/workletImportsPlugin.d.ts.map +1 -1
- package/types/rn-commands/bundle/buildBundle.d.ts.map +1 -1
- package/types/swift-package-id.d.ts +2 -0
- package/types/swift-package-id.d.ts.map +1 -0
- package/types/utils/compileNativeDevBytecode.d.ts +3 -0
- package/types/utils/compileNativeDevBytecode.d.ts.map +1 -0
- package/types/utils/createNativeDevEngine.d.ts +7 -22
- package/types/utils/createNativeDevEngine.d.ts.map +1 -1
- package/types/utils/nativeRun.d.ts.map +1 -1
- package/types/utils/nativeSourceContract.d.ts +121 -0
- package/types/utils/nativeSourceContract.d.ts.map +1 -0
- package/types/utils/scanDepsToOptimize.d.ts +1 -0
- package/types/utils/scanDepsToOptimize.d.ts.map +1 -1
- package/types/utils/swiftPackageId.d.ts +1 -0
- package/types/utils/swiftPackageId.d.ts.map +1 -1
package/dist/utils/nativeRun.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { execFileSync } from "node:child_process";
|
|
2
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
3
3
|
import module from "node:module";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
|
|
@@ -12,6 +12,7 @@ function buildNativeRunCommand(args) {
|
|
|
12
12
|
];
|
|
13
13
|
if (args.simulator) argv.push("--simulator", args.simulator);
|
|
14
14
|
if (args.udid) argv.push("--udid", args.udid);
|
|
15
|
+
if (args.platform === "android" && process.env.ANDROID_SERIAL) argv.push("--device", process.env.ANDROID_SERIAL);
|
|
15
16
|
return {
|
|
16
17
|
command: args.platform === "ios" ? "run-ios" : "run-android",
|
|
17
18
|
argv,
|
|
@@ -26,6 +27,18 @@ async function devServerRunning(port) {
|
|
|
26
27
|
return false;
|
|
27
28
|
}
|
|
28
29
|
}
|
|
30
|
+
function connectedAndroidDevices() {
|
|
31
|
+
const sdk = process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT;
|
|
32
|
+
const adb = sdk ? path.join(sdk, "platform-tools", "adb") : "adb";
|
|
33
|
+
let out;
|
|
34
|
+
try {
|
|
35
|
+
out = execFileSync(adb, ["devices"], { encoding: "utf8" });
|
|
36
|
+
} catch {
|
|
37
|
+
throw new Error(`
|
|
38
|
+
Could not run ${adb}. Install the Android SDK platform tools and set ANDROID_HOME.`);
|
|
39
|
+
}
|
|
40
|
+
return out.split("\n").slice(1).map((line) => line.trim().split(/\s+/)).filter(([serial, state]) => serial && state === "device").map(([serial]) => serial);
|
|
41
|
+
}
|
|
29
42
|
const defaultSpawn = (executable, argv, options) => {
|
|
30
43
|
execFileSync(executable, argv, options);
|
|
31
44
|
};
|
|
@@ -45,9 +58,17 @@ async function nativeRun({ root, platform, port, simulator, udid, spawn = defaul
|
|
|
45
58
|
No dev server running on http://localhost:${resolvedPort} \u2014 the app loads its JS from it.
|
|
46
59
|
Start it first (e.g. \`bun dev\` or \`one dev\`), then re-run this command.`);
|
|
47
60
|
}
|
|
61
|
+
if (platform === "android") {
|
|
62
|
+
const devices = connectedAndroidDevices();
|
|
63
|
+
const serial = process.env.ANDROID_SERIAL;
|
|
64
|
+
if (!devices.length || serial && !devices.includes(serial)) {
|
|
65
|
+
throw new Error(serial ? `
|
|
66
|
+
Android device ${serial} is not connected (connected: ${devices.join(", ") || "none"}).` : "\nNo Android device or emulator is connected. Start an emulator or plug in a device, then re-run this command.");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
48
69
|
process.env.RCT_METRO_PORT = String(resolvedPort);
|
|
49
|
-
const require2 = module.createRequire(
|
|
50
|
-
const cliPackageJson = require2.resolve("@react-native-community/cli/package.json"
|
|
70
|
+
const require2 = module.createRequire(import.meta.url);
|
|
71
|
+
const cliPackageJson = require2.resolve("@react-native-community/cli/package.json");
|
|
51
72
|
const bin = path.join(path.dirname(cliPackageJson), "build", "bin.js");
|
|
52
73
|
spawn(process.execPath, [
|
|
53
74
|
bin,
|
|
@@ -67,19 +88,14 @@ Start it first (e.g. \`bun dev\` or \`one dev\`), then re-run this command.`);
|
|
|
67
88
|
}
|
|
68
89
|
}
|
|
69
90
|
function resolveIosBundleId(root) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
function joinAppJson(root) {
|
|
81
|
-
const file = path.join(root, "app.json");
|
|
82
|
-
return existsSync(file) ? file : null;
|
|
91
|
+
const iosDir = path.join(root, "ios");
|
|
92
|
+
if (!existsSync(iosDir)) return null;
|
|
93
|
+
const project = readdirSync(iosDir).find((entry) => entry.endsWith(".xcodeproj"));
|
|
94
|
+
if (!project) return null;
|
|
95
|
+
const pbxproj = path.join(iosDir, project, "project.pbxproj");
|
|
96
|
+
if (!existsSync(pbxproj)) return null;
|
|
97
|
+
const match = readFileSync(pbxproj, "utf8").match(/PRODUCT_BUNDLE_IDENTIFIER = "?([A-Za-z0-9.-]+)"?;/);
|
|
98
|
+
return match ? match[1] : null;
|
|
83
99
|
}
|
|
84
100
|
function bootedSimulatorUdid() {
|
|
85
101
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nativeRun.js","names":[],"sources":["utils/nativeRun.js"],"sourcesContent":["import { execFileSync } from \"node:child_process\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport module from \"node:module\";\nimport path from \"node:path\";\nfunction buildNativeRunCommand(args) {\n const port = args.port || 8081;\n const argv = [\"--no-packager\", \"--port\", String(port)];\n if (args.simulator) argv.push(\"--simulator\", args.simulator);\n if (args.udid) argv.push(\"--udid\", args.udid);\n return {\n command: args.platform === \"ios\" ? \"run-ios\" : \"run-android\",\n argv,\n port\n };\n}\nasync function devServerRunning(port) {\n try {\n const res = await fetch(`http://localhost:${port}/status`, {\n signal: AbortSignal.timeout(3e3)\n });\n return (await res.text()).includes(\"packager-status:running\");\n } catch {\n return false;\n }\n}\nconst defaultSpawn = (executable, argv, options) => {\n execFileSync(executable, argv, options);\n};\nasync function nativeRun({\n root,\n platform,\n port,\n simulator,\n udid,\n spawn = defaultSpawn\n}) {\n const { fillOptions } = await import(\"../config/getOptionsFilled\");\n const { applyBuiltInPatches } = await import(\"../utils/patches\");\n const options = await fillOptions({ root });\n await applyBuiltInPatches(options);\n const { command, argv, port: resolvedPort } = buildNativeRunCommand({\n platform,\n port,\n simulator,\n udid\n });\n if (!await devServerRunning(resolvedPort)) {\n throw new Error(\n `\nNo dev server running on http://localhost:${resolvedPort} \\u2014 the app loads its JS from it.\nStart it first (e.g. \\`bun dev\\` or \\`one dev\\`), then re-run this command.`\n );\n }\n process.env.RCT_METRO_PORT = String(resolvedPort);\n const require2 = module.createRequire(
|
|
1
|
+
{"version":3,"file":"nativeRun.js","names":[],"sources":["utils/nativeRun.js"],"sourcesContent":["import { execFileSync } from \"node:child_process\";\nimport { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport module from \"node:module\";\nimport path from \"node:path\";\nfunction buildNativeRunCommand(args) {\n const port = args.port || 8081;\n const argv = [\"--no-packager\", \"--port\", String(port)];\n if (args.simulator) argv.push(\"--simulator\", args.simulator);\n if (args.udid) argv.push(\"--udid\", args.udid);\n if (args.platform === \"android\" && process.env.ANDROID_SERIAL)\n argv.push(\"--device\", process.env.ANDROID_SERIAL);\n return {\n command: args.platform === \"ios\" ? \"run-ios\" : \"run-android\",\n argv,\n port\n };\n}\nasync function devServerRunning(port) {\n try {\n const res = await fetch(`http://localhost:${port}/status`, {\n signal: AbortSignal.timeout(3e3)\n });\n return (await res.text()).includes(\"packager-status:running\");\n } catch {\n return false;\n }\n}\nfunction connectedAndroidDevices() {\n const sdk = process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT;\n const adb = sdk ? path.join(sdk, \"platform-tools\", \"adb\") : \"adb\";\n let out;\n try {\n out = execFileSync(adb, [\"devices\"], { encoding: \"utf8\" });\n } catch {\n throw new Error(\n `\nCould not run ${adb}. Install the Android SDK platform tools and set ANDROID_HOME.`\n );\n }\n return out.split(\"\\n\").slice(1).map((line) => line.trim().split(/\\s+/)).filter(([serial, state]) => serial && state === \"device\").map(([serial]) => serial);\n}\nconst defaultSpawn = (executable, argv, options) => {\n execFileSync(executable, argv, options);\n};\nasync function nativeRun({\n root,\n platform,\n port,\n simulator,\n udid,\n spawn = defaultSpawn\n}) {\n const { fillOptions } = await import(\"../config/getOptionsFilled\");\n const { applyBuiltInPatches } = await import(\"../utils/patches\");\n const options = await fillOptions({ root });\n await applyBuiltInPatches(options);\n const { command, argv, port: resolvedPort } = buildNativeRunCommand({\n platform,\n port,\n simulator,\n udid\n });\n if (!await devServerRunning(resolvedPort)) {\n throw new Error(\n `\nNo dev server running on http://localhost:${resolvedPort} \\u2014 the app loads its JS from it.\nStart it first (e.g. \\`bun dev\\` or \\`one dev\\`), then re-run this command.`\n );\n }\n if (platform === \"android\") {\n const devices = connectedAndroidDevices();\n const serial = process.env.ANDROID_SERIAL;\n if (!devices.length || serial && !devices.includes(serial)) {\n throw new Error(\n serial ? `\nAndroid device ${serial} is not connected (connected: ${devices.join(\", \") || \"none\"}).` : \"\\nNo Android device or emulator is connected. Start an emulator or plug in a device, then re-run this command.\"\n );\n }\n }\n process.env.RCT_METRO_PORT = String(resolvedPort);\n const require2 = module.createRequire(import.meta.url);\n const cliPackageJson = require2.resolve(\"@react-native-community/cli/package.json\");\n const bin = path.join(path.dirname(cliPackageJson), \"build\", \"bin.js\");\n spawn(process.execPath, [bin, command, ...argv], {\n cwd: root,\n stdio: \"inherit\",\n env: process.env\n });\n if (platform === \"ios\" && resolvedPort !== 8081) {\n pointSimulatorAtDevServer({ root, udid, port: resolvedPort });\n }\n}\nfunction resolveIosBundleId(root) {\n const iosDir = path.join(root, \"ios\");\n if (!existsSync(iosDir)) return null;\n const project = readdirSync(iosDir).find((entry) => entry.endsWith(\".xcodeproj\"));\n if (!project) return null;\n const pbxproj = path.join(iosDir, project, \"project.pbxproj\");\n if (!existsSync(pbxproj)) return null;\n const match = readFileSync(pbxproj, \"utf8\").match(/PRODUCT_BUNDLE_IDENTIFIER = \"?([A-Za-z0-9.-]+)\"?;/);\n return match ? match[1] : null;\n}\nfunction bootedSimulatorUdid() {\n try {\n const out = execFileSync(\"xcrun\", [\"simctl\", \"list\", \"devices\", \"booted\", \"-j\"], {\n encoding: \"utf8\",\n stdio: [\"ignore\", \"pipe\", \"ignore\"]\n });\n const devices = JSON.parse(out).devices ?? {};\n for (const list of Object.values(devices)) {\n for (const device of list ?? []) {\n if (device?.udid && device.isAvailable !== false) return device.udid;\n }\n }\n return null;\n } catch {\n return null;\n }\n}\nfunction pointSimulatorAtDevServer(args) {\n const udid = args.udid ?? bootedSimulatorUdid();\n const bundleId = resolveIosBundleId(args.root);\n if (!udid || !bundleId) {\n console.warn(\n `\n[one] could not point the simulator at the dev server (udid: ${udid ?? \"none\"}, bundle id: ${bundleId ?? \"none\"}).\nif the app shows \"no script url\", reload it with the bundler host set to localhost:${args.port} in the dev menu.`\n );\n return;\n }\n try {\n execFileSync(\n \"xcrun\",\n [\"simctl\", \"spawn\", udid, \"defaults\", \"write\", bundleId, \"RCT_jsLocation\", `localhost:${args.port}`],\n { stdio: \"pipe\" }\n );\n try {\n execFileSync(\"xcrun\", [\"simctl\", \"terminate\", udid, bundleId], { stdio: \"pipe\" });\n } catch {\n }\n execFileSync(\"xcrun\", [\"simctl\", \"launch\", udid, bundleId], { stdio: \"pipe\" });\n console.info(`[one] pointed ${bundleId} at localhost:${args.port}`);\n } catch {\n console.warn(\n `\n[one] could not write the packager location for ${bundleId}.\nif the app shows \"no script url\", reload it with the bundler host set to localhost:${args.port} in the dev menu.`\n );\n }\n}\nexport {\n buildNativeRun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OAAO,CAAC;EAC7E,QAAQ,KAAK,iBAAiB,SAAS,gBAAgB,KAAK,MAAM;CACpE,QAAQ;EACN,QAAQ,KACN;kDAC4C,SAAS;qFAC0B,KAAK,KAAK,kBAC3F;CACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { execFileSync } from "child_process";
|
|
2
|
-
import { existsSync, readFileSync } from "fs";
|
|
2
|
+
import { existsSync, readFileSync, readdirSync } from "fs";
|
|
3
3
|
import module from "module";
|
|
4
4
|
import path from "path";
|
|
5
5
|
|
|
@@ -12,6 +12,7 @@ function buildNativeRunCommand(args) {
|
|
|
12
12
|
];
|
|
13
13
|
if (args.simulator) argv.push("--simulator", args.simulator);
|
|
14
14
|
if (args.udid) argv.push("--udid", args.udid);
|
|
15
|
+
if (args.platform === "android" && process.env.ANDROID_SERIAL) argv.push("--device", process.env.ANDROID_SERIAL);
|
|
15
16
|
return {
|
|
16
17
|
command: args.platform === "ios" ? "run-ios" : "run-android",
|
|
17
18
|
argv,
|
|
@@ -26,7 +27,27 @@ async function devServerRunning(port) {
|
|
|
26
27
|
return false;
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
+
function connectedAndroidDevices() {
|
|
31
|
+
var sdk = process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT;
|
|
32
|
+
var adb = sdk ? path.join(sdk, "platform-tools", "adb") : "adb";
|
|
33
|
+
var out;
|
|
34
|
+
try {
|
|
35
|
+
out = execFileSync(adb, ["devices"], { encoding: "utf8" });
|
|
36
|
+
} catch (unused) {
|
|
37
|
+
throw new Error(`
|
|
38
|
+
Could not run ${adb}. Install the Android SDK platform tools and set ANDROID_HOME.`);
|
|
39
|
+
}
|
|
40
|
+
return out.split("\n").slice(1).map(function(line) {
|
|
41
|
+
return line.trim().split(/\s+/);
|
|
42
|
+
}).filter(function(param) {
|
|
43
|
+
var [serial, state] = param;
|
|
44
|
+
return serial && state === "device";
|
|
45
|
+
}).map(function(param) {
|
|
46
|
+
var [serial] = param;
|
|
47
|
+
return serial;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
var defaultSpawn = function defaultSpawn2(executable, argv, options) {
|
|
30
51
|
execFileSync(executable, argv, options);
|
|
31
52
|
};
|
|
32
53
|
async function nativeRun(param) {
|
|
@@ -46,9 +67,17 @@ async function nativeRun(param) {
|
|
|
46
67
|
No dev server running on http://localhost:${resolvedPort} \u2014 the app loads its JS from it.
|
|
47
68
|
Start it first (e.g. \`bun dev\` or \`one dev\`), then re-run this command.`);
|
|
48
69
|
}
|
|
70
|
+
if (platform === "android") {
|
|
71
|
+
var devices = connectedAndroidDevices();
|
|
72
|
+
var serial = process.env.ANDROID_SERIAL;
|
|
73
|
+
if (!devices.length || serial && !devices.includes(serial)) {
|
|
74
|
+
throw new Error(serial ? `
|
|
75
|
+
Android device ${serial} is not connected (connected: ${devices.join(", ") || "none"}).` : "\nNo Android device or emulator is connected. Start an emulator or plug in a device, then re-run this command.");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
49
78
|
process.env.RCT_METRO_PORT = String(resolvedPort);
|
|
50
|
-
var require2 = module.createRequire(
|
|
51
|
-
var cliPackageJson = require2.resolve("@react-native-community/cli/package.json"
|
|
79
|
+
var require2 = module.createRequire(import.meta.url);
|
|
80
|
+
var cliPackageJson = require2.resolve("@react-native-community/cli/package.json");
|
|
52
81
|
var bin = path.join(path.dirname(cliPackageJson), "build", "bin.js");
|
|
53
82
|
spawn(process.execPath, [
|
|
54
83
|
bin,
|
|
@@ -68,20 +97,16 @@ Start it first (e.g. \`bun dev\` or \`one dev\`), then re-run this command.`);
|
|
|
68
97
|
}
|
|
69
98
|
}
|
|
70
99
|
function resolveIosBundleId(root) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
function joinAppJson(root) {
|
|
83
|
-
var file = path.join(root, "app.json");
|
|
84
|
-
return existsSync(file) ? file : null;
|
|
100
|
+
var iosDir = path.join(root, "ios");
|
|
101
|
+
if (!existsSync(iosDir)) return null;
|
|
102
|
+
var project = readdirSync(iosDir).find(function(entry) {
|
|
103
|
+
return entry.endsWith(".xcodeproj");
|
|
104
|
+
});
|
|
105
|
+
if (!project) return null;
|
|
106
|
+
var pbxproj = path.join(iosDir, project, "project.pbxproj");
|
|
107
|
+
if (!existsSync(pbxproj)) return null;
|
|
108
|
+
var match = readFileSync(pbxproj, "utf8").match(/PRODUCT_BUNDLE_IDENTIFIER = "?([A-Za-z0-9.-]+)"?;/);
|
|
109
|
+
return match ? match[1] : null;
|
|
85
110
|
}
|
|
86
111
|
function bootedSimulatorUdid() {
|
|
87
112
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nativeRun.native.js","names":[],"sources":["utils/nativeRun.native.js"],"sourcesContent":["import { execFileSync } from \"child_process\";\nimport { existsSync, readFileSync } from \"fs\";\nimport module from \"module\";\nimport path from \"path\";\nfunction buildNativeRunCommand(args) {\n var port = args.port || 8081;\n var argv = [\n \"--no-packager\",\n \"--port\",\n String(port)\n ];\n if (args.simulator) argv.push(\"--simulator\", args.simulator);\n if (args.udid) argv.push(\"--udid\", args.udid);\n return {\n command: args.platform === \"ios\" ? \"run-ios\" : \"run-android\",\n argv,\n port\n };\n}\nasync function devServerRunning(port) {\n try {\n var res = await fetch(`http://localhost:${port}/status`, {\n signal: AbortSignal.timeout(3e3)\n });\n return (await res.text()).includes(\"packager-status:running\");\n } catch (unused) {\n return false;\n }\n}\nvar defaultSpawn = function(executable, argv, options) {\n execFileSync(executable, argv, options);\n};\nasync function nativeRun(param) {\n var { root, platform, port, simulator, udid, spawn = defaultSpawn } = param;\n var { fillOptions } = await import(\"../config/getOptionsFilled\");\n var { applyBuiltInPatches } = await import(\"../utils/patches\");\n var options = await fillOptions({\n root\n });\n await applyBuiltInPatches(options);\n var { command, argv, port: resolvedPort } = buildNativeRunCommand({\n platform,\n port,\n simulator,\n udid\n });\n if (!await devServerRunning(resolvedPort)) {\n throw new Error(`\nNo dev server running on http://localhost:${resolvedPort} \\u2014 the app loads its JS from it.\nStart it first (e.g. \\`bun dev\\` or \\`one dev\\`), then re-run this command.`);\n }\n process.env.RCT_METRO_PORT = String(resolvedPort);\n var require2 = module.createRequire(root + \"/\");\n var cliPackageJson = require2.resolve(\"@react-native-community/cli/package.json\", {\n paths: [\n root\n ]\n });\n var bin = path.join(path.dirname(cliPackageJson), \"build\", \"bin.js\");\n spawn(process.execPath, [\n bin,\n command,\n ...argv\n ], {\n cwd: root,\n stdio: \"inherit\",\n env: process.env\n });\n if (platform === \"ios\" && resolvedPort !== 8081) {\n pointSimulatorAtDevServer({\n root,\n udid,\n port: resolvedPort\n });\n }\n}\nfunction resolveIosBundleId(root) {\n try {\n var _parsed_expo_ios, _parsed_expo;\n var appJson = joinAppJson(root);\n if (!appJson) return null;\n var parsed = JSON.parse(readFileSync(appJson, \"utf8\"));\n var id = parsed === null || parsed === void 0 ? void 0 : (_parsed_expo = parsed.expo) === null || _parsed_expo === void 0 ? void 0 : (_parsed_expo_ios = _parsed_expo.ios) === null || _parsed_expo_ios === void 0 ? void 0 : _parsed_expo_ios.bundleIdentifier;\n return typeof id === \"string\" && id ? id : null;\n } catch (unused) {\n return null;\n }\n}\nfunction joinAppJson(root) {\n var file = path.join(root, \"app.json\");\n return existsSync(file) ? file : null;\n}\nfunction bootedSimulatorUdid() {\n try {\n var _JSON_parse_devices;\n var out = execFileSync(\"xcrun\", [\n \"simctl\",\n \"list\",\n \"devices\",\n \"booted\",\n \"-j\"\n ], {\n encoding: \"utf8\",\n stdio: [\n \"ignore\",\n \"pipe\",\n \"ignore\"\n ]\n });\n var devices = (_JSON_parse_devices = JSON.parse(out).devices) !== null && _JSON_parse_devices !== void 0 ? _JSON_parse_devices : {};\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = Object.values(devices)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var list = _step.value;\n var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;\n try {\n for (var _iterator1 = (list !== null && list !== void 0 ? list : [])[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {\n var device = _step1.value;\n if ((device === null || device === void 0 ? void 0 : device.udid) && device.isAvailable !== false) return device.udid;\n }\n } catch (err) {\n _didIteratorError1 = true;\n _iteratorError1 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion1 && _iterator1.return != null) {\n _iterator1.return();\n }\n } finally {\n if (_didIteratorError1) {\n throw _iteratorError1;\n }\n }\n }\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 return null;\n } catch (unused) {\n return null;\n }\n}\nfunction pointSimulatorAtDevServer(args) {\n var _args_udid;\n var udid = (_args_udid = args.udid) !== null && _args_udid !== void 0 ? _args_udid : bootedSimulatorUdid();\n var bundleId = resolveIosBundleId(args.root);\n if (!udid || !bundleId) {\n console.warn(`\n[one] could not point the simulator at the dev server (udid: ${udid !== null && udid !== void 0 ? udid : \"none\"}, bundle id: ${bundleId !== null && bundleId !== void 0 ? bundleId : \"none\"}).\nif the app shows \"no script url\", reload it with the bundler host set to localhost:${args.port} in the dev menu.`);\n return;\n }\n try {\n execFileSync(\"xcrun\", [\n \"simctl\",\n \"spawn\",\n udid,\n \"defaults\",\n \"write\",\n bundleId,\n \"RCT_jsLocation\",\n `localhost:${args.port}`\n ], {\n stdio: \"pipe\"\n });\n try {\n execFileSync(\"xcrun\", [\n \"simctl\",\n \"terminate\",\n udid,\n bundleId\n ], {\n stdio: \"pipe\"\n });\n } catch (unused) {\n }\n execFileSync(\"xcrun\", [\n \"simctl\",\n \"launch\",\n udid,\n bundleId\n ], {\n stdio: \"pipe\"\n });\n console.info(`[one] pointed ${bundleId} at localhost:${args.port}`);\n } catch (unused) {\n console.warn(`\n[one] could not write the packager location for ${bundleId}.\nif the app shows \"no script url\", reload it with the bundler host set to localhost:${args.port} in the dev menu.`);\n }\n}\nexport {\n buildNativeRunCommand,\n nativeRun,\n resolveIosBundleId\n};\n//# sourceMappingURL=nativeRun.js.map\n"],"mappings":";;;;;;AAIA,SAAS,sBAAsB,MAAM;CACnC,IAAI,OAAO,KAAK,QAAQ;CACxB,IAAI,OAAO;EACT;EACA;EACA,OAAO,IAAI;CACb;CACA,IAAI,KAAK,WAAW,KAAK,KAAK,eAAe,KAAK,SAAS;CAC3D,IAAI,KAAK,MAAM,KAAK,KAAK,UAAU,KAAK,IAAI;CAC5C,OAAO;EACL,SAAS,KAAK,aAAa,QAAQ,YAAY;EAC/C;EACA;CACF;AACF;AACA,eAAe,iBAAiB,MAAM;CACpC,IAAI;EACF,IAAI,MAAM,MAAM,MAAM,oBAAoB,KAAK,UAAU,EACvD,QAAQ,YAAY,QAAQ,GAAG,EACjC,CAAC;EACD,QAAQ,MAAM,IAAI,KAAK,EAAC,CAAE,SAAS,yBAAyB;CAC9D,SAAS,QAAQ;EACf,OAAO;CACT;AACF;AACA,IAAI,eAAe,SAAS,YAAY,MAAM,SAAS;CACrD,aAAa,YAAY,MAAM,OAAO;AACxC;AACA,eAAe,UAAU,OAAO;CAC9B,IAAI,EAAE,MAAM,UAAU,MAAM,WAAW,MAAM,QAAQ,iBAAiB;CACtE,IAAI,EAAE,gBAAgB,MAAM,OAAO;CACnC,IAAI,EAAE,wBAAwB,MAAM,OAAO;CAC3C,IAAI,UAAU,MAAM,YAAY,EAC9B,KACF,CAAC;CACD,MAAM,oBAAoB,OAAO;CACjC,IAAI,EAAE,SAAS,MAAM,MAAM,iBAAiB,sBAAsB;EAChE;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AAI,QAAQ,aAAa,KAAK,UAAU,QAAQ,eAAe,KAAK,IAAI,aAAa,oBAAoB;CACzG,IAAI,WAAW,mBAAmB,KAAK,IAAI;CAC3C,IAAI,CAAC,QAAQ,CAAC,UAAU;EACtB,QAAQ,KAAK;+DAC8C,SAAS,QAAQ,SAAS,KAAK,IAAI,OAAO,OAAO,eAAe,aAAa,QAAQ,aAAa,KAAK,IAAI,WAAW,OAAO;qFACvG,KAAK,KAAK,kBAAkB;EAC7G;CACF;CACA,IAAI;EACF,aAAa,SAAS;GACpB;GACA;GACA;GACA;GACA;GACA;GACA;GACA,aAAa,KAAK;EACpB,GAAG,EACD,OAAO,OACT,CAAC;EACD,IAAI;GACF,aAAa,SAAS;IACpB;IACA;IACA;IACA;GACF,GAAG,EACD,OAAO,OACT,CAAC;EACH,SAAS,QAAQ,CACjB;EACA,aAAa,SAAS;GACpB;GACA;GACA;GACA;EACF,GAAG,EACD,OAAO,OACT,CAAC;EACD,QAAQ,KAAK,iBAAiB,SAAS,gBAAgB,KAAK,MAAM;CACpE,SAAS,QAAQ;EACf,QAAQ,KAAK;kDACiC,SAAS;qFAC0B,KAAK,KAAK,kBAAkB;CAC/G;AACF"}
|
|
1
|
+
{"version":3,"file":"nativeRun.native.js","names":[],"sources":["utils/nativeRun.native.js"],"sourcesContent":["import { execFileSync } from \"child_process\";\nimport { existsSync, readdirSync, readFileSync } from \"fs\";\nimport module from \"module\";\nimport path from \"path\";\nfunction buildNativeRunCommand(args) {\n var port = args.port || 8081;\n var argv = [\n \"--no-packager\",\n \"--port\",\n String(port)\n ];\n if (args.simulator) argv.push(\"--simulator\", args.simulator);\n if (args.udid) argv.push(\"--udid\", args.udid);\n if (args.platform === \"android\" && process.env.ANDROID_SERIAL) argv.push(\"--device\", process.env.ANDROID_SERIAL);\n return {\n command: args.platform === \"ios\" ? \"run-ios\" : \"run-android\",\n argv,\n port\n };\n}\nasync function devServerRunning(port) {\n try {\n var res = await fetch(`http://localhost:${port}/status`, {\n signal: AbortSignal.timeout(3e3)\n });\n return (await res.text()).includes(\"packager-status:running\");\n } catch (unused) {\n return false;\n }\n}\nfunction connectedAndroidDevices() {\n var sdk = process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT;\n var adb = sdk ? path.join(sdk, \"platform-tools\", \"adb\") : \"adb\";\n var out;\n try {\n out = execFileSync(adb, [\n \"devices\"\n ], {\n encoding: \"utf8\"\n });\n } catch (unused) {\n throw new Error(`\nCould not run ${adb}. Install the Android SDK platform tools and set ANDROID_HOME.`);\n }\n return out.split(\"\\n\").slice(1).map(function(line) {\n return line.trim().split(/\\s+/);\n }).filter(function(param) {\n var [serial, state] = param;\n return serial && state === \"device\";\n }).map(function(param) {\n var [serial] = param;\n return serial;\n });\n}\nvar defaultSpawn = function defaultSpawn2(executable, argv, options) {\n execFileSync(executable, argv, options);\n};\nasync function nativeRun(param) {\n var { root, platform, port, simulator, udid, spawn = defaultSpawn } = param;\n var { fillOptions } = await import(\"../config/getOptionsFilled\");\n var { applyBuiltInPatches } = await import(\"../utils/patches\");\n var options = await fillOptions({\n root\n });\n await applyBuiltInPatches(options);\n var { command, argv, port: resolvedPort } = buildNativeRunCommand({\n platform,\n port,\n simulator,\n udid\n });\n if (!await devServerRunning(resolvedPort)) {\n throw new Error(`\nNo dev server running on http://localhost:${resolvedPort} \\u2014 the app loads its JS from it.\nStart it first (e.g. \\`bun dev\\` or \\`one dev\\`), then re-run this command.`);\n }\n if (platform === \"android\") {\n var devices = connectedAndroidDevices();\n var serial = process.env.ANDROID_SERIAL;\n if (!devices.length || serial && !devices.includes(serial)) {\n throw new Error(serial ? `\nAndroid device ${serial} is not connected (connected: ${devices.join(\", \") || \"none\"}).` : \"\\nNo Android device or emulator is connected. Start an emulator or plug in a device, then re-run this command.\");\n }\n }\n process.env.RCT_METRO_PORT = String(resolvedPort);\n var require2 = module.createRequire(import.meta.url);\n var cliPackageJson = require2.resolve(\"@react-native-community/cli/package.json\");\n var bin = path.join(path.dirname(cliPackageJson), \"build\", \"bin.js\");\n spawn(process.execPath, [\n bin,\n command,\n ...argv\n ], {\n cwd: root,\n stdio: \"inherit\",\n env: process.env\n });\n if (platform === \"ios\" && resolvedPort !== 8081) {\n pointSimulatorAtDevServer({\n root,\n udid,\n port: resolvedPort\n });\n }\n}\nfunction resolveIosBundleId(root) {\n var iosDir = path.join(root, \"ios\");\n if (!existsSync(iosDir)) return null;\n var project = readdirSync(iosDir).find(function(entry) {\n return entry.endsWith(\".xcodeproj\");\n });\n if (!project) return null;\n var pbxproj = path.join(iosDir, project, \"project.pbxproj\");\n if (!existsSync(pbxproj)) return null;\n var match = readFileSync(pbxproj, \"utf8\").match(/PRODUCT_BUNDLE_IDENTIFIER = \"?([A-Za-z0-9.-]+)\"?;/);\n return match ? match[1] : null;\n}\nfunction bootedSimulatorUdid() {\n try {\n var _JSON_parse_devices;\n var out = execFileSync(\"xcrun\", [\n \"simctl\",\n \"list\",\n \"devices\",\n \"booted\",\n \"-j\"\n ], {\n encoding: \"utf8\",\n stdio: [\n \"ignore\",\n \"pipe\",\n \"ignore\"\n ]\n });\n var devices = (_JSON_parse_devices = JSON.parse(out).devices) !== null && _JSON_parse_devices !== void 0 ? _JSON_parse_devices : {};\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = Object.values(devices)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var list = _step.value;\n var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;\n try {\n for (var _iterator1 = (list !== null && list !== void 0 ? list : [])[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {\n var device = _step1.value;\n if ((device === null || device === void 0 ? void 0 : device.udid) && device.isAvailable !== false) return device.udid;\n }\n } catch (err) {\n _didIteratorError1 = true;\n _iteratorError1 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion1 && _iterator1.return != null) {\n _iterator1.return();\n }\n } finally {\n if (_didIteratorError1) {\n throw _iteratorError1;\n }\n }\n }\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 return null;\n } catch (unused) {\n return null;\n }\n}\nfunction pointSimulatorAtDevServer(args) {\n var _args_udid;\n var udid = (_args_udid = args.udid) !== null && _args_udid !== void 0 ? _args_udid : bootedSimulatorUdid();\n var bundleId = resolveIosBundleId(args.root);\n if (!udid || !bundleId) {\n console.warn(`\n[one] could not point the simulator at the dev server (udid: ${udid !== null && udid !== void 0 ? udid : \"none\"}, bundle id: ${bundleId !== null && bundleId !== void 0 ? bundleId : \"none\"}).\nif the app shows \"no script url\", reload it with the bundler host set to localhost:${args.port} in the dev menu.`);\n return;\n }\n try {\n execFileSync(\"xcrun\", [\n \"simctl\",\n \"spawn\",\n udid,\n \"defaults\",\n \"write\",\n bundleId,\n \"RCT_jsLocation\",\n `localhost:${args.port}`\n ], {\n stdio: \"pipe\"\n });\n try {\n execFileSync(\"xcrun\", [\n \"simctl\",\n \"terminate\",\n udid,\n bundleId\n ], {\n stdio: \"pipe\"\n });\n } catch (unused) {\n }\n execFileSync(\"xcrun\", [\n \"simctl\",\n \"launch\",\n udid,\n bundleId\n ], {\n stdio: \"pipe\"\n });\n console.info(`[one] pointed ${bundleId} at localhost:${args.port}`);\n } catch (unused) {\n console.warn(`\n[one] could not write the packager location for ${bundleId}.\nif the app shows \"no script url\", reload it with the bundler host set to localhost:${args.port} in the dev menu.`);\n }\n}\nexport {\n buildNativeRunCommand,\n nativeRun,\n resolveIosBundleId\n};\n//# sourceMappingURL=nativeRun.js.map\n"],"mappings":";;;;;;AAIA,SAAS,sBAAsB,MAAM;CACnC,IAAI,OAAO,KAAK,QAAQ;CACxB,IAAI,OAAO;EACT;EACA;EACA,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