vxrn 2.0.0-beta.99.1 → 2.6.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/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/src/utils/nativeRun.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { execFileSync } from 'node:child_process'
|
|
2
|
-
import { existsSync, readFileSync } from 'node:fs'
|
|
2
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs'
|
|
3
3
|
import module from 'node:module'
|
|
4
4
|
import path from 'node:path'
|
|
5
5
|
|
|
@@ -21,6 +21,8 @@ export function buildNativeRunCommand(args: {
|
|
|
21
21
|
// whenever more than one simulator exists.
|
|
22
22
|
if (args.simulator) argv.push('--simulator', args.simulator)
|
|
23
23
|
if (args.udid) argv.push('--udid', args.udid)
|
|
24
|
+
if (args.platform === 'android' && process.env.ANDROID_SERIAL)
|
|
25
|
+
argv.push('--device', process.env.ANDROID_SERIAL)
|
|
24
26
|
return {
|
|
25
27
|
command: args.platform === 'ios' ? 'run-ios' : 'run-android',
|
|
26
28
|
argv,
|
|
@@ -43,6 +45,28 @@ async function devServerRunning(port: number): Promise<boolean> {
|
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
|
|
48
|
+
// community cli logs a missing android device as an error and still exits
|
|
49
|
+
// 0, so a run with no target would read as a successful install. one checks
|
|
50
|
+
// the target itself, with the adb community cli resolves.
|
|
51
|
+
function connectedAndroidDevices(): string[] {
|
|
52
|
+
const sdk = process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT
|
|
53
|
+
const adb = sdk ? path.join(sdk, 'platform-tools', 'adb') : 'adb'
|
|
54
|
+
let out: string
|
|
55
|
+
try {
|
|
56
|
+
out = execFileSync(adb, ['devices'], { encoding: 'utf8' })
|
|
57
|
+
} catch {
|
|
58
|
+
throw new Error(
|
|
59
|
+
`\nCould not run ${adb}. Install the Android SDK platform tools and set ANDROID_HOME.`
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
return out
|
|
63
|
+
.split('\n')
|
|
64
|
+
.slice(1)
|
|
65
|
+
.map((line) => line.trim().split(/\s+/))
|
|
66
|
+
.filter(([serial, state]) => serial && state === 'device')
|
|
67
|
+
.map(([serial]) => serial!)
|
|
68
|
+
}
|
|
69
|
+
|
|
46
70
|
export type NativeRunSpawn = (
|
|
47
71
|
executable: string,
|
|
48
72
|
argv: string[],
|
|
@@ -87,18 +111,27 @@ export async function nativeRun({
|
|
|
87
111
|
)
|
|
88
112
|
}
|
|
89
113
|
|
|
114
|
+
if (platform === 'android') {
|
|
115
|
+
const devices = connectedAndroidDevices()
|
|
116
|
+
const serial = process.env.ANDROID_SERIAL
|
|
117
|
+
if (!devices.length || (serial && !devices.includes(serial))) {
|
|
118
|
+
throw new Error(
|
|
119
|
+
serial
|
|
120
|
+
? `\nAndroid device ${serial} is not connected (connected: ${devices.join(', ') || 'none'}).`
|
|
121
|
+
: '\nNo Android device or emulator is connected. Start an emulator or plug in a device, then re-run this command.'
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
90
126
|
// source-built React-Core bakes RCT_METRO_PORT from this environment
|
|
91
127
|
// into a preprocessor define that RCTBundleURLProvider uses as its
|
|
92
128
|
// default packager port. with prebuilt pods the port is already baked
|
|
93
129
|
// (8081), so the simulator default below is what points the app.
|
|
94
130
|
process.env.RCT_METRO_PORT = String(resolvedPort)
|
|
95
131
|
|
|
96
|
-
//
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
const cliPackageJson = require.resolve('@react-native-community/cli/package.json', {
|
|
100
|
-
paths: [root],
|
|
101
|
-
})
|
|
132
|
+
// vxrn owns the cli; cwd still selects the app's config and native project.
|
|
133
|
+
const require = module.createRequire(import.meta.url)
|
|
134
|
+
const cliPackageJson = require.resolve('@react-native-community/cli/package.json')
|
|
102
135
|
const bin = path.join(path.dirname(cliPackageJson), 'build', 'bin.js')
|
|
103
136
|
|
|
104
137
|
spawn(process.execPath, [bin, command, ...argv], {
|
|
@@ -116,23 +149,18 @@ export async function nativeRun({
|
|
|
116
149
|
// localhost at its baked-in port (8081 with prebuilt pods) and gives up
|
|
117
150
|
// with "no script url" when the dev server lives on one's port. writing
|
|
118
151
|
// the provider's jsLocation default aims it at the real server.
|
|
152
|
+
// the bundle id the built app carries, read from the ios project either
|
|
153
|
+
// prebuild generated, so an app configured by native.app or app.json both
|
|
154
|
+
// resolve.
|
|
119
155
|
export function resolveIosBundleId(root: string): string | null {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
} catch {
|
|
129
|
-
return null
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function joinAppJson(root: string): string | null {
|
|
134
|
-
const file = path.join(root, 'app.json')
|
|
135
|
-
return existsSync(file) ? file : null
|
|
156
|
+
const iosDir = path.join(root, 'ios')
|
|
157
|
+
if (!existsSync(iosDir)) return null
|
|
158
|
+
const project = readdirSync(iosDir).find((entry) => entry.endsWith('.xcodeproj'))
|
|
159
|
+
if (!project) return null
|
|
160
|
+
const pbxproj = path.join(iosDir, project, 'project.pbxproj')
|
|
161
|
+
if (!existsSync(pbxproj)) return null
|
|
162
|
+
const match = readFileSync(pbxproj, 'utf8').match(/PRODUCT_BUNDLE_IDENTIFIER = "?([A-Za-z0-9.-]+)"?;/)
|
|
163
|
+
return match ? match[1] : null
|
|
136
164
|
}
|
|
137
165
|
|
|
138
166
|
function bootedSimulatorUdid(): string | null {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from 'node:fs'
|
|
2
|
+
import { tmpdir } from 'node:os'
|
|
3
|
+
import { join } from 'node:path'
|
|
4
|
+
import { expect, test, vi } from 'vitest'
|
|
5
|
+
import { nativeSourceContract, renderSwiftSourceGlue, writeSwiftPackageArtifacts } from './nativeSourceContract'
|
|
6
|
+
|
|
7
|
+
// directory enumeration order is unspecified and differs between node and bun.
|
|
8
|
+
vi.mock('node:fs', async (importOriginal) => {
|
|
9
|
+
const fs = await importOriginal<typeof import('node:fs')>()
|
|
10
|
+
return {
|
|
11
|
+
...fs,
|
|
12
|
+
readdirSync: (path: import('node:fs').PathLike, options: { withFileTypes: true }) => {
|
|
13
|
+
return fs.readdirSync(path, options)
|
|
14
|
+
.sort((a, b) => a.name < b.name ? 1 : a.name > b.name ? -1 : 0)
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
test('package hash and glue use canonical file order regardless of directory enumeration', () => {
|
|
20
|
+
const root = mkdtempSync(join(tmpdir(), 'one-source-order-'))
|
|
21
|
+
try {
|
|
22
|
+
const pkg = join(root, 'native-source')
|
|
23
|
+
mkdirSync(pkg)
|
|
24
|
+
const audio = '@MainActor final class Audio: PeachModule { init() {}\n func value() -> Double { 1 }\n}'
|
|
25
|
+
const echo = '@MainActor final class Echo: PeachModule { init() {}\n func value() -> Double { 2 }\n}'
|
|
26
|
+
writeFileSync(join(pkg, 'Echo.swift'), echo)
|
|
27
|
+
writeFileSync(join(pkg, 'Audio.swift'), audio)
|
|
28
|
+
const actual = writeSwiftPackageArtifacts(pkg)
|
|
29
|
+
const expected = renderSwiftSourceGlue('native_source', [
|
|
30
|
+
nativeSourceContract(join(pkg, 'Audio.swift'), audio),
|
|
31
|
+
nativeSourceContract(join(pkg, 'Echo.swift'), echo),
|
|
32
|
+
])
|
|
33
|
+
expect(Object.keys(actual.files)).toEqual(['Audio.swift', 'Echo.swift'])
|
|
34
|
+
expect(actual.hash).toBe(expected.hash)
|
|
35
|
+
expect(actual.glue).toBe(expected.source)
|
|
36
|
+
} finally {
|
|
37
|
+
rmSync(root, { recursive: true, force: true })
|
|
38
|
+
}
|
|
39
|
+
})
|