peachsim 0.1.570 → 0.1.571
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 +2 -2
- package/cli/bridge-flow-runner.ts +15 -7
- package/cli/cloud-dispatch.ts +1 -0
- package/cli/cloud-test-result-files.ts +97 -0
- package/cli/commands/maestro.ts +123 -31
- package/cli/commands/test.ts +161 -3
- package/cli/maestro-report.ts +3 -1
- package/cli/outbound-endpoints.ts +2 -0
- package/cli/run-registry.ts +2 -1
- package/detox/jest-preset.cjs +2 -2
- 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 +116 -0
- package/dist-lib/cloud-test-args.mjs +86 -0
- 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/detox/jest-preset.cjs +2 -2
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +16 -7
- 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 +16 -26
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.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/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 +119 -106
- package/dist-lib/swift-compile.cjs +372 -0
- package/dist-lib/swift-compile.mjs +339 -0
- package/dist-lib/swift-package.cjs +78 -0
- package/dist-lib/swift-package.mjs +52 -0
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite.cjs +456 -138
- package/package.json +22 -1
- package/skills/rnx-test/SKILL.md +3 -3
- package/src/cloud-test-args.ts +100 -0
- package/src/rolldown-plugin-swift.ts +8 -7
- package/src/swift-compile.ts +359 -0
- package/src/swift-package.ts +69 -0
- package/src/swift-submit.ts +3 -2
- package/src/vite-plugin-swift.ts +103 -107
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
/*! rnx v0.1.571 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
|
+
"use strict";
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all)
|
|
12
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
+
mod
|
|
29
|
+
));
|
|
30
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
|
+
|
|
32
|
+
// src/swift-compile.ts
|
|
33
|
+
var swift_compile_exports = {};
|
|
34
|
+
__export(swift_compile_exports, {
|
|
35
|
+
MULTI_MANIFEST_VERSION: () => MULTI_MANIFEST_VERSION,
|
|
36
|
+
clearLinkedModuleDigests: () => clearLinkedModuleDigests,
|
|
37
|
+
compileSwiftProjectUnit: () => compileSwiftProjectUnit,
|
|
38
|
+
compileTargets: () => compileTargets,
|
|
39
|
+
emitSwiftPackageManifest: () => emitSwiftPackageManifest,
|
|
40
|
+
swiftArtifactHash: () => swiftArtifactHash,
|
|
41
|
+
swiftModuleInputFiles: () => swiftModuleInputFiles,
|
|
42
|
+
writeSwiftProject: () => writeSwiftProject
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(swift_compile_exports);
|
|
45
|
+
var import_node_child_process = require("node:child_process");
|
|
46
|
+
var import_node_crypto = require("node:crypto");
|
|
47
|
+
var import_node_fs = require("node:fs");
|
|
48
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
49
|
+
var import_node_util = require("node:util");
|
|
50
|
+
|
|
51
|
+
// src/swift-package.ts
|
|
52
|
+
function swiftManifestTargets(manifest) {
|
|
53
|
+
const code = manifest.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/[^\n]*/g, "");
|
|
54
|
+
const targets = [];
|
|
55
|
+
const pattern = /\.(executableTarget|target)\s*\(/g;
|
|
56
|
+
let match;
|
|
57
|
+
while ((match = pattern.exec(code)) !== null) {
|
|
58
|
+
const executable = match[1] === "executableTarget";
|
|
59
|
+
let depth = 1;
|
|
60
|
+
let i = pattern.lastIndex;
|
|
61
|
+
let inString = false;
|
|
62
|
+
let escaped = false;
|
|
63
|
+
let flat = "";
|
|
64
|
+
while (i < code.length && depth > 0) {
|
|
65
|
+
const ch = code[i];
|
|
66
|
+
if (inString) {
|
|
67
|
+
if (escaped) escaped = false;
|
|
68
|
+
else if (ch === "\\") escaped = true;
|
|
69
|
+
else if (ch === '"') inString = false;
|
|
70
|
+
if (depth === 1) flat += ch;
|
|
71
|
+
} else if (ch === '"') {
|
|
72
|
+
inString = true;
|
|
73
|
+
if (depth === 1) flat += ch;
|
|
74
|
+
} else if (ch === "(") {
|
|
75
|
+
depth++;
|
|
76
|
+
if (depth === 1) flat += ch;
|
|
77
|
+
} else if (ch === ")") {
|
|
78
|
+
depth--;
|
|
79
|
+
if (depth >= 1) flat += ch;
|
|
80
|
+
} else if (depth === 1) {
|
|
81
|
+
flat += ch;
|
|
82
|
+
}
|
|
83
|
+
i++;
|
|
84
|
+
}
|
|
85
|
+
const name = /\bname\s*:\s*"([^"]+)"/.exec(flat)?.[1];
|
|
86
|
+
if (!name) continue;
|
|
87
|
+
const rawPath = /\bpath\s*:\s*"([^"]*)"/.exec(flat)?.[1];
|
|
88
|
+
const targetPath = rawPath == null || rawPath === "" ? `Sources/${name}` : rawPath.replace(/^\.\//, "").replace(/\/+$/, "");
|
|
89
|
+
targets.push({ name, path: targetPath, executable });
|
|
90
|
+
}
|
|
91
|
+
return targets;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// src/swift-compile.ts
|
|
95
|
+
var run = (0, import_node_util.promisify)(import_node_child_process.execFile);
|
|
96
|
+
var WASM_TRIPLE = "wasm32-unknown-wasip1";
|
|
97
|
+
function swiftModuleInputFiles(root) {
|
|
98
|
+
const files = ["Package.swift", "scripts/contrast-app-Package.swift"];
|
|
99
|
+
const walk = (dir) => {
|
|
100
|
+
for (const entry of (0, import_node_fs.readdirSync)(import_node_path.default.join(root, dir), { withFileTypes: true })) {
|
|
101
|
+
const relative = `${dir}/${entry.name}`;
|
|
102
|
+
if (entry.isDirectory()) walk(relative);
|
|
103
|
+
else if (entry.name.endsWith(".swift")) files.push(relative);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
walk("Sources");
|
|
107
|
+
return files.sort();
|
|
108
|
+
}
|
|
109
|
+
var linkedModuleDigests = /* @__PURE__ */ new Map();
|
|
110
|
+
function clearLinkedModuleDigests(root) {
|
|
111
|
+
if (root === void 0) linkedModuleDigests.clear();
|
|
112
|
+
else linkedModuleDigests.delete(root);
|
|
113
|
+
}
|
|
114
|
+
function linkedModuleDigest(root) {
|
|
115
|
+
const files = swiftModuleInputFiles(root);
|
|
116
|
+
const stampHash = (0, import_node_crypto.createHash)("sha256");
|
|
117
|
+
for (const file of files) {
|
|
118
|
+
const stat = (0, import_node_fs.statSync)(import_node_path.default.join(root, file), { bigint: true });
|
|
119
|
+
stampHash.update(file);
|
|
120
|
+
stampHash.update(
|
|
121
|
+
`${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}
|
|
122
|
+
`
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
const stamp = stampHash.digest("hex");
|
|
126
|
+
const cached = linkedModuleDigests.get(root);
|
|
127
|
+
if (cached?.stamp === stamp) return cached.digest;
|
|
128
|
+
const hash = (0, import_node_crypto.createHash)("sha256");
|
|
129
|
+
for (const file of files) {
|
|
130
|
+
hash.update((0, import_node_crypto.createHash)("sha256").update(file).digest());
|
|
131
|
+
hash.update(
|
|
132
|
+
(0, import_node_crypto.createHash)("sha256").update((0, import_node_fs.readFileSync)(import_node_path.default.join(root, file))).digest()
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
const digest = hash.digest();
|
|
136
|
+
linkedModuleDigests.set(root, { stamp, digest });
|
|
137
|
+
return digest;
|
|
138
|
+
}
|
|
139
|
+
function compileTargets(input) {
|
|
140
|
+
const manifest = input.files["Package.swift"];
|
|
141
|
+
return manifest === void 0 ? [] : swiftManifestTargets(manifest);
|
|
142
|
+
}
|
|
143
|
+
function swiftSiblingDependencies(files, targets) {
|
|
144
|
+
const names = new Set(targets.map((target) => target.name));
|
|
145
|
+
const siblings = /* @__PURE__ */ new Map();
|
|
146
|
+
for (const target of targets) {
|
|
147
|
+
const prefix = `${target.path}/`;
|
|
148
|
+
const deps = /* @__PURE__ */ new Set();
|
|
149
|
+
for (const [file, contents] of Object.entries(files)) {
|
|
150
|
+
if (file === "Package.swift" || !file.startsWith(prefix)) continue;
|
|
151
|
+
for (const match of contents.matchAll(/^\s*import\s+([A-Za-z_][A-Za-z0-9_]*)/gm)) {
|
|
152
|
+
if (names.has(match[1]) && match[1] !== target.name) deps.add(match[1]);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
siblings.set(target.name, [...deps].sort());
|
|
156
|
+
}
|
|
157
|
+
return siblings;
|
|
158
|
+
}
|
|
159
|
+
var MULTI_MANIFEST_VERSION = 1;
|
|
160
|
+
function swiftArtifactHash(input, release, moduleRoot) {
|
|
161
|
+
const hash = (0, import_node_crypto.createHash)("sha256");
|
|
162
|
+
hash.update(`swift-compile/v1
|
|
163
|
+
${release}
|
|
164
|
+
`);
|
|
165
|
+
hash.update(linkedModuleDigest(moduleRoot));
|
|
166
|
+
for (const file of Object.keys(input.files).sort()) {
|
|
167
|
+
hash.update((0, import_node_crypto.createHash)("sha256").update(file).digest());
|
|
168
|
+
hash.update((0, import_node_crypto.createHash)("sha256").update(input.files[file]).digest());
|
|
169
|
+
}
|
|
170
|
+
for (const base of Object.keys(input.resources ?? {}).sort()) {
|
|
171
|
+
hash.update((0, import_node_crypto.createHash)("sha256").update(base).digest());
|
|
172
|
+
hash.update(
|
|
173
|
+
(0, import_node_crypto.createHash)("sha256").update(input.resources?.[base] ?? "").digest()
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
for (const name of Object.keys(input.images ?? {}).sort()) {
|
|
177
|
+
const image = input.images?.[name];
|
|
178
|
+
if (!image) continue;
|
|
179
|
+
hash.update((0, import_node_crypto.createHash)("sha256").update(name).digest());
|
|
180
|
+
hash.update((0, import_node_crypto.createHash)("sha256").update(image.file).digest());
|
|
181
|
+
hash.update((0, import_node_crypto.createHash)("sha256").update(image.data).digest());
|
|
182
|
+
}
|
|
183
|
+
const targets = compileTargets(input);
|
|
184
|
+
if (targets.length > 0) {
|
|
185
|
+
hash.update(`swift-multi/v${MULTI_MANIFEST_VERSION}
|
|
186
|
+
`);
|
|
187
|
+
hash.update(
|
|
188
|
+
JSON.stringify({
|
|
189
|
+
targets,
|
|
190
|
+
siblings: [...swiftSiblingDependencies(input.files, targets)].sort(
|
|
191
|
+
(a, b) => String(a) < String(b) ? -1 : String(a) > String(b) ? 1 : 0
|
|
192
|
+
)
|
|
193
|
+
})
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
return hash.digest("hex");
|
|
197
|
+
}
|
|
198
|
+
function emitSwiftPackageManifest(args) {
|
|
199
|
+
const { targets, siblings, moduleRoot } = args;
|
|
200
|
+
const executable = targets.find((target) => target.executable);
|
|
201
|
+
if (!executable) throw new Error("swift-compile: no executable target to emit");
|
|
202
|
+
const swiftSettings = 'swiftSettings: [.swiftLanguageMode(.v5), .unsafeFlags(["-Osize"])]';
|
|
203
|
+
const stanza = (target) => {
|
|
204
|
+
const deps = [
|
|
205
|
+
'.product(name: "SwiftUI", package: "sootsim-swift")',
|
|
206
|
+
...(siblings.get(target.name) ?? []).map((sibling) => `"${sibling}"`)
|
|
207
|
+
].join(", ");
|
|
208
|
+
const kind = target.executable ? ".executableTarget" : ".target";
|
|
209
|
+
const link = target.executable ? `,
|
|
210
|
+
linkerSettings: [
|
|
211
|
+
.unsafeFlags([
|
|
212
|
+
"-Xclang-linker", "-mexec-model=reactor",
|
|
213
|
+
"-Xlinker", "--export-if-defined=__main_argc_argv",
|
|
214
|
+
]),
|
|
215
|
+
.unsafeFlags(["-Xlinker", "--strip-all"], .when(configuration: .release)),
|
|
216
|
+
]` : "";
|
|
217
|
+
return [
|
|
218
|
+
` ${kind}(`,
|
|
219
|
+
` name: "${target.name}",`,
|
|
220
|
+
` dependencies: [${deps}],`,
|
|
221
|
+
` path: "${target.path}",`,
|
|
222
|
+
` ${swiftSettings}${link}`,
|
|
223
|
+
` ),`
|
|
224
|
+
].join("\n");
|
|
225
|
+
};
|
|
226
|
+
return [
|
|
227
|
+
"// swift-tools-version: 6.0",
|
|
228
|
+
"import PackageDescription",
|
|
229
|
+
"",
|
|
230
|
+
"// generated by swift-compile from the project package partition.",
|
|
231
|
+
"let package = Package(",
|
|
232
|
+
' name: "app",',
|
|
233
|
+
` products: [.executable(name: "${executable.name}", targets: ["${executable.name}"])],`,
|
|
234
|
+
` dependencies: [.package(path: "${moduleRoot}")],`,
|
|
235
|
+
" targets: [",
|
|
236
|
+
...targets.map(stanza),
|
|
237
|
+
" ]",
|
|
238
|
+
")",
|
|
239
|
+
""
|
|
240
|
+
].join("\n");
|
|
241
|
+
}
|
|
242
|
+
function writeSwiftProject(layout, input, moduleRoot) {
|
|
243
|
+
const targets = compileTargets(input);
|
|
244
|
+
if (targets.length === 0) {
|
|
245
|
+
(0, import_node_fs.rmSync)(layout.sources, { recursive: true, force: true });
|
|
246
|
+
for (const [file, contents] of Object.entries(input.files)) {
|
|
247
|
+
const target = import_node_path.default.join(layout.sources, file);
|
|
248
|
+
(0, import_node_fs.mkdirSync)(import_node_path.default.dirname(target), { recursive: true });
|
|
249
|
+
(0, import_node_fs.writeFileSync)(target, contents, "utf8");
|
|
250
|
+
}
|
|
251
|
+
const manifest = (0, import_node_fs.readFileSync)(
|
|
252
|
+
import_node_path.default.join(moduleRoot, "scripts/contrast-app-Package.swift"),
|
|
253
|
+
"utf8"
|
|
254
|
+
).replaceAll("__SOOTSIM_SWIFT_PACKAGE__", moduleRoot);
|
|
255
|
+
(0, import_node_fs.writeFileSync)(import_node_path.default.join(layout.root, "Package.swift"), manifest, "utf8");
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
(0, import_node_fs.mkdirSync)(layout.root, { recursive: true });
|
|
259
|
+
for (const child of (0, import_node_fs.readdirSync)(layout.root)) {
|
|
260
|
+
if (child === ".build") continue;
|
|
261
|
+
(0, import_node_fs.rmSync)(import_node_path.default.join(layout.root, child), { recursive: true, force: true });
|
|
262
|
+
}
|
|
263
|
+
for (const [file, contents] of Object.entries(input.files)) {
|
|
264
|
+
if (file === "Package.swift") continue;
|
|
265
|
+
const target = import_node_path.default.join(layout.root, file);
|
|
266
|
+
(0, import_node_fs.mkdirSync)(import_node_path.default.dirname(target), { recursive: true });
|
|
267
|
+
(0, import_node_fs.writeFileSync)(target, contents, "utf8");
|
|
268
|
+
}
|
|
269
|
+
(0, import_node_fs.writeFileSync)(
|
|
270
|
+
import_node_path.default.join(layout.root, "Package.swift"),
|
|
271
|
+
emitSwiftPackageManifest({
|
|
272
|
+
targets,
|
|
273
|
+
siblings: swiftSiblingDependencies(input.files, targets),
|
|
274
|
+
moduleRoot
|
|
275
|
+
}),
|
|
276
|
+
"utf8"
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
function streamText(value) {
|
|
280
|
+
if (typeof value === "string") return value.trim();
|
|
281
|
+
if (Buffer.isBuffer(value)) return value.toString("utf8").trim();
|
|
282
|
+
return "";
|
|
283
|
+
}
|
|
284
|
+
function outputOf(error) {
|
|
285
|
+
if (error && typeof error === "object") {
|
|
286
|
+
const streams = [
|
|
287
|
+
streamText(Reflect.get(error, "stdout")),
|
|
288
|
+
streamText(Reflect.get(error, "stderr"))
|
|
289
|
+
].filter(Boolean);
|
|
290
|
+
if (streams.length > 0) return streams.join("\n");
|
|
291
|
+
}
|
|
292
|
+
return error instanceof Error ? error.message : String(error);
|
|
293
|
+
}
|
|
294
|
+
function builtArtifact(layout) {
|
|
295
|
+
const binDir = import_node_path.default.join(layout.root, ".build", WASM_TRIPLE, "release");
|
|
296
|
+
const artifacts = (0, import_node_fs.existsSync)(binDir) ? (0, import_node_fs.readdirSync)(binDir).filter((name) => name.endsWith(".wasm")).sort() : [];
|
|
297
|
+
if (artifacts.length !== 1) {
|
|
298
|
+
throw new Error(
|
|
299
|
+
`swift-compile: the build produced ${artifacts.length} wasm artifacts; exactly one executable is the app`
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
return import_node_path.default.join(binDir, artifacts[0]);
|
|
303
|
+
}
|
|
304
|
+
function projectDiagnostic(output, layout) {
|
|
305
|
+
const base = layout.multi ? layout.root : layout.sources;
|
|
306
|
+
const prefix = `${base}${import_node_path.default.sep}`;
|
|
307
|
+
return output.split("\n").map((line) => line.startsWith(prefix) ? line.slice(prefix.length) : line).join("\n").trim();
|
|
308
|
+
}
|
|
309
|
+
var ROOT_LOCKS = Symbol.for("peachsim.swiftCompile.rootLocks");
|
|
310
|
+
var host = globalThis;
|
|
311
|
+
var rootLocks = host[ROOT_LOCKS] ??= /* @__PURE__ */ new Map();
|
|
312
|
+
function serialize(root, work) {
|
|
313
|
+
const current = rootLocks.get(root) ?? Promise.resolve();
|
|
314
|
+
const next = current.then(work, work);
|
|
315
|
+
rootLocks.set(
|
|
316
|
+
root,
|
|
317
|
+
next.catch(() => {
|
|
318
|
+
})
|
|
319
|
+
);
|
|
320
|
+
return next;
|
|
321
|
+
}
|
|
322
|
+
function compileSwiftProjectUnit(input, options) {
|
|
323
|
+
(0, import_node_fs.mkdirSync)(options.buildRoot, { recursive: true });
|
|
324
|
+
const root = (0, import_node_fs.realpathSync)(options.buildRoot);
|
|
325
|
+
const moduleRoot = import_node_path.default.resolve(options.moduleRoot);
|
|
326
|
+
const layout = {
|
|
327
|
+
root,
|
|
328
|
+
sources: import_node_path.default.join(root, "Sources", "App"),
|
|
329
|
+
multi: compileTargets(input).length > 0
|
|
330
|
+
};
|
|
331
|
+
const hash = swiftArtifactHash(input, options.release, moduleRoot);
|
|
332
|
+
return serialize(root, async () => {
|
|
333
|
+
writeSwiftProject(layout, input, moduleRoot);
|
|
334
|
+
const swift = import_node_path.default.join(options.toolchainBin, "swift");
|
|
335
|
+
if (!(0, import_node_fs.existsSync)(swift)) {
|
|
336
|
+
throw new Error(
|
|
337
|
+
`swift-compile: no swift.org toolchain at ${options.toolchainBin}; install ${options.release} and its matching wasm sdk`
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
try {
|
|
341
|
+
await run(
|
|
342
|
+
swift,
|
|
343
|
+
[
|
|
344
|
+
"build",
|
|
345
|
+
"--package-path",
|
|
346
|
+
root,
|
|
347
|
+
"--swift-sdk",
|
|
348
|
+
`${options.release}_wasm`,
|
|
349
|
+
"-c",
|
|
350
|
+
"release",
|
|
351
|
+
"-Xswiftc",
|
|
352
|
+
"-Osize"
|
|
353
|
+
],
|
|
354
|
+
{ maxBuffer: 64 * 1024 * 1024, timeout: options.timeoutMs }
|
|
355
|
+
);
|
|
356
|
+
} catch (error) {
|
|
357
|
+
throw new Error(projectDiagnostic(outputOf(error), layout), { cause: error });
|
|
358
|
+
}
|
|
359
|
+
return { hash, bytes: (0, import_node_fs.readFileSync)(builtArtifact(layout)) };
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
363
|
+
0 && (module.exports = {
|
|
364
|
+
MULTI_MANIFEST_VERSION,
|
|
365
|
+
clearLinkedModuleDigests,
|
|
366
|
+
compileSwiftProjectUnit,
|
|
367
|
+
compileTargets,
|
|
368
|
+
emitSwiftPackageManifest,
|
|
369
|
+
swiftArtifactHash,
|
|
370
|
+
swiftModuleInputFiles,
|
|
371
|
+
writeSwiftProject
|
|
372
|
+
});
|