peachsim 0.1.1620 → 0.1.1635
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/LICENSE +1 -1
- package/README.md +45 -6
- package/cli/app-config.ts +4 -1
- package/cli/app-fonts.ts +39 -18
- package/cli/app-stubs.ts +224 -9
- package/cli/bridge-flow-runner.ts +248 -156
- package/cli/cloud-client.ts +68 -57
- package/cli/command-registry.ts +1 -0
- package/cli/commands/box/search-command.ts +3 -2
- package/cli/commands/box.ts +10 -29
- package/cli/commands/control.ts +391 -92
- package/cli/commands/doctor.ts +17 -184
- package/cli/commands/flow.ts +79 -11
- package/cli/commands/inspect/core.ts +10 -5
- package/cli/commands/inspect/settling.ts +71 -22
- package/cli/commands/inspect/wait-ready.ts +12 -0
- package/cli/commands/inspect.ts +26 -3
- package/cli/commands/install-desktop.ts +1 -0
- package/cli/commands/maestro-compare.ts +105 -67
- package/cli/commands/maestro.ts +9 -1
- package/cli/commands/platform.ts +71 -36
- package/cli/commands/record.ts +21 -1
- package/cli/commands/screenshot.ts +23 -1
- package/cli/commands/serve.ts +7 -2
- package/cli/commands/setup.ts +19 -42
- package/cli/commands/swift.ts +5 -0
- package/cli/commands/upload.ts +51 -8
- package/cli/desktop-companion.ts +102 -17
- package/cli/dev-build-freshness.ts +37 -2
- package/cli/drivers/desktop.ts +14 -1
- package/cli/drivers/playwright-sim-host.ts +44 -8
- package/cli/drivers/playwright.ts +9 -8
- package/cli/drivers/types.ts +5 -0
- package/cli/maestro-accessibility.ts +53 -0
- package/cli/maestro-compare.ts +108 -12
- package/cli/main.ts +2 -1
- package/cli/outbound-endpoints.ts +35 -6
- package/cli/parent-pid.ts +0 -9
- package/cli/pause-aware-timeout.ts +102 -0
- package/cli/remote-simulators.ts +112 -0
- package/cli/remoteSimulatorContract.ts +21 -0
- package/cli/scene-video.ts +89 -0
- package/cli/ws-bridge.ts +23 -14
- package/detox/attempt-events.cjs +4 -0
- package/detox/expectations.ts +5 -1
- package/detox/index.ts +241 -181
- package/detox/motion-change.cjs +73 -0
- package/detox/motion-change.d.cts +21 -0
- package/detox/navigation-lifecycle.ts +22 -4
- package/dist-lib/agent-daemon-client.cjs +3 -2
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +3 -2
- 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 +13 -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 +14 -8
- package/dist-lib/bridge-contract.mjs +13 -7
- package/dist-lib/bundle-channel.cjs +10480 -7962
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- 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 +3 -2
- package/dist-lib/cloud.mjs +3 -2
- package/dist-lib/config.cjs +10 -6
- package/dist-lib/config.mjs +10 -6
- package/dist-lib/detox/index.cjs +1854 -966
- package/dist-lib/dev-bundle-resolution.cjs +64 -24
- package/dist-lib/expo-swift-bundle.cjs +8715 -6271
- package/dist-lib/expo-swift-metadata.cjs +7 -4
- package/dist-lib/expo-swift-metadata.mjs +7 -4
- package/dist-lib/home-paths.cjs +32 -3
- package/dist-lib/host/bridge-host.cjs +10135 -7060
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- 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 +1843 -408
- 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 +3 -2
- package/dist-lib/menu.mjs +3 -2
- 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 +5 -4
- package/dist-lib/metro-production-bundle.mjs +5 -4
- package/dist-lib/metro.cjs +1182 -418
- package/dist-lib/native-app-identity-project.cjs +782 -23
- package/dist-lib/native-app-identity-project.mjs +781 -23
- package/dist-lib/native-app-identity.cjs +276 -9
- package/dist-lib/native-app-identity.mjs +273 -8
- package/dist-lib/native-firebase-metadata.cjs +5 -4
- package/dist-lib/native-firebase-metadata.mjs +5 -4
- 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 +3 -2
- package/dist-lib/react-native-host-modules.cjs +8 -1
- package/dist-lib/react-native-host-modules.mjs +8 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +106 -28
- package/dist-lib/sdk.cjs +115 -34
- package/dist-lib/sdk.mjs +115 -33
- package/dist-lib/skills.cjs +15274 -9904
- package/dist-lib/swift-compile.cjs +1165 -173
- package/dist-lib/swift-compile.mjs +1212 -203
- package/dist-lib/swift-package.cjs +12 -3
- package/dist-lib/swift-package.mjs +12 -3
- package/dist-lib/swift-submit.cjs +7 -1
- package/dist-lib/swift-submit.mjs +5 -1
- package/dist-lib/swift-toolchain.cjs +133 -18
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +2648 -862
- package/dist-lib/vite.cjs +70 -14
- package/dist-lib/worklet-executable.cjs +25 -2
- package/dist-lib/worklet-executable.mjs +25 -2
- package/kotlin/AppSources/dev/peach/app/PeachDrawable.kt +21 -14
- package/kotlin/Sources/androidx/annotation/DrawableRes.kt +14 -0
- package/package.json +2 -2
- package/scripts/dev-server-scanner.ts +35 -14
- package/skills/peach-perf/SKILL.md +11 -5
- package/skills/peach-setup/SKILL.md +16 -19
- package/src/admitted-mac-build.ts +34 -8
- package/src/android-app-identity.ts +146 -0
- package/src/android-autolinking.ts +75 -0
- package/src/android-string-value.ts +36 -0
- package/src/android-strings.ts +5 -36
- package/src/androidAutolinkingContract.ts +40 -0
- package/src/bridge-constants.ts +11 -0
- package/src/bridge-contract.ts +22 -34
- package/src/bundleGlobalFooter.ts +26 -7
- package/src/codex-client.ts +3 -2
- package/src/config.ts +15 -0
- package/src/desktop-host-delivery.ts +5 -1
- package/src/dev-bundle-resolution.ts +60 -26
- package/src/expo-kotlin-host.ts +6 -36
- package/src/expo-manifest-body.ts +13 -0
- package/src/expo-swift-bundle.ts +17 -12
- package/src/expo-swift-host.ts +640 -192
- package/src/expo-swift-ready.ts +78 -0
- package/src/expoSwiftContract.ts +19 -0
- package/src/home-paths.ts +48 -2
- package/src/host/bridge-host.ts +12 -57
- package/src/host/staged-host-files.ts +29 -2
- package/src/installed-package-versions.ts +54 -14
- package/src/launchMetadataContract.ts +24 -0
- package/src/metro-plugin.ts +37 -42
- package/src/native-app-identity-project.ts +142 -5
- package/src/native-app-identity.ts +176 -11
- package/src/native-firebase-config.ts +209 -13
- package/src/nitro-compile.ts +2 -5
- package/src/nitro-source.ts +147 -63
- package/src/process-group.ts +114 -61
- package/src/process-output.ts +0 -9
- package/src/public-brand.ts +1 -0
- package/src/react-native-bridge-modules.ts +416 -0
- package/src/react-native-host-modules.ts +7 -0
- package/src/sim-client.ts +6 -4
- package/src/swift-binary-modules.ts +2 -2
- package/src/swift-compile.ts +1007 -108
- package/src/swift-compiler-digest.ts +14 -0
- package/src/swift-distribution.lock.json +40 -12
- package/src/swift-distribution.ts +61 -9
- package/src/swift-host.ts +149 -56
- package/src/swift-icu.ts +14 -6
- package/src/swift-objc-sdk.ts +133 -10
- package/src/swift-objc-standin.ts +38 -3
- package/src/swift-package-manifest.ts +21 -6
- package/src/swift-package.ts +15 -1
- package/src/swift-packages.ts +119 -60
- package/src/swift-standin-emit.ts +57 -9
- package/src/swift-standins.ts +185 -25
- package/src/swift-submit.ts +10 -0
- package/src/swift-toolchain.ts +149 -23
- package/src/vite-plugin.ts +20 -20
- package/src/worklet-executable.ts +30 -3
- package/src/worklets-babel.ts +35 -14
- package/src/xcode-project.ts +10 -0
package/cli/commands/maestro.ts
CHANGED
|
@@ -51,7 +51,12 @@ export interface RunMaestroOptions {
|
|
|
51
51
|
// (maestro compare reads it for the errors Peach saw)
|
|
52
52
|
captureConsole?: boolean
|
|
53
53
|
// each flow's final verdict, including a failure before any step ran
|
|
54
|
-
onFlowResult?: (result: {
|
|
54
|
+
onFlowResult?: (result: {
|
|
55
|
+
file: string
|
|
56
|
+
exit: number
|
|
57
|
+
playbackFailure: string
|
|
58
|
+
outputDir: string | null
|
|
59
|
+
}) => void
|
|
55
60
|
}
|
|
56
61
|
|
|
57
62
|
const MAESTRO_DIRS = ['.maestro', 'maestro']
|
|
@@ -518,6 +523,7 @@ export async function runMaestro(
|
|
|
518
523
|
let worstExit = 0
|
|
519
524
|
const results: Array<{
|
|
520
525
|
file: string
|
|
526
|
+
outputDir: string | null
|
|
521
527
|
exit: number
|
|
522
528
|
durationMs: number
|
|
523
529
|
steps: ReturnType<typeof getLastFlowTraceSteps>
|
|
@@ -537,6 +543,7 @@ export async function runMaestro(
|
|
|
537
543
|
console.error(` error: ${playbackFailure}`)
|
|
538
544
|
results.push({
|
|
539
545
|
file,
|
|
546
|
+
outputDir: flowTestDir,
|
|
540
547
|
exit: 1,
|
|
541
548
|
durationMs: 0,
|
|
542
549
|
steps: [],
|
|
@@ -610,6 +617,7 @@ export async function runMaestro(
|
|
|
610
617
|
}
|
|
611
618
|
const result = {
|
|
612
619
|
file,
|
|
620
|
+
outputDir: flowTestDir,
|
|
613
621
|
exit,
|
|
614
622
|
durationMs,
|
|
615
623
|
steps: traceSteps,
|
package/cli/commands/platform.ts
CHANGED
|
@@ -17,7 +17,7 @@ import { settingsStore } from 'peach-engine/settings/store'
|
|
|
17
17
|
import { rnxPublicBrand } from '../../src/public-brand'
|
|
18
18
|
import { UnsupportedRemoteHostError } from '../cloud-client'
|
|
19
19
|
import { rethrowIfExit } from '../run-rnx'
|
|
20
|
-
import type { CloudSession } from '../cloud-session'
|
|
20
|
+
import type { CloudBoxSession, CloudSession } from '../cloud-session'
|
|
21
21
|
|
|
22
22
|
const PLATFORM_LABEL: Record<RuntimePlatform, string> = {
|
|
23
23
|
ios: 'iOS',
|
|
@@ -275,6 +275,7 @@ async function runRemoteCreate(
|
|
|
275
275
|
const [
|
|
276
276
|
{ authHeaderOrExit, cloudAccountIdOrExit },
|
|
277
277
|
{
|
|
278
|
+
assertBundleBuiltFor,
|
|
278
279
|
claimCloudSimulator,
|
|
279
280
|
closeCloudBox,
|
|
280
281
|
closeCloudSession,
|
|
@@ -300,6 +301,7 @@ async function runRemoteCreate(
|
|
|
300
301
|
undefined,
|
|
301
302
|
input.assetsDirectory,
|
|
302
303
|
)
|
|
304
|
+
assertBundleBuiltFor(artifact.bytes, platform, `peach ${platform} --remote`)
|
|
303
305
|
const descriptor = requireCloudSessionShellUpdate()
|
|
304
306
|
const { auth, header } = authHeaderOrExit(
|
|
305
307
|
`${platform} ${args.includes('--nano') ? '--nano' : '--remote'}`,
|
|
@@ -401,8 +403,8 @@ async function runRemoteCreate(
|
|
|
401
403
|
* a nano upload answers to does not apply.
|
|
402
404
|
*
|
|
403
405
|
* a box created from the already-built app boots it in its own page, and this
|
|
404
|
-
* opens the
|
|
405
|
-
*
|
|
406
|
+
* opens the watch url the box service mints with its display grant, on the
|
|
407
|
+
* deploy that serves that page, as the nano service mints one on its own.
|
|
406
408
|
*/
|
|
407
409
|
async function runRemoteBox(
|
|
408
410
|
platform: RuntimePlatform,
|
|
@@ -413,10 +415,12 @@ async function runRemoteBox(
|
|
|
413
415
|
const input = remoteInputFromArgs(args, platform)
|
|
414
416
|
const [
|
|
415
417
|
{
|
|
418
|
+
assertBundleBuiltFor,
|
|
416
419
|
BoxBootFailedError,
|
|
417
420
|
closeCloudBox,
|
|
418
421
|
closeCloudSession,
|
|
419
422
|
produceCloudBoxArtifact,
|
|
423
|
+
awaitBoxBoot,
|
|
420
424
|
requestBoxWatchUrl,
|
|
421
425
|
},
|
|
422
426
|
box,
|
|
@@ -437,13 +441,35 @@ async function runRemoteBox(
|
|
|
437
441
|
import('../cloud-session'),
|
|
438
442
|
])
|
|
439
443
|
const { openInBrowser } = box
|
|
444
|
+
// an app that cannot boot never gets a simulator, so the box ends with the
|
|
445
|
+
// error instead of billing until someone finds it.
|
|
446
|
+
const awaitBootOrCloseBox = async (session: CloudBoxSession) => {
|
|
447
|
+
try {
|
|
448
|
+
await awaitBoxBoot({
|
|
449
|
+
apiOrigin: session.apiOrigin,
|
|
450
|
+
boxId: session.boxId,
|
|
451
|
+
boxToken: session.boxToken,
|
|
452
|
+
})
|
|
453
|
+
} catch (error) {
|
|
454
|
+
if (error instanceof BoxBootFailedError) {
|
|
455
|
+
await closeCloudBox(session)
|
|
456
|
+
try {
|
|
457
|
+
publishCloudSessionToShell(null)
|
|
458
|
+
} catch {
|
|
459
|
+
// no shell update channel is required outside an interactive peach shell
|
|
460
|
+
}
|
|
461
|
+
delete process.env[PEACH_CLOUD_SESSION_ENV]
|
|
462
|
+
}
|
|
463
|
+
throw error
|
|
464
|
+
}
|
|
465
|
+
}
|
|
440
466
|
const artifact = await produceCloudBoxArtifact(input.bundlePath, input.assetsDirectory)
|
|
467
|
+
assertBundleBuiltFor(artifact.bytes, platform, `peach ${command}`)
|
|
441
468
|
// the session records which bundle a box already holds, so reattaching can
|
|
442
469
|
// tell the same app from a rebuilt one. the box producer returns no digest
|
|
443
470
|
// of its own, so take it here over the bytes that actually crossed.
|
|
444
471
|
const artifactSha256 = createHash('sha256').update(artifact.bytes).digest('hex')
|
|
445
|
-
const endpoint = box.cloudBoxEndpoint(args
|
|
446
|
-
if (!endpoint) return 1
|
|
472
|
+
const endpoint = box.cloudBoxEndpoint(args)
|
|
447
473
|
|
|
448
474
|
const existingSession = readCloudSession()
|
|
449
475
|
// a launch link only means something to an app that is launching, so a box
|
|
@@ -470,6 +496,9 @@ async function runRemoteBox(
|
|
|
470
496
|
connectUrl: cloudBoxConnectUrl(existingSession.apiOrigin, existingSession.boxId),
|
|
471
497
|
accessToken: existingSession.boxToken,
|
|
472
498
|
})
|
|
499
|
+
// a lapsed tab reboots the app, so a reconnect reads that boot's outcome
|
|
500
|
+
// before waiting on a simulator a throwing app never attaches.
|
|
501
|
+
await awaitBootOrCloseBox(existingSession)
|
|
473
502
|
// grants are short-lived, so a reconnect mints a fresh one rather than
|
|
474
503
|
// reopening whatever url the create printed.
|
|
475
504
|
const watchUrl = await requestBoxWatchUrl({
|
|
@@ -562,27 +591,12 @@ async function runRemoteBox(
|
|
|
562
591
|
}
|
|
563
592
|
// the session is published before the grant is minted, so a grant that never
|
|
564
593
|
// arrives still leaves the box addressable: re-running this command mints it.
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
})
|
|
572
|
-
} catch (error) {
|
|
573
|
-
// an app that cannot boot never gets a simulator, so the box ends with the
|
|
574
|
-
// error instead of billing until someone finds it.
|
|
575
|
-
if (error instanceof BoxBootFailedError) {
|
|
576
|
-
await closeCloudBox(session)
|
|
577
|
-
try {
|
|
578
|
-
publishCloudSessionToShell(null)
|
|
579
|
-
} catch {
|
|
580
|
-
// no shell update channel is required outside an interactive peach shell
|
|
581
|
-
}
|
|
582
|
-
delete process.env[PEACH_CLOUD_SESSION_ENV]
|
|
583
|
-
}
|
|
584
|
-
throw error
|
|
585
|
-
}
|
|
594
|
+
const watchUrl = await requestBoxWatchUrl({
|
|
595
|
+
apiOrigin: endpoint,
|
|
596
|
+
boxId: created.id,
|
|
597
|
+
boxToken: created.accessToken ?? '',
|
|
598
|
+
})
|
|
599
|
+
await awaitBootOrCloseBox(session)
|
|
586
600
|
console.log(` open ${watchUrl}`)
|
|
587
601
|
return openInBrowser(watchUrl)
|
|
588
602
|
}
|
|
@@ -598,11 +612,22 @@ export async function runRemoteList(args: string[]): Promise<number> {
|
|
|
598
612
|
}
|
|
599
613
|
throw new Error(`usage: peach remote list [--json]`)
|
|
600
614
|
}
|
|
601
|
-
const [
|
|
602
|
-
|
|
615
|
+
const [
|
|
616
|
+
{ authHeaderOrExit, cloudAccountIdOrExit },
|
|
617
|
+
{ listAccountRemoteSimulators },
|
|
618
|
+
{ cloudBoxApiOrigin },
|
|
619
|
+
] = await Promise.all([
|
|
620
|
+
import('../auth'),
|
|
621
|
+
import('../remote-simulators'),
|
|
622
|
+
import('./box'),
|
|
623
|
+
])
|
|
603
624
|
const { auth, header } = authHeaderOrExit('remote list')
|
|
604
625
|
const accountId = cloudAccountIdOrExit(auth)
|
|
605
|
-
const sims = await
|
|
626
|
+
const sims = await listAccountRemoteSimulators({
|
|
627
|
+
apiOrigin: cloudBoxApiOrigin(args, auth),
|
|
628
|
+
authorization: header,
|
|
629
|
+
accountId,
|
|
630
|
+
})
|
|
606
631
|
if (json) {
|
|
607
632
|
console.log(JSON.stringify({ sims }))
|
|
608
633
|
return 0
|
|
@@ -612,6 +637,10 @@ export async function runRemoteList(args: string[]): Promise<number> {
|
|
|
612
637
|
return 0
|
|
613
638
|
}
|
|
614
639
|
for (const sim of sims) {
|
|
640
|
+
if (sim.service === 'box') {
|
|
641
|
+
console.log(` ${sim.simId} ${sim.status} ${sim.name ?? ''}`)
|
|
642
|
+
continue
|
|
643
|
+
}
|
|
615
644
|
const platformLabel = sim.labels['peach.platform'] ?? 'unknown'
|
|
616
645
|
console.log(
|
|
617
646
|
` ${sim.simId} ${sim.status} ${platformLabel} sha256:${sim.artifact.sha256.slice(0, 12)}`,
|
|
@@ -643,11 +672,13 @@ export async function runRemoteStop(args: string[]): Promise<number> {
|
|
|
643
672
|
const simId = positional[0]
|
|
644
673
|
const [
|
|
645
674
|
{ authHeaderOrExit, cloudAccountIdOrExit },
|
|
646
|
-
{
|
|
675
|
+
{ stopAccountRemoteSimulator },
|
|
676
|
+
{ cloudBoxApiOrigin },
|
|
647
677
|
{ publishCloudSessionToShell, readCloudSession, requireCloudSessionShellUpdate },
|
|
648
678
|
] = await Promise.all([
|
|
649
679
|
import('../auth'),
|
|
650
|
-
import('../
|
|
680
|
+
import('../remote-simulators'),
|
|
681
|
+
import('./box'),
|
|
651
682
|
import('../cloud-session'),
|
|
652
683
|
])
|
|
653
684
|
let current: CloudSession | null = null
|
|
@@ -659,16 +690,20 @@ export async function runRemoteStop(args: string[]): Promise<number> {
|
|
|
659
690
|
// stopping the shell's own simulator clears the shell with it, so the
|
|
660
691
|
// update channel is required before anything is deleted.
|
|
661
692
|
const descriptor =
|
|
662
|
-
current?.service === 'sim' && current.simId === simId
|
|
693
|
+
(current?.service === 'sim' && current.simId === simId) ||
|
|
694
|
+
(current?.service === 'box' && current.boxId === simId)
|
|
663
695
|
? requireCloudSessionShellUpdate()
|
|
664
696
|
: null
|
|
665
697
|
const { auth, header } = authHeaderOrExit('remote stop')
|
|
666
698
|
const accountId = cloudAccountIdOrExit(auth)
|
|
667
|
-
const deleted = await
|
|
699
|
+
const deleted = await stopAccountRemoteSimulator(
|
|
700
|
+
{
|
|
701
|
+
apiOrigin: cloudBoxApiOrigin(args, auth),
|
|
702
|
+
authorization: header,
|
|
703
|
+
accountId,
|
|
704
|
+
},
|
|
668
705
|
simId,
|
|
669
|
-
|
|
670
|
-
accountId,
|
|
671
|
-
})
|
|
706
|
+
)
|
|
672
707
|
if (!deleted) {
|
|
673
708
|
console.error(
|
|
674
709
|
` ${rnxPublicBrand.commandName} remote stop: ${simId} does not exist`,
|
package/cli/commands/record.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// peach record — drives the engine's built-in canvas recorder over
|
|
2
|
-
// the WS bridge.
|
|
2
|
+
// the WS bridge. scene export opens an isolated viewer; encoding happens in the
|
|
3
3
|
// running peach page (webm via MediaRecorder, mp4 via WebCodecs, gif
|
|
4
4
|
// via gifenc, raw png frames via a shared bitmap sampler).
|
|
5
5
|
|
|
@@ -143,6 +143,8 @@ const RECORD_VALUE_FLAGS = new Set([
|
|
|
143
143
|
'--origin',
|
|
144
144
|
'--owner',
|
|
145
145
|
'--repo',
|
|
146
|
+
'--scene',
|
|
147
|
+
'--shell-url',
|
|
146
148
|
])
|
|
147
149
|
const RECORD_SUBCOMMANDS = new Set([
|
|
148
150
|
'start',
|
|
@@ -151,6 +153,7 @@ const RECORD_SUBCOMMANDS = new Set([
|
|
|
151
153
|
'status',
|
|
152
154
|
'prelude-start',
|
|
153
155
|
'upload',
|
|
156
|
+
'render',
|
|
154
157
|
])
|
|
155
158
|
|
|
156
159
|
// the record subcommand (start/stop/cancel/status) is the first non-flag
|
|
@@ -195,6 +198,23 @@ export async function runRecord(args: string[], opts: RecordOptions) {
|
|
|
195
198
|
// drop the subcommand token; the rest (incl. any --sim/--port) flows on
|
|
196
199
|
// to the subcommand handlers, which parse bridge flags themselves.
|
|
197
200
|
const rest = [...args.slice(0, sub.index), ...args.slice(sub.index + 1)]
|
|
201
|
+
if (sub.name === 'render') {
|
|
202
|
+
const scene = valueOf(rest, '--scene')
|
|
203
|
+
const shellUrl = valueOf(rest, '--shell-url')
|
|
204
|
+
const output = valueOf(rest, '--output')
|
|
205
|
+
if (!scene || !shellUrl || !output)
|
|
206
|
+
throw new Error('record render requires --scene, --shell-url and --output')
|
|
207
|
+
const { renderSceneToVideo } = await import('../scene-video')
|
|
208
|
+
const result = await renderSceneToVideo({
|
|
209
|
+
scene: readFileSync(scene),
|
|
210
|
+
shellUrl,
|
|
211
|
+
output,
|
|
212
|
+
})
|
|
213
|
+
console.log(
|
|
214
|
+
` video: ${resolve(output)} (${result.frameCount} frames at 60 fps, ${result.sizeBytes} bytes, rendered in ${(result.renderTimeMs / 1000).toFixed(1)}s)`,
|
|
215
|
+
)
|
|
216
|
+
return
|
|
217
|
+
}
|
|
198
218
|
if (sub.name === 'start') {
|
|
199
219
|
await recordStart(rest, opts)
|
|
200
220
|
return
|
|
@@ -140,7 +140,15 @@ examples:
|
|
|
140
140
|
// --id / --text, missing device model). surface them as a one-line
|
|
141
141
|
// failure instead of an uncaught internal stack trace.
|
|
142
142
|
try {
|
|
143
|
-
await captureViaBridge(
|
|
143
|
+
await captureViaBridge(
|
|
144
|
+
parsed,
|
|
145
|
+
outputArg,
|
|
146
|
+
rect,
|
|
147
|
+
withFrame,
|
|
148
|
+
layers,
|
|
149
|
+
allowLoading,
|
|
150
|
+
opts.verbose === true || args.includes('--verbose') || args.includes('-v'),
|
|
151
|
+
)
|
|
144
152
|
} catch (err) {
|
|
145
153
|
console.error(
|
|
146
154
|
` screenshot failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
@@ -206,7 +214,16 @@ async function captureViaBridge(
|
|
|
206
214
|
withFrame: boolean,
|
|
207
215
|
layers: 'full' | 'tenant' | 'shell' | undefined,
|
|
208
216
|
allowLoading: boolean,
|
|
217
|
+
verbose: boolean,
|
|
209
218
|
) {
|
|
219
|
+
// --verbose names the phase a slow capture spent its time in.
|
|
220
|
+
const phases: string[] = []
|
|
221
|
+
let phaseStart = Date.now()
|
|
222
|
+
const phase = (name: string) => {
|
|
223
|
+
const now = Date.now()
|
|
224
|
+
phases.push(`${name} ${now - phaseStart}ms`)
|
|
225
|
+
phaseStart = now
|
|
226
|
+
}
|
|
210
227
|
// 45s, not 10s: a first-paint capture on a headless CI runner with software
|
|
211
228
|
// GL (SwiftShader) is bounded but slow. forceRenderAll caps at ~6s (two
|
|
212
229
|
// 3s-bounded passes) and the WebGL→2D drawImage readback + PNG encode of a
|
|
@@ -225,6 +242,7 @@ async function captureViaBridge(
|
|
|
225
242
|
// affects screenshot fidelity directly, so call it out explicitly so the
|
|
226
243
|
// user doesn't accept a stale frame as ground truth.
|
|
227
244
|
const health = await checkSimHealth(bridge)
|
|
245
|
+
phase('health')
|
|
228
246
|
if (health.hidden) {
|
|
229
247
|
process.stderr.write(
|
|
230
248
|
' ⚠ screenshot will capture the LAST PAINTED canvas — likely stale.\n' +
|
|
@@ -267,6 +285,7 @@ async function captureViaBridge(
|
|
|
267
285
|
}
|
|
268
286
|
}
|
|
269
287
|
|
|
288
|
+
phase('ready')
|
|
270
289
|
let resolvedRect: SampleRect | null = rect
|
|
271
290
|
const matcher = (rect as { __matcher?: { id?: string; text?: string } })?.__matcher
|
|
272
291
|
if (matcher) {
|
|
@@ -297,6 +316,7 @@ async function captureViaBridge(
|
|
|
297
316
|
if (layers) request.layers = layers
|
|
298
317
|
if (cropRect) request.crop = cropRect
|
|
299
318
|
const dataUrl: string = await bridge.send(request)
|
|
319
|
+
phase('capture')
|
|
300
320
|
const pngPrefix = 'data:image/png;base64,'
|
|
301
321
|
// never write a 0-byte "saved" file from an empty or malformed payload —
|
|
302
322
|
// the sim may be alive but not painting (check `peach get errors`)
|
|
@@ -326,6 +346,8 @@ async function captureViaBridge(
|
|
|
326
346
|
} else {
|
|
327
347
|
await writeScreenshotOutput(outputPath, rawBuffer)
|
|
328
348
|
}
|
|
349
|
+
phase('write')
|
|
350
|
+
if (verbose) console.log(` timing: ${phases.join(', ')}`)
|
|
329
351
|
console.log(` saved: ${outputPath}`)
|
|
330
352
|
} finally {
|
|
331
353
|
bridge.close()
|
package/cli/commands/serve.ts
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
// run in the foreground (ctrl-c to stop). the persistent launchd/systemd
|
|
9
9
|
// daemon installation is handled by `peach daemon install`.
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
assertPeachPortEnvironment,
|
|
13
|
+
DEFAULT_SOOTSIM_BRIDGE_PORT,
|
|
14
|
+
} from '../../src/bridge-constants'
|
|
12
15
|
import {
|
|
13
16
|
ensureRnxHome,
|
|
14
17
|
isDaemonLockfileFresh,
|
|
@@ -58,6 +61,7 @@ examples:
|
|
|
58
61
|
peachExit(0)
|
|
59
62
|
}
|
|
60
63
|
|
|
64
|
+
assertPeachPortEnvironment(process.env)
|
|
61
65
|
const portArgIdx = args.indexOf('--port')
|
|
62
66
|
const port =
|
|
63
67
|
portArgIdx >= 0 && args[portArgIdx + 1]
|
|
@@ -147,7 +151,8 @@ examples:
|
|
|
147
151
|
if (sims.length > 0) lastUsedAt = Date.now()
|
|
148
152
|
else if (
|
|
149
153
|
starterGoneAt &&
|
|
150
|
-
Date.now() - Math.max(starterGoneAt, lastUsedAt, host.lastRequestAt) >=
|
|
154
|
+
Date.now() - Math.max(starterGoneAt, lastUsedAt, host.lastRequestAt) >=
|
|
155
|
+
UNUSED_EXIT_MS
|
|
151
156
|
) {
|
|
152
157
|
void shutdown('unused')
|
|
153
158
|
return
|
package/cli/commands/setup.ts
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
writePrivacyPreferences,
|
|
18
18
|
} from '../../src/home-paths'
|
|
19
19
|
import { rnxRuntime } from '../../src/runtime-delivery'
|
|
20
|
-
import { findDesktopCompanion } from '../desktop-companion'
|
|
20
|
+
import { findDesktopCompanion, nativeDesktopIsDefault } from '../desktop-companion'
|
|
21
21
|
import { isCi, PRIVACY_NOTICE } from '../privacy'
|
|
22
22
|
import { confirm, select } from '../prompt'
|
|
23
23
|
import {
|
|
@@ -155,12 +155,7 @@ export async function runSetup(
|
|
|
155
155
|
serviceInstalled = true
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
if (
|
|
159
|
-
simulatorDriver !== 'playwright' &&
|
|
160
|
-
process.platform !== 'darwin' &&
|
|
161
|
-
!options.dryRun &&
|
|
162
|
-
(simulatorDriver === 'desktop' || !findDesktopCompanion({ native: false }))
|
|
163
|
-
) {
|
|
158
|
+
if (simulatorDriver !== 'playwright' && !options.dryRun && !findDesktopCompanion()) {
|
|
164
159
|
await runInstallDesktop(
|
|
165
160
|
simulatorDriver === 'desktop' ? ['--yes'] : ['--yes', '--electron'],
|
|
166
161
|
)
|
|
@@ -272,7 +267,7 @@ function readSimulatorDriverFlag(args: string[]): SimulatorDriverPreference | un
|
|
|
272
267
|
if (desktop && browser) {
|
|
273
268
|
throw new Error('--desktop and --browser cannot be used together')
|
|
274
269
|
}
|
|
275
|
-
if (desktop) return desktopHostPlatform()
|
|
270
|
+
if (desktop) return desktopHostPlatform() ? 'desktop' : 'electron'
|
|
276
271
|
if (browser) return 'playwright'
|
|
277
272
|
return undefined
|
|
278
273
|
}
|
|
@@ -331,46 +326,29 @@ async function decideService(
|
|
|
331
326
|
return confirm('Enable the background service?', true)
|
|
332
327
|
}
|
|
333
328
|
|
|
329
|
+
// the native app is the simulator window wherever it ships, and setup installs
|
|
330
|
+
// it without asking. Windows chooses between the browser and its Electron app.
|
|
334
331
|
async function decideSimulatorDriver(
|
|
335
332
|
options: SetupOptions,
|
|
336
333
|
): Promise<SimulatorDriverPreference> {
|
|
337
|
-
if (process.platform === 'darwin' && !findDesktopCompanion()) {
|
|
338
|
-
if (options.simulatorDriver && options.simulatorDriver !== 'playwright') {
|
|
339
|
-
throw new Error('install the Mac app with `peach desktop install --native` first')
|
|
340
|
-
}
|
|
341
|
-
return 'playwright'
|
|
342
|
-
}
|
|
343
334
|
if (options.simulatorDriver) return options.simulatorDriver
|
|
344
335
|
const current = readSimulatorDriverPreference()
|
|
345
336
|
if (current) return current
|
|
337
|
+
if (isCi()) return 'playwright'
|
|
338
|
+
if (nativeDesktopIsDefault()) return 'desktop'
|
|
339
|
+
if (process.platform !== 'win32') return 'playwright'
|
|
346
340
|
if (options.ci || options.yes || options.dryRun) return 'playwright'
|
|
347
341
|
requireInteractive(options, '--desktop or --browser')
|
|
348
|
-
const desktopDescription =
|
|
349
|
-
process.platform === 'darwin'
|
|
350
|
-
? 'Desktop opens your installed native runtime (beta).'
|
|
351
|
-
: process.platform === 'win32'
|
|
352
|
-
? 'Desktop downloads and runs the peach installer.'
|
|
353
|
-
: 'Desktop installs the native .deb with sudo apt-get and needs a desktop session.'
|
|
354
|
-
const desktopChoice =
|
|
355
|
-
process.platform === 'darwin'
|
|
356
|
-
? 'Native app (beta) Faster, may have more issues'
|
|
357
|
-
: process.platform === 'win32'
|
|
358
|
-
? 'Desktop app Runs the peach installer'
|
|
359
|
-
: 'Native app (beta) Faster, may have more issues'
|
|
360
342
|
printPromptBlock('Simulator window', [
|
|
361
343
|
'Browser opens immediately in an isolated Chrome window.',
|
|
362
|
-
|
|
363
|
-
'The Desktop app opens in a dedicated
|
|
344
|
+
'Desktop downloads and runs the peach installer.',
|
|
345
|
+
'The Desktop app opens in a dedicated window.',
|
|
364
346
|
])
|
|
365
347
|
const choice = await select('Where should peach open?', [
|
|
366
348
|
'Browser (default) No additional download',
|
|
367
|
-
|
|
349
|
+
'Desktop app Runs the peach installer',
|
|
368
350
|
])
|
|
369
|
-
return choice === 0
|
|
370
|
-
? 'playwright'
|
|
371
|
-
: process.platform === 'darwin'
|
|
372
|
-
? 'desktop'
|
|
373
|
-
: 'electron'
|
|
351
|
+
return choice === 0 ? 'playwright' : 'electron'
|
|
374
352
|
}
|
|
375
353
|
|
|
376
354
|
// diagnostics and crash reports are on unless turned off; setup says so once
|
|
@@ -433,15 +411,14 @@ function printIntro(options: SetupOptions): void {
|
|
|
433
411
|
if (options.json) return
|
|
434
412
|
printBrand('Run any React Native app in a local simulator. No project setup required.')
|
|
435
413
|
if (desktopHostPlatform()) {
|
|
436
|
-
printPromptBlock('
|
|
437
|
-
'
|
|
438
|
-
'
|
|
439
|
-
'Open
|
|
440
|
-
'Open a browser window: peach open <port> --driver playwright --headed',
|
|
414
|
+
printPromptBlock('Native desktop app', [
|
|
415
|
+
'peach opens your app in its native desktop app, which is faster than the browser.',
|
|
416
|
+
'Setup installs it, and peach open <port> uses it.',
|
|
417
|
+
'Open a browser window instead: peach open <port> --driver playwright --headed',
|
|
441
418
|
...(process.platform === 'linux'
|
|
442
|
-
? ['Linux
|
|
419
|
+
? ['On Linux the app installs with sudo apt-get and needs a desktop session.']
|
|
443
420
|
: []),
|
|
444
|
-
'The background service is a separate choice that keeps the bridge ready for either
|
|
421
|
+
'The background service is a separate choice that keeps the bridge ready for either window.',
|
|
445
422
|
])
|
|
446
423
|
}
|
|
447
424
|
}
|
|
@@ -451,7 +428,7 @@ function printHelp(): void {
|
|
|
451
428
|
peach setup - configure optional local conveniences
|
|
452
429
|
|
|
453
430
|
peach works without project setup. This command can enable the faster background
|
|
454
|
-
service,
|
|
431
|
+
service, install the native desktop app, configure private diagnostics, and optionally
|
|
455
432
|
add an exact peachsim dependency plus a peach script for teammates.
|
|
456
433
|
|
|
457
434
|
usage:
|
package/cli/commands/swift.ts
CHANGED
|
@@ -73,6 +73,11 @@ export async function runSwift(
|
|
|
73
73
|
} else if (arg === '--scheme') {
|
|
74
74
|
scheme = input[++index]
|
|
75
75
|
if (!scheme || scheme.startsWith('-')) throw new Error('--scheme requires a value')
|
|
76
|
+
} else if (arg === '--swift-sdks-path') {
|
|
77
|
+
const value = input[++index]
|
|
78
|
+
if (!value || value.startsWith('-'))
|
|
79
|
+
throw new Error('--swift-sdks-path requires a value')
|
|
80
|
+
process.env.PEACH_SWIFT_SDKS_PATH = path.resolve(value)
|
|
76
81
|
} else if (arg === '--host-port' || valueFlags.has(arg)) {
|
|
77
82
|
const value = input[++index]
|
|
78
83
|
if (!value || value.startsWith('-')) throw new Error(`${arg} requires a value`)
|