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
@@ -0,0 +1,81 @@
1
+ import { execFile } from 'node:child_process'
2
+ import { createHash } from 'node:crypto'
3
+ import fs from 'node:fs'
4
+ import path from 'node:path'
5
+ import { promisify } from 'node:util'
6
+ import { kotlinHome } from './kotlin-toolchain'
7
+ import { KOTLIN_SDK_FILES, readKotlinSdkManifest } from './kotlinSdkContract'
8
+ import type { KotlinSdkManifest } from './kotlinSdkContract'
9
+
10
+ const run = promisify(execFile)
11
+
12
+ export function verifyKotlinSdkDirectory(
13
+ root: string,
14
+ compilerSha256: string,
15
+ ): KotlinSdkManifest {
16
+ const expectedNames = ['manifest.json', ...KOTLIN_SDK_FILES]
17
+ const names = fs.readdirSync(root)
18
+ if (
19
+ names.length !== expectedNames.length ||
20
+ names.some((name) => !expectedNames.includes(name))
21
+ )
22
+ throw new Error('Kotlin SDK directory contains unexpected inputs')
23
+ const manifestStat = fs.lstatSync(path.join(root, 'manifest.json'))
24
+ if (!manifestStat.isFile() || manifestStat.nlink !== 1)
25
+ throw new Error('Kotlin SDK manifest is not a regular file')
26
+ const manifest = readKotlinSdkManifest(
27
+ fs.readFileSync(path.join(root, 'manifest.json'), 'utf8'),
28
+ compilerSha256,
29
+ )
30
+ for (const [name, expected] of Object.entries(manifest.files)) {
31
+ const target = path.join(root, name)
32
+ const stat = fs.lstatSync(target)
33
+ if (!stat.isFile() || stat.nlink !== 1)
34
+ throw new Error(`Kotlin SDK binary is not a regular file: ${name}`)
35
+ const bytes = fs.readFileSync(target)
36
+ if (
37
+ bytes.length !== expected.bytes ||
38
+ createHash('sha256').update(bytes).digest('hex') !== expected.sha256
39
+ )
40
+ throw new Error(`Kotlin SDK binary differs from its manifest: ${name}`)
41
+ }
42
+ return manifest
43
+ }
44
+
45
+ export async function installKotlinSdkArchive(
46
+ archive: Buffer,
47
+ compilerSha256: string,
48
+ ): Promise<{ root: string; sha256: string; manifest: KotlinSdkManifest }> {
49
+ const sha256 = createHash('sha256').update(archive).digest('hex')
50
+ const parent = path.join(kotlinHome(), 'sdk')
51
+ const root = path.join(parent, sha256)
52
+ if (fs.existsSync(root))
53
+ return { root, sha256, manifest: verifyKotlinSdkDirectory(root, compilerSha256) }
54
+ fs.mkdirSync(parent, { recursive: true })
55
+ const work = fs.mkdtempSync(path.join(parent, '.install-'))
56
+ try {
57
+ const packed = path.join(work, 'sdk.tar.gz')
58
+ fs.writeFileSync(packed, archive)
59
+ const { stdout } = await run('tar', ['-tzf', packed])
60
+ const names = stdout.trim().split('\n')
61
+ const expected = ['manifest.json', ...KOTLIN_SDK_FILES]
62
+ if (
63
+ names.length !== expected.length ||
64
+ new Set(names).size !== names.length ||
65
+ names.some((name) => !expected.includes(name))
66
+ )
67
+ throw new Error('Kotlin SDK archive contains unexpected inputs')
68
+ await run('tar', ['-xzf', packed, '-C', work, '--', ...expected])
69
+ fs.rmSync(packed)
70
+ const manifest = verifyKotlinSdkDirectory(work, compilerSha256)
71
+ try {
72
+ fs.renameSync(work, root)
73
+ } catch (error) {
74
+ if (!fs.existsSync(root)) throw error
75
+ verifyKotlinSdkDirectory(root, compilerSha256)
76
+ }
77
+ return { root, sha256, manifest }
78
+ } finally {
79
+ fs.rmSync(work, { recursive: true, force: true })
80
+ }
81
+ }
@@ -0,0 +1,152 @@
1
+ import { execFile } from 'node:child_process'
2
+ import { createHash } from 'node:crypto'
3
+ import fs from 'node:fs'
4
+ import path from 'node:path'
5
+ import { promisify } from 'node:util'
6
+ import { rnxHomeDir } from './home-paths'
7
+ import { isRecord } from './is-record'
8
+ import type {
9
+ Download,
10
+ KotlinToolchain,
11
+ KotlinToolchainInstallation,
12
+ } from './kotlinSdkContract'
13
+
14
+ const run = promisify(execFile)
15
+
16
+ export function readToolchain(moduleRoot: string): KotlinToolchain {
17
+ const parsed: unknown = JSON.parse(
18
+ fs.readFileSync(path.join(moduleRoot, 'toolchain.json'), 'utf8'),
19
+ )
20
+ const download = (value: unknown): Download => {
21
+ if (
22
+ !isRecord(value) ||
23
+ typeof value.url !== 'string' ||
24
+ typeof value.sha256 !== 'string'
25
+ )
26
+ throw new Error(
27
+ 'peachsim kotlin/toolchain.json names a download without url and sha256',
28
+ )
29
+ return { url: value.url, sha256: value.sha256 }
30
+ }
31
+ if (
32
+ !isRecord(parsed) ||
33
+ !isRecord(parsed.compiler) ||
34
+ !Array.isArray(parsed.libraries) ||
35
+ !Array.isArray(parsed.composeLibraries) ||
36
+ !Array.isArray(parsed.composeJsLibraries) ||
37
+ !isRecord(parsed.composeRuntime) ||
38
+ typeof parsed.composeRuntime.name !== 'string'
39
+ )
40
+ throw new Error('peachsim kotlin/toolchain.json has no compiler and libraries')
41
+ const version = parsed.compiler.version
42
+ if (typeof version !== 'string')
43
+ throw new Error('peachsim kotlin/toolchain.json has no compiler version')
44
+ const libraries = (values: unknown[]) =>
45
+ values.map((library) => {
46
+ if (!isRecord(library) || typeof library.name !== 'string')
47
+ throw new Error('peachsim kotlin/toolchain.json names a library without a name')
48
+ return { ...download(library), name: library.name }
49
+ })
50
+ return {
51
+ compiler: { ...download(parsed.compiler), version },
52
+ libraries: libraries(parsed.libraries),
53
+ composeLibraries: libraries(parsed.composeLibraries),
54
+ composeRuntime: {
55
+ ...download(parsed.composeRuntime),
56
+ name: parsed.composeRuntime.name,
57
+ },
58
+ composeJsLibraries: parsed.composeJsLibraries.map((library) => {
59
+ if (
60
+ !isRecord(library) ||
61
+ typeof library.name !== 'string' ||
62
+ typeof library.module !== 'string' ||
63
+ typeof library.file !== 'string' ||
64
+ typeof library.archiveEntry !== 'string'
65
+ )
66
+ throw new Error('peachsim kotlin/toolchain.json has an incomplete JS library')
67
+ return {
68
+ ...download(library),
69
+ name: library.name,
70
+ module: library.module,
71
+ file: library.file,
72
+ archiveEntry: library.archiveEntry,
73
+ }
74
+ }),
75
+ }
76
+ }
77
+
78
+ export function kotlinHome(): string {
79
+ return path.join(rnxHomeDir(), 'kotlin')
80
+ }
81
+
82
+ export async function fetchVerified(download: Download, target: string): Promise<void> {
83
+ if (fs.existsSync(target)) {
84
+ if (
85
+ createHash('sha256').update(fs.readFileSync(target)).digest('hex') !==
86
+ download.sha256
87
+ )
88
+ throw new Error(
89
+ `cached Kotlin download differs from its pin: ${path.basename(target)}`,
90
+ )
91
+ return
92
+ }
93
+ const response = await fetch(download.url)
94
+ if (!response.ok) throw new Error(`${download.url} answered ${response.status}`)
95
+ const bytes = Buffer.from(await response.arrayBuffer())
96
+ const digest = createHash('sha256').update(bytes).digest('hex')
97
+ if (digest !== download.sha256)
98
+ throw new Error(`${download.url} has sha256 ${digest}, expected ${download.sha256}`)
99
+ fs.mkdirSync(path.dirname(target), { recursive: true })
100
+ const partial = `${target}.${process.pid}.partial`
101
+ fs.writeFileSync(partial, bytes)
102
+ fs.renameSync(partial, target)
103
+ }
104
+
105
+ const toolchains = new Map<string, Promise<KotlinToolchainInstallation>>()
106
+
107
+ // the pinned compiler and the coroutines klibs, fetched once and checked
108
+ // against toolchain.json
109
+ export function ensureToolchain(
110
+ toolchain: KotlinToolchain,
111
+ ): Promise<KotlinToolchainInstallation> {
112
+ const key = JSON.stringify(toolchain)
113
+ const pending = toolchains.get(key)
114
+ if (pending) return pending
115
+ const ready = (async () => {
116
+ const dir = path.join(kotlinHome(), toolchain.compiler.version)
117
+ const kotlinc = path.join(dir, 'kotlinc', 'bin', 'kotlinc-wasm')
118
+ if (!fs.existsSync(kotlinc)) {
119
+ const zip = path.join(dir, 'kotlin-compiler.zip')
120
+ await fetchVerified(toolchain.compiler, zip)
121
+ await run('unzip', ['-q', '-o', zip, '-d', dir])
122
+ fs.rmSync(zip)
123
+ }
124
+ // kotlinc runs on the JVM an android build already needs; it finds it
125
+ // through JAVA_HOME or PATH, as gradle does
126
+ const java = process.env.JAVA_HOME
127
+ ? path.join(process.env.JAVA_HOME, 'bin', 'java')
128
+ : 'java'
129
+ const { stderr } = await run(java, ['-XshowSettings:properties', '-version']).catch(
130
+ () => {
131
+ throw new Error(
132
+ `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'}`,
133
+ )
134
+ },
135
+ )
136
+ const javaHome = /^\s*java\.home\s*=\s*(.+)$/m.exec(stderr)?.[1]?.trim()
137
+ if (!javaHome || !path.isAbsolute(javaHome))
138
+ throw new Error('the configured Java runtime did not report an absolute java.home')
139
+ const libraries = [path.join(dir, 'kotlinc', 'lib', 'kotlin-stdlib-wasm-js.klib')]
140
+ for (const library of toolchain.libraries) {
141
+ const target = path.join(dir, library.name)
142
+ await fetchVerified(library, target)
143
+ libraries.push(target)
144
+ }
145
+ return { kotlinc, libraries, javaHome }
146
+ })().catch((error: unknown) => {
147
+ toolchains.delete(key)
148
+ throw error
149
+ })
150
+ toolchains.set(key, ready)
151
+ return ready
152
+ }
@@ -1,5 +1,5 @@
1
1
  // the ViewModel classes an app declares, read from its compiled klib's ABI
2
- // (`kotlin/tools/abi-classes.main.kts`), each with the constructor androidx's
2
+ // (`kotlin/ToolSources/AbiClasses.kt`), each with the constructor androidx's
3
3
  // SavedStateViewModelFactory finds by reflection: an AndroidViewModel takes a
4
4
  // public (Application, SavedStateHandle) constructor, else AndroidViewModel
5
5
  // Factory's public (Application) one; any other view model a public
@@ -0,0 +1,113 @@
1
+ import { isRecord } from './is-record'
2
+
3
+ export interface Download {
4
+ url: string
5
+ sha256: string
6
+ }
7
+
8
+ export interface KotlinToolchainInstallation {
9
+ kotlinc: string
10
+ libraries: string[]
11
+ javaHome: string
12
+ }
13
+
14
+ const platform = ['Sources', 'JniPlatformSources', 'JniSources']
15
+ export const KOTLIN_SDK_PROFILES = {
16
+ core: { compose: false, directories: platform },
17
+ compose: { compose: true, directories: platform },
18
+ views: { compose: true, directories: [...platform, 'ComposeSources'] },
19
+ jni: { compose: false, directories: [...platform, 'JniTransportSources'] },
20
+ jniCompose: {
21
+ compose: true,
22
+ directories: [...platform, 'JniTransportSources'],
23
+ },
24
+ jniViews: {
25
+ compose: true,
26
+ directories: [...platform, 'JniTransportSources', 'ComposeSources'],
27
+ },
28
+ expo: {
29
+ compose: false,
30
+ directories: [...platform, 'ExpoSources', 'AndroidViewSources'],
31
+ },
32
+ expoCompose: {
33
+ compose: true,
34
+ directories: [
35
+ ...platform,
36
+ 'ExpoSources',
37
+ 'AndroidViewSources',
38
+ 'ComposeSources',
39
+ 'ExpoComposeSources',
40
+ ],
41
+ },
42
+ app: {
43
+ compose: true,
44
+ directories: [...platform, 'ComposeSources', 'AppSources', 'AndroidViewSources'],
45
+ },
46
+ } satisfies Record<string, { compose: boolean; directories: string[] }>
47
+
48
+ export type KotlinSdkProfile = keyof typeof KOTLIN_SDK_PROFILES
49
+ export const KOTLIN_SDK_FILES = [
50
+ 'plugin.jar',
51
+ 'tools.jar',
52
+ ...Object.keys(KOTLIN_SDK_PROFILES).map((name) => `${name}.klib`),
53
+ ]
54
+
55
+ export interface KotlinSdkManifest {
56
+ format: 1
57
+ abi: 1
58
+ compilerSha256: string
59
+ sourceDigest: string
60
+ files: Record<string, { sha256: string; bytes: number }>
61
+ }
62
+
63
+ export function readKotlinSdkManifest(
64
+ source: string,
65
+ compilerSha256: string,
66
+ ): KotlinSdkManifest {
67
+ const value: unknown = JSON.parse(source)
68
+ if (
69
+ !isRecord(value) ||
70
+ value.format !== 1 ||
71
+ value.abi !== 1 ||
72
+ value.compilerSha256 !== compilerSha256 ||
73
+ typeof value.sourceDigest !== 'string' ||
74
+ !/^[a-f0-9]{64}$/.test(value.sourceDigest) ||
75
+ !isRecord(value.files) ||
76
+ Object.keys(value.files).length !== KOTLIN_SDK_FILES.length
77
+ )
78
+ throw new Error('Kotlin SDK manifest is incompatible with this compiler')
79
+ const files: KotlinSdkManifest['files'] = {}
80
+ for (const name of KOTLIN_SDK_FILES) {
81
+ const file = value.files[name]
82
+ if (
83
+ !isRecord(file) ||
84
+ typeof file.sha256 !== 'string' ||
85
+ !/^[a-f0-9]{64}$/.test(file.sha256) ||
86
+ typeof file.bytes !== 'number' ||
87
+ !Number.isSafeInteger(file.bytes) ||
88
+ file.bytes < 1
89
+ )
90
+ throw new Error(`Kotlin SDK has no verified binary ${name}`)
91
+ files[name] = { sha256: file.sha256, bytes: file.bytes }
92
+ }
93
+ return {
94
+ format: 1,
95
+ abi: 1,
96
+ compilerSha256,
97
+ sourceDigest: value.sourceDigest,
98
+ files,
99
+ }
100
+ }
101
+
102
+ export interface KotlinToolchain {
103
+ compiler: Download & { version: string }
104
+ libraries: (Download & { name: string })[]
105
+ composeLibraries: (Download & { name: string })[]
106
+ composeRuntime: Download & { name: string }
107
+ composeJsLibraries: (Download & {
108
+ name: string
109
+ module: string
110
+ file: string
111
+ archiveEntry: string
112
+ })[]
113
+ }
@@ -16,11 +16,11 @@
16
16
  "checksum": "1e19ea768fd4e821aae34b8966c4ddcee45615c4b3cf018979b061aee2fb5504"
17
17
  },
18
18
  "framework": {
19
- "distribution": "e3bdd3d8fa4f9993",
19
+ "distribution": "ca4dfda0ca14bc49",
20
20
  "wireAbi": "ed0b01fcc0a79236d88ef9ac7950ac30932dfc19c19112c69d1d6a039a489292"
21
21
  },
22
22
  "archive": {
23
- "sha256": "1cf000ee821aaf65b04a3d6702c7d4341e450371cfd199e5887c6056f80af899",
24
- "size": 31175
23
+ "sha256": "e5c94039c146c3f35b1a9e32368c2a6c605140be79e386cac57ad2bae06a9a3d",
24
+ "size": 31177
25
25
  }
26
26
  }
@@ -1,5 +1,7 @@
1
+ import { loadRNXAppConfig } from '../cli/app-config'
2
+ import { resolveAppProject } from '../cli/app-project'
1
3
  import { compileNitroModule } from './nitro-compile'
2
- import { discoverNitroProviders } from './nitro-source'
4
+ import { discoverNitroProviders, selectNitroProviders } from './nitro-source'
3
5
  import { SWIFT_ENDPOINT_ENV, swiftDistributionRoot } from './swift-distribution'
4
6
  import { icuUrl } from './swift-host'
5
7
  import type { NitroCompiledModule } from './nitroContract'
@@ -11,13 +13,20 @@ export interface NitroBundle {
11
13
 
12
14
  // every installed iOS Nitro provider the app declares compiles into one
13
15
  // executable with the same compiler and asset addresses as local native loads.
14
- // package javascript is carried verbatim by its bundler.
16
+ // package javascript is carried verbatim by its bundler. a HybridObject the
17
+ // app's config answers, a view or an unsupported or file-answered name, registers no
18
+ // original constructor; a provider left with none is not compiled.
15
19
  export async function buildNitroBundle(
16
20
  appRoot: string,
17
21
  moduleRoot?: string,
18
22
  ): Promise<NitroBundle | null> {
23
+ const config = await loadRNXAppConfig(resolveAppProject(appRoot))
24
+ const answers = {
25
+ hybridObjects: new Set(Object.keys(config?.nativeHybridObjects ?? {})),
26
+ views: new Set(Object.keys(config?.nativeViews ?? {})),
27
+ }
19
28
  const packageRoots = discoverNitroProviders(appRoot)
20
- if (packageRoots.length === 0) return null
29
+ if (selectNitroProviders(packageRoots, answers).length === 0) return null
21
30
  // the adapter archive is built against the published distribution, so Nitro
22
31
  // compiles against it even in a source checkout; the checkout framework has
23
32
  // no manifest for the adapter identity check to bind.
@@ -29,6 +38,7 @@ export async function buildNitroBundle(
29
38
  const { artifact, collection } = await compileNitroModule({
30
39
  appRoot,
31
40
  packageRoots,
41
+ answers,
32
42
  moduleRoot: module,
33
43
  })
34
44
  const assets: NitroBundle['assets'] = [
@@ -47,7 +57,11 @@ export async function buildNitroBundle(
47
57
  return {
48
58
  metadata: {
49
59
  platform: 'ios',
50
- packages: collection.providers.map(({ name, version }) => ({ name, version })),
60
+ packages: collection.providers.map(({ name, version, hybridObjects }) => ({
61
+ name,
62
+ version,
63
+ hybridObjects,
64
+ })),
51
65
  url: `/__peach/swift/${artifact.hash}.wasm`,
52
66
  hash: artifact.hash,
53
67
  icuUrl: icuUrl('', artifact),
@@ -63,7 +63,11 @@ export async function compileNitroModule(
63
63
  await resolveNitroAdapter(collection, options.moduleRoot, committedNitroAdapterLock),
64
64
  )
65
65
  const key = createHash('sha256')
66
- .update(collection.providers.map(({ root }) => root).join('\0'))
66
+ .update(
67
+ collection.providers
68
+ .map(({ root, hybridObjects }) => `${root}\0${hybridObjects.join(',')}`)
69
+ .join('\0'),
70
+ )
67
71
  .update('\0')
68
72
  .update(fs.realpathSync(options.moduleRoot))
69
73
  .digest('hex')
@@ -7,7 +7,16 @@ import { MAX_SWIFT_COMPILE_SOURCE_BYTES } from './swift-submit'
7
7
  import type { SwiftCompileInput } from './swift-compile'
8
8
  import type { SwiftPackageTarget } from './swift-package'
9
9
 
10
- export type NitroSourceOptions = { packageRoots: string[] } & (
10
+ /** the HybridObject names the app answers itself, so their original
11
+ * constructors are not registered. `hybridObjects` names any registered
12
+ * HybridObject (unsupported or a file); `views` answers only a registration
13
+ * that is a Nitro view. */
14
+ export interface NitroAnswers {
15
+ hybridObjects: ReadonlySet<string>
16
+ views: ReadonlySet<string>
17
+ }
18
+
19
+ export type NitroSourceOptions = { packageRoots: string[]; answers?: NitroAnswers } & (
11
20
  | { appRoot: string; dependencyRoots?: never }
12
21
  | {
13
22
  appRoot?: never
@@ -25,7 +34,8 @@ export interface NitroSourceCollection {
25
34
  targets: SwiftPackageTarget[]
26
35
  /** one per provider, sorted by package name; `target` holds its header. */
27
36
  registrations: { symbol: string; header: string; target: string }[]
28
- providers: NitroPackage[]
37
+ /** the selected providers; `hybridObjects` are the names each registers. */
38
+ providers: (NitroPackage & { hybridObjects: string[] })[]
29
39
  nitro: NitroPackage
30
40
  reactNative: NitroPackage
31
41
  sources: { file: string; source: string; sha256: string }[]
@@ -122,7 +132,92 @@ function registrations(root: string) {
122
132
  if (new Set(classes.map(({ name }) => name)).size !== classes.length)
123
133
  throw new Error(`${root}: duplicate generated Nitro iOS registration`)
124
134
  classes.sort((a, b) => a.name.localeCompare(b.name))
125
- return { namespace, swiftModule, classes }
135
+ return { namespace, swiftModule, classes, views: viewNames(root, classes) }
136
+ }
137
+
138
+ // a Nitro view registration ships a generated view config named for its class
139
+ function viewNames(root: string, classes: { name: string }[]): Set<string> {
140
+ const directory = path.join(root, 'nitrogen/generated/shared/json')
141
+ if (!fs.existsSync(directory)) return new Set()
142
+ const views = new Set<string>()
143
+ for (const file of fs.readdirSync(directory)) {
144
+ if (!file.endsWith('Config.json')) continue
145
+ const config = readJson(root, path.join('nitrogen/generated/shared/json', file))
146
+ const name = object(config) ? config.uiViewClassName : undefined
147
+ if (typeof name === 'string' && classes.some((entry) => entry.name === name))
148
+ views.add(name)
149
+ }
150
+ return views
151
+ }
152
+
153
+ function hasNitroIosInitializer(root: string): boolean {
154
+ const generated = path.join(root, 'nitrogen/generated/ios')
155
+ return (
156
+ fs.existsSync(generated) &&
157
+ fs.readdirSync(generated).some((file) => file.endsWith('Autolinking.mm'))
158
+ )
159
+ }
160
+
161
+ /** the HybridObject names a package registers for iOS, and which of them are
162
+ * Nitro views; null for a package with no generated Nitro iOS initializer. */
163
+ export function nitroRegisteredNames(
164
+ root: string,
165
+ ): { names: string[]; views: string[] } | null {
166
+ if (!hasNitroIosInitializer(root)) return null
167
+ const { classes, views } = registrations(root)
168
+ return { names: classes.map(({ name }) => name), views: [...views].sort() }
169
+ }
170
+
171
+ type NitroSelection = {
172
+ provider: NitroPackage
173
+ config: ReturnType<typeof registrations>
174
+ /** the classes whose original constructors register. */
175
+ selected: ReturnType<typeof registrations>['classes']
176
+ }
177
+
178
+ /** every provider with at least one original constructor left to register,
179
+ * after the names the app answers. a provider keeps its complete sources when
180
+ * only some of its names are answered. */
181
+ export function selectNitroProviders(
182
+ packageRoots: string[],
183
+ answers?: NitroAnswers,
184
+ ): NitroSelection[] {
185
+ const providers = packageRoots
186
+ .map(packageInfo)
187
+ .sort((a, b) => a.name.localeCompare(b.name))
188
+ for (const [index, provider] of providers.entries())
189
+ if (providers.findIndex(({ name }) => name === provider.name) !== index)
190
+ throw new Error(`duplicate Nitro provider package ${provider.name}`)
191
+ const all = providers.map((provider) => ({
192
+ provider,
193
+ config: registrations(provider.root),
194
+ }))
195
+ const names = new Map<string, string>()
196
+ for (const { provider, config } of all)
197
+ for (const { name } of config.classes) {
198
+ const owner = names.get(name)
199
+ if (owner !== undefined)
200
+ throw new Error(
201
+ `Nitro HybridObject ${name} is registered by ${owner} and ${provider.name}`,
202
+ )
203
+ names.set(name, provider.name)
204
+ }
205
+ for (const name of answers?.hybridObjects ?? [])
206
+ if (!names.has(name))
207
+ throw new Error(
208
+ `Nitro HybridObject ${name} is answered by the config but no provider registers it`,
209
+ )
210
+ return all
211
+ .map(({ provider, config }) => ({
212
+ provider,
213
+ config,
214
+ selected: config.classes.filter(
215
+ ({ name }) =>
216
+ !answers?.hybridObjects.has(name) &&
217
+ !(config.views.has(name) && answers?.views.has(name)),
218
+ ),
219
+ }))
220
+ .filter(({ selected }) => selected.length > 0)
126
221
  }
127
222
 
128
223
  /** the installed packages react native's iOS autolinking would link into the
@@ -142,12 +237,7 @@ export function discoverNitroProviders(appRoot: string): string[] {
142
237
  for (let directory = appRoot; ; directory = path.dirname(directory)) {
143
238
  const root = path.join(directory, 'node_modules', name)
144
239
  if (fs.existsSync(path.join(root, 'package.json'))) {
145
- const generated = path.join(root, 'nitrogen/generated/ios')
146
- if (
147
- fs.existsSync(generated) &&
148
- fs.readdirSync(generated).some((file) => file.endsWith('Autolinking.mm'))
149
- )
150
- roots.push(root)
240
+ if (hasNitroIosInitializer(root)) roots.push(root)
151
241
  break
152
242
  }
153
243
  if (path.dirname(directory) === directory) break
@@ -159,25 +249,19 @@ export function discoverNitroProviders(appRoot: string): string[] {
159
249
  /** collect installed native bodies, generated bridges, Nitro core and RN's
160
250
  * JSI without reading or rewriting package JavaScript. */
161
251
  export function collectNitroSources(options: NitroSourceOptions): NitroSourceCollection {
162
- if (options.packageRoots.length === 0)
163
- throw new Error('Nitro compilation needs at least one installed provider')
164
- const providers = options.packageRoots
165
- .map(packageInfo)
166
- .sort((a, b) => a.name.localeCompare(b.name))
167
- for (const [index, provider] of providers.entries())
168
- if (providers.findIndex(({ name }) => name === provider.name) !== index)
169
- throw new Error(`duplicate Nitro provider package ${provider.name}`)
170
- const configs = providers.map((provider) => registrations(provider.root))
171
- const names = new Map<string, string>()
172
- for (const [index, config] of configs.entries())
173
- for (const { name } of config.classes) {
174
- const owner = names.get(name)
175
- if (owner !== undefined)
176
- throw new Error(
177
- `Nitro HybridObject ${name} is registered by ${owner} and ${providers[index]!.name}`,
178
- )
179
- names.set(name, providers[index]!.name)
180
- }
252
+ const selections = selectNitroProviders(options.packageRoots, options.answers)
253
+ if (selections.length === 0)
254
+ throw new Error(
255
+ 'Nitro compilation needs at least one provider constructor to register',
256
+ )
257
+ const providers = selections.map(({ provider, selected }) => ({
258
+ ...provider,
259
+ hybridObjects: selected.map(({ name }) => name),
260
+ }))
261
+ const configs = selections.map(({ config, selected }) => ({
262
+ ...config,
263
+ classes: selected,
264
+ }))
181
265
  const swiftModules = new Map<string, string>()
182
266
  for (const [index, config] of configs.entries()) {
183
267
  if (config.swiftModule === null) continue
@@ -8,8 +8,10 @@ export const NITRO_GUEST_PLATFORM = 'ios'
8
8
 
9
9
  export interface NitroCompiledModule {
10
10
  platform: typeof NITRO_GUEST_PLATFORM
11
- /** the original providers this one executable registers, by package name. */
12
- packages: { name: string; version: string }[]
11
+ /** the original providers this one executable registers, by package name,
12
+ * with the HybridObject names each registers. a name the app answers
13
+ * is in no provider's list. */
14
+ packages: { name: string; version: string; hybridObjects: string[] }[]
13
15
  url: string
14
16
  hash: string
15
17
  icuUrl: string
@@ -21,8 +23,16 @@ function readNitroPackage(
21
23
  if (typeof value !== 'object' || value === null) return null
22
24
  const name = Reflect.get(value, 'name')
23
25
  const version = Reflect.get(value, 'version')
24
- return typeof name === 'string' && name && typeof version === 'string' && version
25
- ? { name, version }
26
+ const names = Reflect.get(value, 'hybridObjects')
27
+ return typeof name === 'string' &&
28
+ name &&
29
+ typeof version === 'string' &&
30
+ version &&
31
+ Array.isArray(names) &&
32
+ names.length > 0 &&
33
+ names.every((entry): entry is string => typeof entry === 'string' && entry !== '') &&
34
+ new Set(names).size === names.length
35
+ ? { name, version, hybridObjects: names }
26
36
  : null
27
37
  }
28
38
 
@@ -43,6 +53,8 @@ export function readNitroMetadata(value: unknown): NitroCompiledModule | null {
43
53
  packages.length === 0 ||
44
54
  !packages.every((entry) => entry !== null) ||
45
55
  new Set(packages.map(({ name }) => name)).size !== packages.length ||
56
+ new Set(packages.flatMap((entry) => entry.hybridObjects)).size !==
57
+ packages.reduce((total, entry) => total + entry.hybridObjects.length, 0) ||
46
58
  typeof url !== 'string' ||
47
59
  !url ||
48
60
  typeof hash !== 'string' ||
@@ -489,6 +489,10 @@ function canonicalSourceModulePath(
489
489
  if (normalized.startsWith('node_modules/') || normalized.includes('/node_modules/')) {
490
490
  return null
491
491
  }
492
+ // a workspace package sits outside the app's project root. a folder inside
493
+ // it is the app's own source, even when it is named after a package, such as
494
+ // a vendored copy of that package's JS the app never installed
495
+ if (!normalized.startsWith('../') && !normalized.startsWith('/')) return null
492
496
  const searchable = normalized.startsWith('/') ? normalized : `/${normalized}`
493
497
  sourceDirectoryPattern.lastIndex = 0
494
498
  let match: RegExpExecArray | null