peachsim 0.1.628 → 0.1.630

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.
Files changed (111) hide show
  1. package/README.md +8 -4
  2. package/cli/bridge-flow-runner.ts +10 -3
  3. package/cli/cli-update.ts +2 -7
  4. package/cli/cloud-test-tunnel.ts +16 -3
  5. package/cli/commands/config.ts +1 -1
  6. package/cli/commands/control.ts +28 -3
  7. package/cli/commands/daemon-mac-app.ts +4 -2
  8. package/cli/commands/daemon.ts +4 -4
  9. package/cli/commands/device.ts +2 -3
  10. package/cli/commands/inspect/actions.ts +125 -90
  11. package/cli/commands/inspect/core.ts +5 -0
  12. package/cli/commands/inspect.ts +27 -13
  13. package/cli/commands/platform.ts +1 -1
  14. package/cli/commands/screenshot-layers.ts +1 -1
  15. package/cli/commands/screenshot.ts +1 -1
  16. package/cli/commands/skills.ts +0 -31
  17. package/cli/drivers/playwright-provisioning.ts +3 -2
  18. package/cli/drivers/playwright-sim-host.ts +25 -9
  19. package/cli/main.ts +8 -2
  20. package/cli/outbound-endpoints.ts +0 -4
  21. package/detox/index.ts +74 -43
  22. package/dist-lib/agent-daemon-client.cjs +1 -1
  23. package/dist-lib/agent-events.cjs +1 -1
  24. package/dist-lib/agent-identity.cjs +1 -1
  25. package/dist-lib/agent-sessions.cjs +1 -1
  26. package/dist-lib/attached-projects.cjs +1 -1
  27. package/dist-lib/auth/shared-session.cjs +1 -1
  28. package/dist-lib/backend-origin.cjs +1 -1
  29. package/dist-lib/beta.cjs +1 -1
  30. package/dist-lib/beta.mjs +1 -1
  31. package/dist-lib/bridge-constants.cjs +1 -1
  32. package/dist-lib/bridge-contract-input.cjs +1 -1
  33. package/dist-lib/bridge-contract-input.mjs +1 -1
  34. package/dist-lib/bridge-contract.cjs +1 -1
  35. package/dist-lib/bridge-contract.mjs +1 -1
  36. package/dist-lib/capture-contract.cjs +1 -1
  37. package/dist-lib/capture-contract.mjs +1 -1
  38. package/dist-lib/cli-constants.cjs +1 -1
  39. package/dist-lib/cloud-contract.cjs +1 -1
  40. package/dist-lib/cloud-contract.mjs +1 -1
  41. package/dist-lib/cloud-test-args.cjs +1 -1
  42. package/dist-lib/cloud-test-args.mjs +1 -1
  43. package/dist-lib/cloud.cjs +1 -1
  44. package/dist-lib/cloud.mjs +1 -1
  45. package/dist-lib/config.cjs +1 -1
  46. package/dist-lib/detox/index.cjs +129 -27
  47. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  48. package/dist-lib/home-paths.cjs +1 -1
  49. package/dist-lib/host/bridge-host.cjs +290 -315
  50. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  51. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  52. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  53. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  54. package/dist-lib/host/websocket-proxy.cjs +1 -1
  55. package/dist-lib/index.cjs +253 -121
  56. package/dist-lib/jump-to-source-babel.cjs +1 -1
  57. package/dist-lib/jump-to-source-native.cjs +1 -1
  58. package/dist-lib/{vite-kotlin.cjs → kotlin-host.cjs} +130 -19
  59. package/dist-lib/menu.cjs +1 -1
  60. package/dist-lib/menu.mjs +1 -1
  61. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  62. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  63. package/dist-lib/metro-production-bundle.cjs +1 -1
  64. package/dist-lib/metro-production-bundle.mjs +1 -1
  65. package/dist-lib/metro.cjs +132 -9
  66. package/dist-lib/native-app-identity.cjs +278 -0
  67. package/dist-lib/native-app-identity.mjs +245 -0
  68. package/dist-lib/profiles.cjs +1 -1
  69. package/dist-lib/public-brand.cjs +1 -1
  70. package/dist-lib/react-native-host-modules.cjs +1 -1
  71. package/dist-lib/react-native-host-modules.mjs +1 -1
  72. package/dist-lib/render-mode.cjs +1 -1
  73. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  74. package/dist-lib/sdk.cjs +110 -87
  75. package/dist-lib/sdk.mjs +110 -87
  76. package/dist-lib/skills.cjs +841 -643
  77. package/dist-lib/swift-compile.cjs +1 -1
  78. package/dist-lib/swift-compile.mjs +1 -1
  79. package/dist-lib/swift-package.cjs +1 -1
  80. package/dist-lib/swift-package.mjs +1 -1
  81. package/dist-lib/swift-submit.cjs +1 -1
  82. package/dist-lib/swift-submit.mjs +1 -1
  83. package/dist-lib/swift.cjs +282 -177
  84. package/dist-lib/vite-swift.cjs +1 -1
  85. package/dist-lib/vite.cjs +11 -28
  86. package/kotlin/README.md +32 -4
  87. package/kotlin/fixtures/counter/Counter.kt +26 -0
  88. package/kotlin/fixtures/counter/CounterScreen.kt +40 -0
  89. package/kotlin/fixtures/headless-counter/Headless.kt +228 -0
  90. package/kotlin/fixtures/runtime-state/RuntimeState.kt +200 -0
  91. package/kotlin/fork/LICENSE +178 -0
  92. package/kotlin/fork/NOTICE +25 -0
  93. package/kotlin/fork/README.md +59 -0
  94. package/kotlin/fork/build.sh +128 -0
  95. package/kotlin/fork/compose-worker-globals.patch +96 -0
  96. package/kotlin/fork/fork.json +33 -0
  97. package/kotlin/fork/publish.ts +77 -0
  98. package/kotlin/fork/skiko-worker-clock.patch +33 -0
  99. package/kotlin/toolchain.json +288 -0
  100. package/package.json +12 -5
  101. package/src/automatic-update-policy.ts +17 -0
  102. package/src/host/bridge-host.ts +3 -1
  103. package/src/{vite-plugin-kotlin.ts → kotlin-host.ts} +155 -12
  104. package/src/metro-plugin.ts +18 -0
  105. package/src/native-app-identity.ts +376 -0
  106. package/src/native-firebase-config.ts +90 -0
  107. package/src/screenshots/frame-compose.ts +5 -2
  108. package/src/screenshots/registry.ts +1 -1
  109. package/src/screenshots/schema.ts +2 -2
  110. package/src/vite-plugin-one.ts +11 -28
  111. package/src/vite-plugin.ts +6 -1
@@ -0,0 +1,178 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
@@ -0,0 +1,25 @@
1
+ Peach's patched builds of JetBrains Compose Multiplatform UI and Skiko
2
+
3
+ This directory records modified builds of two Apache License 2.0 projects.
4
+ The license text is in LICENSE beside this file.
5
+
6
+ - JetBrains/compose-multiplatform-core at tag v1.13.0-alpha01
7
+ (commit a9e47e8aa04c95cfe572ab4297c770f3cbfb234e), a fork of the Android
8
+ Open Source Project's AndroidX. Copyright The Android Open Source Project
9
+ and JetBrains s.r.o. and respective authors and developers.
10
+ - JetBrains/skiko at tag v0.152.0-alpha02
11
+ (commit 96378296bb23c23c5f30cd2b0d42d6f8fdeff730). Copyright JetBrains s.r.o.
12
+ and respective authors and developers. Skiko's own NOTICE reads:
13
+
14
+ This project contains code adapted from "The Android Open Source Project"
15
+ licensed under the Apache License, Version 2.0 (the "License"):
16
+
17
+ https://android.googlesource.com/platform/frameworks/base
18
+
19
+ Modifications: compose-worker-globals.patch and skiko-worker-clock.patch
20
+ change four upstream source files so their web code reads globalThis instead
21
+ of window (performance.now, isSecureContext, navigator.clipboard,
22
+ navigator.languages). Each modified file carries a notice saying so. No other
23
+ upstream file changes; the built klibs are ui-wasm-js and ui-text-wasm-js
24
+ 1.13.0-alpha01 and skiko-wasm-js 0.152.0-alpha02 compiled from the patched
25
+ sources.
@@ -0,0 +1,59 @@
1
+ # Peach's JetBrains web fork
2
+
3
+ Peach runs Compose in a tenant worker, which has no `window`, like any browser
4
+ worker. Three web functions in Compose UI 1.13.0-alpha01 and one in Skiko
5
+ 0.152.0-alpha02 name `window` anyway, so a Compose scene throws
6
+ `window is not defined` before its first frame. Peach carries patched builds
7
+ of those modules until upstream supports workers.
8
+
9
+ The patches replace `window` with `globalThis` and nothing else:
10
+
11
+ | module | file | read |
12
+ | --- | --- | --- |
13
+ | `org.jetbrains.compose.ui:ui` | `Actuals.wasm.kt` | `currentTimeMillis()` from `globalThis.performance.now()` |
14
+ | `org.jetbrains.compose.ui:ui` | `PlatformClipboard.web.kt` | `globalThis.isSecureContext`, `globalThis.navigator.clipboard` |
15
+ | `org.jetbrains.compose.ui:ui-text` | `PlatformLocale.web.kt` | `globalThis.navigator.languages` |
16
+ | `org.jetbrains.skiko:skiko` | `Actuals.web.kt` | `currentNanoTime()` from `globalThis.performance.now()` |
17
+
18
+ In a document `globalThis` is the window, so behavior there is unchanged. In a
19
+ worker each read returns the worker's real value: its clock, its secure
20
+ context, its languages, and no clipboard API. Nothing defines a `window`.
21
+
22
+ ## files
23
+
24
+ - `fork.json`: upstream repositories, tags and commits, patch sha256s, and the
25
+ builder's pinned JDK and Android command-line tools.
26
+ - `compose-worker-globals.patch`, `skiko-worker-clock.patch`: the whole fork.
27
+ Every modified file carries a notice saying it was modified.
28
+ - `LICENSE` (Apache 2.0, both upstreams) and `NOTICE`.
29
+ - `build.sh`: fetches each upstream at its commit, applies its patch and runs
30
+ the upstream Gradle build for the changed modules only.
31
+
32
+ `packages/peachsim/kotlin/toolchain.json` names each built klib by its sha256
33
+ at `https://r2.rnxsim.com/peach-kotlin-fork/<sha256>/<file>`, beside a copy of
34
+ the patches, `fork.json`, `LICENSE` and `NOTICE`. Every other Compose library
35
+ is the official Maven artifact. The klibs load only for an app whose Kotlin
36
+ imports Compose, like the rest of the Compose closure.
37
+
38
+ ## rebuilding
39
+
40
+ ```sh
41
+ bun remote bash packages/peachsim/kotlin/fork/build.sh
42
+ bun packages/peachsim/kotlin/fork/publish.ts .remote-out/kotlin-fork
43
+ ```
44
+
45
+ The build runs on the Linux builder under its idle scheduling and memory
46
+ bound; a warm rebuild takes a few minutes. The build delivers the klibs with
47
+ the record it used (`fork.json`, patches, LICENSE, NOTICE, `klibs.sha256`).
48
+ `publish.ts` uploads exactly that delivery under each klib's sha256, refuses to
49
+ replace an existing object with other bytes, and prints the `toolchain.json`
50
+ entries. Moving a pin means a new tag, commit, regenerated patch and patch
51
+ sha256 in `fork.json`, then a rebuild.
52
+
53
+ ## exit
54
+
55
+ Delete this directory and point `toolchain.json` back at Maven Central when
56
+ official Compose Multiplatform and Skiko releases read worker-safe globals in
57
+ all four places, and those releases match the Android pin table in
58
+ `plans/peach/kotlin-everywhere.md`. The upstream issue text lives with that
59
+ plan's owner until it is filed.
@@ -0,0 +1,128 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # builds Peach's patched JetBrains Kotlin/Wasm klibs on the linux builder and
4
+ # delivers them to the caller's `.remote-out/kotlin-fork/`:
5
+ #
6
+ # bun remote bash packages/peachsim/kotlin/fork/build.sh
7
+ #
8
+ # each upstream in fork.json is fetched at its pinned commit, gets its
9
+ # committed patch, and builds with its own gradle build at the upstream's
10
+ # kotlin compiler. only the modules the patches change are delivered. the
11
+ # builder keeps the sources, the verified toolchain downloads, the sdk
12
+ # platforms the compose build installs, and gradle's caches under
13
+ # ~/builders/peach-kotlin-fork, so a rebuild is warm. the JDK and sdk tools are
14
+ # unpacked fresh from their pinned archives every run, so a changed pin or an
15
+ # altered install never survives into a build. bun remote already runs this under SCHED_IDLE with a
16
+ # 16G memory bound; gradle and its in-process compiler stay inside it.
17
+
18
+ set -euo pipefail
19
+
20
+ FORK=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
21
+ REPO_ROOT=$(cd "${FORK}/../../../.." && pwd)
22
+ ROOT=$HOME/builders/peach-kotlin-fork
23
+ DELIVER=${REPO_ROOT}/.remote-out/kotlin-fork
24
+
25
+ mkdir -p "${ROOT}/downloads" "${ROOT}/src"
26
+ exec 9>>"${ROOT}.lock"
27
+ flock 9
28
+
29
+ field() { node -p "const f = require('${FORK}/fork.json'); ${1}"; }
30
+
31
+ fetch() {
32
+ local url=$1 sha256=$2 target=$3
33
+ if [[ -f "${target}" ]] && echo "${sha256} ${target}" | sha256sum -c --status; then return; fi
34
+ curl -sfL --retry 3 -o "${target}.partial" "${url}"
35
+ if ! echo "${sha256} ${target}.partial" | sha256sum -c --status; then
36
+ echo "${url} does not match its pinned sha256 ${sha256}" >&2
37
+ exit 2
38
+ fi
39
+ mv "${target}.partial" "${target}"
40
+ }
41
+
42
+ JDK=${ROOT}/jdk
43
+ fetch "$(field 'f.toolchain.jdk.url')" "$(field 'f.toolchain.jdk.sha256')" "${ROOT}/downloads/jdk.tar.gz"
44
+ rm -rf "${JDK}" && mkdir -p "${JDK}"
45
+ tar -xzf "${ROOT}/downloads/jdk.tar.gz" -C "${JDK}" --strip-components=1
46
+
47
+ SDK=${ROOT}/android-sdk
48
+ fetch "$(field 'f.toolchain.androidCommandLineTools.url')" \
49
+ "$(field 'f.toolchain.androidCommandLineTools.sha256')" "${ROOT}/downloads/cmdline-tools.zip"
50
+ rm -rf "${SDK}/cmdline-tools" && mkdir -p "${SDK}/cmdline-tools"
51
+ unzip -q "${ROOT}/downloads/cmdline-tools.zip" -d "${SDK}/cmdline-tools"
52
+ mv "${SDK}/cmdline-tools/cmdline-tools" "${SDK}/cmdline-tools/latest"
53
+ # the compose build downloads the platforms it configures against, which needs
54
+ # the sdk licenses accepted once
55
+ JAVA_HOME=${JDK} "${SDK}/cmdline-tools/latest/bin/sdkmanager" --sdk_root="${SDK}" --licenses < <(yes) >/dev/null 2>&1
56
+
57
+ export JAVA_HOME=${JDK} ANDROIDX_JDK21=${JDK} ANDROID_HOME=${SDK} ANDROID_SDK_ROOT=${SDK}
58
+ export GRADLE_USER_HOME=${ROOT}/gradle-home
59
+ M2=${ROOT}/m2
60
+
61
+ # fetches one upstream at its pinned commit, discards anything a previous run
62
+ # left in tracked files, and applies its patch after checking the patch hash.
63
+ # sets SOURCE rather than printing it: a command substitution would drop
64
+ # errexit and build on past a failed checkout or apply
65
+ checkout() {
66
+ local index=$1
67
+ local name repository commit patch patch_sha256 dir
68
+ name=$(field "f.upstreams[${index}].name")
69
+ repository=$(field "f.upstreams[${index}].repository")
70
+ commit=$(field "f.upstreams[${index}].commit")
71
+ patch=${FORK}/$(field "f.upstreams[${index}].patch")
72
+ patch_sha256=$(field "f.upstreams[${index}].patchSha256")
73
+ dir=${ROOT}/src/${name}
74
+ if ! echo "${patch_sha256} ${patch}" | sha256sum -c --status; then
75
+ echo "${patch} does not match fork.json patchSha256" >&2
76
+ exit 2
77
+ fi
78
+ if [[ ! -d "${dir}/.git" ]]; then
79
+ git init -q "${dir}"
80
+ git -C "${dir}" remote add origin "${repository}"
81
+ fi
82
+ if ! git -C "${dir}" cat-file -e "${commit}^{commit}" 2>/dev/null; then
83
+ git -C "${dir}" fetch -q --depth 1 origin "${commit}"
84
+ fi
85
+ git -C "${dir}" checkout -q -f --detach "${commit}"
86
+ git -C "${dir}" clean -fdq
87
+ if [[ $(git -C "${dir}" rev-parse HEAD) != "${commit}" ]]; then
88
+ echo "${name} is not at ${commit}" >&2
89
+ exit 2
90
+ fi
91
+ git -C "${dir}" apply "${patch}"
92
+ SOURCE=${dir}
93
+ }
94
+
95
+ gradle() {
96
+ ./gradlew --no-daemon --console=plain --max-workers=6 \
97
+ "-Dorg.gradle.jvmargs=-Xmx10g -XX:+UseParallelGC -Dfile.encoding=UTF-8" \
98
+ -Pkotlin.compiler.execution.strategy=in-process \
99
+ "-Dmaven.repo.local=${M2}" "$@"
100
+ }
101
+
102
+ rm -rf "${DELIVER}" "${M2}"
103
+ mkdir -p "${DELIVER}"
104
+
105
+ checkout 0
106
+ (
107
+ cd "${SOURCE}"
108
+ gradle -Pcompose.platforms=web -Pjetbrains.publication.version.COMPOSE=1.13.0-alpha01 \
109
+ :compose:ui:ui:publishWasmJsPublicationToMavenLocal \
110
+ :compose:ui:ui-text:publishWasmJsPublicationToMavenLocal
111
+ )
112
+
113
+ checkout 1
114
+ (
115
+ cd "${SOURCE}/skiko"
116
+ gradle -Pdeploy.version=0.152.0-alpha02 -Pdeploy.release=true \
117
+ -Pskiko.wasm.enabled=true -Pskiko.awt.enabled=false \
118
+ :publishWasmJsPublicationToMavenLocal
119
+ )
120
+
121
+ cp "${M2}/org/jetbrains/compose/ui/ui-wasm-js/1.13.0-alpha01/ui-wasm-js-1.13.0-alpha01.klib" \
122
+ "${M2}/org/jetbrains/compose/ui/ui-text-wasm-js/1.13.0-alpha01/ui-text-wasm-js-1.13.0-alpha01.klib" \
123
+ "${M2}/org/jetbrains/skiko/skiko-wasm-js/0.152.0-alpha02/skiko-wasm-js-0.152.0-alpha02.klib" \
124
+ "${DELIVER}/"
125
+ # the record travels with the klibs it describes, so publishing attaches what
126
+ # this build used, not whatever the checkout holds later
127
+ cp "${FORK}/fork.json" "${FORK}/LICENSE" "${FORK}/NOTICE" "${FORK}"/*.patch "${DELIVER}/"
128
+ (cd "${DELIVER}" && sha256sum -- *.klib > klibs.sha256 && cat klibs.sha256)
@@ -0,0 +1,96 @@
1
+ diff --git a/compose/ui/ui-text/src/webMain/kotlin/androidx/compose/ui/text/intl/PlatformLocale.web.kt b/compose/ui/ui-text/src/webMain/kotlin/androidx/compose/ui/text/intl/PlatformLocale.web.kt
2
+ index 6e80e51..28f1de1 100644
3
+ --- a/compose/ui/ui-text/src/webMain/kotlin/androidx/compose/ui/text/intl/PlatformLocale.web.kt
4
+ +++ b/compose/ui/ui-text/src/webMain/kotlin/androidx/compose/ui/text/intl/PlatformLocale.web.kt
5
+ @@ -12,6 +12,10 @@
6
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7
+ * See the License for the specific language governing permissions and
8
+ * limitations under the License.
9
+ + *
10
+ + * Modified for Peach (https://peachsim.com): reads worker-safe globals through
11
+ + * globalThis instead of window, so this code runs in a Web Worker as well as a
12
+ + * document. See the Peach fork record for the patch and upstream revision.
13
+ */
14
+
15
+ package androidx.compose.ui.text.intl
16
+ @@ -127,4 +131,4 @@ private fun userPreferredLanguages(): List<String> {
17
+
18
+ @OptIn(ExperimentalWasmJsInterop::class)
19
+ private fun getUserPreferredLanguagesAsArray(): JsArray<JsString> =
20
+ - js("window.navigator.languages")
21
+
22
+ + js("globalThis.navigator.languages")
23
+
24
+ diff --git a/compose/ui/ui/src/wasmJsMain/kotlin/androidx/compose/ui/Actuals.wasm.kt b/compose/ui/ui/src/wasmJsMain/kotlin/androidx/compose/ui/Actuals.wasm.kt
25
+ index 26aa8ea..aa4f6d4 100644
26
+ --- a/compose/ui/ui/src/wasmJsMain/kotlin/androidx/compose/ui/Actuals.wasm.kt
27
+ +++ b/compose/ui/ui/src/wasmJsMain/kotlin/androidx/compose/ui/Actuals.wasm.kt
28
+ @@ -12,16 +12,22 @@
29
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30
+ * See the License for the specific language governing permissions and
31
+ * limitations under the License.
32
+ + *
33
+ + * Modified for Peach (https://peachsim.com): reads worker-safe globals through
34
+ + * globalThis instead of window, so this code runs in a Web Worker as well as a
35
+ + * document. See the Peach fork record for the patch and upstream revision.
36
+ */
37
+
38
+ package androidx.compose.ui
39
+
40
+ -import kotlinx.browser.window
41
+ +import kotlin.js.js
42
+
43
+ internal actual fun areObjectsOfSameType(a: Any, b: Any): Boolean {
44
+ return a === b || a::class == b::class
45
+ }
46
+
47
+ internal actual fun currentTimeMillis(): Long {
48
+ - return window.performance.now().toLong()
49
+ -}
50
+
51
+ + return performanceNow().toLong()
52
+ +}
53
+ +
54
+ +private fun performanceNow(): Double = js("globalThis.performance.now()")
55
+ diff --git a/compose/ui/ui/src/webMain/kotlin/androidx/compose/ui/platform/PlatformClipboard.web.kt b/compose/ui/ui/src/webMain/kotlin/androidx/compose/ui/platform/PlatformClipboard.web.kt
56
+ index 7aa3e26..47e20a8 100644
57
+ --- a/compose/ui/ui/src/webMain/kotlin/androidx/compose/ui/platform/PlatformClipboard.web.kt
58
+ +++ b/compose/ui/ui/src/webMain/kotlin/androidx/compose/ui/platform/PlatformClipboard.web.kt
59
+ @@ -12,6 +12,10 @@
60
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
61
+ * See the License for the specific language governing permissions and
62
+ * limitations under the License.
63
+ + *
64
+ + * Modified for Peach (https://peachsim.com): reads worker-safe globals through
65
+ + * globalThis instead of window, so this code runs in a Web Worker as well as a
66
+ + * document. See the Peach fork record for the patch and upstream revision.
67
+ */
68
+
69
+ package androidx.compose.ui.platform
70
+ @@ -34,20 +38,20 @@ actual typealias NativeClipboard = W3CTemporaryClipboard
71
+ internal fun isFullClipboardApiSupported(): Boolean =
72
+ js(
73
+ """Boolean(
74
+ - window.navigator.clipboard &&
75
+ - window.navigator.clipboard.write &&
76
+ - window.navigator.clipboard.read &&
77
+ + globalThis.navigator.clipboard &&
78
+ + globalThis.navigator.clipboard.write &&
79
+ + globalThis.navigator.clipboard.read &&
80
+ typeof(ClipboardItem) !== 'undefined'
81
+ )
82
+ """
83
+ )
84
+
85
+ -internal fun isSecureContext(): Boolean = js("window.isSecureContext === true")
86
+ +internal fun isSecureContext(): Boolean = js("globalThis.isSecureContext === true")
87
+
88
+ internal fun isFallbackWriteTextApiAvailable(): Boolean =
89
+ - js("Boolean(window.navigator.clipboard && window.navigator.clipboard.writeText)")
90
+ + js("Boolean(globalThis.navigator.clipboard && globalThis.navigator.clipboard.writeText)")
91
+
92
+ -internal fun getW3CClipboard(): NativeClipboard = js("window.navigator.clipboard")
93
+ +internal fun getW3CClipboard(): NativeClipboard = js("globalThis.navigator.clipboard")
94
+
95
+ /**
96
+ * https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API
@@ -0,0 +1,33 @@
1
+ {
2
+ "toolchain": {
3
+ "jdk": {
4
+ "release": "jdk-21.0.12.1+1",
5
+ "url": "https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12.1%2B1/OpenJDK21U-jdk_x64_linux_hotspot_21.0.12.1_1.tar.gz",
6
+ "sha256": "ce79869e1307ed8ee1e2baa86a412b1eb5b75d10a01006d788a6f968bcfaee94"
7
+ },
8
+ "androidCommandLineTools": {
9
+ "url": "https://dl.google.com/android/repository/commandlinetools-linux-16111833_latest.zip",
10
+ "sha256": "0877a1d048fe4a24efe2eff536ca4223f7adeb58648bb81909d33c446918cfa8"
11
+ }
12
+ },
13
+ "upstreams": [
14
+ {
15
+ "name": "compose-multiplatform-core",
16
+ "repository": "https://github.com/JetBrains/compose-multiplatform-core",
17
+ "license": "Apache-2.0",
18
+ "tag": "v1.13.0-alpha01",
19
+ "commit": "a9e47e8aa04c95cfe572ab4297c770f3cbfb234e",
20
+ "patch": "compose-worker-globals.patch",
21
+ "patchSha256": "7f7df0788145b8d44c32a9ca7746cf254c363beca816922f84d73faa0effed5a"
22
+ },
23
+ {
24
+ "name": "skiko",
25
+ "repository": "https://github.com/JetBrains/skiko",
26
+ "license": "Apache-2.0",
27
+ "tag": "v0.152.0-alpha02",
28
+ "commit": "96378296bb23c23c5f30cd2b0d42d6f8fdeff730",
29
+ "patch": "skiko-worker-clock.patch",
30
+ "patchSha256": "d55007f3aa4c2b61e44f036bdb43f37ab38455bf800664fdb6598955874d10da"
31
+ }
32
+ ]
33
+ }
@@ -0,0 +1,77 @@
1
+ // uploads the klibs one build.sh run delivered to R2, each under its sha256
2
+ // beside the record that run copied (patches, fork.json, LICENSE, NOTICE,
3
+ // klibs.sha256), and prints the toolchain.json entries that name them. keys
4
+ // are immutable: an existing object with other bytes stops the publish. needs
5
+ // R2 credentials; reads are public.
6
+ //
7
+ // bun packages/peachsim/kotlin/fork/publish.ts .remote-out/kotlin-fork
8
+
9
+ import { createHash } from 'node:crypto'
10
+ import { readFileSync, readdirSync } from 'node:fs'
11
+ import path from 'node:path'
12
+ import { RNX_PUBLIC } from '../../../../src/site/rnxPublicContract'
13
+ import { readR2Object, uploadToR2 } from '../../../peach-engine/scripts/s3'
14
+
15
+ const delivered = process.argv[2]
16
+ if (!delivered) throw new Error('usage: publish.ts <directory build.sh delivered>')
17
+
18
+ const IMMUTABLE = 'public, max-age=31536000, immutable'
19
+ const sha256 = (bytes: Buffer) => createHash('sha256').update(bytes).digest('hex')
20
+
21
+ const files = readdirSync(delivered)
22
+ const record = files.filter(
23
+ (name) =>
24
+ name.endsWith('.patch') ||
25
+ ['fork.json', 'LICENSE', 'NOTICE', 'klibs.sha256'].includes(name),
26
+ )
27
+ if (record.length !== files.filter((name) => !name.endsWith('.klib')).length)
28
+ throw new Error(`${delivered} holds files build.sh does not deliver`)
29
+ if (!record.includes('klibs.sha256') || !record.includes('fork.json'))
30
+ throw new Error(`${delivered} is not a build.sh delivery`)
31
+
32
+ // the klibs are exactly the ones the build hashed
33
+ const built = new Map(
34
+ readFileSync(path.join(delivered, 'klibs.sha256'), 'utf8')
35
+ .trim()
36
+ .split('\n')
37
+ .map((line) => {
38
+ const [hash, name] = line.split(/\s+/)
39
+ if (!hash || !name) throw new Error(`malformed klibs.sha256 line: ${line}`)
40
+ return [name, hash]
41
+ }),
42
+ )
43
+ const klibs = files.filter((name) => name.endsWith('.klib')).sort()
44
+ if (klibs.length === 0 || klibs.length !== built.size)
45
+ throw new Error(`${delivered} klibs do not match klibs.sha256`)
46
+
47
+ async function put(key: string, bytes: Buffer, contentType: string) {
48
+ const existing = await readR2Object(key, 120000)
49
+ if (existing) {
50
+ if (!existing.equals(bytes)) throw new Error(`${key} already holds other bytes`)
51
+ return
52
+ }
53
+ await uploadToR2(key, bytes, contentType, IMMUTABLE)
54
+ }
55
+
56
+ const entries = []
57
+ for (const name of klibs) {
58
+ const bytes = readFileSync(path.join(delivered, name))
59
+ const hash = sha256(bytes)
60
+ if (built.get(name) !== hash)
61
+ throw new Error(`${name} is not the klib the build hashed`)
62
+ const prefix = `peach-kotlin-fork/${hash}`
63
+ await put(`${prefix}/${name}`, bytes, 'application/octet-stream')
64
+ for (const file of record)
65
+ await put(
66
+ `${prefix}/${file}`,
67
+ readFileSync(path.join(delivered, file)),
68
+ 'text/plain; charset=utf-8',
69
+ )
70
+ // the loader caches a library by its name, so the name carries the hash
71
+ entries.push({
72
+ name: name.replace(/\.klib$/, `-peach-${hash.slice(0, 12)}.klib`),
73
+ url: `${RNX_PUBLIC.publicR2Origin}/${prefix}/${name}`,
74
+ sha256: hash,
75
+ })
76
+ }
77
+ console.log(JSON.stringify(entries, null, 2))
@@ -0,0 +1,33 @@
1
+ diff --git a/skiko/src/webMain/kotlin/org/jetbrains/skiko/Actuals.web.kt b/skiko/src/webMain/kotlin/org/jetbrains/skiko/Actuals.web.kt
2
+ index 366ed37..d56c267 100644
3
+ --- a/skiko/src/webMain/kotlin/org/jetbrains/skiko/Actuals.web.kt
4
+ +++ b/skiko/src/webMain/kotlin/org/jetbrains/skiko/Actuals.web.kt
5
+ @@ -1,3 +1,8 @@
6
+ +// Modified for Peach (https://peachsim.com): reads the worker-safe
7
+ +// globalThis.performance clock instead of window.performance, so this code
8
+ +// runs in a Web Worker as well as a document. See the Peach fork record for
9
+ +// the patch and upstream revision.
10
+ +
11
+ package org.jetbrains.skiko
12
+
13
+ import org.w3c.dom.HTMLElement
14
+ @@ -5,7 +10,7 @@ import org.w3c.dom.HTMLElement
15
+ internal actual inline fun <R> maybeSynchronized(lock: Any, block: () -> R): R =
16
+ block()
17
+
18
+ -actual fun currentNanoTime(): Long = currentNanoTimeWindowPerformance().toLong()
19
+ +actual fun currentNanoTime(): Long = currentNanoTimePerformance().toLong()
20
+
21
+ internal actual fun loadOpenGLLibrary() {
22
+ // Nothing to do here
23
+ @@ -15,8 +20,8 @@ internal actual fun loadAngleLibrary() {
24
+ // Nothing to do here
25
+ }
26
+
27
+ -private fun currentNanoTimeWindowPerformance() : Double =
28
+ +private fun currentNanoTimePerformance() : Double =
29
+ //language=JavaScript
30
+ - js("window.performance.now() * 1000000")
31
+ + js("globalThis.performance.now() * 1000000")
32
+
33
+ annotation class WebImport(val name : String)