peachsim 0.1.2422 → 0.1.2425
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/cli/command-agent.ts +14 -15
- package/cli/commands/box.ts +33 -28
- package/cli/commands/canvas.ts +54 -0
- package/cli/commands/platform.ts +28 -27
- package/cli/commands/preview.ts +2 -1
- package/cli/outbound-endpoints.ts +141 -23
- 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 +114 -28
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +22 -1
- package/dist-lib/cloud-contract.mjs +20 -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 +27 -13
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +112 -26
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +114 -28
- package/dist-lib/host/fetch-proxy-handler.cjs +4 -4
- 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 +88 -59
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +22 -7
- 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 +25 -10
- package/dist-lib/native-app-identity-project.cjs +2 -2
- package/dist-lib/native-app-identity-project.mjs +2 -2
- 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 +24 -24
- package/dist-lib/public-origins-lib.json +54 -53
- 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 +258 -150
- package/dist-lib/swift-compile.cjs +87 -16
- package/dist-lib/swift-compile.mjs +87 -16
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +88 -17
- package/dist-lib/vite.cjs +25 -10
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/ios/apps/canvas-map-data.d.ts +83 -2
- package/dist-types/packages/peach-engine/src/remote-stream/cloud-display.d.ts +2 -2
- package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +9 -0
- package/dist-types/packages/peach-globals/src/canvasAgentContract.d.ts +8 -0
- package/dist-types/packages/peach-globals/src/index.d.ts +4 -2
- package/dist-types/packages/peach-globals/src/lockstepCaptureBridgeContract.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/replayBridgeContract.d.ts +12 -0
- package/dist-types/packages/peach-globals/src/sceneStreamBridgeContract.d.ts +5 -1
- package/kotlin/README.md +4 -3
- package/kotlin/sdk.tar.gz +0 -0
- package/kotlin/toolchain.json +2 -2
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/CoreData.apinotes +2 -0
- package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/NSPersistentStore.h +2 -0
- package/sdk/ios/wasm/include/errno.h +10 -0
- package/src/agent-daemon-client.ts +1 -1
- package/src/agent-prompt.ts +1 -8
- package/src/canvas-agent-note-delivery.ts +2 -5
- package/src/canvas-groups.ts +11 -3
- package/src/cloud-contract.ts +31 -1
- package/src/swift-compile.ts +1 -1
- package/src/swift-guest-compile.ts +2 -0
- package/src/swift-guest-image-ledger.ts +37 -2
- package/src/swift-guest-source-inputs.ts +45 -6
- package/src/visit-parsed-program.ts +21 -6
- package/src/vite-plugin.ts +4 -1
package/cli/command-agent.ts
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
import { hostname } from 'os'
|
|
7
7
|
import { formatLockOwner } from '../../peach-kit/src/agent-identity'
|
|
8
|
-
import { AGENT_IDENTITY_MAX_CHARS } from '../src/cloud-contract'
|
|
8
|
+
import { AGENT_IDENTITY_MAX_CHARS, agentActionTargetName } from '../src/cloud-contract'
|
|
9
9
|
import { getCliIdentity, readAgentId } from './current-sim'
|
|
10
10
|
import type { PerformStep, WsBridgeCommand } from '../src/bridge-contract'
|
|
11
|
-
import type { SootSimAgentIdentity
|
|
11
|
+
import type { SootSimAgentIdentity } from '@peach/globals'
|
|
12
12
|
|
|
13
13
|
function clip(text: string): string {
|
|
14
14
|
return text.length > AGENT_IDENTITY_MAX_CHARS
|
|
@@ -16,11 +16,6 @@ function clip(text: string): string {
|
|
|
16
16
|
: text
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
function targetName(target: SootSimReplayTarget | undefined): string | null {
|
|
20
|
-
const name = target?.text?.trim() || target?.testID?.trim() || target?.id?.trim()
|
|
21
|
-
return name ? name.replace(/\s+/g, ' ') : null
|
|
22
|
-
}
|
|
23
|
-
|
|
24
19
|
function verb(action: string, target: string | null): string {
|
|
25
20
|
return target ? `${action} ${target}` : action
|
|
26
21
|
}
|
|
@@ -30,13 +25,13 @@ function verb(action: string, target: string | null): string {
|
|
|
30
25
|
function describeStep(step: PerformStep): string | null {
|
|
31
26
|
switch (step.type) {
|
|
32
27
|
case 'tap':
|
|
33
|
-
return verb('Tapping',
|
|
28
|
+
return verb('Tapping', agentActionTargetName(step.target))
|
|
34
29
|
case 'tapId':
|
|
35
30
|
return verb('Tapping', step.id)
|
|
36
31
|
case 'doubleTap':
|
|
37
32
|
return 'Double tapping'
|
|
38
33
|
case 'longPress':
|
|
39
|
-
return verb('Long pressing',
|
|
34
|
+
return verb('Long pressing', agentActionTargetName(step.target))
|
|
40
35
|
case 'drag':
|
|
41
36
|
return 'Dragging'
|
|
42
37
|
case 'pinch':
|
|
@@ -80,9 +75,9 @@ function describeStep(step: PerformStep): string | null {
|
|
|
80
75
|
function describeCommand(command: WsBridgeCommand): string | null {
|
|
81
76
|
switch (command.type) {
|
|
82
77
|
case 'tap':
|
|
83
|
-
return verb('Tapping',
|
|
78
|
+
return verb('Tapping', agentActionTargetName(command.target))
|
|
84
79
|
case 'longPress':
|
|
85
|
-
return verb('Long pressing',
|
|
80
|
+
return verb('Long pressing', agentActionTargetName(command.target))
|
|
86
81
|
case 'keyboard':
|
|
87
82
|
return command.action === 'dismiss'
|
|
88
83
|
? 'Dismissing the keyboard'
|
|
@@ -102,6 +97,13 @@ function describeCommand(command: WsBridgeCommand): string | null {
|
|
|
102
97
|
}
|
|
103
98
|
}
|
|
104
99
|
|
|
100
|
+
/** the name an agent shows beside its actions */
|
|
101
|
+
export function cliAgentName(identityKey: string): string {
|
|
102
|
+
return (
|
|
103
|
+
readAgentId() ?? (process.env.PEACH_AGENT_ID?.trim() || formatLockOwner(identityKey))
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
|
|
105
107
|
/** the identity a command carries to the sim, or undefined when it names nobody. */
|
|
106
108
|
export function commandAgent(command: WsBridgeCommand): SootSimAgentIdentity | undefined {
|
|
107
109
|
const step = describeCommand(command)
|
|
@@ -112,10 +114,7 @@ export function commandAgent(command: WsBridgeCommand): SootSimAgentIdentity | u
|
|
|
112
114
|
if (!machine) return undefined
|
|
113
115
|
return {
|
|
114
116
|
id: clip(identity.key),
|
|
115
|
-
name: clip(
|
|
116
|
-
readAgentId() ??
|
|
117
|
-
(process.env.PEACH_AGENT_ID?.trim() || formatLockOwner(identity.key)),
|
|
118
|
-
),
|
|
117
|
+
name: clip(cliAgentName(identity.key)),
|
|
119
118
|
machine: clip(machine),
|
|
120
119
|
step: clip(step),
|
|
121
120
|
}
|
package/cli/commands/box.ts
CHANGED
|
@@ -525,10 +525,10 @@ function cloudBoxClient(options: {
|
|
|
525
525
|
*/
|
|
526
526
|
export async function createPrebuiltBundleBox(options: {
|
|
527
527
|
fresh?: boolean
|
|
528
|
-
|
|
528
|
+
artifact:
|
|
529
|
+
| { bytes: Uint8Array; nativeAssets: readonly CloudBoxNativeAsset[] }
|
|
530
|
+
| (() => Promise<{ bytes: Uint8Array; nativeAssets: readonly CloudBoxNativeAsset[] }>)
|
|
529
531
|
nativeProjectDir?: string
|
|
530
|
-
// the compiled native module files the bundle's footers name
|
|
531
|
-
nativeAssets?: readonly CloudBoxNativeAsset[]
|
|
532
532
|
bundleUpdate?: PrebuiltBundleUpdate
|
|
533
533
|
// the simulator's device model, or null for the Box page's default
|
|
534
534
|
device: string | null
|
|
@@ -543,35 +543,41 @@ export async function createPrebuiltBundleBox(options: {
|
|
|
543
543
|
repo: string | null
|
|
544
544
|
secrets?: Readonly<Record<string, string>>
|
|
545
545
|
}) {
|
|
546
|
-
const
|
|
547
|
-
options.device && isDeviceModel(options.device)
|
|
548
|
-
? getCliRuntime().settings_devices.getRuntimePlatform(options.device)
|
|
549
|
-
: 'ios'
|
|
550
|
-
const nativeRenderer = options.nativeProjectDir
|
|
551
|
-
? readNativeProjectRenderer(options.nativeProjectDir, platform)
|
|
552
|
-
: undefined
|
|
553
|
-
const appFonts = options.nativeProjectDir
|
|
554
|
-
? readNativeLinkedAppFontsWire({
|
|
555
|
-
projectDir: options.nativeProjectDir,
|
|
556
|
-
platform,
|
|
557
|
-
})
|
|
558
|
-
: ''
|
|
559
|
-
const source = new BundleFilePlane(
|
|
560
|
-
options.bundle,
|
|
561
|
-
options.device,
|
|
562
|
-
options.initialUrl ?? null,
|
|
563
|
-
appFonts,
|
|
564
|
-
nativeRenderer,
|
|
565
|
-
options.nativeAssets,
|
|
566
|
-
options.bundleUpdate,
|
|
567
|
-
)
|
|
546
|
+
const pending = Promise.withResolvers<{ source: BundleFilePlane; appFonts: string }>()
|
|
568
547
|
const box = await cloudBoxClient(options).create({
|
|
569
548
|
name: options.name,
|
|
570
549
|
stack: prebuiltBundleBoxTemplate.stack,
|
|
571
550
|
template: BOX_TEMPLATES.resolve({ name: prebuiltBundleBoxTemplate.name }).provenance,
|
|
572
|
-
source
|
|
551
|
+
source: async () => {
|
|
552
|
+
const artifact =
|
|
553
|
+
typeof options.artifact === 'function'
|
|
554
|
+
? await options.artifact()
|
|
555
|
+
: options.artifact
|
|
556
|
+
const platform =
|
|
557
|
+
options.device && isDeviceModel(options.device)
|
|
558
|
+
? getCliRuntime().settings_devices.getRuntimePlatform(options.device)
|
|
559
|
+
: 'ios'
|
|
560
|
+
const nativeRenderer = options.nativeProjectDir
|
|
561
|
+
? readNativeProjectRenderer(options.nativeProjectDir, platform)
|
|
562
|
+
: undefined
|
|
563
|
+
const appFonts = options.nativeProjectDir
|
|
564
|
+
? readNativeLinkedAppFontsWire({ projectDir: options.nativeProjectDir, platform })
|
|
565
|
+
: ''
|
|
566
|
+
const source = new BundleFilePlane(
|
|
567
|
+
artifact.bytes,
|
|
568
|
+
options.device,
|
|
569
|
+
options.initialUrl ?? null,
|
|
570
|
+
appFonts,
|
|
571
|
+
nativeRenderer,
|
|
572
|
+
artifact.nativeAssets,
|
|
573
|
+
options.bundleUpdate,
|
|
574
|
+
)
|
|
575
|
+
pending.resolve({ source, appFonts })
|
|
576
|
+
return source
|
|
577
|
+
},
|
|
573
578
|
...(options.secrets ? { secrets: options.secrets } : {}),
|
|
574
579
|
})
|
|
580
|
+
const { source, appFonts } = await pending.promise
|
|
575
581
|
return {
|
|
576
582
|
box,
|
|
577
583
|
source,
|
|
@@ -738,8 +744,7 @@ async function runCloudBoxCreate(
|
|
|
738
744
|
'bundle' in source
|
|
739
745
|
? await createPrebuiltBundleBox({
|
|
740
746
|
...connection,
|
|
741
|
-
|
|
742
|
-
nativeAssets: source.nativeAssets,
|
|
747
|
+
artifact: { bytes: source.bundle, nativeAssets: source.nativeAssets },
|
|
743
748
|
nativeProjectDir,
|
|
744
749
|
device: null,
|
|
745
750
|
name,
|
package/cli/commands/canvas.ts
CHANGED
|
@@ -4,12 +4,16 @@
|
|
|
4
4
|
// display.
|
|
5
5
|
|
|
6
6
|
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
|
|
7
|
+
import { hostname } from 'node:os'
|
|
7
8
|
import { dirname, resolve } from 'node:path'
|
|
9
|
+
import { isCanvasMapAgent } from '@peach/globals'
|
|
8
10
|
import { groupCanvasItems, type CanvasGrouping } from '../../src/canvas-groups'
|
|
9
11
|
import { devices, isDeviceModel, type DeviceModel } from '../../src/device-catalog'
|
|
10
12
|
import { layoutFlowGraph } from '../../src/flow-graph-layout'
|
|
11
13
|
import { isRecord } from '../../src/is-record'
|
|
12
14
|
import { LAUNCH_METADATA_QUERY_PARAM } from '../../src/launchMetadataContract'
|
|
15
|
+
import { cliAgentName } from '../command-agent'
|
|
16
|
+
import { getCliIdentity } from '../current-sim'
|
|
13
17
|
import {
|
|
14
18
|
createBridgeFromParsed,
|
|
15
19
|
evalInBridge,
|
|
@@ -80,6 +84,9 @@ usage:
|
|
|
80
84
|
peach canvas freeze <id>
|
|
81
85
|
peach canvas camera --at x,y --scale <n>
|
|
82
86
|
peach canvas camera --path <file>
|
|
87
|
+
peach canvas agent <item> --name <name> --step <step> [--id <agent>] [--machine <name>] [--action <json>]
|
|
88
|
+
peach canvas agent remove --id <agent>
|
|
89
|
+
peach canvas follow <agent|off>
|
|
83
90
|
peach canvas remove <id>
|
|
84
91
|
peach canvas list
|
|
85
92
|
peach canvas push
|
|
@@ -100,7 +107,11 @@ verbs:
|
|
|
100
107
|
focus select an item, or clear focus without an id
|
|
101
108
|
live resume an item's app
|
|
102
109
|
freeze retain an item's last frame and app state
|
|
110
|
+
agent attach the caller to an item, update its step, or report an external driver's action
|
|
111
|
+
follow follow one agent between items, or stop with off
|
|
103
112
|
camera set the canvas translation and scale, or play a path
|
|
113
|
+
agent attach the caller to an item, update its step, or report an external driver's action
|
|
114
|
+
follow follow one agent between items, or stop with off
|
|
104
115
|
remove take an item, or a whole map by its name, off the canvas
|
|
105
116
|
list print the working file's items
|
|
106
117
|
push post the working file to the canvas sim again, as after a reload
|
|
@@ -123,6 +134,10 @@ options:
|
|
|
123
134
|
--flow arrange: lay each map out along its links and leave other items in place
|
|
124
135
|
--path <file> camera: JSON array of {ms,x,y,scale} keyframes, starting at 0 ms
|
|
125
136
|
--file <path> working file (default: peach-canvas.json)
|
|
137
|
+
--name <name> agent's displayed name
|
|
138
|
+
--machine <name> agent's machine (default: this hostname)
|
|
139
|
+
--step <text> agent's current step
|
|
140
|
+
--action <json> an agent action in item coordinates, reported by an external driver
|
|
126
141
|
--sim <id> target a specific canvas sim
|
|
127
142
|
|
|
128
143
|
examples:
|
|
@@ -665,6 +680,9 @@ async function dispatch(
|
|
|
665
680
|
'--agent',
|
|
666
681
|
'--machine',
|
|
667
682
|
'--label',
|
|
683
|
+
'--name',
|
|
684
|
+
'--step',
|
|
685
|
+
'--action',
|
|
668
686
|
],
|
|
669
687
|
})
|
|
670
688
|
const [verb, target] = parsed.positional
|
|
@@ -682,6 +700,42 @@ async function dispatch(
|
|
|
682
700
|
}
|
|
683
701
|
const file = resolve(flag(args, '--file') ?? 'peach-canvas.json')
|
|
684
702
|
const canvas = readCanvas(file)
|
|
703
|
+
if (verb === 'agent' || verb === 'follow') {
|
|
704
|
+
// the same id the cli puts on the actions it drives (command-agent.ts)
|
|
705
|
+
const agentId = flag(args, '--id') ?? getCliIdentity().key
|
|
706
|
+
let command: unknown
|
|
707
|
+
if (verb === 'follow') {
|
|
708
|
+
if (!target) throw new Error('follow takes an agent id or off')
|
|
709
|
+
command = { kind: 'follow-agent', agentId: target === 'off' ? null : target }
|
|
710
|
+
} else if (target === 'remove') {
|
|
711
|
+
if (!agentId) throw new Error('agent remove takes --id <agent>')
|
|
712
|
+
command = { kind: 'remove-agent', agentId }
|
|
713
|
+
} else {
|
|
714
|
+
const item = findItem(canvas, target)
|
|
715
|
+
const rawAction = flag(args, '--action')
|
|
716
|
+
const detail: unknown = rawAction ? JSON.parse(rawAction) : undefined
|
|
717
|
+
const agent = {
|
|
718
|
+
id: agentId,
|
|
719
|
+
name: flag(args, '--name') ?? cliAgentName(agentId),
|
|
720
|
+
machine: flag(args, '--machine') ?? hostname(),
|
|
721
|
+
step: flag(args, '--step'),
|
|
722
|
+
screenId: item.id,
|
|
723
|
+
...(detail ? { action: { sequence: Date.now(), detail } } : {}),
|
|
724
|
+
}
|
|
725
|
+
if (!isCanvasMapAgent(agent))
|
|
726
|
+
throw new Error(
|
|
727
|
+
'agent takes --id, --name and --step, with an optional agent action JSON',
|
|
728
|
+
)
|
|
729
|
+
command = { kind: 'agent', agent }
|
|
730
|
+
}
|
|
731
|
+
const bridge = createBridgeFromParsed(parsed)
|
|
732
|
+
try {
|
|
733
|
+
await evalInBridge(bridge, commandCode(command))
|
|
734
|
+
} finally {
|
|
735
|
+
bridge.close()
|
|
736
|
+
}
|
|
737
|
+
return 0
|
|
738
|
+
}
|
|
685
739
|
if (verb === 'camera') {
|
|
686
740
|
const path = flag(args, '--path')
|
|
687
741
|
if (path) {
|
package/cli/commands/platform.ts
CHANGED
|
@@ -537,35 +537,33 @@ async function runRemoteBox(
|
|
|
537
537
|
isRecord(body) && typeof body.message === 'string'
|
|
538
538
|
? body.message
|
|
539
539
|
: `Peach Cloud refused the simulator (${covered.status})`
|
|
540
|
-
throw new Error(
|
|
541
|
-
covered.status === 402
|
|
542
|
-
? `${message}. add credit with \`${rnxPublicBrand.commandName} support fund\` and run it again.`
|
|
543
|
-
: message,
|
|
544
|
-
)
|
|
540
|
+
throw new Error(message)
|
|
545
541
|
}
|
|
546
|
-
const
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
542
|
+
const prepareArtifact = async () => {
|
|
543
|
+
const buildDir = projectDir && mkdtempSync(join(tmpdir(), 'peach-remote-'))
|
|
544
|
+
try {
|
|
545
|
+
const artifact = await produceCloudBoxArtifact(
|
|
546
|
+
projectDir && buildDir ? { projectDir, buildDir } : input.bundlePath,
|
|
547
|
+
platform,
|
|
548
|
+
{
|
|
549
|
+
assetsDirectory: input.assetsDirectory,
|
|
550
|
+
nativeProjectDir,
|
|
551
|
+
...(input.watch ? { assetServer: new URL(input.bundlePath) } : {}),
|
|
552
|
+
},
|
|
553
|
+
)
|
|
554
|
+
assertBundleBuiltFor(artifact.bytes, platform, `peach ${command}`)
|
|
555
|
+
return artifact
|
|
556
|
+
} finally {
|
|
557
|
+
if (buildDir) rmSync(buildDir, { recursive: true, force: true })
|
|
558
|
+
}
|
|
560
559
|
}
|
|
561
|
-
assertBundleBuiltFor(artifact.bytes, platform, `peach ${command}`)
|
|
562
|
-
// the session records which bundle a box already holds, so reattaching can
|
|
563
|
-
// tell the same app from a rebuilt one. the box producer returns no digest
|
|
564
|
-
// of its own, so take it here over the bytes that actually crossed.
|
|
565
|
-
const artifactSha256 = createHash('sha256').update(artifact.bytes).digest('hex')
|
|
566
560
|
const endpoint = box.cloudBoxEndpoint(args)
|
|
567
561
|
|
|
568
562
|
const existingSession = readCloudSession()
|
|
563
|
+
let preparation: ReturnType<typeof prepareArtifact> | undefined
|
|
564
|
+
const getArtifact = () => (preparation ??= prepareArtifact())
|
|
565
|
+
// a failed build leaves the previous simulator running.
|
|
566
|
+
const existingArtifact = existingSession || input.name ? await getArtifact() : undefined
|
|
569
567
|
// a launch link only means something to an app that is launching, so a box
|
|
570
568
|
// already running this bundle is never reattached in its place.
|
|
571
569
|
if (
|
|
@@ -577,7 +575,9 @@ async function runRemoteBox(
|
|
|
577
575
|
existingSession.apiOrigin === endpoint &&
|
|
578
576
|
existingSession.platform === platform &&
|
|
579
577
|
existingSession.device === selectedDevice &&
|
|
580
|
-
|
|
578
|
+
existingArtifact &&
|
|
579
|
+
existingSession.artifact?.sha256 ===
|
|
580
|
+
createHash('sha256').update(existingArtifact.bytes).digest('hex')
|
|
581
581
|
) {
|
|
582
582
|
// a box deleted since, from here, another machine or the web, answers its
|
|
583
583
|
// old token like any wrong one, so this folder has nothing to reattach
|
|
@@ -631,9 +631,8 @@ async function runRemoteBox(
|
|
|
631
631
|
source,
|
|
632
632
|
appFontsWireSha256,
|
|
633
633
|
} = await box.createPrebuiltBundleBox({
|
|
634
|
-
|
|
634
|
+
artifact: existingArtifact ?? getArtifact,
|
|
635
635
|
nativeProjectDir,
|
|
636
|
-
nativeAssets: artifact.nativeAssets,
|
|
637
636
|
...(input.watch ? { bundleUpdate: { sequence: 1 } } : {}),
|
|
638
637
|
device: selectedDevice,
|
|
639
638
|
initialUrl: input.initialUrl,
|
|
@@ -645,6 +644,8 @@ async function runRemoteBox(
|
|
|
645
644
|
accountId,
|
|
646
645
|
repo: resolveCheckoutRepo(projectDir ?? undefined),
|
|
647
646
|
})
|
|
647
|
+
const artifact = await getArtifact()
|
|
648
|
+
const artifactSha256 = createHash('sha256').update(artifact.bytes).digest('hex')
|
|
648
649
|
const session = createCloudBoxSession({
|
|
649
650
|
boxId: created.id,
|
|
650
651
|
boxToken: created.accessToken ?? '',
|
package/cli/commands/preview.ts
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
import { getCliRuntime } from '../../src/cli-runtime.ts'
|
|
22
22
|
import { isRecord } from '../../src/is-record'
|
|
23
23
|
import { terminateProcessGroup } from '../../src/process-group'
|
|
24
|
+
import { rnxPublicBrand } from '../../src/public-brand'
|
|
24
25
|
import { authHeaderValue, cloudAccountIdOrExit, resolveCliAuth } from '../auth'
|
|
25
26
|
import { extractAppBinaryBundle, isAppBinaryPath } from '../binary-sidecar'
|
|
26
27
|
import { producePreviewArtifact } from '../cloud-client'
|
|
@@ -233,7 +234,7 @@ async function publishProjectPreview(
|
|
|
233
234
|
})
|
|
234
235
|
if (preflight.status === 402)
|
|
235
236
|
throw new Error(
|
|
236
|
-
`
|
|
237
|
+
`The build needs an available balance (${parseServerMessage(await preflight.text()) ?? 'no credit available'}). Add balance at ${rnxPublicBrand.origin}/billing and try again.`,
|
|
237
238
|
)
|
|
238
239
|
if (!preflight.ok) {
|
|
239
240
|
const text = await preflight.text()
|
|
@@ -571,6 +571,9 @@ export const DECLARED_OUTBOUND_CALLS: Record<string, OutboundCallDeclaration> =
|
|
|
571
571
|
{ category: 'contrast_user_action', count: 1 },
|
|
572
572
|
'packages/peach-cloud-box/src/box-do.ts :: fetch :: `${origin}/api/v1/rnx/sessions/internal/${encodeURIComponent()}`':
|
|
573
573
|
{ category: 'contrast_user_action', count: 1 },
|
|
574
|
+
// the stopped session's recording goes to the account that ran it, nowhere else.
|
|
575
|
+
'packages/peach-cloud-box/src/box-do.ts :: fetch :: `${origin}/api/v1/rnx/sessions/internal/${encodeURIComponent()}/recording`':
|
|
576
|
+
{ category: 'contrast_user_action', count: 1 },
|
|
574
577
|
// stop and delete authorize the caller against the account before any
|
|
575
578
|
// teardown. the account service owns the verdict on a key, its scope and the
|
|
576
579
|
// account it names; no project content is sent.
|
|
@@ -1170,27 +1173,70 @@ function isFetchBinding(node: Expression): boolean {
|
|
|
1170
1173
|
)
|
|
1171
1174
|
}
|
|
1172
1175
|
|
|
1176
|
+
const EMPTY_ALIASES: Set<string> = new Set()
|
|
1177
|
+
const EXPORT_VARIABLE_DECLARATION = /\bexport\s+(?:const|let|var)\b/
|
|
1178
|
+
|
|
1179
|
+
interface OutboundScanCaches {
|
|
1180
|
+
trackedSet: Set<string>
|
|
1181
|
+
sources: Map<string, string>
|
|
1182
|
+
diskFiles: Map<string, boolean>
|
|
1183
|
+
parsed: Map<string, { source: string; program: Program }>
|
|
1184
|
+
exportedFetchAliases: Map<string, Set<string>>
|
|
1185
|
+
networkNames: Map<string, NetworkNames>
|
|
1186
|
+
exporterScanDone: boolean
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
function isCachedFile(candidate: string, caches: OutboundScanCaches): boolean {
|
|
1190
|
+
if (caches.trackedSet.has(candidate)) return true
|
|
1191
|
+
let found = caches.diskFiles.get(candidate)
|
|
1192
|
+
if (found === undefined) {
|
|
1193
|
+
found = fs.existsSync(candidate) && fs.statSync(candidate).isFile()
|
|
1194
|
+
caches.diskFiles.set(candidate, found)
|
|
1195
|
+
}
|
|
1196
|
+
return found
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
function loadParsedFile(
|
|
1200
|
+
file: string,
|
|
1201
|
+
caches: OutboundScanCaches,
|
|
1202
|
+
): { source: string; program: Program } {
|
|
1203
|
+
let cached = caches.parsed.get(file)
|
|
1204
|
+
if (!cached) {
|
|
1205
|
+
const source = caches.sources.get(file) ?? fs.readFileSync(file, 'utf8')
|
|
1206
|
+
const program = parseSync(file, source, {
|
|
1207
|
+
lang: file.endsWith('.tsx') ? 'tsx' : 'ts',
|
|
1208
|
+
}).program
|
|
1209
|
+
cached = { source, program }
|
|
1210
|
+
caches.parsed.set(file, cached)
|
|
1211
|
+
}
|
|
1212
|
+
return cached
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1173
1215
|
// names a relative module exports as fetch aliases, so a call through the
|
|
1174
1216
|
// imported binding is declared like a direct fetch.
|
|
1175
1217
|
function exportedFetchAliases(
|
|
1176
1218
|
importer: string,
|
|
1177
1219
|
specifier: string,
|
|
1178
|
-
|
|
1220
|
+
caches: OutboundScanCaches,
|
|
1179
1221
|
): Set<string> {
|
|
1180
|
-
if (!specifier.startsWith('.')) return
|
|
1222
|
+
if (!specifier.startsWith('.')) return EMPTY_ALIASES
|
|
1181
1223
|
const base = path.resolve(path.dirname(importer), specifier)
|
|
1182
1224
|
const file = [`${base}.ts`, `${base}.tsx`, base, path.join(base, 'index.ts')].find(
|
|
1183
|
-
(candidate) =>
|
|
1225
|
+
(candidate) => isCachedFile(candidate, caches),
|
|
1184
1226
|
)
|
|
1185
|
-
if (!file) return
|
|
1186
|
-
const cached =
|
|
1227
|
+
if (!file) return EMPTY_ALIASES
|
|
1228
|
+
const cached = caches.exportedFetchAliases.get(file)
|
|
1187
1229
|
if (cached) return cached
|
|
1230
|
+
if (caches.exporterScanDone && caches.trackedSet.has(file)) return EMPTY_ALIASES
|
|
1231
|
+
const text = caches.sources.get(file) ?? fs.readFileSync(file, 'utf8')
|
|
1232
|
+
if (!EXPORT_VARIABLE_DECLARATION.test(text)) {
|
|
1233
|
+
caches.exportedFetchAliases.set(file, EMPTY_ALIASES)
|
|
1234
|
+
return EMPTY_ALIASES
|
|
1235
|
+
}
|
|
1188
1236
|
const aliases = new Set<string>()
|
|
1189
|
-
|
|
1190
|
-
const program =
|
|
1191
|
-
|
|
1192
|
-
}).program
|
|
1193
|
-
const names = networkNames(program, file, exportedFetchAliasCache)
|
|
1237
|
+
caches.exportedFetchAliases.set(file, aliases)
|
|
1238
|
+
const { program } = loadParsedFile(file, caches)
|
|
1239
|
+
const names = networkNames(program, file, caches)
|
|
1194
1240
|
for (const statement of program.body) {
|
|
1195
1241
|
if (statement.type !== 'ExportNamedDeclaration') continue
|
|
1196
1242
|
if (statement.declaration?.type !== 'VariableDeclaration') continue
|
|
@@ -1205,8 +1251,10 @@ function exportedFetchAliases(
|
|
|
1205
1251
|
function networkNames(
|
|
1206
1252
|
source: Program,
|
|
1207
1253
|
file: string,
|
|
1208
|
-
|
|
1254
|
+
caches: OutboundScanCaches,
|
|
1209
1255
|
): NetworkNames {
|
|
1256
|
+
const existing = caches.networkNames.get(file)
|
|
1257
|
+
if (existing) return existing
|
|
1210
1258
|
const names: NetworkNames = {
|
|
1211
1259
|
fetch: new Set(['fetch', 'fetchWithRetries']),
|
|
1212
1260
|
httpClient: new Set(['http', 'https']),
|
|
@@ -1215,6 +1263,7 @@ function networkNames(
|
|
|
1215
1263
|
nodeRequest: new Set(),
|
|
1216
1264
|
nodeGet: new Set(),
|
|
1217
1265
|
}
|
|
1266
|
+
caches.networkNames.set(file, names)
|
|
1218
1267
|
const isClientExpression = (node: Expression, clients: Set<string>): boolean => {
|
|
1219
1268
|
if (node.type === 'Identifier') return clients.has(node.name)
|
|
1220
1269
|
if (node.type === 'ParenthesizedExpression')
|
|
@@ -1249,11 +1298,7 @@ function networkNames(
|
|
|
1249
1298
|
},
|
|
1250
1299
|
ImportDeclaration(node) {
|
|
1251
1300
|
const moduleName = node.source.value.replace(/^node:/, '')
|
|
1252
|
-
const fetchAliases = exportedFetchAliases(
|
|
1253
|
-
file,
|
|
1254
|
-
node.source.value,
|
|
1255
|
-
exportedFetchAliasCache,
|
|
1256
|
-
)
|
|
1301
|
+
const fetchAliases = exportedFetchAliases(file, node.source.value, caches)
|
|
1257
1302
|
for (const specifier of node.specifiers) {
|
|
1258
1303
|
if (
|
|
1259
1304
|
specifier.type === 'ImportSpecifier' &&
|
|
@@ -1427,15 +1472,88 @@ export function detectOutboundCalls(repositoryRoot: string): DetectedOutboundCal
|
|
|
1427
1472
|
'packages/contrast-runtime-delivery/src',
|
|
1428
1473
|
'packages/peach-cloud-box/src',
|
|
1429
1474
|
]
|
|
1475
|
+
const tracked = trackedSourceFiles(repositoryRoot, roots)
|
|
1476
|
+
const sources = new Map<string, string>()
|
|
1477
|
+
for (const file of tracked) sources.set(file, fs.readFileSync(file, 'utf8'))
|
|
1478
|
+
|
|
1479
|
+
const caches: OutboundScanCaches = {
|
|
1480
|
+
trackedSet: new Set(tracked),
|
|
1481
|
+
sources,
|
|
1482
|
+
diskFiles: new Map(),
|
|
1483
|
+
parsed: new Map(),
|
|
1484
|
+
exportedFetchAliases: new Map(),
|
|
1485
|
+
networkNames: new Map(),
|
|
1486
|
+
exporterScanDone: false,
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
const escapeRegExp = (value: string): string =>
|
|
1490
|
+
value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
1491
|
+
const fetchTokens = new Set(['fetch', 'fetchWithRetries'])
|
|
1492
|
+
const checkedExporters = new Set<string>()
|
|
1493
|
+
let fetchTokenPattern = new RegExp(
|
|
1494
|
+
`\\b(?:${[...fetchTokens].map(escapeRegExp).join('|')})\\b`,
|
|
1495
|
+
)
|
|
1496
|
+
while (true) {
|
|
1497
|
+
let added = false
|
|
1498
|
+
for (const file of tracked) {
|
|
1499
|
+
if (checkedExporters.has(file) || file.endsWith('/outbound-endpoints.ts')) continue
|
|
1500
|
+
const text = sources.get(file)!
|
|
1501
|
+
if (!EXPORT_VARIABLE_DECLARATION.test(text) || !fetchTokenPattern.test(text))
|
|
1502
|
+
continue
|
|
1503
|
+
checkedExporters.add(file)
|
|
1504
|
+
const aliases = new Set<string>()
|
|
1505
|
+
caches.exportedFetchAliases.set(file, aliases)
|
|
1506
|
+
const { program } = loadParsedFile(file, caches)
|
|
1507
|
+
const names = networkNames(program, file, caches)
|
|
1508
|
+
for (const statement of program.body) {
|
|
1509
|
+
if (
|
|
1510
|
+
statement.type !== 'ExportNamedDeclaration' ||
|
|
1511
|
+
statement.declaration?.type !== 'VariableDeclaration'
|
|
1512
|
+
)
|
|
1513
|
+
continue
|
|
1514
|
+
for (const declarator of statement.declaration.declarations) {
|
|
1515
|
+
if (
|
|
1516
|
+
declarator.id.type === 'Identifier' &&
|
|
1517
|
+
names.fetch.has(declarator.id.name)
|
|
1518
|
+
) {
|
|
1519
|
+
aliases.add(declarator.id.name)
|
|
1520
|
+
if (!fetchTokens.has(declarator.id.name)) {
|
|
1521
|
+
fetchTokens.add(declarator.id.name)
|
|
1522
|
+
added = true
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
if (!added) break
|
|
1529
|
+
fetchTokenPattern = new RegExp(
|
|
1530
|
+
`\\b(?:${[...fetchTokens].map(escapeRegExp).join('|')})\\b`,
|
|
1531
|
+
)
|
|
1532
|
+
}
|
|
1533
|
+
caches.exporterScanDone = true
|
|
1534
|
+
|
|
1535
|
+
const activeTokens = new Set([
|
|
1536
|
+
...fetchTokens,
|
|
1537
|
+
'WebSocket',
|
|
1538
|
+
'NativeWebSocket',
|
|
1539
|
+
'EventSource',
|
|
1540
|
+
'XMLHttpRequest',
|
|
1541
|
+
'sendBeacon',
|
|
1542
|
+
'http',
|
|
1543
|
+
'https',
|
|
1544
|
+
'net',
|
|
1545
|
+
'transport',
|
|
1546
|
+
])
|
|
1547
|
+
const tokenPattern = new RegExp(
|
|
1548
|
+
`\\b(?:${[...activeTokens].map(escapeRegExp).join('|')})\\b`,
|
|
1549
|
+
)
|
|
1550
|
+
|
|
1430
1551
|
const counts = new Map<string, number>()
|
|
1431
|
-
const
|
|
1432
|
-
for (const file of trackedSourceFiles(repositoryRoot, roots)) {
|
|
1552
|
+
for (const file of tracked) {
|
|
1433
1553
|
if (file.endsWith('/outbound-endpoints.ts')) continue
|
|
1434
|
-
|
|
1435
|
-
const program =
|
|
1436
|
-
|
|
1437
|
-
}).program
|
|
1438
|
-
const names = networkNames(program, file, exportedFetchAliasCache)
|
|
1554
|
+
if (!tokenPattern.test(sources.get(file)!)) continue
|
|
1555
|
+
const { source, program } = loadParsedFile(file, caches)
|
|
1556
|
+
const names = networkNames(program, file, caches)
|
|
1439
1557
|
const relative = path.relative(repositoryRoot, file).split(path.sep).join('/')
|
|
1440
1558
|
const recordCall = (node: CallExpression | NewExpression): void => {
|
|
1441
1559
|
const kind = callKind(node, names, source)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2425 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2425 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2425 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2425 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2425 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
package/dist-lib/beta.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2425 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
package/dist-lib/beta.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2425 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2425 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|