peachsim 0.1.2498 → 0.1.2500
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/agent-note.ts +76 -59
- package/cli/cloud-client.ts +59 -1
- package/cli/cloud-dispatch.ts +8 -1
- package/cli/commands/perf-native.ts +72 -2
- package/cli/commands/serve.ts +30 -5
- package/cli/commands/stream.ts +29 -33
- package/cli/outbound-endpoints.ts +2 -0
- package/cli/stream-record.ts +56 -0
- 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 +2 -2
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +5 -5
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +3 -3
- package/dist-lib/bundle-channel.cjs +1 -1
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +3 -3
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +3 -3
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +2 -2
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +7 -7
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +5 -5
- package/dist-lib/detox/index.cjs +35 -19
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/esm-chunks/{acorn-CV7H6VJJ.mjs → acorn-FAFTHRIF.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-4ASYVZ5B.mjs → chunk-2TEZ22ZJ.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-UQKT44EJ.mjs → chunk-3WW5WG4Z.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-SOUJNEPW.mjs → chunk-B47KUDF6.mjs} +2 -2
- package/dist-lib/esm-chunks/{chunk-QAIJ5OQB.mjs → chunk-BHMUWCQ3.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-AB56E2TJ.mjs → chunk-BZZDAC5F.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-RHXRTQKV.mjs → chunk-COY6S3UO.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-E3TYTJHG.mjs → chunk-DVVPGZAO.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-BISD2YO4.mjs → chunk-EE3RVR43.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-ZPGGRIC3.mjs → chunk-FTW7FYVC.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-YCQWIWGZ.mjs → chunk-G5XQIR2J.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-DKGZUPYM.mjs → chunk-GUWMIHAV.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-QK3DYE56.mjs → chunk-HC2AC7SK.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-FOIUHQFJ.mjs → chunk-HQFK43EA.mjs} +12 -12
- package/dist-lib/esm-chunks/{chunk-GB3YGXNX.mjs → chunk-JRVAB44R.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-DVMGK7EL.mjs → chunk-MAV7ERB4.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-LMRGVTQM.mjs → chunk-NVK7HKIG.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-P6UVYWER.mjs → chunk-SMNIC2BY.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-6UZPG7WL.mjs → chunk-U2A7SW35.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-HZVWEN6V.mjs → chunk-X7BCKYHC.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-474VQXI5.mjs → chunk-Z4J4KXU3.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-JURSSDET.mjs → chunk-ZUTV47C5.mjs} +5 -5
- package/dist-lib/esm-chunks/{metro-layout-parser-6D3UQ5ZK.mjs → metro-layout-parser-23DHUJCN.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-TLGMG7HO.mjs → swift-package-prebuilt-TVGODNLV.mjs} +10 -10
- package/dist-lib/esm-chunks/{swift-sdk-app-module-X5IDBZ4Q.mjs → swift-sdk-app-module-CZGSZHEG.mjs} +13 -13
- package/dist-lib/esm-chunks/{swift-sdk-image-F6O2N2C6.mjs → swift-sdk-image-2ZL67WIA.mjs} +13 -13
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-UOV2FEBV.mjs → swift-sdk-image-producer-F4O3V7LJ.mjs} +4 -4
- package/dist-lib/expo-swift-bundle.cjs +1 -1
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +7 -7
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +92 -59
- 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 +2 -2
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +98 -16
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +3 -3
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +3 -3
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +4 -4
- package/dist-lib/native-app-identity-project.cjs +1 -1
- package/dist-lib/native-app-identity-project.mjs +15 -15
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +6 -6
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +3 -3
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +2 -2
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +3 -3
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +81 -80
- package/dist-lib/public-origins-lib.json +78 -71
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +2 -2
- 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 +7 -7
- package/dist-lib/skills.cjs +545 -459
- package/dist-lib/swift-compile.cjs +1 -1
- package/dist-lib/swift-compile.mjs +10 -10
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +3 -3
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +5 -5
- package/dist-lib/swift-svg-raster.cjs +30 -20
- package/dist-lib/swift-svg-raster.mjs +31 -21
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
- package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
- package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
- package/dist-lib/vendor/@xmldom/xmldom.cjs +1 -1
- package/dist-lib/vendor/acorn.cjs +1 -1
- package/dist-lib/vendor/bplist-parser.cjs +1 -1
- package/dist-lib/vendor/ignore.cjs +1 -1
- package/dist-lib/vendor/magic-string.cjs +1 -1
- package/dist-lib/vendor/plist.cjs +1 -1
- package/dist-lib/vendor/smol-toml.cjs +1 -1
- package/dist-lib/vendor/stream-json.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
- package/dist-lib/vendor/sucrase.cjs +1 -1
- package/dist-lib/vendor/terser.cjs +1 -1
- package/dist-lib/vendor/valibot.cjs +1 -1
- package/dist-lib/vendor/ws.cjs +1 -1
- package/dist-lib/vendor/zod.cjs +1 -1
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +3 -3
- package/dist-types/packages/peach-engine/src/engine/animationDriverContract.d.ts +3 -0
- package/dist-types/packages/peach-engine/src/engine/image-svg-raster.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/engine/native-animation-driver.d.ts +1 -0
- package/dist-types/packages/peach-engine/vendor/camera/camera-heic.d.ts +2 -1
- package/package.json +1 -1
- package/src/svg-rasterizer-wasm.ts +44 -0
- package/src/swift-svg-raster.ts +10 -39
package/cli/agent-note.ts
CHANGED
|
@@ -19,11 +19,16 @@ import {
|
|
|
19
19
|
} from '../src/canvas-agent-note-delivery'
|
|
20
20
|
import { rnxPublicBrand } from '../src/public-brand'
|
|
21
21
|
import { authHeaderValue, resolveCliAuth } from './auth'
|
|
22
|
-
import { resolveCloudSessionForParsed } from './cloud-client'
|
|
23
|
-
import { readLocalStreamRecord } from './commands/stream'
|
|
22
|
+
import { createCloudBridgeForParsed, resolveCloudSessionForParsed } from './cloud-client'
|
|
24
23
|
import { getCliIdentity, readCurrentTarget } from './current-sim'
|
|
24
|
+
import { readLocalStreamRecord, readSceneStreamForParsed } from './stream-record'
|
|
25
25
|
import { CliUsageError } from './usage-error'
|
|
26
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
callInBridge,
|
|
28
|
+
createBridge,
|
|
29
|
+
parseBridgeCliArgs,
|
|
30
|
+
type WsBridge,
|
|
31
|
+
} from './ws-bridge'
|
|
27
32
|
import type { SootSimInspectInfo } from '@peach/globals'
|
|
28
33
|
|
|
29
34
|
export function inspectArtifactDirectory(messageId: string): string {
|
|
@@ -127,12 +132,13 @@ function inboxTarget(args: string[], port?: number) {
|
|
|
127
132
|
: identity.key,
|
|
128
133
|
)
|
|
129
134
|
: undefined
|
|
130
|
-
const
|
|
135
|
+
const scene = readSceneStreamForParsed(parsed)
|
|
136
|
+
const cloud = scene ? null : resolveCloudSessionForParsed(parsed)
|
|
131
137
|
const simId = cloud?.service === 'box' ? cloud.boxId : (cloud?.simId ?? parsed.simId)
|
|
132
|
-
const stream = !cloud && simId ? readLocalStreamRecord(simId) : null
|
|
138
|
+
const stream = scene ?? (!cloud && simId ? readLocalStreamRecord(simId) : null)
|
|
133
139
|
const pin = readCurrentTarget()
|
|
134
140
|
const local =
|
|
135
|
-
!cloud && simId
|
|
141
|
+
!cloud && !scene && simId
|
|
136
142
|
? {
|
|
137
143
|
simId,
|
|
138
144
|
port: parsed.explicitPort
|
|
@@ -160,7 +166,7 @@ function inboxTarget(args: string[], port?: number) {
|
|
|
160
166
|
authorization: authHeaderValue(auth),
|
|
161
167
|
}
|
|
162
168
|
: null
|
|
163
|
-
return { local, remote, simId, recipientId }
|
|
169
|
+
return { local, remote, simId, recipientId, parsed }
|
|
164
170
|
}
|
|
165
171
|
|
|
166
172
|
type CloudInbox = NonNullable<ReturnType<typeof inboxTarget>['remote']>
|
|
@@ -191,17 +197,12 @@ async function requestCloudNote<T>(
|
|
|
191
197
|
}
|
|
192
198
|
}
|
|
193
199
|
|
|
194
|
-
async function takeCloudNote(
|
|
195
|
-
remote: CloudInbox,
|
|
196
|
-
recipientId: string,
|
|
197
|
-
wait: boolean,
|
|
198
|
-
grant?: string,
|
|
199
|
-
) {
|
|
200
|
+
async function takeCloudNote(remote: CloudInbox, recipientId: string, grant?: string) {
|
|
200
201
|
const { data } = await requestCloudNote<{ message: AgentInspectMessage | null }>(
|
|
201
202
|
remote,
|
|
202
203
|
recipientId,
|
|
203
204
|
'take',
|
|
204
|
-
|
|
205
|
+
false,
|
|
205
206
|
{ grant },
|
|
206
207
|
)
|
|
207
208
|
return data.message
|
|
@@ -233,12 +234,7 @@ async function listenToStreamNotes(
|
|
|
233
234
|
const delivery = await Promise.race([local, waitForCloud()])
|
|
234
235
|
if ('id' in delivery) return delivery
|
|
235
236
|
if (!(await client.cancelInspectListener(simId))) return await local
|
|
236
|
-
const cloud = await takeCloudNote(
|
|
237
|
-
remote,
|
|
238
|
-
recipientId,
|
|
239
|
-
false,
|
|
240
|
-
delivery.grant ?? undefined,
|
|
241
|
-
)
|
|
237
|
+
const cloud = await takeCloudNote(remote, recipientId, delivery.grant ?? undefined)
|
|
242
238
|
if (cloud) return cloud
|
|
243
239
|
} finally {
|
|
244
240
|
stop.abort()
|
|
@@ -246,53 +242,74 @@ async function listenToStreamNotes(
|
|
|
246
242
|
}
|
|
247
243
|
}
|
|
248
244
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
)
|
|
256
|
-
while (true) {
|
|
257
|
-
const message = await takeCloudNote(remote, recipientId, true)
|
|
258
|
-
if (message) return message
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
if (!local) {
|
|
262
|
-
throw new CliUsageError(
|
|
263
|
-
simId
|
|
264
|
-
? 'Sign in to receive notes for the remote simulator.'
|
|
265
|
-
: 'No current simulator. Run peach use <id> or pass --sim <id>.',
|
|
266
|
-
)
|
|
267
|
-
}
|
|
268
|
-
const client = await connectToDaemon({
|
|
269
|
-
port: local.port,
|
|
270
|
-
commandTimeoutMs: 0,
|
|
271
|
-
clientLabel: 'peach-agent-listen',
|
|
272
|
-
})
|
|
273
|
-
// the canvas lists an agent only while it acts, so a waiting agent says so
|
|
274
|
-
// and the people watching can still pick its app and send a note
|
|
275
|
-
const presence = createBridge(local.port, {
|
|
276
|
-
simId: local.simId,
|
|
277
|
-
commandTimeoutMs: 10_000,
|
|
278
|
-
})
|
|
279
|
-
const announce = () => void presence.send({ type: 'listen' }).catch(() => undefined)
|
|
245
|
+
async function listenWithPresence(
|
|
246
|
+
presence: WsBridge,
|
|
247
|
+
listen: () => Promise<AgentInspectMessage>,
|
|
248
|
+
) {
|
|
249
|
+
const announce = () =>
|
|
250
|
+
void presence.send({ type: 'listen' }, { timeoutMs: 10_000 }).catch(() => undefined)
|
|
280
251
|
announce()
|
|
281
252
|
const announcing = setInterval(announce, LISTEN_PRESENCE_MS)
|
|
282
253
|
try {
|
|
283
|
-
|
|
284
|
-
return await nameCanvasNotePoint(
|
|
285
|
-
await listenToStreamNotes(client, local.simId, remote, recipientId),
|
|
286
|
-
local,
|
|
287
|
-
)
|
|
288
|
-
return await client.listenForInspect(local.simId, recipientId)
|
|
254
|
+
return await listen()
|
|
289
255
|
} finally {
|
|
290
256
|
clearInterval(announcing)
|
|
291
257
|
presence.close()
|
|
292
|
-
client.close()
|
|
293
258
|
}
|
|
294
259
|
}
|
|
295
260
|
|
|
261
|
+
export async function listenForAgentInspect(args: string[], port?: number) {
|
|
262
|
+
const { local, remote, simId, recipientId, parsed } = inboxTarget(args, port)
|
|
263
|
+
if (local) {
|
|
264
|
+
const client = await connectToDaemon({
|
|
265
|
+
port: local.port,
|
|
266
|
+
commandTimeoutMs: 0,
|
|
267
|
+
clientLabel: 'peach-agent-listen',
|
|
268
|
+
})
|
|
269
|
+
try {
|
|
270
|
+
return await listenWithPresence(
|
|
271
|
+
createBridge(local.port, { simId: local.simId }),
|
|
272
|
+
async () => {
|
|
273
|
+
if (remote && recipientId)
|
|
274
|
+
return nameCanvasNotePoint(
|
|
275
|
+
await listenToStreamNotes(client, local.simId, remote, recipientId),
|
|
276
|
+
local,
|
|
277
|
+
)
|
|
278
|
+
return client.listenForInspect(local.simId, recipientId)
|
|
279
|
+
},
|
|
280
|
+
)
|
|
281
|
+
} finally {
|
|
282
|
+
client.close()
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
const presence = remote ? createCloudBridgeForParsed(parsed) : null
|
|
286
|
+
if (remote && presence) {
|
|
287
|
+
if (!recipientId)
|
|
288
|
+
throw new CliUsageError(
|
|
289
|
+
'Set PEACH_CLI_IDENTITY to the identity driving the simulator.',
|
|
290
|
+
)
|
|
291
|
+
return listenWithPresence(presence, async () => {
|
|
292
|
+
let grant: string | undefined
|
|
293
|
+
while (true) {
|
|
294
|
+
const result = await requestCloudNote<{ message: AgentInspectMessage | null }>(
|
|
295
|
+
remote,
|
|
296
|
+
recipientId,
|
|
297
|
+
'take',
|
|
298
|
+
true,
|
|
299
|
+
{ grant },
|
|
300
|
+
)
|
|
301
|
+
if (result.data.message) return result.data.message
|
|
302
|
+
grant = result.grant ?? grant
|
|
303
|
+
}
|
|
304
|
+
})
|
|
305
|
+
}
|
|
306
|
+
throw new CliUsageError(
|
|
307
|
+
simId
|
|
308
|
+
? 'Sign in to receive notes for the remote simulator.'
|
|
309
|
+
: 'No current simulator. Run peach use <id> or pass --sim <id>.',
|
|
310
|
+
)
|
|
311
|
+
}
|
|
312
|
+
|
|
296
313
|
export async function printPendingCanvasNote(args: string[], port?: number) {
|
|
297
314
|
const { local, remote, recipientId } = inboxTarget(args, port)
|
|
298
315
|
if (!recipientId) return
|
|
@@ -311,7 +328,7 @@ export async function printPendingCanvasNote(args: string[], port?: number) {
|
|
|
311
328
|
client.close()
|
|
312
329
|
}
|
|
313
330
|
}
|
|
314
|
-
if (!message && remote) message = await takeCloudNote(remote, recipientId
|
|
331
|
+
if (!message && remote) message = await takeCloudNote(remote, recipientId)
|
|
315
332
|
if (!message) return
|
|
316
333
|
if (local) message = await nameCanvasNotePoint(message, local)
|
|
317
334
|
const artifacts = saveCanvasNoteArtifacts(message)
|
package/cli/cloud-client.ts
CHANGED
|
@@ -69,6 +69,8 @@ import {
|
|
|
69
69
|
import { commandAgent } from './command-agent.ts'
|
|
70
70
|
import { detectProject } from './commands/detect.ts'
|
|
71
71
|
import { resolveCheckoutRepo } from './run-registry.ts'
|
|
72
|
+
import { readSceneStreamForParsed, type SceneCommandEndpoint } from './stream-record'
|
|
73
|
+
import { CliUsageError } from './usage-error'
|
|
72
74
|
import type { WsBridgeCommand } from '../src/bridge-contract.ts'
|
|
73
75
|
import type {
|
|
74
76
|
BridgeClaimResult,
|
|
@@ -1763,14 +1765,70 @@ export function createCloudBridgeForParsed(
|
|
|
1763
1765
|
Pick<ParsedBridgeCliArgs, 'explicitTimeout' | 'commandTimeoutMs' | 'explicitPort'>
|
|
1764
1766
|
>,
|
|
1765
1767
|
): WsBridge | null {
|
|
1768
|
+
const scene = readSceneStreamForParsed(parsed)
|
|
1769
|
+
const timeoutMs = parsed.explicitTimeout ? parsed.commandTimeoutMs : undefined
|
|
1770
|
+
if (scene) return new SceneBridge(scene.command, timeoutMs)
|
|
1766
1771
|
const session = resolveCloudSessionForParsed(parsed)
|
|
1767
1772
|
if (!session) return null
|
|
1768
|
-
const timeoutMs = parsed.explicitTimeout ? parsed.commandTimeoutMs : undefined
|
|
1769
1773
|
return session.service === 'box'
|
|
1770
1774
|
? new CloudBoxBridge(session, timeoutMs)
|
|
1771
1775
|
: new CloudBridge(session, timeoutMs)
|
|
1772
1776
|
}
|
|
1773
1777
|
|
|
1778
|
+
class SceneBridge implements WsBridge {
|
|
1779
|
+
readonly plane = 'cloud' as const
|
|
1780
|
+
|
|
1781
|
+
constructor(
|
|
1782
|
+
private readonly endpoint: SceneCommandEndpoint,
|
|
1783
|
+
private readonly explicitTimeoutMs?: number,
|
|
1784
|
+
) {}
|
|
1785
|
+
|
|
1786
|
+
async send(
|
|
1787
|
+
command: WsBridgeCommand,
|
|
1788
|
+
options?: { timeoutMs?: number; defaultTimeoutMs?: number },
|
|
1789
|
+
): Promise<unknown> {
|
|
1790
|
+
const timeoutMs =
|
|
1791
|
+
options?.timeoutMs ?? this.explicitTimeoutMs ?? options?.defaultTimeoutMs ?? 15_000
|
|
1792
|
+
const agent = commandAgent(command)
|
|
1793
|
+
const response = await fetch(`http://127.0.0.1:${this.endpoint.port}/command`, {
|
|
1794
|
+
method: 'POST',
|
|
1795
|
+
headers: {
|
|
1796
|
+
authorization: `Bearer ${this.endpoint.token}`,
|
|
1797
|
+
'content-type': 'application/json',
|
|
1798
|
+
},
|
|
1799
|
+
body: JSON.stringify(cloudCommand(agent ? { ...command, agent } : command)),
|
|
1800
|
+
...(timeoutMs ? { signal: AbortSignal.timeout(timeoutMs) } : {}),
|
|
1801
|
+
})
|
|
1802
|
+
if (!response.ok && response.headers.get('content-type') !== 'application/json')
|
|
1803
|
+
throw new CliUsageError(`Scene host returned HTTP ${response.status}.`)
|
|
1804
|
+
const body: unknown = await response.json()
|
|
1805
|
+
if (!response.ok)
|
|
1806
|
+
throw new Error(
|
|
1807
|
+
isRecord(body) && typeof body.error === 'string'
|
|
1808
|
+
? body.error
|
|
1809
|
+
: `scene host returned HTTP ${response.status}`,
|
|
1810
|
+
)
|
|
1811
|
+
return body
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
async listSims(): Promise<never> {
|
|
1815
|
+
throw new CliUsageError('Use peach list to see simulators on the local bridge.')
|
|
1816
|
+
}
|
|
1817
|
+
async resolveReloadedSim(): Promise<null> {
|
|
1818
|
+
return null
|
|
1819
|
+
}
|
|
1820
|
+
async focusSim(): Promise<never> {
|
|
1821
|
+
throw new Error('a scene host has no browser window to focus')
|
|
1822
|
+
}
|
|
1823
|
+
async closeSim(): Promise<never> {
|
|
1824
|
+
throw new Error('stop the scene host to close its simulator')
|
|
1825
|
+
}
|
|
1826
|
+
async claim(): Promise<never> {
|
|
1827
|
+
throw new Error('a scene host does not use CLI claims')
|
|
1828
|
+
}
|
|
1829
|
+
close(): void {}
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1774
1832
|
// deletes the box, which ends the simulator it holds. a cloud session box is
|
|
1775
1833
|
// the prebuilt bundle `peach ios --remote` created, so it holds nothing but that
|
|
1776
1834
|
// bundle: stopping it would only keep its name taken and its storage held. an
|
package/cli/cloud-dispatch.ts
CHANGED
|
@@ -131,12 +131,19 @@ export async function dispatchCloudBoundary({
|
|
|
131
131
|
}
|
|
132
132
|
if (!CLOUD_TARGET_COMMANDS.has(command)) return { handled: false }
|
|
133
133
|
|
|
134
|
-
const [
|
|
134
|
+
const [
|
|
135
|
+
{ parseBridgeCliArgs },
|
|
136
|
+
cloudClient,
|
|
137
|
+
cloudSession,
|
|
138
|
+
{ readSceneStreamForParsed },
|
|
139
|
+
] = await Promise.all([
|
|
135
140
|
import('./ws-bridge'),
|
|
136
141
|
import('./cloud-client'),
|
|
137
142
|
import('./cloud-session'),
|
|
143
|
+
import('./stream-record'),
|
|
138
144
|
])
|
|
139
145
|
const parsed = parseBridgeCliArgs(args)
|
|
146
|
+
if (readSceneStreamForParsed(parsed)) return { handled: false }
|
|
140
147
|
const positionalTarget =
|
|
141
148
|
command === 'claim' || command === 'close' ? firstVerb(parsed.positional) : null
|
|
142
149
|
const target: Pick<typeof parsed, 'simId' | 'simIdSource'> = positionalTarget
|
|
@@ -411,7 +411,9 @@ function symbolicateTrace(tracePath: string, bundle: SourceMapBundle): void {
|
|
|
411
411
|
if (changed) writeFileSync(tracePath, JSON.stringify(parsed))
|
|
412
412
|
}
|
|
413
413
|
|
|
414
|
-
|
|
414
|
+
type ProfileLocation = Pick<NativeProfileFunction, 'name' | 'url' | 'line' | 'column'>
|
|
415
|
+
|
|
416
|
+
function symbolicateFnList(list: ProfileLocation[], bundle: SourceMapBundle): void {
|
|
415
417
|
for (const entry of list) {
|
|
416
418
|
const resolved = resolveAotLocation(
|
|
417
419
|
bundle,
|
|
@@ -432,7 +434,14 @@ function symbolicateReport(report: NativeProfileReport, bundle: SourceMapBundle)
|
|
|
432
434
|
if (!Object.keys(bundle.rawMaps).length) return
|
|
433
435
|
symbolicateFnList(report.topJsFunctions, bundle)
|
|
434
436
|
if (report.topJsCallers) symbolicateFnList(report.topJsCallers, bundle)
|
|
435
|
-
|
|
437
|
+
symbolicateReactNames(report.topReactComponents, bundle)
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function symbolicateReactNames(
|
|
441
|
+
components: { name: string }[],
|
|
442
|
+
bundle: SourceMapBundle,
|
|
443
|
+
): void {
|
|
444
|
+
for (const comp of components) {
|
|
436
445
|
const demangled = demangleAotSymbol(bundle, undefined, comp.name)
|
|
437
446
|
if (demangled?.name && demangled.name !== comp.name) {
|
|
438
447
|
comp.name = demangled.source
|
|
@@ -442,6 +451,56 @@ function symbolicateReport(report: NativeProfileReport, bundle: SourceMapBundle)
|
|
|
442
451
|
}
|
|
443
452
|
}
|
|
444
453
|
|
|
454
|
+
function symbolicateTelemetry(input: string, mapsPath: string): string {
|
|
455
|
+
const mapDirectory = statSync(mapsPath).isDirectory()
|
|
456
|
+
const snapshots: Record<string, unknown>[] = []
|
|
457
|
+
let current: { uuid: string; bundle: SourceMapBundle } | undefined
|
|
458
|
+
for (const line of readFileSync(input, 'utf8').split('\n')) {
|
|
459
|
+
if (!line.trim()) continue
|
|
460
|
+
const row: unknown = JSON.parse(line)
|
|
461
|
+
if (!isRecord(row)) continue
|
|
462
|
+
const snapshot = isRecord(row.details) ? row.details : row
|
|
463
|
+
const { executableUUID, topJsFunctions, topReactComponents } = snapshot
|
|
464
|
+
if (
|
|
465
|
+
typeof executableUUID !== 'string' ||
|
|
466
|
+
!/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(executableUUID) ||
|
|
467
|
+
!Array.isArray(topJsFunctions) ||
|
|
468
|
+
!Array.isArray(topReactComponents)
|
|
469
|
+
)
|
|
470
|
+
continue
|
|
471
|
+
|
|
472
|
+
if (current?.uuid !== executableUUID) {
|
|
473
|
+
const expected = `OneJavaScriptSourceMaps-${executableUUID}.json`
|
|
474
|
+
const mapFile = mapDirectory ? join(mapsPath, expected) : mapsPath
|
|
475
|
+
if (basename(mapFile) !== expected || !existsSync(mapFile)) {
|
|
476
|
+
throw new Error(`Missing exact source map ${expected}`)
|
|
477
|
+
}
|
|
478
|
+
const bundle = loadSourceMapsBundle(mapFile, executableUUID)
|
|
479
|
+
if (!Object.keys(bundle.rawMaps).length)
|
|
480
|
+
throw new Error(`No source maps in ${mapFile}`)
|
|
481
|
+
current = { uuid: executableUUID, bundle }
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
const jsFunctions = topJsFunctions.filter(
|
|
485
|
+
(entry: unknown): entry is ProfileLocation =>
|
|
486
|
+
isRecord(entry) &&
|
|
487
|
+
typeof entry.name === 'string' &&
|
|
488
|
+
typeof entry.url === 'string' &&
|
|
489
|
+
typeof entry.line === 'number' &&
|
|
490
|
+
typeof entry.column === 'number',
|
|
491
|
+
)
|
|
492
|
+
const components = topReactComponents.filter(
|
|
493
|
+
(entry: unknown): entry is { name: string } =>
|
|
494
|
+
isRecord(entry) && typeof entry.name === 'string',
|
|
495
|
+
)
|
|
496
|
+
symbolicateFnList(jsFunctions, current.bundle)
|
|
497
|
+
symbolicateReactNames(components, current.bundle)
|
|
498
|
+
snapshots.push(row)
|
|
499
|
+
}
|
|
500
|
+
if (!snapshots.length) throw new Error(`No profiler telemetry snapshots in ${input}`)
|
|
501
|
+
return `${JSON.stringify(snapshots, null, 2)}\n`
|
|
502
|
+
}
|
|
503
|
+
|
|
445
504
|
function detectSimulatorBundleId(udid: string): string {
|
|
446
505
|
const list = execFileSync('xcrun', ['simctl', 'spawn', udid, 'launchctl', 'list'], {
|
|
447
506
|
encoding: 'utf8',
|
|
@@ -565,6 +624,7 @@ usage:
|
|
|
565
624
|
peach perf native --device <device-udid> --bundle-id <id> --scheme <url-scheme> [--duration <sec>] [-o <prefix>]
|
|
566
625
|
peach perf native --overlay <on|off|toggle> [--bundle-id <id>] [--udid <sim-udid>]
|
|
567
626
|
peach perf native --start|--stop [--bundle-id <id>] [--udid <sim-udid>] [-o <prefix>]
|
|
627
|
+
peach perf native --telemetry <jsonl> --source-maps <path> [-o <file>]
|
|
568
628
|
|
|
569
629
|
options:
|
|
570
630
|
--bundle-id <id> App bundle identifier (auto-detected if one user app is running on simulator)
|
|
@@ -574,6 +634,7 @@ options:
|
|
|
574
634
|
--duration <sec> Capture window in seconds (default: 5)
|
|
575
635
|
-o, --output <path> Output file prefix or directory (default: /tmp/one-profile-<ts>)
|
|
576
636
|
--source-maps <path> Path to OneJavaScriptSourceMaps-<uuid>.json or build directory for AoT symbolication
|
|
637
|
+
--telemetry <jsonl> Symbolicate saved rolling snapshots and print JSON without connecting to a device
|
|
577
638
|
--overlay <mode> Toggle floating overlay: on, off, or toggle
|
|
578
639
|
--start Start profiling without waiting
|
|
579
640
|
--stop Stop an active profile and pull artifacts
|
|
@@ -687,6 +748,7 @@ export async function runPerfNative(args: string[]): Promise<number> {
|
|
|
687
748
|
duration: { type: 'string', default: '5' },
|
|
688
749
|
output: { type: 'string', short: 'o' },
|
|
689
750
|
'source-maps': { type: 'string' },
|
|
751
|
+
telemetry: { type: 'string' },
|
|
690
752
|
overlay: { type: 'string' },
|
|
691
753
|
start: { type: 'boolean', default: false },
|
|
692
754
|
stop: { type: 'boolean', default: false },
|
|
@@ -695,6 +757,14 @@ export async function runPerfNative(args: string[]): Promise<number> {
|
|
|
695
757
|
strict: true,
|
|
696
758
|
})
|
|
697
759
|
|
|
760
|
+
if (values.telemetry) {
|
|
761
|
+
if (!values['source-maps']) throw new Error('--telemetry requires --source-maps')
|
|
762
|
+
const named = symbolicateTelemetry(values.telemetry, values['source-maps'])
|
|
763
|
+
if (values.output) writeFileSync(values.output, named, { mode: 0o600 })
|
|
764
|
+
else process.stdout.write(named)
|
|
765
|
+
return 0
|
|
766
|
+
}
|
|
767
|
+
|
|
698
768
|
const durationSec = Number(values.duration)
|
|
699
769
|
if (!Number.isFinite(durationSec) || durationSec <= 0) {
|
|
700
770
|
throw new Error('--duration must be a positive number of seconds')
|
package/cli/commands/serve.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
import { spawn } from 'node:child_process'
|
|
12
12
|
import { basename, join, resolve } from 'node:path'
|
|
13
|
+
import { createInterface } from 'node:readline'
|
|
13
14
|
import {
|
|
14
15
|
assertPeachPortEnvironment,
|
|
15
16
|
DEFAULT_SOOTSIM_BRIDGE_PORT,
|
|
@@ -28,6 +29,7 @@ import {
|
|
|
28
29
|
findStaleDevBuildRoutes,
|
|
29
30
|
} from '../dev-build-freshness'
|
|
30
31
|
import { peachExit } from '../run-rnx'
|
|
32
|
+
import { sceneCommandEndpoint } from '../stream-record'
|
|
31
33
|
import { registerSceneStream, STREAM_FLAG } from './stream'
|
|
32
34
|
import { resolveDefaultUploadOrigin } from './upload'
|
|
33
35
|
|
|
@@ -133,18 +135,41 @@ examples:
|
|
|
133
135
|
...nodeArgs,
|
|
134
136
|
]
|
|
135
137
|
}
|
|
136
|
-
const child = spawn(program, launchArgs, {
|
|
138
|
+
const child = spawn(program, launchArgs, {
|
|
139
|
+
stdio: ['inherit', stream ? 'pipe' : 'inherit', 'inherit'],
|
|
140
|
+
})
|
|
137
141
|
const signals = ['SIGINT', 'SIGTERM', 'SIGHUP'] satisfies NodeJS.Signals[]
|
|
138
142
|
const forward = (signal: NodeJS.Signals) => child.kill(signal)
|
|
143
|
+
const exited = new Promise<number>((resolve, reject) => {
|
|
144
|
+
child.once('error', reject)
|
|
145
|
+
child.once('exit', (code) => resolve(code ?? 1))
|
|
146
|
+
})
|
|
139
147
|
for (const signal of signals) process.on(signal, forward)
|
|
140
148
|
try {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
149
|
+
let ready: Promise<void> | undefined
|
|
150
|
+
if (stream && child.stdout) {
|
|
151
|
+
const publishing = stream
|
|
152
|
+
const lines = createInterface({ input: child.stdout })
|
|
153
|
+
ready = new Promise<void>((resolve, reject) => {
|
|
154
|
+
lines.once('line', (line) => {
|
|
155
|
+
try {
|
|
156
|
+
publishing.recordCommand(sceneCommandEndpoint.parse(JSON.parse(line)))
|
|
157
|
+
resolve()
|
|
158
|
+
} catch (error) {
|
|
159
|
+
reject(error)
|
|
160
|
+
}
|
|
161
|
+
})
|
|
162
|
+
lines.once('close', () =>
|
|
163
|
+
reject(new Error('scene host stopped before startup')),
|
|
164
|
+
)
|
|
165
|
+
})
|
|
166
|
+
lines.on('line', (line) => console.log(line))
|
|
167
|
+
}
|
|
168
|
+
const [code] = await Promise.all([exited, ready])
|
|
145
169
|
if (code !== 0) peachExit(code)
|
|
146
170
|
} finally {
|
|
147
171
|
for (const signal of signals) process.off(signal, forward)
|
|
172
|
+
if (child.exitCode === null && child.signalCode === null) child.kill()
|
|
148
173
|
await stream?.stop()
|
|
149
174
|
}
|
|
150
175
|
return
|
package/cli/commands/stream.ts
CHANGED
|
@@ -1,38 +1,31 @@
|
|
|
1
|
-
import { mkdirSync,
|
|
1
|
+
import { mkdirSync, watch } from 'node:fs'
|
|
2
2
|
import { join } from 'node:path'
|
|
3
3
|
import { z } from 'zod'
|
|
4
4
|
import { rnxHomeDir } from '../../src/home-paths'
|
|
5
5
|
import { rnxPublicBrand } from '../../src/public-brand'
|
|
6
6
|
import { authHeaderOrExit, cloudAccountIdOrExit } from '../auth'
|
|
7
7
|
import { resolveCheckoutRepo } from '../run-registry'
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
readLocalStreamRecord,
|
|
10
|
+
removeLocalStreamRecord,
|
|
11
|
+
writeLocalStreamRecord,
|
|
12
|
+
type SceneCommandEndpoint,
|
|
13
|
+
type StreamRecord,
|
|
14
|
+
} from '../stream-record'
|
|
9
15
|
import { callInBridge, createBridgeFromParsed, parseBridgeCliArgs } from '../ws-bridge'
|
|
10
16
|
|
|
11
17
|
export const STREAM_FLAG = '--stream'
|
|
12
18
|
const registrationSchema = z.object({
|
|
13
|
-
session: z.object({
|
|
19
|
+
session: z.object({
|
|
20
|
+
id: z.string(),
|
|
21
|
+
accountId: z.string(),
|
|
22
|
+
externalId: z.string(),
|
|
23
|
+
url: z.string(),
|
|
24
|
+
}),
|
|
14
25
|
url: z.string(),
|
|
15
26
|
token: z.string(),
|
|
16
27
|
credential: z.string(),
|
|
17
28
|
})
|
|
18
|
-
const recordSchema = z.object({
|
|
19
|
-
sessionId: z.string(),
|
|
20
|
-
accountId: z.string(),
|
|
21
|
-
origin: z.string(),
|
|
22
|
-
watchUrl: z.string(),
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
export function readLocalStreamRecord(simId: string) {
|
|
26
|
-
const file = join(rnxHomeDir(), 'streams', `${encodeURIComponent(simId)}.json`)
|
|
27
|
-
try {
|
|
28
|
-
return recordSchema.parse(JSON.parse(readFileSync(file, 'utf8')))
|
|
29
|
-
} catch (error) {
|
|
30
|
-
if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return null
|
|
31
|
-
throw error
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
type StreamRecord = z.infer<typeof recordSchema>
|
|
36
29
|
type SignIn = ReturnType<typeof authHeaderOrExit>
|
|
37
30
|
|
|
38
31
|
// a stream session on the signed-in account, watched at its /sim/<id> page
|
|
@@ -87,11 +80,21 @@ export async function registerSceneStream(body: { device: string; name: string }
|
|
|
87
80
|
transport: 'scene',
|
|
88
81
|
...body,
|
|
89
82
|
})
|
|
83
|
+
const simId = registration.session.externalId
|
|
90
84
|
return {
|
|
91
85
|
relay: registration.url,
|
|
92
86
|
credential: registration.credential,
|
|
93
87
|
watchUrl: record.watchUrl,
|
|
94
|
-
|
|
88
|
+
recordCommand(command: SceneCommandEndpoint) {
|
|
89
|
+
writeLocalStreamRecord(simId, { ...record, command }, false)
|
|
90
|
+
},
|
|
91
|
+
async stop() {
|
|
92
|
+
try {
|
|
93
|
+
removeLocalStreamRecord(simId)
|
|
94
|
+
} finally {
|
|
95
|
+
await stop()
|
|
96
|
+
}
|
|
97
|
+
},
|
|
95
98
|
}
|
|
96
99
|
}
|
|
97
100
|
|
|
@@ -127,7 +130,6 @@ export async function runStreamCommand(
|
|
|
127
130
|
throw new Error('Could not identify the local simulator.')
|
|
128
131
|
const directory = join(rnxHomeDir(), 'streams')
|
|
129
132
|
mkdirSync(directory, { recursive: true })
|
|
130
|
-
const file = join(directory, `${encodeURIComponent(simId)}.json`)
|
|
131
133
|
const state = await callInBridge<string>(bridge, 'SootSim.bridges.videoStream.state')
|
|
132
134
|
if (action === 'status') {
|
|
133
135
|
console.log(` stream: ${state}`)
|
|
@@ -138,7 +140,7 @@ export async function runStreamCommand(
|
|
|
138
140
|
await callInBridge(bridge, 'SootSim.bridges.videoStream.stop')
|
|
139
141
|
const record = readLocalStreamRecord(simId)
|
|
140
142
|
if (record) await stopStreamSession(record, header)
|
|
141
|
-
|
|
143
|
+
removeLocalStreamRecord(simId)
|
|
142
144
|
console.log(' stream: off')
|
|
143
145
|
return
|
|
144
146
|
}
|
|
@@ -172,8 +174,8 @@ export async function runStreamCommand(
|
|
|
172
174
|
url: registration.url,
|
|
173
175
|
token: registration.token,
|
|
174
176
|
})
|
|
175
|
-
|
|
176
|
-
removeRecord = () =>
|
|
177
|
+
writeLocalStreamRecord(simId, record, !opts.signal)
|
|
178
|
+
removeRecord = () => removeLocalStreamRecord(simId)
|
|
177
179
|
if (opts.onStarted) opts.onStarted(record.watchUrl)
|
|
178
180
|
else {
|
|
179
181
|
console.log(` simulator: ${record.watchUrl}`)
|
|
@@ -218,13 +220,7 @@ export async function runStreamCommand(
|
|
|
218
220
|
let alive = setTimeout(checkStream, 5000)
|
|
219
221
|
const watcher = watch(directory, (_event, filename) => {
|
|
220
222
|
if (filename !== `${encodeURIComponent(simId)}.json`) return
|
|
221
|
-
|
|
222
|
-
readFileSync(file)
|
|
223
|
-
} catch (error) {
|
|
224
|
-
if (error instanceof Error && 'code' in error && error.code === 'ENOENT')
|
|
225
|
-
finish()
|
|
226
|
-
else throw error
|
|
227
|
-
}
|
|
223
|
+
if (!readLocalStreamRecord(simId)) finish()
|
|
228
224
|
})
|
|
229
225
|
if (opts.signal) {
|
|
230
226
|
opts.signal.addEventListener('abort', stopped, { once: true })
|
|
@@ -459,6 +459,8 @@ export const DECLARED_OUTBOUND_CALLS: Record<string, OutboundCallDeclaration> =
|
|
|
459
459
|
{ category: 'peach_cloud_sim', count: 2 },
|
|
460
460
|
'packages/peachsim/cli/cloud-client.ts :: fetch :: `${this.session.apiOrigin}/v1/sims/${encodeURIComponent()}/commands`':
|
|
461
461
|
{ category: 'peach_cloud_sim', count: 1 },
|
|
462
|
+
'packages/peachsim/cli/cloud-client.ts :: fetch :: `http://127.0.0.1:${this.endpoint.port}/command`':
|
|
463
|
+
{ category: 'local_development', count: 1 },
|
|
462
464
|
'packages/peachsim/cli/cloud-client.ts :: fetch :: bundleUrl': {
|
|
463
465
|
category: 'guest_app_network',
|
|
464
466
|
count: 1,
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { readFileSync, rmSync } from 'node:fs'
|
|
2
|
+
import { join } from 'node:path'
|
|
3
|
+
import { z } from 'zod'
|
|
4
|
+
import { rnxHomeDir } from '../src/home-paths'
|
|
5
|
+
import { writeSecureJsonAtomic } from './secure-file'
|
|
6
|
+
import type { ParsedBridgeCliArgs } from './ws-bridge'
|
|
7
|
+
|
|
8
|
+
export const sceneCommandEndpoint = z.object({
|
|
9
|
+
port: z.number().int().min(1).max(65535),
|
|
10
|
+
token: z.string().regex(/^[a-f0-9]{64}$/),
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
const streamRecord = z.object({
|
|
14
|
+
sessionId: z.string(),
|
|
15
|
+
accountId: z.string(),
|
|
16
|
+
origin: z.string(),
|
|
17
|
+
watchUrl: z.string(),
|
|
18
|
+
command: sceneCommandEndpoint.optional(),
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
export type StreamRecord = z.infer<typeof streamRecord>
|
|
22
|
+
export type SceneCommandEndpoint = z.infer<typeof sceneCommandEndpoint>
|
|
23
|
+
|
|
24
|
+
function streamRecordPath(simId: string) {
|
|
25
|
+
return join(rnxHomeDir(), 'streams', `${encodeURIComponent(simId)}.json`)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function readLocalStreamRecord(simId: string): StreamRecord | null {
|
|
29
|
+
try {
|
|
30
|
+
return streamRecord.parse(JSON.parse(readFileSync(streamRecordPath(simId), 'utf8')))
|
|
31
|
+
} catch (error) {
|
|
32
|
+
if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return null
|
|
33
|
+
throw error
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function readSceneStreamForParsed(
|
|
38
|
+
parsed: Pick<ParsedBridgeCliArgs, 'simId'> &
|
|
39
|
+
Partial<Pick<ParsedBridgeCliArgs, 'explicitPort'>>,
|
|
40
|
+
) {
|
|
41
|
+
const record =
|
|
42
|
+
!parsed.explicitPort && parsed.simId ? readLocalStreamRecord(parsed.simId) : null
|
|
43
|
+
return record?.command ? { ...record, command: record.command } : null
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function writeLocalStreamRecord(
|
|
47
|
+
simId: string,
|
|
48
|
+
record: StreamRecord,
|
|
49
|
+
durable: boolean,
|
|
50
|
+
) {
|
|
51
|
+
writeSecureJsonAtomic(streamRecordPath(simId), record, { durable })
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function removeLocalStreamRecord(simId: string) {
|
|
55
|
+
rmSync(streamRecordPath(simId), { force: true })
|
|
56
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2500 | (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;
|