peachsim 0.1.1808 → 0.1.1812
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/README.md +4 -2
- package/cli/app-bundle-resources.ts +15 -2
- package/cli/cloud-box-artifact.ts +115 -0
- package/cli/cloud-client.ts +148 -76
- package/cli/cloud-dispatch.ts +4 -4
- package/cli/cloud-session.ts +60 -22
- package/cli/commands/box.ts +8 -2
- package/cli/commands/compat.ts +7 -4
- package/cli/commands/control.ts +69 -3
- package/cli/commands/coverage.ts +14 -4
- package/cli/commands/daemon.ts +41 -0
- package/cli/commands/no-bridge-hint.ts +9 -0
- package/cli/commands/package.ts +31 -56
- package/cli/commands/platform.ts +71 -60
- package/cli/commands/preview.ts +73 -24
- package/cli/commands/record.ts +10 -2
- package/cli/commands/screenshot.ts +17 -60
- package/cli/commands/setup.ts +3 -1
- package/cli/commands/three-mode.ts +22 -12
- package/cli/commands/upload.ts +2 -1
- package/cli/desktop-companion.ts +6 -1
- package/cli/drivers/desktop.ts +4 -1
- package/cli/main.ts +12 -2
- package/cli/metro-bundle-assets.ts +14 -4
- package/cli/outbound-endpoints.ts +7 -3
- package/cli/output-redaction.ts +38 -0
- package/cli/privacy.ts +2 -2
- package/cli/recording-access.ts +5 -0
- package/cli/remote-project-bundle.ts +83 -0
- package/cli/shell-init.ts +7 -11
- package/cli/telemetry.ts +41 -4
- package/cli/usage-error.ts +3 -0
- package/cli/ws-bridge.ts +42 -6
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +42897 -40755
- package/dist-lib/capture-contract.cjs +7 -8
- package/dist-lib/capture-contract.mjs +7 -8
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +13 -7
- package/dist-lib/dev-bundle-resolution.cjs +10 -4
- package/dist-lib/expo-swift-bundle.cjs +15889 -15553
- package/dist-lib/expo-swift-metadata.cjs +2 -1
- package/dist-lib/expo-swift-metadata.mjs +2 -1
- package/dist-lib/home-paths.cjs +2 -33
- package/dist-lib/host/bridge-host.cjs +20891 -18714
- package/dist-lib/host/fetch-proxy-handler.cjs +10 -11
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +620 -553
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +57 -28
- package/dist-lib/native-app-identity-project.cjs +47 -14
- package/dist-lib/native-app-identity-project.mjs +55 -20
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +27 -26
- package/dist-lib/public-origins-lib.json +104 -81
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +30700 -24410
- package/dist-lib/swift-compile.cjs +336 -222
- package/dist-lib/swift-compile.mjs +378 -263
- package/dist-lib/swift-package.cjs +19 -7
- package/dist-lib/swift-package.mjs +16 -6
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +49 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +19213 -18937
- package/dist-lib/vite.cjs +11 -12
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/engine/animated.d.ts +4 -0
- package/dist-types/packages/peach-engine/src/engine/animation-graph.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/expo-manifest.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/preview/upload-protocol.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +8 -1
- package/dist-types/packages/peach-globals/src/electronBridgeContract.d.ts +2 -1
- package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTCall.h +1 -1
- package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTCallCenter.h +1 -1
- package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTCarrier.h +1 -1
- package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTSubscriber.h +1 -1
- package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTSubscriberInfo.h +1 -1
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSArray.h +1 -1
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSDictionary.h +1 -1
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSExtensionItem.h +1 -1
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/AVFoundation+MPNowPlayingInfoLanguageOptionAdditions.h +39 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/AVPlayerItem+MediaPlayerAdditions.h +26 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPContentItem.h +67 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPError.h +33 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaEntity.h +53 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaItem.h +346 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaItemCollection.h +42 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaLibrary.h +76 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaPickerController.h +64 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaPlayback.h +47 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaPlaylist.h +82 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaQuery.h +120 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaQuerySection.h +26 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMoviePlayerController.h +444 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMoviePlayerViewController.h +43 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMusicPlayerApplicationController.h +47 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMusicPlayerController.h +147 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMusicPlayerQueueDescriptor.h +75 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPNowPlayingInfoCenter.h +197 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPNowPlayingInfoLanguageOption.h +107 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPNowPlayingSession.h +89 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentDataSource.h +59 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentDelegate.h +64 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentManager.h +46 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentManagerContext.h +32 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteCommand.h +143 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteCommandCenter.h +66 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteCommandEvent.h +128 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteControlTypes.h +27 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPVolumeSettings.h +20 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPVolumeView.h +82 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MediaPlayer.apinotes +74 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MediaPlayer.h +40 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MediaPlayerDefines.h +84 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/NSUserActivity+MediaPlayerAdditions.h +20 -0
- package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Modules/module.modulemap +5 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIAccessibilityCustomRotor.h +2 -2
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIAction.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIBackgroundConfiguration.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIButtonConfiguration.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIContextMenuConfiguration.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIContextMenuInteraction.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIDeferredMenuElement.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIMenu.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIPointerStyle.h +5 -5
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UISlider.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UISplitViewController.h +12 -50
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UISplitViewControllerLayoutEnvironment.h +2 -8
- package/sdk/ios/System/Library/Frameworks/UIKitTypes.framework/Headers/UIKitTypes.h +62 -0
- package/sdk/ios/usr/include/dispatch.modulemap +22 -0
- package/sdk/ios/usr/include/module.modulemap +8 -3
- package/sdk/ios/usr/include/net/if.h +24 -0
- package/sdk/ios/usr/include/sys/time.h +1 -1
- package/sdk/ios/usr/lib/swift/Foundation.swiftmodule/arm64-apple-ios-simulator.swiftinterface +265 -0
- package/sdk/ios/usr/lib/swift/ObjectiveC.swiftmodule/arm64-apple-ios-simulator.swiftinterface +2 -0
- package/sdk/ios/wasm/include/fcntl.h +2 -0
- package/sdk/ios/wasm/include/pthread.h +3 -0
- package/sdk/ios/wasm/include/stdlib.h +2 -0
- package/sdk/ios/wasm/include/unistd.h +2 -2
- package/skills/contrast/SKILL.md +2 -2
- package/src/bundle-channel.mjs +9 -72
- package/src/capture-contract.ts +12 -9
- package/src/desktop-host-delivery.ts +16 -2
- package/src/dev-bundle-resolution.ts +12 -3
- package/src/expo-native-workspace.ts +113 -46
- package/src/expo-swift-host.ts +17 -12
- package/src/expo-swift-ready.ts +4 -1
- package/src/expoSwiftContract.ts +1 -0
- package/src/home-paths.ts +4 -48
- package/src/host/bridge-host.ts +1 -0
- package/src/installed-native-libraries.ts +2 -8
- package/src/metro-project-root.ts +2 -1
- package/src/native-bundles.ts +122 -0
- package/src/native-static-libraries.ts +65 -8
- package/src/nitro-adapter.lock.json +272 -272
- package/src/nitro-bundle.ts +2 -2
- package/src/nitro-compile.ts +68 -28
- package/src/nitro-source.ts +24 -6
- package/src/nitro-superset.lock.json +94 -34
- package/src/nitroContract.ts +3 -0
- package/src/podspec-sources.ts +1966 -0
- package/src/storageSnapshotContract.ts +40 -0
- package/src/swift-compile.ts +77 -26
- package/src/swift-design-time.ts +18 -1
- package/src/swift-distribution.lock.json +12 -12
- package/src/swift-distribution.ts +9 -6
- package/src/swift-host.ts +1 -2
- package/src/swift-link-roots.ts +13 -2
- package/src/swift-objc-compile.ts +12 -0
- package/src/swift-objc-standin.ts +321 -114
- package/src/swift-package-manifest.ts +4 -3
- package/src/swift-package.ts +31 -4
- package/src/swift-root-lock.ts +11 -0
- package/src/swift-shared-sdk.ts +10 -9
- package/src/swift-source-pods.ts +2 -2
- package/src/swift-standins.ts +40 -143
- package/src/swift-toolchain.ts +59 -0
- package/src/swift-wasm-prune.ts +53 -21
- package/src/turbo-bundle.ts +4 -5
- package/src/turbo-codegen-intake.ts +111 -108
- package/src/turbo-compile.ts +63 -33
- package/src/turbo-runtime.lock.json +22 -22
- package/src/turbo-source.ts +171 -76
- package/src/wasm-optimize.ts +31 -2
- package/src/xcode-project.ts +65 -15
package/README.md
CHANGED
|
@@ -225,7 +225,9 @@ the host forwards each command to the targeted sim and relays the reply back. It
|
|
|
225
225
|
also serves the engine runtime over HTTP (with a self-update route), exposes
|
|
226
226
|
`/__server-scan` to discover local metro/expo/vxrn/one dev servers, and proxies
|
|
227
227
|
guest-app fetch/WebSocket traffic so the cross-origin tenant worker can reach
|
|
228
|
-
localhost. The
|
|
228
|
+
localhost. The lockfile records the cli version that started the daemon; `peach open`
|
|
229
|
+
replaces an older or unrecorded daemon once it has no live or retained sim (the Mac
|
|
230
|
+
app's own bridge excepted), and leaves a busy one alone. The `AgentHost` extension owns one FIFO reader per agent session and
|
|
229
231
|
fans agent events out to every subscriber.
|
|
230
232
|
|
|
231
233
|
`peach open` auto-installs a published runtime only when the runtime directory
|
|
@@ -862,7 +864,7 @@ verifies its sha256, and unpacks it under `~/.peach`:
|
|
|
862
864
|
├── cache/ legacy downloads; empty after cleanup
|
|
863
865
|
├── profiles/ persistent named app storage, without browser caches
|
|
864
866
|
├── electron/userData/ desktop app storage, with bounded browser caches
|
|
865
|
-
├── daemon.json lockfile: pid, ports, active runtime, heartbeat
|
|
867
|
+
├── daemon.json lockfile: pid, ports, cli version, active runtime, heartbeat
|
|
866
868
|
├── cli-update.json cached standalone CLI version and notice state
|
|
867
869
|
├── automatic-cleanup-v1.json last complete safe cleanup
|
|
868
870
|
└── config.json user prefs: update channel, cdn origin override
|
|
@@ -20,8 +20,21 @@ export function stageAppBundleResources(
|
|
|
20
20
|
): AppBundleResources {
|
|
21
21
|
const app = readIosAppTarget(appDir, iosTarget, environment)
|
|
22
22
|
if (!app) return {}
|
|
23
|
-
// a monorepo app's font and asset resources live in the workspace root
|
|
24
|
-
|
|
23
|
+
// a monorepo app's font and asset resources live in the workspace root.
|
|
24
|
+
// a stale nested lockfile can pin that root at the app while the Xcode
|
|
25
|
+
// target reaches sibling workspace packages, so widen to the enclosing
|
|
26
|
+
// workspace root until every resource is contained.
|
|
27
|
+
let root = fs.realpathSync(findWorkspaceRoot(appDir))
|
|
28
|
+
for (;;) {
|
|
29
|
+
const escaped = app.resources.some((file) => {
|
|
30
|
+
const relative = path.relative(root, fs.realpathSync(file))
|
|
31
|
+
return relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)
|
|
32
|
+
})
|
|
33
|
+
if (!escaped) break
|
|
34
|
+
const wider = fs.realpathSync(findWorkspaceRoot(path.dirname(root)))
|
|
35
|
+
if (wider === root) break
|
|
36
|
+
root = wider
|
|
37
|
+
}
|
|
25
38
|
const members = new Map<string, string>()
|
|
26
39
|
for (const file of app.resources) {
|
|
27
40
|
const real = fs.realpathSync(file)
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// the prebuilt bundle a Box boots, with the app's Metro assets and compiled
|
|
2
|
+
// native modules inside it. it compiles on the cli's machine, so it lives apart
|
|
3
|
+
// from cloud-client, which the box worker itself bundles.
|
|
4
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
5
|
+
import { dirname, join, resolve } from 'node:path'
|
|
6
|
+
import { getCliRuntime } from '../src/cli-runtime.ts'
|
|
7
|
+
import { isRecord } from '../src/is-record'
|
|
8
|
+
import { detectBundleModeFromText } from '../src/metro-production-bundle.ts'
|
|
9
|
+
import {
|
|
10
|
+
buildNativeBundles,
|
|
11
|
+
insertNativeBundleFooters,
|
|
12
|
+
nativeBundleAssets,
|
|
13
|
+
} from '../src/native-bundles'
|
|
14
|
+
import { readPackageVersionsFooter } from '../src/packageVersionsContract'
|
|
15
|
+
import { embedBundleAssets, isRemoteBundleInput } from './cloud-client.ts'
|
|
16
|
+
import type { RemotePlatform } from './cloud-session.ts'
|
|
17
|
+
|
|
18
|
+
export interface CloudBoxArtifactProduction {
|
|
19
|
+
bytes: Buffer
|
|
20
|
+
assetsDirectory: string | null
|
|
21
|
+
/** the app project whose compiled native modules the bundle carries. */
|
|
22
|
+
nativeProject: string | null
|
|
23
|
+
warnings: string[]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// the app a local bundle was built from: the nearest directory above it whose
|
|
27
|
+
// package.json depends on react-native, as `expo export:embed` and
|
|
28
|
+
// `react-native bundle` write into the project.
|
|
29
|
+
function bundleAppProject(bundlePath: string): string | null {
|
|
30
|
+
if (isRemoteBundleInput(bundlePath)) return null
|
|
31
|
+
for (let dir = dirname(resolve(bundlePath)); ; dir = dirname(dir)) {
|
|
32
|
+
const manifest = join(dir, 'package.json')
|
|
33
|
+
if (existsSync(manifest)) {
|
|
34
|
+
const json: unknown = JSON.parse(readFileSync(manifest, 'utf8'))
|
|
35
|
+
if (
|
|
36
|
+
isRecord(json) &&
|
|
37
|
+
[json.dependencies, json.devDependencies].some(
|
|
38
|
+
(dependencies) => isRecord(dependencies) && 'react-native' in dependencies,
|
|
39
|
+
)
|
|
40
|
+
)
|
|
41
|
+
return dir
|
|
42
|
+
}
|
|
43
|
+
if (dirname(dir) === dir) return null
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* prepares a prebuilt bundle for a Box: the Metro assets beside the bundle and
|
|
49
|
+
* the app project's compiled native modules travel inside it, because the box
|
|
50
|
+
* page boots these bytes with no server of the app's behind them.
|
|
51
|
+
*/
|
|
52
|
+
export async function produceCloudBoxArtifact(
|
|
53
|
+
bundlePath: string,
|
|
54
|
+
platform: RemotePlatform,
|
|
55
|
+
options: { assetsDirectory?: string; nativeProjectDir?: string } = {},
|
|
56
|
+
): Promise<CloudBoxArtifactProduction> {
|
|
57
|
+
const { assetsDirectory } = options
|
|
58
|
+
const prepared = await embedBundleAssets(
|
|
59
|
+
bundlePath,
|
|
60
|
+
'peach box create',
|
|
61
|
+
assetsDirectory ? 'require-assets' : 'allow-placeholders',
|
|
62
|
+
assetsDirectory,
|
|
63
|
+
)
|
|
64
|
+
if (!readPackageVersionsFooter(prepared.source)?.['react-native']) {
|
|
65
|
+
throw new Error(
|
|
66
|
+
'remote simulator bundle is missing __peachPackageVersions with the installed react-native version. Wrap your project Metro config with withPeach from peachsim/metro, then rebuild the bundle before running peach ios --remote or peach android --remote.',
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
const warnings: string[] = []
|
|
70
|
+
if (prepared.search.unconfirmed && prepared.dest) {
|
|
71
|
+
warnings.push(
|
|
72
|
+
`peach box create read this bundle's assets from ${prepared.dest.directory} on layout alone: every asset declares a scale that directory does not hold, so not one of Metro's hashes could be reproduced. Confirm these are the images this bundle was built against.`,
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
if (prepared.substituted.length > 0) {
|
|
76
|
+
warnings.push(
|
|
77
|
+
`peach box create embedded a placeholder image for ${prepared.substituted.length} asset(s) no scale of which is in ${prepared.search.searched.join(', ') || 'any asset dest directory'}: ${prepared.substituted.join(', ')}. Rebuild with \`react-native bundle --assets-dest\` to ship the real images.`,
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
const nativeProject = options.nativeProjectDir
|
|
81
|
+
? resolve(options.nativeProjectDir)
|
|
82
|
+
: bundleAppProject(bundlePath)
|
|
83
|
+
let code = prepared.code
|
|
84
|
+
if (nativeProject) {
|
|
85
|
+
const natives = await buildNativeBundles(
|
|
86
|
+
nativeProject,
|
|
87
|
+
platform,
|
|
88
|
+
(await detectBundleModeFromText(prepared.source)) === 'production'
|
|
89
|
+
? 'Release'
|
|
90
|
+
: 'Debug',
|
|
91
|
+
)
|
|
92
|
+
// a Kotlin module imports its loader and wasm by relative url, which a
|
|
93
|
+
// self-contained data url cannot answer.
|
|
94
|
+
if (natives.expoKotlin?.metadata.module) {
|
|
95
|
+
throw new Error(
|
|
96
|
+
`${nativeProject} has Expo Kotlin modules, and remote Android simulators cannot load compiled Kotlin modules yet.`,
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
const files = new Map(nativeBundleAssets(natives).map((asset) => [asset.path, asset]))
|
|
100
|
+
code = insertNativeBundleFooters(code, natives, (path) => {
|
|
101
|
+
const asset = files.get(path)
|
|
102
|
+
if (!asset) throw new Error(`compiled native module file ${path} was not produced`)
|
|
103
|
+
return `data:${asset.contentType};base64,${asset.bytes.toString('base64')}`
|
|
104
|
+
}).source
|
|
105
|
+
}
|
|
106
|
+
if (getCliRuntime().preview_bundle_layout.isRolldownBundle(code))
|
|
107
|
+
code =
|
|
108
|
+
await getCliRuntime().rolldown_bundle_inventory.attachRolldownBundleInventory(code)
|
|
109
|
+
return {
|
|
110
|
+
bytes: Buffer.from(code, 'utf8'),
|
|
111
|
+
assetsDirectory: prepared.dest?.directory ?? null,
|
|
112
|
+
nativeProject,
|
|
113
|
+
warnings,
|
|
114
|
+
}
|
|
115
|
+
}
|
package/cli/cloud-client.ts
CHANGED
|
@@ -44,7 +44,6 @@ import {
|
|
|
44
44
|
RNX_METRO_MODULE_IDENTITY_VERSION,
|
|
45
45
|
type RNXMetroModuleIdentityMetadata,
|
|
46
46
|
} from '../src/metro-production-bundle.ts'
|
|
47
|
-
import { readPackageVersionsFooter } from '../src/packageVersionsContract'
|
|
48
47
|
import { rnxPublicBrand } from '../src/public-brand.ts'
|
|
49
48
|
import { StorageSnapshot } from '../src/storageSnapshotContract.ts'
|
|
50
49
|
import { CHOOSE_ACCOUNT_HINT, resolveCliAuth } from './auth.ts'
|
|
@@ -154,9 +153,14 @@ function responseError(status: number, text: string): Error {
|
|
|
154
153
|
const parsed = text ? failureSentence(text) : null
|
|
155
154
|
const sentence =
|
|
156
155
|
parsed && ACCOUNT_CHOICE_REFUSALS.has(parsed) ? CHOOSE_ACCOUNT_HINT : parsed
|
|
156
|
+
// box tokens never carry the debug scope, so a command built on call or
|
|
157
|
+
// evaluate cannot run remotely; say that instead of leaving a bare 403
|
|
158
|
+
const hint = parsed?.endsWith(' requires the debug scope')
|
|
159
|
+
? '; this command needs debug access, which a remote simulator does not grant, so run it against a local sim'
|
|
160
|
+
: ''
|
|
157
161
|
return new Error(
|
|
158
162
|
`remote simulator request failed (${status})${
|
|
159
|
-
sentence ? `: ${sentence}` : text.trim() ? `: ${text.trim()}` : ''
|
|
163
|
+
sentence ? `: ${sentence}${hint}` : text.trim() ? `: ${text.trim()}` : ''
|
|
160
164
|
}`,
|
|
161
165
|
)
|
|
162
166
|
}
|
|
@@ -169,6 +173,12 @@ function resolveCloudOrigin(value?: string): string {
|
|
|
169
173
|
|
|
170
174
|
function readImmutableBundleSource(bundlePath: string, command: string): string {
|
|
171
175
|
const filepath = resolve(bundlePath)
|
|
176
|
+
if (extname(filepath) === '.hbc') {
|
|
177
|
+
const platform = filepath.includes('/android/') ? 'android' : 'ios'
|
|
178
|
+
throw new Error(
|
|
179
|
+
`${command} cannot preview Hermes bytecode (${bundlePath}). Export plain JavaScript with \`npx expo export --platform ${platform} --no-bytecode\` and preview the .js bundle instead.`,
|
|
180
|
+
)
|
|
181
|
+
}
|
|
172
182
|
if (extname(filepath) !== '.js') {
|
|
173
183
|
throw new Error(`${command} requires one local .js bundle`)
|
|
174
184
|
}
|
|
@@ -241,7 +251,7 @@ function isLoopbackBundleUrl(bundleInput: string): boolean {
|
|
|
241
251
|
}
|
|
242
252
|
}
|
|
243
253
|
|
|
244
|
-
function isRemoteBundleInput(bundleInput: string): boolean {
|
|
254
|
+
export function isRemoteBundleInput(bundleInput: string): boolean {
|
|
245
255
|
return bundleInput.startsWith('https://') || bundleInput.startsWith('http://')
|
|
246
256
|
}
|
|
247
257
|
|
|
@@ -418,6 +428,30 @@ function distinctByContent(directory: string, options: readonly string[]): strin
|
|
|
418
428
|
return [...byContent.values()]
|
|
419
429
|
}
|
|
420
430
|
|
|
431
|
+
/**
|
|
432
|
+
* the files `npx expo export` wrote for one scale: extensionless md5 names in
|
|
433
|
+
* `dist/assets/`, one per entry of the descriptor's `fileHashes`. the name is
|
|
434
|
+
* only a lookup; the bytes still face the same md5 identity check below.
|
|
435
|
+
*/
|
|
436
|
+
function resolveExpoHashedAssetFiles(
|
|
437
|
+
destFiles: readonly string[],
|
|
438
|
+
descriptor: MetroAssetDescriptor,
|
|
439
|
+
scale: number,
|
|
440
|
+
): string[] {
|
|
441
|
+
const hashes = descriptor.fileHashes
|
|
442
|
+
if (!hashes || hashes.length !== descriptor.scales.length) return []
|
|
443
|
+
const wanted = new Set<string>()
|
|
444
|
+
descriptor.scales.forEach((declaredScale, index) => {
|
|
445
|
+
const hash = hashes[index]
|
|
446
|
+
if (declaredScale === scale && hash) wanted.add(hash)
|
|
447
|
+
})
|
|
448
|
+
if (wanted.size === 0) return []
|
|
449
|
+
return destFiles
|
|
450
|
+
.filter((file) => wanted.has(file.split('/').pop() ?? ''))
|
|
451
|
+
.map((file) => file.replaceAll('\\', '/'))
|
|
452
|
+
.sort()
|
|
453
|
+
}
|
|
454
|
+
|
|
421
455
|
/**
|
|
422
456
|
* decides what a candidate directory holds for one descriptor, by bytes.
|
|
423
457
|
*
|
|
@@ -440,10 +474,12 @@ function placeMetroDescriptor(
|
|
|
440
474
|
): DescriptorPlacement {
|
|
441
475
|
const scales = [...new Set(descriptor.scales)]
|
|
442
476
|
const perScale = scales.map((scale) =>
|
|
443
|
-
distinctByContent(
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
477
|
+
distinctByContent(listing.directory, [
|
|
478
|
+
...new Set([
|
|
479
|
+
...resolveMetroIosAssetDestFiles(listing.files, descriptor, scale),
|
|
480
|
+
...resolveExpoHashedAssetFiles(listing.files, descriptor, scale),
|
|
481
|
+
]),
|
|
482
|
+
]),
|
|
447
483
|
)
|
|
448
484
|
// a scale that resolved to one image names its file whatever the verdict
|
|
449
485
|
// below is. one that resolved to several is left for the hash to settle.
|
|
@@ -555,6 +591,32 @@ function unverifiedContentKey(
|
|
|
555
591
|
)
|
|
556
592
|
}
|
|
557
593
|
|
|
594
|
+
/**
|
|
595
|
+
* the `npx expo export` output directory holding this bundle, if any: the
|
|
596
|
+
* nearest ancestor with a `metadata.json` naming per-platform bundles and an
|
|
597
|
+
* `assets/` directory of md5-named files. a bundle at
|
|
598
|
+
* `dist/_expo/static/js/ios/entry-<hash>.js` finds `dist` four levels up.
|
|
599
|
+
*/
|
|
600
|
+
function findExpoExportRoot(bundleDirectory: string): string | null {
|
|
601
|
+
let directory = resolve(bundleDirectory)
|
|
602
|
+
for (let depth = 0; depth < 6; depth++) {
|
|
603
|
+
const metadata = join(directory, 'metadata.json')
|
|
604
|
+
if (existsSync(metadata) && existsSync(join(directory, 'assets'))) {
|
|
605
|
+
try {
|
|
606
|
+
if (readFileSync(metadata, 'utf8').includes('"fileMetadata"')) {
|
|
607
|
+
return directory
|
|
608
|
+
}
|
|
609
|
+
} catch {
|
|
610
|
+
// unreadable metadata proves nothing; keep walking up.
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
const parent = dirname(directory)
|
|
614
|
+
if (parent === directory) return null
|
|
615
|
+
directory = parent
|
|
616
|
+
}
|
|
617
|
+
return null
|
|
618
|
+
}
|
|
619
|
+
|
|
558
620
|
/**
|
|
559
621
|
* finds the `--assets-dest` directory by RESOLVING the bundle's own asset
|
|
560
622
|
* descriptors against a short ordered list of the places Metro writes one, and
|
|
@@ -569,9 +631,14 @@ export function searchMetroAssetDest(
|
|
|
569
631
|
assetsDirectory?: string,
|
|
570
632
|
): MetroAssetSearch {
|
|
571
633
|
const bundleDirectory = dirname(resolve(bundlePath))
|
|
634
|
+
const expoRoot =
|
|
635
|
+
assetsDirectory || isRemoteBundleInput(bundlePath)
|
|
636
|
+
? null
|
|
637
|
+
: findExpoExportRoot(bundleDirectory)
|
|
572
638
|
const candidates = assetsDirectory
|
|
573
639
|
? [resolve(assetsDirectory)]
|
|
574
640
|
: [
|
|
641
|
+
...(expoRoot ? [join(expoRoot, 'assets')] : []),
|
|
575
642
|
join(bundleDirectory, 'assets'),
|
|
576
643
|
bundleDirectory,
|
|
577
644
|
resolve(bundleDirectory, '..', 'assets'),
|
|
@@ -770,52 +837,7 @@ export async function producePreviewArtifact(bundlePath: string) {
|
|
|
770
837
|
}
|
|
771
838
|
}
|
|
772
839
|
|
|
773
|
-
export
|
|
774
|
-
bytes: Buffer
|
|
775
|
-
assetsDirectory: string | null
|
|
776
|
-
warnings: string[]
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
/** prepares a prebuilt bundle for a Box by embedding any beside-the-bundle Metro assets. */
|
|
780
|
-
export async function produceCloudBoxArtifact(
|
|
781
|
-
bundlePath: string,
|
|
782
|
-
assetsDirectory?: string,
|
|
783
|
-
): Promise<CloudBoxArtifactProduction> {
|
|
784
|
-
const prepared = await embedBundleAssets(
|
|
785
|
-
bundlePath,
|
|
786
|
-
'peach box create',
|
|
787
|
-
assetsDirectory ? 'require-assets' : 'allow-placeholders',
|
|
788
|
-
assetsDirectory,
|
|
789
|
-
)
|
|
790
|
-
if (!readPackageVersionsFooter(prepared.source)?.['react-native']) {
|
|
791
|
-
throw new Error(
|
|
792
|
-
'remote simulator bundle is missing __peachPackageVersions with the installed react-native version. Wrap your project Metro config with withPeach from peachsim/metro, then rebuild the bundle before running peach ios --remote or peach android --remote.',
|
|
793
|
-
)
|
|
794
|
-
}
|
|
795
|
-
const warnings: string[] = []
|
|
796
|
-
if (prepared.search.unconfirmed && prepared.dest) {
|
|
797
|
-
warnings.push(
|
|
798
|
-
`peach box create read this bundle's assets from ${prepared.dest.directory} on layout alone: every asset declares a scale that directory does not hold, so not one of Metro's hashes could be reproduced. Confirm these are the images this bundle was built against.`,
|
|
799
|
-
)
|
|
800
|
-
}
|
|
801
|
-
if (prepared.substituted.length > 0) {
|
|
802
|
-
warnings.push(
|
|
803
|
-
`peach box create embedded a placeholder image for ${prepared.substituted.length} asset(s) no scale of which is in ${prepared.search.searched.join(', ') || 'any asset dest directory'}: ${prepared.substituted.join(', ')}. Rebuild with \`react-native bundle --assets-dest\` to ship the real images.`,
|
|
804
|
-
)
|
|
805
|
-
}
|
|
806
|
-
const code = getCliRuntime().preview_bundle_layout.isRolldownBundle(prepared.code)
|
|
807
|
-
? await getCliRuntime().rolldown_bundle_inventory.attachRolldownBundleInventory(
|
|
808
|
-
prepared.code,
|
|
809
|
-
)
|
|
810
|
-
: prepared.code
|
|
811
|
-
return {
|
|
812
|
-
bytes: Buffer.from(code, 'utf8'),
|
|
813
|
-
assetsDirectory: prepared.dest?.directory ?? null,
|
|
814
|
-
warnings,
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
async function embedBundleAssets(
|
|
840
|
+
export async function embedBundleAssets(
|
|
819
841
|
bundlePath: string,
|
|
820
842
|
command: string,
|
|
821
843
|
assetPolicy: 'allow-placeholders' | 'require-assets',
|
|
@@ -1719,6 +1741,44 @@ export class BoxBootFailedError extends Error {
|
|
|
1719
1741
|
const BOX_DISPLAY_GRANT_WAIT_MS = 180_000
|
|
1720
1742
|
const BOX_DISPLAY_GRANT_RETRY_MS = 2_000
|
|
1721
1743
|
|
|
1744
|
+
// a box's lifecycle as the page's runtime receipts and lost browser
|
|
1745
|
+
// generations record it.
|
|
1746
|
+
async function readBoxLifecycle(options: {
|
|
1747
|
+
apiOrigin: string
|
|
1748
|
+
boxId: string
|
|
1749
|
+
boxToken: string
|
|
1750
|
+
}): Promise<{ generation: unknown; receipts: unknown[]; lostGenerations: number }> {
|
|
1751
|
+
const response = await fetch(
|
|
1752
|
+
`${options.apiOrigin}/v1/boxes/${encodeURIComponent(options.boxId)}/lifecycle`,
|
|
1753
|
+
{ headers: { authorization: `Bearer ${options.boxToken}` } },
|
|
1754
|
+
)
|
|
1755
|
+
const text = await response.text()
|
|
1756
|
+
if (!response.ok) throw responseError(response.status, text)
|
|
1757
|
+
const status: unknown = JSON.parse(text)
|
|
1758
|
+
if (!isRecord(status)) return { generation: null, receipts: [], lostGenerations: 0 }
|
|
1759
|
+
return {
|
|
1760
|
+
generation: isRecord(status.browser) ? status.browser.browserGeneration : null,
|
|
1761
|
+
receipts: Array.isArray(status.runtimeReceipts) ? status.runtimeReceipts : [],
|
|
1762
|
+
lostGenerations: Array.isArray(status.recoveries) ? status.recoveries.length : 0,
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
// the newest boot outcome among receipts that pass the filter, or null while
|
|
1767
|
+
// the app has reported neither loading nor failing.
|
|
1768
|
+
function bootOutcome(
|
|
1769
|
+
receipts: unknown[],
|
|
1770
|
+
include: (receipt: Record<string, unknown>) => boolean,
|
|
1771
|
+
): { loaded: true } | { loaded: false; error: string } | null {
|
|
1772
|
+
for (const receipt of receipts.toReversed()) {
|
|
1773
|
+
if (!isRecord(receipt) || !include(receipt)) continue
|
|
1774
|
+
if (receipt.kind === 'boot-failed' && typeof receipt.error === 'string') {
|
|
1775
|
+
return { loaded: false, error: receipt.error }
|
|
1776
|
+
}
|
|
1777
|
+
if (receipt.kind === 'loaded' || receipt.kind === 'painted') return { loaded: true }
|
|
1778
|
+
}
|
|
1779
|
+
return null
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1722
1782
|
// waits for a fresh box's page to load its app or report that the app threw
|
|
1723
1783
|
// while booting, reading the same runtime receipts the page records. a boot
|
|
1724
1784
|
// error throws; a slow boot that reports neither within the wait is not an
|
|
@@ -1730,28 +1790,13 @@ export async function awaitBoxBoot(options: {
|
|
|
1730
1790
|
}): Promise<void> {
|
|
1731
1791
|
const started = Date.now()
|
|
1732
1792
|
while (Date.now() - started < BOX_DISPLAY_GRANT_WAIT_MS) {
|
|
1733
|
-
const
|
|
1734
|
-
|
|
1735
|
-
|
|
1793
|
+
const { generation, receipts } = await readBoxLifecycle(options)
|
|
1794
|
+
const outcome = bootOutcome(
|
|
1795
|
+
receipts,
|
|
1796
|
+
(receipt) => receipt.browserGeneration === generation,
|
|
1736
1797
|
)
|
|
1737
|
-
|
|
1738
|
-
if (
|
|
1739
|
-
const status: unknown = JSON.parse(text)
|
|
1740
|
-
const generation =
|
|
1741
|
-
isRecord(status) && isRecord(status.browser)
|
|
1742
|
-
? status.browser.browserGeneration
|
|
1743
|
-
: null
|
|
1744
|
-
const receipts =
|
|
1745
|
-
isRecord(status) && Array.isArray(status.runtimeReceipts)
|
|
1746
|
-
? status.runtimeReceipts
|
|
1747
|
-
: []
|
|
1748
|
-
for (const receipt of receipts.toReversed()) {
|
|
1749
|
-
if (!isRecord(receipt) || receipt.browserGeneration !== generation) continue
|
|
1750
|
-
if (receipt.kind === 'boot-failed' && typeof receipt.error === 'string') {
|
|
1751
|
-
throw new BoxBootFailedError(options.boxId, receipt.error)
|
|
1752
|
-
}
|
|
1753
|
-
if (receipt.kind === 'loaded' || receipt.kind === 'painted') return
|
|
1754
|
-
}
|
|
1798
|
+
if (outcome?.loaded) return
|
|
1799
|
+
if (outcome) throw new BoxBootFailedError(options.boxId, outcome.error)
|
|
1755
1800
|
await new Promise((resolve) => setTimeout(resolve, BOX_DISPLAY_GRANT_RETRY_MS))
|
|
1756
1801
|
}
|
|
1757
1802
|
}
|
|
@@ -1794,10 +1839,17 @@ export async function requestBoxWatchUrl(options: {
|
|
|
1794
1839
|
failureSentence(text) === 'no simulator is hosting this box'
|
|
1795
1840
|
) {
|
|
1796
1841
|
// the page has not attached its simulator yet. this is the normal state
|
|
1797
|
-
// right after a create, so wait rather than refusing
|
|
1842
|
+
// right after a create, so wait rather than refusing, unless a page of
|
|
1843
|
+
// any browser generation already reported that the app cannot boot.
|
|
1844
|
+
const lifecycle = await readBoxLifecycle(options)
|
|
1845
|
+
const outcome = bootOutcome(lifecycle.receipts, () => true)
|
|
1846
|
+
if (outcome && !outcome.loaded)
|
|
1847
|
+
throw new BoxBootFailedError(options.boxId, outcome.error)
|
|
1798
1848
|
if (Date.now() - started >= BOX_DISPLAY_GRANT_WAIT_MS) {
|
|
1799
1849
|
throw new Error(
|
|
1800
|
-
|
|
1850
|
+
lifecycle.lostGenerations > 0
|
|
1851
|
+
? `box ${options.boxId} has no simulator hosting it: its page's browser was lost ${lifecycle.lostGenerations} time(s) before the app reported loading or failing`
|
|
1852
|
+
: `box ${options.boxId} has no simulator hosting it yet; try again once its page has booted`,
|
|
1801
1853
|
)
|
|
1802
1854
|
}
|
|
1803
1855
|
await new Promise((resolve) => setTimeout(resolve, BOX_DISPLAY_GRANT_RETRY_MS))
|
|
@@ -1816,6 +1868,26 @@ export async function requestBoxWatchUrl(options: {
|
|
|
1816
1868
|
}
|
|
1817
1869
|
}
|
|
1818
1870
|
|
|
1871
|
+
// the short peachsim.com link a person opens for a watch url. the link lives
|
|
1872
|
+
// as long as the grant in the url's fragment, so it is minted per grant.
|
|
1873
|
+
export async function shortWatchUrl(options: {
|
|
1874
|
+
apiOrigin: string
|
|
1875
|
+
authHeader: string
|
|
1876
|
+
watchUrl: string
|
|
1877
|
+
}): Promise<string> {
|
|
1878
|
+
const response = await fetch(`${options.apiOrigin}/api/v1/watch-links`, {
|
|
1879
|
+
method: 'POST',
|
|
1880
|
+
headers: { authorization: options.authHeader, 'content-type': 'application/json' },
|
|
1881
|
+
body: JSON.stringify({ url: options.watchUrl }),
|
|
1882
|
+
})
|
|
1883
|
+
const text = await response.text()
|
|
1884
|
+
if (!response.ok) throw responseError(response.status, text)
|
|
1885
|
+
const parsed: unknown = JSON.parse(text)
|
|
1886
|
+
if (!isRecord(parsed) || typeof parsed.url !== 'string')
|
|
1887
|
+
throw new Error('watch link returned no url')
|
|
1888
|
+
return parsed.url
|
|
1889
|
+
}
|
|
1890
|
+
|
|
1819
1891
|
function readClaimResponse(value: unknown): { id: string; expiresAt: number } {
|
|
1820
1892
|
const claim = isRecord(value) ? value.claim : null
|
|
1821
1893
|
if (
|
package/cli/cloud-dispatch.ts
CHANGED
|
@@ -154,10 +154,10 @@ export async function dispatchCloudBoundary({
|
|
|
154
154
|
return refuseCloudInvocation(command, parsed.positional)
|
|
155
155
|
}
|
|
156
156
|
try {
|
|
157
|
-
const descriptor = cloudSession.
|
|
157
|
+
const descriptor = cloudSession.cloudSessionShellUpdate()
|
|
158
158
|
if (session.service === 'box') await cloudClient.closeCloudBox(session)
|
|
159
159
|
else await cloudClient.closeCloudSession(session)
|
|
160
|
-
cloudSession.
|
|
160
|
+
cloudSession.publishCloudSession(null, descriptor)
|
|
161
161
|
console.log(
|
|
162
162
|
session.service === 'box'
|
|
163
163
|
? ` closed: remote box ${session.boxId}`
|
|
@@ -189,11 +189,11 @@ export async function dispatchCloudBoundary({
|
|
|
189
189
|
|
|
190
190
|
if (command === 'claim') {
|
|
191
191
|
try {
|
|
192
|
-
const descriptor = cloudSession.
|
|
192
|
+
const descriptor = cloudSession.cloudSessionShellUpdate()
|
|
193
193
|
const claimed = await cloudClient.claimCloudSimulator(session, {
|
|
194
194
|
force: args.includes('--force'),
|
|
195
195
|
})
|
|
196
|
-
cloudSession.
|
|
196
|
+
cloudSession.publishCloudSession(claimed.session, descriptor)
|
|
197
197
|
console.log(` claimed: ${session.simId}`)
|
|
198
198
|
console.log(` expires: ${claimed.claim.expiresAt}`)
|
|
199
199
|
return { handled: true, code: 0 }
|
package/cli/cloud-session.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createHash } from 'node:crypto'
|
|
2
|
+
import {
|
|
3
|
+
existsSync,
|
|
4
|
+
fstatSync,
|
|
5
|
+
readFileSync,
|
|
6
|
+
realpathSync,
|
|
7
|
+
rmSync,
|
|
8
|
+
writeSync,
|
|
9
|
+
} from 'node:fs'
|
|
10
|
+
import { dirname, join } from 'node:path'
|
|
2
11
|
import { isLoopbackHost } from '../src/backend-origin.ts'
|
|
12
|
+
import { rnxHomeDir } from '../src/home-paths'
|
|
3
13
|
import { isRecord } from '../src/is-record'
|
|
14
|
+
import { writeSecureJsonAtomic } from './secure-file'
|
|
4
15
|
|
|
5
16
|
const CLOUD_SESSION_VERSION = 3 as const
|
|
6
17
|
const SHELL_UPDATE_FD_ENV = 'PEACH_SHELL_UPDATE_FD'
|
|
@@ -251,17 +262,48 @@ export function parseCloudSession(encoded: string): CloudSession {
|
|
|
251
262
|
}
|
|
252
263
|
}
|
|
253
264
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
265
|
+
// a remote simulator belongs to the project folder it was opened from, so
|
|
266
|
+
// agents and scripts, whose every command runs in a fresh shell, reach it on
|
|
267
|
+
// later commands. a shell whose Peach integration holds a session keeps its own.
|
|
268
|
+
const PROJECT_MARKERS = [
|
|
269
|
+
'package.json',
|
|
270
|
+
'Package.swift',
|
|
271
|
+
'settings.gradle',
|
|
272
|
+
'settings.gradle.kts',
|
|
273
|
+
'.git',
|
|
274
|
+
]
|
|
275
|
+
|
|
276
|
+
function projectSessionFile(): string {
|
|
277
|
+
const cwd = realpathSync(process.cwd())
|
|
278
|
+
let dir = cwd
|
|
279
|
+
while (!PROJECT_MARKERS.some((marker) => existsSync(join(dir, marker)))) {
|
|
280
|
+
const parent = dirname(dir)
|
|
281
|
+
if (parent === dir) {
|
|
282
|
+
dir = cwd
|
|
283
|
+
break
|
|
284
|
+
}
|
|
285
|
+
dir = parent
|
|
286
|
+
}
|
|
287
|
+
const key = createHash('sha256').update(dir).digest('hex').slice(0, 32)
|
|
288
|
+
return join(rnxHomeDir(), 'remote-sessions', `${key}.json`)
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export function readCloudSession(): CloudSession | null {
|
|
292
|
+
const encoded = process.env[PEACH_CLOUD_SESSION_ENV]
|
|
293
|
+
if (encoded?.trim()) return parseCloudSession(encoded)
|
|
294
|
+
const file = projectSessionFile()
|
|
295
|
+
if (!existsSync(file)) return null
|
|
296
|
+
const saved: unknown = JSON.parse(readFileSync(file, 'utf8'))
|
|
297
|
+
if (!isRecord(saved) || typeof saved.session !== 'string') {
|
|
298
|
+
throw new Error(`the saved remote simulator in ${file} is invalid`)
|
|
299
|
+
}
|
|
300
|
+
return parseCloudSession(saved.session)
|
|
259
301
|
}
|
|
260
302
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
): number | null {
|
|
264
|
-
const source =
|
|
303
|
+
// the update channel the shell integration opens around a lifecycle command,
|
|
304
|
+
// or null outside it (agents, scripts, a shell without the integration)
|
|
305
|
+
export function cloudSessionShellUpdate(): number | null {
|
|
306
|
+
const source = process.env[SHELL_UPDATE_FD_ENV]
|
|
265
307
|
if (!source) return null
|
|
266
308
|
const descriptor = Number(source)
|
|
267
309
|
if (!Number.isSafeInteger(descriptor) || descriptor < 3) {
|
|
@@ -275,20 +317,16 @@ function shellUpdateFd(
|
|
|
275
317
|
return descriptor
|
|
276
318
|
}
|
|
277
319
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
throw new Error(
|
|
282
|
-
'Peach shell integration is required so this remote simulator stays connected to the current shell; restart the shell after installing peach',
|
|
283
|
-
)
|
|
284
|
-
}
|
|
285
|
-
return descriptor
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
export function publishCloudSessionToShell(
|
|
320
|
+
// saves the project folder's remote simulator, or forgets it, and hands the
|
|
321
|
+
// same update to the shell integration when it is listening
|
|
322
|
+
export function publishCloudSession(
|
|
289
323
|
session: CloudSession | null,
|
|
290
|
-
descriptor =
|
|
324
|
+
descriptor = cloudSessionShellUpdate(),
|
|
291
325
|
): void {
|
|
326
|
+
const file = projectSessionFile()
|
|
327
|
+
if (session) writeSecureJsonAtomic(file, { session: serializeCloudSession(session) })
|
|
328
|
+
else rmSync(file, { force: true })
|
|
329
|
+
if (descriptor === null) return
|
|
292
330
|
const update = session
|
|
293
331
|
? `${RNX_SHELL_UPDATE_SET_PREFIX}${serializeCloudSession(session)}`
|
|
294
332
|
: RNX_SHELL_UPDATE_UNSET
|
package/cli/commands/box.ts
CHANGED
|
@@ -35,7 +35,10 @@ import { readDefaultBox, writeDefaultBox } from '../../src/home-paths'
|
|
|
35
35
|
import { rnxPublicBrand } from '../../src/public-brand'
|
|
36
36
|
import { readNativeLinkedAppFontsWire } from '../app-fonts'
|
|
37
37
|
import { authHeaderOrExit, cloudAccountIdOrExit, type CliAuth } from '../auth'
|
|
38
|
-
import {
|
|
38
|
+
import {
|
|
39
|
+
produceCloudBoxArtifact,
|
|
40
|
+
type CloudBoxArtifactProduction,
|
|
41
|
+
} from '../cloud-box-artifact.ts'
|
|
39
42
|
import { openUrl } from '../open-url'
|
|
40
43
|
import { findRepositoryPackageRoot } from '../setup-repository'
|
|
41
44
|
import { resolvePlacement } from '../ws-bridge'
|
|
@@ -637,7 +640,10 @@ async function runCloudBoxCreate(
|
|
|
637
640
|
// embeds them. the box service owns the size ceiling, not this producer.
|
|
638
641
|
let artifact: CloudBoxArtifactProduction
|
|
639
642
|
try {
|
|
640
|
-
artifact = await produceCloudBoxArtifact(resolved,
|
|
643
|
+
artifact = await produceCloudBoxArtifact(resolved, 'ios', {
|
|
644
|
+
assetsDirectory,
|
|
645
|
+
nativeProjectDir,
|
|
646
|
+
})
|
|
641
647
|
} catch (error) {
|
|
642
648
|
console.error(
|
|
643
649
|
` ${peach} box create: could not prepare the bundle at ${resolved}: ${
|
package/cli/commands/compat.ts
CHANGED
|
@@ -487,8 +487,9 @@ function printVersions(findings: CompatFindings): void {
|
|
|
487
487
|
}
|
|
488
488
|
}
|
|
489
489
|
|
|
490
|
-
// packages appear worst first with the published implementation percent
|
|
491
|
-
// complete capability details. javascript-only packages sit
|
|
490
|
+
// packages appear worst first with the published implementation percent;
|
|
491
|
+
// --verbose adds complete capability details. javascript-only packages sit
|
|
492
|
+
// last on one line.
|
|
492
493
|
function printPackages(
|
|
493
494
|
packages: readonly PackageResult[],
|
|
494
495
|
verbose: boolean,
|
|
@@ -527,9 +528,11 @@ function printPackages(
|
|
|
527
528
|
console.log(
|
|
528
529
|
` ${row.glyph} ${row.item.name.padEnd(nameWidth)}${muted(row.item.version.padEnd(versionWidth))}${percent.padStart(5)}${detail ? ` ${row.tone(detail)}` : ''}`,
|
|
529
530
|
)
|
|
530
|
-
|
|
531
|
+
// by default a package shows only what it lacks, and only when it is not
|
|
532
|
+
// fully supported; --verbose adds what works for every package
|
|
533
|
+
if (!effectiveStubs.has(row.item.name) && (verbose || row.rank < RANK.supported)) {
|
|
531
534
|
for (const [label, text] of [
|
|
532
|
-
['working', row.item.rnx.working],
|
|
535
|
+
['working', verbose ? row.item.rnx.working : undefined],
|
|
533
536
|
['missing', row.item.rnx.missing],
|
|
534
537
|
]) {
|
|
535
538
|
if (!text) continue
|