peachsim 0.1.2632 → 0.1.2634
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/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 +2 -2
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +5 -5
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +3 -3
- package/dist-lib/bundle-channel.cjs +1027 -900
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +3 -3
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +3 -3
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +2 -2
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +7 -7
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +5 -5
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/esm-chunks/{acorn-DKB7GZT6.mjs → acorn-E7YS7T7M.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-GA7FAECM.mjs → chunk-2SB3P7CJ.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-GQTUYS4H.mjs → chunk-2VYVW3RF.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-CV5RZOOJ.mjs → chunk-4SRXXXOC.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-NIEMZH6X.mjs → chunk-6EG4II5F.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-MKMHVD4N.mjs → chunk-6YZJ2GYO.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-V7XEPFLK.mjs → chunk-CXDXPI7W.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-6VSB2YLC.mjs → chunk-ERQZXSHP.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-H4QC7QRJ.mjs → chunk-H223T2KC.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-MUCYHHLH.mjs → chunk-N2XQ3OUI.mjs} +2 -2
- package/dist-lib/esm-chunks/{chunk-P2RM4AZ3.mjs → chunk-NPVYXBWM.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-QAEHTEPD.mjs → chunk-P4JHWOEI.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-XHDXDIWR.mjs → chunk-PCY75YWE.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-4LVSQJ55.mjs → chunk-PXOH2HF6.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-BFBZA2BQ.mjs → chunk-RN4YJUYM.mjs} +6 -6
- package/dist-lib/esm-chunks/{chunk-JAKV5RNE.mjs → chunk-S4CJUCCF.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-I2M7AILU.mjs → chunk-TPIVMDXH.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-527QC43Y.mjs → chunk-VPM63Q6Z.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-NIABR6EE.mjs → chunk-WH5NWS6Z.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-UR2TSXLV.mjs → chunk-WWO6KGXH.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-I5WMQJP2.mjs → chunk-X2TVSD4W.mjs} +42 -32
- package/dist-lib/esm-chunks/{chunk-76BZWBAM.mjs → chunk-X726CWSL.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-MIJ3VPMP.mjs → chunk-XOL6DFMM.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-BSVNB3XA.mjs → chunk-Y4EG7XXB.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-WSCFAJJ4.mjs → chunk-YLD4VKUR.mjs} +6 -6
- package/dist-lib/esm-chunks/{metro-layout-parser-42HRR6M7.mjs → metro-layout-parser-I7JGQQV2.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-U5U7A3UO.mjs → swift-package-prebuilt-CXXM7OME.mjs} +12 -12
- package/dist-lib/esm-chunks/{swift-sdk-app-module-WPBWI4HC.mjs → swift-sdk-app-module-XKY52BHH.mjs} +16 -16
- package/dist-lib/esm-chunks/{swift-sdk-image-YTWDRBZU.mjs → swift-sdk-image-EUTGX6FL.mjs} +16 -16
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-JTJP3DMV.mjs → swift-sdk-image-producer-JVAFRRME.mjs} +5 -5
- package/dist-lib/expo-swift-bundle.cjs +31 -21
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +7 -7
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +7575 -7354
- package/dist-lib/host/fetch-proxy-handler.cjs +3 -3
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +3 -3
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +3 -3
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +4 -4
- package/dist-lib/native-app-identity-project.cjs +1 -1
- package/dist-lib/native-app-identity-project.mjs +15 -15
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +6 -6
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +3 -3
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +2 -2
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +3 -3
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +85 -85
- package/dist-lib/public-origins-lib.json +89 -82
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +2 -2
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +8 -8
- package/dist-lib/skills.cjs +8181 -7950
- package/dist-lib/swift-compile.cjs +29 -19
- package/dist-lib/swift-compile.mjs +12 -12
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +3 -3
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +6 -6
- package/dist-lib/swift-svg-raster.cjs +1 -1
- package/dist-lib/swift-svg-raster.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
- package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
- package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
- package/dist-lib/vendor/acorn.cjs +1 -1
- package/dist-lib/vendor/magic-string.cjs +1 -1
- package/dist-lib/vendor/stream-json.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
- package/dist-lib/vendor/sucrase.cjs +1 -1
- package/dist-lib/vendor/terser.cjs +1 -1
- package/dist-lib/vendor/valibot.cjs +1 -1
- package/dist-lib/vendor/ws.cjs +1 -1
- package/dist-lib/vendor/zod.cjs +1 -1
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +3 -3
- package/dist-types/packages/peach-engine/src/components/native-ui/context-menu-types.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/native-node-queries.d.ts +1 -0
- package/package.json +1 -1
- package/src/host/bridge-host.ts +42 -20
- package/src/native-package-slice-build.ts +44 -31
- package/src/one-native-controls-package.ts +80 -14
- package/src/one-native-controls-release.ts +69 -0
- package/src/one-sdk/shard.ts +382 -0
- package/src/one-sdk-bundle.ts +4 -208
- package/src/swift-compile.ts +44 -19
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
peachAnsweredNativePackages,
|
|
9
9
|
withUnansweredNativePackages,
|
|
10
10
|
} from './answeredNativePackages'
|
|
11
|
-
import { prepareNativeAppRoot } from './expo-native-workspace'
|
|
11
|
+
import { declaresNativeDependency, prepareNativeAppRoot } from './expo-native-workspace'
|
|
12
12
|
import { expoPodInputs, expoPodPackages } from './expo-pod-prebuilt'
|
|
13
13
|
import { cacheDir } from './home-paths'
|
|
14
14
|
import { installedNativeLibraries } from './installed-native-libraries'
|
|
@@ -36,7 +36,11 @@ import { swiftNativePin } from './swift-native-pin'
|
|
|
36
36
|
import { swiftManifestTargets } from './swift-package'
|
|
37
37
|
import { withSwiftRootLock } from './swift-root-lock'
|
|
38
38
|
import { prepareTurboCompileInput } from './turbo-compile'
|
|
39
|
-
import {
|
|
39
|
+
import {
|
|
40
|
+
discoverTurboProviders,
|
|
41
|
+
TURBO_CORE_TARGET,
|
|
42
|
+
turboProviderCandidates,
|
|
43
|
+
} from './turbo-source'
|
|
40
44
|
import { installedXcodeWorkspace } from './xcode-project'
|
|
41
45
|
import type { NitroBuildConfiguration } from './nitroContract'
|
|
42
46
|
|
|
@@ -68,6 +72,32 @@ function resolveReactNativeRoot(appRoot: string): string {
|
|
|
68
72
|
return path.dirname(fs.realpathSync(require.resolve('react-native/package.json')))
|
|
69
73
|
}
|
|
70
74
|
|
|
75
|
+
async function discoverTurboSliceProviders(
|
|
76
|
+
appRoot: string,
|
|
77
|
+
projectRoot?: string,
|
|
78
|
+
iosTarget?: string,
|
|
79
|
+
) {
|
|
80
|
+
let root = projectRoot ?? appRoot
|
|
81
|
+
if (!projectRoot && !installedXcodeWorkspace(appRoot)) {
|
|
82
|
+
const manifest = JSON.parse(
|
|
83
|
+
fs.readFileSync(path.join(appRoot, 'package.json'), 'utf8'),
|
|
84
|
+
)
|
|
85
|
+
if (
|
|
86
|
+
declaresNativeDependency(manifest, 'expo') ||
|
|
87
|
+
declaresNativeDependency(manifest, 'one')
|
|
88
|
+
) {
|
|
89
|
+
if ((await turboProviderCandidates(appRoot)).length === 0)
|
|
90
|
+
return { projectRoot: root, providers: [] }
|
|
91
|
+
// podspecs can resolve dependencies from the generated ios directory.
|
|
92
|
+
root = await prepareNativeAppRoot(appRoot, undefined, iosTarget)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
projectRoot: root,
|
|
97
|
+
providers: await discoverTurboProviders(appRoot, root, iosTarget),
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
71
101
|
/** detects buildable native packages in an app across Expo Swift, Nitro, and TurboModules. */
|
|
72
102
|
export async function detectNativePackageKinds(
|
|
73
103
|
appRoot: string,
|
|
@@ -114,7 +144,8 @@ export async function detectNativePackageKinds(
|
|
|
114
144
|
|
|
115
145
|
if (!opts?.kind || opts.kind === 'turbomodule') {
|
|
116
146
|
const seenTurbo = new Set<string>()
|
|
117
|
-
|
|
147
|
+
const { providers } = await discoverTurboSliceProviders(realRoot)
|
|
148
|
+
for (const provider of providers) {
|
|
118
149
|
const root = fs.realpathSync(provider.root)
|
|
119
150
|
const meta = readPackageMeta(root)
|
|
120
151
|
if (!meta || seenTurbo.has(meta.name)) continue
|
|
@@ -230,38 +261,20 @@ export async function buildNativePackageSlice(opts: {
|
|
|
230
261
|
}
|
|
231
262
|
|
|
232
263
|
if (kind === 'turbomodule') {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
264
|
+
const { projectRoot: resolvedProjectRoot, providers: discovered } =
|
|
265
|
+
await discoverTurboSliceProviders(
|
|
266
|
+
appRoot,
|
|
267
|
+
opts.projectRoot ? projectRoot : undefined,
|
|
268
|
+
opts.iosTarget,
|
|
269
|
+
)
|
|
270
|
+
const providers = discovered.filter(
|
|
271
|
+
(provider) => readPackageMeta(provider.root)?.name === opts.packageName,
|
|
272
|
+
)
|
|
237
273
|
if (providers.length === 0) {
|
|
238
274
|
opts.onSkip?.('no TurboModule provider discovered')
|
|
239
275
|
return null
|
|
240
276
|
}
|
|
241
|
-
const
|
|
242
|
-
fs.existsSync(path.join(appRoot, name)),
|
|
243
|
-
)
|
|
244
|
-
const hasSwiftSources = providers.some((provider) =>
|
|
245
|
-
fs
|
|
246
|
-
.readdirSync(provider.root, { recursive: true, encoding: 'utf8' })
|
|
247
|
-
.some((file) => file.endsWith('.swift')),
|
|
248
|
-
)
|
|
249
|
-
if (
|
|
250
|
-
!opts.projectRoot &&
|
|
251
|
-
!installedXcodeWorkspace(resolvedProjectRoot) &&
|
|
252
|
-
hasExpoConfig &&
|
|
253
|
-
hasSwiftSources
|
|
254
|
-
) {
|
|
255
|
-
resolvedProjectRoot = await prepareNativeAppRoot(appRoot, undefined, opts.iosTarget)
|
|
256
|
-
providers = (
|
|
257
|
-
await discoverTurboProviders(appRoot, resolvedProjectRoot, opts.iosTarget)
|
|
258
|
-
).filter((provider) => readPackageMeta(provider.root)?.name === opts.packageName)
|
|
259
|
-
if (providers.length === 0) {
|
|
260
|
-
opts.onSkip?.('no TurboModule provider discovered in prepared workspace')
|
|
261
|
-
return null
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
const reactNativeRoot = resolveReactNativeRoot(appRoot)
|
|
277
|
+
const reactNativeRoot = resolveReactNativeRoot(resolvedProjectRoot)
|
|
265
278
|
const installed = installedXcodeWorkspace(resolvedProjectRoot)
|
|
266
279
|
? installedNativeLibraries(
|
|
267
280
|
providers,
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
// builds the Peach Swift package that compiles One v3's unchanged SwiftUI
|
|
2
2
|
// controls against Peach's Swift SDK and exposes them through PeachTypedViews.
|
|
3
|
-
import { createHash } from 'node:crypto'
|
|
3
|
+
import { createHash, randomUUID } from 'node:crypto'
|
|
4
4
|
import fs from 'node:fs'
|
|
5
5
|
import { createRequire } from 'node:module'
|
|
6
6
|
import path from 'node:path'
|
|
7
7
|
import { fileURLToPath } from 'node:url'
|
|
8
8
|
import { swiftGuestControls } from '../../peach-globals/build/one-swift-control-source'
|
|
9
|
+
import {
|
|
10
|
+
shardOneSDKBindingSource,
|
|
11
|
+
translateShardedOneSDKDiagnostic,
|
|
12
|
+
type ShardedBindingFile,
|
|
13
|
+
} from './one-sdk/shard'
|
|
9
14
|
import { oneSDKHost, oneSDKModule, oneSDKTransport } from './one-sdk/source'
|
|
10
15
|
import {
|
|
11
16
|
ONE_NATIVE_CONTROLS_CONTAINER_VIEWS,
|
|
@@ -17,7 +22,9 @@ import {
|
|
|
17
22
|
ONE_NATIVE_CONTROLS_VISUAL_VIEWS,
|
|
18
23
|
} from './oneNativeControlsContract'
|
|
19
24
|
import { swiftCodeMask, syncSwiftTree } from './swift-compile'
|
|
25
|
+
import { swiftDistributionRoot } from './swift-distribution'
|
|
20
26
|
import { projectFor, swiftPackageMetadata, swiftPackageReleaseFiles } from './swift-host'
|
|
27
|
+
import { swiftModuleDigest } from './swift-sdk-surface'
|
|
21
28
|
import { collectSwiftSourceClosure } from './swift-source-closure'
|
|
22
29
|
import { SWIFT_PACKAGE_PATH } from './swift-submit'
|
|
23
30
|
import { privateSwiftDistributionRoot, swiftCacheDir } from './swift-toolchain'
|
|
@@ -1133,6 +1140,28 @@ export interface OneNativeControlsPackage {
|
|
|
1133
1140
|
packagePath: string
|
|
1134
1141
|
watched: string[]
|
|
1135
1142
|
oneSDKModules?: string[]
|
|
1143
|
+
oneSDKShards?: ReadonlyMap<string, ShardedBindingFile>
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
function cachedWasiBindings(file: string, base: ReadonlyMap<string, string>) {
|
|
1147
|
+
let record: unknown
|
|
1148
|
+
try {
|
|
1149
|
+
record = JSON.parse(fs.readFileSync(file, 'utf8'))
|
|
1150
|
+
} catch (error) {
|
|
1151
|
+
if (
|
|
1152
|
+
error instanceof SyntaxError ||
|
|
1153
|
+
(error instanceof Error && 'code' in error && error.code === 'ENOENT')
|
|
1154
|
+
)
|
|
1155
|
+
return
|
|
1156
|
+
throw error
|
|
1157
|
+
}
|
|
1158
|
+
if (!record || typeof record !== 'object' || Array.isArray(record)) return
|
|
1159
|
+
const files = new Map(base)
|
|
1160
|
+
for (const [name, source] of Object.entries(record)) {
|
|
1161
|
+
if (!base.has(name) || typeof source !== 'string') return
|
|
1162
|
+
files.set(name, source)
|
|
1163
|
+
}
|
|
1164
|
+
return files
|
|
1136
1165
|
}
|
|
1137
1166
|
|
|
1138
1167
|
function excludedGroupSource(source: string, defines: ReadonlySet<string>): boolean {
|
|
@@ -1236,6 +1265,7 @@ export async function oneNativeControlsPackage(
|
|
|
1236
1265
|
if (full) watched.add(full)
|
|
1237
1266
|
}
|
|
1238
1267
|
|
|
1268
|
+
const oneSDKShards = new Map<string, ShardedBindingFile>()
|
|
1239
1269
|
if (bindings) {
|
|
1240
1270
|
files.set('Sources/One/One.swift', oneSDKModule)
|
|
1241
1271
|
for (const relative of ONE_SDK_RUNTIME_SOURCES) {
|
|
@@ -1246,10 +1276,14 @@ export async function oneNativeControlsPackage(
|
|
|
1246
1276
|
for (const [name, content] of [...bindings.files].sort(([a], [b]) =>
|
|
1247
1277
|
a.localeCompare(b),
|
|
1248
1278
|
)) {
|
|
1249
|
-
const
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1279
|
+
const baseName = path.basename(name)
|
|
1280
|
+
for (const shard of shardOneSDKBindingSource(baseName, content)) {
|
|
1281
|
+
const relative = 'Sources/OneSDKBindings/' + shard.name
|
|
1282
|
+
if (files.has(relative))
|
|
1283
|
+
throw new Error('duplicate Swift filename in OneSDKBindings: ' + relative)
|
|
1284
|
+
files.set(relative, shard.source)
|
|
1285
|
+
if (shard.name !== shard.originalName) oneSDKShards.set(shard.name, shard)
|
|
1286
|
+
}
|
|
1253
1287
|
}
|
|
1254
1288
|
files.set('Sources/Controls/OneSDKHost.swift', oneSDKHost)
|
|
1255
1289
|
files.set('Sources/Controls/OneSDKTransport.swift', oneSDKTransport)
|
|
@@ -1314,6 +1348,7 @@ export async function oneNativeControlsPackage(
|
|
|
1314
1348
|
packagePath,
|
|
1315
1349
|
watched: [...watched],
|
|
1316
1350
|
oneSDKModules: bindings && [...bindings.modules],
|
|
1351
|
+
...(oneSDKShards.size ? { oneSDKShards } : {}),
|
|
1317
1352
|
}
|
|
1318
1353
|
}
|
|
1319
1354
|
|
|
@@ -1331,15 +1366,32 @@ export async function stageOneNativeControlsRelease(
|
|
|
1331
1366
|
files: Map<string, Blob>
|
|
1332
1367
|
oneSDKModules?: string[]
|
|
1333
1368
|
}> {
|
|
1334
|
-
const
|
|
1335
|
-
|
|
1369
|
+
const original = options?.sdk
|
|
1370
|
+
const moduleRoot =
|
|
1371
|
+
options?.moduleRoot ??
|
|
1372
|
+
defaultSwiftModuleRoot() ??
|
|
1373
|
+
(original?.reemitForWasi ? await swiftDistributionRoot() : undefined)
|
|
1374
|
+
let sdk = original
|
|
1375
|
+
let prepared = await oneNativeControlsPackage(appRoot, linkedGroups, sdk)
|
|
1376
|
+
let receipt: string | undefined
|
|
1377
|
+
let restored = false
|
|
1378
|
+
if (sdk?.reemitForWasi && moduleRoot) {
|
|
1379
|
+
// the package digest covers the full binding and control sources and flags.
|
|
1380
|
+
const target = swiftModuleDigest(moduleRoot).toString('hex')
|
|
1381
|
+
receipt = path.join(
|
|
1382
|
+
path.dirname(prepared.packagePath),
|
|
1383
|
+
`wasi-bindings-${target}.json`,
|
|
1384
|
+
)
|
|
1385
|
+
const cached = cachedWasiBindings(receipt, sdk.files)
|
|
1386
|
+
if (cached) {
|
|
1387
|
+
sdk = { ...sdk, files: cached }
|
|
1388
|
+
prepared = await oneNativeControlsPackage(appRoot, linkedGroups, sdk)
|
|
1389
|
+
restored = true
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1336
1392
|
const compile = async () => {
|
|
1337
1393
|
for (;;) {
|
|
1338
|
-
const { packagePath, oneSDKModules } =
|
|
1339
|
-
appRoot,
|
|
1340
|
-
linkedGroups,
|
|
1341
|
-
sdk,
|
|
1342
|
-
)
|
|
1394
|
+
const { packagePath, oneSDKModules, oneSDKShards } = prepared
|
|
1343
1395
|
if (oneSDKModules?.length)
|
|
1344
1396
|
projectFor(fs.realpathSync(packagePath)).oneModule = false
|
|
1345
1397
|
try {
|
|
@@ -1355,10 +1407,12 @@ export async function stageOneNativeControlsRelease(
|
|
|
1355
1407
|
)
|
|
1356
1408
|
return { packagePath, oneSDKModules, metadata }
|
|
1357
1409
|
} catch (error) {
|
|
1358
|
-
if (!sdk?.reemitForWasi || !(error instanceof Error)) throw error
|
|
1359
|
-
const
|
|
1410
|
+
if (restored || !sdk?.reemitForWasi || !(error instanceof Error)) throw error
|
|
1411
|
+
const diagnostic = translateShardedOneSDKDiagnostic(error.message, oneSDKShards)
|
|
1412
|
+
const files = await sdk.reemitForWasi(diagnostic)
|
|
1360
1413
|
if (!files) throw error
|
|
1361
1414
|
sdk = { ...sdk, files }
|
|
1415
|
+
prepared = await oneNativeControlsPackage(appRoot, linkedGroups, sdk)
|
|
1362
1416
|
}
|
|
1363
1417
|
}
|
|
1364
1418
|
}
|
|
@@ -1369,5 +1423,17 @@ export async function stageOneNativeControlsRelease(
|
|
|
1369
1423
|
ONE_NATIVE_CONTROLS_PACKAGE,
|
|
1370
1424
|
metadata,
|
|
1371
1425
|
)
|
|
1426
|
+
if (receipt && original && sdk && sdk !== original && !restored) {
|
|
1427
|
+
const revised = Object.fromEntries(
|
|
1428
|
+
[...sdk.files].filter(([name, source]) => original.files.get(name) !== source),
|
|
1429
|
+
)
|
|
1430
|
+
const partial = `${receipt}.${process.pid}.${randomUUID()}.tmp`
|
|
1431
|
+
try {
|
|
1432
|
+
fs.writeFileSync(partial, JSON.stringify(revised))
|
|
1433
|
+
fs.renameSync(partial, receipt)
|
|
1434
|
+
} finally {
|
|
1435
|
+
fs.rmSync(partial, { force: true })
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1372
1438
|
return { metadataPath, metadata, files, oneSDKModules }
|
|
1373
1439
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import { installVerifiedTarball } from '@contrast/runtime-delivery'
|
|
4
|
+
import {
|
|
5
|
+
ONE_NATIVE_CONTROLS_RELEASE_PIN,
|
|
6
|
+
ONE_NATIVE_CONTROLS_STAGED_BUNDLE,
|
|
7
|
+
oneNativeControlsReleaseObject,
|
|
8
|
+
parseOneNativeControlsReleasePin,
|
|
9
|
+
} from '../../peach-globals/src/oneNativeControlsReleaseContract'
|
|
10
|
+
import { cacheDir } from './home-paths'
|
|
11
|
+
import { NATIVE_PREBUILT_ORIGIN } from './native-prebuilt'
|
|
12
|
+
import { ONE_NATIVE_CONTROLS_PACKAGE } from './oneNativeControlsContract'
|
|
13
|
+
import {
|
|
14
|
+
resolveRuntimeFilePath,
|
|
15
|
+
runtimeFileHeaders,
|
|
16
|
+
sendFileWithRanges,
|
|
17
|
+
} from './runtime-assets'
|
|
18
|
+
import { SWIFT_PACKAGE_PATH } from './swift-submit'
|
|
19
|
+
import type { IncomingMessage, ServerResponse } from 'node:http'
|
|
20
|
+
|
|
21
|
+
export const ONE_NATIVE_CONTROLS_METADATA_PATH = `${SWIFT_PACKAGE_PATH}${ONE_NATIVE_CONTROLS_PACKAGE}`
|
|
22
|
+
|
|
23
|
+
const PACKAGE_PREFIX = '/__peach/'
|
|
24
|
+
const METADATA_FILE = ONE_NATIVE_CONTROLS_METADATA_PATH.slice(PACKAGE_PREFIX.length)
|
|
25
|
+
const RELEASE_ASSET = /^\/__peach\/swift(?:-(?:icu|res|sdk|sdk-bindings))?\//
|
|
26
|
+
const installing = new Map<string, Promise<void>>()
|
|
27
|
+
|
|
28
|
+
export function isOneNativeControlsReleaseAsset(pathname: string): boolean {
|
|
29
|
+
return RELEASE_ASSET.test(pathname)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export async function serveOneNativeControlsRelease(
|
|
33
|
+
req: IncomingMessage,
|
|
34
|
+
res: ServerResponse,
|
|
35
|
+
pathname: string,
|
|
36
|
+
runtime: string,
|
|
37
|
+
): Promise<boolean> {
|
|
38
|
+
const pin = path.join(runtime, ONE_NATIVE_CONTROLS_RELEASE_PIN)
|
|
39
|
+
if (!fs.existsSync(pin)) return false
|
|
40
|
+
const sha256 = parseOneNativeControlsReleasePin(fs.readFileSync(pin, 'utf8'), pin)
|
|
41
|
+
const destDir = path.join(cacheDir(), 'one-native-controls', sha256)
|
|
42
|
+
const metadata = pathname === ONE_NATIVE_CONTROLS_METADATA_PATH
|
|
43
|
+
if (metadata && !fs.existsSync(path.join(destDir, METADATA_FILE))) {
|
|
44
|
+
let pending = installing.get(sha256)
|
|
45
|
+
if (!pending) {
|
|
46
|
+
const staged = path.join(runtime, ONE_NATIVE_CONTROLS_STAGED_BUNDLE)
|
|
47
|
+
pending = installVerifiedTarball({
|
|
48
|
+
url: `${NATIVE_PREBUILT_ORIGIN}/${oneNativeControlsReleaseObject(sha256)}`,
|
|
49
|
+
localPath: fs.existsSync(staged) ? staged : undefined,
|
|
50
|
+
digest: { algorithm: 'sha256', encoding: 'hex', value: sha256 },
|
|
51
|
+
destDir,
|
|
52
|
+
installedMarker: METADATA_FILE,
|
|
53
|
+
label: ONE_NATIVE_CONTROLS_PACKAGE,
|
|
54
|
+
}).finally(() => installing.delete(sha256))
|
|
55
|
+
installing.set(sha256, pending)
|
|
56
|
+
}
|
|
57
|
+
await pending
|
|
58
|
+
}
|
|
59
|
+
const file = resolveRuntimeFilePath(destDir, pathname.slice(PACKAGE_PREFIX.length - 1))
|
|
60
|
+
if (!file) return false
|
|
61
|
+
const stat = fs.statSync(file)
|
|
62
|
+
sendFileWithRanges(req, res, file, stat.size, {
|
|
63
|
+
...runtimeFileHeaders(file, req.url ?? '', stat.mtime.toUTCString()),
|
|
64
|
+
'access-control-allow-origin': '*',
|
|
65
|
+
'cache-control': metadata ? 'no-store' : 'public, max-age=31536000, immutable',
|
|
66
|
+
...(metadata ? { 'content-type': 'application/json' } : {}),
|
|
67
|
+
})
|
|
68
|
+
return true
|
|
69
|
+
}
|