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.
- package/README.md +1 -1
- package/cli/app-fonts.ts +1 -1
- package/cli/app-stubs.ts +1 -1
- package/cli/cli-release-origin.ts +1 -0
- package/cli/cli-update.ts +1 -1
- package/cli/cloud-box-artifact.ts +1 -1
- package/cli/cloud-test-tunnel.ts +1 -1
- package/cli/commands/compat.ts +1 -1
- package/cli/commands/control.ts +2 -0
- package/cli/commands/coverage.ts +1 -1
- package/cli/commands/flow.ts +8 -1
- package/cli/commands/inspect/core.ts +25 -4
- package/cli/commands/package.ts +21 -12
- package/cli/commands/shell-url.ts +8 -3
- package/cli/commands/upgrade.ts +1 -1
- package/cli/drivers/linux-browser-libs.ts +1 -1
- package/cli/outbound-endpoints.ts +4 -0
- package/cli/remote-project-bundle.ts +2 -2
- package/detox/index.ts +12 -5
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +1787 -1799
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +2 -2
- package/dist-lib/config.mjs +2 -2
- package/dist-lib/detox/index.cjs +31 -8
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +33 -31
- package/dist-lib/expo-swift-metadata.cjs +10 -2
- package/dist-lib/expo-swift-metadata.mjs +9 -2
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +268 -241
- package/dist-lib/host/fetch-proxy-handler.cjs +459 -484
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +266 -266
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +2 -2
- package/dist-lib/metro-production-bundle.mjs +2 -2
- package/dist-lib/metro.cjs +320 -336
- package/dist-lib/native-app-identity-project.cjs +134 -159
- package/dist-lib/native-app-identity-project.mjs +428 -459
- package/dist-lib/native-app-identity.cjs +18 -18
- package/dist-lib/native-app-identity.mjs +18 -18
- package/dist-lib/native-firebase-metadata.cjs +2 -2
- package/dist-lib/native-firebase-metadata.mjs +2 -2
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +32 -36
- package/dist-lib/public-origins-lib.json +135 -161
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +2 -2
- package/dist-lib/sdk.cjs +20 -2
- package/dist-lib/sdk.mjs +20 -2
- package/dist-lib/skills.cjs +579 -529
- package/dist-lib/swift-compile.cjs +15 -6
- package/dist-lib/swift-compile.mjs +15 -6
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +33 -37
- package/dist-lib/vite.cjs +745 -768
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-compat/src/stubs/native-seams/react-native-cookies.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/engine/secureItemHostContract.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/render-worker/expo-widgets-activityContract.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/render-worker/map-command-channel.d.ts +2 -0
- package/dist-types/packages/peach-engine/src/render-worker/metro-bundle-metadata.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/render-worker/native-ui-protocol.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/render-worker/one-native-contentContract.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +2 -2
- package/dist-types/packages/peach-engine/src/render-worker/worklet-serialize.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/render-worker/worklet-wire.d.ts +1 -1
- package/dist-types/packages/peach-globals/src/package-versions.d.ts +16 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/src/androidAutolinkingContract.ts +1 -1
- package/src/androidRootModuleContract.ts +1 -1
- package/src/bundle-channel.mjs +1 -1
- package/src/config.ts +1 -1
- package/src/configured-bundle-producer.ts +1 -1
- package/src/expo-swift-host.ts +34 -4
- package/src/expoKotlinContract.ts +4 -1
- package/src/expoSwiftContract.ts +18 -4
- package/src/guest-bundle.ts +1 -1
- package/src/host/dev-server-package-versions.ts +1 -1
- package/src/host/fetch-proxy-handler.ts +1 -1
- package/src/installed-native-build-options.ts +2 -2
- package/src/installed-package-versions.ts +7 -7
- package/src/metro-plugin.ts +1 -1
- package/src/metro-production-bundle.ts +1 -1
- package/src/native-app-identity.ts +1 -1
- package/src/native-firebase-metadata.ts +1 -1
- package/src/nitro-adapter.lock.json +244 -244
- package/src/nitro-superset.lock.json +4 -4
- package/src/nitroContract.ts +1 -1
- package/src/oneSdkContract.ts +1 -1
- package/src/react-native-coverage/capability-reference-resolution.ts +4 -4
- package/src/storageSnapshotContract.ts +2 -2
- package/src/swift-compile.ts +17 -5
- package/src/swift-coverage/source.ts +1 -1
- package/src/swift-distribution.lock.json +8 -8
- package/src/turbo-runtime.lock.json +18 -18
- package/src/vite-plugin-one.ts +4 -4
- package/src/vite-plugin.ts +6 -6
- package/src/bundleGlobalFooter.ts +0 -137
- package/src/packageVersionsContract.ts +0 -131
- /package/dist-types/packages/{peach-compat/src/stubs → peach-engine/src/guest}/native-evaluation-lease.d.ts +0 -0
- /package/dist-types/packages/{peach-compat → peach-globals}/src/secure-item-store.d.ts +0 -0
- /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": "
|
|
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": "
|
|
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": "
|
|
242
|
-
"size":
|
|
241
|
+
"sha256": "4aea843d94562e297bd7e60f77579d9c274d3fc1027a78b9f3dacf68b7afd436",
|
|
242
|
+
"size": 101265134
|
|
243
243
|
},
|
|
244
244
|
"linux-x64": {
|
|
245
|
-
"sha256": "
|
|
246
|
-
"size":
|
|
245
|
+
"sha256": "a404b0e04b5590ef51fa74fb6e697d6264415a8aee0cfe39eb0b7247f3fe0472",
|
|
246
|
+
"size": 103983437
|
|
247
247
|
},
|
|
248
248
|
"linux-arm64": {
|
|
249
|
-
"sha256": "
|
|
250
|
-
"size":
|
|
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": "
|
|
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": "
|
|
24
|
-
"size":
|
|
23
|
+
"sha256": "8330c65a28046500d6c8459060fd7ed0a36faeaac14915a42bfaceec87b6e7e4",
|
|
24
|
+
"size": 25394
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
"headers": {
|
|
28
28
|
"reactNativeJsi": "21a624ea24fd17d56bf26832d496fc1177067f89640414c20e6486c7984dfb0a"
|
|
29
29
|
},
|
|
30
|
-
"sha256": "
|
|
31
|
-
"size":
|
|
30
|
+
"sha256": "aab840a1b5cd5abb544307283cc5fce53903fff3562819efb2e048dc375e253b",
|
|
31
|
+
"size": 26135
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
34
|
"headers": {
|
|
35
35
|
"reactNativeJsi": "324aefd8591d9ce688bce7589c4c2b516cd33ecb95d35c47239a87a8fcf6a8da"
|
|
36
36
|
},
|
|
37
|
-
"sha256": "
|
|
38
|
-
"size":
|
|
37
|
+
"sha256": "ad74a79d9410601c5a874a4b1c5987c2d5e6f1ef46b5d4fc9f1fb096b2577686",
|
|
38
|
+
"size": 25393
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
41
|
"headers": {
|
|
42
42
|
"reactNativeJsi": "33596664ee7d7a6623f0796a6feb429543316c3a41b211150acda6e1d835286c"
|
|
43
43
|
},
|
|
44
|
-
"sha256": "
|
|
45
|
-
"size":
|
|
44
|
+
"sha256": "1dea4d611cd4666d7d52cf99a2c5b1e56122440226bd305d3d834212660c937d",
|
|
45
|
+
"size": 25159
|
|
46
46
|
},
|
|
47
47
|
{
|
|
48
48
|
"headers": {
|
|
49
49
|
"reactNativeJsi": "66b2cd5a38511195207f6c8a76aba735f9b9cc66a52a0d00780ffe5d331623f7"
|
|
50
50
|
},
|
|
51
|
-
"sha256": "
|
|
52
|
-
"size":
|
|
51
|
+
"sha256": "cd2b0174ddd11a4e88cf335b7b62bd1d3b0917a6e294fb2cea0d7e9d2a3ec0b1",
|
|
52
|
+
"size": 25396
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
55
|
"headers": {
|
|
56
56
|
"reactNativeJsi": "96db4e758dd53e9320cef7cad485e00aa06e7a982cefd920f17007de8a5bd9f9"
|
|
57
57
|
},
|
|
58
|
-
"sha256": "
|
|
59
|
-
"size":
|
|
58
|
+
"sha256": "299edc48d3fc3fd1e0b83b1c2fc274115a8cef470839141b2a057b73b3a026cc",
|
|
59
|
+
"size": 26138
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
62
|
"headers": {
|
|
63
63
|
"reactNativeJsi": "aeab590ddd1218df963462242d3954ce467b0fa88f70e91429e4ffc74d230893"
|
|
64
64
|
},
|
|
65
|
-
"sha256": "
|
|
65
|
+
"sha256": "6daa3464d62a3204b3858ca32ef4de860590773a9ebcccad7f5de51db1000dfb",
|
|
66
66
|
"size": 26137
|
|
67
67
|
},
|
|
68
68
|
{
|
|
69
69
|
"headers": {
|
|
70
70
|
"reactNativeJsi": "b5fb260522384dd7ab07d740cdc534b529922446fcec798341c7817d9eaa49f4"
|
|
71
71
|
},
|
|
72
|
-
"sha256": "
|
|
73
|
-
"size":
|
|
72
|
+
"sha256": "2fcba636be876a984c94bd9931b7ec2e1a11489ea5957c4ae134bd9c8dd9391c",
|
|
73
|
+
"size": 25264
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
76
|
"headers": {
|
|
77
77
|
"reactNativeJsi": "c6b391a1e870ccf7cdd534be63582862840f8245b99ebd253317deece1e6ffd5"
|
|
78
78
|
},
|
|
79
|
-
"sha256": "
|
|
79
|
+
"sha256": "2bd8da9820bc1a634ff43eaf6ce76ab4f01d1cfd280740878e743eb5c2ef6f7b",
|
|
80
80
|
"size": 26139
|
|
81
81
|
},
|
|
82
82
|
{
|
|
83
83
|
"headers": {
|
|
84
84
|
"reactNativeJsi": "c8270f1315745ecc204c4209a4f50f58ff6f14b4a385ad6820a69800270b53c6"
|
|
85
85
|
},
|
|
86
|
-
"sha256": "
|
|
86
|
+
"sha256": "48e2b670a0db3fb5590b20b62646da9f6aea4a87557f7e6beca0a635eb430722",
|
|
87
87
|
"size": 25105
|
|
88
88
|
}
|
|
89
89
|
]
|
package/src/vite-plugin-one.ts
CHANGED
|
@@ -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,
|
package/src/vite-plugin.ts
CHANGED
|
@@ -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 '
|
|
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
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|