peachsim 0.1.1716 → 0.1.1738
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 +21 -3
- package/cli/app-bundle-resources.ts +2 -1
- package/cli/app-fonts.ts +4 -4
- package/cli/app-splash.ts +4 -4
- package/cli/app-stubs.ts +17 -0
- package/cli/command-registry.ts +1 -0
- package/cli/commands/control.ts +83 -822
- package/cli/commands/coverage-swift.ts +112 -4
- package/cli/commands/daemon.ts +8 -0
- package/cli/commands/detox.ts +3 -0
- package/cli/commands/doctor.ts +19 -2
- package/cli/commands/inspect/actions.ts +74 -14
- package/cli/commands/inspect/core.ts +5 -1
- package/cli/commands/inspect/settling.ts +5 -2
- package/cli/commands/inspect/wait-ready.ts +6 -0
- package/cli/commands/inspect.ts +48 -45
- package/cli/commands/kotlin.ts +12 -2
- package/cli/commands/package.ts +760 -0
- package/cli/commands/serve.ts +6 -0
- package/cli/commands/shell-url.ts +838 -0
- package/cli/commands/swift.ts +42 -102
- package/cli/commands/test.ts +20 -0
- package/cli/commands/upload.ts +1 -1
- package/cli/device-option.ts +1 -1
- package/cli/main.ts +13 -1
- package/cli/native-input.ts +199 -0
- package/cli/outbound-endpoints.ts +26 -1
- package/cli/packaged-app-launcher.ts +95 -0
- package/cli/scene-video.ts +36 -12
- package/detox/index.ts +196 -24
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +5 -2
- package/dist-lib/auth/shared-session.cjs +5 -2
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +39889 -31873
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +195 -63
- package/dist-lib/dev-bundle-resolution.cjs +14 -13
- package/dist-lib/expo-swift-bundle.cjs +18507 -11835
- package/dist-lib/expo-swift-metadata.cjs +4 -1
- package/dist-lib/expo-swift-metadata.mjs +3 -1
- package/dist-lib/home-paths.cjs +27 -3
- package/dist-lib/host/bridge-host.cjs +28373 -24090
- package/dist-lib/host/fetch-proxy-handler.cjs +235 -225
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +915 -399
- 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 +335 -47
- package/dist-lib/menu.cjs +13 -1
- package/dist-lib/menu.mjs +13 -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 +918 -411
- package/dist-lib/native-app-identity-project.cjs +703 -283
- package/dist-lib/native-app-identity-project.mjs +500 -87
- package/dist-lib/native-app-identity.cjs +13 -2
- package/dist-lib/native-app-identity.mjs +13 -2
- 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 +5 -2
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +28 -23
- package/dist-lib/public-origins-lib.json +418 -224
- package/dist-lib/react-native-host-modules.cjs +35 -2
- package/dist-lib/react-native-host-modules.mjs +35 -2
- package/dist-lib/reap-browser.cjs +12 -4
- package/dist-lib/scripts/dev-server-scanner.cjs +15 -8
- package/dist-lib/sdk.cjs +17 -7
- package/dist-lib/sdk.mjs +16 -7
- package/dist-lib/skills.cjs +44825 -29141
- package/dist-lib/swift-compile.cjs +616 -400
- package/dist-lib/swift-compile.mjs +528 -315
- 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 +105 -17
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +4660 -2252
- package/dist-lib/vite.cjs +248 -234
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-compat/src/stubs/native-seams/react-native-cookies.d.ts +17 -8
- package/dist-types/packages/peach-engine/src/engine/canvaskit-renderer.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/font-config.d.ts +7 -4
- package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +9 -6
- package/dist-types/packages/peach-engine/src/engine/liquid-glass.d.ts +0 -5
- package/dist-types/packages/peach-engine/src/engine/memory-counts.d.ts +11 -1
- package/dist-types/packages/peach-engine/src/engine/node.d.ts +5 -12
- package/dist-types/packages/peach-engine/src/engine/render-damage.d.ts +2 -2
- package/dist-types/packages/peach-engine/src/engine/text-first-baseline.d.ts +5 -0
- package/dist-types/packages/peach-engine/src/engine/text-paragraph.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/types.d.ts +3 -0
- package/dist-types/packages/peach-engine/src/native-preview-bundle.d.ts +2 -0
- package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +9 -0
- package/dist-types/packages/peach-engine/src/render-worker/host-service-protocol.d.ts +3 -0
- package/dist-types/packages/peach-engine/src/render-worker/native-ui-commandContract.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +7 -2
- package/dist-types/packages/peach-engine/src/render-worker/shell-protocol.d.ts +5 -0
- package/dist-types/packages/peach-engine/src/render-worker/tree-sync-port.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +36 -2
- package/dist-types/packages/peach-engine/src/shell-events.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/audioBridgeContract.d.ts +5 -0
- package/dist-types/packages/peach-globals/src/index.d.ts +1 -1
- package/dist-types/packages/peach-globals/src/keyboardBridgeContract.d.ts +11 -0
- package/dist-types/packages/peach-globals/src/shellBridgeContract.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/testBridgeContract.d.ts +9 -2
- package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
- package/kotlin/README.md +3 -0
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/scripts/dev-server-scanner.ts +12 -25
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccount.h +55 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountCredential.h +35 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountStore.h +94 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountType.h +53 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACError.h +37 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/Accounts.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/AccountsDefines.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Modules/module.modulemap +5 -0
- package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASFoundation.h +52 -0
- package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASWebAuthenticationSession.h +128 -0
- package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASWebAuthenticationSessionCallback.h +35 -0
- package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/AuthenticationServices.h +3 -0
- package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Modules/module.modulemap +5 -0
- package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFHTTPMessage.h +724 -0
- package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetwork.h +4 -0
- package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetworkDefs.h +27 -0
- package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Modules/module.modulemap +5 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFURL.h +1301 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h +3 -1
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationManager.h +21 -50
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLRegion.h +6 -6
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes +58 -3
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +711 -46
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h +12 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIInterface.h +23 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h +7 -9
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIOrientation.h +14 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIStringDrawing.h +12 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIView.h +14 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIViewAnimating.h +12 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIViewController.h +16 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIWindow.h +2 -0
- package/sdk/ios/usr/include/ConditionalMacros.h +619 -0
- package/sdk/ios/usr/include/module.modulemap +1 -0
- package/sdk/ios/usr/include/objc/objc-sync.h +59 -0
- package/sdk/ios/usr/include/os/signpost.h +414 -0
- package/sdk/ios/usr/include/os.modulemap +10 -0
- package/sdk/ios/usr/include/sys/cdefs.h +5 -0
- package/sdk/ios/usr/include/sys/ioccom.h +99 -0
- package/sdk/ios/usr/include/sys/syslog.h +236 -0
- package/sdk/ios/usr/include/syslog.h +24 -0
- package/sdk/ios/wasm/include/errno.h +4 -20
- package/sdk/ios/wasm/include/fcntl.h +4 -2
- package/sdk/ios/wasm/include/pthread.h +3 -0
- package/sdk/ios/wasm/include/setjmp.h +57 -0
- package/sdk/ios/wasm/include/stdio.h +24 -0
- package/sdk/ios/wasm/include/stdlib.h +32 -7
- package/sdk/ios/wasm/include/sys/file.h +7 -0
- package/sdk/ios/wasm/include/sys/ioctl.h +6 -0
- package/sdk/ios/wasm/include/sys/resource.h +2 -2
- package/sdk/ios/wasm/include/sys/syscall.h +9 -0
- package/sdk/ios/wasm/include/sys/time.h +10 -0
- package/sdk/ios/wasm/include/unistd.h +12 -3
- package/sdk/native-hashes.json +4 -3
- package/skills/contrast/SKILL.md +2 -1
- package/skills/peach-debug/SKILL.md +0 -1
- package/skills/peach-perf/SKILL.md +0 -1
- package/skills/peach-setup/SKILL.md +0 -1
- package/skills/peach-test/SKILL.md +7 -4
- package/skills/peach-visual/SKILL.md +0 -1
- package/src/admitted-mac-build.ts +3 -0
- package/src/android-app-identity.ts +18 -0
- package/src/android-autolinking.ts +1 -0
- package/src/android-bridge-packages.ts +279 -0
- package/src/android-root-module.ts +9 -9
- package/src/appPackageContract.ts +83 -0
- package/src/bridge-contract.ts +50 -0
- package/src/bundle-channel.mjs +41 -6
- package/src/cli-runtime.ts +9 -5
- package/src/dev-bundle-resolution.ts +7 -27
- package/src/dom-source-reference.ts +15 -0
- package/src/expo-discovery-cache.ts +134 -26
- package/src/expo-kotlin-host.ts +97 -26
- package/src/expo-manifest-body.ts +33 -0
- package/src/expo-native-workspace.ts +158 -38
- package/src/expo-swift-host.ts +350 -75
- package/src/expo-swift-ready.ts +5 -1
- package/src/expoKotlinContract.ts +12 -2
- package/src/expoSwiftContract.ts +10 -0
- package/src/generated/swift-c-predefines.json +1 -1
- package/src/home-paths.ts +41 -2
- package/src/host/app-package-handler.ts +47 -0
- package/src/host/bridge-host.ts +8 -0
- package/src/host/fetch-proxy-handler.ts +10 -0
- package/src/host/staged-host-files.ts +18 -0
- package/src/index.ts +3 -0
- package/src/kotlin-host.ts +225 -48
- package/src/kotlin-instance-source.ts +126 -0
- package/src/kotlinSdkContract.ts +2 -1
- package/src/menu.ts +14 -0
- package/src/native-app-identity-project.ts +7 -2
- package/src/native-app-identity.ts +11 -0
- package/src/native-firebase-config.ts +24 -1
- package/src/native-prebuilt.ts +154 -0
- package/src/nitro-adapter.lock.json +270 -270
- package/src/nitro-adapter.ts +56 -50
- package/src/nitro-bundle.ts +92 -74
- package/src/nitro-compile.ts +45 -14
- package/src/nitro-dependencies.ts +63 -46
- package/src/nitro-source.ts +64 -26
- package/src/nitroAdapterContract.ts +146 -98
- package/src/nitroContract.ts +71 -21
- package/src/react-native-bridge-modules.ts +70 -42
- package/src/react-native-host-modules.ts +34 -1
- package/src/reactNativeConfigurationContract.ts +14 -0
- package/src/reap-browser.ts +15 -3
- package/src/sdk.ts +5 -0
- package/src/settingsContract.ts +38 -1
- package/src/sim-client.ts +4 -1
- package/src/storageSnapshotContract.ts +32 -81
- package/src/swift-compile.ts +268 -89
- package/src/swift-coverage/indexdump.ts +22 -6
- package/src/swift-coverage/indexing.ts +4 -4
- package/src/swift-coverage/provenance.ts +1 -0
- package/src/swift-coverage/sdk.ts +104 -20
- package/src/swift-coverage/types.ts +34 -0
- package/src/swift-coverage/xcode-asset-symbols.ts +922 -0
- package/src/swift-coverage/xcode-assets.ts +89 -131
- package/src/swift-coverage/xcode.ts +10 -2
- package/src/swift-cxx-reachable.ts +2 -1
- package/src/swift-distribution.lock.json +20 -16
- package/src/swift-host.ts +98 -22
- package/src/swift-icu.ts +1 -1
- package/src/swift-link-roots.ts +118 -0
- package/src/swift-objc-compile.ts +144 -22
- package/src/swift-objc-import.ts +6 -0
- package/src/swift-objc-standin.ts +2 -14
- package/src/swift-package-manifest.ts +14 -6
- package/src/swift-packages.ts +75 -11
- package/src/swift-pdf-raster.ts +1 -0
- package/src/swift-root-lock.ts +17 -1
- package/src/swift-source-pods.ts +2 -10
- package/src/swift-standin-emit.ts +597 -57
- package/src/swift-standins.ts +599 -56
- package/src/swift-submit.ts +7 -1
- package/src/swift-toolchain.ts +140 -17
- package/src/turbo-bundle.ts +81 -0
- package/src/turbo-codegen-intake.ts +91 -0
- package/src/turbo-compile.ts +120 -0
- package/src/turbo-runtime.lock.json +69 -0
- package/src/turbo-source.ts +754 -0
- package/src/vite-plugin-one.ts +17 -12
- package/src/vite-plugin.ts +28 -15
- package/src/xcode-project.ts +223 -22
package/src/kotlin-host.ts
CHANGED
|
@@ -11,8 +11,16 @@ import { createRequire } from 'node:module'
|
|
|
11
11
|
import path from 'node:path'
|
|
12
12
|
import { promisify } from 'node:util'
|
|
13
13
|
import { parse } from 'acorn'
|
|
14
|
+
import {
|
|
15
|
+
readBridgeFiles,
|
|
16
|
+
type BridgeFile,
|
|
17
|
+
type BridgeMethod,
|
|
18
|
+
type BridgeModule,
|
|
19
|
+
type BridgeSelection,
|
|
20
|
+
} from './android-bridge-packages'
|
|
14
21
|
import { rnxHomeDir } from './home-paths'
|
|
15
22
|
import { isRecord } from './is-record'
|
|
23
|
+
import { kotlinInstanceSource } from './kotlin-instance-source'
|
|
16
24
|
import { installKotlinSdkArchive } from './kotlin-sdk'
|
|
17
25
|
import {
|
|
18
26
|
ensureToolchain,
|
|
@@ -151,7 +159,7 @@ function entrySource(ids: string[]): string {
|
|
|
151
159
|
].join('\n')
|
|
152
160
|
}
|
|
153
161
|
|
|
154
|
-
const BUILD_FORMAT =
|
|
162
|
+
const BUILD_FORMAT = 19
|
|
155
163
|
const builds = new Map<string, Promise<KotlinArtifact>>()
|
|
156
164
|
|
|
157
165
|
function buildsDir(): string {
|
|
@@ -221,6 +229,8 @@ interface ExpoField {
|
|
|
221
229
|
required: boolean
|
|
222
230
|
mutable: boolean
|
|
223
231
|
hidden: boolean
|
|
232
|
+
// a primary constructor parameter rather than a body property
|
|
233
|
+
parameter: boolean
|
|
224
234
|
initializer: [number, number] | null
|
|
225
235
|
}
|
|
226
236
|
|
|
@@ -248,7 +258,8 @@ function readExpoField(value: unknown): ExpoField {
|
|
|
248
258
|
typeof value.key !== 'string' ||
|
|
249
259
|
typeof value.required !== 'boolean' ||
|
|
250
260
|
typeof value.mutable !== 'boolean' ||
|
|
251
|
-
typeof value.hidden !== 'boolean'
|
|
261
|
+
typeof value.hidden !== 'boolean' ||
|
|
262
|
+
typeof value.parameter !== 'boolean'
|
|
252
263
|
)
|
|
253
264
|
throw new Error('expo-types printed an invalid field')
|
|
254
265
|
const range = value.initializer
|
|
@@ -266,6 +277,7 @@ function readExpoField(value: unknown): ExpoField {
|
|
|
266
277
|
required: value.required,
|
|
267
278
|
mutable: value.mutable,
|
|
268
279
|
hidden: value.hidden,
|
|
280
|
+
parameter: value.parameter,
|
|
269
281
|
initializer: range === null ? null : [range[0], range[1]],
|
|
270
282
|
}
|
|
271
283
|
}
|
|
@@ -352,56 +364,208 @@ function readExpoTypes(output: string): ExpoTypesFile[] {
|
|
|
352
364
|
})
|
|
353
365
|
}
|
|
354
366
|
|
|
355
|
-
const
|
|
367
|
+
const toolScans = new Map<string, Promise<string>>()
|
|
356
368
|
|
|
357
|
-
// the
|
|
358
|
-
//
|
|
359
|
-
async function
|
|
369
|
+
// runs one of the SDK's parser tools over source files and parses its output;
|
|
370
|
+
// the same files under the same SDK answer from the first scan
|
|
371
|
+
async function scanSources<T>(
|
|
372
|
+
tool: string,
|
|
373
|
+
parse: (output: string) => T,
|
|
360
374
|
toolchain: KotlinToolchain,
|
|
361
375
|
moduleRoot: string,
|
|
362
|
-
|
|
363
|
-
): Promise<
|
|
364
|
-
const candidates = sources.filter((file) =>
|
|
365
|
-
/\bRecord\b|\benum\s+class\b|\bExpoComposeView\b|\bExpoView\b|\bComposeProps\b|:\s*(?:[A-Za-z0-9_.]+\.)?(?:View|FrameLayout|LinearLayout|ViewGroup)\b/.test(
|
|
366
|
-
fs.readFileSync(file, 'utf8'),
|
|
367
|
-
),
|
|
368
|
-
)
|
|
369
|
-
if (candidates.length === 0) return Promise.resolve([])
|
|
376
|
+
files: string[],
|
|
377
|
+
): Promise<T> {
|
|
370
378
|
const digest = createHash('sha256').update(JSON.stringify(toolchain.compiler))
|
|
371
379
|
const sdk = await loadKotlinSdk(moduleRoot, toolchain)
|
|
372
|
-
|
|
373
|
-
digest.update(
|
|
374
|
-
for (const file of
|
|
375
|
-
digest.update(`${file}\0${fs.readFileSync(file, 'utf8')}\0`)
|
|
380
|
+
digest.update(fs.readFileSync(path.join(moduleRoot, 'sdk.tar.gz')))
|
|
381
|
+
digest.update(tool)
|
|
382
|
+
for (const file of files) digest.update(`${file}\0${fs.readFileSync(file, 'utf8')}\0`)
|
|
376
383
|
const key = digest.digest('hex')
|
|
377
|
-
let scan =
|
|
384
|
+
let scan = toolScans.get(key)
|
|
378
385
|
if (!scan) {
|
|
379
386
|
scan = (async () => {
|
|
380
|
-
const
|
|
381
|
-
ensureToolchain(toolchain),
|
|
382
|
-
Promise.resolve(sdk),
|
|
383
|
-
])
|
|
387
|
+
const { kotlinc } = await ensureToolchain(toolchain)
|
|
384
388
|
const { stdout } = await run(
|
|
385
389
|
path.join(path.dirname(kotlinc), 'kotlin'),
|
|
386
390
|
[
|
|
387
391
|
'-cp',
|
|
388
392
|
[
|
|
389
393
|
path.resolve(path.dirname(kotlinc), '../lib/kotlin-compiler.jar'),
|
|
390
|
-
path.join(
|
|
394
|
+
path.join(sdk.root, 'tools.jar'),
|
|
391
395
|
].join(path.delimiter),
|
|
392
|
-
|
|
393
|
-
...
|
|
396
|
+
tool,
|
|
397
|
+
...files,
|
|
394
398
|
],
|
|
395
399
|
{ maxBuffer: 16 * 1024 * 1024 },
|
|
396
400
|
)
|
|
397
|
-
return
|
|
401
|
+
return stdout
|
|
398
402
|
})().catch((error: unknown) => {
|
|
399
|
-
|
|
403
|
+
toolScans.delete(key)
|
|
400
404
|
throw error
|
|
401
405
|
})
|
|
402
|
-
|
|
406
|
+
toolScans.set(key, scan)
|
|
403
407
|
}
|
|
404
|
-
return scan
|
|
408
|
+
return parse(await scan)
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// the records, enums, compose views and compose props the module sources
|
|
412
|
+
// declare, read by Kotlin's own parser; sources that name none skip the JVM start
|
|
413
|
+
async function scanExpoTypes(
|
|
414
|
+
toolchain: KotlinToolchain,
|
|
415
|
+
moduleRoot: string,
|
|
416
|
+
sources: string[],
|
|
417
|
+
): Promise<ExpoTypesFile[]> {
|
|
418
|
+
const candidates = sources.filter((file) =>
|
|
419
|
+
/\bRecord\b|\benum\s+class\b|\bExpoComposeView\b|\bExpoView\b|\bComposeProps\b|:\s*(?:[A-Za-z0-9_.]+\.)?(?:View|FrameLayout|LinearLayout|ViewGroup)\b/.test(
|
|
420
|
+
fs.readFileSync(file, 'utf8'),
|
|
421
|
+
),
|
|
422
|
+
)
|
|
423
|
+
if (candidates.length === 0) return []
|
|
424
|
+
return scanSources(
|
|
425
|
+
'dev.peach.tools.expo.ExpoTypesKt',
|
|
426
|
+
readExpoTypes,
|
|
427
|
+
toolchain,
|
|
428
|
+
moduleRoot,
|
|
429
|
+
candidates,
|
|
430
|
+
)
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// every app source's declared and used names, ReactPackage classes and
|
|
434
|
+
// @ReactMethod signatures, read by Kotlin's own parser
|
|
435
|
+
export async function scanBridgeFiles(
|
|
436
|
+
moduleRoot: string,
|
|
437
|
+
sources: string[],
|
|
438
|
+
): Promise<BridgeFile[]> {
|
|
439
|
+
if (sources.length === 0) return []
|
|
440
|
+
return scanSources(
|
|
441
|
+
'dev.peach.tools.bridge.BridgeModulesKt',
|
|
442
|
+
readBridgeFiles,
|
|
443
|
+
readToolchain(moduleRoot),
|
|
444
|
+
moduleRoot,
|
|
445
|
+
sources,
|
|
446
|
+
)
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
// the parameter kinds PeachBridgeParam names, by the class JavaTurboModule
|
|
450
|
+
// converts them to
|
|
451
|
+
const BRIDGE_PARAMETERS: Record<string, string> = {
|
|
452
|
+
Boolean: 'boolean',
|
|
453
|
+
Int: 'int',
|
|
454
|
+
Double: 'double',
|
|
455
|
+
Float: 'float',
|
|
456
|
+
String: 'string',
|
|
457
|
+
Callback: 'callback',
|
|
458
|
+
Promise: 'promise',
|
|
459
|
+
ReadableMap: 'map',
|
|
460
|
+
ReadableArray: 'array',
|
|
461
|
+
Dynamic: 'dynamic',
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
const BRIDGE_CASTS: Record<string, string> = {
|
|
465
|
+
boolean: 'Boolean',
|
|
466
|
+
int: 'Int',
|
|
467
|
+
double: 'Double',
|
|
468
|
+
float: 'Float',
|
|
469
|
+
string: 'String',
|
|
470
|
+
callback: 'com.facebook.react.bridge.Callback',
|
|
471
|
+
promise: 'com.facebook.react.bridge.Promise',
|
|
472
|
+
map: 'com.facebook.react.bridge.ReadableNativeMap',
|
|
473
|
+
array: 'com.facebook.react.bridge.ReadableNativeArray',
|
|
474
|
+
dynamic: 'com.facebook.react.bridge.Dynamic',
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
const BRIDGE_RETURNS = new Set([
|
|
478
|
+
'Boolean',
|
|
479
|
+
'Int',
|
|
480
|
+
'Double',
|
|
481
|
+
'Float',
|
|
482
|
+
'String',
|
|
483
|
+
'WritableMap',
|
|
484
|
+
'WritableArray',
|
|
485
|
+
'Map',
|
|
486
|
+
'MutableMap',
|
|
487
|
+
])
|
|
488
|
+
|
|
489
|
+
const bridgeType = (text: string) => ({
|
|
490
|
+
nullable: text.trim().endsWith('?'),
|
|
491
|
+
base: text.replace(/\?$/, '').trim().split('<')[0].split('.').pop()!,
|
|
492
|
+
})
|
|
493
|
+
|
|
494
|
+
// the Java classes of Kotlin types the JNI signature parser names
|
|
495
|
+
const JAVA_CLASSES: Record<string, string> = {
|
|
496
|
+
Long: 'long',
|
|
497
|
+
Short: 'short',
|
|
498
|
+
Byte: 'byte',
|
|
499
|
+
Char: 'char',
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// TurboModuleInteropUtils's reading of one @ReactMethod
|
|
503
|
+
function bridgeUnsupported(method: BridgeMethod): string | null {
|
|
504
|
+
const promise = method.params.findIndex(
|
|
505
|
+
(param) => bridgeType(param.type).base === 'Promise',
|
|
506
|
+
)
|
|
507
|
+
if (promise !== -1 && promise !== method.params.length - 1)
|
|
508
|
+
return 'Unable to parse JavaScript arg count. Promises must be used as last parameter only.'
|
|
509
|
+
for (const param of method.params) {
|
|
510
|
+
const { base } = bridgeType(param.type)
|
|
511
|
+
if (!BRIDGE_PARAMETERS[base])
|
|
512
|
+
return `Unable to parse JNI signature. Detected unsupported parameter class: ${JAVA_CLASSES[base] ?? base}`
|
|
513
|
+
}
|
|
514
|
+
const returns = method.returns === null ? 'Unit' : bridgeType(method.returns).base
|
|
515
|
+
if (method.blocking === (returns === 'Unit'))
|
|
516
|
+
return 'TurboModule system assumes returnType == void iff the method is synchronous.'
|
|
517
|
+
if (returns !== 'Unit' && !BRIDGE_RETURNS.has(returns))
|
|
518
|
+
return `Unable to parse JNI signature. Detected unsupported return class: ${JAVA_CLASSES[returns] ?? returns}`
|
|
519
|
+
return null
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
function bridgeMethodSource(module: BridgeModule, method: BridgeMethod): string {
|
|
523
|
+
const unsupported = bridgeUnsupported(method)
|
|
524
|
+
const kinds = method.params.map((param) => {
|
|
525
|
+
const { base, nullable } = bridgeType(param.type)
|
|
526
|
+
return `dev.peach.expo.PeachBridgeParam(${JSON.stringify(BRIDGE_PARAMETERS[base] ?? 'unsupported')}, ${nullable})`
|
|
527
|
+
})
|
|
528
|
+
const returnsValue = method.blocking
|
|
529
|
+
const head = `dev.peach.expo.PeachBridgeMethod(${JSON.stringify(method.name)}, ${method.blocking}, ${returnsValue}, listOf(${kinds.join(', ')}), ${unsupported === null ? 'null' : JSON.stringify(unsupported)})`
|
|
530
|
+
if (unsupported !== null)
|
|
531
|
+
return `${head} { throw UnsupportedOperationException(${JSON.stringify(unsupported)}) }`
|
|
532
|
+
const args = method.params.map((param, index) => {
|
|
533
|
+
const { base, nullable } = bridgeType(param.type)
|
|
534
|
+
const kind = BRIDGE_PARAMETERS[base]
|
|
535
|
+
const cast = BRIDGE_CASTS[kind]
|
|
536
|
+
const read = `a[${index}] as ${cast}`
|
|
537
|
+
// Kotlin's null check on a non-null reference parameter
|
|
538
|
+
return nullable || !['string', 'map', 'array'].includes(kind)
|
|
539
|
+
? `${read}${nullable ? '?' : ''}`
|
|
540
|
+
: `(${read}?) ?: throw NullPointerException(${JSON.stringify(`Parameter specified as non-null is null: method ${module.className}.${method.name}, parameter ${param.name}`)})`
|
|
541
|
+
})
|
|
542
|
+
const call = `m.${method.name}(${args.join(', ')})`
|
|
543
|
+
return `${head} { a -> ${returnsValue ? call : `${call}; null`} }`
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
// react native finds a module's @ReactMethod functions by reflection;
|
|
547
|
+
// Kotlin/Wasm has none, so each module class gets its table here
|
|
548
|
+
function bridgeSource(bridge: BridgeSelection): string[] {
|
|
549
|
+
const modules = bridge.packages.flatMap((hosted) => hosted.modules)
|
|
550
|
+
return [
|
|
551
|
+
' dev.peach.expo.PeachBridgeRuntime.register(',
|
|
552
|
+
` ${JSON.stringify(bridge.applicationId)},`,
|
|
553
|
+
' listOf<() -> com.facebook.react.ReactPackage>(',
|
|
554
|
+
...bridge.packages.map((hosted) => ` { ${hosted.className}() },`),
|
|
555
|
+
' ),',
|
|
556
|
+
' listOf<(com.facebook.react.bridge.NativeModule) -> Map<String, dev.peach.expo.PeachBridgeMethod>?>(',
|
|
557
|
+
...modules.map(
|
|
558
|
+
(module) =>
|
|
559
|
+
` { m -> if (m is ${module.className}) mapOf(${module.methods
|
|
560
|
+
.map(
|
|
561
|
+
(method) =>
|
|
562
|
+
`${JSON.stringify(method.name)} to ${bridgeMethodSource(module, method)}`,
|
|
563
|
+
)
|
|
564
|
+
.join(', ')}) else null },`,
|
|
565
|
+
),
|
|
566
|
+
' ),',
|
|
567
|
+
' )',
|
|
568
|
+
]
|
|
405
569
|
}
|
|
406
570
|
|
|
407
571
|
// upstream converts records and enums by reflection; Kotlin/Wasm has none, so
|
|
@@ -420,9 +584,16 @@ function expoTypeSources(files: ExpoTypesFile[]): {
|
|
|
420
584
|
const calls: string[] = []
|
|
421
585
|
for (const record of file.records) {
|
|
422
586
|
const fields: string[] = []
|
|
587
|
+
// upstream allocates a record without a no-argument constructor without
|
|
588
|
+
// calling one; its undefaulted fields take the incoming values by name
|
|
589
|
+
const parameters: string[] = []
|
|
423
590
|
for (const field of record.fields) {
|
|
424
591
|
if (field.initializer)
|
|
425
592
|
edits.push({ range: field.initializer, owner: record.name, field })
|
|
593
|
+
else if (field.parameter)
|
|
594
|
+
parameters.push(
|
|
595
|
+
`${field.name} = dev.peach.expo.PeachExpoTypes.initial(${record.name}::class, ${literal(field.key)}, ${field.required}) { dev.peach.expo.PeachExpoTypes.unset() }`,
|
|
596
|
+
)
|
|
426
597
|
if (field.hidden) {
|
|
427
598
|
if (!field.initializer)
|
|
428
599
|
throw new Error(
|
|
@@ -443,7 +614,7 @@ function expoTypeSources(files: ExpoTypesFile[]): {
|
|
|
443
614
|
if (record.hidden) continue
|
|
444
615
|
calls.push(
|
|
445
616
|
[
|
|
446
|
-
` dev.peach.expo.PeachExpoTypes.record(${record.name}::class, ${literal(file.package ? `${file.package}.${record.name}` : record.name)}, { ${record.name}() }, listOf(`,
|
|
617
|
+
` dev.peach.expo.PeachExpoTypes.record(${record.name}::class, ${literal(file.package ? `${file.package}.${record.name}` : record.name)}, { ${record.name}(${parameters.join(', ')}) }, listOf(`,
|
|
447
618
|
...fields,
|
|
448
619
|
' ))',
|
|
449
620
|
].join('\n'),
|
|
@@ -546,6 +717,7 @@ export async function expoKotlinArtifact(
|
|
|
546
717
|
'',
|
|
547
718
|
'private val registered by lazy {',
|
|
548
719
|
...types.registrations.map((call) => ` ${call}`),
|
|
720
|
+
...(modules.bridge ? bridgeSource(modules.bridge) : []),
|
|
549
721
|
' PeachExpoRuntime.register(listOf(',
|
|
550
722
|
...modules.modules.map(
|
|
551
723
|
({ classifier, name }) =>
|
|
@@ -554,6 +726,9 @@ export async function expoKotlinArtifact(
|
|
|
554
726
|
' ))',
|
|
555
727
|
'}',
|
|
556
728
|
'',
|
|
729
|
+
'@JsExport fun peachSetAndroidBuildInfo(model: String, release: String) =',
|
|
730
|
+
' android.os.Build.setDevice(model, release)',
|
|
731
|
+
'',
|
|
557
732
|
'@JsExport fun peachExpoListen(notify: () -> Unit) {',
|
|
558
733
|
' registered',
|
|
559
734
|
' PeachExpoRuntime.listen(notify)',
|
|
@@ -1249,27 +1424,29 @@ async function compileKotlin(
|
|
|
1249
1424
|
}
|
|
1250
1425
|
const entry = path.join(work, 'js/app.mjs')
|
|
1251
1426
|
const entrySource = fs.readFileSync(entry, 'utf8')
|
|
1252
|
-
const
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
(statement) =>
|
|
1257
|
-
statement.type === 'ExportDefaultDeclaration' ||
|
|
1258
|
-
(statement.type === 'ExportNamedDeclaration' &&
|
|
1259
|
-
statement.specifiers.some(
|
|
1260
|
-
(specifier) =>
|
|
1261
|
-
specifier.exported.type === 'Identifier' &&
|
|
1262
|
-
specifier.exported.name === 'default',
|
|
1263
|
-
)),
|
|
1427
|
+
const importsPath = path.join(work, 'js/app.import-object.mjs')
|
|
1428
|
+
const importsFactory = kotlinInstanceSource(
|
|
1429
|
+
fs.readFileSync(importsPath, 'utf8'),
|
|
1430
|
+
'createKotlinImportObject',
|
|
1264
1431
|
)
|
|
1265
|
-
|
|
1432
|
+
const runtimeFactory = kotlinInstanceSource(
|
|
1433
|
+
entrySource,
|
|
1434
|
+
'createKotlinInstance',
|
|
1435
|
+
new Map([['./app.import-object.mjs', 'createKotlinImportObject']]),
|
|
1436
|
+
)
|
|
1437
|
+
fs.writeFileSync(importsPath, importsFactory.source)
|
|
1438
|
+
fs.writeFileSync(path.join(work, 'js/app-runtime.mjs'), runtimeFactory.source)
|
|
1266
1439
|
fs.writeFileSync(
|
|
1267
1440
|
entry,
|
|
1268
1441
|
[
|
|
1269
|
-
"
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1442
|
+
"import { createKotlinInstance } from './app-runtime.mjs';",
|
|
1443
|
+
'const instance = await createKotlinInstance();',
|
|
1444
|
+
...runtimeFactory.exports.map(({ exported }) =>
|
|
1445
|
+
exported === 'default'
|
|
1446
|
+
? 'export default instance.default;'
|
|
1447
|
+
: `export const ${exported} = instance[${JSON.stringify(exported)}];`,
|
|
1448
|
+
),
|
|
1449
|
+
'instance.peachInitializeModuleBindings();',
|
|
1273
1450
|
'',
|
|
1274
1451
|
].join('\n'),
|
|
1275
1452
|
)
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { parse, type Pattern, type Expression } from 'acorn'
|
|
2
|
+
|
|
3
|
+
function bindingNames(pattern: Pattern | Expression): string[] {
|
|
4
|
+
if (pattern.type === 'Identifier') return [pattern.name]
|
|
5
|
+
if (pattern.type === 'ObjectPattern')
|
|
6
|
+
return pattern.properties.flatMap((property) =>
|
|
7
|
+
bindingNames(property.type === 'RestElement' ? property.argument : property.value),
|
|
8
|
+
)
|
|
9
|
+
if (pattern.type === 'ArrayPattern')
|
|
10
|
+
return pattern.elements.flatMap((element) => (element ? bindingNames(element) : []))
|
|
11
|
+
if (pattern.type === 'AssignmentPattern') return bindingNames(pattern.left)
|
|
12
|
+
if (pattern.type === 'RestElement') return bindingNames(pattern.argument)
|
|
13
|
+
throw new Error(`unsupported Kotlin export binding ${pattern.type}`)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// compiler-generated module state belongs to an instance, including closures in
|
|
17
|
+
// the import object that retain its exports, memory and guest object identities.
|
|
18
|
+
export function kotlinInstanceSource(
|
|
19
|
+
source: string,
|
|
20
|
+
factory: string,
|
|
21
|
+
instanceImports: ReadonlyMap<string, string> = new Map(),
|
|
22
|
+
): { source: string; exports: { local: string; exported: string }[] } {
|
|
23
|
+
const program = parse(source, { ecmaVersion: 'latest', sourceType: 'module' })
|
|
24
|
+
const imports: string[] = []
|
|
25
|
+
const body: string[] = []
|
|
26
|
+
let dependencies = 0
|
|
27
|
+
const exports: { local: string; exported: string }[] = []
|
|
28
|
+
for (const statement of program.body) {
|
|
29
|
+
if (statement.type === 'ImportDeclaration') {
|
|
30
|
+
const importedFactory =
|
|
31
|
+
typeof statement.source.value === 'string'
|
|
32
|
+
? instanceImports.get(statement.source.value)
|
|
33
|
+
: undefined
|
|
34
|
+
if (!importedFactory) {
|
|
35
|
+
imports.push(source.slice(statement.start, statement.end))
|
|
36
|
+
continue
|
|
37
|
+
}
|
|
38
|
+
imports.push(
|
|
39
|
+
`import { ${importedFactory} } from ${JSON.stringify(statement.source.value)};`,
|
|
40
|
+
)
|
|
41
|
+
const names = statement.specifiers.map((specifier) => {
|
|
42
|
+
if (
|
|
43
|
+
specifier.type !== 'ImportSpecifier' ||
|
|
44
|
+
specifier.imported.type !== 'Identifier'
|
|
45
|
+
)
|
|
46
|
+
throw new Error('unsupported Kotlin instance import')
|
|
47
|
+
return `${specifier.imported.name}: ${specifier.local.name}`
|
|
48
|
+
})
|
|
49
|
+
const dependency = `__peachDependency${dependencies++}`
|
|
50
|
+
body.push(
|
|
51
|
+
`const ${dependency} = ${importedFactory}();`,
|
|
52
|
+
`__peachDisposers.push(${dependency}.peachDisposeInstance);`,
|
|
53
|
+
`const { ${names.join(', ')} } = ${dependency};`,
|
|
54
|
+
)
|
|
55
|
+
} else if (statement.type === 'ExportNamedDeclaration') {
|
|
56
|
+
const declaration = statement.declaration
|
|
57
|
+
if (declaration) {
|
|
58
|
+
body.push(source.slice(declaration.start, declaration.end))
|
|
59
|
+
const names =
|
|
60
|
+
declaration.type === 'VariableDeclaration'
|
|
61
|
+
? declaration.declarations.flatMap((item) => bindingNames(item.id))
|
|
62
|
+
: declaration.id
|
|
63
|
+
? [declaration.id.name]
|
|
64
|
+
: []
|
|
65
|
+
exports.push(...names.map((name) => ({ local: name, exported: name })))
|
|
66
|
+
} else {
|
|
67
|
+
if (statement.source) throw new Error('unsupported Kotlin instance re-export')
|
|
68
|
+
for (const specifier of statement.specifiers) {
|
|
69
|
+
if (
|
|
70
|
+
specifier.local.type !== 'Identifier' ||
|
|
71
|
+
specifier.exported.type !== 'Identifier'
|
|
72
|
+
)
|
|
73
|
+
throw new Error('unsupported Kotlin export name')
|
|
74
|
+
exports.push({ local: specifier.local.name, exported: specifier.exported.name })
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
} else if (statement.type === 'ExportDefaultDeclaration') {
|
|
78
|
+
body.push(
|
|
79
|
+
`const __defaultExport = (${source.slice(statement.declaration.start, statement.declaration.end)});`,
|
|
80
|
+
)
|
|
81
|
+
exports.push({ local: '__defaultExport', exported: 'default' })
|
|
82
|
+
} else if (statement.type === 'ExportAllDeclaration') {
|
|
83
|
+
throw new Error('unsupported Kotlin instance re-export')
|
|
84
|
+
} else {
|
|
85
|
+
body.push(source.slice(statement.start, statement.end))
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
source: `${imports.join('\n')}
|
|
90
|
+
export ${instanceImports.size ? 'async ' : ''}function ${factory}() {
|
|
91
|
+
const __peachTimers = new Set();
|
|
92
|
+
const __peachDisposers = [];
|
|
93
|
+
let __peachClosed = false;
|
|
94
|
+
function peachDisposeInstance() {
|
|
95
|
+
if (__peachClosed) return;
|
|
96
|
+
__peachClosed = true;
|
|
97
|
+
for (const timer of __peachTimers) globalThis.clearTimeout(timer);
|
|
98
|
+
__peachTimers.clear();
|
|
99
|
+
for (const dispose of __peachDisposers) dispose();
|
|
100
|
+
__peachDisposers.length = 0;
|
|
101
|
+
}
|
|
102
|
+
const setTimeout = (callback, delay, ...args) => {
|
|
103
|
+
if (__peachClosed) return 0;
|
|
104
|
+
const timer = globalThis.setTimeout(() => {
|
|
105
|
+
__peachTimers.delete(timer);
|
|
106
|
+
if (!__peachClosed) callback(...args);
|
|
107
|
+
}, delay);
|
|
108
|
+
__peachTimers.add(timer);
|
|
109
|
+
return timer;
|
|
110
|
+
};
|
|
111
|
+
const clearTimeout = timer => {
|
|
112
|
+
__peachTimers.delete(timer);
|
|
113
|
+
globalThis.clearTimeout(timer);
|
|
114
|
+
};
|
|
115
|
+
try {
|
|
116
|
+
${body.join('\n')}
|
|
117
|
+
return { peachDisposeInstance, ${exports.map((item) => `${JSON.stringify(item.exported)}: ${item.local}`).join(', ')} };
|
|
118
|
+
} catch (error) {
|
|
119
|
+
peachDisposeInstance();
|
|
120
|
+
throw error;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
`,
|
|
124
|
+
exports,
|
|
125
|
+
}
|
|
126
|
+
}
|
package/src/kotlinSdkContract.ts
CHANGED
|
@@ -27,13 +27,14 @@ export const KOTLIN_SDK_PROFILES = {
|
|
|
27
27
|
},
|
|
28
28
|
expo: {
|
|
29
29
|
compose: false,
|
|
30
|
-
directories: [...platform, 'ExpoSources', 'AndroidViewSources'],
|
|
30
|
+
directories: [...platform, 'ExpoSources', 'BridgeSources', 'AndroidViewSources'],
|
|
31
31
|
},
|
|
32
32
|
expoCompose: {
|
|
33
33
|
compose: true,
|
|
34
34
|
directories: [
|
|
35
35
|
...platform,
|
|
36
36
|
'ExpoSources',
|
|
37
|
+
'BridgeSources',
|
|
37
38
|
'AndroidViewSources',
|
|
38
39
|
'ComposeSources',
|
|
39
40
|
'ExpoComposeSources',
|
package/src/menu.ts
CHANGED
|
@@ -136,6 +136,8 @@ export interface SootSimMenuState {
|
|
|
136
136
|
developmentMode: boolean
|
|
137
137
|
showBezels: boolean
|
|
138
138
|
showTouches: boolean
|
|
139
|
+
systemCursor: boolean
|
|
140
|
+
hardwareKeyboard: boolean
|
|
139
141
|
slowAnimations: boolean
|
|
140
142
|
showMenuBar: boolean
|
|
141
143
|
showRail: boolean
|
|
@@ -385,6 +387,12 @@ function deviceMenu(
|
|
|
385
387
|
},
|
|
386
388
|
{ type: 'separator' },
|
|
387
389
|
{ label: 'Trigger Screenshot', action: 'screenshot' },
|
|
390
|
+
{
|
|
391
|
+
label: 'Connect Hardware Keyboard',
|
|
392
|
+
type: 'checkbox',
|
|
393
|
+
checked: state.hardwareKeyboard,
|
|
394
|
+
action: 'toggle-hardware-keyboard',
|
|
395
|
+
},
|
|
388
396
|
// pose controls for the current device: open/close, book and laptop on
|
|
389
397
|
// foldables, rotate left/right wherever a turn changes geometry, the way
|
|
390
398
|
// ios simulator holds them (rotate left is cmd+left, rotate right
|
|
@@ -571,6 +579,12 @@ function windowMenu(state: SootSimMenuState): SootSimMenuDef {
|
|
|
571
579
|
checked: state.showTouches,
|
|
572
580
|
action: 'toggle-touches',
|
|
573
581
|
},
|
|
582
|
+
{
|
|
583
|
+
label: 'Use System Cursor',
|
|
584
|
+
type: 'checkbox',
|
|
585
|
+
checked: state.systemCursor,
|
|
586
|
+
action: 'toggle-system-cursor',
|
|
587
|
+
},
|
|
574
588
|
{
|
|
575
589
|
label: 'Show Menu Bar',
|
|
576
590
|
type: 'checkbox',
|
|
@@ -224,10 +224,12 @@ export function readNativeAppIdentityFromProject(
|
|
|
224
224
|
parseInfoPlist: (source: string) => unknown = parsePlistSource,
|
|
225
225
|
iosTarget?: string,
|
|
226
226
|
androidMergedManifest?: string,
|
|
227
|
+
environment?: Record<string, string>,
|
|
227
228
|
): NativeAppIdentity | null {
|
|
228
229
|
const read = selectNativeAppIdentityReader(platform, {
|
|
229
230
|
android: () => readAndroidNativeAppIdentity(projectRoot, androidMergedManifest),
|
|
230
|
-
ios: () =>
|
|
231
|
+
ios: () =>
|
|
232
|
+
readIosNativeAppIdentity(projectRoot, parseInfoPlist, iosTarget, environment),
|
|
231
233
|
})
|
|
232
234
|
return read ? read() : null
|
|
233
235
|
}
|
|
@@ -329,8 +331,9 @@ function readIosNativeAppIdentity(
|
|
|
329
331
|
projectRoot: string,
|
|
330
332
|
parseInfoPlist: (source: string) => unknown,
|
|
331
333
|
iosTarget: string | undefined,
|
|
334
|
+
environment: Record<string, string> | undefined,
|
|
332
335
|
): NativeAppIdentity | null {
|
|
333
|
-
const app = readIosAppTarget(projectRoot, iosTarget)
|
|
336
|
+
const app = readIosAppTarget(projectRoot, iosTarget, environment)
|
|
334
337
|
if (!app) return null
|
|
335
338
|
const identity = readNativeAppIdentityFromXcodeTarget(app, parseInfoPlist)
|
|
336
339
|
const projectManifestPath = path.join(projectRoot, 'package.json')
|
|
@@ -395,6 +398,7 @@ function readIosNativeAppIdentity(
|
|
|
395
398
|
export function readIosAppTarget(
|
|
396
399
|
projectRoot: string,
|
|
397
400
|
iosTarget?: string,
|
|
401
|
+
environment?: Record<string, string>,
|
|
398
402
|
): XcodeAppTarget | null {
|
|
399
403
|
const iosRoot = path.join(projectRoot, 'ios')
|
|
400
404
|
if (!fs.existsSync(iosRoot)) return null
|
|
@@ -434,5 +438,6 @@ export function readIosAppTarget(
|
|
|
434
438
|
return readXcodeAppTarget(xcodeproj, iosTarget ?? appTargets[0], 'Release', {
|
|
435
439
|
requireSources: false,
|
|
436
440
|
prepareGeneratedSources: true,
|
|
441
|
+
environment,
|
|
437
442
|
})
|
|
438
443
|
}
|
|
@@ -65,6 +65,9 @@ export interface NativeAppIdentity {
|
|
|
65
65
|
// declarations from the selected app manifest merger output; install-time
|
|
66
66
|
// SDK filtering belongs to the evaluation's device, not the bundle builder.
|
|
67
67
|
androidManifestPermissions?: readonly AndroidManifestPermission[]
|
|
68
|
+
// the application meta-data one prebuild stamps for native.app.photoLibrary.addOnly.
|
|
69
|
+
// carried only from the completed merger output when the value is literal true.
|
|
70
|
+
androidPhotoLibraryAddOnly?: true
|
|
68
71
|
permissionUsageDescriptions?: Readonly<Record<string, unknown>>
|
|
69
72
|
// every top-level string the app's Info.plist declares, build settings
|
|
70
73
|
// resolved, for native code that reads its own plist keys.
|
|
@@ -151,6 +154,11 @@ export function isNativeAppIdentity(value: unknown): value is NativeAppIdentity
|
|
|
151
154
|
))
|
|
152
155
|
)
|
|
153
156
|
return false
|
|
157
|
+
if (
|
|
158
|
+
value.androidPhotoLibraryAddOnly !== undefined &&
|
|
159
|
+
value.androidPhotoLibraryAddOnly !== true
|
|
160
|
+
)
|
|
161
|
+
return false
|
|
154
162
|
if (value.googleSignIn !== undefined && !isRecord(value.googleSignIn)) return false
|
|
155
163
|
const descriptions = value.permissionUsageDescriptions
|
|
156
164
|
if (
|
|
@@ -315,6 +323,9 @@ export function readNativeAppIdentity(value: unknown): NativeAppIdentity | null
|
|
|
315
323
|
(permission) => ({ ...permission }),
|
|
316
324
|
),
|
|
317
325
|
}),
|
|
326
|
+
...(value.androidPhotoLibraryAddOnly === undefined
|
|
327
|
+
? {}
|
|
328
|
+
: { androidPhotoLibraryAddOnly: value.androidPhotoLibraryAddOnly }),
|
|
318
329
|
...(value.googleSignIn === undefined
|
|
319
330
|
? {}
|
|
320
331
|
: { googleSignIn: structuredClone(value.googleSignIn) }),
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// expose only FirebaseOptions, never a partner-specific extra configuration.
|
|
3
3
|
import { spawn, spawnSync } from 'node:child_process'
|
|
4
4
|
import fs from 'node:fs'
|
|
5
|
+
import { createRequire } from 'node:module'
|
|
5
6
|
import os from 'node:os'
|
|
6
7
|
import path from 'node:path'
|
|
7
8
|
import { isRecord } from './is-record'
|
|
@@ -10,15 +11,37 @@ import { listXcodeAppTargets, readXcodeAppTarget } from './xcode-project'
|
|
|
10
11
|
|
|
11
12
|
// expo's synchronous ESM/TypeScript loader requires Node's module evaluator.
|
|
12
13
|
// a private result file keeps authored console output off the configuration wire.
|
|
14
|
+
// Expo's CLI loads the project's .env files into process.env before it reads the
|
|
15
|
+
// config, so an app.config that reads EXPO_PUBLIC_* values evaluates the same here.
|
|
16
|
+
// @expo/config is a dependency of the project's expo package, and @expo/env
|
|
17
|
+
// ships with the CLI that package depends on; a strict pnpm layout exposes
|
|
18
|
+
// neither to the project itself.
|
|
13
19
|
const EXPO_CONFIG_SCRIPT = `const { createRequire } = require('node:module');
|
|
14
20
|
const { writeFileSync } = require('node:fs');
|
|
15
21
|
const { join } = require('node:path');
|
|
16
22
|
const root = process.argv[1];
|
|
17
|
-
const
|
|
23
|
+
const projectRequire = createRequire(join(root, 'package.json'));
|
|
24
|
+
const expoRequire = createRequire(projectRequire.resolve('expo/package.json'));
|
|
25
|
+
const { getConfig } = expoRequire('@expo/config');
|
|
26
|
+
let expoEnv = null;
|
|
27
|
+
try { expoEnv = createRequire(expoRequire.resolve('@expo/cli/package.json'))('@expo/env'); } catch {}
|
|
28
|
+
if (expoEnv) {
|
|
29
|
+
process.env.NODE_ENV ||= 'development';
|
|
30
|
+
expoEnv.load(root, { silent: true });
|
|
31
|
+
}
|
|
18
32
|
const result = JSON.stringify(getConfig(root, { skipSDKVersionRequirement: true }).exp);
|
|
19
33
|
if (Buffer.byteLength(result) > 1024 * 1024) throw new Error('Expo native configuration exceeds 1 MiB.');
|
|
20
34
|
writeFileSync(process.argv[2], result, { mode: 0o600 });`
|
|
21
35
|
|
|
36
|
+
// the project's own @expo/config, reached through its expo package as in
|
|
37
|
+
// EXPO_CONFIG_SCRIPT; throws when the project has no expo install.
|
|
38
|
+
export function resolveExpoConfigModule(appDir: string) {
|
|
39
|
+
const expo = createRequire(path.join(appDir, 'package.json')).resolve(
|
|
40
|
+
'expo/package.json',
|
|
41
|
+
)
|
|
42
|
+
return createRequire(expo).resolve('@expo/config')
|
|
43
|
+
}
|
|
44
|
+
|
|
22
45
|
function hasExpoConfig(projectRoot: string) {
|
|
23
46
|
const appJsonPath = path.join(projectRoot, 'app.json')
|
|
24
47
|
const appJson: unknown = fs.existsSync(appJsonPath)
|