peachsim 0.1.1655 → 0.1.1660

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 (237) hide show
  1. package/cli/app-config.ts +4 -0
  2. package/cli/app-stubs.ts +43 -6
  3. package/cli/commands/inspect/shared.ts +5 -2
  4. package/cli/commands/inspect/url.ts +2 -1
  5. package/cli/commands/screenshot.ts +5 -5
  6. package/cli/commands/state.ts +9 -6
  7. package/cli/outbound-endpoints.ts +9 -1
  8. package/cli/output-redaction.ts +49 -0
  9. package/detox/index.ts +0 -1
  10. package/dist-lib/agent-daemon-client.cjs +1 -1
  11. package/dist-lib/agent-events.cjs +1 -1
  12. package/dist-lib/attached-projects.cjs +1 -1
  13. package/dist-lib/auth/shared-session.cjs +1 -1
  14. package/dist-lib/backend-origin.cjs +1 -1
  15. package/dist-lib/beta.cjs +1 -1
  16. package/dist-lib/beta.mjs +1 -1
  17. package/dist-lib/bridge-constants.cjs +1 -1
  18. package/dist-lib/bridge-contract-input.cjs +1 -1
  19. package/dist-lib/bridge-contract-input.mjs +1 -1
  20. package/dist-lib/bridge-contract.cjs +1 -1
  21. package/dist-lib/bridge-contract.mjs +1 -1
  22. package/dist-lib/bundle-channel.cjs +12772 -1132
  23. package/dist-lib/capture-contract.cjs +1 -1
  24. package/dist-lib/capture-contract.mjs +1 -1
  25. package/dist-lib/cloud-contract.cjs +1 -1
  26. package/dist-lib/cloud-contract.mjs +1 -1
  27. package/dist-lib/cloud-test-args.cjs +1 -1
  28. package/dist-lib/cloud-test-args.mjs +1 -1
  29. package/dist-lib/cloud.cjs +1 -1
  30. package/dist-lib/cloud.mjs +1 -1
  31. package/dist-lib/config.cjs +29 -5
  32. package/dist-lib/config.mjs +29 -5
  33. package/dist-lib/detox/index.cjs +19 -6
  34. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  35. package/dist-lib/expo-swift-bundle.cjs +10411 -73
  36. package/dist-lib/expo-swift-metadata.cjs +1 -1
  37. package/dist-lib/expo-swift-metadata.mjs +1 -1
  38. package/dist-lib/home-paths.cjs +1 -1
  39. package/dist-lib/host/bridge-host.cjs +11220 -670
  40. package/dist-lib/host/fetch-proxy-handler.cjs +260 -197
  41. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  42. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  43. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  44. package/dist-lib/host/websocket-proxy.cjs +1 -1
  45. package/dist-lib/index.cjs +653 -338
  46. package/dist-lib/jump-to-source-babel.cjs +1 -1
  47. package/dist-lib/jump-to-source-native.cjs +1 -1
  48. package/dist-lib/kotlin-host.cjs +443 -312
  49. package/dist-lib/menu.cjs +1 -1
  50. package/dist-lib/menu.mjs +1 -1
  51. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  52. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  53. package/dist-lib/metro-production-bundle.cjs +1 -1
  54. package/dist-lib/metro-production-bundle.mjs +1 -1
  55. package/dist-lib/metro.cjs +548 -163
  56. package/dist-lib/native-app-identity-project.cjs +179 -33
  57. package/dist-lib/native-app-identity-project.mjs +179 -33
  58. package/dist-lib/native-app-identity.cjs +1 -1
  59. package/dist-lib/native-app-identity.mjs +1 -1
  60. package/dist-lib/native-firebase-metadata.cjs +1 -1
  61. package/dist-lib/native-firebase-metadata.mjs +1 -1
  62. package/dist-lib/plist.cjs +1 -1
  63. package/dist-lib/plist.mjs +1 -1
  64. package/dist-lib/profiles.cjs +1 -1
  65. package/dist-lib/public-brand.cjs +1 -1
  66. package/dist-lib/public-origins-lib-esm.json +23 -23
  67. package/dist-lib/public-origins-lib.json +96 -63
  68. package/dist-lib/react-native-host-modules.cjs +1 -1
  69. package/dist-lib/react-native-host-modules.mjs +1 -1
  70. package/dist-lib/scripts/dev-server-scanner.cjs +2 -2
  71. package/dist-lib/sdk.cjs +1 -1
  72. package/dist-lib/sdk.mjs +1 -1
  73. package/dist-lib/skills.cjs +12193 -1448
  74. package/dist-lib/swift-compile.cjs +10348 -172
  75. package/dist-lib/swift-compile.mjs +10348 -172
  76. package/dist-lib/swift-package.cjs +1 -1
  77. package/dist-lib/swift-package.mjs +1 -1
  78. package/dist-lib/swift-submit.cjs +1 -1
  79. package/dist-lib/swift-submit.mjs +1 -1
  80. package/dist-lib/swift-toolchain.cjs +1 -1
  81. package/dist-lib/swift.cjs +1 -1
  82. package/dist-lib/vite-swift.cjs +10411 -73
  83. package/dist-lib/vite.cjs +149 -163
  84. package/dist-lib/worklet-executable.cjs +1 -1
  85. package/dist-lib/worklet-executable.mjs +1 -1
  86. package/dist-types/packages/peach-compat/src/stubs/native-seams/react-native-gesture-handler.d.ts +2 -0
  87. package/dist-types/packages/peach-engine/src/engine/app-font-registry.d.ts +14 -0
  88. package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +8 -0
  89. package/dist-types/packages/peach-engine/src/engine/node.d.ts +3 -0
  90. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +21 -0
  91. package/dist-types/packages/peach-engine/src/render-worker/gesture-seam-protocol.d.ts +2 -1
  92. package/dist-types/packages/peach-engine/src/render-worker/test-bridge-protocol.d.ts +1 -1
  93. package/dist-types/packages/peach-engine/src/rolldown-bundle-inventory.d.ts +1 -0
  94. package/dist-types/packages/peach-globals/src/index.d.ts +34 -0
  95. package/kotlin/README.md +38 -23
  96. package/kotlin/sdk.tar.gz +0 -0
  97. package/package.json +2 -12
  98. package/runtime-companion.json +1 -1
  99. package/src/bundleGlobalFooter.ts +0 -2
  100. package/src/config.ts +54 -2
  101. package/src/configured-bundle-producer.ts +7 -1
  102. package/src/host/fetch-proxy-handler.ts +14 -50
  103. package/src/host/rolldown-bundle-forward.ts +71 -0
  104. package/src/installed-package-versions.ts +54 -2
  105. package/src/kotlin-host.ts +138 -285
  106. package/src/kotlin-module.ts +4 -7
  107. package/src/kotlin-sdk.ts +81 -0
  108. package/src/kotlin-toolchain.ts +152 -0
  109. package/src/kotlin-view-models.ts +1 -1
  110. package/src/kotlinSdkContract.ts +113 -0
  111. package/src/nitro-adapter.lock.json +3 -3
  112. package/src/nitro-bundle.ts +18 -4
  113. package/src/nitro-compile.ts +5 -1
  114. package/src/nitro-source.ts +112 -28
  115. package/src/nitroContract.ts +16 -4
  116. package/src/stub-pattern-matcher.ts +4 -0
  117. package/src/swift-compile.ts +44 -14
  118. package/src/swift-host.ts +2 -1
  119. package/src/swift-objc-compile.ts +117 -4
  120. package/src/swift-objc-sdk.ts +10215 -59
  121. package/src/swift-objc-standin.ts +5 -2
  122. package/src/vite-plugin-one.ts +73 -134
  123. package/src/worker-system-chunks.ts +14 -4
  124. package/src/xcode-project.ts +261 -34
  125. package/kotlin/AndroidViewSources/android/content/Context.kt +0 -22
  126. package/kotlin/AndroidViewSources/android/content/res/Configuration.kt +0 -25
  127. package/kotlin/AndroidViewSources/android/content/res/Resources.kt +0 -72
  128. package/kotlin/AndroidViewSources/android/graphics/Canvas.kt +0 -22
  129. package/kotlin/AndroidViewSources/android/graphics/Color.kt +0 -13
  130. package/kotlin/AndroidViewSources/android/graphics/Paint.kt +0 -18
  131. package/kotlin/AndroidViewSources/android/util/DisplayMetrics.kt +0 -12
  132. package/kotlin/AndroidViewSources/android/view/View.kt +0 -211
  133. package/kotlin/AndroidViewSources/android/widget/FrameLayout.kt +0 -61
  134. package/kotlin/AndroidViewSources/android/widget/LinearLayout.kt +0 -49
  135. package/kotlin/AndroidViewSources/dev/peach/app/JavaFormat.kt +0 -272
  136. package/kotlin/AppSources/android/app/Activity.kt +0 -174
  137. package/kotlin/AppSources/android/app/Application.kt +0 -11
  138. package/kotlin/AppSources/android/app/UiModeManager.kt +0 -9
  139. package/kotlin/AppSources/android/content/Intent.kt +0 -16
  140. package/kotlin/AppSources/android/os/Bundle.kt +0 -11
  141. package/kotlin/AppSources/android/util/SuperNotCalledException.kt +0 -3
  142. package/kotlin/AppSources/android/view/Window.kt +0 -182
  143. package/kotlin/AppSources/android/view/WindowInsets.kt +0 -9
  144. package/kotlin/AppSources/android/view/WindowInsetsController.kt +0 -17
  145. package/kotlin/AppSources/android/view/WindowManager.kt +0 -16
  146. package/kotlin/AppSources/android/window/BackEvent.kt +0 -24
  147. package/kotlin/AppSources/android/window/OnBackAnimationCallback.kt +0 -7
  148. package/kotlin/AppSources/android/window/OnBackInvokedDispatcher.kt +0 -84
  149. package/kotlin/AppSources/androidx/activity/ActivityFlags.kt +0 -9
  150. package/kotlin/AppSources/androidx/activity/ActivityViewModelLazy.kt +0 -21
  151. package/kotlin/AppSources/androidx/activity/BackEventCompat.kt +0 -43
  152. package/kotlin/AppSources/androidx/activity/ComponentActivity.kt +0 -122
  153. package/kotlin/AppSources/androidx/activity/EdgeToEdge.kt +0 -75
  154. package/kotlin/AppSources/androidx/activity/ExperimentalActivityApi.kt +0 -6
  155. package/kotlin/AppSources/androidx/activity/OnBackPressedCallback.kt +0 -69
  156. package/kotlin/AppSources/androidx/activity/OnBackPressedDispatcher.kt +0 -144
  157. package/kotlin/AppSources/androidx/activity/OnBackPressedDispatcherOwner.kt +0 -7
  158. package/kotlin/AppSources/androidx/activity/compose/BackHandler.kt +0 -86
  159. package/kotlin/AppSources/androidx/activity/compose/ComponentActivity.kt +0 -29
  160. package/kotlin/AppSources/androidx/activity/compose/internal/BackHandlerCompat.kt +0 -38
  161. package/kotlin/AppSources/androidx/activity/compose/internal/BackHandlerDispatcherCompat.kt +0 -27
  162. package/kotlin/AppSources/androidx/compose/foundation/layout/WindowInsets.kt +0 -15
  163. package/kotlin/AppSources/androidx/compose/ui/platform/AndroidCompositionLocals.kt +0 -27
  164. package/kotlin/AppSources/androidx/compose/ui/platform/ComposeView.kt +0 -68
  165. package/kotlin/AppSources/androidx/compose/ui/res/ColorResources.kt +0 -16
  166. package/kotlin/AppSources/androidx/compose/ui/res/PainterResources.kt +0 -70
  167. package/kotlin/AppSources/androidx/compose/ui/res/StringResources.kt +0 -38
  168. package/kotlin/AppSources/androidx/core/view/WindowCompat.kt +0 -32
  169. package/kotlin/AppSources/androidx/lifecycle/AndroidViewModel.kt +0 -10
  170. package/kotlin/AppSources/dev/peach/app/PeachApp.kt +0 -388
  171. package/kotlin/AppSources/dev/peach/app/PeachDrawable.kt +0 -102
  172. package/kotlin/AppSources/dev/peach/app/PeachWindowHost.kt +0 -14
  173. package/kotlin/CompilerSources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar +0 -1
  174. package/kotlin/CompilerSources/PeachJniIncoming.kt +0 -243
  175. package/kotlin/CompilerSources/PeachJniPlugin.kt +0 -116
  176. package/kotlin/ComposeSources/PeachComposeHost.kt +0 -724
  177. package/kotlin/ComposeSources/PeachMagnifier.kt +0 -185
  178. package/kotlin/ComposeSources/PeachSemantics.kt +0 -127
  179. package/kotlin/ExpoComposeSources/PeachAndroidView.kt +0 -103
  180. package/kotlin/ExpoComposeSources/PeachExpoViewMount.kt +0 -24
  181. package/kotlin/ExpoComposeSources/dev/peach/expo/PeachExpoCompose.kt +0 -28
  182. package/kotlin/ExpoComposeSources/expo/modules/kotlin/views/ExpoComposeView.kt +0 -70
  183. package/kotlin/ExpoSources/dev/peach/expo/PeachExpoRuntime.kt +0 -516
  184. package/kotlin/ExpoSources/dev/peach/expo/PeachExpoTypes.kt +0 -173
  185. package/kotlin/ExpoSources/expo/modules/kotlin/AppContext.kt +0 -20
  186. package/kotlin/ExpoSources/expo/modules/kotlin/Promise.kt +0 -19
  187. package/kotlin/ExpoSources/expo/modules/kotlin/classcomponent/ClassComponentBuilder.kt +0 -198
  188. package/kotlin/ExpoSources/expo/modules/kotlin/exception/CodedException.kt +0 -126
  189. package/kotlin/ExpoSources/expo/modules/kotlin/functions/Functions.kt +0 -132
  190. package/kotlin/ExpoSources/expo/modules/kotlin/jni/JavaScriptTypedArray.kt +0 -81
  191. package/kotlin/ExpoSources/expo/modules/kotlin/modules/Module.kt +0 -98
  192. package/kotlin/ExpoSources/expo/modules/kotlin/objects/ObjectDefinitionBuilder.kt +0 -236
  193. package/kotlin/ExpoSources/expo/modules/kotlin/records/Record.kt +0 -12
  194. package/kotlin/ExpoSources/expo/modules/kotlin/runtime/Runtime.kt +0 -9
  195. package/kotlin/ExpoSources/expo/modules/kotlin/sharedobjects/SharedObject.kt +0 -50
  196. package/kotlin/ExpoSources/expo/modules/kotlin/sharedobjects/SharedObjectRegistry.kt +0 -57
  197. package/kotlin/ExpoSources/expo/modules/kotlin/sharedobjects/SharedRef.kt +0 -19
  198. package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/ConcreteTypedArrays.kt +0 -158
  199. package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/GenericTypedArray.kt +0 -8
  200. package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/TypedArray.kt +0 -29
  201. package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/TypedArrayIterator.kt +0 -9
  202. package/kotlin/ExpoSources/expo/modules/kotlin/types/AnyType.kt +0 -155
  203. package/kotlin/ExpoSources/expo/modules/kotlin/types/Either.kt +0 -91
  204. package/kotlin/ExpoSources/expo/modules/kotlin/types/Enumerable.kt +0 -6
  205. package/kotlin/ExpoSources/expo/modules/kotlin/viewevent/ViewEvent.kt +0 -68
  206. package/kotlin/ExpoSources/expo/modules/kotlin/views/ExpoView.kt +0 -20
  207. package/kotlin/ExpoSources/expo/modules/kotlin/views/ViewDefinitionBuilder.kt +0 -72
  208. package/kotlin/ExpoSources/expo/modules/kotlin/views/ViewProps.kt +0 -36
  209. package/kotlin/JniPlatformSources/androidx/annotation/CallSuper.kt +0 -5
  210. package/kotlin/JniPlatformSources/com/facebook/proguard/annotations/DoNotStrip.kt +0 -5
  211. package/kotlin/JniPlatformSources/dalvik/annotation/optimization/FastNative.kt +0 -5
  212. package/kotlin/JniPlatformSources/kotlin/Synchronized.kt +0 -6
  213. package/kotlin/JniPlatformSources/kotlin/jvm/JvmField.kt +0 -5
  214. package/kotlin/JniPlatformSources/kotlin/jvm/JvmStatic.kt +0 -5
  215. package/kotlin/JniSources/com/facebook/jni/HybridData.kt +0 -66
  216. package/kotlin/JniSources/dev/peach/jni/IncomingBindings.kt +0 -157
  217. package/kotlin/JniSources/dev/peach/jni/NativeBindings.kt +0 -77
  218. package/kotlin/JniTransportSources/dev/peach/jni/integration/JniTransport.kt +0 -89
  219. package/kotlin/Sources/android/os/Build.kt +0 -17
  220. package/kotlin/Sources/android/os/Handler.kt +0 -35
  221. package/kotlin/Sources/android/os/Looper.kt +0 -17
  222. package/kotlin/Sources/android/os/MessageQueue.kt +0 -56
  223. package/kotlin/Sources/android/os/SystemClock.kt +0 -14
  224. package/kotlin/Sources/android/util/Log.kt +0 -64
  225. package/kotlin/Sources/androidx/annotation/DrawableRes.kt +0 -14
  226. package/kotlin/Sources/androidx/annotation/Keep.kt +0 -4
  227. package/kotlin/Sources/dev/onejs/one/OneNativeSourceDispatch.kt +0 -7
  228. package/kotlin/Sources/dev/onejs/one/OneNativeSourceViewDispatch.kt +0 -13
  229. package/kotlin/Sources/dev/onejs/one/source/OneModule.kt +0 -4
  230. package/kotlin/Sources/java/lang/Runnable.kt +0 -6
  231. package/kotlin/Sources/java/security/MessageDigest.kt +0 -114
  232. package/kotlin/Sources/java/util/IllegalFormatCodePointException.kt +0 -10
  233. package/kotlin/Sources/java/util/IllegalFormatException.kt +0 -5
  234. package/kotlin/Sources/kotlin/text/StringFormat.kt +0 -9
  235. package/kotlin/Sources/org/json/JSON.kt +0 -307
  236. package/kotlin/tools/abi-classes.main.kts +0 -41
  237. package/kotlin/tools/expo-types.main.kts +0 -127
@@ -13,6 +13,13 @@ import { promisify } from 'node:util'
13
13
  import { parse } from 'acorn'
14
14
  import { rnxHomeDir } from './home-paths'
15
15
  import { isRecord } from './is-record'
16
+ import { installKotlinSdkArchive } from './kotlin-sdk'
17
+ import {
18
+ ensureToolchain,
19
+ fetchVerified,
20
+ kotlinHome,
21
+ readToolchain,
22
+ } from './kotlin-toolchain'
16
23
  import {
17
24
  readAbiClasses,
18
25
  viewModelClasses,
@@ -21,29 +28,19 @@ import {
21
28
  import type { DayNight, DrawableFile } from './android-drawables'
22
29
  import type { ExpoKotlinModules } from './expo-kotlin-host'
23
30
  import type { KotlinAppProject, KotlinWindowTheme } from './kotlin-app'
31
+ import type { KotlinSdkProfile, KotlinToolchain } from './kotlinSdkContract'
24
32
  import type { ServerResponse } from 'node:http'
25
33
 
26
34
  const run = promisify(execFile)
27
35
 
28
- const KOTLIN_ARTIFACT_PREFIX = '/__peach/kotlin-artifact/'
29
-
30
- interface Download {
31
- url: string
32
- sha256: string
36
+ function loadKotlinSdk(moduleRoot: string, toolchain: KotlinToolchain) {
37
+ return installKotlinSdkArchive(
38
+ fs.readFileSync(path.join(moduleRoot, 'sdk.tar.gz')),
39
+ toolchain.compiler.sha256,
40
+ )
33
41
  }
34
42
 
35
- interface KotlinToolchain {
36
- compiler: Download & { version: string }
37
- libraries: (Download & { name: string })[]
38
- composeLibraries: (Download & { name: string })[]
39
- composeRuntime: Download & { name: string }
40
- composeJsLibraries: (Download & {
41
- name: string
42
- module: string
43
- file: string
44
- archiveEntry: string
45
- })[]
46
- }
43
+ const KOTLIN_ARTIFACT_PREFIX = '/__peach/kotlin-artifact/'
47
44
 
48
45
  export interface KotlinArtifact {
49
46
  // the module the seam imports; it loads its wasm beside it
@@ -51,130 +48,6 @@ export interface KotlinArtifact {
51
48
  hash: string
52
49
  }
53
50
 
54
- function readToolchain(moduleRoot: string): KotlinToolchain {
55
- const parsed: unknown = JSON.parse(
56
- fs.readFileSync(path.join(moduleRoot, 'toolchain.json'), 'utf8'),
57
- )
58
- const download = (value: unknown): Download => {
59
- if (
60
- !isRecord(value) ||
61
- typeof value.url !== 'string' ||
62
- typeof value.sha256 !== 'string'
63
- )
64
- throw new Error(
65
- 'peachsim kotlin/toolchain.json names a download without url and sha256',
66
- )
67
- return { url: value.url, sha256: value.sha256 }
68
- }
69
- if (
70
- !isRecord(parsed) ||
71
- !isRecord(parsed.compiler) ||
72
- !Array.isArray(parsed.libraries) ||
73
- !Array.isArray(parsed.composeLibraries) ||
74
- !Array.isArray(parsed.composeJsLibraries) ||
75
- !isRecord(parsed.composeRuntime) ||
76
- typeof parsed.composeRuntime.name !== 'string'
77
- )
78
- throw new Error('peachsim kotlin/toolchain.json has no compiler and libraries')
79
- const version = parsed.compiler.version
80
- if (typeof version !== 'string')
81
- throw new Error('peachsim kotlin/toolchain.json has no compiler version')
82
- const libraries = (values: unknown[]) =>
83
- values.map((library) => {
84
- if (!isRecord(library) || typeof library.name !== 'string')
85
- throw new Error('peachsim kotlin/toolchain.json names a library without a name')
86
- return { ...download(library), name: library.name }
87
- })
88
- return {
89
- compiler: { ...download(parsed.compiler), version },
90
- libraries: libraries(parsed.libraries),
91
- composeLibraries: libraries(parsed.composeLibraries),
92
- composeRuntime: {
93
- ...download(parsed.composeRuntime),
94
- name: parsed.composeRuntime.name,
95
- },
96
- composeJsLibraries: parsed.composeJsLibraries.map((library) => {
97
- if (
98
- !isRecord(library) ||
99
- typeof library.name !== 'string' ||
100
- typeof library.module !== 'string' ||
101
- typeof library.file !== 'string' ||
102
- typeof library.archiveEntry !== 'string'
103
- )
104
- throw new Error('peachsim kotlin/toolchain.json has an incomplete JS library')
105
- return {
106
- ...download(library),
107
- name: library.name,
108
- module: library.module,
109
- file: library.file,
110
- archiveEntry: library.archiveEntry,
111
- }
112
- }),
113
- }
114
- }
115
-
116
- function kotlinHome(): string {
117
- return path.join(rnxHomeDir(), 'kotlin')
118
- }
119
-
120
- async function fetchVerified(download: Download, target: string): Promise<void> {
121
- if (fs.existsSync(target)) return
122
- const response = await fetch(download.url)
123
- if (!response.ok) throw new Error(`${download.url} answered ${response.status}`)
124
- const bytes = Buffer.from(await response.arrayBuffer())
125
- const digest = createHash('sha256').update(bytes).digest('hex')
126
- if (digest !== download.sha256)
127
- throw new Error(`${download.url} has sha256 ${digest}, expected ${download.sha256}`)
128
- fs.mkdirSync(path.dirname(target), { recursive: true })
129
- const partial = `${target}.${process.pid}.partial`
130
- fs.writeFileSync(partial, bytes)
131
- fs.renameSync(partial, target)
132
- }
133
-
134
- const toolchains = new Map<string, Promise<{ kotlinc: string; libraries: string[] }>>()
135
-
136
- // the pinned compiler and the coroutines klibs, fetched once and checked
137
- // against toolchain.json
138
- function ensureToolchain(
139
- toolchain: KotlinToolchain,
140
- ): Promise<{ kotlinc: string; libraries: string[] }> {
141
- const key = JSON.stringify(toolchain)
142
- const pending = toolchains.get(key)
143
- if (pending) return pending
144
- const ready = (async () => {
145
- const dir = path.join(kotlinHome(), toolchain.compiler.version)
146
- const kotlinc = path.join(dir, 'kotlinc', 'bin', 'kotlinc-wasm')
147
- if (!fs.existsSync(kotlinc)) {
148
- const zip = path.join(dir, 'kotlin-compiler.zip')
149
- await fetchVerified(toolchain.compiler, zip)
150
- await run('unzip', ['-q', '-o', zip, '-d', dir])
151
- fs.rmSync(zip)
152
- }
153
- // kotlinc runs on the JVM an android build already needs; it finds it
154
- // through JAVA_HOME or PATH, as gradle does
155
- const java = process.env.JAVA_HOME
156
- ? path.join(process.env.JAVA_HOME, 'bin', 'java')
157
- : 'java'
158
- await run(java, ['-version']).catch(() => {
159
- throw new Error(
160
- `Kotlin in Peach compiles with kotlinc, which needs a Java runtime (17 or newer, as android builds use); ${process.env.JAVA_HOME ? `JAVA_HOME ${process.env.JAVA_HOME} has none` : 'set JAVA_HOME or put java on PATH'}`,
161
- )
162
- })
163
- const libraries = [path.join(dir, 'kotlinc', 'lib', 'kotlin-stdlib-wasm-js.klib')]
164
- for (const library of toolchain.libraries) {
165
- const target = path.join(dir, library.name)
166
- await fetchVerified(library, target)
167
- libraries.push(target)
168
- }
169
- return { kotlinc, libraries }
170
- })().catch((error: unknown) => {
171
- toolchains.delete(key)
172
- throw error
173
- })
174
- toolchains.set(key, ready)
175
- return ready
176
- }
177
-
178
51
  // the kotlin language the device compiles the app with: react native's
179
52
  // android gradle build pins it, and the wasm compile holds the app to it
180
53
  function appKotlinLanguage(root: string): string {
@@ -224,79 +97,6 @@ export function kotlinSources(
224
97
  return sources.sort()
225
98
  }
226
99
 
227
- // all entry paths compile the same native platform and runtime declarations.
228
- // the compose graph links the real androidx.annotation library, so its source
229
- // stub compiles only where that library is absent; both at once bind the
230
- // same class symbol twice.
231
- function kotlinPlatformSources(moduleRoot: string, usesCompose: boolean): string[] {
232
- return ['Sources', 'JniPlatformSources', 'JniSources'].flatMap((directory) =>
233
- kotlinSources(path.join(moduleRoot, directory), new Set()).filter((file) =>
234
- usesCompose
235
- ? !file.endsWith('/androidx/annotation/CallSuper.kt')
236
- : !file.endsWith('/OneNativeSourceViewDispatch.kt'),
237
- ),
238
- )
239
- }
240
-
241
- interface KotlinCompilerPlugin {
242
- hash: string
243
- files: { name: string; bytes: Buffer }[]
244
- }
245
-
246
- const compilerPlugins = new Map<string, Promise<string>>()
247
- const COMPILER_PLUGIN_SERVICE =
248
- 'META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar'
249
-
250
- // publish classes and their service together; kotlinc loads a directory directly.
251
- function ensureCompilerPlugin(
252
- kotlinc: string,
253
- plugin: KotlinCompilerPlugin,
254
- ): Promise<string> {
255
- const cache = path.join(kotlinHome(), 'compiler-plugins')
256
- const out = path.join(cache, plugin.hash)
257
- if (fs.existsSync(out)) return Promise.resolve(out)
258
- const pending = compilerPlugins.get(plugin.hash)
259
- if (pending) return pending
260
- const build = (async () => {
261
- fs.mkdirSync(cache, { recursive: true })
262
- const work = fs.mkdtempSync(path.join(cache, `${plugin.hash}-`))
263
- const classes = path.join(work, 'classes')
264
- try {
265
- const sources: string[] = []
266
- for (const { name, bytes } of plugin.files) {
267
- const target = path.join(work, 'sources', name)
268
- fs.mkdirSync(path.dirname(target), { recursive: true })
269
- fs.writeFileSync(target, bytes)
270
- if (name.endsWith('.kt')) sources.push(target)
271
- }
272
- await run(
273
- path.join(path.dirname(kotlinc), 'kotlinc'),
274
- [
275
- '-cp',
276
- path.resolve(path.dirname(kotlinc), '../lib/kotlin-compiler.jar'),
277
- ...sources,
278
- '-d',
279
- classes,
280
- ],
281
- { maxBuffer: 16 * 1024 * 1024 },
282
- )
283
- const service = path.join(classes, COMPILER_PLUGIN_SERVICE)
284
- fs.mkdirSync(path.dirname(service), { recursive: true })
285
- fs.copyFileSync(path.join(work, 'sources', COMPILER_PLUGIN_SERVICE), service)
286
- try {
287
- fs.renameSync(classes, out)
288
- } catch (error) {
289
- if (!fs.existsSync(out)) throw error
290
- }
291
- return out
292
- } finally {
293
- fs.rmSync(work, { recursive: true, force: true })
294
- }
295
- })().finally(() => compilerPlugins.delete(plugin.hash))
296
- compilerPlugins.set(plugin.hash, build)
297
- return build
298
- }
299
-
300
100
  // the process's entry: One's android host (HybridOneNativeModules) finds a
301
101
  // package's dispatch by its class name, checks the contract hash, and runs
302
102
  // the call as a coroutine on the main dispatcher; a thrown error rejects as
@@ -351,7 +151,7 @@ function entrySource(ids: string[]): string {
351
151
  ].join('\n')
352
152
  }
353
153
 
354
- const BUILD_FORMAT = 15
154
+ const BUILD_FORMAT = 17
355
155
  const builds = new Map<string, Promise<KotlinArtifact>>()
356
156
 
357
157
  function buildsDir(): string {
@@ -388,13 +188,29 @@ export async function kotlinArtifact(
388
188
  }
389
189
  generated['PeachEntry.kt'] = entrySource(ids)
390
190
  if (viewIds.length > 0) generated['PeachViews.kt'] = viewsSource(viewIds)
391
- const shims = kotlinPlatformSources(moduleRoot, usesCompose)
392
- if (target === 'jni')
393
- shims.push(...kotlinSources(path.join(moduleRoot, 'JniTransportSources'), new Set()))
394
- if (viewIds.length > 0)
395
- shims.push(...kotlinSources(path.join(moduleRoot, 'ComposeSources')))
191
+ const sdkProfile: KotlinSdkProfile =
192
+ target === 'jni'
193
+ ? viewIds.length > 0
194
+ ? 'jniViews'
195
+ : usesCompose
196
+ ? 'jniCompose'
197
+ : 'jni'
198
+ : viewIds.length > 0
199
+ ? 'views'
200
+ : usesCompose
201
+ ? 'compose'
202
+ : 'core'
396
203
  return compileKotlin(
397
- { root, moduleRoot, toolchain, language, sources, generated, shims, usesCompose },
204
+ {
205
+ root,
206
+ moduleRoot,
207
+ toolchain,
208
+ language,
209
+ sources,
210
+ generated,
211
+ sdkProfile,
212
+ usesCompose,
213
+ },
398
214
  origin,
399
215
  )
400
216
  }
@@ -540,9 +356,9 @@ const expoTypeScans = new Map<string, Promise<ExpoTypesFile[]>>()
540
356
 
541
357
  // the records, enums, compose views and compose props the module sources
542
358
  // declare, read by Kotlin's own parser; sources that name none skip the JVM start
543
- function scanExpoTypes(
359
+ async function scanExpoTypes(
544
360
  toolchain: KotlinToolchain,
545
- script: string,
361
+ moduleRoot: string,
546
362
  sources: string[],
547
363
  ): Promise<ExpoTypesFile[]> {
548
364
  const candidates = sources.filter((file) =>
@@ -552,20 +368,28 @@ function scanExpoTypes(
552
368
  )
553
369
  if (candidates.length === 0) return Promise.resolve([])
554
370
  const digest = createHash('sha256').update(JSON.stringify(toolchain.compiler))
555
- for (const file of [script, ...candidates])
371
+ const sdk = await loadKotlinSdk(moduleRoot, toolchain)
372
+ const packedSdk = fs.readFileSync(path.join(moduleRoot, 'sdk.tar.gz'))
373
+ digest.update(packedSdk)
374
+ for (const file of candidates)
556
375
  digest.update(`${file}\0${fs.readFileSync(file, 'utf8')}\0`)
557
376
  const key = digest.digest('hex')
558
377
  let scan = expoTypeScans.get(key)
559
378
  if (!scan) {
560
379
  scan = (async () => {
561
- const { kotlinc } = await ensureToolchain(toolchain)
380
+ const [{ kotlinc }, installed] = await Promise.all([
381
+ ensureToolchain(toolchain),
382
+ Promise.resolve(sdk),
383
+ ])
562
384
  const { stdout } = await run(
563
- path.join(path.dirname(kotlinc), 'kotlinc'),
385
+ path.join(path.dirname(kotlinc), 'kotlin'),
564
386
  [
565
387
  '-cp',
566
- path.resolve(path.dirname(kotlinc), '../lib/kotlin-compiler.jar'),
567
- '-script',
568
- script,
388
+ [
389
+ path.resolve(path.dirname(kotlinc), '../lib/kotlin-compiler.jar'),
390
+ path.join(installed.root, 'tools.jar'),
391
+ ].join(path.delimiter),
392
+ 'dev.peach.tools.expo.ExpoTypesKt',
569
393
  ...candidates,
570
394
  ],
571
395
  { maxBuffer: 16 * 1024 * 1024 },
@@ -705,11 +529,7 @@ export async function expoKotlinArtifact(
705
529
  ): Promise<KotlinArtifact & { compose: boolean }> {
706
530
  const toolchain = readToolchain(moduleRoot)
707
531
  const language = appKotlinLanguage(root)
708
- const scanned = await scanExpoTypes(
709
- toolchain,
710
- path.join(moduleRoot, 'tools/expo-types.main.kts'),
711
- modules.sources,
712
- )
532
+ const scanned = await scanExpoTypes(toolchain, moduleRoot, modules.sources)
713
533
  // every exported view uses the existing native scene presenter. modules
714
534
  // without views or compose imports do not link that renderer.
715
535
  const usesCompose =
@@ -717,17 +537,6 @@ export async function expoKotlinArtifact(
717
537
  modules.sources.some((file) =>
718
538
  /\bandroidx\.compose\./.test(fs.readFileSync(file, 'utf8')),
719
539
  )
720
- const shims = [
721
- ...kotlinPlatformSources(moduleRoot, usesCompose),
722
- ...kotlinSources(path.join(moduleRoot, 'ExpoSources'), new Set()),
723
- ...kotlinSources(path.join(moduleRoot, 'AndroidViewSources'), new Set()),
724
- ...(usesCompose
725
- ? [
726
- ...kotlinSources(path.join(moduleRoot, 'ComposeSources')),
727
- ...kotlinSources(path.join(moduleRoot, 'ExpoComposeSources'), new Set()),
728
- ]
729
- : []),
730
- ]
731
540
  const types = expoTypeSources(scanned)
732
541
  const rewritten = new Set(Object.values(types.origins))
733
542
  const entry = [
@@ -769,7 +578,7 @@ export async function expoKotlinArtifact(
769
578
  ...(usesCompose ? { 'PeachViews.kt': viewsSource([]) } : {}),
770
579
  },
771
580
  origins: types.origins,
772
- shims,
581
+ sdkProfile: usesCompose ? 'expoCompose' : 'expo',
773
582
  usesCompose,
774
583
  },
775
584
  origin,
@@ -781,9 +590,11 @@ function viewsSource(viewIds: string[]): string {
781
590
  return [
782
591
  'import dev.onejs.one.OneNativeSourceViewDispatch',
783
592
  '',
784
- 'fun peachViewDispatcher(source: String): OneNativeSourceViewDispatch = when (source) {',
593
+ 'internal fun initializeApplicationViews() {',
594
+ ' peachViewDispatcher = { source -> when (source) {',
785
595
  ...viewIds.map((id) => ` ${JSON.stringify(id)} -> OneNativeSourceViews_${id}()`),
786
596
  ' else -> error("composable source $source is not linked; rebuild the app")',
597
+ ' } }',
787
598
  '}',
788
599
  ].join('\n')
789
600
  }
@@ -843,6 +654,7 @@ export async function kotlinAppArtifact(
843
654
  ' font: String, insets: String, night: Boolean,',
844
655
  ' invalidate: (Boolean) -> Unit): String = dev.peach.app.peachStartApp(',
845
656
  ' dev.peach.app.PeachAppSpec(',
657
+ ' dev.peach.app.compiledAppResources,',
846
658
  ` android.content.ComponentName(${literal(app.packageName)}, ${literal(app.launcher.name)}),`,
847
659
  ` android.content.ComponentName(${literal(app.packageName)}, ${literal(app.launcher.targetClass)}),`,
848
660
  ...windowTheme(app.window.day),
@@ -887,12 +699,6 @@ export async function kotlinAppArtifact(
887
699
  'PeachAppEntry.kt': appEntry([]),
888
700
  ...appResourceSources(app),
889
701
  }
890
- const shims = [
891
- ...kotlinPlatformSources(moduleRoot, true),
892
- ...kotlinSources(path.join(moduleRoot, 'ComposeSources')),
893
- ...kotlinSources(path.join(moduleRoot, 'AppSources'), new Set()),
894
- ...kotlinSources(path.join(moduleRoot, 'AndroidViewSources'), new Set()),
895
- ]
896
702
  return compileKotlin(
897
703
  {
898
704
  root: app.projectDir,
@@ -901,12 +707,12 @@ export async function kotlinAppArtifact(
901
707
  language: app.language,
902
708
  sources: app.sources,
903
709
  generated,
904
- shims,
710
+ sdkProfile: 'app',
905
711
  usesCompose: true,
906
712
  viewModels: {
907
713
  file: 'PeachAppEntry.kt',
908
714
  render: appEntry,
909
- script: path.join(moduleRoot, 'tools/abi-classes.main.kts'),
715
+ toolClass: 'dev.peach.tools.abi.AbiClassesKt',
910
716
  },
911
717
  },
912
718
  origin,
@@ -1039,6 +845,12 @@ function appResourceSources(app: KotlinAppProject): Record<string, string> {
1039
845
  ')',
1040
846
  '',
1041
847
  ]),
848
+ 'internal val compiledAppResources = PeachAppResources(',
849
+ ...kinds.map(
850
+ (kind) =>
851
+ ` ${kind.table.slice('peachApp'.length).toLowerCase()} = ${kind.table},`,
852
+ ),
853
+ ')',
1042
854
  ].join('\n'),
1043
855
  }
1044
856
  }
@@ -1114,14 +926,14 @@ async function compileKotlin(
1114
926
  generated: Record<string, string>
1115
927
  // the app source a generated file rewrites, which its diagnostics name
1116
928
  origins?: Record<string, string>
1117
- shims: string[]
929
+ sdkProfile: KotlinSdkProfile
1118
930
  usesCompose: boolean
1119
931
  // a generated file that names the app's view models: rendered empty for a
1120
932
  // first compile, then from that klib's ABI
1121
933
  viewModels?: {
1122
934
  file: string
1123
935
  render: (classes: ViewModelClass[]) => string
1124
- script: string
936
+ toolClass: string
1125
937
  }
1126
938
  },
1127
939
  origin: string,
@@ -1132,40 +944,53 @@ async function compileKotlin(
1132
944
  toolchain,
1133
945
  language,
1134
946
  sources,
1135
- generated,
947
+ generated: sourceGenerated,
1136
948
  origins = {},
1137
- shims,
949
+ sdkProfile,
1138
950
  usesCompose,
1139
951
  viewModels,
1140
952
  } = input
1141
- const compilerRoot = path.join(moduleRoot, 'CompilerSources')
1142
- const compilerFiles = [
1143
- ...kotlinSources(compilerRoot, new Set()).map((file) =>
1144
- path.relative(compilerRoot, file),
1145
- ),
1146
- COMPILER_PLUGIN_SERVICE,
1147
- ].map((name) => ({
1148
- name,
1149
- bytes: fs.readFileSync(path.join(compilerRoot, name)),
1150
- }))
1151
- const compilerDigest = createHash('sha256').update(
1152
- JSON.stringify({ format: 1, compiler: toolchain.compiler }),
1153
- )
1154
- for (const { name, bytes } of compilerFiles)
1155
- compilerDigest.update(name).update('\0').update(bytes).update('\0')
1156
- const plugin = { hash: compilerDigest.digest('hex'), files: compilerFiles }
1157
- const inputs = [...shims, ...sources].map((file) => ({
953
+ const sdk = await loadKotlinSdk(moduleRoot, toolchain)
954
+ const plugin = path.join(sdk.root, 'plugin.jar')
955
+ const sdkLibrary = path.join(sdk.root, `${sdkProfile}.klib`)
956
+ const generated = {
957
+ ...sourceGenerated,
958
+ 'PeachBindingsInitialization.kt': [
959
+ '@file:OptIn(kotlin.js.ExperimentalJsExport::class)',
960
+ 'package dev.peach.jni',
961
+ ...(sourceGenerated['PeachViews.kt'] ? ['import initializeApplicationViews'] : []),
962
+ 'internal fun initializeApplicationIncomingBindings() { error("application bindings require the compiler plugin") }',
963
+ 'private var initialized = false',
964
+ '@JsExport fun peachInitializeModuleBindings() {',
965
+ ' if (!initialized) {',
966
+ ' requireIncomingBindings()',
967
+ ' initializeApplicationIncomingBindings()',
968
+ ...(sourceGenerated['PeachViews.kt']
969
+ ? [' initializeApplicationViews()']
970
+ : []),
971
+ ' initialized = true',
972
+ ' }',
973
+ '}',
974
+ ].join('\n'),
975
+ }
976
+ const inputs = sources.map((file) => ({
1158
977
  file,
1159
978
  bytes: fs.readFileSync(file),
1160
979
  }))
1161
980
  const digest = createHash('sha256')
1162
981
  // BUILD_FORMAT moves when this host changes what it does to a build
1163
982
  digest.update(
1164
- JSON.stringify({ format: BUILD_FORMAT, toolchain, language, plugin: plugin.hash }),
983
+ JSON.stringify({
984
+ format: BUILD_FORMAT,
985
+ toolchain,
986
+ language,
987
+ sdk: sdk.sha256,
988
+ sdkProfile,
989
+ }),
1165
990
  )
1166
991
  for (const { file, bytes } of inputs)
1167
992
  digest.update(path.relative(root, file)).update('\0').update(bytes).update('\0')
1168
- if (viewModels) digest.update(fs.readFileSync(viewModels.script))
993
+ if (viewModels) digest.update(viewModels.toolClass)
1169
994
  for (const [name, text] of Object.entries(generated))
1170
995
  digest.update(`${name}\0${text}\0`)
1171
996
  const hash = digest.digest('hex').slice(0, 24)
@@ -1180,8 +1005,7 @@ async function compileKotlin(
1180
1005
  const build = (async () => {
1181
1006
  const ready = await ensureToolchain(toolchain)
1182
1007
  const { kotlinc } = ready
1183
- const compilerPlugin = await ensureCompilerPlugin(kotlinc, plugin)
1184
- const libraries = [...ready.libraries]
1008
+ const libraries = [...ready.libraries, sdkLibrary]
1185
1009
  const composeRuntime = path.join(
1186
1010
  kotlinHome(),
1187
1011
  toolchain.compiler.version,
@@ -1220,7 +1044,8 @@ async function compileKotlin(
1220
1044
  kotlinc,
1221
1045
  [
1222
1046
  ...common,
1223
- `-Xplugin=${compilerPlugin}`,
1047
+ `-Xplugin=${plugin}`,
1048
+ `-Xfriend-modules=${sdkLibrary}`,
1224
1049
  ...(usesCompose
1225
1050
  ? [
1226
1051
  `-Xplugin=${path.resolve(path.dirname(kotlinc), '../lib/compose-compiler-plugin.jar')}`,
@@ -1253,12 +1078,14 @@ async function compileKotlin(
1253
1078
  ) {
1254
1079
  await compileKlib(path.join(work, 'abi'))
1255
1080
  const { stdout } = await run(
1256
- path.join(path.dirname(kotlinc), 'kotlinc'),
1081
+ path.join(path.dirname(kotlinc), 'kotlin'),
1257
1082
  [
1258
1083
  '-cp',
1259
- path.resolve(path.dirname(kotlinc), '../lib/kotlin-compiler.jar'),
1260
- '-script',
1261
- viewModels.script,
1084
+ [
1085
+ path.resolve(path.dirname(kotlinc), '../lib/kotlin-compiler.jar'),
1086
+ path.join(sdk.root, 'tools.jar'),
1087
+ ].join(path.delimiter),
1088
+ viewModels.toolClass,
1262
1089
  path.join(work, 'abi'),
1263
1090
  ],
1264
1091
  { maxBuffer: 64 * 1024 * 1024 },
@@ -1420,6 +1247,32 @@ async function compileKotlin(
1420
1247
  `kotlin output no longer contains ${from}; recheck how it detects its host in Peach`,
1421
1248
  )
1422
1249
  }
1250
+ const entry = path.join(work, 'js/app.mjs')
1251
+ const entrySource = fs.readFileSync(entry, 'utf8')
1252
+ const hasDefault = parse(entrySource, {
1253
+ ecmaVersion: 'latest',
1254
+ sourceType: 'module',
1255
+ }).body.some(
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
+ )),
1264
+ )
1265
+ fs.renameSync(entry, path.join(work, 'js/app-runtime.mjs'))
1266
+ fs.writeFileSync(
1267
+ entry,
1268
+ [
1269
+ "export * from './app-runtime.mjs';",
1270
+ ...(hasDefault ? ["export { default } from './app-runtime.mjs';"] : []),
1271
+ "import { peachInitializeModuleBindings } from './app-runtime.mjs';",
1272
+ 'peachInitializeModuleBindings();',
1273
+ '',
1274
+ ].join('\n'),
1275
+ )
1423
1276
  // another host process (a second peach kotlin, the vite plugin) may have
1424
1277
  // published this content address while this one compiled; its output is
1425
1278
  // the same build, so this one's copy is discarded
@@ -1,4 +1,4 @@
1
- // kotlin compilation needs real files for both the compiler and its scripts.
1
+ // the compiler consumes the packaged binary SDK archive and its toolchain pins.
2
2
  import { createHash } from 'node:crypto'
3
3
  import fs from 'node:fs'
4
4
  import path from 'node:path'
@@ -27,16 +27,13 @@ export function peachKotlinModuleRoot(): string {
27
27
  for (const [name, contents] of Object.entries(files)) {
28
28
  const file = path.join(pending, name)
29
29
  fs.mkdirSync(path.dirname(file), { recursive: true })
30
- fs.writeFileSync(file, contents)
30
+ fs.writeFileSync(file, Buffer.from(contents, 'base64'))
31
31
  }
32
32
  try {
33
33
  fs.renameSync(pending, root)
34
34
  } catch (error) {
35
35
  // another process may have atomically published this same module.
36
- if (
37
- !isRecord(error) ||
38
- (error.code !== 'EEXIST' && error.code !== 'ENOTEMPTY')
39
- )
36
+ if (!isRecord(error) || (error.code !== 'EEXIST' && error.code !== 'ENOTEMPTY'))
40
37
  throw error
41
38
  }
42
39
  } finally {
@@ -44,7 +41,7 @@ export function peachKotlinModuleRoot(): string {
44
41
  }
45
42
  }
46
43
  for (const [name, contents] of Object.entries(files)) {
47
- if (fs.readFileSync(path.join(root, name), 'utf8') !== contents)
44
+ if (!fs.readFileSync(path.join(root, name)).equals(Buffer.from(contents, 'base64')))
48
45
  throw new Error(`packaged Kotlin module differs from this CLI: ${name}`)
49
46
  }
50
47
  installedRoot = root