diff --git a/example/package.json b/example/package.json index 4a1ba4c5b..f2bd4b9b8 100644 --- a/example/package.json +++ b/example/package.json @@ -15,6 +15,7 @@ "macos": "react-native run-macos --no-packager --scheme Example", "set-react-version": "yarn workspace react-native-test-app set-react-version", "start": "react-native start", + "visionos": "react-native run-visionos", "windows": "react-native run-windows --no-packager" }, "dependencies": { diff --git a/package.json b/package.json index 62d700440..b8d821bd1 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,7 @@ "yoctocolors": "^2.0.0" }, "peerDependencies": { - "@callstack/react-native-visionos": "0.73", + "@callstack/react-native-visionos": "0.73 - 0.74", "@expo/config-plugins": ">=5.0", "react": "17.0.1 - 18.2", "react-native": "0.66 - 0.74 || >=0.75.0-0 <0.75.0", diff --git a/scripts/set-react-version.mjs b/scripts/set-react-version.mjs index ed58753a3..f188b4118 100755 --- a/scripts/set-react-version.mjs +++ b/scripts/set-react-version.mjs @@ -348,22 +348,35 @@ async function getProfile(v, coreOnly) { } default: { - const [reactNative, { version: rnmVersion }, { version: rnwVersion }] = - await Promise.all([ - fetchPackageInfo(`react-native@^${v}.0-0`), - coreOnly - ? Promise.resolve({ version: undefined }) - : fetchPackageInfo(`react-native-macos@^${v}.0-0`), - coreOnly - ? Promise.resolve({ version: undefined }) - : fetchPackageInfo(`react-native-windows@^${v}.0-0`), - ]); + const manifest = /** @type {Manifest} */ (readJSONFile("package.json")); + const visionos = manifest.defaultPlatformPackages?.["visionos"]; + if (!visionos) { + throw new Error("Missing platform package for visionOS"); + } + + const versions = { + core: fetchPackageInfo(`react-native@^${v}.0-0`), + macos: coreOnly + ? Promise.resolve({ version: undefined }) + : fetchPackageInfo(`react-native-macos@^${v}.0-0`), + visionos: coreOnly + ? Promise.resolve({ version: undefined }) + : fetchPackageInfo(`${visionos}@^${v}.0-0`), + windows: coreOnly + ? Promise.resolve({ version: undefined }) + : fetchPackageInfo(`react-native-windows@^${v}.0-0`), + }; + const reactNative = await versions.core; const commonDeps = await resolveCommonDependencies(v, reactNative); + + /** @type {(manifest: Manifest) => string | undefined} */ + const getVersion = ({ version }) => version; return { ...commonDeps, "react-native": reactNative.version, - "react-native-macos": rnmVersion, - "react-native-windows": rnwVersion, + "react-native-macos": await versions.macos.then(getVersion), + "react-native-windows": await versions.windows.then(getVersion), + [visionos]: await versions.visionos.then(getVersion), }; } } diff --git a/yarn.lock b/yarn.lock index b933429cf..d45f2834e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12276,7 +12276,7 @@ __metadata: uuid: "npm:^9.0.0" yoctocolors: "npm:^2.0.0" peerDependencies: - "@callstack/react-native-visionos": 0.73 + "@callstack/react-native-visionos": 0.73 - 0.74 "@expo/config-plugins": ">=5.0" react: 17.0.1 - 18.2 react-native: 0.66 - 0.74 || >=0.75.0-0 <0.75.0