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/cli/commands/platform.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto'
|
|
2
|
+
import { mkdtempSync, rmSync, statSync } from 'node:fs'
|
|
3
|
+
import { tmpdir } from 'node:os'
|
|
4
|
+
import { join, resolve } from 'node:path'
|
|
2
5
|
// `peach ios` and `peach android` — start a simulator on that platform.
|
|
3
6
|
//
|
|
4
7
|
// the platform picks the device; the command context picks where the sim runs
|
|
@@ -97,7 +100,7 @@ function remoteInputFromArgs(
|
|
|
97
100
|
}
|
|
98
101
|
if (positional.length !== 1 || !positional[0]) {
|
|
99
102
|
throw new Error(
|
|
100
|
-
`usage: peach remote ${platform} <local bundle.js|https://bundle-url> [--device <model>] [--url <link>] [--reuse|--new]`,
|
|
103
|
+
`usage: peach remote ${platform} <app-dir|local bundle.js|https://bundle-url> [--device <model>] [--url <link>] [--reuse|--new]`,
|
|
101
104
|
)
|
|
102
105
|
}
|
|
103
106
|
const reuse = args.includes('--reuse')
|
|
@@ -297,9 +300,9 @@ async function runRemoteCreate(
|
|
|
297
300
|
},
|
|
298
301
|
{
|
|
299
302
|
createCloudSession,
|
|
300
|
-
|
|
303
|
+
publishCloudSession,
|
|
301
304
|
readCloudSession,
|
|
302
|
-
|
|
305
|
+
cloudSessionShellUpdate,
|
|
303
306
|
},
|
|
304
307
|
{ openInBrowser },
|
|
305
308
|
] = await Promise.all([
|
|
@@ -314,7 +317,7 @@ async function runRemoteCreate(
|
|
|
314
317
|
input.assetsDirectory,
|
|
315
318
|
)
|
|
316
319
|
assertBundleBuiltFor(artifact.bytes, platform, `peach ${platform} --remote`)
|
|
317
|
-
const descriptor =
|
|
320
|
+
const descriptor = cloudSessionShellUpdate()
|
|
318
321
|
const { auth, header } = authHeaderOrExit(
|
|
319
322
|
`${platform} ${args.includes('--nano') ? '--nano' : '--remote'}`,
|
|
320
323
|
)
|
|
@@ -343,7 +346,7 @@ async function runRemoteCreate(
|
|
|
343
346
|
claimId: claimed.claim.id,
|
|
344
347
|
...(streamUrl ? { streamUrl } : {}),
|
|
345
348
|
})
|
|
346
|
-
|
|
349
|
+
publishCloudSession(session, descriptor)
|
|
347
350
|
console.log(
|
|
348
351
|
` reconnected to remote simulator: ${existingSession.simId} (${platform})`,
|
|
349
352
|
)
|
|
@@ -367,7 +370,7 @@ async function runRemoteCreate(
|
|
|
367
370
|
assetsDirectory: input.assetsDirectory,
|
|
368
371
|
})
|
|
369
372
|
try {
|
|
370
|
-
|
|
373
|
+
publishCloudSession(created.session, descriptor)
|
|
371
374
|
} catch (error) {
|
|
372
375
|
await closeCloudSession(created.session)
|
|
373
376
|
throw error
|
|
@@ -431,51 +434,71 @@ async function runRemoteBox(
|
|
|
431
434
|
BoxBootFailedError,
|
|
432
435
|
closeCloudBox,
|
|
433
436
|
closeCloudSession,
|
|
434
|
-
produceCloudBoxArtifact,
|
|
435
437
|
awaitBoxBoot,
|
|
436
438
|
requestBoxWatchUrl,
|
|
439
|
+
shortWatchUrl,
|
|
437
440
|
},
|
|
438
441
|
box,
|
|
439
442
|
{ cloudBoxConnectUrl, ensureCloudBoxBrowser, readCloudBoxSession },
|
|
440
443
|
{ authHeaderOrExit, cloudAccountIdOrExit },
|
|
444
|
+
{ buildRemoteProjectBundle },
|
|
441
445
|
{
|
|
442
446
|
createCloudBoxSession,
|
|
443
|
-
|
|
447
|
+
publishCloudSession,
|
|
444
448
|
readCloudSession,
|
|
445
449
|
serializeCloudSession,
|
|
446
450
|
PEACH_CLOUD_SESSION_ENV,
|
|
447
451
|
},
|
|
452
|
+
{ produceCloudBoxArtifact },
|
|
448
453
|
] = await Promise.all([
|
|
449
454
|
import('../cloud-client'),
|
|
450
455
|
import('./box'),
|
|
451
456
|
import('peach-cloud-box/client'),
|
|
452
457
|
import('../auth'),
|
|
458
|
+
import('../remote-project-bundle'),
|
|
453
459
|
import('../cloud-session'),
|
|
460
|
+
import('../cloud-box-artifact.ts'),
|
|
454
461
|
])
|
|
455
462
|
const { openInBrowser } = box
|
|
456
463
|
// an app that cannot boot never gets a simulator, so the box ends with the
|
|
457
464
|
// error instead of billing until someone finds it.
|
|
458
|
-
const
|
|
465
|
+
const closeBoxOnBootFailure = async <T>(
|
|
466
|
+
session: CloudBoxSession,
|
|
467
|
+
work: () => Promise<T>,
|
|
468
|
+
): Promise<T> => {
|
|
459
469
|
try {
|
|
460
|
-
await
|
|
461
|
-
apiOrigin: session.apiOrigin,
|
|
462
|
-
boxId: session.boxId,
|
|
463
|
-
boxToken: session.boxToken,
|
|
464
|
-
})
|
|
470
|
+
return await work()
|
|
465
471
|
} catch (error) {
|
|
466
472
|
if (error instanceof BoxBootFailedError) {
|
|
467
473
|
await closeCloudBox(session)
|
|
468
|
-
|
|
469
|
-
publishCloudSessionToShell(null)
|
|
470
|
-
} catch {
|
|
471
|
-
// no shell update channel is required outside an interactive peach shell
|
|
472
|
-
}
|
|
474
|
+
publishCloudSession(null)
|
|
473
475
|
delete process.env[PEACH_CLOUD_SESSION_ENV]
|
|
474
476
|
}
|
|
475
477
|
throw error
|
|
476
478
|
}
|
|
477
479
|
}
|
|
478
|
-
|
|
480
|
+
// an app folder is built here, and its native modules and fonts come from it
|
|
481
|
+
const projectDir =
|
|
482
|
+
!/^https?:/.test(input.bundlePath) &&
|
|
483
|
+
statSync(input.bundlePath, { throwIfNoEntry: false })?.isDirectory()
|
|
484
|
+
? resolve(input.bundlePath)
|
|
485
|
+
: null
|
|
486
|
+
if (projectDir && (input.assetsDirectory || input.nativeProjectDir))
|
|
487
|
+
throw new Error('--assets and --native-project apply to a prebuilt bundle')
|
|
488
|
+
const nativeProjectDir = projectDir ?? input.nativeProjectDir
|
|
489
|
+
const buildDir = projectDir && mkdtempSync(join(tmpdir(), 'peach-remote-'))
|
|
490
|
+
let artifact: Awaited<ReturnType<typeof produceCloudBoxArtifact>>
|
|
491
|
+
try {
|
|
492
|
+
artifact = await produceCloudBoxArtifact(
|
|
493
|
+
projectDir && buildDir
|
|
494
|
+
? await buildRemoteProjectBundle(projectDir, platform, buildDir)
|
|
495
|
+
: input.bundlePath,
|
|
496
|
+
platform,
|
|
497
|
+
{ assetsDirectory: buildDir || input.assetsDirectory, nativeProjectDir },
|
|
498
|
+
)
|
|
499
|
+
} finally {
|
|
500
|
+
if (buildDir) rmSync(buildDir, { recursive: true, force: true })
|
|
501
|
+
}
|
|
479
502
|
assertBundleBuiltFor(artifact.bytes, platform, `peach ${command}`)
|
|
480
503
|
// the session records which bundle a box already holds, so reattaching can
|
|
481
504
|
// tell the same app from a rebuilt one. the box producer returns no digest
|
|
@@ -487,7 +510,7 @@ async function runRemoteBox(
|
|
|
487
510
|
// a launch link only means something to an app that is launching, so a box
|
|
488
511
|
// already running this bundle is never reattached in its place.
|
|
489
512
|
if (
|
|
490
|
-
!
|
|
513
|
+
!nativeProjectDir &&
|
|
491
514
|
!input.initialUrl &&
|
|
492
515
|
existingSession?.service === 'box' &&
|
|
493
516
|
!input.fresh &&
|
|
@@ -510,13 +533,16 @@ async function runRemoteBox(
|
|
|
510
533
|
})
|
|
511
534
|
// a lapsed tab reboots the app, so a reconnect reads that boot's outcome
|
|
512
535
|
// before waiting on a simulator a throwing app never attaches.
|
|
513
|
-
await
|
|
536
|
+
await closeBoxOnBootFailure(existingSession, () => awaitBoxBoot(existingSession))
|
|
514
537
|
// grants are short-lived, so a reconnect mints a fresh one rather than
|
|
515
538
|
// reopening whatever url the create printed.
|
|
516
|
-
const
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
539
|
+
const signedIn = authHeaderOrExit(command)
|
|
540
|
+
const watchUrl = await shortWatchUrl({
|
|
541
|
+
apiOrigin: box.cloudBoxApiOrigin(args, signedIn.auth),
|
|
542
|
+
authHeader: signedIn.header,
|
|
543
|
+
watchUrl: await closeBoxOnBootFailure(existingSession, () =>
|
|
544
|
+
requestBoxWatchUrl(existingSession),
|
|
545
|
+
),
|
|
520
546
|
})
|
|
521
547
|
console.log(
|
|
522
548
|
` reconnected to remote simulator: ${existingSession.boxId} (${platform})`,
|
|
@@ -532,20 +558,18 @@ async function runRemoteBox(
|
|
|
532
558
|
|
|
533
559
|
if (existingSession?.service === 'box') {
|
|
534
560
|
await closeCloudBox(existingSession)
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
// no shell update channel is required outside an interactive peach shell
|
|
539
|
-
}
|
|
561
|
+
// the shell takes exactly one update, the new box's below; until then
|
|
562
|
+
// only the folder forgets the closed one
|
|
563
|
+
publishCloudSession(null, null)
|
|
540
564
|
} else if (existingSession) {
|
|
541
565
|
await closeCloudSession(existingSession)
|
|
542
566
|
}
|
|
543
567
|
const { box: created, appFontsWireSha256 } = await box.createPrebuiltBundleBox({
|
|
544
568
|
bundle: new Uint8Array(artifact.bytes),
|
|
545
|
-
nativeProjectDir
|
|
569
|
+
nativeProjectDir,
|
|
546
570
|
device: selectedDevice,
|
|
547
571
|
initialUrl: input.initialUrl,
|
|
548
|
-
name: input.name ?? boxNameForBundle(input.bundlePath),
|
|
572
|
+
name: input.name ?? boxNameForBundle(projectDir ?? input.bundlePath),
|
|
549
573
|
fresh: input.name === null,
|
|
550
574
|
endpoint,
|
|
551
575
|
apiOrigin: box.cloudBoxApiOrigin(args, auth),
|
|
@@ -577,13 +601,7 @@ async function runRemoteBox(
|
|
|
577
601
|
await closeCloudBox(session)
|
|
578
602
|
throw error
|
|
579
603
|
}
|
|
580
|
-
|
|
581
|
-
try {
|
|
582
|
-
publishCloudSessionToShell(session)
|
|
583
|
-
} catch {
|
|
584
|
-
// shell update fd not configured
|
|
585
|
-
attachedToShell = false
|
|
586
|
-
}
|
|
604
|
+
publishCloudSession(session)
|
|
587
605
|
process.env[PEACH_CLOUD_SESSION_ENV] = serializeCloudSession(session)
|
|
588
606
|
|
|
589
607
|
console.log(` box: ${created.id} (${artifact.bytes.length} bytes)`)
|
|
@@ -592,24 +610,19 @@ async function runRemoteBox(
|
|
|
592
610
|
console.log(` artifact: sha256:${artifactSha256}`)
|
|
593
611
|
// the dest directory was chosen by resolving this bundle's descriptors
|
|
594
612
|
// against it, so say which one won rather than leaving it invisible.
|
|
595
|
-
if (artifact.assetsDirectory
|
|
613
|
+
if (artifact.assetsDirectory && !projectDir)
|
|
614
|
+
console.log(` asset dest: ${artifact.assetsDirectory}`)
|
|
615
|
+
if (artifact.nativeProject) console.log(` native modules: ${artifact.nativeProject}`)
|
|
596
616
|
for (const warning of artifact.warnings) console.warn(` warning: ${warning}`)
|
|
597
617
|
console.log(REMOTE_COMMANDS_HELP)
|
|
598
|
-
// without the shell integration no later command reaches this box, so
|
|
599
|
-
// `peach remote close` cannot end it; name the command that does.
|
|
600
|
-
if (!attachedToShell) {
|
|
601
|
-
console.log(
|
|
602
|
-
` this shell has no Peach integration; the Box bills until: ${rnxPublicBrand.commandName} box delete ${created.id}`,
|
|
603
|
-
)
|
|
604
|
-
}
|
|
605
618
|
// the session is published before the grant is minted, so a grant that never
|
|
606
619
|
// arrives still leaves the box addressable: re-running this command mints it.
|
|
607
|
-
const watchUrl = await
|
|
608
|
-
apiOrigin:
|
|
609
|
-
|
|
610
|
-
|
|
620
|
+
const watchUrl = await shortWatchUrl({
|
|
621
|
+
apiOrigin: box.cloudBoxApiOrigin(args, auth),
|
|
622
|
+
authHeader: header,
|
|
623
|
+
watchUrl: await closeBoxOnBootFailure(session, () => requestBoxWatchUrl(session)),
|
|
611
624
|
})
|
|
612
|
-
await
|
|
625
|
+
await closeBoxOnBootFailure(session, () => awaitBoxBoot(session))
|
|
613
626
|
console.log(` open ${watchUrl}`)
|
|
614
627
|
return openInBrowser(watchUrl)
|
|
615
628
|
}
|
|
@@ -687,7 +700,7 @@ export async function runRemoteStop(args: string[]): Promise<number> {
|
|
|
687
700
|
{ authHeaderOrExit, cloudAccountIdOrExit },
|
|
688
701
|
{ stopAccountRemoteSimulator },
|
|
689
702
|
{ cloudBoxApiOrigin },
|
|
690
|
-
{
|
|
703
|
+
{ publishCloudSession, readCloudSession, cloudSessionShellUpdate },
|
|
691
704
|
] = await Promise.all([
|
|
692
705
|
import('../auth'),
|
|
693
706
|
import('../remote-simulators'),
|
|
@@ -700,13 +713,11 @@ export async function runRemoteStop(args: string[]): Promise<number> {
|
|
|
700
713
|
} catch {
|
|
701
714
|
current = null
|
|
702
715
|
}
|
|
703
|
-
// stopping the
|
|
704
|
-
|
|
705
|
-
const descriptor =
|
|
716
|
+
// stopping the project's own simulator forgets it, and the shell's with it
|
|
717
|
+
const ownSession =
|
|
706
718
|
(current?.service === 'sim' && current.simId === simId) ||
|
|
707
719
|
(current?.service === 'box' && current.boxId === simId)
|
|
708
|
-
|
|
709
|
-
: null
|
|
720
|
+
const descriptor = ownSession ? cloudSessionShellUpdate() : null
|
|
710
721
|
const { auth, header } = authHeaderOrExit('remote stop')
|
|
711
722
|
const accountId = cloudAccountIdOrExit(auth)
|
|
712
723
|
const deleted = await stopAccountRemoteSimulator(
|
|
@@ -723,7 +734,7 @@ export async function runRemoteStop(args: string[]): Promise<number> {
|
|
|
723
734
|
)
|
|
724
735
|
return 1
|
|
725
736
|
}
|
|
726
|
-
if (
|
|
737
|
+
if (ownSession) publishCloudSession(null, descriptor)
|
|
727
738
|
console.log(` stopped remote simulator: ${deleted.simId}`)
|
|
728
739
|
return 0
|
|
729
740
|
} catch (error) {
|
package/cli/commands/preview.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { spawn, type ChildProcess } from 'node:child_process'
|
|
2
2
|
import { createHash } from 'node:crypto'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
closeSync,
|
|
5
|
+
existsSync,
|
|
6
|
+
mkdtempSync,
|
|
7
|
+
openSync,
|
|
8
|
+
readFileSync,
|
|
9
|
+
rmSync,
|
|
10
|
+
statSync,
|
|
11
|
+
} from 'node:fs'
|
|
4
12
|
import { createRequire } from 'node:module'
|
|
5
13
|
import { createServer } from 'node:net'
|
|
6
14
|
import { tmpdir } from 'node:os'
|
|
@@ -17,6 +25,7 @@ import { authHeaderValue, cloudAccountIdOrExit, resolveCliAuth } from '../auth'
|
|
|
17
25
|
import { producePreviewArtifact } from '../cloud-client'
|
|
18
26
|
import { publishLiveDevStack, type PublishedLiveDevStack } from '../cloud-test-tunnel'
|
|
19
27
|
import { openUrl } from '../open-url'
|
|
28
|
+
import { PRIVATE_PREVIEW_NOTE } from '../recording-access'
|
|
20
29
|
import { detectProject } from './detect'
|
|
21
30
|
import {
|
|
22
31
|
parseServerMessage,
|
|
@@ -34,6 +43,43 @@ function takeValue(args: string[], flag: string): string | null {
|
|
|
34
43
|
return value
|
|
35
44
|
}
|
|
36
45
|
|
|
46
|
+
// an `npx expo export` output directory carries metadata.json naming one
|
|
47
|
+
// bundle per exported platform. returns that bundle for the requested platform,
|
|
48
|
+
// or null when the directory is not an expo export at all.
|
|
49
|
+
function resolveExpoExportBundle(
|
|
50
|
+
exportDir: string,
|
|
51
|
+
platform: 'ios' | 'android',
|
|
52
|
+
): string | null {
|
|
53
|
+
const metadataPath = join(exportDir, 'metadata.json')
|
|
54
|
+
if (!existsSync(metadataPath)) return null
|
|
55
|
+
let metadata: unknown
|
|
56
|
+
try {
|
|
57
|
+
metadata = JSON.parse(readFileSync(metadataPath, 'utf8'))
|
|
58
|
+
} catch {
|
|
59
|
+
return null
|
|
60
|
+
}
|
|
61
|
+
if (!isRecord(metadata) || !isRecord(metadata.fileMetadata)) return null
|
|
62
|
+
const entry = metadata.fileMetadata[platform]
|
|
63
|
+
if (!isRecord(entry) || typeof entry.bundle !== 'string' || !entry.bundle) {
|
|
64
|
+
const exported = Object.keys(metadata.fileMetadata).join(', ') || 'none'
|
|
65
|
+
throw new Error(
|
|
66
|
+
`peach preview found an Expo export in ${exportDir} with no ${platform} bundle (exported: ${exported}). Export with \`npx expo export --platform ${platform} --no-bytecode\`.`,
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
if (entry.bundle.endsWith('.hbc')) {
|
|
70
|
+
throw new Error(
|
|
71
|
+
`peach preview cannot preview Hermes bytecode (${entry.bundle}). Export plain JavaScript with \`npx expo export --platform ${platform} --no-bytecode\` and preview the dist directory again.`,
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
const bundlePath = join(exportDir, entry.bundle)
|
|
75
|
+
if (!existsSync(bundlePath)) {
|
|
76
|
+
throw new Error(
|
|
77
|
+
`peach preview found an Expo export in ${exportDir} but its ${platform} bundle is missing: ${entry.bundle}. Export again with \`npx expo export --platform ${platform} --no-bytecode\`.`,
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
return bundlePath
|
|
81
|
+
}
|
|
82
|
+
|
|
37
83
|
export async function runPreview(args: string[]): Promise<number> {
|
|
38
84
|
try {
|
|
39
85
|
const input = [...args]
|
|
@@ -55,7 +101,7 @@ export async function runPreview(args: string[]): Promise<number> {
|
|
|
55
101
|
throw new Error('--platform must be ios or android')
|
|
56
102
|
}
|
|
57
103
|
if (input.length !== 1 || input[0]?.startsWith('-')) {
|
|
58
|
-
throw new Error('usage: peach preview <project
|
|
104
|
+
throw new Error('usage: peach preview <project|dist|bundle>')
|
|
59
105
|
}
|
|
60
106
|
const auth = resolveCliAuth()
|
|
61
107
|
if (!auth) throw new Error('peach preview needs `peach login` or PEACH_API_KEY')
|
|
@@ -63,24 +109,29 @@ export async function runPreview(args: string[]): Promise<number> {
|
|
|
63
109
|
|
|
64
110
|
const target = input[0]
|
|
65
111
|
const projectPath = resolve(target)
|
|
112
|
+
let bundleTarget: string | null = null
|
|
66
113
|
if (!/^https?:/.test(target) && statSync(projectPath).isDirectory()) {
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
console.log(
|
|
77
|
-
|
|
78
|
-
|
|
114
|
+
const expoBundle = resolveExpoExportBundle(projectPath, platform)
|
|
115
|
+
if (!expoBundle) {
|
|
116
|
+
const receipt = await publishProjectPreview(
|
|
117
|
+
projectPath,
|
|
118
|
+
platform,
|
|
119
|
+
origin,
|
|
120
|
+
authHeaderValue(auth),
|
|
121
|
+
accountId,
|
|
122
|
+
)
|
|
123
|
+
if (json) console.log(JSON.stringify(receipt))
|
|
124
|
+
else {
|
|
125
|
+
console.log(` preview: ${receipt.previewUrl}`)
|
|
126
|
+
console.log(` job: ${receipt.jobId}`)
|
|
127
|
+
console.log(` artifact: ${JSON.stringify(receipt.artifact)}`)
|
|
128
|
+
}
|
|
129
|
+
if (open) await openUrl(receipt.previewUrl)
|
|
130
|
+
return 0
|
|
79
131
|
}
|
|
80
|
-
|
|
81
|
-
return 0
|
|
132
|
+
bundleTarget = expoBundle
|
|
82
133
|
}
|
|
83
|
-
const artifact = await producePreviewArtifact(target)
|
|
134
|
+
const artifact = await producePreviewArtifact(bundleTarget ?? target)
|
|
84
135
|
const bundle = getCliRuntime().preview_compress_node.brotliBundle(artifact.bytes)
|
|
85
136
|
const initBody: InitRequestBody = {
|
|
86
137
|
kind: 'build',
|
|
@@ -127,11 +178,7 @@ export async function runPreview(args: string[]): Promise<number> {
|
|
|
127
178
|
)
|
|
128
179
|
else {
|
|
129
180
|
console.log(` preview: ${url}`)
|
|
130
|
-
if (finalize.visibility === 'private')
|
|
131
|
-
console.log(
|
|
132
|
-
" private: only signed-in members of your account can open it; turn on Public link in the page's share menu to share it",
|
|
133
|
-
)
|
|
134
|
-
}
|
|
181
|
+
if (finalize.visibility === 'private') console.log(PRIVATE_PREVIEW_NOTE)
|
|
135
182
|
console.log(
|
|
136
183
|
` artifact: sha256:${artifact.sha256} (${artifact.bytes.byteLength} bytes)`,
|
|
137
184
|
)
|
|
@@ -181,10 +228,12 @@ async function publishProjectPreview(
|
|
|
181
228
|
throw new Error(
|
|
182
229
|
`cloud previews are paid from your account balance (${parseServerMessage(await preflight.text()) ?? 'no credit available'}). add credit at ${origin}/billing and run it again.`,
|
|
183
230
|
)
|
|
184
|
-
if (!preflight.ok)
|
|
231
|
+
if (!preflight.ok) {
|
|
232
|
+
const text = await preflight.text()
|
|
185
233
|
throw new Error(
|
|
186
|
-
`hosted build
|
|
234
|
+
`hosted build refused (${preflight.status}): ${parseServerMessage(text) ?? text}`,
|
|
187
235
|
)
|
|
236
|
+
}
|
|
188
237
|
const expoRoot = dirname(
|
|
189
238
|
createRequire(join(projectPath, 'package.json')).resolve('expo/package.json'),
|
|
190
239
|
)
|
package/cli/commands/record.ts
CHANGED
|
@@ -18,7 +18,7 @@ import { githubUploadIdentity, resolveCliAuth } from '../auth'
|
|
|
18
18
|
import { getCliIdentityKey } from '../current-sim'
|
|
19
19
|
import { openUrl } from '../open-url'
|
|
20
20
|
import { previewCaptureKind } from '../preview-capture'
|
|
21
|
-
import { ensureCliRecordingEntitlement } from '../recording-access'
|
|
21
|
+
import { ensureCliRecordingEntitlement, PRIVATE_PREVIEW_NOTE } from '../recording-access'
|
|
22
22
|
import { resolveRunProvenance } from '../run-registry'
|
|
23
23
|
import { peachExit } from '../run-rnx'
|
|
24
24
|
import {
|
|
@@ -1724,9 +1724,11 @@ async function evalStoreStop(bridge: WsBridge): Promise<boolean | 'pending'> {
|
|
|
1724
1724
|
|
|
1725
1725
|
interface StoreUploadResult {
|
|
1726
1726
|
previewUrl?: string
|
|
1727
|
+
previewId?: string
|
|
1727
1728
|
uploadError?: string
|
|
1728
1729
|
eventCount?: number
|
|
1729
1730
|
phases?: Array<{ label: string; ms: number }>
|
|
1731
|
+
visibility?: 'private' | 'public'
|
|
1730
1732
|
}
|
|
1731
1733
|
|
|
1732
1734
|
async function pollStoreUpload(bridge: WsBridge): Promise<StoreUploadResult> {
|
|
@@ -1735,9 +1737,11 @@ async function pollStoreUpload(bridge: WsBridge): Promise<StoreUploadResult> {
|
|
|
1735
1737
|
const snap: {
|
|
1736
1738
|
state: 'idle' | 'recording' | 'processing'
|
|
1737
1739
|
lastUpload: {
|
|
1740
|
+
id?: string
|
|
1738
1741
|
previewUrl?: string
|
|
1739
1742
|
eventCount?: number
|
|
1740
1743
|
phases?: Array<{ label: string; ms: number }>
|
|
1744
|
+
visibility?: 'private' | 'public'
|
|
1741
1745
|
} | null
|
|
1742
1746
|
uploadError: string | null
|
|
1743
1747
|
uploadRemainingMs: number | null
|
|
@@ -1757,8 +1761,10 @@ async function pollStoreUpload(bridge: WsBridge): Promise<StoreUploadResult> {
|
|
|
1757
1761
|
if (snap.lastUpload?.previewUrl) {
|
|
1758
1762
|
return {
|
|
1759
1763
|
previewUrl: snap.lastUpload.previewUrl,
|
|
1764
|
+
previewId: snap.lastUpload.id,
|
|
1760
1765
|
eventCount: snap.lastUpload.eventCount,
|
|
1761
1766
|
phases: snap.lastUpload.phases,
|
|
1767
|
+
visibility: snap.lastUpload.visibility,
|
|
1762
1768
|
}
|
|
1763
1769
|
}
|
|
1764
1770
|
}
|
|
@@ -1781,6 +1787,8 @@ function handleStoreUploadResult(
|
|
|
1781
1787
|
peachExit(1)
|
|
1782
1788
|
}
|
|
1783
1789
|
console.log(` preview: ${result.previewUrl}`)
|
|
1790
|
+
if (result.previewId) console.log(` preview id: ${result.previewId}`)
|
|
1791
|
+
if (result.visibility === 'private') console.log(PRIVATE_PREVIEW_NOTE)
|
|
1784
1792
|
if (result.phases?.length) {
|
|
1785
1793
|
console.log(
|
|
1786
1794
|
` upload phases: ${result.phases.map(({ label, ms }) => `${label} ${(ms / 1000).toFixed(1)}s`).join(', ')}`,
|
|
@@ -1794,7 +1802,7 @@ function handleStoreUploadResult(
|
|
|
1794
1802
|
// warning (QA F19-4). say so once so the reuse is a known choice.
|
|
1795
1803
|
console.log(
|
|
1796
1804
|
' note: this URL is content-addressed — re-recording the same bundle\n' +
|
|
1797
|
-
' replaces this capture at the same
|
|
1805
|
+
' replaces this capture at the same link.',
|
|
1798
1806
|
)
|
|
1799
1807
|
// surface how many interaction events were captured (F14-7). without this
|
|
1800
1808
|
// the CLI gave no signal that an event-capture regression shipped a stale
|
|
@@ -2,29 +2,27 @@
|
|
|
2
2
|
//
|
|
3
3
|
// prefers the WS bridge when one is reachable so the screenshot comes from
|
|
4
4
|
// the user's current sim (and can be cropped to a logical
|
|
5
|
-
// rect via --area / --id / --text).
|
|
6
|
-
//
|
|
7
|
-
// without a daemon.
|
|
5
|
+
// rect via --area / --id / --text). with no sim connected it says so and
|
|
6
|
+
// shows how to open one.
|
|
8
7
|
|
|
9
|
-
import {
|
|
10
|
-
import { dirname, resolve } from 'path'
|
|
11
|
-
import { DEFAULT_SOOTSIM_BRIDGE_PORT } from '../../src/bridge-constants'
|
|
8
|
+
import { resolve } from 'path'
|
|
12
9
|
import { devices, type DeviceModel } from '../../src/device-catalog.ts'
|
|
13
|
-
import { launchReapedChrome } from '../../src/reap-browser'
|
|
14
10
|
import { composeFramedScreenshot } from '../../src/screenshots/frame-compose'
|
|
15
11
|
import { buildResolveRectEval, type SampleRect } from '../browser-evals'
|
|
16
12
|
import { createCloudBridgeForParsed } from '../cloud-client'
|
|
17
13
|
import { peachExit } from '../run-rnx'
|
|
18
14
|
import { writeScreenshotOutput } from '../screenshot-output'
|
|
19
15
|
import {
|
|
16
|
+
BridgeHandshakeTimeoutError,
|
|
20
17
|
callInBridge,
|
|
21
18
|
checkSimHealth,
|
|
22
19
|
createBridge,
|
|
23
20
|
createBridgeFromParsed,
|
|
24
|
-
isLiveBridge,
|
|
25
21
|
parseBridgeCliArgs,
|
|
22
|
+
probeBridge,
|
|
26
23
|
} from '../ws-bridge'
|
|
27
24
|
import { inspectCaptureReady, waitReadyReason } from './inspect/core'
|
|
25
|
+
import { printMissingSimHint } from './no-bridge-hint'
|
|
28
26
|
|
|
29
27
|
interface ScreenshotOptions {
|
|
30
28
|
port?: number
|
|
@@ -134,9 +132,9 @@ examples:
|
|
|
134
132
|
return
|
|
135
133
|
}
|
|
136
134
|
const rect = await parseRect(args)
|
|
137
|
-
const
|
|
135
|
+
const probe = await probeBridge(parsed.wsPort)
|
|
138
136
|
|
|
139
|
-
if (
|
|
137
|
+
if (probe.live) {
|
|
140
138
|
// captureViaBridge throws plain Errors for expected conditions (unknown
|
|
141
139
|
// --id / --text, missing device model). surface them as a one-line
|
|
142
140
|
// failure instead of an uncaught internal stack trace.
|
|
@@ -159,21 +157,20 @@ examples:
|
|
|
159
157
|
return
|
|
160
158
|
}
|
|
161
159
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if (rect) {
|
|
169
|
-
console.error(' --area / --id / --text require a running peach bridge')
|
|
160
|
+
// a port that accepts tcp but never completes the upgrade is a hung or
|
|
161
|
+
// overloaded bridge, not an empty one — the no-sim hint would send the user
|
|
162
|
+
// to open an app on a bridge that cannot answer.
|
|
163
|
+
if (probe.error instanceof BridgeHandshakeTimeoutError) {
|
|
164
|
+
console.error('')
|
|
165
|
+
console.error(` ${probe.error.message}`)
|
|
170
166
|
console.error(
|
|
171
|
-
'
|
|
167
|
+
' the bridge may be hung or overloaded; retry, or restart serve if it persists.',
|
|
172
168
|
)
|
|
173
169
|
peachExit(1)
|
|
174
170
|
}
|
|
175
171
|
|
|
176
|
-
|
|
172
|
+
printMissingSimHint(parsed.wsPort)
|
|
173
|
+
peachExit(1)
|
|
177
174
|
}
|
|
178
175
|
|
|
179
176
|
async function parseRect(args: string[]): Promise<SampleRect | null> {
|
|
@@ -401,7 +398,6 @@ const SCREENSHOT_VALUE_FLAGS = new Set([
|
|
|
401
398
|
'--area',
|
|
402
399
|
'--id',
|
|
403
400
|
'--text',
|
|
404
|
-
'--url',
|
|
405
401
|
'--port',
|
|
406
402
|
'--timeout',
|
|
407
403
|
'--sim',
|
|
@@ -483,42 +479,3 @@ function resolveOutputPath(args: string[]): string | undefined {
|
|
|
483
479
|
}
|
|
484
480
|
return undefined
|
|
485
481
|
}
|
|
486
|
-
|
|
487
|
-
// capture a page in headless chromium when no bridge is running.
|
|
488
|
-
async function runPlaywrightScreenshot(args: string[], opts: ScreenshotOptions) {
|
|
489
|
-
const output = resolveOutputPath(args) || 'peach-screenshot.png'
|
|
490
|
-
const url =
|
|
491
|
-
args.find((_, i) => args[i - 1] === '--url') ||
|
|
492
|
-
`http://localhost:${opts.port || 5173}`
|
|
493
|
-
|
|
494
|
-
const { chromium } = await import('playwright')
|
|
495
|
-
const browser = await launchReapedChrome((options) => chromium.launch(options), {
|
|
496
|
-
headless: true,
|
|
497
|
-
})
|
|
498
|
-
|
|
499
|
-
try {
|
|
500
|
-
const page = await browser.newPage({
|
|
501
|
-
viewport: { width: 500, height: 900 },
|
|
502
|
-
// this fallback screenshots a page a person opens; state display density
|
|
503
|
-
// so the PNG is retina rather than half of what the display shows.
|
|
504
|
-
deviceScaleFactor: 2,
|
|
505
|
-
})
|
|
506
|
-
await page.goto(url, { waitUntil: 'networkidle' })
|
|
507
|
-
await page.waitForTimeout(2000)
|
|
508
|
-
|
|
509
|
-
const outputPath = resolve(process.cwd(), output)
|
|
510
|
-
if (outputPath === '/dev/stdout') {
|
|
511
|
-
await writeScreenshotOutput(outputPath, await page.screenshot({ type: 'png' }))
|
|
512
|
-
} else {
|
|
513
|
-
mkdirSync(dirname(outputPath), { recursive: true })
|
|
514
|
-
await page.screenshot({ path: outputPath })
|
|
515
|
-
}
|
|
516
|
-
console.log(` saved: ${outputPath}`)
|
|
517
|
-
await page.close()
|
|
518
|
-
} catch (err: any) {
|
|
519
|
-
console.error(` screenshot failed: ${err.message}`)
|
|
520
|
-
process.exitCode = 1
|
|
521
|
-
} finally {
|
|
522
|
-
await browser.close()
|
|
523
|
-
}
|
|
524
|
-
}
|
package/cli/commands/setup.ts
CHANGED
|
@@ -102,7 +102,9 @@ export async function runSetup(
|
|
|
102
102
|
console.log(` ${muted('Would enable')} ${accent('the background service')}`)
|
|
103
103
|
}
|
|
104
104
|
if (!service && !serviceStatus.installed && !options.json) {
|
|
105
|
-
console.log(
|
|
105
|
+
console.log(
|
|
106
|
+
` ${muted('The background service is off; turn it on with')} ${accent('peach daemon install')}`,
|
|
107
|
+
)
|
|
106
108
|
}
|
|
107
109
|
const simulatorDriver = await decideSimulatorDriver(options)
|
|
108
110
|
if (options.dryRun && !options.json) {
|