peachsim 0.1.2441 → 0.1.2457
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -49
- package/cli/app-catalog.ts +8 -7
- package/cli/app-stubs.ts +98 -70
- package/cli/cloud-box-artifact.ts +2 -5
- package/cli/cloud-client.ts +12 -1
- package/cli/commands/box.ts +41 -2
- package/cli/commands/compat.ts +5 -3
- package/cli/commands/cpu-profile.ts +11 -14
- package/cli/commands/diagnose.ts +5 -18
- package/cli/commands/inspect/describe.ts +4 -8
- package/cli/commands/maestro-generate.ts +4 -8
- package/cli/commands/mode.ts +3 -19
- package/cli/commands/perf.ts +3 -19
- package/cli/commands/permissions.ts +2 -6
- package/cli/commands/platform.ts +22 -14
- package/cli/commands/react.ts +7 -21
- package/cli/commands/record-three.ts +6 -10
- package/cli/commands/record.ts +38 -62
- package/cli/commands/screenshot-command.ts +8 -25
- package/cli/commands/storage.ts +4 -16
- package/cli/commands/three-mode.ts +6 -10
- package/cli/outbound-endpoints.ts +4 -5
- package/cli/parse-args.ts +45 -0
- package/cli/remote-metro.ts +1 -1
- package/cli/remote-simulators.ts +5 -1
- package/cli/send-to-box.ts +3 -1
- package/detox/index.ts +20 -1
- package/dist-lib/agent-daemon-client.cjs +2 -2
- 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 +240 -316
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +3 -3
- package/dist-lib/cloud-contract.cjs +14 -1
- package/dist-lib/cloud-contract.mjs +5 -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 -6
- package/dist-lib/config.mjs +5 -9
- package/dist-lib/detox/index.cjs +17 -5
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/esm-chunks/{acorn-FRQNHKFC.mjs → acorn-73XUBXBT.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-IRMC5BCX.mjs → chunk-7V2QJGVI.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-PMGJ7FLI.mjs → chunk-BHQEYJAF.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-BAYRN7ZL.mjs → chunk-DSPFMVBM.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-4HEUXQGM.mjs → chunk-GA73RJSG.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-ABMB3G7I.mjs → chunk-IGBAFWZ3.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-ZCMAKWHN.mjs → chunk-IKZDUGT6.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-VAQJQDWI.mjs → chunk-IP5ZV36U.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-O4EOBXAP.mjs → chunk-KGHQ4GK2.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-4BZ3Z3IQ.mjs → chunk-KY63O76W.mjs} +2 -2
- package/dist-lib/esm-chunks/{chunk-QYYJESMK.mjs → chunk-LJ74MO6Y.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-DJMWTW2B.mjs → chunk-LJX42YVT.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-XO5GX4PI.mjs → chunk-O4KAW2JJ.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-6A6JEVIF.mjs → chunk-OIFM356B.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-NPLEBOWJ.mjs → chunk-P63DPATT.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-VCAJFWZD.mjs → chunk-SCCOZKCP.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-QUBR7LHU.mjs → chunk-TAZL253K.mjs} +41 -15
- package/dist-lib/esm-chunks/{chunk-ORYS5CC4.mjs → chunk-UBXCWZL3.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-4ZRMJ5YO.mjs → chunk-ZQWWO33G.mjs} +14 -2
- package/dist-lib/esm-chunks/{metro-layout-parser-AUAVE5VL.mjs → metro-layout-parser-HNQRTPVE.mjs} +3 -3
- package/dist-lib/expo-swift-bundle.cjs +197 -336
- 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 +276 -381
- package/dist-lib/host/fetch-proxy-handler.cjs +35 -43
- 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 +4 -2
- package/dist-lib/index.cjs +2 -105
- package/dist-lib/kotlin-host.cjs +6 -4
- 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 +2 -2
- package/dist-lib/native-app-identity-project.mjs +12 -12
- 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 +64 -64
- package/dist-lib/public-origins-lib-static.json +1 -1
- package/dist-lib/public-origins-lib.json +107 -85
- 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 +310 -310
- package/dist-lib/swift-compile.cjs +37 -11
- package/dist-lib/swift-compile.mjs +8 -8
- 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-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 +14770 -0
- package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +2790 -0
- 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/prism.wasm +0 -0
- 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 +3710 -0
- 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-compat/src/stubs/native-seams/react-native-gesture-handler.d.ts +0 -3
- package/dist-types/packages/peach-engine/src/config.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/engine/scene-table.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/text-line-break.d.ts +3 -1
- package/dist-types/packages/peach-engine/src/engine/text-paint.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/text-runs.d.ts +6 -1
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +22 -14
- package/skills/peach-setup/references/native-config.md +3 -3
- package/src/app-config.ts +7 -15
- package/src/cloud-contract.ts +35 -0
- package/src/config.ts +2 -6
- package/src/estree-walk.ts +13 -0
- package/src/host/network-policy.ts +4 -1
- package/src/index.ts +0 -1
- package/src/one-native-app-config.ts +14 -15
- package/src/podspec-prism.ts +7 -1
- package/src/process-group.ts +4 -1
- package/src/process-table.ts +6 -1
- package/src/swift-compile.ts +38 -8
- package/src/swift-host.ts +10 -4
- package/cli/commands/box/bundle-plane.ts +0 -154
- package/dist-lib/jump-to-source-babel.cjs +0 -131
- package/dist-lib/jump-to-source-native.cjs +0 -235
- package/src/java-static-imports.ts +0 -68
- package/src/jump-to-source-babel.ts +0 -143
- package/src/jump-to-source-native.ts +0 -200
- package/src/kotlin-jvm-sources.ts +0 -35
package/README.md
CHANGED
|
@@ -34,9 +34,6 @@ What this workspace gives you:
|
|
|
34
34
|
- the standalone `peach` CLI source and binary build, which provides the primary
|
|
35
35
|
debugging and automation surface (inspect the UI tree, tap elements, capture
|
|
36
36
|
flows, screenshot, record, run agents)
|
|
37
|
-
- `peachsim/jump-to-source-babel` — an optional Babel plugin that annotates JSX
|
|
38
|
-
with source locations so inspect mode can open the selected element in your
|
|
39
|
-
editor
|
|
40
37
|
- `peachsim/detox` — a drop-in Detox driver + jest preset
|
|
41
38
|
- `peachsim/sdk` — the inspect/interact verbs as a programmatic API
|
|
42
39
|
- `peachsim/bridge-contract-input` — parsers turning untrusted JSON into
|
|
@@ -441,6 +438,8 @@ seconds denies the request. The policy gets one of these events:
|
|
|
441
438
|
with 1008. Compression is not negotiated while a policy is active.
|
|
442
439
|
- `tcp`: `host`, `port` and `tls` for `/__tcp-relay`, once per connection, with
|
|
443
440
|
writes held until it is allowed.
|
|
441
|
+
- `udp`: `host` and `port` before a native Node socket connects or sends a
|
|
442
|
+
datagram. Browser sockets have no UDP transport.
|
|
444
443
|
- `tunnel`: `host` and `port` of an opaque TLS tunnel (browser guard only).
|
|
445
444
|
- `dns`: `host` before a guest-requested hostname lookup.
|
|
446
445
|
|
|
@@ -465,51 +464,6 @@ governed. `scripts/debug/network-policy-proof.ts` runs all of this against
|
|
|
465
464
|
independent local listeners, including the real shell, and exits 0 only when every
|
|
466
465
|
check holds.
|
|
467
466
|
|
|
468
|
-
## Jump to source in inspect mode
|
|
469
|
-
|
|
470
|
-
Inspect mode can open a selected React Native element in your editor when the
|
|
471
|
-
bundle includes source metadata. Add the optional Babel plugin to your app's
|
|
472
|
-
Metro/Babel config:
|
|
473
|
-
|
|
474
|
-
```js
|
|
475
|
-
plugins: [
|
|
476
|
-
[
|
|
477
|
-
'peachsim/jump-to-source-babel',
|
|
478
|
-
{
|
|
479
|
-
include: [__dirname],
|
|
480
|
-
},
|
|
481
|
-
],
|
|
482
|
-
'react-native-worklets/plugin',
|
|
483
|
-
]
|
|
484
|
-
```
|
|
485
|
-
|
|
486
|
-
The plugin adds an `srcloc="/absolute/path/App.tsx:12:3"` prop to JSX elements
|
|
487
|
-
outside `node_modules`, `dist`, and `build`. Keep it before
|
|
488
|
-
`react-native-worklets/plugin` in a custom Babel stack that lists both plugins.
|
|
489
|
-
Apps using `babel-preset-expo` omit the explicit Worklets plugin because the
|
|
490
|
-
preset configures it automatically.
|
|
491
|
-
Runtime Fragment aliases are excluded before element creation. Component tag
|
|
492
|
-
expressions are evaluated once, and ordinary components retain their locations.
|
|
493
|
-
|
|
494
|
-
For One's Rolldown native bundler, use the native transform in `vite.config.ts`:
|
|
495
|
-
|
|
496
|
-
```ts
|
|
497
|
-
import { jumpToSourceNativePlugin } from 'peachsim/jump-to-source-native'
|
|
498
|
-
|
|
499
|
-
one({
|
|
500
|
-
native: {
|
|
501
|
-
bundler: 'vite',
|
|
502
|
-
bundlerOptions: {
|
|
503
|
-
plugins: [jumpToSourceNativePlugin({ include: [import.meta.dirname] })],
|
|
504
|
-
},
|
|
505
|
-
},
|
|
506
|
-
})
|
|
507
|
-
```
|
|
508
|
-
|
|
509
|
-
This transform uses the same source props and filters without running Babel.
|
|
510
|
-
For One's `nativeTransformModules`, export
|
|
511
|
-
`createJumpToSourceNativeTransform(options)` from a module and pass its module id.
|
|
512
|
-
|
|
513
467
|
## CLI
|
|
514
468
|
|
|
515
469
|
The CLI is the primary debugging surface for Peach — use it first for runtime
|
|
@@ -600,7 +554,8 @@ fingerprinting treat each as zero dependencies and reject malformed arguments.
|
|
|
600
554
|
|
|
601
555
|
Peach ships a drop-in Detox driver. Existing Detox test files
|
|
602
556
|
(`import { by, element, expect, device } from 'detox'`) run against Peach with
|
|
603
|
-
no code changes
|
|
557
|
+
no code changes. Install `playwright-core` beside `peachsim`, then add one line
|
|
558
|
+
to your jest config:
|
|
604
559
|
|
|
605
560
|
```js
|
|
606
561
|
// jest config
|
package/cli/app-catalog.ts
CHANGED
|
@@ -56,18 +56,19 @@ export function readAssetCatalog(
|
|
|
56
56
|
const colors = enumerateBundleColors(files, readContents)
|
|
57
57
|
const symbols = enumerateBundleSymbols(files, readContents, () => '.')
|
|
58
58
|
const images: AppCatalog['images'] = {}
|
|
59
|
-
for (const { name, file, scale, renderingMode } of enumerateBundleImages(
|
|
59
|
+
for (const { name, file, scale, renderingMode, fileNames } of enumerateBundleImages(
|
|
60
60
|
files,
|
|
61
61
|
readContents,
|
|
62
62
|
)) {
|
|
63
63
|
const uri = imageUri(file)
|
|
64
|
-
if (uri
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
if (uri === null) continue
|
|
65
|
+
const variant = { uri, scale, ...(renderingMode ? { renderingMode } : {}) }
|
|
66
|
+
for (const lookup of [name, ...(fileNames ?? [])]) {
|
|
67
|
+
const variants = (images[lookup] ??= [])
|
|
68
|
+
variants.push(variant)
|
|
69
|
+
}
|
|
70
70
|
}
|
|
71
|
+
for (const variants of Object.values(images)) variants.sort((a, b) => a.scale - b.scale)
|
|
71
72
|
if (
|
|
72
73
|
accentName === null &&
|
|
73
74
|
Object.keys(colors).length === 0 &&
|
package/cli/app-stubs.ts
CHANGED
|
@@ -13,7 +13,13 @@ import {
|
|
|
13
13
|
} from 'node:fs'
|
|
14
14
|
import { dirname, join, relative, resolve } from 'node:path'
|
|
15
15
|
import { resolveCompatVersionRange } from '@peach/globals/guest-modules/version-range'
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
parse,
|
|
18
|
+
type Expression,
|
|
19
|
+
type PrivateIdentifier,
|
|
20
|
+
type Program,
|
|
21
|
+
type Super,
|
|
22
|
+
} from 'acorn'
|
|
17
23
|
import { transform } from 'sucrase'
|
|
18
24
|
import {
|
|
19
25
|
isPackageStubs,
|
|
@@ -25,10 +31,10 @@ import {
|
|
|
25
31
|
type PackageStubs,
|
|
26
32
|
type PeachConfig,
|
|
27
33
|
} from '../src/config'
|
|
34
|
+
import { visitNodes } from '../src/estree-walk'
|
|
28
35
|
import { isRecord } from '../src/is-record'
|
|
29
36
|
import { nitroRegisteredNames } from '../src/nitro-source'
|
|
30
37
|
import { rnxPublicBrand } from '../src/public-brand'
|
|
31
|
-
import { visitParsedProgram } from '../src/visit-parsed-program'
|
|
32
38
|
import {
|
|
33
39
|
readProjectManifest,
|
|
34
40
|
scanRepository,
|
|
@@ -326,7 +332,7 @@ function isAndroidCheck(node: Expression): boolean {
|
|
|
326
332
|
return side(node.left, node.right) || side(node.right, node.left)
|
|
327
333
|
}
|
|
328
334
|
|
|
329
|
-
function nativeLookupName(node: Expression): string | null {
|
|
335
|
+
function nativeLookupName(node: Expression | Super): string | null {
|
|
330
336
|
if (node.type === 'Identifier') return node.name
|
|
331
337
|
if (
|
|
332
338
|
node.type === 'MemberExpression' &&
|
|
@@ -337,7 +343,7 @@ function nativeLookupName(node: Expression): string | null {
|
|
|
337
343
|
return null
|
|
338
344
|
}
|
|
339
345
|
|
|
340
|
-
// sucrase removes flow and typescript types while retaining source lines.
|
|
346
|
+
// sucrase removes flow and typescript types and jsx while retaining source lines. acorn
|
|
341
347
|
// then visits executable syntax, including expressions inside template literals,
|
|
342
348
|
// without interpreting comments, fixture strings or type queries as requests.
|
|
343
349
|
export function sourceNativeRequests(
|
|
@@ -356,8 +362,17 @@ export function sourceNativeRequests(
|
|
|
356
362
|
} catch {
|
|
357
363
|
return []
|
|
358
364
|
}
|
|
359
|
-
|
|
360
|
-
|
|
365
|
+
let program: Program
|
|
366
|
+
try {
|
|
367
|
+
program = parse(code, {
|
|
368
|
+
ecmaVersion: 'latest',
|
|
369
|
+
sourceType: 'module',
|
|
370
|
+
allowHashBang: true,
|
|
371
|
+
allowReturnOutsideFunction: true,
|
|
372
|
+
})
|
|
373
|
+
} catch {
|
|
374
|
+
return []
|
|
375
|
+
}
|
|
361
376
|
const found: (NativeRequest & { line: number })[] = []
|
|
362
377
|
// source ranges only an android device runs: the branch a Platform.OS === 'android' guards
|
|
363
378
|
const androidRanges: [number, number][] = []
|
|
@@ -379,70 +394,83 @@ export function sourceNativeRequests(
|
|
|
379
394
|
line: code.slice(0, at).split('\n').length,
|
|
380
395
|
})
|
|
381
396
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
guard(node.test, node.consequent)
|
|
388
|
-
},
|
|
389
|
-
LogicalExpression(node) {
|
|
390
|
-
if (node.operator === '&&') guard(node.left, node.right)
|
|
391
|
-
},
|
|
392
|
-
VariableDeclarator(node) {
|
|
393
|
-
if (
|
|
394
|
-
!includeLegacy ||
|
|
395
|
-
!node.init ||
|
|
396
|
-
nativeLookupName(node.init) !== 'NativeModules' ||
|
|
397
|
-
node.id.type !== 'ObjectPattern'
|
|
398
|
-
)
|
|
399
|
-
return
|
|
400
|
-
for (const property of node.id.properties) {
|
|
401
|
-
if (property.type !== 'Property') continue
|
|
402
|
-
const key = property.key
|
|
403
|
-
if (!property.computed && key.type === 'Identifier')
|
|
404
|
-
add('module', key.name, property.start, false)
|
|
405
|
-
else if (key.type === 'Literal' && typeof key.value === 'string')
|
|
406
|
-
add('module', key.value, property.start, false)
|
|
397
|
+
visitNodes(program, (node) => {
|
|
398
|
+
switch (node.type) {
|
|
399
|
+
case 'IfStatement': {
|
|
400
|
+
guard(node.test, node.consequent)
|
|
401
|
+
break
|
|
407
402
|
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
? `${first.value}_${second.value}`
|
|
432
|
-
: first.value
|
|
433
|
-
add('view', name, node.start, false)
|
|
403
|
+
case 'ConditionalExpression': {
|
|
404
|
+
guard(node.test, node.consequent)
|
|
405
|
+
break
|
|
406
|
+
}
|
|
407
|
+
case 'LogicalExpression': {
|
|
408
|
+
if (node.operator === '&&') guard(node.left, node.right)
|
|
409
|
+
break
|
|
410
|
+
}
|
|
411
|
+
case 'VariableDeclarator': {
|
|
412
|
+
if (
|
|
413
|
+
!includeLegacy ||
|
|
414
|
+
!node.init ||
|
|
415
|
+
nativeLookupName(node.init) !== 'NativeModules' ||
|
|
416
|
+
node.id.type !== 'ObjectPattern'
|
|
417
|
+
)
|
|
418
|
+
return
|
|
419
|
+
for (const property of node.id.properties) {
|
|
420
|
+
if (property.type !== 'Property') continue
|
|
421
|
+
const key = property.key
|
|
422
|
+
if (!property.computed && key.type === 'Identifier')
|
|
423
|
+
add('module', key.name, property.start, false)
|
|
424
|
+
else if (key.type === 'Literal' && typeof key.value === 'string')
|
|
425
|
+
add('module', key.value, property.start, false)
|
|
434
426
|
}
|
|
427
|
+
break
|
|
435
428
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
429
|
+
case 'CallExpression': {
|
|
430
|
+
const first = node.arguments[0]
|
|
431
|
+
if (first?.type !== 'Literal' || typeof first.value !== 'string') return
|
|
432
|
+
const callee = node.callee
|
|
433
|
+
const lookup = nativeLookupName(callee)
|
|
434
|
+
if (
|
|
435
|
+
callee.type === 'MemberExpression' &&
|
|
436
|
+
!callee.computed &&
|
|
437
|
+
nativeLookupName(callee.object) === 'TurboModuleRegistry' &&
|
|
438
|
+
(lookup === 'get' || lookup === 'getEnforcing')
|
|
439
|
+
) {
|
|
440
|
+
add('module', first.value, node.start, false)
|
|
441
|
+
} else if (lookup) {
|
|
442
|
+
if (['requireNativeModule', 'requireOptionalNativeModule'].includes(lookup))
|
|
443
|
+
add(
|
|
444
|
+
'module',
|
|
445
|
+
first.value,
|
|
446
|
+
node.start,
|
|
447
|
+
lookup === 'requireOptionalNativeModule',
|
|
448
|
+
)
|
|
449
|
+
else if (['requireNativeComponent', 'codegenNativeComponent'].includes(lookup))
|
|
450
|
+
add('view', first.value, node.start, false)
|
|
451
|
+
else if (['requireNativeView', 'requireNativeViewManager'].includes(lookup)) {
|
|
452
|
+
const second = node.arguments[1]
|
|
453
|
+
// expo registers a named view under the module_view key.
|
|
454
|
+
const name =
|
|
455
|
+
second?.type === 'Literal' && typeof second.value === 'string'
|
|
456
|
+
? `${first.value}_${second.value}`
|
|
457
|
+
: first.value
|
|
458
|
+
add('view', name, node.start, false)
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
break
|
|
462
|
+
}
|
|
463
|
+
case 'MemberExpression': {
|
|
464
|
+
if (
|
|
465
|
+
includeLegacy &&
|
|
466
|
+
!node.computed &&
|
|
467
|
+
nativeLookupName(node.object) === 'NativeModules' &&
|
|
468
|
+
node.property.type === 'Identifier'
|
|
469
|
+
)
|
|
470
|
+
add('module', node.property.name, node.start, false)
|
|
471
|
+
break
|
|
472
|
+
}
|
|
473
|
+
}
|
|
446
474
|
})
|
|
447
475
|
return found
|
|
448
476
|
}
|
|
@@ -548,11 +576,11 @@ function configModule(configPath: string | null, packages: string[]): string {
|
|
|
548
576
|
)
|
|
549
577
|
return ['module.exports = {', ...body, '}'].join('\n')
|
|
550
578
|
return [
|
|
551
|
-
`import {
|
|
579
|
+
`import type { PeachConfig } from '${rnxPublicBrand.packageName}/config'`,
|
|
552
580
|
'',
|
|
553
|
-
'export default
|
|
581
|
+
'export default {',
|
|
554
582
|
...body,
|
|
555
|
-
'}
|
|
583
|
+
'} satisfies PeachConfig',
|
|
556
584
|
].join('\n')
|
|
557
585
|
}
|
|
558
586
|
|
|
@@ -24,11 +24,8 @@ import { embedBundleAssets } from './cloud-client.ts'
|
|
|
24
24
|
import { buildRemoteProjectBundle } from './remote-project-bundle'
|
|
25
25
|
import type { RemotePlatform } from './cloud-session.ts'
|
|
26
26
|
|
|
27
|
-
export
|
|
28
|
-
|
|
29
|
-
contentType: string
|
|
30
|
-
bytes: Uint8Array
|
|
31
|
-
}
|
|
27
|
+
export type { CloudBoxNativeAsset } from '@peach/box/cloud-bundle-plane'
|
|
28
|
+
import type { CloudBoxNativeAsset } from '@peach/box/cloud-bundle-plane'
|
|
32
29
|
|
|
33
30
|
export interface CloudBoxArtifactProduction {
|
|
34
31
|
bytes: Buffer
|
package/cli/cloud-client.ts
CHANGED
|
@@ -80,6 +80,14 @@ export const MAX_RNX_CLOUD_BUNDLE_BYTES = RNX_CLOUD_MAX_ARTIFACT_BYTES
|
|
|
80
80
|
const REMOTE_COMMAND = 'peach remote'
|
|
81
81
|
const PREVIEW_COMMAND = 'peach preview'
|
|
82
82
|
|
|
83
|
+
export class NanoDevelopmentOnlyError extends Error {
|
|
84
|
+
readonly code = 'nano_development_only'
|
|
85
|
+
|
|
86
|
+
constructor() {
|
|
87
|
+
super('Nano requires a development build. [nano_development_only]')
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
83
91
|
export class UnsupportedRemoteHostError extends Error {
|
|
84
92
|
readonly code = 'unsupported_host' as const
|
|
85
93
|
readonly platform: string
|
|
@@ -1292,6 +1300,7 @@ export async function createRemoteSim(options: CreateRemoteSimOptions): Promise<
|
|
|
1292
1300
|
const headers: Record<string, string> = {
|
|
1293
1301
|
authorization: options.authorization,
|
|
1294
1302
|
'content-type': 'application/javascript',
|
|
1303
|
+
'x-rnx-box-size': 'nano',
|
|
1295
1304
|
'x-rnx-artifact-sha256': artifact.sha256,
|
|
1296
1305
|
'x-rnx-platform': options.platform,
|
|
1297
1306
|
'x-rnx-device': options.device,
|
|
@@ -1433,7 +1442,9 @@ export async function listRemoteSims(options: {
|
|
|
1433
1442
|
if (!isRecord(parsed) || !Array.isArray(parsed.sims)) {
|
|
1434
1443
|
throw new Error('remote simulator list returned invalid JSON')
|
|
1435
1444
|
}
|
|
1436
|
-
return parsed.sims
|
|
1445
|
+
return parsed.sims
|
|
1446
|
+
.filter((sim) => !isRecord(sim) || sim.size !== 'micro')
|
|
1447
|
+
.map(readSimView)
|
|
1437
1448
|
}
|
|
1438
1449
|
|
|
1439
1450
|
// one simulator reread by id to check whether it can be reattached.
|
package/cli/commands/box.ts
CHANGED
|
@@ -14,6 +14,7 @@ import fs from 'node:fs'
|
|
|
14
14
|
import path from 'node:path'
|
|
15
15
|
import { createInterface } from 'node:readline'
|
|
16
16
|
import { BoxClientError, createBoxClient } from '@peach/box/client'
|
|
17
|
+
import { BundleFilePlane } from '@peach/box/cloud-bundle-plane'
|
|
17
18
|
import {
|
|
18
19
|
cloudBoxConnectUrl,
|
|
19
20
|
createCloudBoxProvider,
|
|
@@ -31,7 +32,11 @@ import {
|
|
|
31
32
|
} from '@peach/box/template'
|
|
32
33
|
import { getCliRuntime } from '../../src/cli-runtime.ts'
|
|
33
34
|
import { isDeviceModel } from '../../src/device-catalog.ts'
|
|
34
|
-
import {
|
|
35
|
+
import {
|
|
36
|
+
isSootsimDevCheckout,
|
|
37
|
+
readDefaultBox,
|
|
38
|
+
writeDefaultBox,
|
|
39
|
+
} from '../../src/home-paths'
|
|
35
40
|
import { rnxPublicBrand } from '../../src/public-brand'
|
|
36
41
|
import { readNativeLinkedAppFontsWire } from '../app-fonts'
|
|
37
42
|
import { authHeaderOrExit, cloudAccountIdOrExit, type CliAuth } from '../auth'
|
|
@@ -44,7 +49,6 @@ import { openUrl } from '../open-url'
|
|
|
44
49
|
import { resolveCheckoutRepo } from '../run-registry'
|
|
45
50
|
import { findRepositoryPackageRoot } from '../setup-repository'
|
|
46
51
|
import { resolvePlacement } from '../ws-bridge'
|
|
47
|
-
import { BundleFilePlane } from './box/bundle-plane'
|
|
48
52
|
import { CheckoutFilePlane, CheckoutRequiresGitError } from './box/checkout-plane'
|
|
49
53
|
import { createPeachCommand } from './box/peach-command'
|
|
50
54
|
import { sharePlane } from './box/plane-share'
|
|
@@ -495,6 +499,7 @@ export async function openInBrowser(url: string): Promise<number> {
|
|
|
495
499
|
function cloudBoxClient(options: {
|
|
496
500
|
endpoint: string
|
|
497
501
|
fresh?: boolean
|
|
502
|
+
simulatorOrigin?: string
|
|
498
503
|
apiOrigin: string
|
|
499
504
|
apiKey: string
|
|
500
505
|
accountId: string | null
|
|
@@ -504,6 +509,7 @@ function cloudBoxClient(options: {
|
|
|
504
509
|
createCloudBoxProvider({
|
|
505
510
|
endpoint: options.endpoint,
|
|
506
511
|
fresh: options.fresh,
|
|
512
|
+
simulatorOrigin: options.simulatorOrigin,
|
|
507
513
|
authority: {
|
|
508
514
|
kind: 'account',
|
|
509
515
|
apiOrigin: options.apiOrigin,
|
|
@@ -525,6 +531,7 @@ function cloudBoxClient(options: {
|
|
|
525
531
|
*/
|
|
526
532
|
export async function createPrebuiltBundleBox(options: {
|
|
527
533
|
fresh?: boolean
|
|
534
|
+
simulatorOrigin?: string
|
|
528
535
|
artifact:
|
|
529
536
|
| { bytes: Uint8Array; nativeAssets: readonly CloudBoxNativeAsset[] }
|
|
530
537
|
| (() => Promise<{ bytes: Uint8Array; nativeAssets: readonly CloudBoxNativeAsset[] }>)
|
|
@@ -611,6 +618,38 @@ async function runCloudBoxCreate(
|
|
|
611
618
|
): Promise<number> {
|
|
612
619
|
const peach = rnxPublicBrand.commandName
|
|
613
620
|
const json = args.includes('--json')
|
|
621
|
+
if (args.includes('--nano')) {
|
|
622
|
+
const { createCloudBox, NanoDevelopmentOnlyError } = await import('../cloud-client')
|
|
623
|
+
if (!isSootsimDevCheckout()) {
|
|
624
|
+
console.error(` ${new NanoDevelopmentOnlyError().message}`)
|
|
625
|
+
return 1
|
|
626
|
+
}
|
|
627
|
+
const bundlePath = flag(args, 'bundle')
|
|
628
|
+
if (!bundlePath) {
|
|
629
|
+
console.error(` ${peach} box create --nano requires --bundle.`)
|
|
630
|
+
return 1
|
|
631
|
+
}
|
|
632
|
+
const { auth, header } = authHeaderOrExit('box create --nano')
|
|
633
|
+
try {
|
|
634
|
+
const { receipt, session } = await createCloudBox({
|
|
635
|
+
bundlePath,
|
|
636
|
+
device: flag(args, 'device') ?? 'iphone-16',
|
|
637
|
+
authorization: header,
|
|
638
|
+
accountId: cloudAccountIdOrExit(auth),
|
|
639
|
+
apiOrigin: flag(args, 'endpoint'),
|
|
640
|
+
boxName: flag(args, 'name'),
|
|
641
|
+
})
|
|
642
|
+
const { publishCloudSession } = await import('../cloud-session')
|
|
643
|
+
publishCloudSession(session)
|
|
644
|
+
console.log(json ? JSON.stringify(receipt) : ` box: ${receipt.boxId}`)
|
|
645
|
+
return 0
|
|
646
|
+
} catch (error) {
|
|
647
|
+
console.error(
|
|
648
|
+
` ${peach} box create: ${error instanceof Error ? error.message : String(error)}`,
|
|
649
|
+
)
|
|
650
|
+
return 1
|
|
651
|
+
}
|
|
652
|
+
}
|
|
614
653
|
const endpoint = cloudBoxEndpoint(args)
|
|
615
654
|
|
|
616
655
|
// --bundle IS the template choice: the box runs an app that is already
|
package/cli/commands/compat.ts
CHANGED
|
@@ -711,10 +711,12 @@ function printNativeGuidance(
|
|
|
711
711
|
if (open.size) {
|
|
712
712
|
console.log(`\n stub them in peach.config.ts, by package:\n`)
|
|
713
713
|
console.log(
|
|
714
|
-
muted(
|
|
714
|
+
muted(
|
|
715
|
+
` import type { PeachConfig } from '${rnxPublicBrand.packageName}/config'`,
|
|
716
|
+
),
|
|
715
717
|
)
|
|
716
718
|
console.log()
|
|
717
|
-
console.log(muted(` export default
|
|
719
|
+
console.log(muted(` export default {`))
|
|
718
720
|
console.log(muted(` packages: {`))
|
|
719
721
|
for (const [owner, requestsByName] of open) {
|
|
720
722
|
const requests = [...requestsByName.values()]
|
|
@@ -734,7 +736,7 @@ function printNativeGuidance(
|
|
|
734
736
|
console.log(muted(` },`))
|
|
735
737
|
}
|
|
736
738
|
console.log(muted(` },`))
|
|
737
|
-
console.log(muted(` }
|
|
739
|
+
console.log(muted(` } satisfies PeachConfig`))
|
|
738
740
|
console.log(
|
|
739
741
|
`\n ${muted("'noop' in place of a package's object makes its every native name inert.")}`,
|
|
740
742
|
)
|
|
@@ -31,6 +31,7 @@ import { dirname, resolve } from 'node:path'
|
|
|
31
31
|
import { getCliVersion } from '../../src/cli-version'
|
|
32
32
|
import { sleep } from '../../src/sleep'
|
|
33
33
|
import { Cdp } from '../cdp'
|
|
34
|
+
import { readStringFlag } from '../parse-args'
|
|
34
35
|
import { IS_STANDALONE } from '../standalone'
|
|
35
36
|
import { createBridgeFromParsed, evalInBridge, parseBridgeCliArgs } from '../ws-bridge'
|
|
36
37
|
|
|
@@ -342,14 +343,16 @@ async function runHostCpuProfile(
|
|
|
342
343
|
stripBooleanFlags: ['--host'],
|
|
343
344
|
stripValueFlags: ['--duration', '--sample-interval', '--output', '-o'],
|
|
344
345
|
})
|
|
345
|
-
const sampleIntervalMs = Number(
|
|
346
|
+
const sampleIntervalMs = Number(readStringFlag(args, '--sample-interval') ?? '0.25')
|
|
346
347
|
if (!Number.isFinite(sampleIntervalMs) || sampleIntervalMs <= 0) {
|
|
347
348
|
console.error(' --sample-interval must be a positive number (milliseconds)')
|
|
348
349
|
return 1
|
|
349
350
|
}
|
|
350
351
|
const outputPath = resolve(
|
|
351
352
|
process.cwd(),
|
|
352
|
-
|
|
353
|
+
readStringFlag(args, '--output') ??
|
|
354
|
+
readStringFlag(args, '-o') ??
|
|
355
|
+
'/tmp/peach.cpuprofile',
|
|
353
356
|
)
|
|
354
357
|
const bridge = createBridgeFromParsed(parsed)
|
|
355
358
|
try {
|
|
@@ -495,16 +498,16 @@ Writes a page profile, worker profiles, and a manifest alongside the output.
|
|
|
495
498
|
return 0
|
|
496
499
|
}
|
|
497
500
|
|
|
498
|
-
const duration = Number(
|
|
501
|
+
const duration = Number(readStringFlag(args, '--duration') ?? '5')
|
|
499
502
|
if (!Number.isFinite(duration) || duration <= 0) {
|
|
500
503
|
console.error(' --duration must be a positive number (seconds)')
|
|
501
504
|
return 1
|
|
502
505
|
}
|
|
503
506
|
if (args.includes('--host')) return runHostCpuProfile(args, opts, duration)
|
|
504
|
-
const sampleInterval = Number(
|
|
507
|
+
const sampleInterval = Number(readStringFlag(args, '--sample-interval') ?? '0.1') // ms
|
|
505
508
|
const interactionBarrierEnabled = args.includes('--interaction-barrier')
|
|
506
509
|
const interactionBarrierTimeoutSeconds = Number(
|
|
507
|
-
|
|
510
|
+
readStringFlag(args, '--interaction-barrier-timeout') ?? '90',
|
|
508
511
|
)
|
|
509
512
|
if (
|
|
510
513
|
!Number.isFinite(interactionBarrierTimeoutSeconds) ||
|
|
@@ -518,12 +521,12 @@ Writes a page profile, worker profiles, and a manifest alongside the output.
|
|
|
518
521
|
Math.ceil((interactionBarrierTimeoutSeconds + duration + 5) * 1000),
|
|
519
522
|
)
|
|
520
523
|
const cdpPort = Number(
|
|
521
|
-
|
|
524
|
+
readStringFlag(args, '--cdp-port') ?? process.env.PEACH_CDP_PORT ?? '9222',
|
|
522
525
|
)
|
|
523
526
|
// optional substring filter to pick the right page when several sims share
|
|
524
527
|
// the CDP browser (e.g. `--match 8089` or `--match /rn/8089`).
|
|
525
|
-
const match =
|
|
526
|
-
const outputArg =
|
|
528
|
+
const match = readStringFlag(args, '--match') ?? '/rn/'
|
|
529
|
+
const outputArg = readStringFlag(args, '--output') ?? readStringFlag(args, '-o')
|
|
527
530
|
const outputPath = resolve(process.cwd(), outputArg ?? '/tmp/peach.cpuprofile')
|
|
528
531
|
|
|
529
532
|
// locate the page target on the CDP endpoint. NOTE: Chrome's DevTools HTTP
|
|
@@ -1080,9 +1083,3 @@ function topSelfTime(profile: any, topN: number) {
|
|
|
1080
1083
|
.sort((a, b) => b.self - a.self)
|
|
1081
1084
|
.slice(0, topN)
|
|
1082
1085
|
}
|
|
1083
|
-
|
|
1084
|
-
function valueOf(args: string[], flag: string): string | undefined {
|
|
1085
|
-
const i = args.indexOf(flag)
|
|
1086
|
-
if (i < 0 || i === args.length - 1) return undefined
|
|
1087
|
-
return args[i + 1]
|
|
1088
|
-
}
|
package/cli/commands/diagnose.ts
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
// "diagnose" pass, add it as one more parallel call here.
|
|
23
23
|
|
|
24
24
|
import { getCliIdentityKey } from '../current-sim'
|
|
25
|
+
import { readRoundedPositiveFlag, readStringFlagWithEquals } from '../parse-args'
|
|
25
26
|
import { formatTable } from '../ui'
|
|
26
27
|
import {
|
|
27
28
|
callInBridge,
|
|
@@ -148,20 +149,6 @@ function parseCsv(value: string | undefined): Set<string> {
|
|
|
148
149
|
return out
|
|
149
150
|
}
|
|
150
151
|
|
|
151
|
-
function valueOf(args: string[], flag: string): string | undefined {
|
|
152
|
-
const idx = args.indexOf(flag)
|
|
153
|
-
if (idx >= 0 && idx + 1 < args.length) return args[idx + 1]
|
|
154
|
-
const prefix = `${flag}=`
|
|
155
|
-
return args.find((a) => a.startsWith(prefix))?.slice(prefix.length)
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function numberFlag(args: string[], flag: string, fallback: number): number {
|
|
159
|
-
const raw = valueOf(args, flag)
|
|
160
|
-
if (raw === undefined) return fallback
|
|
161
|
-
const n = Number(raw)
|
|
162
|
-
return Number.isFinite(n) && n > 0 ? Math.round(n) : fallback
|
|
163
|
-
}
|
|
164
|
-
|
|
165
152
|
interface TimelineSlice {
|
|
166
153
|
events: SootSimTimelineEvent[]
|
|
167
154
|
byKind: Record<string, number>
|
|
@@ -359,10 +346,10 @@ export async function runDiagnose(
|
|
|
359
346
|
return 1
|
|
360
347
|
}
|
|
361
348
|
|
|
362
|
-
const sinceMs = parseSinceMs(
|
|
363
|
-
const include = parseCsv(
|
|
364
|
-
const reactLimit =
|
|
365
|
-
const slowThresholdMs =
|
|
349
|
+
const sinceMs = parseSinceMs(readStringFlagWithEquals(args, '--since'), 90_000)
|
|
350
|
+
const include = parseCsv(readStringFlagWithEquals(args, '--include'))
|
|
351
|
+
const reactLimit = readRoundedPositiveFlag(args, '--limit', 8)
|
|
352
|
+
const slowThresholdMs = readRoundedPositiveFlag(args, '--slow-threshold', 1000)
|
|
366
353
|
const wantsJson = args.includes('--json')
|
|
367
354
|
|
|
368
355
|
const bridge = createBridgeFromParsed(parsed)
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { sleep } from '../../../src/sleep'
|
|
4
4
|
import { maybeHint } from '../../hints'
|
|
5
|
+
import { readStringFlag } from '../../parse-args'
|
|
5
6
|
import { inspectDescribe, type DescribeDumpOptions } from './core'
|
|
6
7
|
import { maybeWaitForStartedScreenTransitions, printJson, wantsJson } from './shared'
|
|
7
8
|
import type { WsBridge } from '../../ws-bridge'
|
|
@@ -12,11 +13,6 @@ export interface DescribeOptions {
|
|
|
12
13
|
positional: string[]
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
function flagValue(args: string[], name: string): string | null {
|
|
16
|
-
const i = args.indexOf(name)
|
|
17
|
-
return i >= 0 && i + 1 < args.length ? args[i + 1] : null
|
|
18
|
-
}
|
|
19
|
-
|
|
20
16
|
export async function runDescribeSubcommand(opts: DescribeOptions): Promise<void> {
|
|
21
17
|
const { bridge, args, positional } = opts
|
|
22
18
|
const verbose = args.includes('--verbose') || args.includes('-v')
|
|
@@ -26,9 +22,9 @@ export async function runDescribeSubcommand(opts: DescribeOptions): Promise<void
|
|
|
26
22
|
const watchInterval = 1000
|
|
27
23
|
const compact = args.includes('--compact')
|
|
28
24
|
const hideXy = args.includes('--no-xy')
|
|
29
|
-
const testIdLike =
|
|
30
|
-
const onlyGlob =
|
|
31
|
-
const subtreeRoot =
|
|
25
|
+
const testIdLike = readStringFlag(args, '--testid-like')
|
|
26
|
+
const onlyGlob = readStringFlag(args, '--only')
|
|
27
|
+
const subtreeRoot = readStringFlag(args, '--subtree')
|
|
32
28
|
|
|
33
29
|
// bare positional still works — routes to --only if it looks globby,
|
|
34
30
|
// otherwise preserves the old substring-match behavior as `filter`. guard
|