peachsim 0.1.697 → 0.1.699
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/cli/cloud-test-tunnel.ts +2 -10
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.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/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cli-constants.cjs +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 +1 -1
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +1561 -1439
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +1 -1
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.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/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/render-mode.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 +1 -1
- package/dist-lib/skills.cjs +1482 -1359
- package/dist-lib/swift-compile.cjs +3 -1
- package/dist-lib/swift-compile.mjs +2 -1
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +2 -2
- package/dist-lib/swift-submit.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +2 -2
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/src/expo-swift-host.ts +174 -43
- package/src/expoSwiftContract.ts +19 -0
- package/src/swift-compile.ts +1 -1
- package/src/swift-submit.ts +2 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.699 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -46,6 +46,7 @@ __export(swift_compile_exports, {
|
|
|
46
46
|
swiftModuleSdk: () => swiftModuleSdk,
|
|
47
47
|
swiftSourceAsIOS: () => swiftSourceAsIOS,
|
|
48
48
|
swiftTargetDependencies: () => swiftTargetDependencies,
|
|
49
|
+
syncSwiftTree: () => syncSwiftTree,
|
|
49
50
|
withNativeSourceGlue: () => withNativeSourceGlue,
|
|
50
51
|
writeSwiftProject: () => writeSwiftProject
|
|
51
52
|
});
|
|
@@ -1120,6 +1121,7 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
1120
1121
|
swiftModuleSdk,
|
|
1121
1122
|
swiftSourceAsIOS,
|
|
1122
1123
|
swiftTargetDependencies,
|
|
1124
|
+
syncSwiftTree,
|
|
1123
1125
|
withNativeSourceGlue,
|
|
1124
1126
|
writeSwiftProject
|
|
1125
1127
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.699 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
|
|
3
3
|
// src/swift-compile.ts
|
|
4
4
|
import { execFile as execFile2 } from "node:child_process";
|
|
@@ -1080,6 +1080,7 @@ export {
|
|
|
1080
1080
|
swiftModuleSdk,
|
|
1081
1081
|
swiftSourceAsIOS,
|
|
1082
1082
|
swiftTargetDependencies,
|
|
1083
|
+
syncSwiftTree,
|
|
1083
1084
|
withNativeSourceGlue,
|
|
1084
1085
|
writeSwiftProject
|
|
1085
1086
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.699 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.699 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -51,7 +51,7 @@ var MAX_SWIFT_COMPILE_RESOURCE_TOTAL_BYTES = 8 * 1024 * 1024;
|
|
|
51
51
|
var MAX_SWIFT_COMPILE_IMAGES = 128;
|
|
52
52
|
var MAX_SWIFT_COMPILE_IMAGE_BYTES = 4 * 1024 * 1024;
|
|
53
53
|
var MAX_SWIFT_COMPILE_IMAGE_TOTAL_BYTES = 16 * 1024 * 1024;
|
|
54
|
-
var SWIFT_HOST_ABI =
|
|
54
|
+
var SWIFT_HOST_ABI = 16;
|
|
55
55
|
var POLL_INTERVAL_MS = 1500;
|
|
56
56
|
function swiftNativeEntry(native, file) {
|
|
57
57
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.699 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
|
|
3
3
|
// src/swift-submit.ts
|
|
4
4
|
var SWIFT_COMPILE_PATH = "/api/swift-compile";
|
|
@@ -12,7 +12,7 @@ var MAX_SWIFT_COMPILE_RESOURCE_TOTAL_BYTES = 8 * 1024 * 1024;
|
|
|
12
12
|
var MAX_SWIFT_COMPILE_IMAGES = 128;
|
|
13
13
|
var MAX_SWIFT_COMPILE_IMAGE_BYTES = 4 * 1024 * 1024;
|
|
14
14
|
var MAX_SWIFT_COMPILE_IMAGE_TOTAL_BYTES = 16 * 1024 * 1024;
|
|
15
|
-
var SWIFT_HOST_ABI =
|
|
15
|
+
var SWIFT_HOST_ABI = 16;
|
|
16
16
|
var POLL_INTERVAL_MS = 1500;
|
|
17
17
|
function swiftNativeEntry(native, file) {
|
|
18
18
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.699 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
package/dist-lib/swift.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.699 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
package/dist-lib/vite-swift.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.699 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -1881,7 +1881,7 @@ var MAX_SWIFT_COMPILE_RESOURCE_TOTAL_BYTES = 8 * 1024 * 1024;
|
|
|
1881
1881
|
var MAX_SWIFT_COMPILE_IMAGES = 128;
|
|
1882
1882
|
var MAX_SWIFT_COMPILE_IMAGE_BYTES = 4 * 1024 * 1024;
|
|
1883
1883
|
var MAX_SWIFT_COMPILE_IMAGE_TOTAL_BYTES = 16 * 1024 * 1024;
|
|
1884
|
-
var SWIFT_HOST_ABI =
|
|
1884
|
+
var SWIFT_HOST_ABI = 16;
|
|
1885
1885
|
var POLL_INTERVAL_MS = 1500;
|
|
1886
1886
|
function swiftNativeEntry(native, file) {
|
|
1887
1887
|
return {
|
package/dist-lib/vite.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.699 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
package/package.json
CHANGED
package/src/expo-swift-host.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
1
|
+
// expo's own autolinker selects app-owned Swift modules; the common Swift host
|
|
2
|
+
// validates namespaces independently and links successful registrations together.
|
|
3
3
|
import { execFile } from 'node:child_process'
|
|
4
4
|
import { createHash } from 'node:crypto'
|
|
5
5
|
import fs from 'node:fs'
|
|
@@ -9,9 +9,17 @@ import path from 'node:path'
|
|
|
9
9
|
import { promisify } from 'node:util'
|
|
10
10
|
import { RNX_FORKED_SCRIPT_ENV } from '../cli/internal-child'
|
|
11
11
|
import { isLoopbackHost } from './backend-origin'
|
|
12
|
+
import { swiftTargetDependencies, syncSwiftTree } from './swift-compile'
|
|
12
13
|
import { resolveSwiftModule } from './swift-distribution'
|
|
13
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
artifactFor,
|
|
16
|
+
icuUrl,
|
|
17
|
+
projectFor,
|
|
18
|
+
serveSwiftPackageAsset,
|
|
19
|
+
sourceStamp,
|
|
20
|
+
} from './swift-host'
|
|
14
21
|
import { MAX_SWIFT_COMPILE_FILES, MAX_SWIFT_COMPILE_SOURCE_BYTES } from './swift-submit'
|
|
22
|
+
import type { ExpoSwiftSourceUnit, ExpoSwiftCompilationResult } from './expoSwiftContract'
|
|
15
23
|
import type { IncomingMessage, ServerResponse } from 'node:http'
|
|
16
24
|
|
|
17
25
|
const run = promisify(execFile)
|
|
@@ -23,7 +31,7 @@ export const EXPO_SWIFT_ENTRY = 'Sources/PeachExpoApp/PeachExpoEntry.swift'
|
|
|
23
31
|
|
|
24
32
|
export async function collectExpoSwiftSources(
|
|
25
33
|
appRoot: string,
|
|
26
|
-
): Promise<
|
|
34
|
+
): Promise<ExpoSwiftSourceUnit[] | null> {
|
|
27
35
|
appRoot = fs.realpathSync(appRoot)
|
|
28
36
|
const appRequire = createRequire(path.join(appRoot, 'package.json'))
|
|
29
37
|
let autolinker: string
|
|
@@ -71,10 +79,10 @@ export async function collectExpoSwiftSources(
|
|
|
71
79
|
const resolutions =
|
|
72
80
|
resolved && typeof resolved === 'object' ? Reflect.get(resolved, 'modules') : null
|
|
73
81
|
if (!Array.isArray(resolutions)) throw new Error('invalid Expo Apple resolution')
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
const classes: string[] = []
|
|
82
|
+
const units: ExpoSwiftSourceUnit[] = []
|
|
83
|
+
const namespacesSeen = new Set<string>()
|
|
77
84
|
let bytes = 0
|
|
85
|
+
let fileCount = 0
|
|
78
86
|
for (const entry of Object.values(search)) {
|
|
79
87
|
if (!entry || typeof entry !== 'object')
|
|
80
88
|
throw new Error('invalid Expo autolinking entry')
|
|
@@ -109,9 +117,11 @@ export async function collectExpoSwiftSources(
|
|
|
109
117
|
`${sourceRoot}: local Expo Swift modules need one Apple Swift module`,
|
|
110
118
|
)
|
|
111
119
|
const namespace: string = namespaces[0]
|
|
112
|
-
if (
|
|
120
|
+
if (namespacesSeen.has(namespace))
|
|
113
121
|
throw new Error(`duplicate local Expo Swift module ${namespace}`)
|
|
114
|
-
|
|
122
|
+
namespacesSeen.add(namespace)
|
|
123
|
+
const files: Record<string, string> = {}
|
|
124
|
+
const classes: string[] = []
|
|
115
125
|
for (const module of modules) {
|
|
116
126
|
const className =
|
|
117
127
|
module && typeof module === 'object' ? Reflect.get(module, 'class') : null
|
|
@@ -144,8 +154,9 @@ export async function collectExpoSwiftSources(
|
|
|
144
154
|
if (!child.name.endsWith('.swift')) continue
|
|
145
155
|
const size = fs.statSync(file).size
|
|
146
156
|
bytes += size
|
|
157
|
+
fileCount++
|
|
147
158
|
if (
|
|
148
|
-
|
|
159
|
+
fileCount > MAX_SWIFT_COMPILE_FILES - 2 ||
|
|
149
160
|
bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
150
161
|
)
|
|
151
162
|
throw new Error('Expo Swift sources exceed compile service caps')
|
|
@@ -156,16 +167,52 @@ export async function collectExpoSwiftSources(
|
|
|
156
167
|
}
|
|
157
168
|
}
|
|
158
169
|
walk(ios)
|
|
170
|
+
const unit = { namespace, classes, files }
|
|
171
|
+
files[EXPO_SWIFT_ENTRY] = expoEntry([unit])
|
|
172
|
+
units.push(unit)
|
|
159
173
|
}
|
|
160
|
-
if (
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
174
|
+
if (units.length === 0) return null
|
|
175
|
+
const allFiles: Record<string, string> = Object.assign(
|
|
176
|
+
{},
|
|
177
|
+
...units.map((unit) => unit.files),
|
|
178
|
+
)
|
|
179
|
+
const targets = units.map((unit) => ({
|
|
180
|
+
name: unit.namespace,
|
|
181
|
+
path: `Sources/${unit.namespace}`,
|
|
182
|
+
}))
|
|
183
|
+
const dependencies = swiftTargetDependencies(allFiles, targets)
|
|
184
|
+
const byNamespace = new Map(units.map((unit) => [unit.namespace, unit]))
|
|
185
|
+
for (const unit of units) {
|
|
186
|
+
const included = new Set([unit.namespace])
|
|
187
|
+
const visit = (namespace: string) => {
|
|
188
|
+
for (const dependency of dependencies.get(namespace) ?? []) {
|
|
189
|
+
if (!byNamespace.has(dependency) || included.has(dependency)) continue
|
|
190
|
+
included.add(dependency)
|
|
191
|
+
visit(dependency)
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
visit(unit.namespace)
|
|
195
|
+
for (const namespace of included) {
|
|
196
|
+
if (namespace === unit.namespace) continue
|
|
197
|
+
const dependency = byNamespace.get(namespace)
|
|
198
|
+
if (!dependency) throw new Error(`missing local Swift namespace ${namespace}`)
|
|
199
|
+
for (const [name, source] of Object.entries(allFiles)) {
|
|
200
|
+
if (name.startsWith(`Sources/${namespace}/`)) unit.files[name] = source
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
unit.files['Package.swift'] =
|
|
204
|
+
`// swift-tools-version: 6.0\nimport PackageDescription\nlet package = Package(name: "PeachExpo", targets: [${[...included].map((name) => `.target(name: ${JSON.stringify(name)}, path: ${JSON.stringify(`Sources/${name}`)})`).join(', ')}, .executableTarget(name: "PeachExpoApp", path: "Sources/PeachExpoApp")])\n`
|
|
205
|
+
}
|
|
206
|
+
return units
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function expoEntry(units: ExpoSwiftSourceUnit[]): string {
|
|
210
|
+
return `import SwiftUI\nimport ExpoModulesCore\n${units.map((unit) => `import ${unit.namespace}`).join('\n')}\n\n@main struct PeachExpoApp: RNXPackage {\n init() { MainActor.assumeIsolated { PeachExpoRuntime.register([${units.flatMap((unit) => unit.classes).join(', ')}]) } }\n func view(props: JSON) -> PeachExpoNativeView { PeachExpoNativeView(props: props) }\n}\n\n@_expose(wasm, "peach_expo_call")\n@_cdecl("peach_expo_call")\n@MainActor public func peachExpoCall(_ payload: UnsafePointer<UInt8>?, _ length: Int32) -> UnsafeMutablePointer<UInt8>? {\n PeachExpoRuntime.dispatch(payload, length)\n}\n`
|
|
166
211
|
}
|
|
167
212
|
|
|
168
213
|
const compiling = new Map<string, Promise<unknown>>()
|
|
214
|
+
// a failed compiler result is valid only for the exact app and framework inputs.
|
|
215
|
+
const failedCompilations = new Map<string, { stamp: string; diagnostic: string }>()
|
|
169
216
|
|
|
170
217
|
export async function handleExpoSwiftRequest(
|
|
171
218
|
req: IncomingMessage,
|
|
@@ -205,39 +252,123 @@ export async function handleExpoSwiftRequest(
|
|
|
205
252
|
let pending = compiling.get(root)
|
|
206
253
|
if (!pending) {
|
|
207
254
|
pending = (async () => {
|
|
208
|
-
const
|
|
209
|
-
if (!
|
|
210
|
-
//
|
|
211
|
-
// against the checkout's module or the distribution PEACH_SWIFT_ENDPOINT
|
|
212
|
-
// names. with neither, the app's own native modules stay unregistered,
|
|
213
|
-
// as an unlinked module is.
|
|
255
|
+
const units = await collectExpoSwiftSources(root)
|
|
256
|
+
if (!units) return null
|
|
257
|
+
// source checks isolate failures; successful modules share one linked app.
|
|
214
258
|
const module = await resolveSwiftModule()
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
// this cache belongs to this adapter; original app sources are read only.
|
|
220
|
-
fs.rmSync(sources, { recursive: true, force: true })
|
|
221
|
-
fs.mkdirSync(sources, { recursive: true })
|
|
222
|
-
for (const [name, content] of Object.entries(files)) {
|
|
223
|
-
const target = path.join(packagePath, name)
|
|
224
|
-
fs.mkdirSync(path.dirname(target), { recursive: true })
|
|
225
|
-
fs.writeFileSync(target, content)
|
|
259
|
+
const result: ExpoSwiftCompilationResult = {
|
|
260
|
+
namespaces: units.map((unit) => unit.namespace),
|
|
261
|
+
modules: [],
|
|
262
|
+
failures: [],
|
|
226
263
|
}
|
|
227
|
-
const
|
|
228
|
-
projectFor(packagePath),
|
|
229
|
-
EXPO_SWIFT_ENTRY,
|
|
230
|
-
module.root,
|
|
231
|
-
)
|
|
264
|
+
const key = createHash('sha256').update(fs.realpathSync(root)).digest('hex')
|
|
232
265
|
const host = req.headers.host
|
|
233
266
|
if (!host) throw new Error('Expo Swift request has no host')
|
|
234
267
|
const base = `http://${host}`
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
268
|
+
const linked: ExpoSwiftSourceUnit[] = []
|
|
269
|
+
for (const unit of units) {
|
|
270
|
+
if (!module) {
|
|
271
|
+
result.failures.push({
|
|
272
|
+
namespace: unit.namespace,
|
|
273
|
+
diagnostic: 'No local Swift toolchain or distribution is available',
|
|
274
|
+
})
|
|
275
|
+
continue
|
|
276
|
+
}
|
|
277
|
+
try {
|
|
278
|
+
const packagePath = path.join(
|
|
279
|
+
os.tmpdir(),
|
|
280
|
+
'peach-expo-swift',
|
|
281
|
+
key,
|
|
282
|
+
unit.namespace,
|
|
283
|
+
)
|
|
284
|
+
// preserve the compiler's input stamp across unchanged reloads.
|
|
285
|
+
// only this adapter's build copy is synchronized; app sources are read only.
|
|
286
|
+
syncSwiftTree(
|
|
287
|
+
packagePath,
|
|
288
|
+
new Map(
|
|
289
|
+
Object.entries(unit.files).map(([name, source]) => [
|
|
290
|
+
path.join(packagePath, name),
|
|
291
|
+
source,
|
|
292
|
+
]),
|
|
293
|
+
),
|
|
294
|
+
)
|
|
295
|
+
const stamp = sourceStamp(packagePath, module.root)
|
|
296
|
+
const failed = failedCompilations.get(packagePath)
|
|
297
|
+
if (failed?.stamp === stamp) {
|
|
298
|
+
result.failures.push({
|
|
299
|
+
namespace: unit.namespace,
|
|
300
|
+
diagnostic: failed.diagnostic,
|
|
301
|
+
})
|
|
302
|
+
continue
|
|
303
|
+
}
|
|
304
|
+
failedCompilations.delete(packagePath)
|
|
305
|
+
await artifactFor(
|
|
306
|
+
projectFor(packagePath),
|
|
307
|
+
EXPO_SWIFT_ENTRY,
|
|
308
|
+
module.root,
|
|
309
|
+
).catch((error: unknown) => {
|
|
310
|
+
const diagnostic = error instanceof Error ? error.message : String(error)
|
|
311
|
+
// retain actual source diagnostics, not a timeout or infrastructure failure.
|
|
312
|
+
if (
|
|
313
|
+
/^.+:\d+(?::\d+)?: error:/m.test(diagnostic) &&
|
|
314
|
+
sourceStamp(packagePath, module.root) === stamp
|
|
315
|
+
)
|
|
316
|
+
failedCompilations.set(packagePath, { stamp, diagnostic })
|
|
317
|
+
throw error
|
|
318
|
+
})
|
|
319
|
+
linked.push(unit)
|
|
320
|
+
} catch (error) {
|
|
321
|
+
result.failures.push({
|
|
322
|
+
namespace: unit.namespace,
|
|
323
|
+
diagnostic: error instanceof Error ? error.message : String(error),
|
|
324
|
+
})
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
if (module && linked.length) {
|
|
328
|
+
const files: Record<string, string> = Object.assign(
|
|
329
|
+
{},
|
|
330
|
+
...linked.map((unit) => unit.files),
|
|
331
|
+
)
|
|
332
|
+
files[EXPO_SWIFT_ENTRY] = expoEntry(linked)
|
|
333
|
+
const targets = [
|
|
334
|
+
...new Set(
|
|
335
|
+
Object.keys(files).flatMap((name) => {
|
|
336
|
+
const match = /^Sources\/([^/]+)\//.exec(name)
|
|
337
|
+
return match && match[1] !== 'PeachExpoApp' ? [match[1]] : []
|
|
338
|
+
}),
|
|
339
|
+
),
|
|
340
|
+
]
|
|
341
|
+
files['Package.swift'] =
|
|
342
|
+
`// swift-tools-version: 6.0\nimport PackageDescription\nlet package = Package(name: "PeachExpo", targets: [${targets.map((name) => `.target(name: ${JSON.stringify(name)}, path: ${JSON.stringify(`Sources/${name}`)})`).join(', ')}, .executableTarget(name: "PeachExpoApp", path: "Sources/PeachExpoApp")])\n`
|
|
343
|
+
const packagePath = path.join(
|
|
344
|
+
os.tmpdir(),
|
|
345
|
+
'peach-expo-swift',
|
|
346
|
+
key,
|
|
347
|
+
'linked-app',
|
|
348
|
+
)
|
|
349
|
+
syncSwiftTree(
|
|
350
|
+
packagePath,
|
|
351
|
+
new Map(
|
|
352
|
+
Object.entries(files).map(([name, source]) => [
|
|
353
|
+
path.join(packagePath, name),
|
|
354
|
+
source,
|
|
355
|
+
]),
|
|
356
|
+
),
|
|
357
|
+
)
|
|
358
|
+
const artifact = await artifactFor(
|
|
359
|
+
projectFor(packagePath),
|
|
360
|
+
EXPO_SWIFT_ENTRY,
|
|
361
|
+
module.root,
|
|
362
|
+
)
|
|
363
|
+
result.modules.push({
|
|
364
|
+
namespaces: linked.map((unit) => unit.namespace),
|
|
365
|
+
url: `${base}/__peach/swift/${artifact.hash}.wasm`,
|
|
366
|
+
hash: artifact.hash,
|
|
367
|
+
icuUrl: icuUrl(base, artifact),
|
|
368
|
+
rootId: `${key}/Expo`,
|
|
369
|
+
})
|
|
240
370
|
}
|
|
371
|
+
return result
|
|
241
372
|
})()
|
|
242
373
|
compiling.set(root, pending)
|
|
243
374
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface ExpoSwiftSourceUnit {
|
|
2
|
+
namespace: string
|
|
3
|
+
classes: string[]
|
|
4
|
+
files: Record<string, string>
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface ExpoSwiftCompiledModule {
|
|
8
|
+
namespaces: string[]
|
|
9
|
+
url: string
|
|
10
|
+
hash: string
|
|
11
|
+
icuUrl: string
|
|
12
|
+
rootId: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ExpoSwiftCompilationResult {
|
|
16
|
+
namespaces: string[]
|
|
17
|
+
modules: ExpoSwiftCompiledModule[]
|
|
18
|
+
failures: { namespace: string; diagnostic: string }[]
|
|
19
|
+
}
|
package/src/swift-compile.ts
CHANGED
|
@@ -476,7 +476,7 @@ export function emitSwiftPackageManifest(args: {
|
|
|
476
476
|
// the build tree mirrors the input: a file is written only when its text
|
|
477
477
|
// changed and a file the input dropped is removed, so an unchanged source
|
|
478
478
|
// keeps its mtime and swiftpm rebuilds only what moved. `.build` stays.
|
|
479
|
-
function syncSwiftTree(base: string, files: Map<string, string>): void {
|
|
479
|
+
export function syncSwiftTree(base: string, files: Map<string, string>): void {
|
|
480
480
|
mkdirSync(base, { recursive: true })
|
|
481
481
|
const walk = (dir: string): void => {
|
|
482
482
|
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
package/src/swift-submit.ts
CHANGED
|
@@ -61,8 +61,9 @@ export const MAX_SWIFT_COMPILE_IMAGE_TOTAL_BYTES = 16 * 1024 * 1024
|
|
|
61
61
|
* 13: fetch replies stream headers and pulled body chunks, with cancellation.
|
|
62
62
|
* 14: `permission_status` answers notifications (2) as UNAuthorizationStatus.
|
|
63
63
|
* 15: `rnx_display_link_active` asks the host to tick on every display frame.
|
|
64
|
+
* 16: `peach_expo_call` uses the tagged Expo wire and coded exception replies.
|
|
64
65
|
*/
|
|
65
|
-
export const SWIFT_HOST_ABI =
|
|
66
|
+
export const SWIFT_HOST_ABI = 16
|
|
66
67
|
|
|
67
68
|
export interface SwiftImageUpload {
|
|
68
69
|
/** the raster file picked for the asset (has the extension). */
|