peachsim 0.1.939 → 0.1.1399
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 +28 -22
- package/cli/app-catalog.ts +29 -14
- package/cli/app-fonts.ts +5 -3
- package/cli/bridge-flow-runner.ts +40 -29
- package/cli/cloud-client.ts +57 -21
- package/cli/cloud-test-tunnel.ts +12 -18
- package/cli/commands/agent.ts +1 -1
- package/cli/commands/app-fonts.ts +3 -3
- package/cli/commands/assert.ts +8 -8
- package/cli/commands/auth.ts +8 -3
- package/cli/commands/box/bundle-plane.ts +13 -1
- package/cli/commands/box.ts +16 -5
- package/cli/commands/compat.ts +1 -1
- package/cli/commands/config.ts +2 -2
- package/cli/commands/control.ts +125 -71
- package/cli/commands/cpu-profile.ts +45 -1
- package/cli/commands/daemon.ts +131 -33
- package/cli/commands/debug.ts +24 -17
- package/cli/commands/desktop.ts +7 -1
- package/cli/commands/detect.ts +101 -0
- package/cli/commands/detox.ts +6 -6
- package/cli/commands/device.ts +12 -12
- package/cli/commands/electron.ts +32 -14
- package/cli/commands/flow.ts +49 -41
- package/cli/commands/guest-host.ts +39 -1
- package/cli/commands/inspect/core.ts +14 -8
- package/cli/commands/inspect/list.ts +1 -1
- package/cli/commands/inspect/settle.ts +5 -3
- package/cli/commands/inspect/settling.ts +229 -44
- package/cli/commands/inspect/wait-idle.ts +3 -2
- package/cli/commands/inspect.ts +105 -93
- package/cli/commands/install-cli.ts +36 -15
- package/cli/commands/install-desktop.ts +68 -195
- package/cli/commands/kotlin.ts +6 -5
- package/cli/commands/login.ts +5 -5
- package/cli/commands/maestro-compare.ts +554 -0
- package/cli/commands/maestro-generate.ts +6 -3
- package/cli/commands/maestro.ts +22 -0
- package/cli/commands/mode.ts +2 -2
- package/cli/commands/no-bridge-hint.ts +6 -2
- package/cli/commands/platform.ts +35 -6
- package/cli/commands/preview.ts +6 -0
- package/cli/commands/project-report.ts +10 -12
- package/cli/commands/record.ts +37 -37
- package/cli/commands/runtime.ts +9 -9
- package/cli/commands/screenshot-layers.ts +4 -4
- package/cli/commands/screenshot-mode.ts +2 -2
- package/cli/commands/screenshot.ts +8 -8
- package/cli/commands/screenshots-capture.ts +2 -2
- package/cli/commands/serve.ts +9 -12
- package/cli/commands/setup.ts +29 -14
- package/cli/commands/shell-boolean-mode.ts +2 -2
- package/cli/commands/show-touches-mode.ts +2 -2
- package/cli/commands/skills.ts +11 -11
- package/cli/commands/swift.ts +29 -11
- package/cli/commands/telemetry.ts +2 -2
- package/cli/commands/test.ts +5 -0
- package/cli/commands/three-mode.ts +3 -3
- package/cli/commands/timeline.ts +4 -4
- package/cli/commands/upgrade.ts +2 -2
- package/cli/commands/upload.ts +15 -15
- package/cli/commands/what-happened.ts +2 -2
- package/cli/current-sim.ts +6 -3
- package/cli/desktop-companion.ts +55 -149
- package/cli/dev-build-freshness.ts +2 -2
- package/cli/drivers/desktop.ts +17 -9
- package/cli/drivers/electron.ts +1 -2
- package/cli/drivers/playwright-sim-host.ts +11 -2
- package/cli/drivers/playwright.ts +35 -2
- package/cli/drivers/types.ts +8 -0
- package/cli/maestro-compare.ts +670 -0
- package/cli/outbound-endpoints.ts +46 -8
- package/cli/recording-access.ts +6 -6
- package/cli/run-registry.ts +1 -1
- package/cli/runtime-compat.ts +5 -1
- package/cli/send-to-box.ts +3 -3
- package/cli/shell-init.ts +2 -1
- package/cli/ws-bridge.ts +9 -5
- package/detox/element-types.ts +1 -0
- package/detox/gestures.ts +3 -3
- package/detox/index.ts +67 -38
- package/detox/navigation-lifecycle.ts +9 -6
- package/detox/proof-frame.cjs +6 -4
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +42 -17
- package/dist-lib/bridge-contract-input.mjs +41 -16
- package/dist-lib/bridge-contract.cjs +1 -4
- package/dist-lib/bridge-contract.mjs +1 -3
- package/dist-lib/bundle-channel.cjs +2918 -550
- package/dist-lib/capture-contract.cjs +65 -24
- package/dist-lib/capture-contract.mjs +63 -24
- package/dist-lib/cloud-contract.cjs +2 -2
- package/dist-lib/cloud-contract.mjs +2 -2
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +3 -3
- package/dist-lib/cloud.mjs +3 -3
- package/dist-lib/config.cjs +15 -5
- package/dist-lib/config.mjs +154 -0
- package/dist-lib/detox/index.cjs +495 -139
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +1168 -238
- package/dist-lib/expo-swift-metadata.cjs +34 -23
- package/dist-lib/expo-swift-metadata.mjs +32 -23
- package/dist-lib/home-paths.cjs +2 -2
- package/dist-lib/host/bridge-host.cjs +2938 -654
- package/dist-lib/host/fetch-proxy-handler.cjs +14 -1
- package/dist-lib/host/fetch-proxy-overrides.cjs +7 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +5 -1
- package/dist-lib/host/replacement-module-handler.cjs +2 -2
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +999 -353
- 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 +332 -19
- 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 +7 -7
- package/dist-lib/metro-production-bundle.mjs +5 -5
- package/dist-lib/metro.cjs +688 -250
- package/dist-lib/native-app-identity-project.cjs +2647 -0
- package/dist-lib/native-app-identity-project.mjs +1257 -0
- package/dist-lib/native-app-identity.cjs +325 -25
- package/dist-lib/native-app-identity.mjs +323 -25
- 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 +5 -1
- package/dist-lib/react-native-host-modules.mjs +5 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +57 -32
- package/dist-lib/sdk.cjs +231 -51
- package/dist-lib/sdk.mjs +231 -51
- package/dist-lib/skills.cjs +4107 -1374
- package/dist-lib/swift-compile.cjs +290 -30
- package/dist-lib/swift-compile.mjs +290 -30
- package/dist-lib/swift-package.cjs +143 -12
- package/dist-lib/swift-package.mjs +137 -11
- package/dist-lib/swift-submit.cjs +47 -5
- package/dist-lib/swift-submit.mjs +42 -5
- package/dist-lib/swift-toolchain.cjs +7 -2
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +1392 -458
- package/dist-lib/vite.cjs +13 -17
- package/dist-lib/worklet-executable.cjs +248 -33
- package/dist-lib/worklet-executable.mjs +248 -33
- package/install.sh +10 -1
- package/kotlin/{AppSources → AndroidViewSources}/android/content/res/Resources.kt +9 -9
- package/kotlin/AndroidViewSources/android/graphics/Canvas.kt +20 -0
- package/kotlin/AndroidViewSources/android/view/View.kt +211 -0
- package/kotlin/AndroidViewSources/android/widget/FrameLayout.kt +61 -0
- package/kotlin/AndroidViewSources/android/widget/LinearLayout.kt +49 -0
- package/kotlin/AppSources/android/view/Window.kt +36 -0
- package/kotlin/AppSources/android/view/WindowInsets.kt +9 -0
- package/kotlin/AppSources/android/view/WindowInsetsController.kt +5 -0
- package/kotlin/AppSources/android/window/OnBackInvokedDispatcher.kt +48 -0
- package/kotlin/AppSources/androidx/activity/OnBackPressedDispatcher.kt +20 -5
- package/kotlin/AppSources/androidx/compose/foundation/layout/WindowInsets.kt +15 -0
- package/kotlin/AppSources/androidx/compose/ui/platform/ComposeView.kt +2 -1
- package/kotlin/AppSources/dev/peach/app/PeachApp.kt +42 -50
- package/kotlin/ComposeSources/PeachComposeHost.kt +200 -84
- package/kotlin/ExpoComposeSources/PeachAndroidView.kt +87 -0
- package/kotlin/ExpoComposeSources/PeachExpoViewMount.kt +24 -0
- package/kotlin/ExpoComposeSources/dev/peach/expo/PeachExpoCompose.kt +28 -0
- package/kotlin/ExpoComposeSources/expo/modules/kotlin/views/ExpoComposeView.kt +70 -0
- package/kotlin/ExpoSources/dev/peach/expo/PeachExpoRuntime.kt +513 -0
- package/kotlin/ExpoSources/dev/peach/expo/PeachExpoTypes.kt +173 -0
- package/kotlin/ExpoSources/expo/modules/kotlin/AppContext.kt +20 -0
- package/kotlin/ExpoSources/expo/modules/kotlin/Promise.kt +19 -0
- package/kotlin/ExpoSources/expo/modules/kotlin/classcomponent/ClassComponentBuilder.kt +198 -0
- package/kotlin/ExpoSources/expo/modules/kotlin/exception/CodedException.kt +126 -0
- package/kotlin/ExpoSources/expo/modules/kotlin/functions/Functions.kt +132 -0
- package/kotlin/ExpoSources/expo/modules/kotlin/jni/JavaScriptTypedArray.kt +81 -0
- package/kotlin/ExpoSources/expo/modules/kotlin/modules/Module.kt +98 -0
- package/kotlin/ExpoSources/expo/modules/kotlin/objects/ObjectDefinitionBuilder.kt +236 -0
- package/kotlin/ExpoSources/expo/modules/kotlin/records/Record.kt +12 -0
- package/kotlin/ExpoSources/expo/modules/kotlin/runtime/Runtime.kt +9 -0
- package/kotlin/ExpoSources/expo/modules/kotlin/sharedobjects/SharedObject.kt +50 -0
- package/kotlin/ExpoSources/expo/modules/kotlin/sharedobjects/SharedObjectRegistry.kt +57 -0
- package/kotlin/ExpoSources/expo/modules/kotlin/sharedobjects/SharedRef.kt +19 -0
- package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/ConcreteTypedArrays.kt +158 -0
- package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/GenericTypedArray.kt +8 -0
- package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/TypedArray.kt +29 -0
- package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/TypedArrayIterator.kt +9 -0
- package/kotlin/ExpoSources/expo/modules/kotlin/types/AnyType.kt +155 -0
- package/kotlin/ExpoSources/expo/modules/kotlin/types/Either.kt +91 -0
- package/kotlin/ExpoSources/expo/modules/kotlin/types/Enumerable.kt +6 -0
- package/kotlin/ExpoSources/expo/modules/kotlin/viewevent/ViewEvent.kt +54 -0
- package/kotlin/ExpoSources/expo/modules/kotlin/views/ExpoView.kt +23 -0
- package/kotlin/ExpoSources/expo/modules/kotlin/views/ViewDefinitionBuilder.kt +71 -0
- package/kotlin/ExpoSources/expo/modules/kotlin/views/ViewProps.kt +35 -0
- package/kotlin/README.md +13 -3
- package/kotlin/Sources/android/os/Build.kt +17 -0
- package/kotlin/Sources/android/os/Handler.kt +35 -0
- package/kotlin/Sources/android/os/Looper.kt +17 -0
- package/kotlin/Sources/android/os/MessageQueue.kt +56 -0
- package/kotlin/Sources/android/os/SystemClock.kt +14 -0
- package/kotlin/Sources/android/util/Log.kt +64 -0
- package/kotlin/Sources/java/security/MessageDigest.kt +114 -0
- package/kotlin/Sources/kotlin/text/StringFormat.kt +9 -0
- package/kotlin/Sources/org/json/JSON.kt +44 -0
- package/kotlin/fixtures/counter/Counter.d.kt.ts +1 -0
- package/kotlin/fixtures/counter/Counter.kt +10 -3
- package/kotlin/fixtures/counter/CounterApp.native.tsx +1 -1
- package/kotlin/fixtures/counter/vite.config.ts +2 -2
- package/kotlin/fixtures/headless-counter/Headless.kt +7 -6
- package/kotlin/fixtures/import-animation/Animation.d.kt.ts +7 -0
- package/kotlin/fixtures/import-animation/Animation.kt +80 -0
- package/kotlin/fixtures/import-animation/ImportAnimation.native.tsx +13 -0
- package/kotlin/fixtures/import-animation/README.md +24 -0
- package/kotlin/fixtures/import-animation/app/_layout.tsx +4 -0
- package/kotlin/fixtures/import-animation/app/index+spa.tsx +1 -0
- package/kotlin/fixtures/import-animation/app/routes.d.ts +18 -0
- package/kotlin/fixtures/import-animation/package.json +23 -0
- package/kotlin/fixtures/import-animation/tsconfig.json +20 -0
- package/kotlin/fixtures/import-animation/vite.config.ts +20 -0
- package/kotlin/fixtures/import-editor/Editor.d.kt.ts +7 -0
- package/kotlin/fixtures/import-editor/Editor.kt +59 -0
- package/kotlin/fixtures/import-editor/ImportEditor.native.tsx +23 -0
- package/kotlin/fixtures/import-editor/README.md +27 -0
- package/kotlin/fixtures/import-editor/app/_layout.tsx +4 -0
- package/kotlin/fixtures/import-editor/app/index+spa.tsx +1 -0
- package/kotlin/fixtures/import-editor/package.json +23 -0
- package/kotlin/fixtures/import-editor/tsconfig.json +20 -0
- package/kotlin/fixtures/import-editor/vite.config.ts +20 -0
- package/kotlin/fixtures/import-effects/Effects.d.kt.ts +7 -0
- package/kotlin/fixtures/import-effects/Effects.kt +87 -0
- package/kotlin/fixtures/import-effects/ImportEffects.native.tsx +13 -0
- package/kotlin/fixtures/import-effects/README.md +19 -0
- package/kotlin/fixtures/import-effects/app/_layout.tsx +4 -0
- package/kotlin/fixtures/import-effects/app/index+spa.tsx +1 -0
- package/kotlin/fixtures/import-effects/package.json +23 -0
- package/kotlin/fixtures/import-effects/tsconfig.json +20 -0
- package/kotlin/fixtures/import-effects/vite.config.ts +20 -0
- package/kotlin/fixtures/import-layout/ImportLayout.native.tsx +13 -0
- package/kotlin/fixtures/import-layout/Layout.d.kt.ts +7 -0
- package/kotlin/fixtures/import-layout/Layout.kt +72 -0
- package/kotlin/fixtures/import-layout/README.md +24 -0
- package/kotlin/fixtures/import-layout/app/_layout.tsx +4 -0
- package/kotlin/fixtures/import-layout/app/index+spa.tsx +1 -0
- package/kotlin/fixtures/import-layout/package.json +23 -0
- package/kotlin/fixtures/import-layout/tsconfig.json +20 -0
- package/kotlin/fixtures/import-layout/vite.config.ts +20 -0
- package/kotlin/fixtures/import-navigation/ImportNavigation.native.tsx +18 -0
- package/kotlin/fixtures/import-navigation/Navigation.d.kt.ts +7 -0
- package/kotlin/fixtures/import-navigation/Navigation.kt +104 -0
- package/kotlin/fixtures/import-navigation/README.md +31 -0
- package/kotlin/fixtures/import-navigation/app/_layout.tsx +4 -0
- package/kotlin/fixtures/import-navigation/app/index+spa.tsx +1 -0
- package/kotlin/fixtures/import-navigation/package.json +23 -0
- package/kotlin/fixtures/import-navigation/tsconfig.json +20 -0
- package/kotlin/fixtures/import-navigation/vite.config.ts +20 -0
- package/kotlin/fixtures/import-overlays/ImportOverlays.native.tsx +29 -0
- package/kotlin/fixtures/import-overlays/Overlays.d.kt.ts +7 -0
- package/kotlin/fixtures/import-overlays/Overlays.kt +93 -0
- package/kotlin/fixtures/import-overlays/README.md +34 -0
- package/kotlin/fixtures/import-overlays/app/_layout.tsx +4 -0
- package/kotlin/fixtures/import-overlays/app/index+spa.tsx +1 -0
- package/kotlin/fixtures/import-overlays/package.json +23 -0
- package/kotlin/fixtures/import-overlays/tsconfig.json +20 -0
- package/kotlin/fixtures/import-overlays/vite.config.ts +20 -0
- package/kotlin/fixtures/import-scroll/ImportScroll.native.tsx +13 -0
- package/kotlin/fixtures/import-scroll/README.md +23 -0
- package/kotlin/fixtures/import-scroll/Scroll.d.kt.ts +7 -0
- package/kotlin/fixtures/import-scroll/Scroll.kt +91 -0
- package/kotlin/fixtures/import-scroll/app/_layout.tsx +4 -0
- package/kotlin/fixtures/import-scroll/app/index+spa.tsx +1 -0
- package/kotlin/fixtures/import-scroll/package.json +23 -0
- package/kotlin/fixtures/import-scroll/tsconfig.json +20 -0
- package/kotlin/fixtures/import-scroll/vite.config.ts +20 -0
- package/kotlin/fixtures/import-selection/ImportSelection.native.tsx +44 -0
- package/kotlin/fixtures/import-selection/README.md +32 -0
- package/kotlin/fixtures/import-selection/Selection.d.kt.ts +8 -0
- package/kotlin/fixtures/import-selection/Selection.kt +78 -0
- package/kotlin/fixtures/import-selection/app/_layout.tsx +4 -0
- package/kotlin/fixtures/import-selection/app/index+spa.tsx +1 -0
- package/kotlin/fixtures/import-selection/package.json +23 -0
- package/kotlin/fixtures/import-selection/tsconfig.json +20 -0
- package/kotlin/fixtures/import-selection/vite.config.ts +20 -0
- package/kotlin/fixtures/import-surfaces/ImportSurfaces.native.tsx +13 -0
- package/kotlin/fixtures/import-surfaces/README.md +22 -0
- package/kotlin/fixtures/import-surfaces/Surfaces.d.kt.ts +7 -0
- package/kotlin/fixtures/import-surfaces/Surfaces.kt +64 -0
- package/kotlin/fixtures/import-surfaces/app/_layout.tsx +4 -0
- package/kotlin/fixtures/import-surfaces/app/index+spa.tsx +1 -0
- package/kotlin/fixtures/import-surfaces/package.json +23 -0
- package/kotlin/fixtures/import-surfaces/tsconfig.json +20 -0
- package/kotlin/fixtures/import-surfaces/vite.config.ts +20 -0
- package/kotlin/fixtures/import-values/ImportValues.native.tsx +35 -0
- package/kotlin/fixtures/import-values/README.md +23 -0
- package/kotlin/fixtures/import-values/Values.d.kt.ts +11 -0
- package/kotlin/fixtures/import-values/Values.kt +66 -0
- package/kotlin/fixtures/import-values/app/_layout.tsx +4 -0
- package/kotlin/fixtures/import-values/app/index+spa.tsx +1 -0
- package/kotlin/fixtures/import-values/package.json +23 -0
- package/kotlin/fixtures/import-values/tsconfig.json +20 -0
- package/kotlin/fixtures/import-values/vite.config.ts +20 -0
- package/kotlin/fixtures/kotlin-app-variants/BarBehavior.kt +38 -0
- package/kotlin/fixtures/kotlin-app-variants/BarVisibility.kt +36 -0
- package/kotlin/fixtures/kotlin-app-variants/Ime.kt +3 -1
- package/kotlin/fixtures/kotlin-app-variants/TransientInsets.kt +50 -0
- package/kotlin/fork/NOTICE +6 -1
- package/kotlin/fork/README.md +15 -7
- package/kotlin/fork/build.sh +2 -0
- package/kotlin/fork/compose-worker-globals.patch +186 -4
- package/kotlin/fork/fork.json +2 -2
- package/kotlin/fork/skiko-worker-clock.patch +12 -0
- package/kotlin/toolchain.json +12 -12
- package/kotlin/tools/expo-types.main.kts +115 -0
- package/package.json +17 -23
- package/scripts/dev-server-scanner.ts +92 -66
- package/skills/contrast/SKILL.md +2 -2
- package/skills/peach-debug/SKILL.md +1 -1
- package/skills/peach-perf/SKILL.md +1 -1
- package/skills/peach-setup/SKILL.md +2 -1
- package/skills/peach-test/SKILL.md +8 -0
- package/src/assetCatalogContract.ts +43 -1
- package/src/bridge-contract-input.ts +46 -19
- package/src/bridge-contract.ts +0 -1
- package/src/bundle-channel.mjs +197 -84
- package/src/bundleGlobalFooter.ts +38 -0
- package/src/capture-contract.ts +107 -33
- package/src/cloud-contract.ts +5 -1
- package/src/cloud.ts +5 -2
- package/src/config.ts +22 -3
- package/src/configured-bundle-producer.ts +1 -1
- package/src/desktop-host-delivery.ts +95 -1
- package/src/expo-kotlin-bundle.ts +29 -0
- package/src/expo-kotlin-host.ts +201 -0
- package/src/expo-swift-host.ts +96 -76
- package/src/expoKotlinContract.ts +70 -0
- package/src/expoSwiftContract.ts +4 -25
- package/src/home-paths.ts +7 -4
- package/src/host/bridge-host.ts +23 -3
- package/src/host/fetch-proxy-handler.ts +13 -0
- package/src/host/fetch-proxy-overrides.ts +11 -0
- package/src/host/replacement-module-handler.ts +5 -2
- package/src/index.ts +3 -1
- package/src/kotlin-host.ts +463 -19
- package/src/metro-plugin.ts +56 -28
- package/src/metro-production-bundle.ts +2 -2
- package/src/native-app-identity-project.ts +190 -0
- package/src/native-app-identity.ts +398 -34
- package/src/native-firebase-config.ts +69 -15
- package/src/native-seam-manifest.ts +6 -0
- package/src/one-widget-discovery.ts +2 -1
- package/src/openstep-plist.ts +107 -0
- package/src/react-native-host-modules.ts +4 -0
- package/src/runtime-assets.ts +2 -2
- package/src/sim-client.ts +2 -2
- package/src/swift-binary-modules.ts +3 -1
- package/src/swift-compile.ts +286 -38
- package/src/swift-distribution-contract.ts +4 -0
- package/src/swift-distribution.lock.json +123 -12
- package/src/swift-distribution.ts +7 -3
- package/src/swift-host.ts +298 -83
- package/src/swift-package-manifest.ts +29 -2
- package/src/swift-package.ts +180 -10
- package/src/swift-packages.ts +4 -0
- package/src/swift-standin-emit.ts +4 -1
- package/src/swift-standins.ts +274 -15
- package/src/swift-submit.ts +62 -7
- package/src/swift-toolchain.ts +6 -1
- package/src/swiftContract.ts +126 -3
- package/src/vite-plugin-one.ts +13 -16
- package/src/vite-plugin-swift.ts +4 -5
- package/src/vite-plugin.ts +360 -144
- package/src/vite.d.ts +1 -1
- package/src/worker-system-chunks.ts +221 -0
- package/src/worklet-executable.ts +348 -38
- package/src/worklets-babel.ts +1 -1
- package/src/xcode-project.ts +243 -127
- package/dist-lib/agent-identity.cjs +0 -39
- package/dist-lib/agent-sessions.cjs +0 -760
- package/dist-lib/cli-constants.cjs +0 -32
- package/dist-lib/render-mode.cjs +0 -44
- package/kotlin/AppSources/android/view/View.kt +0 -74
- package/kotlin/AppSources/android/widget/FrameLayout.kt +0 -6
- package/src/render-mode.ts +0 -15
- /package/kotlin/{AppSources → AndroidViewSources}/android/content/Context.kt +0 -0
- /package/kotlin/{AppSources → AndroidViewSources}/android/content/res/Configuration.kt +0 -0
- /package/kotlin/{AppSources → AndroidViewSources}/android/graphics/Color.kt +0 -0
- /package/kotlin/{AppSources → AndroidViewSources}/android/util/DisplayMetrics.kt +0 -0
- /package/kotlin/{AppSources → AndroidViewSources}/dev/peach/app/JavaFormat.kt +0 -0
- /package/kotlin/{AppSources → Sources}/java/lang/Runnable.kt +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
@file:Suppress("FunctionName", "UNCHECKED_CAST")
|
|
2
|
+
|
|
3
|
+
package expo.modules.kotlin.views
|
|
4
|
+
|
|
5
|
+
import android.content.Context
|
|
6
|
+
import expo.modules.kotlin.AppContext
|
|
7
|
+
import expo.modules.kotlin.functions.AsyncFunctionComponent
|
|
8
|
+
import expo.modules.kotlin.objects.ObjectDefinitionBuilder
|
|
9
|
+
import expo.modules.kotlin.types.toAnyType
|
|
10
|
+
import kotlin.reflect.KClass
|
|
11
|
+
import kotlin.reflect.KType
|
|
12
|
+
|
|
13
|
+
class ViewManagerDefinition(
|
|
14
|
+
val name: String,
|
|
15
|
+
internal val viewClass: KClass<*>,
|
|
16
|
+
internal val createView: (Context, AppContext) -> ExpoView,
|
|
17
|
+
internal val props: Map<String, AnyViewProp>,
|
|
18
|
+
internal val callbacks: List<String>,
|
|
19
|
+
internal val asyncFunctions: Map<String, AsyncFunctionComponent>,
|
|
20
|
+
internal val onViewDestroys: ((ExpoView) -> Unit)?,
|
|
21
|
+
internal val onViewDidUpdateProps: ((ExpoView) -> Unit)?,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
// the view's async functions take the view as their first argument when they
|
|
25
|
+
// name its type, as upstream's do; their arities come from ObjectDefinitionBuilder
|
|
26
|
+
class ViewDefinitionBuilder<T : ExpoView>(
|
|
27
|
+
@PublishedApi internal val viewClass: KClass<T>,
|
|
28
|
+
@PublishedApi internal val viewType: KType,
|
|
29
|
+
) : ObjectDefinitionBuilder() {
|
|
30
|
+
@PublishedApi internal var name: String = requireNotNull(viewClass.simpleName)
|
|
31
|
+
@PublishedApi internal val props = mutableMapOf<String, AnyViewProp>()
|
|
32
|
+
@PublishedApi internal var onViewDestroys: ((ExpoView) -> Unit)? = null
|
|
33
|
+
@PublishedApi internal var onViewDidUpdateProps: ((ExpoView) -> Unit)? = null
|
|
34
|
+
|
|
35
|
+
fun build(createView: (Context, AppContext) -> ExpoView): ViewManagerDefinition {
|
|
36
|
+
val functions = asyncFunctions + asyncFunctionBuilders.mapValues { (_, builder) -> builder.build() }
|
|
37
|
+
for (function in functions.values) {
|
|
38
|
+
function.ownerType = viewType
|
|
39
|
+
function.canTakeOwner = true
|
|
40
|
+
}
|
|
41
|
+
return ViewManagerDefinition(name, viewClass, createView, props.toMap(), eventNames, functions, onViewDestroys, onViewDidUpdateProps)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
fun Name(viewName: String) {
|
|
45
|
+
name = viewName
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
inline fun OnViewDestroys(crossinline body: (view: T) -> Unit) {
|
|
49
|
+
onViewDestroys = { body(it as T) }
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
inline fun OnViewDidUpdateProps(crossinline body: (view: T) -> Unit) {
|
|
53
|
+
onViewDidUpdateProps = { body(it as T) }
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
inline fun <reified PropType> Prop(name: String, noinline body: (view: T, prop: PropType) -> Unit): ConcreteViewProp<T, PropType> =
|
|
57
|
+
ConcreteViewProp(name, toAnyType<PropType>(), body).also { props[name] = it }
|
|
58
|
+
|
|
59
|
+
inline fun <reified ViewType : ExpoView, reified PropType> Prop(
|
|
60
|
+
name: String,
|
|
61
|
+
noinline body: (view: ViewType, prop: PropType) -> Unit,
|
|
62
|
+
): ConcreteViewProp<ViewType, PropType> =
|
|
63
|
+
ConcreteViewProp(name, toAnyType<PropType>(), body).also { props[name] = it }
|
|
64
|
+
|
|
65
|
+
inline fun <reified ViewType : ExpoView, reified PropType> Prop(
|
|
66
|
+
name: String,
|
|
67
|
+
defaultValue: PropType,
|
|
68
|
+
noinline body: (view: ViewType, prop: PropType) -> Unit,
|
|
69
|
+
): ConcreteViewPropWithDefault<ViewType, PropType> =
|
|
70
|
+
ConcreteViewPropWithDefault(name, toAnyType<PropType>(), body, defaultValue).also { props[name] = it }
|
|
71
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@file:Suppress("UNCHECKED_CAST")
|
|
2
|
+
|
|
3
|
+
package expo.modules.kotlin.views
|
|
4
|
+
|
|
5
|
+
import expo.modules.kotlin.exception.PropSetException
|
|
6
|
+
import expo.modules.kotlin.exception.exceptionDecorator
|
|
7
|
+
import expo.modules.kotlin.types.AnyType
|
|
8
|
+
|
|
9
|
+
abstract class AnyViewProp(val name: String, internal val type: AnyType) {
|
|
10
|
+
abstract fun set(prop: Any?, onView: ExpoView)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
open class ConcreteViewProp<ViewType : ExpoView, PropType>(
|
|
14
|
+
name: String,
|
|
15
|
+
propType: AnyType,
|
|
16
|
+
protected val setter: (view: ViewType, prop: PropType) -> Unit,
|
|
17
|
+
) : AnyViewProp(name, propType) {
|
|
18
|
+
override fun set(prop: Any?, onView: ExpoView) {
|
|
19
|
+
exceptionDecorator({ PropSetException(name, onView::class, it) }) {
|
|
20
|
+
setter(onView as ViewType, type.convert(prop) as PropType)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
class ConcreteViewPropWithDefault<ViewType : ExpoView, PropType>(
|
|
26
|
+
name: String,
|
|
27
|
+
propType: AnyType,
|
|
28
|
+
setter: (view: ViewType, prop: PropType) -> Unit,
|
|
29
|
+
private val defaultValue: PropType,
|
|
30
|
+
) : ConcreteViewProp<ViewType, PropType>(name, propType, setter) {
|
|
31
|
+
override fun set(prop: Any?, onView: ExpoView) {
|
|
32
|
+
if (prop == null) setter(onView as ViewType, defaultValue)
|
|
33
|
+
else super.set(prop, onView)
|
|
34
|
+
}
|
|
35
|
+
}
|
package/kotlin/README.md
CHANGED
|
@@ -17,10 +17,20 @@ traffic in `scripts/debug/peach-swift-lazy-network.sh`.
|
|
|
17
17
|
into `~/.peach/kotlin/<version>`. kotlinc needs a Java runtime (17 or newer)
|
|
18
18
|
from `JAVA_HOME` or `PATH`, the one an Android build uses. Its heap is capped
|
|
19
19
|
at 2 GiB for the complete Compose closure.
|
|
20
|
-
- `Sources/`: the Android and One declarations app Kotlin
|
|
21
|
-
|
|
20
|
+
- `Sources/`: the Android and One declarations every app Kotlin compile
|
|
21
|
+
(imported modules and pure Kotlin apps) sees: `org.json` with Android's parse
|
|
22
|
+
and print rules, `android.util.Log` writing the guest console,
|
|
23
|
+
`android.os.SystemClock`, `Handler`/`Looper`/`MessageQueue` with Android's
|
|
24
|
+
queue order on the guest event loop, `java.lang.Runnable`,
|
|
25
|
+
`android.os.Build` values from the active Peach device,
|
|
26
|
+
`java.security.MessageDigest` for SHA-256, the `%02x` Byte formatter,
|
|
22
27
|
`androidx.annotation.Keep`, `dev.onejs.one.OneNativeSourceDispatch` and
|
|
23
|
-
`dev.onejs.one.source.OneModule`.
|
|
28
|
+
`dev.onejs.one.source.OneModule`. Kotlin/Wasm has no implicit `java.lang`
|
|
29
|
+
import, so app sources import `java.lang.Runnable` explicitly. `AppSources/`
|
|
30
|
+
adds the activity, window and Compose actuals only pure Kotlin apps compile.
|
|
31
|
+
- `ExpoSources/`: the expo-modules-core Kotlin DSL port and `PeachExpoRuntime`
|
|
32
|
+
that local Expo Android modules compile against. Owner spec:
|
|
33
|
+
[`specs/peach-kotlin-expo-modules.md`](../../../specs/peach-kotlin-expo-modules.md).
|
|
24
34
|
|
|
25
35
|
The dev server compiles every `.kt` source of the app, One's glue for each and
|
|
26
36
|
a generated entry into one Kotlin/Wasm module, held to the Kotlin language
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package android.os
|
|
2
|
+
|
|
3
|
+
// Build values follow the active Peach Android device supplied by its host.
|
|
4
|
+
object Build {
|
|
5
|
+
var MODEL: String = ""
|
|
6
|
+
private set
|
|
7
|
+
|
|
8
|
+
object VERSION {
|
|
9
|
+
var RELEASE: String = ""
|
|
10
|
+
internal set
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
internal fun setDevice(model: String, release: String) {
|
|
14
|
+
MODEL = model
|
|
15
|
+
VERSION.RELEASE = release
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
package android.os
|
|
2
|
+
|
|
3
|
+
import java.lang.Runnable
|
|
4
|
+
|
|
5
|
+
// android.os.Handler's runnable half, posting to its looper's queue
|
|
6
|
+
open class Handler(private val looper: Looper) {
|
|
7
|
+
@Deprecated("implicitly choosing a Looper during Handler construction can lead to bugs")
|
|
8
|
+
constructor() : this(Looper.myLooper() ?: throw RuntimeException("Can't create handler inside thread that has not called Looper.prepare()"))
|
|
9
|
+
|
|
10
|
+
fun getLooper(): Looper = looper
|
|
11
|
+
|
|
12
|
+
fun post(r: Runnable): Boolean = postAtTime(r, SystemClock.uptimeMillis())
|
|
13
|
+
fun postDelayed(r: Runnable, delayMillis: Long): Boolean =
|
|
14
|
+
postAtTime(r, SystemClock.uptimeMillis() + delayMillis.coerceAtLeast(0))
|
|
15
|
+
fun postDelayed(r: Runnable, token: Any?, delayMillis: Long): Boolean =
|
|
16
|
+
postAtTime(r, token, SystemClock.uptimeMillis() + delayMillis.coerceAtLeast(0))
|
|
17
|
+
fun postAtTime(r: Runnable, uptimeMillis: Long): Boolean = postAtTime(r, null, uptimeMillis)
|
|
18
|
+
fun postAtTime(r: Runnable, token: Any?, uptimeMillis: Long): Boolean {
|
|
19
|
+
looper.queue.enqueue(MessageQueue.Entry(uptimeMillis, this, r, token), front = false)
|
|
20
|
+
return true
|
|
21
|
+
}
|
|
22
|
+
fun postAtFrontOfQueue(r: Runnable): Boolean {
|
|
23
|
+
looper.queue.enqueue(MessageQueue.Entry(0, this, r, null), front = true)
|
|
24
|
+
return true
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
fun removeCallbacks(r: Runnable) = looper.queue.remove(this, r, null)
|
|
28
|
+
fun removeCallbacks(r: Runnable, token: Any?) = looper.queue.remove(this, r, token)
|
|
29
|
+
fun removeCallbacksAndMessages(token: Any?) = looper.queue.remove(this, null, token)
|
|
30
|
+
fun hasCallbacks(r: Runnable): Boolean = looper.queue.has(this, r, null)
|
|
31
|
+
|
|
32
|
+
companion object {
|
|
33
|
+
fun createAsync(looper: Looper): Handler = Handler(looper)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package android.os
|
|
2
|
+
|
|
3
|
+
// the guest's one thread is Android's main thread: its looper is the main
|
|
4
|
+
// looper and every message runs on the guest event loop
|
|
5
|
+
class Looper private constructor() {
|
|
6
|
+
internal val queue = MessageQueue()
|
|
7
|
+
|
|
8
|
+
fun isCurrentThread(): Boolean = true
|
|
9
|
+
fun getQueue(): MessageQueue = queue
|
|
10
|
+
|
|
11
|
+
companion object {
|
|
12
|
+
private val main = Looper()
|
|
13
|
+
fun getMainLooper(): Looper = main
|
|
14
|
+
fun myLooper(): Looper? = main
|
|
15
|
+
fun myQueue(): MessageQueue = main.queue
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
package android.os
|
|
2
|
+
|
|
3
|
+
import java.lang.Runnable
|
|
4
|
+
import kotlinx.coroutines.DelicateCoroutinesApi
|
|
5
|
+
import kotlinx.coroutines.Dispatchers
|
|
6
|
+
import kotlinx.coroutines.GlobalScope
|
|
7
|
+
import kotlinx.coroutines.Job
|
|
8
|
+
import kotlinx.coroutines.delay
|
|
9
|
+
import kotlinx.coroutines.launch
|
|
10
|
+
|
|
11
|
+
// MessageQueue's ordering: by uptime, then by enqueue order, with
|
|
12
|
+
// postAtFrontOfQueue at time zero ahead of everything already queued
|
|
13
|
+
class MessageQueue internal constructor() {
|
|
14
|
+
internal class Entry(val time: Long, val handler: Handler, val callback: Runnable, val token: Any?)
|
|
15
|
+
|
|
16
|
+
private val entries = ArrayList<Entry>()
|
|
17
|
+
private var wake: Job? = null
|
|
18
|
+
private var wakeAt = Long.MAX_VALUE
|
|
19
|
+
|
|
20
|
+
fun isIdle(): Boolean = entries.firstOrNull().let { it == null || it.time > SystemClock.uptimeMillis() }
|
|
21
|
+
|
|
22
|
+
internal fun enqueue(entry: Entry, front: Boolean) {
|
|
23
|
+
val index = if (front) 0 else entries.indexOfFirst { it.time > entry.time }.let { if (it < 0) entries.size else it }
|
|
24
|
+
entries.add(index, entry)
|
|
25
|
+
schedule()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
internal fun remove(handler: Handler, callback: Runnable?, token: Any?) {
|
|
29
|
+
entries.removeAll { it.handler === handler && (callback == null || it.callback === callback) && (token == null || it.token === token) }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
internal fun has(handler: Handler, callback: Runnable?, token: Any?): Boolean =
|
|
33
|
+
entries.any { it.handler === handler && (callback == null || it.callback === callback) && (token == null || it.token === token) }
|
|
34
|
+
|
|
35
|
+
@OptIn(DelicateCoroutinesApi::class)
|
|
36
|
+
private fun schedule() {
|
|
37
|
+
val next = entries.firstOrNull()?.time ?: return
|
|
38
|
+
if (wake != null && wakeAt <= next) return
|
|
39
|
+
wake?.cancel()
|
|
40
|
+
wakeAt = next
|
|
41
|
+
wake = GlobalScope.launch(Dispatchers.Main) {
|
|
42
|
+
delay(next - SystemClock.uptimeMillis())
|
|
43
|
+
wake = null
|
|
44
|
+
wakeAt = Long.MAX_VALUE
|
|
45
|
+
// run what is due one message at a time; a callback may post or
|
|
46
|
+
// remove, so read the head again after each one
|
|
47
|
+
while (true) {
|
|
48
|
+
val head = entries.firstOrNull() ?: break
|
|
49
|
+
if (head.time > SystemClock.uptimeMillis()) break
|
|
50
|
+
entries.removeAt(0)
|
|
51
|
+
head.callback.run()
|
|
52
|
+
}
|
|
53
|
+
schedule()
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
package android.os
|
|
2
|
+
|
|
3
|
+
// android.os.SystemClock over the guest's monotonic clock; the device boots
|
|
4
|
+
// with the guest, and a browser device never sleeps, so uptime and realtime
|
|
5
|
+
// agree. sleep() is absent: the main thread cannot block here.
|
|
6
|
+
object SystemClock {
|
|
7
|
+
fun uptimeMillis(): Long = nowMillis().toLong()
|
|
8
|
+
fun uptimeNanos(): Long = (nowMillis() * 1_000_000.0).toLong()
|
|
9
|
+
fun elapsedRealtime(): Long = nowMillis().toLong()
|
|
10
|
+
fun elapsedRealtimeNanos(): Long = (nowMillis() * 1_000_000.0).toLong()
|
|
11
|
+
fun currentThreadTimeMillis(): Long = nowMillis().toLong()
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
private fun nowMillis(): Double = js("performance.now()")
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
package android.util
|
|
2
|
+
|
|
3
|
+
// android.util.Log: the main log buffer is the guest console, one console
|
|
4
|
+
// level per priority. liblog answers 1 for a written line and -EPERM below
|
|
5
|
+
// VERBOSE; isLoggable answers the unset log.tag property's INFO default.
|
|
6
|
+
object Log {
|
|
7
|
+
const val VERBOSE = 2
|
|
8
|
+
const val DEBUG = 3
|
|
9
|
+
const val INFO = 4
|
|
10
|
+
const val WARN = 5
|
|
11
|
+
const val ERROR = 6
|
|
12
|
+
const val ASSERT = 7
|
|
13
|
+
|
|
14
|
+
fun v(tag: String?, msg: String): Int = println(VERBOSE, tag, msg)
|
|
15
|
+
fun v(tag: String?, msg: String?, tr: Throwable?): Int = printlns(VERBOSE, tag, msg, tr)
|
|
16
|
+
fun d(tag: String?, msg: String): Int = println(DEBUG, tag, msg)
|
|
17
|
+
fun d(tag: String?, msg: String?, tr: Throwable?): Int = printlns(DEBUG, tag, msg, tr)
|
|
18
|
+
fun i(tag: String?, msg: String): Int = println(INFO, tag, msg)
|
|
19
|
+
fun i(tag: String?, msg: String?, tr: Throwable?): Int = printlns(INFO, tag, msg, tr)
|
|
20
|
+
fun w(tag: String?, msg: String): Int = println(WARN, tag, msg)
|
|
21
|
+
fun w(tag: String?, msg: String?, tr: Throwable?): Int = printlns(WARN, tag, msg, tr)
|
|
22
|
+
fun w(tag: String?, tr: Throwable?): Int = printlns(WARN, tag, "", tr)
|
|
23
|
+
fun e(tag: String?, msg: String): Int = println(ERROR, tag, msg)
|
|
24
|
+
fun e(tag: String?, msg: String?, tr: Throwable?): Int = printlns(ERROR, tag, msg, tr)
|
|
25
|
+
|
|
26
|
+
// an app process's default terrible failure handler logs and continues
|
|
27
|
+
fun wtf(tag: String?, msg: String?): Int = printlns(ASSERT, tag, msg, null)
|
|
28
|
+
fun wtf(tag: String?, tr: Throwable): Int = printlns(ASSERT, tag, tr.message, tr)
|
|
29
|
+
fun wtf(tag: String?, msg: String?, tr: Throwable?): Int = printlns(ASSERT, tag, msg, tr)
|
|
30
|
+
|
|
31
|
+
fun isLoggable(tag: String?, level: Int): Boolean = level >= INFO
|
|
32
|
+
|
|
33
|
+
fun getStackTraceString(tr: Throwable?): String {
|
|
34
|
+
var cause = tr ?: return ""
|
|
35
|
+
// Android hides host lookup failures, which carry no useful trace
|
|
36
|
+
while (true) {
|
|
37
|
+
if (cause::class.simpleName == "UnknownHostException") return ""
|
|
38
|
+
cause = cause.cause ?: break
|
|
39
|
+
}
|
|
40
|
+
return tr.stackTraceToString()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
fun println(priority: Int, tag: String?, msg: String): Int {
|
|
44
|
+
if (priority < VERBOSE) return -1
|
|
45
|
+
val line = if (tag == null) msg else "$tag: $msg"
|
|
46
|
+
when (priority) {
|
|
47
|
+
VERBOSE, DEBUG -> consoleDebug(line)
|
|
48
|
+
INFO -> consoleInfo(line)
|
|
49
|
+
WARN -> consoleWarn(line)
|
|
50
|
+
else -> consoleError(line)
|
|
51
|
+
}
|
|
52
|
+
return 1
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private fun printlns(priority: Int, tag: String?, msg: String?, tr: Throwable?): Int {
|
|
56
|
+
val trace = getStackTraceString(tr)
|
|
57
|
+
return println(priority, tag, if (trace.isEmpty()) msg ?: "" else "${msg ?: ""}\n$trace")
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private fun consoleDebug(line: String): Unit = js("console.debug(line)")
|
|
62
|
+
private fun consoleInfo(line: String): Unit = js("console.info(line)")
|
|
63
|
+
private fun consoleWarn(line: String): Unit = js("console.warn(line)")
|
|
64
|
+
private fun consoleError(line: String): Unit = js("console.error(line)")
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
package java.security
|
|
2
|
+
|
|
3
|
+
class NoSuchAlgorithmException(message: String) : Exception(message)
|
|
4
|
+
|
|
5
|
+
class MessageDigest private constructor() {
|
|
6
|
+
companion object {
|
|
7
|
+
fun getInstance(algorithm: String): MessageDigest {
|
|
8
|
+
if (algorithm.uppercase() != "SHA-256")
|
|
9
|
+
throw NoSuchAlgorithmException("$algorithm MessageDigest not available")
|
|
10
|
+
return MessageDigest()
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
fun digest(input: ByteArray): ByteArray = sha256(input)
|
|
15
|
+
|
|
16
|
+
private fun sha256(input: ByteArray): ByteArray {
|
|
17
|
+
val bitLength = input.size.toLong() * 8L
|
|
18
|
+
val paddedLength = ((input.size + 9 + 63) / 64) * 64
|
|
19
|
+
val padded = ByteArray(paddedLength)
|
|
20
|
+
input.copyInto(padded)
|
|
21
|
+
padded[input.size] = 0x80.toByte()
|
|
22
|
+
for (index in 0 until 8) {
|
|
23
|
+
padded[paddedLength - 1 - index] = (bitLength ushr (index * 8)).toByte()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
val state = intArrayOf(
|
|
27
|
+
0x6a09e667,
|
|
28
|
+
0xbb67ae85.toInt(),
|
|
29
|
+
0x3c6ef372,
|
|
30
|
+
0xa54ff53a.toInt(),
|
|
31
|
+
0x510e527f,
|
|
32
|
+
0x9b05688c.toInt(),
|
|
33
|
+
0x1f83d9ab,
|
|
34
|
+
0x5be0cd19,
|
|
35
|
+
)
|
|
36
|
+
val constants = intArrayOf(
|
|
37
|
+
0x428a2f98.toInt(), 0x71374491, 0xb5c0fbcf.toInt(), 0xe9b5dba5.toInt(),
|
|
38
|
+
0x3956c25b, 0x59f111f1, 0x923f82a4.toInt(), 0xab1c5ed5.toInt(),
|
|
39
|
+
0xd807aa98.toInt(), 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74,
|
|
40
|
+
0x80deb1fe.toInt(), 0x9bdc06a7.toInt(), 0xc19bf174.toInt(),
|
|
41
|
+
0xe49b69c1.toInt(), 0xefbe4786.toInt(), 0x0fc19dc6, 0x240ca1cc,
|
|
42
|
+
0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da.toInt(), 0x983e5152.toInt(),
|
|
43
|
+
0xa831c66d.toInt(), 0xb00327c8.toInt(), 0xbf597fc7.toInt(), 0xc6e00bf3.toInt(),
|
|
44
|
+
0xd5a79147.toInt(), 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138,
|
|
45
|
+
0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e.toInt(),
|
|
46
|
+
0x92722c85.toInt(), 0xa2bfe8a1.toInt(), 0xa81a664b.toInt(), 0xc24b8b70.toInt(),
|
|
47
|
+
0xc76c51a3.toInt(), 0xd192e819.toInt(), 0xd6990624.toInt(), 0xf40e3585.toInt(),
|
|
48
|
+
0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
|
|
49
|
+
0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee,
|
|
50
|
+
0x78a5636f, 0x84c87814.toInt(), 0x8cc70208.toInt(), 0x90befffa.toInt(),
|
|
51
|
+
0xa4506ceb.toInt(), 0xbef9a3f7.toInt(), 0xc67178f2.toInt(),
|
|
52
|
+
)
|
|
53
|
+
val words = IntArray(64)
|
|
54
|
+
var offset = 0
|
|
55
|
+
while (offset < padded.size) {
|
|
56
|
+
for (index in 0 until 16) {
|
|
57
|
+
val start = offset + index * 4
|
|
58
|
+
words[index] =
|
|
59
|
+
((padded[start].toInt() and 0xff) shl 24) or
|
|
60
|
+
((padded[start + 1].toInt() and 0xff) shl 16) or
|
|
61
|
+
((padded[start + 2].toInt() and 0xff) shl 8) or
|
|
62
|
+
(padded[start + 3].toInt() and 0xff)
|
|
63
|
+
}
|
|
64
|
+
for (index in 16 until 64) {
|
|
65
|
+
val x = words[index - 15]
|
|
66
|
+
val y = words[index - 2]
|
|
67
|
+
val small0 = x.rotateRight(7) xor x.rotateRight(18) xor (x ushr 3)
|
|
68
|
+
val small1 = y.rotateRight(17) xor y.rotateRight(19) xor (y ushr 10)
|
|
69
|
+
words[index] = words[index - 16] + small0 + words[index - 7] + small1
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
var a = state[0]
|
|
73
|
+
var b = state[1]
|
|
74
|
+
var c = state[2]
|
|
75
|
+
var d = state[3]
|
|
76
|
+
var e = state[4]
|
|
77
|
+
var f = state[5]
|
|
78
|
+
var g = state[6]
|
|
79
|
+
var h = state[7]
|
|
80
|
+
for (index in 0 until 64) {
|
|
81
|
+
val large1 = e.rotateRight(6) xor e.rotateRight(11) xor e.rotateRight(25)
|
|
82
|
+
val choose = (e and f) xor (e.inv() and g)
|
|
83
|
+
val first = h + large1 + choose + constants[index] + words[index]
|
|
84
|
+
val large0 = a.rotateRight(2) xor a.rotateRight(13) xor a.rotateRight(22)
|
|
85
|
+
val majority = (a and b) xor (a and c) xor (b and c)
|
|
86
|
+
val second = large0 + majority
|
|
87
|
+
h = g
|
|
88
|
+
g = f
|
|
89
|
+
f = e
|
|
90
|
+
e = d + first
|
|
91
|
+
d = c
|
|
92
|
+
c = b
|
|
93
|
+
b = a
|
|
94
|
+
a = first + second
|
|
95
|
+
}
|
|
96
|
+
state[0] += a
|
|
97
|
+
state[1] += b
|
|
98
|
+
state[2] += c
|
|
99
|
+
state[3] += d
|
|
100
|
+
state[4] += e
|
|
101
|
+
state[5] += f
|
|
102
|
+
state[6] += g
|
|
103
|
+
state[7] += h
|
|
104
|
+
offset += 64
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return ByteArray(32) { index ->
|
|
108
|
+
(state[index / 4] ushr (24 - (index % 4) * 8)).toByte()
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private fun Int.rotateRight(distance: Int): Int =
|
|
113
|
+
(this ushr distance) or (this shl (32 - distance))
|
|
114
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
package kotlin.text
|
|
2
|
+
|
|
3
|
+
fun String.format(vararg args: Any?): String {
|
|
4
|
+
if (this != "%02x" || args.size != 1 || args[0] !is Byte)
|
|
5
|
+
throw IllegalArgumentException("Peach Kotlin formatting supports only %02x Byte conversion")
|
|
6
|
+
return ((args[0] as Byte).toInt() and 0xff).toString(16).padStart(2, '0')
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
fun String.toByteArray(): ByteArray = encodeToByteArray()
|
|
@@ -139,6 +139,20 @@ private fun write(value: Any?, out: StringBuilder) {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
+
private fun typeMismatch(indexOrName: Any, value: Any, required: String): JSONException {
|
|
143
|
+
val className = when (value) {
|
|
144
|
+
JSONObject.NULL -> "org.json.JSONObject\$1"
|
|
145
|
+
is String -> "java.lang.String"
|
|
146
|
+
is Boolean -> "java.lang.Boolean"
|
|
147
|
+
is Int -> "java.lang.Integer"
|
|
148
|
+
is Long -> "java.lang.Long"
|
|
149
|
+
is Double -> "java.lang.Double"
|
|
150
|
+
is Float -> "java.lang.Float"
|
|
151
|
+
else -> value::class.qualifiedName
|
|
152
|
+
}
|
|
153
|
+
return JSONException("Value $value at $indexOrName of type $className cannot be converted to $required")
|
|
154
|
+
}
|
|
155
|
+
|
|
142
156
|
class JSONArray() {
|
|
143
157
|
private val values = ArrayList<Any?>()
|
|
144
158
|
|
|
@@ -161,6 +175,22 @@ class JSONArray() {
|
|
|
161
175
|
return values[index] ?: throw JSONException("Value at $index is null.")
|
|
162
176
|
}
|
|
163
177
|
|
|
178
|
+
fun getString(index: Int): String = get(index).toString()
|
|
179
|
+
|
|
180
|
+
fun getJSONArray(index: Int): JSONArray {
|
|
181
|
+
val value = get(index)
|
|
182
|
+
return value as? JSONArray ?: throw typeMismatch(index, value, "JSONArray")
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
fun optJSONArray(index: Int): JSONArray? = opt(index) as? JSONArray
|
|
186
|
+
|
|
187
|
+
fun getJSONObject(index: Int): JSONObject {
|
|
188
|
+
val value = get(index)
|
|
189
|
+
return value as? JSONObject ?: throw typeMismatch(index, value, "JSONObject")
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
fun optJSONObject(index: Int): JSONObject? = opt(index) as? JSONObject
|
|
193
|
+
|
|
164
194
|
fun put(value: Any?): JSONArray {
|
|
165
195
|
values.add(value)
|
|
166
196
|
return this
|
|
@@ -214,6 +244,20 @@ class JSONObject() {
|
|
|
214
244
|
else -> value.toString()
|
|
215
245
|
}
|
|
216
246
|
|
|
247
|
+
fun getJSONArray(name: String): JSONArray {
|
|
248
|
+
val value = get(name)
|
|
249
|
+
return value as? JSONArray ?: throw typeMismatch(name, value, "JSONArray")
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
fun optJSONArray(name: String): JSONArray? = opt(name) as? JSONArray
|
|
253
|
+
|
|
254
|
+
fun getJSONObject(name: String): JSONObject {
|
|
255
|
+
val value = get(name)
|
|
256
|
+
return value as? JSONObject ?: throw typeMismatch(name, value, "JSONObject")
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
fun optJSONObject(name: String): JSONObject? = opt(name) as? JSONObject
|
|
260
|
+
|
|
217
261
|
fun optInt(name: String, fallback: Int = 0): Int = when (val value = opt(name)) {
|
|
218
262
|
is Number -> value.toInt()
|
|
219
263
|
is String -> value.toDoubleOrNull()?.toInt() ?: fallback
|
|
@@ -2,6 +2,8 @@ package dev.contrast.composefixtures
|
|
|
2
2
|
|
|
3
3
|
import dev.onejs.one.source.OneModule
|
|
4
4
|
import kotlinx.coroutines.delay
|
|
5
|
+
import kotlinx.coroutines.flow.MutableStateFlow
|
|
6
|
+
import kotlinx.coroutines.flow.first
|
|
5
7
|
|
|
6
8
|
object Counter : OneModule {
|
|
7
9
|
private var count = 0
|
|
@@ -30,6 +32,7 @@ object CounterEffects : OneModule {
|
|
|
30
32
|
private var entered = 0
|
|
31
33
|
private var disposed = 0
|
|
32
34
|
private var cancelled = 0
|
|
35
|
+
private val changes = MutableStateFlow(0)
|
|
33
36
|
private var compositionLocale = ""
|
|
34
37
|
private var currentLocale = ""
|
|
35
38
|
internal fun recordLocale(current: String, composition: String) {
|
|
@@ -37,8 +40,12 @@ object CounterEffects : OneModule {
|
|
|
37
40
|
compositionLocale = composition
|
|
38
41
|
}
|
|
39
42
|
fun locales(): List<String> = listOf(currentLocale, compositionLocale)
|
|
40
|
-
fun enter() { entered += 1 }
|
|
41
|
-
fun dispose() { disposed += 1 }
|
|
42
|
-
fun cancel() { cancelled += 1 }
|
|
43
|
+
fun enter() { entered += 1; changes.value += 1 }
|
|
44
|
+
fun dispose() { disposed += 1; changes.value += 1 }
|
|
45
|
+
fun cancel() { cancelled += 1; changes.value += 1 }
|
|
43
46
|
fun read(): List<Int> = listOf(entered, disposed, cancelled)
|
|
47
|
+
suspend fun awaitDisposed(): List<Int> {
|
|
48
|
+
changes.first { entered > 0 && disposed == entered && cancelled == entered }
|
|
49
|
+
return read()
|
|
50
|
+
}
|
|
44
51
|
}
|
|
@@ -13,7 +13,7 @@ export default function Index() {
|
|
|
13
13
|
if (callback > 0) void CounterEffects.locales().then(setLocales)
|
|
14
14
|
}, [callback])
|
|
15
15
|
useEffect(() => {
|
|
16
|
-
if (!mounted) void CounterEffects.
|
|
16
|
+
if (!mounted) void CounterEffects.awaitDisposed().then(setEffects)
|
|
17
17
|
}, [mounted])
|
|
18
18
|
return (
|
|
19
19
|
<View style={{ flex: 1 }}>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { one } from 'one/vite'
|
|
2
|
-
import {
|
|
2
|
+
import { peachPlugin } from 'peachsim/vite'
|
|
3
3
|
export default {
|
|
4
4
|
root: import.meta.dirname,
|
|
5
5
|
plugins: [
|
|
6
6
|
one({ web: { defaultRenderMode: 'spa' }, native: { bundler: 'vite' } }),
|
|
7
|
-
|
|
7
|
+
peachPlugin(),
|
|
8
8
|
],
|
|
9
9
|
server: { host: '0.0.0.0' },
|
|
10
10
|
}
|
|
@@ -28,6 +28,7 @@ import androidx.compose.ui.semantics.getOrNull
|
|
|
28
28
|
import androidx.compose.ui.text.font.FontFamily
|
|
29
29
|
import androidx.compose.ui.text.font.FontStyle
|
|
30
30
|
import androidx.compose.ui.text.font.FontSynthesis
|
|
31
|
+
import androidx.compose.ui.text.font.FontVariation
|
|
31
32
|
import androidx.compose.ui.text.font.FontWeight
|
|
32
33
|
import androidx.compose.ui.text.font.PlatformTypefacesLoader
|
|
33
34
|
import androidx.compose.ui.text.font.createPlatformFontFamilyResolver
|
|
@@ -182,13 +183,13 @@ private fun text(node: SemanticsNode): String? =
|
|
|
182
183
|
node.config.getOrNull(SemanticsProperties.Text)?.joinToString { it.text }
|
|
183
184
|
|
|
184
185
|
object Headless : OneModule {
|
|
185
|
-
suspend fun capture(
|
|
186
|
+
suspend fun capture(font: String): String {
|
|
186
187
|
try {
|
|
187
|
-
val
|
|
188
|
-
|
|
189
|
-
Font("Roboto
|
|
190
|
-
|
|
191
|
-
)
|
|
188
|
+
val data = Base64.decode(font)
|
|
189
|
+
val roboto = FontFamily(listOf(FontWeight.Normal, FontWeight.Medium, FontWeight.Bold).map { weight ->
|
|
190
|
+
Font("Roboto-${weight.weight}", getData = { data }, weight = weight,
|
|
191
|
+
variationSettings = FontVariation.Settings(weight, FontStyle.Normal))
|
|
192
|
+
})
|
|
192
193
|
Counter.reset()
|
|
193
194
|
val start = TimeSource.Monotonic.markNow()
|
|
194
195
|
DeviceScene("en-US") { AndroidFonts(roboto) { CounterScreen() } }.use { device ->
|