peachsim 0.1.686 → 0.1.688
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/cloud-client.ts +3 -3
- package/cli/command-registry.ts +2 -0
- package/cli/commands/control.ts +1 -0
- package/cli/commands/debug.ts +10 -33
- package/cli/commands/do-chain.ts +56 -6
- package/cli/commands/inspect/core.ts +2 -0
- package/cli/commands/inspect/list.ts +2 -1
- package/cli/commands/inspect/settling.ts +17 -3
- package/cli/commands/inspect/shared.ts +2 -0
- package/cli/commands/inspect/wait-idle.ts +2 -2
- package/cli/commands/inspect/wait-ready.ts +3 -3
- package/cli/commands/inspect.ts +33 -7
- package/cli/commands/location.ts +164 -0
- package/cli/commands/platform.ts +1 -1
- package/cli/drivers/playwright-sim-host.ts +46 -25
- package/cli/main.ts +6 -0
- package/detox/index.ts +13 -8
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.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 +4 -3
- package/dist-lib/bridge-contract-input.cjs +12 -1
- package/dist-lib/bridge-contract-input.mjs +12 -1
- package/dist-lib/bridge-contract.cjs +4 -3
- package/dist-lib/bridge-contract.mjs +4 -3
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/cloud-contract.cjs +2 -1
- package/dist-lib/cloud-contract.mjs +2 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +2 -1
- package/dist-lib/cloud.mjs +2 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/detox/index.cjs +1197 -65
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +402 -113
- package/dist-lib/host/fetch-proxy-handler.cjs +50 -40
- package/dist-lib/host/fetch-proxy-overrides.cjs +50 -6
- package/dist-lib/host/fetch-proxy-overrides.mjs +48 -5
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +29 -11
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +89 -13
- 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 +5 -3
- package/dist-lib/native-app-identity.cjs +8 -3
- package/dist-lib/native-app-identity.mjs +8 -3
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.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/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +2 -2
- package/dist-lib/sdk.cjs +21 -6
- package/dist-lib/sdk.mjs +21 -6
- package/dist-lib/skills.cjs +441 -135
- package/dist-lib/swift-compile.cjs +317 -27
- package/dist-lib/swift-compile.mjs +315 -27
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +2 -2
- package/dist-lib/swift-submit.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +10 -10
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +320 -49
- package/dist-lib/vite.cjs +1 -1
- package/kotlin/AppSources/android/content/res/Configuration.kt +2 -0
- package/kotlin/AppSources/android/content/res/Resources.kt +6 -3
- package/kotlin/AppSources/android/util/DisplayMetrics.kt +12 -0
- package/kotlin/AppSources/androidx/compose/ui/res/PainterResources.kt +70 -0
- package/kotlin/AppSources/dev/peach/app/PeachApp.kt +12 -10
- package/kotlin/AppSources/dev/peach/app/PeachDrawable.kt +95 -0
- package/kotlin/fixtures/kotlin-app-variants/Bitmaps.kt +50 -0
- package/kotlin/fixtures/kotlin-app-variants/Drawables.kt +53 -0
- package/package.json +2 -2
- package/scripts/dev-server-scanner.ts +3 -1
- package/skills/contrast/SKILL.md +1 -0
- package/src/android-drawables.ts +315 -0
- package/src/android-theme.ts +9 -0
- package/src/bridge-constants.ts +3 -2
- package/src/bridge-contract-input.ts +11 -0
- package/src/bridge-contract.ts +45 -3
- package/src/cloud-contract.ts +1 -0
- package/src/host/fetch-proxy-handler.ts +13 -49
- package/src/host/fetch-proxy-overrides.ts +69 -12
- package/src/kotlin-app.ts +6 -0
- package/src/kotlin-host.ts +103 -15
- package/src/native-app-identity.ts +16 -3
- package/src/swift-compile.ts +426 -29
- package/src/swift-distribution-contract.ts +11 -4
- package/src/swift-distribution.lock.json +11 -9
- package/src/swift-distribution.ts +4 -4
- package/src/swift-icu.ts +8 -11
- package/src/swift-submit.ts +13 -1
- package/src/swift-toolchain.ts +17 -9
- package/src/vite-plugin.ts +86 -34
package/src/kotlin-app.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import fs from 'node:fs'
|
|
7
7
|
import path from 'node:path'
|
|
8
|
+
import { readAndroidDrawables, type AndroidDrawable } from './android-drawables'
|
|
8
9
|
import { readAndroidStrings, type AndroidStringResources } from './android-strings'
|
|
9
10
|
import {
|
|
10
11
|
readResourceValues,
|
|
@@ -52,6 +53,7 @@ export interface KotlinAppProject {
|
|
|
52
53
|
// the module's string resources, which its R class names
|
|
53
54
|
strings: AndroidStringResources
|
|
54
55
|
colors: KotlinAppColor[]
|
|
56
|
+
drawables: AndroidDrawable[]
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
// a color resource's ARGB in the day and the night configuration
|
|
@@ -543,5 +545,9 @@ export function readKotlinApp(
|
|
|
543
545
|
softInputAdjust,
|
|
544
546
|
strings: readAndroidStrings(moduleDir),
|
|
545
547
|
colors: readAppColors(moduleDir),
|
|
548
|
+
drawables: readAndroidDrawables(moduleDir, {
|
|
549
|
+
day: themeSources(moduleDir, false),
|
|
550
|
+
night: themeSources(moduleDir, true),
|
|
551
|
+
}),
|
|
546
552
|
}
|
|
547
553
|
}
|
package/src/kotlin-host.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
viewModelClasses,
|
|
18
18
|
type ViewModelClass,
|
|
19
19
|
} from './kotlin-view-models'
|
|
20
|
+
import type { DayNight, DrawableFile } from './android-drawables'
|
|
20
21
|
import type { KotlinAppProject, KotlinWindowTheme } from './kotlin-app'
|
|
21
22
|
import type { ServerResponse } from 'node:http'
|
|
22
23
|
|
|
@@ -436,25 +437,27 @@ export async function kotlinAppArtifact(
|
|
|
436
437
|
)
|
|
437
438
|
}
|
|
438
439
|
|
|
439
|
-
//
|
|
440
|
-
|
|
440
|
+
// a Kotlin string literal of any text
|
|
441
|
+
const escapes: Record<string, string> = {
|
|
442
|
+
'\\': '\\\\',
|
|
443
|
+
'"': '\\"',
|
|
444
|
+
$: '\\$',
|
|
445
|
+
'\n': '\\n',
|
|
446
|
+
'\r': '\\r',
|
|
447
|
+
'\t': '\\t',
|
|
448
|
+
}
|
|
449
|
+
const literal = (value: string) =>
|
|
450
|
+
`"${value.replace(
|
|
451
|
+
/[\\"$\u0000-\u001f]/g,
|
|
452
|
+
(char) => escapes[char] ?? `\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}`,
|
|
453
|
+
)}"`
|
|
454
|
+
|
|
455
|
+
// the module's R class in its namespace and the string, plurals, array,
|
|
456
|
+
// drawable and color tables Resources reads. an id is 0x7f, the type, then the entry in name
|
|
441
457
|
// order. a device's ids also count the module's other resource types and the
|
|
442
458
|
// resources its libraries merge in, which Peach does not build, so the
|
|
443
459
|
// numbers themselves differ
|
|
444
460
|
function appResourceSources(app: KotlinAppProject): Record<string, string> {
|
|
445
|
-
const escapes: Record<string, string> = {
|
|
446
|
-
'\\': '\\\\',
|
|
447
|
-
'"': '\\"',
|
|
448
|
-
$: '\\$',
|
|
449
|
-
'\n': '\\n',
|
|
450
|
-
'\r': '\\r',
|
|
451
|
-
'\t': '\\t',
|
|
452
|
-
}
|
|
453
|
-
const literal = (value: string) =>
|
|
454
|
-
`"${value.replace(
|
|
455
|
-
/[\\"$\u0000-\u001f]/g,
|
|
456
|
-
(char) => escapes[char] ?? `\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}`,
|
|
457
|
-
)}"`
|
|
458
461
|
// aapt2 writes a resource name's dots and dashes as underscores in R
|
|
459
462
|
const field = (name: string) => `\`${name.replace(/[.-]/g, '_')}\``
|
|
460
463
|
const id = (type: number, entry: number) =>
|
|
@@ -499,6 +502,17 @@ function appResourceSources(app: KotlinAppProject): Record<string, string> {
|
|
|
499
502
|
(items) => `listOf(${items.map(literal).join(', ')})`,
|
|
500
503
|
),
|
|
501
504
|
},
|
|
505
|
+
{
|
|
506
|
+
type: 'drawable',
|
|
507
|
+
table: 'peachAppDrawables',
|
|
508
|
+
value: 'List<PeachDrawable>',
|
|
509
|
+
entries: app.drawables.map((drawable) => ({
|
|
510
|
+
name: drawable.name,
|
|
511
|
+
init: `listOf(\n${drawable.files
|
|
512
|
+
.map((file) => drawableInit(file, path.relative(app.moduleDir, file.file)))
|
|
513
|
+
.join(',\n')}\n)`,
|
|
514
|
+
})),
|
|
515
|
+
},
|
|
502
516
|
// the day and the night ARGB
|
|
503
517
|
{
|
|
504
518
|
type: 'color',
|
|
@@ -534,6 +548,17 @@ function appResourceSources(app: KotlinAppProject): Record<string, string> {
|
|
|
534
548
|
'PeachAppResources.kt': [
|
|
535
549
|
'package dev.peach.app',
|
|
536
550
|
'',
|
|
551
|
+
...[
|
|
552
|
+
'androidx.compose.ui.graphics.BlendMode',
|
|
553
|
+
'androidx.compose.ui.graphics.Color',
|
|
554
|
+
'androidx.compose.ui.graphics.PathFillType',
|
|
555
|
+
'androidx.compose.ui.graphics.StrokeCap',
|
|
556
|
+
'androidx.compose.ui.graphics.StrokeJoin',
|
|
557
|
+
'androidx.compose.ui.graphics.vector.ImageVector',
|
|
558
|
+
'androidx.compose.ui.graphics.vector.addPathNodes',
|
|
559
|
+
'androidx.compose.ui.unit.Dp',
|
|
560
|
+
].map((name) => `import ${name}`),
|
|
561
|
+
'',
|
|
537
562
|
...kinds.flatMap((kind) => [
|
|
538
563
|
`internal val ${kind.table}: Map<Int, ${kind.value}> = mapOf(`,
|
|
539
564
|
...kind.entries.map((entry) => ` ${entry.id} to ${entry.init},`),
|
|
@@ -544,6 +569,69 @@ function appResourceSources(app: KotlinAppProject): Record<string, string> {
|
|
|
544
569
|
}
|
|
545
570
|
}
|
|
546
571
|
|
|
572
|
+
// a drawable file's table entry: a vector as the ImageVector.Builder calls
|
|
573
|
+
// XmlVectorParser makes, its colors chosen by the configuration's night
|
|
574
|
+
// mode; a bitmap as its encoded bytes
|
|
575
|
+
function drawableInit(drawable: DrawableFile, file: string): string {
|
|
576
|
+
const where = `${literal(file)}, ${drawable.density}, ${drawable.version}`
|
|
577
|
+
if (drawable.kind === 'xml') return `PeachDrawable.Xml(${where})`
|
|
578
|
+
if (drawable.kind === 'bitmap')
|
|
579
|
+
return `PeachDrawable.Bitmap(${where}, ${drawable.ninePatch}, ${literal(
|
|
580
|
+
fs.readFileSync(drawable.file).toString('base64'),
|
|
581
|
+
)})`
|
|
582
|
+
const vector = drawable.vector
|
|
583
|
+
const float = (value: number) => `${value}f`
|
|
584
|
+
const argb = (value: number) =>
|
|
585
|
+
`0x${value.toString(16).padStart(8, '0').toUpperCase()}.toInt()`
|
|
586
|
+
const pick = (value: DayNight) =>
|
|
587
|
+
value.day === value.night
|
|
588
|
+
? argb(value.day)
|
|
589
|
+
: `if (night) ${argb(value.night)} else ${argb(value.day)}`
|
|
590
|
+
const nodes = (pathData: string) =>
|
|
591
|
+
pathData ? `addPathNodes(${literal(pathData)})` : 'emptyList()'
|
|
592
|
+
const calls = vector.calls.map((call) => {
|
|
593
|
+
if (call.call === 'clear') return '.clearGroup()'
|
|
594
|
+
if (call.call === 'clip')
|
|
595
|
+
return `.addGroup(name = ${literal(call.name)}, clipPathData = ${nodes(call.pathData)})`
|
|
596
|
+
if (call.call === 'group')
|
|
597
|
+
return `.addGroup(${[
|
|
598
|
+
literal(call.name),
|
|
599
|
+
...[
|
|
600
|
+
call.rotate,
|
|
601
|
+
call.pivotX,
|
|
602
|
+
call.pivotY,
|
|
603
|
+
call.scaleX,
|
|
604
|
+
call.scaleY,
|
|
605
|
+
call.translateX,
|
|
606
|
+
call.translateY,
|
|
607
|
+
].map(float),
|
|
608
|
+
].join(', ')})`
|
|
609
|
+
return `.addPath(${[
|
|
610
|
+
nodes(call.pathData),
|
|
611
|
+
`PathFillType.${call.fillType}`,
|
|
612
|
+
literal(call.name),
|
|
613
|
+
`peachBrush(${pick(call.fill)})`,
|
|
614
|
+
float(call.fillAlpha),
|
|
615
|
+
`peachBrush(${pick(call.stroke)})`,
|
|
616
|
+
float(call.strokeAlpha),
|
|
617
|
+
float(call.strokeWidth),
|
|
618
|
+
`StrokeCap.${call.cap}`,
|
|
619
|
+
`StrokeJoin.${call.join}`,
|
|
620
|
+
...[call.miter, call.trimStart, call.trimEnd, call.trimOffset].map(float),
|
|
621
|
+
].join(', ')})`
|
|
622
|
+
})
|
|
623
|
+
return [
|
|
624
|
+
`PeachDrawable.Vector(${where}) { night -> ImageVector.Builder(`,
|
|
625
|
+
` defaultWidth = Dp(${float(vector.width)}), defaultHeight = Dp(${float(vector.height)}),`,
|
|
626
|
+
` viewportWidth = ${float(vector.viewportWidth)}, viewportHeight = ${float(vector.viewportHeight)},`,
|
|
627
|
+
` tintColor = ${vector.tint ? `Color(${pick(vector.tint)})` : 'Color.Unspecified'},`,
|
|
628
|
+
` tintBlendMode = BlendMode.${vector.tintMode}, autoMirror = ${vector.autoMirror},`,
|
|
629
|
+
` )`,
|
|
630
|
+
...calls.map((call) => ` ${call}`),
|
|
631
|
+
' .build() }',
|
|
632
|
+
].join('\n')
|
|
633
|
+
}
|
|
634
|
+
|
|
547
635
|
async function compileKotlin(
|
|
548
636
|
input: {
|
|
549
637
|
root: string
|
|
@@ -12,7 +12,12 @@
|
|
|
12
12
|
export type NativeAppIdentityPlatform = 'ios' | 'android'
|
|
13
13
|
|
|
14
14
|
export interface NativeAppIdentity {
|
|
15
|
+
// the user-facing name (CFBundleDisplayName, else CFBundleName).
|
|
15
16
|
applicationName: string | null
|
|
17
|
+
// CFBundleName, which CFNetwork stamps into the default User-Agent and iOS's
|
|
18
|
+
// own prompts use (the ASWebAuthenticationSession consent alert); distinct
|
|
19
|
+
// from the display name. absent in footers built before it was carried.
|
|
20
|
+
bundleName?: string
|
|
16
21
|
appVersion: string
|
|
17
22
|
buildVersion: string
|
|
18
23
|
bundleIdentifier: string
|
|
@@ -46,6 +51,8 @@ export function isNativeAppIdentity(value: unknown): value is NativeAppIdentity
|
|
|
46
51
|
if (platform !== 'ios' && platform !== 'android') return false
|
|
47
52
|
const applicationName = value.applicationName
|
|
48
53
|
if (applicationName !== null && nonEmptyString(applicationName) === null) return false
|
|
54
|
+
if (value.bundleName !== undefined && nonEmptyString(value.bundleName) === null)
|
|
55
|
+
return false
|
|
49
56
|
if (nonEmptyString(value.appVersion) === null) return false
|
|
50
57
|
if (nonEmptyString(value.bundleIdentifier) === null) return false
|
|
51
58
|
const buildVersion = nonEmptyString(value.buildVersion)
|
|
@@ -63,6 +70,7 @@ export function readNativeAppIdentity(value: unknown): NativeAppIdentity | null
|
|
|
63
70
|
}
|
|
64
71
|
return {
|
|
65
72
|
applicationName: value.applicationName,
|
|
73
|
+
...(value.bundleName === undefined ? {} : { bundleName: value.bundleName }),
|
|
66
74
|
appVersion: value.appVersion,
|
|
67
75
|
buildVersion: value.buildVersion,
|
|
68
76
|
bundleIdentifier: value.bundleIdentifier,
|
|
@@ -349,8 +357,9 @@ function nativeAppIdentityFromIos(
|
|
|
349
357
|
)
|
|
350
358
|
if (!appVersion || !buildVersion) return null
|
|
351
359
|
|
|
352
|
-
|
|
353
|
-
|
|
360
|
+
// CFNetwork names the bundle by CFBundleName, else the executable, which
|
|
361
|
+
// Xcode names after PRODUCT_NAME.
|
|
362
|
+
const bundleName =
|
|
354
363
|
identityFieldFrom(
|
|
355
364
|
settings,
|
|
356
365
|
plistString(plist, 'CFBundleName'),
|
|
@@ -358,7 +367,10 @@ function nativeAppIdentityFromIos(
|
|
|
358
367
|
) ??
|
|
359
368
|
resolvedIdentityField(resolveBuildSetting(settings.PRODUCT_NAME ?? '', settings)) ??
|
|
360
369
|
resolvedIdentityField(targetName)
|
|
361
|
-
if (!
|
|
370
|
+
if (!bundleName) return null
|
|
371
|
+
const applicationName =
|
|
372
|
+
identityFieldFrom(settings, plistString(plist, 'CFBundleDisplayName'), undefined) ??
|
|
373
|
+
bundleName
|
|
362
374
|
|
|
363
375
|
// only native privacy purpose strings travel here, not an invented Bundle
|
|
364
376
|
// dictionary. parse XML with the build-side parser so entities and empty
|
|
@@ -393,6 +405,7 @@ function nativeAppIdentityFromIos(
|
|
|
393
405
|
|
|
394
406
|
return {
|
|
395
407
|
applicationName,
|
|
408
|
+
bundleName,
|
|
396
409
|
appVersion,
|
|
397
410
|
buildVersion,
|
|
398
411
|
bundleIdentifier,
|