peachsim 0.1.715 → 0.1.716
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/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 +63 -21
- 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 +64 -21
- package/dist-lib/swift-compile.cjs +56 -21
- package/dist-lib/swift-compile.mjs +56 -21
- package/dist-lib/swift-package.cjs +27 -5
- package/dist-lib/swift-package.mjs +26 -5
- 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 +63 -21
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/src/swift-compile.ts +43 -20
- package/src/swift-host.ts +9 -0
- package/src/swift-package.ts +42 -5
- package/src/swift-submit.ts +4 -0
package/dist-lib/vite-swift.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.716 | (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;
|
|
@@ -244,7 +244,15 @@ function icuSegment(object) {
|
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
// src/swift-package.ts
|
|
247
|
-
function
|
|
247
|
+
function swiftImplicitResourcePaths(paths) {
|
|
248
|
+
return paths.filter(
|
|
249
|
+
(file) => !file.endsWith(".swift") && (/\.(xcassets|xcstrings|nib|xib|storyboard|xcdatamodeld|xcdatamodel|xcmappingmodel|metal|xcprivacy)(?:\/|$)/.test(
|
|
250
|
+
file
|
|
251
|
+
) || /(?:^|\/)[^/]+\.lproj\/[^/]+$/.test(file))
|
|
252
|
+
).sort();
|
|
253
|
+
}
|
|
254
|
+
function swiftManifestTargets(manifest, resourcePaths = []) {
|
|
255
|
+
const implicitResources = swiftImplicitResourcePaths(resourcePaths);
|
|
248
256
|
const code = manifest.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/[^\n]*/g, "");
|
|
249
257
|
const targets = [];
|
|
250
258
|
const pattern = /\.(executableTarget|target)\s*\(/g;
|
|
@@ -287,7 +295,19 @@ function swiftManifestTargets(manifest) {
|
|
|
287
295
|
/\.swiftLanguageMode\(\s*\.v(\d+)\s*\)/.exec(call)?.[1] ?? "5"
|
|
288
296
|
);
|
|
289
297
|
const mainActorIsolation = /\.defaultIsolation\(\s*MainActor\.self\s*\)/.test(call);
|
|
290
|
-
const
|
|
298
|
+
const excluded = [
|
|
299
|
+
...(/\bexclude\s*:\s*\[([^\]]*)\]/.exec(flat)?.[1] ?? "").matchAll(/"([^"]+)"/g)
|
|
300
|
+
].map((match2) => match2[1].replace(/^\.\//, "").replace(/\/+$/, ""));
|
|
301
|
+
const prefix = targetPath === "." ? "" : `${targetPath}/`;
|
|
302
|
+
const resources = /\bresources\s*:/.test(flat) || implicitResources.some((file) => {
|
|
303
|
+
if (!file.startsWith(prefix)) return false;
|
|
304
|
+
const relative = file.slice(prefix.length);
|
|
305
|
+
if (excluded.some(
|
|
306
|
+
(exclude) => relative === exclude || relative.startsWith(`${exclude}/`)
|
|
307
|
+
))
|
|
308
|
+
return false;
|
|
309
|
+
return true;
|
|
310
|
+
});
|
|
291
311
|
targets.push({
|
|
292
312
|
name,
|
|
293
313
|
path: targetPath,
|
|
@@ -299,8 +319,8 @@ function swiftManifestTargets(manifest) {
|
|
|
299
319
|
}
|
|
300
320
|
return targets;
|
|
301
321
|
}
|
|
302
|
-
function swiftPackagePartition(manifest) {
|
|
303
|
-
const targets = swiftManifestTargets(manifest);
|
|
322
|
+
function swiftPackagePartition(manifest, resourcePaths = []) {
|
|
323
|
+
const targets = swiftManifestTargets(manifest, resourcePaths);
|
|
304
324
|
return targets.length === 1 && targets[0].executable && targets[0].path === "." ? [] : targets;
|
|
305
325
|
}
|
|
306
326
|
|
|
@@ -398,7 +418,7 @@ function swiftModuleDigest(root) {
|
|
|
398
418
|
}
|
|
399
419
|
function compileTargets(input) {
|
|
400
420
|
const manifest = input.files["Package.swift"];
|
|
401
|
-
return manifest === void 0 ? [] : swiftPackagePartition(manifest);
|
|
421
|
+
return manifest === void 0 ? [] : swiftPackagePartition(manifest, input.resourcePaths);
|
|
402
422
|
}
|
|
403
423
|
function withNativeSourceGlue(input, glue) {
|
|
404
424
|
const targets = compileTargets(input);
|
|
@@ -463,7 +483,7 @@ var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"'
|
|
|
463
483
|
var MULTI_MANIFEST_VERSION = 10;
|
|
464
484
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
465
485
|
const hash = (0, import_node_crypto2.createHash)("sha256");
|
|
466
|
-
hash.update(`swift-compile/
|
|
486
|
+
hash.update(`swift-compile/v13
|
|
467
487
|
${release}
|
|
468
488
|
`);
|
|
469
489
|
if (input.oneModule) hash.update("one-module\n");
|
|
@@ -485,6 +505,10 @@ ${release}
|
|
|
485
505
|
hash.update((0, import_node_crypto2.createHash)("sha256").update(image.file).digest());
|
|
486
506
|
hash.update((0, import_node_crypto2.createHash)("sha256").update(image.data).digest());
|
|
487
507
|
}
|
|
508
|
+
for (const file of [...new Set(input.resourcePaths ?? [])].sort()) {
|
|
509
|
+
hash.update("resource-path\n");
|
|
510
|
+
hash.update((0, import_node_crypto2.createHash)("sha256").update(file).digest());
|
|
511
|
+
}
|
|
488
512
|
const targets = compileTargets(input);
|
|
489
513
|
if (targets.length > 0) {
|
|
490
514
|
hash.update(`swift-multi/v${MULTI_MANIFEST_VERSION}
|
|
@@ -936,6 +960,10 @@ function swiftCodeScan(source) {
|
|
|
936
960
|
}
|
|
937
961
|
var compiledSource = (file, contents) => file.endsWith(".swift") ? swiftSourceAsIOS(contents) : contents;
|
|
938
962
|
function writeSwiftProject(layout, input, moduleRoot) {
|
|
963
|
+
const resourceTargets = swiftManifestTargets(
|
|
964
|
+
input.files["Package.swift"] ?? "",
|
|
965
|
+
input.resourcePaths
|
|
966
|
+
);
|
|
939
967
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
940
968
|
const targets = distribution && compileTargets(input).length === 0 ? [
|
|
941
969
|
{
|
|
@@ -954,8 +982,14 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
954
982
|
if (!distribution) {
|
|
955
983
|
modulePlan.update((0, import_node_fs2.readFileSync)(import_node_path2.default.join(moduleRoot, "Package.swift")));
|
|
956
984
|
}
|
|
985
|
+
const resourcePlan = (0, import_node_crypto2.createHash)("sha256").update(
|
|
986
|
+
JSON.stringify(
|
|
987
|
+
resourceTargets.filter((target) => target.resources).map((target) => [target.name, target.path])
|
|
988
|
+
)
|
|
989
|
+
).digest("hex").slice(0, 16);
|
|
957
990
|
const moduleFiles = `
|
|
958
991
|
// sootsim-swift files ${modulePlan.digest("hex").slice(0, 16)}
|
|
992
|
+
// resource accessors ${resourcePlan}
|
|
959
993
|
`;
|
|
960
994
|
if (targets.length === 0) {
|
|
961
995
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
@@ -1008,20 +1042,6 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
1008
1042
|
if (file === "Package.swift") continue;
|
|
1009
1043
|
files.set(import_node_path2.default.join(base, file), compiledSource(file, contents));
|
|
1010
1044
|
}
|
|
1011
|
-
for (const target of targets) {
|
|
1012
|
-
if (!target.resources) continue;
|
|
1013
|
-
files.set(
|
|
1014
|
-
import_node_path2.default.join(layout.root, target.path, "ResourceBundleAccessor.generated.swift"),
|
|
1015
|
-
[
|
|
1016
|
-
"import Foundation",
|
|
1017
|
-
"",
|
|
1018
|
-
"extension Foundation.Bundle {",
|
|
1019
|
-
" static let module: Bundle = Bundle.main",
|
|
1020
|
-
"}",
|
|
1021
|
-
""
|
|
1022
|
-
].join("\n")
|
|
1023
|
-
);
|
|
1024
|
-
}
|
|
1025
1045
|
files.set(
|
|
1026
1046
|
import_node_path2.default.join(layout.root, "Package.swift"),
|
|
1027
1047
|
emitSwiftPackageManifest({
|
|
@@ -1037,6 +1057,21 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
1037
1057
|
}) + moduleFiles
|
|
1038
1058
|
);
|
|
1039
1059
|
}
|
|
1060
|
+
for (const target of resourceTargets) {
|
|
1061
|
+
if (!target.resources) continue;
|
|
1062
|
+
const directory = layout.multi ? import_node_path2.default.join(layout.root, target.path) : layout.sources;
|
|
1063
|
+
files.set(
|
|
1064
|
+
import_node_path2.default.join(directory, "ResourceBundleAccessor.generated.swift"),
|
|
1065
|
+
[
|
|
1066
|
+
"import Foundation",
|
|
1067
|
+
"",
|
|
1068
|
+
"extension Foundation.Bundle {",
|
|
1069
|
+
" static let module: Bundle = Bundle.main",
|
|
1070
|
+
"}",
|
|
1071
|
+
""
|
|
1072
|
+
].join("\n")
|
|
1073
|
+
);
|
|
1074
|
+
}
|
|
1040
1075
|
syncSwiftTree(layout.root, files);
|
|
1041
1076
|
}
|
|
1042
1077
|
function streamText(value) {
|
|
@@ -2323,6 +2358,11 @@ function packageSnapshot(project) {
|
|
|
2323
2358
|
const native = nativeSourceDescriptor(project.packagePath);
|
|
2324
2359
|
return {
|
|
2325
2360
|
files,
|
|
2361
|
+
resourcePaths: swiftImplicitResourcePaths(
|
|
2362
|
+
resourceCandidateFiles(project.packagePath).map(
|
|
2363
|
+
(file) => import_node_path8.default.relative(project.packagePath, file).split(import_node_path8.default.sep).join(import_node_path8.default.posix.sep)
|
|
2364
|
+
)
|
|
2365
|
+
),
|
|
2326
2366
|
resources: buildSwiftResourceTable(project, ""),
|
|
2327
2367
|
bundleFiles: buildSwiftBundleFiles(project.packagePath),
|
|
2328
2368
|
native,
|
|
@@ -2338,6 +2378,7 @@ function packageSnapshot(project) {
|
|
|
2338
2378
|
function snapshotCompileInput(snapshot, entry) {
|
|
2339
2379
|
const input = {
|
|
2340
2380
|
files: snapshot.files,
|
|
2381
|
+
resourcePaths: snapshot.resourcePaths,
|
|
2341
2382
|
resources: snapshot.bundleFiles.files,
|
|
2342
2383
|
images: snapshot.resources.images,
|
|
2343
2384
|
entry,
|
|
@@ -2416,6 +2457,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
2416
2457
|
submit,
|
|
2417
2458
|
{
|
|
2418
2459
|
files: snapshot.files,
|
|
2460
|
+
resourcePaths: snapshot.resourcePaths,
|
|
2419
2461
|
resources: snapshot.bundleFiles.files,
|
|
2420
2462
|
images: snapshot.resources.images,
|
|
2421
2463
|
entry,
|
package/dist-lib/vite.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.716 | (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/swift-compile.ts
CHANGED
|
@@ -44,6 +44,8 @@ const BUILD_JOBS = String(Math.max(1, Math.floor(cores / 2)))
|
|
|
44
44
|
export interface SwiftCompileInput {
|
|
45
45
|
files: Record<string, string>
|
|
46
46
|
resources?: Record<string, string>
|
|
47
|
+
/** project-relative resource paths retained before the bundle namespace flattens. */
|
|
48
|
+
resourcePaths?: string[]
|
|
47
49
|
images?: Record<string, SwiftImageUpload>
|
|
48
50
|
entry: string
|
|
49
51
|
/**
|
|
@@ -207,7 +209,9 @@ export function swiftModuleDigest(root: string): Buffer {
|
|
|
207
209
|
|
|
208
210
|
export function compileTargets(input: SwiftCompileInput): SwiftPackageTarget[] {
|
|
209
211
|
const manifest = input.files['Package.swift']
|
|
210
|
-
return manifest === undefined
|
|
212
|
+
return manifest === undefined
|
|
213
|
+
? []
|
|
214
|
+
: swiftPackagePartition(manifest, input.resourcePaths)
|
|
211
215
|
}
|
|
212
216
|
|
|
213
217
|
/**
|
|
@@ -318,6 +322,7 @@ export function swiftArtifactHash(
|
|
|
318
322
|
moduleRoot: string,
|
|
319
323
|
): string {
|
|
320
324
|
const hash = createHash('sha256')
|
|
325
|
+
// v13: implicit target resources synthesize Bundle.module
|
|
321
326
|
// v12: overrides in an extension of a same-file class lift into the class
|
|
322
327
|
// v10: Foundation-only sources see Dispatch queues
|
|
323
328
|
// v9: table cell and header footer view initializers compile required
|
|
@@ -326,7 +331,7 @@ export function swiftArtifactHash(
|
|
|
326
331
|
// v6: app and scene delegate classes compile final
|
|
327
332
|
// (v5: a target declaring resources gets SwiftPM's Bundle.module accessor;
|
|
328
333
|
// v4: sources compile through swiftSourceAsIOS)
|
|
329
|
-
hash.update(`swift-compile/
|
|
334
|
+
hash.update(`swift-compile/v13\n${release}\n`)
|
|
330
335
|
if (input.oneModule) hash.update('one-module\n')
|
|
331
336
|
hash.update(swiftModuleDigest(moduleRoot))
|
|
332
337
|
for (const file of Object.keys(input.files).sort()) {
|
|
@@ -348,6 +353,10 @@ export function swiftArtifactHash(
|
|
|
348
353
|
hash.update(createHash('sha256').update(image.file).digest())
|
|
349
354
|
hash.update(createHash('sha256').update(image.data).digest())
|
|
350
355
|
}
|
|
356
|
+
for (const file of [...new Set(input.resourcePaths ?? [])].sort()) {
|
|
357
|
+
hash.update('resource-path\n')
|
|
358
|
+
hash.update(createHash('sha256').update(file).digest())
|
|
359
|
+
}
|
|
351
360
|
const targets = compileTargets(input)
|
|
352
361
|
if (targets.length > 0) {
|
|
353
362
|
hash.update(`swift-multi/v${MULTI_MANIFEST_VERSION}\n`)
|
|
@@ -990,6 +999,10 @@ export function writeSwiftProject(
|
|
|
990
999
|
input: SwiftCompileInput,
|
|
991
1000
|
moduleRoot: string,
|
|
992
1001
|
): void {
|
|
1002
|
+
const resourceTargets = swiftManifestTargets(
|
|
1003
|
+
input.files['Package.swift'] ?? '',
|
|
1004
|
+
input.resourcePaths,
|
|
1005
|
+
)
|
|
993
1006
|
const distribution = swiftDistributionAt(moduleRoot)
|
|
994
1007
|
// a distribution ships no manifest template, so a project without its own
|
|
995
1008
|
// manifest compiles as the one App target the template declares
|
|
@@ -1017,7 +1030,17 @@ export function writeSwiftProject(
|
|
|
1017
1030
|
if (!distribution) {
|
|
1018
1031
|
modulePlan.update(readFileSync(path.join(moduleRoot, 'Package.swift')))
|
|
1019
1032
|
}
|
|
1020
|
-
const
|
|
1033
|
+
const resourcePlan = createHash('sha256')
|
|
1034
|
+
.update(
|
|
1035
|
+
JSON.stringify(
|
|
1036
|
+
resourceTargets
|
|
1037
|
+
.filter((target) => target.resources)
|
|
1038
|
+
.map((target) => [target.name, target.path]),
|
|
1039
|
+
),
|
|
1040
|
+
)
|
|
1041
|
+
.digest('hex')
|
|
1042
|
+
.slice(0, 16)
|
|
1043
|
+
const moduleFiles = `\n// sootsim-swift files ${modulePlan.digest('hex').slice(0, 16)}\n// resource accessors ${resourcePlan}\n`
|
|
1021
1044
|
if (targets.length === 0) {
|
|
1022
1045
|
for (const [file, contents] of Object.entries(input.files)) {
|
|
1023
1046
|
if (file === 'Package.swift') continue
|
|
@@ -1072,23 +1095,6 @@ export function writeSwiftProject(
|
|
|
1072
1095
|
if (file === 'Package.swift') continue
|
|
1073
1096
|
files.set(path.join(base, file), compiledSource(file, contents))
|
|
1074
1097
|
}
|
|
1075
|
-
// SwiftPM writes this accessor into a target that declares resources. the
|
|
1076
|
-
// emitted manifest declares none, since Peach serves every target's
|
|
1077
|
-
// resources from the app's one flat bundle, so the accessor names it.
|
|
1078
|
-
for (const target of targets) {
|
|
1079
|
-
if (!target.resources) continue
|
|
1080
|
-
files.set(
|
|
1081
|
-
path.join(layout.root, target.path, 'ResourceBundleAccessor.generated.swift'),
|
|
1082
|
-
[
|
|
1083
|
-
'import Foundation',
|
|
1084
|
-
'',
|
|
1085
|
-
'extension Foundation.Bundle {',
|
|
1086
|
-
' static let module: Bundle = Bundle.main',
|
|
1087
|
-
'}',
|
|
1088
|
-
'',
|
|
1089
|
-
].join('\n'),
|
|
1090
|
-
)
|
|
1091
|
-
}
|
|
1092
1098
|
files.set(
|
|
1093
1099
|
path.join(layout.root, 'Package.swift'),
|
|
1094
1100
|
emitSwiftPackageManifest({
|
|
@@ -1104,6 +1110,23 @@ export function writeSwiftProject(
|
|
|
1104
1110
|
}) + moduleFiles,
|
|
1105
1111
|
)
|
|
1106
1112
|
}
|
|
1113
|
+
// peach serves all target resources from the mount's flat /res bundle.
|
|
1114
|
+
// retain target ownership of the accessor even though its bytes share that bundle.
|
|
1115
|
+
for (const target of resourceTargets) {
|
|
1116
|
+
if (!target.resources) continue
|
|
1117
|
+
const directory = layout.multi ? path.join(layout.root, target.path) : layout.sources
|
|
1118
|
+
files.set(
|
|
1119
|
+
path.join(directory, 'ResourceBundleAccessor.generated.swift'),
|
|
1120
|
+
[
|
|
1121
|
+
'import Foundation',
|
|
1122
|
+
'',
|
|
1123
|
+
'extension Foundation.Bundle {',
|
|
1124
|
+
' static let module: Bundle = Bundle.main',
|
|
1125
|
+
'}',
|
|
1126
|
+
'',
|
|
1127
|
+
].join('\n'),
|
|
1128
|
+
)
|
|
1129
|
+
}
|
|
1107
1130
|
syncSwiftTree(layout.root, files)
|
|
1108
1131
|
}
|
|
1109
1132
|
|
package/src/swift-host.ts
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
swiftModuleInputFiles,
|
|
20
20
|
} from './swift-compile'
|
|
21
21
|
import { swiftDistributionRoot, swiftModuleToolchain } from './swift-distribution'
|
|
22
|
+
import { swiftImplicitResourcePaths } from './swift-package'
|
|
22
23
|
import {
|
|
23
24
|
MAX_SWIFT_COMPILE_FILES,
|
|
24
25
|
MAX_SWIFT_COMPILE_SOURCE_BYTES,
|
|
@@ -521,6 +522,7 @@ function packageSources(packagePath: string): Record<string, string> {
|
|
|
521
522
|
|
|
522
523
|
interface SwiftPackageSnapshot {
|
|
523
524
|
files: Record<string, string>
|
|
525
|
+
resourcePaths: string[]
|
|
524
526
|
resources: SwiftResourceTable
|
|
525
527
|
bundleFiles: SwiftBundlePack
|
|
526
528
|
native: SwiftNativeModules | null
|
|
@@ -532,6 +534,11 @@ function packageSnapshot(project: SwiftProject): SwiftPackageSnapshot {
|
|
|
532
534
|
const native = nativeSourceDescriptor(project.packagePath)
|
|
533
535
|
return {
|
|
534
536
|
files,
|
|
537
|
+
resourcePaths: swiftImplicitResourcePaths(
|
|
538
|
+
resourceCandidateFiles(project.packagePath).map((file) =>
|
|
539
|
+
path.relative(project.packagePath, file).split(path.sep).join(path.posix.sep),
|
|
540
|
+
),
|
|
541
|
+
),
|
|
535
542
|
resources: buildSwiftResourceTable(project, ''),
|
|
536
543
|
bundleFiles: buildSwiftBundleFiles(project.packagePath),
|
|
537
544
|
native,
|
|
@@ -553,6 +560,7 @@ function snapshotCompileInput(
|
|
|
553
560
|
): SwiftCompileInput {
|
|
554
561
|
const input: SwiftCompileInput = {
|
|
555
562
|
files: snapshot.files,
|
|
563
|
+
resourcePaths: snapshot.resourcePaths,
|
|
556
564
|
resources: snapshot.bundleFiles.files,
|
|
557
565
|
images: snapshot.resources.images,
|
|
558
566
|
entry,
|
|
@@ -666,6 +674,7 @@ async function compileRemote(
|
|
|
666
674
|
submit,
|
|
667
675
|
{
|
|
668
676
|
files: snapshot.files,
|
|
677
|
+
resourcePaths: snapshot.resourcePaths,
|
|
669
678
|
resources: snapshot.bundleFiles.files,
|
|
670
679
|
images: snapshot.resources.images,
|
|
671
680
|
entry,
|
package/src/swift-package.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface SwiftPackageTarget {
|
|
|
10
10
|
languageMode: number
|
|
11
11
|
/** true when the target declares `.defaultIsolation(MainActor.self)`. */
|
|
12
12
|
mainActorIsolation: boolean
|
|
13
|
-
/** true when
|
|
13
|
+
/** true when declared or implicit resources give the target `Bundle.module`. */
|
|
14
14
|
resources: boolean
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -20,6 +20,20 @@ export function isSwiftManifestFile(file: string): boolean {
|
|
|
20
20
|
return segments[segments.length - 1] === 'Package.swift'
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
/** the files xcode recognizes as implicit resources, before target exclusions. */
|
|
24
|
+
export function swiftImplicitResourcePaths(paths: readonly string[]): string[] {
|
|
25
|
+
return paths
|
|
26
|
+
.filter(
|
|
27
|
+
(file) =>
|
|
28
|
+
!file.endsWith('.swift') &&
|
|
29
|
+
(/\.(xcassets|xcstrings|nib|xib|storyboard|xcdatamodeld|xcdatamodel|xcmappingmodel|metal|xcprivacy)(?:\/|$)/.test(
|
|
30
|
+
file,
|
|
31
|
+
) ||
|
|
32
|
+
/(?:^|\/)[^/]+\.lproj\/[^/]+$/.test(file)),
|
|
33
|
+
)
|
|
34
|
+
.sort()
|
|
35
|
+
}
|
|
36
|
+
|
|
23
37
|
/**
|
|
24
38
|
* the library and executable targets a sent root manifest declares, in order.
|
|
25
39
|
*
|
|
@@ -29,7 +43,11 @@ export function isSwiftManifestFile(file: string): boolean {
|
|
|
29
43
|
* early), and `name:` / `path:` are read from the call's own depth only, so
|
|
30
44
|
* a nested `.product(name: "SwiftUI", ...)` inside dependencies never wins.
|
|
31
45
|
*/
|
|
32
|
-
export function swiftManifestTargets(
|
|
46
|
+
export function swiftManifestTargets(
|
|
47
|
+
manifest: string,
|
|
48
|
+
resourcePaths: readonly string[] = [],
|
|
49
|
+
): SwiftPackageTarget[] {
|
|
50
|
+
const implicitResources = swiftImplicitResourcePaths(resourcePaths)
|
|
33
51
|
const code = manifest.replace(/\/\*[\s\S]*?\*\//g, '').replace(/\/\/[^\n]*/g, '')
|
|
34
52
|
const targets: SwiftPackageTarget[] = []
|
|
35
53
|
const pattern = /\.(executableTarget|target)\s*\(/g
|
|
@@ -77,7 +95,23 @@ export function swiftManifestTargets(manifest: string): SwiftPackageTarget[] {
|
|
|
77
95
|
/\.swiftLanguageMode\(\s*\.v(\d+)\s*\)/.exec(call)?.[1] ?? '5',
|
|
78
96
|
)
|
|
79
97
|
const mainActorIsolation = /\.defaultIsolation\(\s*MainActor\.self\s*\)/.test(call)
|
|
80
|
-
const
|
|
98
|
+
const excluded = [
|
|
99
|
+
...(/\bexclude\s*:\s*\[([^\]]*)\]/.exec(flat)?.[1] ?? '').matchAll(/"([^"]+)"/g),
|
|
100
|
+
].map((match) => match[1].replace(/^\.\//, '').replace(/\/+$/, ''))
|
|
101
|
+
const prefix = targetPath === '.' ? '' : `${targetPath}/`
|
|
102
|
+
const resources =
|
|
103
|
+
/\bresources\s*:/.test(flat) ||
|
|
104
|
+
implicitResources.some((file) => {
|
|
105
|
+
if (!file.startsWith(prefix)) return false
|
|
106
|
+
const relative = file.slice(prefix.length)
|
|
107
|
+
if (
|
|
108
|
+
excluded.some(
|
|
109
|
+
(exclude) => relative === exclude || relative.startsWith(`${exclude}/`),
|
|
110
|
+
)
|
|
111
|
+
)
|
|
112
|
+
return false
|
|
113
|
+
return true
|
|
114
|
+
})
|
|
81
115
|
targets.push({
|
|
82
116
|
name,
|
|
83
117
|
path: targetPath,
|
|
@@ -95,8 +129,11 @@ export function swiftManifestTargets(manifest: string): SwiftPackageTarget[] {
|
|
|
95
129
|
* executable target at the package root (`path: "."`) holds the whole project,
|
|
96
130
|
* which is the compiler's single-target shape, so it declares no partition.
|
|
97
131
|
*/
|
|
98
|
-
export function swiftPackagePartition(
|
|
99
|
-
|
|
132
|
+
export function swiftPackagePartition(
|
|
133
|
+
manifest: string,
|
|
134
|
+
resourcePaths: readonly string[] = [],
|
|
135
|
+
): SwiftPackageTarget[] {
|
|
136
|
+
const targets = swiftManifestTargets(manifest, resourcePaths)
|
|
100
137
|
return targets.length === 1 && targets[0].executable && targets[0].path === '.'
|
|
101
138
|
? []
|
|
102
139
|
: targets
|
package/src/swift-submit.ts
CHANGED
|
@@ -183,6 +183,8 @@ export type SwiftCompileSubmit = (work: {
|
|
|
183
183
|
files: Record<string, string>
|
|
184
184
|
/** the bundle pack; absent means the project packs none. */
|
|
185
185
|
resources?: Record<string, string>
|
|
186
|
+
/** project-relative resource paths used to associate implicit resources with targets. */
|
|
187
|
+
resourcePaths?: string[]
|
|
186
188
|
/** the photo rasters to publish; absent means the project packs none. */
|
|
187
189
|
images?: Record<string, SwiftImageUpload>
|
|
188
190
|
entry: string
|
|
@@ -330,6 +332,8 @@ export async function compileSwiftProject(
|
|
|
330
332
|
work: {
|
|
331
333
|
files: Record<string, string>
|
|
332
334
|
resources?: Record<string, string>
|
|
335
|
+
/** project-relative resource paths used to associate implicit resources with targets. */
|
|
336
|
+
resourcePaths?: string[]
|
|
333
337
|
images?: Record<string, SwiftImageUpload>
|
|
334
338
|
entry: string
|
|
335
339
|
packageId?: string
|