peachsim 0.1.2130 → 0.1.2155

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 (145) hide show
  1. package/README.md +1 -1
  2. package/cli/app-fonts.ts +1 -1
  3. package/cli/app-stubs.ts +1 -1
  4. package/cli/cli-release-origin.ts +1 -0
  5. package/cli/cli-update.ts +1 -1
  6. package/cli/cloud-box-artifact.ts +1 -1
  7. package/cli/cloud-test-tunnel.ts +1 -1
  8. package/cli/commands/compat.ts +1 -1
  9. package/cli/commands/control.ts +2 -0
  10. package/cli/commands/coverage.ts +1 -1
  11. package/cli/commands/flow.ts +8 -1
  12. package/cli/commands/inspect/core.ts +25 -4
  13. package/cli/commands/package.ts +21 -12
  14. package/cli/commands/shell-url.ts +8 -3
  15. package/cli/commands/upgrade.ts +1 -1
  16. package/cli/drivers/linux-browser-libs.ts +1 -1
  17. package/cli/outbound-endpoints.ts +4 -0
  18. package/cli/remote-project-bundle.ts +2 -2
  19. package/detox/index.ts +12 -5
  20. package/dist-lib/agent-daemon-client.cjs +1 -1
  21. package/dist-lib/agent-events.cjs +1 -1
  22. package/dist-lib/attached-projects.cjs +1 -1
  23. package/dist-lib/auth/shared-session.cjs +1 -1
  24. package/dist-lib/backend-origin.cjs +1 -1
  25. package/dist-lib/beta.cjs +1 -1
  26. package/dist-lib/beta.mjs +1 -1
  27. package/dist-lib/bridge-constants.cjs +1 -1
  28. package/dist-lib/bridge-contract-input.cjs +1 -1
  29. package/dist-lib/bridge-contract-input.mjs +1 -1
  30. package/dist-lib/bridge-contract.cjs +1 -1
  31. package/dist-lib/bridge-contract.mjs +1 -1
  32. package/dist-lib/bundle-channel.cjs +1787 -1799
  33. package/dist-lib/capture-contract.cjs +1 -1
  34. package/dist-lib/capture-contract.mjs +1 -1
  35. package/dist-lib/cloud-contract.cjs +1 -1
  36. package/dist-lib/cloud-contract.mjs +1 -1
  37. package/dist-lib/cloud-test-args.cjs +1 -1
  38. package/dist-lib/cloud-test-args.mjs +1 -1
  39. package/dist-lib/cloud.cjs +1 -1
  40. package/dist-lib/cloud.mjs +1 -1
  41. package/dist-lib/config.cjs +2 -2
  42. package/dist-lib/config.mjs +2 -2
  43. package/dist-lib/detox/index.cjs +31 -8
  44. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  45. package/dist-lib/expo-swift-bundle.cjs +33 -31
  46. package/dist-lib/expo-swift-metadata.cjs +10 -2
  47. package/dist-lib/expo-swift-metadata.mjs +9 -2
  48. package/dist-lib/home-paths.cjs +1 -1
  49. package/dist-lib/host/bridge-host.cjs +268 -241
  50. package/dist-lib/host/fetch-proxy-handler.cjs +459 -484
  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 +266 -266
  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/kotlin-host.cjs +1 -1
  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 +2 -2
  64. package/dist-lib/metro-production-bundle.mjs +2 -2
  65. package/dist-lib/metro.cjs +320 -336
  66. package/dist-lib/native-app-identity-project.cjs +134 -159
  67. package/dist-lib/native-app-identity-project.mjs +428 -459
  68. package/dist-lib/native-app-identity.cjs +18 -18
  69. package/dist-lib/native-app-identity.mjs +18 -18
  70. package/dist-lib/native-firebase-metadata.cjs +2 -2
  71. package/dist-lib/native-firebase-metadata.mjs +2 -2
  72. package/dist-lib/pdfium-raster.cjs +1 -1
  73. package/dist-lib/pdfium-raster.mjs +1 -1
  74. package/dist-lib/plist.cjs +1 -1
  75. package/dist-lib/plist.mjs +1 -1
  76. package/dist-lib/profiles.cjs +1 -1
  77. package/dist-lib/public-brand.cjs +1 -1
  78. package/dist-lib/public-origins-lib-esm.json +32 -36
  79. package/dist-lib/public-origins-lib.json +135 -161
  80. package/dist-lib/react-native-host-modules.cjs +1 -1
  81. package/dist-lib/react-native-host-modules.mjs +1 -1
  82. package/dist-lib/reap-browser.cjs +1 -1
  83. package/dist-lib/scripts/dev-server-scanner.cjs +2 -2
  84. package/dist-lib/sdk.cjs +20 -2
  85. package/dist-lib/sdk.mjs +20 -2
  86. package/dist-lib/skills.cjs +579 -529
  87. package/dist-lib/swift-compile.cjs +15 -6
  88. package/dist-lib/swift-compile.mjs +15 -6
  89. package/dist-lib/swift-package.cjs +1 -1
  90. package/dist-lib/swift-package.mjs +1 -1
  91. package/dist-lib/swift-submit.cjs +1 -1
  92. package/dist-lib/swift-submit.mjs +1 -1
  93. package/dist-lib/swift-toolchain.cjs +1 -1
  94. package/dist-lib/swift.cjs +1 -1
  95. package/dist-lib/vite-swift.cjs +33 -37
  96. package/dist-lib/vite.cjs +745 -768
  97. package/dist-lib/worklet-executable.cjs +1 -1
  98. package/dist-lib/worklet-executable.mjs +1 -1
  99. package/dist-types/packages/peach-compat/src/stubs/native-seams/react-native-cookies.d.ts +1 -1
  100. package/dist-types/packages/peach-engine/src/engine/secureItemHostContract.d.ts +1 -1
  101. package/dist-types/packages/peach-engine/src/render-worker/expo-widgets-activityContract.d.ts +1 -1
  102. package/dist-types/packages/peach-engine/src/render-worker/map-command-channel.d.ts +2 -0
  103. package/dist-types/packages/peach-engine/src/render-worker/metro-bundle-metadata.d.ts +1 -1
  104. package/dist-types/packages/peach-engine/src/render-worker/native-ui-protocol.d.ts +1 -1
  105. package/dist-types/packages/peach-engine/src/render-worker/one-native-contentContract.d.ts +1 -1
  106. package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +2 -2
  107. package/dist-types/packages/peach-engine/src/render-worker/worklet-serialize.d.ts +1 -1
  108. package/dist-types/packages/peach-engine/src/render-worker/worklet-wire.d.ts +1 -1
  109. package/dist-types/packages/peach-globals/src/package-versions.d.ts +16 -0
  110. package/package.json +1 -1
  111. package/runtime-companion.json +1 -1
  112. package/src/androidAutolinkingContract.ts +1 -1
  113. package/src/androidRootModuleContract.ts +1 -1
  114. package/src/bundle-channel.mjs +1 -1
  115. package/src/config.ts +1 -1
  116. package/src/configured-bundle-producer.ts +1 -1
  117. package/src/expo-swift-host.ts +34 -4
  118. package/src/expoKotlinContract.ts +4 -1
  119. package/src/expoSwiftContract.ts +18 -4
  120. package/src/guest-bundle.ts +1 -1
  121. package/src/host/dev-server-package-versions.ts +1 -1
  122. package/src/host/fetch-proxy-handler.ts +1 -1
  123. package/src/installed-native-build-options.ts +2 -2
  124. package/src/installed-package-versions.ts +7 -7
  125. package/src/metro-plugin.ts +1 -1
  126. package/src/metro-production-bundle.ts +1 -1
  127. package/src/native-app-identity.ts +1 -1
  128. package/src/native-firebase-metadata.ts +1 -1
  129. package/src/nitro-adapter.lock.json +244 -244
  130. package/src/nitro-superset.lock.json +4 -4
  131. package/src/nitroContract.ts +1 -1
  132. package/src/oneSdkContract.ts +1 -1
  133. package/src/react-native-coverage/capability-reference-resolution.ts +4 -4
  134. package/src/storageSnapshotContract.ts +2 -2
  135. package/src/swift-compile.ts +17 -5
  136. package/src/swift-coverage/source.ts +1 -1
  137. package/src/swift-distribution.lock.json +8 -8
  138. package/src/turbo-runtime.lock.json +18 -18
  139. package/src/vite-plugin-one.ts +4 -4
  140. package/src/vite-plugin.ts +6 -6
  141. package/src/bundleGlobalFooter.ts +0 -137
  142. package/src/packageVersionsContract.ts +0 -131
  143. /package/dist-types/packages/{peach-compat/src/stubs → peach-engine/src/guest}/native-evaluation-lease.d.ts +0 -0
  144. /package/dist-types/packages/{peach-compat → peach-globals}/src/secure-item-store.d.ts +0 -0
  145. /package/dist-types/packages/{peach-compat/src/stubs → peach-kit/src}/ring-mode-state.d.ts +0 -0
@@ -10,7 +10,6 @@ import {
10
10
  import { SWIFT_INDEX_READER_SOURCE } from './indexdump'
11
11
  import { createSwiftIndexer } from './indexing'
12
12
  import { swiftCoverageProvenance } from './provenance'
13
- import type { CapabilityInventoryRow } from '../../../peach-compat/src/capability-inventory-types'
14
13
  import type { VerifiedFeature } from '../../../peach-compat/src/verified-map-types'
15
14
  import type {
16
15
  SwiftIndexRef,
@@ -18,6 +17,7 @@ import type {
18
17
  SwiftSourceLeg,
19
18
  SwiftSdkSymbolSnapshot,
20
19
  } from './types'
20
+ import type { CapabilityInventoryRow } from '@peach/globals/guest-modules/capability-inventory-types'
21
21
 
22
22
  // the inventory owns SDK identities, and the existing reach rules own feature
23
23
  // attribution. a compiler reference establishes possible reach, never proof.
@@ -1,10 +1,10 @@
1
1
  {
2
- "id": "61fd19547d0ae26c",
2
+ "id": "0d7bb5f2df7211f8",
3
3
  "release": "swift-6.4.0-RELEASE-custom-11345d60dca47496",
4
4
  "wasmSdkId": "swift-6.4.0-RELEASE_wasm-peach-449999fa",
5
5
  "wasmSdkUrl": "https://r2.sootsim.com/swift-wasm-sdk/swift-6.4.0-RELEASE_wasm-peach-449999fa.artifactbundle.tar.gz",
6
6
  "wasmSdkChecksum": "f076baab44830cc5b940a217d74f0d827f15fd7979c10a0e74b66ecbe330753d",
7
- "source": "bda371f244d41f9f927f56bb297f1d077bb7f737",
7
+ "source": "810257bbb309b636ff42b432468aeb3546940ba8",
8
8
  "targets": [
9
9
  "ImagePlayground",
10
10
  "QuickLookThumbnailing",
@@ -238,16 +238,16 @@
238
238
  },
239
239
  "hosts": {
240
240
  "darwin-arm64": {
241
- "sha256": "87a16837b4dc115ef2e5db17c3658bde6d5291bf2030c20cf9d364869f9586e0",
242
- "size": 101143871
241
+ "sha256": "4aea843d94562e297bd7e60f77579d9c274d3fc1027a78b9f3dacf68b7afd436",
242
+ "size": 101265134
243
243
  },
244
244
  "linux-x64": {
245
- "sha256": "018ebcb1f3ebfb33f9473d8d0533a7969865a39975199100c2b0f9704fa5c460",
246
- "size": 103861080
245
+ "sha256": "a404b0e04b5590ef51fa74fb6e697d6264415a8aee0cfe39eb0b7247f3fe0472",
246
+ "size": 103983437
247
247
  },
248
248
  "linux-arm64": {
249
- "sha256": "7037426663d5fd6b128cd8bfa0a831a3d07b75365e8c5a6e32330d41191083c8",
250
- "size": 103354486
249
+ "sha256": "b2f4ff2babe2503eed0e9ae61cc4ea16841e74eb1753afe5178a87478fa125c4",
250
+ "size": 103473434
251
251
  }
252
252
  }
253
253
  }
@@ -12,7 +12,7 @@
12
12
  "checksum": "f076baab44830cc5b940a217d74f0d827f15fd7979c10a0e74b66ecbe330753d"
13
13
  },
14
14
  "framework": {
15
- "distribution": "61fd19547d0ae26c",
15
+ "distribution": "0d7bb5f2df7211f8",
16
16
  "wireAbi": "246b8412514b644113e6a26252c8ebd6de49ab4156ac5f5c98bb9e4c2ff2568b"
17
17
  },
18
18
  "archives": [
@@ -20,70 +20,70 @@
20
20
  "headers": {
21
21
  "reactNativeJsi": "0f8c2defbca69a27a848a81ae72363073bf9602fd316e57a75811be1a0528358"
22
22
  },
23
- "sha256": "ca18cc9eb28b057429ac7659e0b4e87922a525ffe33860ce3e9ea7ce36f7d8c9",
24
- "size": 25393
23
+ "sha256": "8330c65a28046500d6c8459060fd7ed0a36faeaac14915a42bfaceec87b6e7e4",
24
+ "size": 25394
25
25
  },
26
26
  {
27
27
  "headers": {
28
28
  "reactNativeJsi": "21a624ea24fd17d56bf26832d496fc1177067f89640414c20e6486c7984dfb0a"
29
29
  },
30
- "sha256": "ef36cd52aefc26f852d23ea7f9b5b48304a07f8c3d7bfa6b9fb98f908800f250",
31
- "size": 26136
30
+ "sha256": "aab840a1b5cd5abb544307283cc5fce53903fff3562819efb2e048dc375e253b",
31
+ "size": 26135
32
32
  },
33
33
  {
34
34
  "headers": {
35
35
  "reactNativeJsi": "324aefd8591d9ce688bce7589c4c2b516cd33ecb95d35c47239a87a8fcf6a8da"
36
36
  },
37
- "sha256": "1cd0519198fa94a6e4826dfe9366daafdfbda425fef6e0018d165cff7731929f",
38
- "size": 25392
37
+ "sha256": "ad74a79d9410601c5a874a4b1c5987c2d5e6f1ef46b5d4fc9f1fb096b2577686",
38
+ "size": 25393
39
39
  },
40
40
  {
41
41
  "headers": {
42
42
  "reactNativeJsi": "33596664ee7d7a6623f0796a6feb429543316c3a41b211150acda6e1d835286c"
43
43
  },
44
- "sha256": "f27b47f6293671dbc7e69e95ce82ef4b21e83c58e6939ef3c707f2d41810cbd9",
45
- "size": 25161
44
+ "sha256": "1dea4d611cd4666d7d52cf99a2c5b1e56122440226bd305d3d834212660c937d",
45
+ "size": 25159
46
46
  },
47
47
  {
48
48
  "headers": {
49
49
  "reactNativeJsi": "66b2cd5a38511195207f6c8a76aba735f9b9cc66a52a0d00780ffe5d331623f7"
50
50
  },
51
- "sha256": "806e5521296d0a3eee6732541a757dc483fde1f73761062911422477a7e1bb81",
52
- "size": 25393
51
+ "sha256": "cd2b0174ddd11a4e88cf335b7b62bd1d3b0917a6e294fb2cea0d7e9d2a3ec0b1",
52
+ "size": 25396
53
53
  },
54
54
  {
55
55
  "headers": {
56
56
  "reactNativeJsi": "96db4e758dd53e9320cef7cad485e00aa06e7a982cefd920f17007de8a5bd9f9"
57
57
  },
58
- "sha256": "6489af32dad063a1cc6a2829922f746d618d658fbb00d8de09a4621fe7f29c3c",
59
- "size": 26139
58
+ "sha256": "299edc48d3fc3fd1e0b83b1c2fc274115a8cef470839141b2a057b73b3a026cc",
59
+ "size": 26138
60
60
  },
61
61
  {
62
62
  "headers": {
63
63
  "reactNativeJsi": "aeab590ddd1218df963462242d3954ce467b0fa88f70e91429e4ffc74d230893"
64
64
  },
65
- "sha256": "92d4ff153d0b49b07aad72505e6f7bd74c770a5aae041082b09a05933033d1c8",
65
+ "sha256": "6daa3464d62a3204b3858ca32ef4de860590773a9ebcccad7f5de51db1000dfb",
66
66
  "size": 26137
67
67
  },
68
68
  {
69
69
  "headers": {
70
70
  "reactNativeJsi": "b5fb260522384dd7ab07d740cdc534b529922446fcec798341c7817d9eaa49f4"
71
71
  },
72
- "sha256": "386b33732b87064be4e231fe3c4f7dd4456ddc40606e4cbaba507edcca08ded6",
73
- "size": 25266
72
+ "sha256": "2fcba636be876a984c94bd9931b7ec2e1a11489ea5957c4ae134bd9c8dd9391c",
73
+ "size": 25264
74
74
  },
75
75
  {
76
76
  "headers": {
77
77
  "reactNativeJsi": "c6b391a1e870ccf7cdd534be63582862840f8245b99ebd253317deece1e6ffd5"
78
78
  },
79
- "sha256": "58cae6186021f9d08085435f3a831bc5ae69ae037380b61e7b1a0326659335df",
79
+ "sha256": "2bd8da9820bc1a634ff43eaf6ce76ab4f01d1cfd280740878e743eb5c2ef6f7b",
80
80
  "size": 26139
81
81
  },
82
82
  {
83
83
  "headers": {
84
84
  "reactNativeJsi": "c8270f1315745ecc204c4209a4f50f58ff6f14b4a385ad6820a69800270b53c6"
85
85
  },
86
- "sha256": "6d4642327d60a5f7e8c6820a74f3eb9c34a4001dadf7fcb5f26daf8881627a99",
86
+ "sha256": "48e2b670a0db3fb5590b20b62646da9f6aea4a87557f7e6beca0a635eb430722",
87
87
  "size": 25105
88
88
  }
89
89
  ]
@@ -13,6 +13,10 @@ import https from 'node:https'
13
13
  import { fileURLToPath } from 'node:url'
14
14
  import path from 'path'
15
15
  import { pipeline } from 'stream/promises'
16
+ import {
17
+ insertPackageVersionsFooter,
18
+ PACKAGE_VERSIONS_HEADER,
19
+ } from '@peach/globals/package-versions'
16
20
  import { WebSocket, WebSocketServer } from 'ws'
17
21
  import { DEFAULT_SOOTSIM_BRIDGE_PORT } from './bridge-constants'
18
22
  import { getCliRuntime } from './cli-runtime'
@@ -32,10 +36,6 @@ import {
32
36
  readOneNativeAppAccent,
33
37
  } from './one-native-app-accent'
34
38
  import { configuredOneWidget } from './one-widget-metadata'
35
- import {
36
- insertPackageVersionsFooter,
37
- PACKAGE_VERSIONS_HEADER,
38
- } from './packageVersionsContract'
39
39
  import {
40
40
  isRootRuntimeAssetPath,
41
41
  resolveRuntimeFilePath,
@@ -34,11 +34,6 @@ declare module '@babel/core' {
34
34
  projectRoot?: string
35
35
  }
36
36
  }
37
- import {
38
- EXPO_PLATFORM_MODULE,
39
- selectHostExpoOs,
40
- } from '../../peach-compat/src/expo-os-selector.ts'
41
- import { resolveExportsHiddenSubpath } from '../../peach-compat/src/resolve-hidden-subpath.ts'
42
37
  import {
43
38
  SOOTSIM_COMPAT_PUBLISHED_BROWSER_ENTRIES,
44
39
  PEACH_UPSTREAM_MODULES,
@@ -47,7 +42,12 @@ import {
47
42
  compatStubsForBuildResolver,
48
43
  usesUpstreamScreensJavaScript,
49
44
  reactNativeDeepStubsForBuildResolver,
50
- } from '../../peach-compat/src/stub-manifest.ts'
45
+ } from '@peach/globals/guest-modules/stub-manifest'
46
+ import {
47
+ EXPO_PLATFORM_MODULE,
48
+ selectHostExpoOs,
49
+ } from '../../peach-compat/src/expo-os-selector.ts'
50
+ import { resolveExportsHiddenSubpath } from '../../peach-compat/src/resolve-hidden-subpath.ts'
51
51
  import {
52
52
  assertPeachPortEnvironment,
53
53
  resolveSootsimBridgePort,
@@ -1,137 +0,0 @@
1
- // nitro uses inert metadata because its native oracle observes guest globals;
2
- // executing a nitro metadata assignment adds a global absent on native. expo
3
- // and package versions retain their existing assignment wire contracts. both
4
- // encodings share serialization, replacement and parsing below. module path
5
- // identity is read by the guest router and must remain an executable last line.
6
-
7
- // footer writers append assignments or comments ahead of module path identity.
8
- // walking that block from the end finds a footer, or proves it absent, without
9
- // reading the whole bundle. returns the newline before the footer, or -1.
10
- export function findBundleFooter(source: string, prefix: string): number {
11
- let end = source.length
12
- while (end > 0) {
13
- const newline = source.lastIndexOf('\n', end - 1)
14
- if (newline < 0) return -1
15
- const line = newline + 1
16
- if (source.startsWith(prefix, line)) return newline
17
- if (!isFooterBlockLine(source, line, end)) return -1
18
- end = newline
19
- }
20
- return -1
21
- }
22
-
23
- function isFooterBlockLine(source: string, line: number, end: number): boolean {
24
- return (
25
- line === end ||
26
- source.startsWith('globalThis.', line) ||
27
- source.startsWith('//', line)
28
- )
29
- }
30
-
31
- // the whole trailing block the readers above walk, split from the code before
32
- // it. a rewrite of the code (minification) must leave the block as written:
33
- // a minifier reprints each footer's JSON as an object literal and moves legal
34
- // comments after it, so no reader would find the footer again.
35
- export function splitBundleFooterBlock(source: string): {
36
- code: string
37
- footers: string
38
- } {
39
- let end = source.length
40
- while (end > 0) {
41
- const newline = source.lastIndexOf('\n', end - 1)
42
- if (newline < 0 || !isFooterBlockLine(source, newline + 1, end)) break
43
- end = newline
44
- }
45
- return { code: source.slice(0, end), footers: source.slice(end) }
46
- }
47
-
48
- function readFooter(
49
- source: string,
50
- prefix: string,
51
- suffix: string,
52
- name: string,
53
- ): unknown {
54
- const start = findBundleFooter(source, prefix)
55
- if (start < 0) return null
56
- const end = source.indexOf('\n', start + 1)
57
- const line = source.slice(start + 1, end < 0 ? undefined : end)
58
- if (!line.endsWith(suffix)) throw new Error(`${name} footer is truncated`)
59
- const value: unknown = JSON.parse(
60
- line.slice(prefix.length, suffix ? -suffix.length : undefined),
61
- )
62
- if (value === null) throw new Error(`${name} footer has no metadata`)
63
- return value
64
- }
65
-
66
- export function readBundleGlobalFooter(source: string, name: string): unknown {
67
- return readFooter(source, `globalThis.${name}=`, ';', name)
68
- }
69
-
70
- // transport metadata is parsed before evaluation and has no guest JS effect.
71
- export function readBundleMetadataFooter(source: string, name: string): unknown {
72
- return readFooter(source, `// peach.${name}=`, '', name)
73
- }
74
-
75
- export function stripBundleMetadataFooter(source: string, name: string): string {
76
- const start = findBundleFooter(source, `// peach.${name}=`)
77
- if (start < 0) return source
78
- const end = source.indexOf('\n', start + 1)
79
- return source.slice(0, start) + (end < 0 ? '' : source.slice(end))
80
- }
81
-
82
- // removes the footer line so a rewrite of the bundle's code (minification)
83
- // cannot reshape it; the caller inserts the value again afterwards.
84
- export function detachBundleGlobalFooter(
85
- source: string,
86
- name: string,
87
- ): { source: string; value: unknown } {
88
- return detachFooter(source, `globalThis.${name}=`, ';', name)
89
- }
90
-
91
- function detachFooter(
92
- source: string,
93
- prefix: string,
94
- suffix: string,
95
- name: string,
96
- ): { source: string; value: unknown } {
97
- const start = findBundleFooter(source, prefix)
98
- if (start < 0) return { source, value: null }
99
- const value = readFooter(source, prefix, suffix, name)
100
- const end = source.indexOf('\n', start + 1)
101
- return { source: source.slice(0, start) + (end < 0 ? '' : source.slice(end)), value }
102
- }
103
-
104
- export function insertBundleGlobalFooter(
105
- source: string,
106
- name: string,
107
- value: unknown,
108
- ): string {
109
- return insertFooter(source, `globalThis.${name}=`, ';', name, value)
110
- }
111
-
112
- export function insertBundleMetadataFooter(
113
- source: string,
114
- name: string,
115
- value: unknown,
116
- ): string {
117
- return insertFooter(source, `// peach.${name}=`, '', name, value)
118
- }
119
-
120
- function insertFooter(
121
- source: string,
122
- prefix: string,
123
- suffix: string,
124
- name: string,
125
- value: unknown,
126
- ): string {
127
- source = detachFooter(source, prefix, suffix, name).source
128
- const json = JSON.stringify(value)
129
- .replace(/\u2028/g, '\\u2028')
130
- .replace(/\u2029/g, '\\u2029')
131
- .replace(/<\//g, '<\\/')
132
- const footer = `\n${prefix}${json}${suffix}`
133
- const identity = findBundleFooter(source, 'globalThis.__sootsimModulePaths=')
134
- return identity < 0
135
- ? source + footer
136
- : source.slice(0, identity) + footer + source.slice(identity)
137
- }
@@ -1,131 +0,0 @@
1
- import {
2
- detachBundleGlobalFooter,
3
- insertBundleGlobalFooter,
4
- readBundleGlobalFooter,
5
- } from './bundleGlobalFooter'
6
- import type { NativeBuildOptions } from '@peach/globals'
7
-
8
- // the version of each package in a bundle's graph as the app installed it. a
9
- // device compiles a package's native side from that install, so a native seam
10
- // follows this version. the bundler that read the install writes it as a
11
- // footer; boot analysis reads it before any seam loads.
12
- export type PackageVersions = Record<string, string>
13
-
14
- // native choices travel with the install record and are applied to the engine
15
- // config for each evaluation. the reserved key is not a package version.
16
- export const NATIVE_BUILD_OPTIONS_KEY = '@peach/native-build-options'
17
-
18
- export function readNativeBuildOptions(
19
- versions: PackageVersions | null,
20
- ): NativeBuildOptions {
21
- const wire = versions?.[NATIVE_BUILD_OPTIONS_KEY]
22
- if (wire === undefined) return {}
23
- const value: unknown = JSON.parse(wire)
24
- if (typeof value !== 'object' || value === null || Array.isArray(value))
25
- throw new Error('invalid native build options')
26
- const result: Record<string, Record<string, boolean>> = {}
27
- for (const [name, options] of Object.entries(value)) {
28
- if (
29
- !name ||
30
- typeof options !== 'object' ||
31
- options === null ||
32
- Array.isArray(options)
33
- )
34
- throw new Error('invalid native build options')
35
- const record: Record<string, boolean> = {}
36
- for (const [key, option] of Object.entries(options)) {
37
- if (!key || typeof option !== 'boolean')
38
- throw new Error('invalid native build options')
39
- record[key] = option
40
- }
41
- result[name] = record
42
- }
43
- return result
44
- }
45
-
46
- export const PACKAGE_VERSIONS_HEADER = 'X-Peach-Package-Versions'
47
-
48
- const FOOTER = '__peachPackageVersions'
49
-
50
- export function readPackageVersions(value: unknown): PackageVersions {
51
- if (typeof value !== 'object' || value === null || Array.isArray(value)) {
52
- throw new Error('invalid package versions')
53
- }
54
- const versions: PackageVersions = {}
55
- for (const [name, version] of Object.entries(value)) {
56
- if (name.length === 0 || typeof version !== 'string' || version.length === 0) {
57
- throw new Error('invalid package versions')
58
- }
59
- versions[name] = version
60
- }
61
- return versions
62
- }
63
-
64
- export function readPackageVersionsFooter(source: string): PackageVersions | null {
65
- const value = readBundleGlobalFooter(source, FOOTER)
66
- return value === null ? null : readPackageVersions(value)
67
- }
68
-
69
- export function insertPackageVersionsFooter(
70
- source: string,
71
- versions: PackageVersions,
72
- ): string {
73
- return insertBundleGlobalFooter(source, FOOTER, readPackageVersions(versions))
74
- }
75
-
76
- export function detachPackageVersionsFooter(source: string): {
77
- source: string
78
- versions: PackageVersions | null
79
- } {
80
- const detached = detachBundleGlobalFooter(source, FOOTER)
81
- return {
82
- source: detached.source,
83
- versions: detached.value === null ? null : readPackageVersions(detached.value),
84
- }
85
- }
86
-
87
- // the installed react-native-worklets compiles its static feature flags from
88
- // src/featureFlags/staticFlags.json plus the app manifest's `worklets` overrides.
89
- // the producer that read the install records the resolved table beside the
90
- // versions, keyed by the file it came from, so every app and runtime answers
91
- // from what the app installed.
92
- export const WORKLETS_STATIC_FLAGS_KEY = 'react-native-worklets/staticFlags.json'
93
-
94
- export type WorkletsStaticFlags = Readonly<Record<string, boolean>>
95
-
96
- function isFlagRecord(value: unknown): value is Record<string, unknown> {
97
- return typeof value === 'object' && value !== null && !Array.isArray(value)
98
- }
99
-
100
- // package defaults with the app manifest's overrides, as the native build resolves them.
101
- export function resolveWorkletsStaticFlags(
102
- defaults: unknown,
103
- appManifest: unknown,
104
- ): string {
105
- if (!isFlagRecord(defaults)) throw new Error('Worklets static flags are malformed')
106
- const worklets = isFlagRecord(appManifest) ? appManifest.worklets : undefined
107
- const overrides = isFlagRecord(worklets) ? worklets.staticFeatureFlags : undefined
108
- if (overrides !== undefined && !isFlagRecord(overrides)) {
109
- throw new Error('Worklets static flag overrides are malformed')
110
- }
111
- const flags: Record<string, boolean> = {}
112
- for (const [name, value] of Object.entries({ ...defaults, ...overrides })) {
113
- flags[name] = String(value) === 'true'
114
- }
115
- return JSON.stringify(flags)
116
- }
117
-
118
- export function readWorkletsStaticFlags(
119
- versions: PackageVersions | null,
120
- ): WorkletsStaticFlags | null {
121
- const wire = versions?.[WORKLETS_STATIC_FLAGS_KEY]
122
- if (wire === undefined) return null
123
- const flags: unknown = JSON.parse(wire)
124
- if (!isFlagRecord(flags)) throw new Error('invalid Worklets static flags')
125
- const table: Record<string, boolean> = {}
126
- for (const [name, value] of Object.entries(flags)) {
127
- if (typeof value !== 'boolean') throw new Error('invalid Worklets static flags')
128
- table[name] = value
129
- }
130
- return table
131
- }