@swiftbrowser/cli 0.6.6 → 0.7.0
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 +73 -5
- package/dist/appSources.d.ts +116 -0
- package/dist/appSources.js +624 -0
- package/dist/appSources.js.map +1 -0
- package/dist/browser.d.ts +4 -0
- package/dist/browser.js +8 -0
- package/dist/browser.js.map +1 -0
- package/dist/build.d.ts +17 -2
- package/dist/build.js +38 -11
- package/dist/build.js.map +1 -1
- package/dist/cli.js +28 -4
- package/dist/cli.js.map +1 -1
- package/dist/commands/build.js +10 -7
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/check.js +38 -8
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/dev.d.ts +8 -4
- package/dist/commands/dev.js +25 -10
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/doctor.d.ts +8 -0
- package/dist/commands/doctor.js +52 -4
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/kit.d.ts +1 -0
- package/dist/commands/kit.js +20 -5
- package/dist/commands/kit.js.map +1 -1
- package/dist/commands/shared.d.ts +24 -6
- package/dist/commands/shared.js +92 -16
- package/dist/commands/shared.js.map +1 -1
- package/dist/commands/test.d.ts +4 -2
- package/dist/commands/test.js +25 -17
- package/dist/commands/test.js.map +1 -1
- package/dist/compat.d.ts +2 -30
- package/dist/compat.js +2 -44
- package/dist/compat.js.map +1 -1
- package/dist/compiler.d.ts +50 -0
- package/dist/compiler.js +94 -0
- package/dist/compiler.js.map +1 -0
- package/dist/config.d.ts +5 -2
- package/dist/config.js +7 -3
- package/dist/config.js.map +1 -1
- package/dist/frameworks.d.ts +30 -0
- package/dist/frameworks.js +48 -0
- package/dist/frameworks.js.map +1 -0
- package/dist/icu.d.ts +2 -4
- package/dist/icu.js +7 -36
- package/dist/icu.js.map +1 -1
- package/dist/kit.d.ts +44 -12
- package/dist/kit.js +149 -27
- package/dist/kit.js.map +1 -1
- package/dist/log.js +2 -1
- package/dist/log.js.map +1 -1
- package/dist/manifest.d.ts +73 -0
- package/dist/manifest.js +324 -0
- package/dist/manifest.js.map +1 -0
- package/dist/moduleCache.d.ts +20 -0
- package/dist/moduleCache.js +98 -0
- package/dist/moduleCache.js.map +1 -0
- package/dist/objc.js +1 -1
- package/dist/objc.js.map +1 -1
- package/dist/packages.d.ts +8 -1
- package/dist/packages.js +10 -2
- package/dist/packages.js.map +1 -1
- package/dist/registry.d.ts +46 -0
- package/dist/registry.js +184 -0
- package/dist/registry.js.map +1 -0
- package/dist/resolve.d.ts +80 -0
- package/dist/resolve.js +396 -0
- package/dist/resolve.js.map +1 -0
- package/dist/stage.d.ts +5 -144
- package/dist/stage.js +19 -516
- package/dist/stage.js.map +1 -1
- package/dist/testDiscovery.d.ts +44 -0
- package/dist/testDiscovery.js +111 -0
- package/dist/testDiscovery.js.map +1 -0
- package/dist/vendor.d.ts +41 -5
- package/dist/vendor.js +71 -31
- package/dist/vendor.js.map +1 -1
- package/dist/wasmCompiler.d.ts +160 -0
- package/dist/wasmCompiler.js +628 -0
- package/dist/wasmCompiler.js.map +1 -0
- package/dist/wasmFlags.d.ts +31 -0
- package/dist/wasmFlags.js +56 -0
- package/dist/wasmFlags.js.map +1 -0
- package/dist/wasmPackages.d.ts +163 -0
- package/dist/wasmPackages.js +466 -0
- package/dist/wasmPackages.js.map +1 -0
- package/dist/wasmSdk.d.ts +27 -0
- package/dist/wasmSdk.js +103 -0
- package/dist/wasmSdk.js.map +1 -0
- package/package.json +6 -5
package/dist/resolve.js
ADDED
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
// Resolving an app's Swift packages without SwiftPM: which version of each
|
|
2
|
+
// package, checked out where. What `swift package show-dependencies` gives
|
|
3
|
+
// vendor.ts, for a machine with no Swift.
|
|
4
|
+
//
|
|
5
|
+
// Versions are a repository's semantic-version tags (`git ls-remote`). A
|
|
6
|
+
// package's dependencies come from its manifest (manifest.ts), and only those
|
|
7
|
+
// the products in use need are followed, as SwiftPM prunes them: a test
|
|
8
|
+
// target's or a plugin's dependencies are not fetched. Each package takes the
|
|
9
|
+
// version a `Package.resolved` pins when that satisfies every requirement
|
|
10
|
+
// on it, else the highest version that does; a requirement found later that
|
|
11
|
+
// the choice breaks makes it choose again, until nothing changes. Checkouts are
|
|
12
|
+
// shallow clones in the CLI's cache, one per package and revision.
|
|
13
|
+
//
|
|
14
|
+
// A package from a registry (`.package(id: "scope.name", ...)`, registry.ts)
|
|
15
|
+
// is chosen the same way from the releases the registry lists, and its
|
|
16
|
+
// source archive unpacked in the cache, one per package and version.
|
|
17
|
+
import { spawnSync } from 'node:child_process';
|
|
18
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, rmSync } from 'node:fs';
|
|
19
|
+
import path from 'node:path';
|
|
20
|
+
import { CliError } from './log.js';
|
|
21
|
+
import { cacheDir } from './toolchain.js';
|
|
22
|
+
export function parseVersion(text) {
|
|
23
|
+
const match = /^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(text);
|
|
24
|
+
if (!match)
|
|
25
|
+
return null;
|
|
26
|
+
return { major: Number(match[1]), minor: Number(match[2] ?? 0), patch: Number(match[3] ?? 0), prerelease: match[4] ? match[4].split('.') : [] };
|
|
27
|
+
}
|
|
28
|
+
export function compareVersions(a, b) {
|
|
29
|
+
for (const key of ['major', 'minor', 'patch'])
|
|
30
|
+
if (a[key] !== b[key])
|
|
31
|
+
return a[key] - b[key];
|
|
32
|
+
// A prerelease comes before its release.
|
|
33
|
+
if (a.prerelease.length === 0 || b.prerelease.length === 0)
|
|
34
|
+
return b.prerelease.length - a.prerelease.length;
|
|
35
|
+
for (let i = 0; i < Math.max(a.prerelease.length, b.prerelease.length); i++) {
|
|
36
|
+
const x = a.prerelease[i];
|
|
37
|
+
const y = b.prerelease[i];
|
|
38
|
+
if (x === undefined)
|
|
39
|
+
return -1;
|
|
40
|
+
if (y === undefined)
|
|
41
|
+
return 1;
|
|
42
|
+
const nx = /^\d+$/.test(x) ? Number(x) : null;
|
|
43
|
+
const ny = /^\d+$/.test(y) ? Number(y) : null;
|
|
44
|
+
if (nx !== null && ny !== null) {
|
|
45
|
+
if (nx !== ny)
|
|
46
|
+
return nx - ny;
|
|
47
|
+
}
|
|
48
|
+
else if (nx !== null || ny !== null) {
|
|
49
|
+
return nx !== null ? -1 : 1;
|
|
50
|
+
}
|
|
51
|
+
else if (x !== y) {
|
|
52
|
+
return x < y ? -1 : 1;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return 0;
|
|
56
|
+
}
|
|
57
|
+
function versionText(v) {
|
|
58
|
+
return `${v.major}.${v.minor}.${v.patch}${v.prerelease.length ? `-${v.prerelease.join('.')}` : ''}`;
|
|
59
|
+
}
|
|
60
|
+
/** Whether `version` meets a version requirement; prereleases only where the requirement names one. */
|
|
61
|
+
export function satisfies(version, requirement) {
|
|
62
|
+
if (requirement.kind === 'exact') {
|
|
63
|
+
const exact = parseVersion(requirement.version);
|
|
64
|
+
return exact !== null && compareVersions(version, exact) === 0;
|
|
65
|
+
}
|
|
66
|
+
if (requirement.kind !== 'range')
|
|
67
|
+
return false;
|
|
68
|
+
const lower = parseVersion(requirement.lower);
|
|
69
|
+
const upper = parseVersion(requirement.upper);
|
|
70
|
+
if (version.prerelease.length > 0 && lower.prerelease.length === 0)
|
|
71
|
+
return false;
|
|
72
|
+
return compareVersions(version, lower) >= 0 && compareVersions(version, upper) < 0;
|
|
73
|
+
}
|
|
74
|
+
/** An Xcode project's dependency rule as a manifest's requirement. */
|
|
75
|
+
export function projectRequirement(rule) {
|
|
76
|
+
const next = (version, part) => {
|
|
77
|
+
const v = parseVersion(version);
|
|
78
|
+
if (!v)
|
|
79
|
+
throw new CliError(`not a version: ${version}`);
|
|
80
|
+
return part === 'major' ? `${v.major + 1}.0.0` : `${v.major}.${v.minor + 1}.0`;
|
|
81
|
+
};
|
|
82
|
+
switch (rule.kind) {
|
|
83
|
+
case 'upToNextMajorVersion': return { kind: 'range', lower: rule.minimumVersion, upper: next(rule.minimumVersion, 'major') };
|
|
84
|
+
case 'upToNextMinorVersion': return { kind: 'range', lower: rule.minimumVersion, upper: next(rule.minimumVersion, 'minor') };
|
|
85
|
+
case 'exactVersion': return { kind: 'exact', version: rule.version };
|
|
86
|
+
case 'versionRange': return { kind: 'range', lower: rule.minimumVersion, upper: rule.maximumVersion };
|
|
87
|
+
case 'branch': return { kind: 'branch', branch: rule.branch };
|
|
88
|
+
case 'revision': return { kind: 'revision', revision: rule.revision };
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/** The pins of a Package.resolved (formats 1, 2 and 3), by identity. */
|
|
92
|
+
export function readPins(text) {
|
|
93
|
+
const pins = new Map();
|
|
94
|
+
const json = JSON.parse(text);
|
|
95
|
+
const entries = json.pins
|
|
96
|
+
? json.pins.map((pin) => ({ identity: pin.identity, state: pin.state }))
|
|
97
|
+
: (json.object?.pins ?? []).map((pin) => ({ identity: identityOf(pin.repositoryURL), state: pin.state }));
|
|
98
|
+
for (const { identity, state } of entries) {
|
|
99
|
+
pins.set(identity, { revision: state.revision ?? '', ...(state.version ? { version: state.version } : {}), ...(state.branch ? { branch: state.branch } : {}) });
|
|
100
|
+
}
|
|
101
|
+
return pins;
|
|
102
|
+
}
|
|
103
|
+
/** SwiftPM's identity of a location: its last path component, without `.git`, lower-cased. */
|
|
104
|
+
export function identityOf(location) {
|
|
105
|
+
return location.replace(/\/+$/, '').split(/[/:]/).pop().replace(/\.git$/, '').toLowerCase();
|
|
106
|
+
}
|
|
107
|
+
function git(args, cwd) {
|
|
108
|
+
const result = spawnSync('git', args, { encoding: 'utf8', ...(cwd ? { cwd } : {}), env: { ...process.env, GIT_TERMINAL_PROMPT: '0' } });
|
|
109
|
+
if (result.error)
|
|
110
|
+
throw new CliError(`reading Swift packages without SwiftPM takes git, which is not on PATH (${result.error.message})`);
|
|
111
|
+
if (result.status !== 0)
|
|
112
|
+
throw new CliError(`git ${args.join(' ')} failed:\n${result.stderr.trim()}`);
|
|
113
|
+
return result.stdout;
|
|
114
|
+
}
|
|
115
|
+
/** The git command line. */
|
|
116
|
+
export const systemGit = {
|
|
117
|
+
tags(url) {
|
|
118
|
+
const tags = new Map();
|
|
119
|
+
for (const line of git(['ls-remote', '--tags', url]).split('\n')) {
|
|
120
|
+
const match = /^([0-9a-f]{40})\trefs\/tags\/(.+?)(\^\{\})?$/.exec(line);
|
|
121
|
+
// An annotated tag's peeled line (^{}) names the commit: it wins.
|
|
122
|
+
if (match && (match[3] || !tags.has(match[2])))
|
|
123
|
+
tags.set(match[2], match[1]);
|
|
124
|
+
}
|
|
125
|
+
return tags;
|
|
126
|
+
},
|
|
127
|
+
branch(url, branch) {
|
|
128
|
+
const line = git(['ls-remote', url, `refs/heads/${branch}`]).trim();
|
|
129
|
+
if (!line)
|
|
130
|
+
throw new CliError(`${url} has no branch ${branch}`);
|
|
131
|
+
return line.split('\t')[0];
|
|
132
|
+
},
|
|
133
|
+
checkout(url, ref, dir) {
|
|
134
|
+
const temp = `${dir}.tmp-${process.pid}`;
|
|
135
|
+
rmSync(temp, { recursive: true, force: true });
|
|
136
|
+
mkdirSync(temp, { recursive: true });
|
|
137
|
+
git(['init', '-q'], temp);
|
|
138
|
+
git(['fetch', '-q', '--depth', '1', url, ref], temp);
|
|
139
|
+
git(['-c', 'advice.detachedHead=false', 'checkout', '-q', 'FETCH_HEAD'], temp);
|
|
140
|
+
const commit = git(['rev-parse', 'HEAD'], temp).trim();
|
|
141
|
+
mkdirSync(path.dirname(dir), { recursive: true });
|
|
142
|
+
rmSync(dir, { recursive: true, force: true });
|
|
143
|
+
renameSync(temp, dir);
|
|
144
|
+
return commit;
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
/** The products of a package that a set of products needs, and the other packages' products they use. */
|
|
148
|
+
function productClosure(manifest, products) {
|
|
149
|
+
const { dump } = manifest;
|
|
150
|
+
const byIdentity = new Map(manifest.dependencies.map((d) => [d.identity, d]));
|
|
151
|
+
// A product dependency names its package by identity, or by the name its declaration gives.
|
|
152
|
+
const packageOf = (name, product) => {
|
|
153
|
+
if (name) {
|
|
154
|
+
const lower = name.toLowerCase();
|
|
155
|
+
if (byIdentity.has(lower))
|
|
156
|
+
return lower;
|
|
157
|
+
const named = manifest.dependencies.find((d) => d.name?.toLowerCase() === lower);
|
|
158
|
+
return named?.identity ?? null;
|
|
159
|
+
}
|
|
160
|
+
return byIdentity.has(product.toLowerCase()) ? product.toLowerCase() : null;
|
|
161
|
+
};
|
|
162
|
+
const packages = new Map();
|
|
163
|
+
const seen = new Set();
|
|
164
|
+
const visit = (target) => {
|
|
165
|
+
if (seen.has(target))
|
|
166
|
+
return;
|
|
167
|
+
seen.add(target);
|
|
168
|
+
const found = dump.targets.find((t) => t.name === target);
|
|
169
|
+
if (!found)
|
|
170
|
+
return;
|
|
171
|
+
for (const dependency of found.dependencies) {
|
|
172
|
+
if ('target' in dependency && dependency.target) {
|
|
173
|
+
visit(dependency.target[0]);
|
|
174
|
+
}
|
|
175
|
+
else if ('product' in dependency && dependency.product) {
|
|
176
|
+
const [product, name] = dependency.product;
|
|
177
|
+
const identity = packageOf(name, product);
|
|
178
|
+
if (identity)
|
|
179
|
+
(packages.get(identity) ?? packages.set(identity, new Set()).get(identity)).add(product);
|
|
180
|
+
}
|
|
181
|
+
else if ('byName' in dependency && dependency.byName) {
|
|
182
|
+
const name = dependency.byName[0];
|
|
183
|
+
if (dump.targets.some((t) => t.name === name))
|
|
184
|
+
visit(name);
|
|
185
|
+
else {
|
|
186
|
+
// A product of a dependency with the same name as its package.
|
|
187
|
+
const identity = packageOf(null, name);
|
|
188
|
+
if (identity)
|
|
189
|
+
(packages.get(identity) ?? packages.set(identity, new Set()).get(identity)).add(name);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
for (const product of dump.products)
|
|
195
|
+
if (products.has(product.name))
|
|
196
|
+
for (const target of product.targets)
|
|
197
|
+
visit(target);
|
|
198
|
+
return { packages };
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* The app's packages, resolved and checked out: each package once, with its
|
|
202
|
+
* version, its checkout and the packages it depends on (the shape vendor.ts
|
|
203
|
+
* reads from SwiftPM).
|
|
204
|
+
*/
|
|
205
|
+
export async function resolvePackages(roots, options) {
|
|
206
|
+
const gitTool = options.git ?? systemGit;
|
|
207
|
+
const checkouts = options.checkouts ?? path.join(cacheDir(), 'checkouts');
|
|
208
|
+
const tagCache = new Map();
|
|
209
|
+
const tagsOf = (url) => {
|
|
210
|
+
let tags = tagCache.get(url);
|
|
211
|
+
if (!tags)
|
|
212
|
+
tagCache.set(url, (tags = gitTool.tags(url)));
|
|
213
|
+
return tags;
|
|
214
|
+
};
|
|
215
|
+
const chosen = new Map();
|
|
216
|
+
const checkout = async (identity, url, ref, commit, version) => {
|
|
217
|
+
const dir = path.join(checkouts, identity, commit);
|
|
218
|
+
if (!existsSync(path.join(dir, '.git'))) {
|
|
219
|
+
options.onProgress?.(`fetching ${identity} ${version === 'unspecified' ? commit.slice(0, 7) : version}`);
|
|
220
|
+
gitTool.checkout(url, ref, dir);
|
|
221
|
+
}
|
|
222
|
+
return { identity, url, version, revision: commit, path: dir, manifest: await options.readManifest(dir), local: false };
|
|
223
|
+
};
|
|
224
|
+
/** The version to check out under every requirement on the package. */
|
|
225
|
+
const choose = async (identity, constraints) => {
|
|
226
|
+
const url = constraints[0].url;
|
|
227
|
+
const pin = options.pins?.get(identity);
|
|
228
|
+
const revisions = [...new Set(constraints.flatMap((c) => (c.requirement.kind === 'revision' ? [c.requirement.revision] : [])))];
|
|
229
|
+
const branches = [...new Set(constraints.flatMap((c) => (c.requirement.kind === 'branch' ? [c.requirement.branch] : [])))];
|
|
230
|
+
if (revisions.length > 1 || branches.length > 1 || (revisions.length > 0 && branches.length > 0)) {
|
|
231
|
+
throw new CliError(`${identity} is required at different revisions or branches: ${constraints.map((c) => `${describe(c.requirement)} (${c.from})`).join(', ')}`);
|
|
232
|
+
}
|
|
233
|
+
if (revisions.length > 0)
|
|
234
|
+
return checkout(identity, url, revisions[0], revisions[0], 'unspecified');
|
|
235
|
+
if (branches.length > 0) {
|
|
236
|
+
const branch = branches[0];
|
|
237
|
+
const commit = pin?.branch === branch ? pin.revision : gitTool.branch(url, branch);
|
|
238
|
+
return checkout(identity, url, commit, commit, 'unspecified');
|
|
239
|
+
}
|
|
240
|
+
const requirements = constraints.map((c) => c.requirement);
|
|
241
|
+
if (constraints.some((c) => c.registry))
|
|
242
|
+
return chooseRelease(identity, constraints, requirements);
|
|
243
|
+
const tags = tagsOf(url);
|
|
244
|
+
const candidates = [...tags.keys()]
|
|
245
|
+
.flatMap((tag) => {
|
|
246
|
+
const version = parseVersion(tag);
|
|
247
|
+
return version && requirements.every((r) => satisfies(version, r)) ? [{ tag, version }] : [];
|
|
248
|
+
})
|
|
249
|
+
.sort((a, b) => compareVersions(b.version, a.version));
|
|
250
|
+
const pinned = pin?.version ? candidates.find((c) => versionText(c.version) === versionText(parseVersion(pin.version))) : undefined;
|
|
251
|
+
const pick = pinned ?? candidates[0];
|
|
252
|
+
if (!pick) {
|
|
253
|
+
throw new CliError(`no version of ${identity} meets every requirement on it: ${constraints.map((c) => `${describe(c.requirement)} (${c.from})`).join(', ')}`);
|
|
254
|
+
}
|
|
255
|
+
return checkout(identity, url, `refs/tags/${pick.tag}`, tags.get(pick.tag), versionText(pick.version));
|
|
256
|
+
};
|
|
257
|
+
const releaseCache = new Map();
|
|
258
|
+
/** A registry package's version under every requirement on it, downloaded. */
|
|
259
|
+
const chooseRelease = async (identity, constraints, requirements) => {
|
|
260
|
+
const id = constraints.find((c) => c.registry).url;
|
|
261
|
+
if (constraints.some((c) => !c.registry)) {
|
|
262
|
+
throw new CliError(`${identity} is required both from a registry (${id}) and from a repository: ${constraints.map((c) => `${c.url} (${c.from})`).join(', ')}`);
|
|
263
|
+
}
|
|
264
|
+
if (!options.registry)
|
|
265
|
+
throw new CliError(`${id} comes from a package registry, and none is configured`);
|
|
266
|
+
let releases = releaseCache.get(identity);
|
|
267
|
+
if (!releases)
|
|
268
|
+
releaseCache.set(identity, (releases = await options.registry.releases(id)));
|
|
269
|
+
const candidates = releases
|
|
270
|
+
.flatMap((release) => {
|
|
271
|
+
const version = parseVersion(release);
|
|
272
|
+
return version && requirements.every((r) => satisfies(version, r)) ? [{ release, version }] : [];
|
|
273
|
+
})
|
|
274
|
+
.sort((a, b) => compareVersions(b.version, a.version));
|
|
275
|
+
const pin = options.pins?.get(identity);
|
|
276
|
+
const pinned = pin?.version ? candidates.find((c) => c.release === pin.version) : undefined;
|
|
277
|
+
const pick = pinned ?? candidates[0];
|
|
278
|
+
if (!pick) {
|
|
279
|
+
throw new CliError(`no release of ${id} meets every requirement on it: ${constraints.map((c) => `${describe(c.requirement)} (${c.from})`).join(', ')}`);
|
|
280
|
+
}
|
|
281
|
+
const dir = path.join(checkouts, identity, pick.release);
|
|
282
|
+
if (!existsSync(dir)) {
|
|
283
|
+
options.onProgress?.(`fetching ${id} ${pick.release} from its registry`);
|
|
284
|
+
await options.registry.download(id, pick.release, dir);
|
|
285
|
+
}
|
|
286
|
+
return { identity, url: id, version: pick.release, revision: null, path: dir, manifest: await options.readManifest(dir), local: false };
|
|
287
|
+
};
|
|
288
|
+
for (let round = 0; round < 20; round++) {
|
|
289
|
+
// Walk the graph from the app with the current choices, collecting every requirement.
|
|
290
|
+
const constraints = new Map();
|
|
291
|
+
const usedProducts = new Map();
|
|
292
|
+
const reached = new Set();
|
|
293
|
+
const queue = roots.map((root) => ({ identity: root.identity, dependency: root, from: 'the app', base: '', products: root.products }));
|
|
294
|
+
let changed = false;
|
|
295
|
+
while (queue.length > 0) {
|
|
296
|
+
const { identity, dependency, from, base, products } = queue.shift();
|
|
297
|
+
const used = usedProducts.get(identity) ?? usedProducts.set(identity, new Set()).get(identity);
|
|
298
|
+
const before = used.size;
|
|
299
|
+
for (const product of products)
|
|
300
|
+
used.add(product);
|
|
301
|
+
if (dependency.kind === 'local' || dependency.kind === 'fileSystem') {
|
|
302
|
+
const dir = path.resolve(base, dependency.path);
|
|
303
|
+
if (!chosen.has(identity)) {
|
|
304
|
+
chosen.set(identity, { identity, url: dir, version: 'unspecified', revision: null, path: dir, manifest: await options.readManifest(dir), local: true });
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
const requirement = dependency.requirement;
|
|
309
|
+
const list = constraints.get(identity) ?? constraints.set(identity, []).get(identity);
|
|
310
|
+
list.push(dependency.kind === 'registry' ? { url: dependency.id, registry: true, requirement, from } : { url: dependency.url, registry: false, requirement, from });
|
|
311
|
+
if (!chosen.has(identity))
|
|
312
|
+
chosen.set(identity, await choose(identity, list));
|
|
313
|
+
}
|
|
314
|
+
// Follow what the products in use need, again whenever more of its products are used.
|
|
315
|
+
if (reached.has(identity) && used.size === before)
|
|
316
|
+
continue;
|
|
317
|
+
reached.add(identity);
|
|
318
|
+
const choice = chosen.get(identity);
|
|
319
|
+
const closure = productClosure(choice.manifest, used);
|
|
320
|
+
for (const [dependencyIdentity, needed] of closure.packages) {
|
|
321
|
+
const declared = choice.manifest.dependencies.find((d) => d.identity === dependencyIdentity);
|
|
322
|
+
queue.push({ identity: dependencyIdentity, dependency: declared, from: `${choice.manifest.dump.name} ${choice.version}`, base: choice.path, products: [...needed] });
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
// A choice a later requirement breaks is made again with all of them.
|
|
326
|
+
for (const [identity, list] of constraints) {
|
|
327
|
+
const choice = chosen.get(identity);
|
|
328
|
+
const version = parseVersion(choice.version);
|
|
329
|
+
const fits = list.every(({ requirement: r }) => r.kind === 'revision' ? choice.revision === r.revision
|
|
330
|
+
: r.kind === 'branch' ? choice.version === 'unspecified'
|
|
331
|
+
: version !== null && satisfies(version, r));
|
|
332
|
+
if (!fits) {
|
|
333
|
+
chosen.set(identity, await choose(identity, list));
|
|
334
|
+
changed = true;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
for (const identity of [...chosen.keys()])
|
|
338
|
+
if (!reached.has(identity))
|
|
339
|
+
chosen.delete(identity);
|
|
340
|
+
if (!changed) {
|
|
341
|
+
return [...chosen.values()].map((choice) => ({
|
|
342
|
+
local: choice.local,
|
|
343
|
+
identity: choice.identity,
|
|
344
|
+
name: choice.manifest.dump.name,
|
|
345
|
+
url: choice.url,
|
|
346
|
+
version: choice.version,
|
|
347
|
+
path: choice.path,
|
|
348
|
+
dependencies: [...productClosure(choice.manifest, usedProducts.get(choice.identity) ?? new Set()).packages.keys()],
|
|
349
|
+
}));
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
throw new CliError('resolving the app\'s Swift packages did not settle');
|
|
353
|
+
}
|
|
354
|
+
function describe(requirement) {
|
|
355
|
+
switch (requirement.kind) {
|
|
356
|
+
case 'exact': return `exactly ${requirement.version}`;
|
|
357
|
+
case 'range': return `${requirement.lower}..<${requirement.upper}`;
|
|
358
|
+
case 'revision': return `revision ${requirement.revision}`;
|
|
359
|
+
case 'branch': return `branch ${requirement.branch}`;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
/** The Package.resolved of an app: its Xcode project's, or its folder's. */
|
|
363
|
+
export function appPins(locations) {
|
|
364
|
+
for (const file of locations) {
|
|
365
|
+
if (existsSync(file)) {
|
|
366
|
+
try {
|
|
367
|
+
return readPins(readFileSync(file, 'utf8'));
|
|
368
|
+
}
|
|
369
|
+
catch {
|
|
370
|
+
// Unreadable: resolve without pins.
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
return new Map();
|
|
375
|
+
}
|
|
376
|
+
/** The app's package dependencies as the resolver's roots. */
|
|
377
|
+
export function rootDependencies(plans) {
|
|
378
|
+
return plans.flatMap((plan) => {
|
|
379
|
+
if (plan.kind !== 'dependency')
|
|
380
|
+
return [];
|
|
381
|
+
const reference = plan.package.reference;
|
|
382
|
+
if (reference.kind === 'local')
|
|
383
|
+
return [{ kind: 'local', identity: plan.identity, path: reference.path, products: [...plan.package.products] }];
|
|
384
|
+
if (reference.kind === 'registry')
|
|
385
|
+
return [{ kind: 'registry', identity: plan.identity, id: reference.id, requirement: projectRequirement(reference.requirement), products: [...plan.package.products] }];
|
|
386
|
+
return [{ kind: 'remote', identity: plan.identity, url: reference.url, requirement: projectRequirement(reference.requirement), products: [...plan.package.products] }];
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
/** Packages without SwiftPM (vendor.ts's PackageTools): this resolver, and manifests read by `readManifest`. */
|
|
390
|
+
export function resolverPackageTools(options) {
|
|
391
|
+
return {
|
|
392
|
+
resolve: async (plans) => (await resolvePackages(rootDependencies(plans), options)).map((node) => ({ ...node })),
|
|
393
|
+
targets: async (packageDir) => (await options.readManifest(packageDir)).dump.targets.map((t) => ({ name: t.name, type: t.type, path: t.path ?? null })),
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,2EAA2E;AAC3E,0CAA0C;AAC1C,EAAE;AACF,yEAAyE;AACzE,8EAA8E;AAC9E,wEAAwE;AACxE,8EAA8E;AAC9E,0EAA0E;AAC1E,4EAA4E;AAC5E,gFAAgF;AAChF,mEAAmE;AACnE,EAAE;AACF,6EAA6E;AAC7E,uEAAuE;AACvE,qEAAqE;AAErE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAClF,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGpC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAg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AC,CAAC,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC;KACxJ,CAAC;AACJ,CAAC"}
|
package/dist/stage.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { type CompiledModel } from './coreml.js';
|
|
2
2
|
import { type ICUData } from './icu.js';
|
|
3
|
+
import { type StageFeatures } from './appSources.js';
|
|
4
|
+
export { transformSource, sceneDelegateClasses, numberCasts, usesObjC, selectorPointers, importsObjectiveC, importsDispatch, usesPosixMutex, rewriteObjC, stripPreviews, matchingBrace, WASM_EXPORTS, APP_STACK_SIZE, LOCALE_WRAPS, appLinkerFlags, linkedProducts, featuresOf, FULL_FOUNDATION_FILE, fullFoundationSource, declaredTypeNames } from './appSources.js';
|
|
5
|
+
export type { StageFeatures, TransformResult } from './appSources.js';
|
|
3
6
|
import type { ResolvedApp } from './project.js';
|
|
4
7
|
import type { Vendored } from './vendor.js';
|
|
5
8
|
export interface StagedApp {
|
|
@@ -16,6 +19,8 @@ export interface StagedApp {
|
|
|
16
19
|
localizations: string[];
|
|
17
20
|
/** What compiling the string tables reported. */
|
|
18
21
|
localizationWarnings: string[];
|
|
22
|
+
/** What the sources use beyond the shim: what the app links. */
|
|
23
|
+
features: StageFeatures;
|
|
19
24
|
}
|
|
20
25
|
/**
|
|
21
26
|
* `$SWIFTBROWSER_BUILD_ROOT`, resolved; unset by default. With it, every app is
|
|
@@ -41,136 +46,6 @@ export declare function testTargetPath(name: string): string;
|
|
|
41
46
|
export declare function scratchPathArgs(): string[];
|
|
42
47
|
/** The built module, optimized or not. */
|
|
43
48
|
export declare function wasmOutput(app: ResolvedApp): string;
|
|
44
|
-
export interface TransformResult {
|
|
45
|
-
text: string;
|
|
46
|
-
previewsStripped: number;
|
|
47
|
-
/** `import Foundation` lines rewritten. */
|
|
48
|
-
foundationRewrites: number;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Adjusts one source for the shim without moving any line, so compiler
|
|
52
|
-
* diagnostics keep their line numbers:
|
|
53
|
-
* - `import SwiftUI` also imports Foundation, FoundationBridge and Observation,
|
|
54
|
-
* as Apple's SwiftUI re-exports Foundation (and Foundation re-exports
|
|
55
|
-
* Observation, so `@Observable` works in a file that imports either alone);
|
|
56
|
-
* - `import Foundation` also imports Observation, for the same reason, and
|
|
57
|
-
* (`bridged`: in a module built against the bridge) FoundationBridge, whose
|
|
58
|
-
* `URLSession`, `UserDefaults`… the alias file names: a public default
|
|
59
|
-
* argument (`session: URLSession = .shared`) may only use a member of a
|
|
60
|
-
* module its own file imports;
|
|
61
|
-
* - `import CoreImage.CIFilterBuiltins` → `import CoreImage`, and likewise
|
|
62
|
-
* `import UIKit.UIImage`, `import os.log`, `import CoreGraphics.CGImage`:
|
|
63
|
-
* on Apple platforms those are Clang submodules; the shim's frameworks are
|
|
64
|
-
* Swift modules, which have no submodules to import;
|
|
65
|
-
* - `delegate?.urlSession?(…)` → `delegate?.urlSession(…)`: the delegate
|
|
66
|
-
* methods are `@objc optional` on Apple platforms, plain requirements with
|
|
67
|
-
* default implementations in FoundationBridge;
|
|
68
|
-
* - `ProcessInfo.processInfo.physicalMemory` → `_swiftBrowserPhysicalMemory` (the alias file's):
|
|
69
|
-
* swift-foundation answers 0 on WASI, and limits sized from it refuse everything;
|
|
70
|
-
* - `import Dispatch` → `import FoundationBridge`: the SDK has no Dispatch on
|
|
71
|
-
* WASI, and the bridge's queues run on the main actor (a package that
|
|
72
|
-
* imports it is built from a copy, vendor.ts);
|
|
73
|
-
* - `import ObjectiveC` → `import FoundationBridge`, which has the associated
|
|
74
|
-
* objects (CoreFoundation.swift), and `unsafeBitCast(Selector(…), to:
|
|
75
|
-
* UnsafeRawPointer.self)` → `Selector(…)._uniquePointer`: on Apple platforms
|
|
76
|
-
* a selector is a uniqued pointer, the usual key of an associated object;
|
|
77
|
-
* here it is a struct, which the bit cast would trap on (`selectorPointers`;
|
|
78
|
-
* a package that imports ObjectiveC is built from a copy, vendor.ts);
|
|
79
|
-
* - `import FoundationLite` → `import FoundationBridge`: FoundationLite was the
|
|
80
|
-
* lean mode's formatting layer (Phase 14 folded it into Foundation); a file
|
|
81
|
-
* that still names it gets the bridge, which holds what remains;
|
|
82
|
-
* - `configuration.delegateClass = SceneDelegate.self` records how to make
|
|
83
|
-
* the scene delegate (`sceneDelegateClasses`);
|
|
84
|
-
* - `x as? AnyObject` → `x as? _AnyObjectValue` in a file that reads a number
|
|
85
|
-
* off it (`.doubleValue`, `.intValue`…): Objective-C finds those members on
|
|
86
|
-
* any object at run time, which the browser's Swift cannot (`numberCasts`);
|
|
87
|
-
* - `@objc` protocols become class-bound, with their `optional` requirements
|
|
88
|
-
* as plain ones that have default implementations, and calls of those
|
|
89
|
-
* requirements (`delegate?.method?(…)`, in any of the module's files:
|
|
90
|
-
* `optionalRequirements`) plain calls; an `override` in an extension is
|
|
91
|
-
* blanked; `#keyPath(Type.property)` becomes `"property"` (objc.ts);
|
|
92
|
-
* - `ProcessInfo()` → `ProcessInfo.processInfo`;
|
|
93
|
-
* - `#Preview { … }` blocks (and `#Preview("name", traits: …) { … }`) become
|
|
94
|
-
* blank lines: the shim has no preview macro and previews are not part of
|
|
95
|
-
* the app. So do the older `struct …: PreviewProvider { … }` declarations,
|
|
96
|
-
* which packages still carry (with preview-only modifiers inside).
|
|
97
|
-
*/
|
|
98
|
-
export declare function transformSource(text: string, options?: {
|
|
99
|
-
bridged?: boolean;
|
|
100
|
-
optionalRequirements?: ReadonlySet<string>;
|
|
101
|
-
}): TransformResult;
|
|
102
|
-
/**
|
|
103
|
-
* `configuration.delegateClass = SceneDelegate.self` →
|
|
104
|
-
* `configuration._setDelegateClass(SceneDelegate.self) { SceneDelegate() }`:
|
|
105
|
-
* UIKit makes the scene delegate through the Objective-C runtime, and Swift
|
|
106
|
-
* without it can only make an instance from a metatype through a `required`
|
|
107
|
-
* initializer (UIKit/SceneDelegates.swift). Same line, so diagnostics keep
|
|
108
|
-
* their places.
|
|
109
|
-
*/
|
|
110
|
-
export declare function sceneDelegateClasses(text: string): string;
|
|
111
|
-
/**
|
|
112
|
-
* `as? AnyObject` → `as? _AnyObjectValue` where the file reads a number from
|
|
113
|
-
* the result: `(dict[key] as? AnyObject)?.doubleValue` looks the member up on
|
|
114
|
-
* any object through Objective-C (nil where there is none); FoundationBridge's
|
|
115
|
-
* `_AnyObjectValue` (Selector.swift) has those members, optional likewise, on
|
|
116
|
-
* the numbers, booleans and strings a dictionary of `Any` holds.
|
|
117
|
-
*/
|
|
118
|
-
export declare function numberCasts(text: string): string;
|
|
119
|
-
/** Whether a source uses the Objective-C runtime's selectors or attributes. */
|
|
120
|
-
export declare function usesObjC(text: string): boolean;
|
|
121
|
-
/**
|
|
122
|
-
* Whether a source calls POSIX mutex functions. WASI's libc module leaves
|
|
123
|
-
* `pthread.h` out, so a package that does is built from a copy: there
|
|
124
|
-
* `#if os(iOS)` holds (Darwin's `os_unfair_lock` branch) and FoundationBridge
|
|
125
|
-
* declares the mutex functions for the page's single thread (Locks.swift).
|
|
126
|
-
*/
|
|
127
|
-
/**
|
|
128
|
-
* `unsafeBitCast(Selector(#function), to: UnsafeRawPointer.self)` →
|
|
129
|
-
* `Selector(#function)._uniquePointer`: the address that stands for the
|
|
130
|
-
* selector's name (FoundationBridge/Selector.swift), which on Apple
|
|
131
|
-
* platforms the bit cast gives, the selector being a uniqued pointer.
|
|
132
|
-
*/
|
|
133
|
-
export declare function selectorPointers(text: string): string;
|
|
134
|
-
/** Whether a source imports ObjectiveC, which the SDK does not have on WASI (transformSource). */
|
|
135
|
-
export declare function importsObjectiveC(text: string): boolean;
|
|
136
|
-
/** Whether a source imports Dispatch, which the SDK does not have on WASI (transformSource). */
|
|
137
|
-
export declare function importsDispatch(text: string): boolean;
|
|
138
|
-
export declare function usesPosixMutex(text: string): boolean;
|
|
139
|
-
/**
|
|
140
|
-
* Objective-C without its runtime (FoundationBridge/Selector.swift). The
|
|
141
|
-
* browser's Swift has no Objective-C interop, so `@objc` (and the Interface
|
|
142
|
-
* Builder attributes that imply it) is dropped, and `#selector(handle(_:))`
|
|
143
|
-
* becomes `Selector(Self.handle(_:), name: "handle(_:)")`: the method itself,
|
|
144
|
-
* which the target/selector APIs call on their target. A qualified method
|
|
145
|
-
* (`Type.method`) is used as it is; one of another object
|
|
146
|
-
* (`#selector(model.refresh)`) is called bound; `getter:`/`setter:`
|
|
147
|
-
* selectors only have a name. A method the file declares `@MainActor` is
|
|
148
|
-
* bound to its target in a closure instead,
|
|
149
|
-
* `Selector(name: "tick", isolated: { (target: Self) in target.tick })`:
|
|
150
|
-
* Swift 6 rejects naming a main-actor method of a class that is not
|
|
151
|
-
* `Sendable` unapplied (Gifu's display link proxy).
|
|
152
|
-
*/
|
|
153
|
-
export declare function rewriteObjC(text: string): string;
|
|
154
|
-
/** Replaces every `#Preview …{ … }` block and `PreviewProvider` struct with blank lines of the same count. */
|
|
155
|
-
export declare function stripPreviews(text: string): {
|
|
156
|
-
text: string;
|
|
157
|
-
count: number;
|
|
158
|
-
};
|
|
159
|
-
/** Index of the `}` closing the `{` at `open`, skipping strings and comments; -1 when unbalanced. */
|
|
160
|
-
export declare function matchingBrace(text: string, open: number): number;
|
|
161
|
-
/** What the app's sources use beyond the shim, which decides what the staging links. */
|
|
162
|
-
export interface StageFeatures {
|
|
163
|
-
/**
|
|
164
|
-
* Some file imports SwiftData: the app links the SwiftData product (and so
|
|
165
|
-
* builds its macros, against swift-syntax), and the generated file routes
|
|
166
|
-
* `#Predicate` to SwiftData's copy of the macro.
|
|
167
|
-
*/
|
|
168
|
-
swiftData: boolean;
|
|
169
|
-
/** The stand-in frameworks (StoreKit, CoreLocation, LocalAuthentication, CoreML, PhotosUI, CoreImage, UserNotifications, …) some file imports; each is linked. */
|
|
170
|
-
frameworks: readonly string[];
|
|
171
|
-
}
|
|
172
|
-
/** The features `sources` (their text) call for. */
|
|
173
|
-
export declare function featuresOf(sources: readonly string[]): StageFeatures;
|
|
174
49
|
/**
|
|
175
50
|
* The Package.swift of the staging package; with `tests` (the names of the
|
|
176
51
|
* app's test targets, for `swiftbrowser test`), a test target for each that
|
|
@@ -179,20 +54,6 @@ export declare function featuresOf(sources: readonly string[]): StageFeatures;
|
|
|
179
54
|
export declare function packageManifest(app: ResolvedApp, swiftPackagePath: string, features?: StageFeatures, vendored?: Vendored, tests?: readonly string[]): string;
|
|
180
55
|
/** Where the compiled string tables go in the staging directory (`<language>.lproj` folders). */
|
|
181
56
|
export declare const LOCALIZATION_DIR = "Localization";
|
|
182
|
-
/** The staged file that settles names declared by both the shim and Foundation. */
|
|
183
|
-
export declare const FULL_FOUNDATION_FILE = "_SwiftBrowserFoundation.swift";
|
|
184
|
-
/**
|
|
185
|
-
* The app imports both the shim and Foundation, and both declare a few names
|
|
186
|
-
* (a module does not shadow another's declarations, only the current module's
|
|
187
|
-
* do). A typealias in the app module does: these point the shared names at
|
|
188
|
-
* the shim's types (what its `frame(width:)` and friends take) and at
|
|
189
|
-
* FoundationBridge's `Timer` and `RunLoop`, which Foundation lacks on WASI
|
|
190
|
-
* (`RunLoop` is marked unavailable, its `Timer` needs CFRunLoop and does not
|
|
191
|
-
* link).
|
|
192
|
-
*/
|
|
193
|
-
export declare function fullFoundationSource(features?: StageFeatures, declared?: ReadonlySet<string>): string;
|
|
194
|
-
/** The type names a module's sources declare at the top level (lines that start with the declaration). */
|
|
195
|
-
export declare function declaredTypeNames(sources: readonly string[]): Set<string>;
|
|
196
57
|
/** The directory the staged sources keep their layout relative to. */
|
|
197
58
|
export declare function commonSourceBase(app: ResolvedApp): string;
|
|
198
59
|
/** The deepest directory holding every one of `files`. */
|