@swiftbrowser/cli 0.1.0 → 0.3.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.
Files changed (90) hide show
  1. package/README.md +340 -65
  2. package/dist/assetSymbols.d.ts +25 -0
  3. package/dist/assetSymbols.js +218 -0
  4. package/dist/assetSymbols.js.map +1 -0
  5. package/dist/build.d.ts +27 -2
  6. package/dist/build.js +71 -14
  7. package/dist/build.js.map +1 -1
  8. package/dist/buildSettings.d.ts +15 -0
  9. package/dist/buildSettings.js +74 -0
  10. package/dist/buildSettings.js.map +1 -0
  11. package/dist/cli.d.ts +6 -0
  12. package/dist/cli.js +66 -11
  13. package/dist/cli.js.map +1 -1
  14. package/dist/commands/build.js +6 -5
  15. package/dist/commands/build.js.map +1 -1
  16. package/dist/commands/check.js +2 -2
  17. package/dist/commands/check.js.map +1 -1
  18. package/dist/commands/dev.d.ts +5 -2
  19. package/dist/commands/dev.js +19 -13
  20. package/dist/commands/dev.js.map +1 -1
  21. package/dist/commands/init.d.ts +18 -0
  22. package/dist/commands/init.js +59 -0
  23. package/dist/commands/init.js.map +1 -0
  24. package/dist/commands/kit.d.ts +3 -0
  25. package/dist/commands/kit.js +21 -0
  26. package/dist/commands/kit.js.map +1 -0
  27. package/dist/commands/shared.d.ts +28 -4
  28. package/dist/commands/shared.js +106 -11
  29. package/dist/commands/shared.js.map +1 -1
  30. package/dist/commands/test.d.ts +22 -0
  31. package/dist/commands/test.js +95 -0
  32. package/dist/commands/test.js.map +1 -0
  33. package/dist/compat.d.ts +44 -6
  34. package/dist/compat.js +64 -36
  35. package/dist/compat.js.map +1 -1
  36. package/dist/config.d.ts +48 -10
  37. package/dist/config.js +64 -8
  38. package/dist/config.js.map +1 -1
  39. package/dist/coreml.d.ts +194 -0
  40. package/dist/coreml.js +626 -0
  41. package/dist/coreml.js.map +1 -0
  42. package/dist/icu.d.ts +17 -4
  43. package/dist/icu.js +32 -18
  44. package/dist/icu.js.map +1 -1
  45. package/dist/kit.d.ts +133 -0
  46. package/dist/kit.js +403 -0
  47. package/dist/kit.js.map +1 -0
  48. package/dist/objc.d.ts +31 -0
  49. package/dist/objc.js +319 -0
  50. package/dist/objc.js.map +1 -0
  51. package/dist/packagePatches.d.ts +24 -0
  52. package/dist/packagePatches.js +107 -0
  53. package/dist/packagePatches.js.map +1 -0
  54. package/dist/packages.d.ts +59 -0
  55. package/dist/packages.js +149 -0
  56. package/dist/packages.js.map +1 -0
  57. package/dist/project.d.ts +97 -4
  58. package/dist/project.js +157 -20
  59. package/dist/project.js.map +1 -1
  60. package/dist/protobuf.d.ts +62 -0
  61. package/dist/protobuf.js +233 -0
  62. package/dist/protobuf.js.map +1 -0
  63. package/dist/stage.d.ts +175 -28
  64. package/dist/stage.js +551 -85
  65. package/dist/stage.js.map +1 -1
  66. package/dist/strings.d.ts +44 -0
  67. package/dist/strings.js +386 -0
  68. package/dist/strings.js.map +1 -0
  69. package/dist/template.d.ts +39 -0
  70. package/dist/template.js +678 -0
  71. package/dist/template.js.map +1 -0
  72. package/dist/testRunner.d.ts +1 -0
  73. package/dist/testRunner.js +44 -0
  74. package/dist/testRunner.js.map +1 -0
  75. package/dist/threadStacks.d.ts +14 -0
  76. package/dist/threadStacks.js +78 -0
  77. package/dist/threadStacks.js.map +1 -0
  78. package/dist/toolchain.d.ts +7 -1
  79. package/dist/toolchain.js +8 -2
  80. package/dist/toolchain.js.map +1 -1
  81. package/dist/urlSchemes.d.ts +11 -0
  82. package/dist/urlSchemes.js +58 -0
  83. package/dist/urlSchemes.js.map +1 -0
  84. package/dist/vendor.d.ts +109 -0
  85. package/dist/vendor.js +440 -0
  86. package/dist/vendor.js.map +1 -0
  87. package/dist/wasm.d.ts +28 -0
  88. package/dist/wasm.js +84 -0
  89. package/dist/wasm.js.map +1 -0
  90. package/package.json +7 -6
@@ -0,0 +1,218 @@
1
+ // Xcode's generated asset symbols (ASSETCATALOG_COMPILER_GENERATE_ASSET_SYMBOLS,
2
+ // on by default since Xcode 15, and for Swift packages' catalogs): a static
3
+ // member of `ImageResource` for each image or symbol set and of
4
+ // `ColorResource` for each color set, so an app writes `Image(.floor1)` and
5
+ // `Color(.accent)`, with a nested type for each folder that provides a
6
+ // namespace (`ImageResource.Fountain.terracotta`); and, when the target asks
7
+ // for them (..._GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS, set by Xcode's
8
+ // templates), `Color` and `ShapeStyle` members for each color
9
+ // (`.foregroundStyle(.accent)`). The page's asset catalog is the whole
10
+ // app's, so every resource names the main bundle.
11
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
12
+ import path from 'node:path';
13
+ /** The staged file that holds a module's asset symbols. */
14
+ export const ASSET_SYMBOLS_FILE = '_SwiftBrowserAssetSymbols.swift';
15
+ const SWIFT_KEYWORDS = new Set([
16
+ 'associatedtype', 'class', 'deinit', 'enum', 'extension', 'fileprivate', 'func', 'import', 'init', 'inout',
17
+ 'internal', 'let', 'open', 'operator', 'private', 'protocol', 'public', 'rethrows', 'static', 'struct',
18
+ 'subscript', 'typealias', 'var', 'break', 'case', 'continue', 'default', 'defer', 'do', 'else', 'fallthrough',
19
+ 'for', 'guard', 'if', 'in', 'repeat', 'return', 'switch', 'where', 'while', 'as', 'catch', 'false', 'is', 'nil',
20
+ 'super', 'self', 'Self', 'throw', 'throws', 'true', 'try', 'Any', 'Type',
21
+ ]);
22
+ /**
23
+ * `Color` members SwiftUI already has: Xcode generates no `Color` or
24
+ * `ShapeStyle` member for a color set of the same name (the
25
+ * `ColorResource` member is still there).
26
+ */
27
+ const SWIFTUI_COLORS = new Set([
28
+ 'accentColor', 'black', 'blue', 'brown', 'clear', 'cyan', 'gray', 'green', 'indigo', 'mint', 'orange', 'pink',
29
+ 'primary', 'purple', 'red', 'secondary', 'teal', 'white', 'yellow', 'tertiary', 'quaternary', 'quinary',
30
+ 'foreground', 'background', 'selection', 'separator', 'placeholder', 'link', 'fill', 'tint',
31
+ ]);
32
+ /** The words of a name: runs of letters and digits. */
33
+ function words(name) {
34
+ return name.split(/[^A-Za-z0-9]+/).filter((word) => word.length > 0);
35
+ }
36
+ /** Lowercases a word's leading capitals (`URL` → `url`, `URLIcon` → `urlIcon`, `Floor` → `floor`). */
37
+ function lowerFirst(word) {
38
+ const run = /^[A-Z]+/.exec(word)?.[0] ?? '';
39
+ if (run.length <= 1 || run.length === word.length)
40
+ return run.length === word.length ? word.toLowerCase() : word[0].toLowerCase() + word.slice(1);
41
+ // `URLIcon`: the last capital starts the next word.
42
+ return run.slice(0, -1).toLowerCase() + word.slice(run.length - 1);
43
+ }
44
+ function upperFirst(word) {
45
+ return word[0].toUpperCase() + word.slice(1);
46
+ }
47
+ function escape(identifier) {
48
+ if (/^[0-9]/.test(identifier))
49
+ return `_${identifier}`;
50
+ return SWIFT_KEYWORDS.has(identifier) ? `\`${identifier}\`` : identifier;
51
+ }
52
+ /**
53
+ * The member an asset's name becomes, as Xcode names it: a trailing `Color`
54
+ * (of a color set) or `Image` (of an image set) dropped, then lower camel
55
+ * case (`Floor 1` → `floor1`, `AccentColor` → `accent`, `bird-food` →
56
+ * `birdFood`); one that starts with a digit gets an underscore.
57
+ */
58
+ export function assetIdentifier(name, kind) {
59
+ const suffix = kind === 'color' ? 'Color' : 'Image';
60
+ const trimmed = name.endsWith(suffix) && name.length > suffix.length ? name.slice(0, -suffix.length) : name;
61
+ const parts = words(trimmed);
62
+ if (parts.length === 0)
63
+ return '_';
64
+ return escape([lowerFirst(parts[0]), ...parts.slice(1).map(upperFirst)].join(''));
65
+ }
66
+ /** The type a namespace folder becomes (`Fountain`, `bird houses` → `BirdHouses`). */
67
+ export function namespaceIdentifier(name) {
68
+ const parts = words(name);
69
+ if (parts.length === 0)
70
+ return '_';
71
+ return escape(parts.map(upperFirst).join(''));
72
+ }
73
+ function readContents(dir) {
74
+ try {
75
+ return JSON.parse(readFileSync(path.join(dir, 'Contents.json'), 'utf8'));
76
+ }
77
+ catch {
78
+ return null;
79
+ }
80
+ }
81
+ function providesNamespace(dir) {
82
+ const properties = readContents(dir)?.properties;
83
+ return properties?.['provides-namespace'] === true;
84
+ }
85
+ /** Adds a catalog folder's image and color sets to `scope`, under `prefix` (the namespace path). */
86
+ function scan(dir, prefix, scope) {
87
+ let entries;
88
+ try {
89
+ entries = readdirSync(dir, { withFileTypes: true });
90
+ }
91
+ catch {
92
+ return;
93
+ }
94
+ for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
95
+ if (!entry.isDirectory() || entry.name.startsWith('.'))
96
+ continue;
97
+ const full = path.join(dir, entry.name);
98
+ const ext = path.extname(entry.name);
99
+ const base = entry.name.slice(0, entry.name.length - ext.length);
100
+ if (ext === '.imageset' || ext === '.symbolset' || ext === '.colorset') {
101
+ const kind = ext === '.colorset' ? 'color' : 'image';
102
+ scope.symbols.push({ kind, name: `${prefix}${base}`, identifier: assetIdentifier(base, kind) });
103
+ }
104
+ else if (ext === '') {
105
+ if (providesNamespace(full)) {
106
+ const type = namespaceIdentifier(entry.name);
107
+ const inner = scope.namespaces.get(type) ?? { symbols: [], namespaces: new Map() };
108
+ scope.namespaces.set(type, inner);
109
+ scan(full, `${prefix}${entry.name}/`, inner);
110
+ }
111
+ else {
112
+ scan(full, prefix, scope);
113
+ }
114
+ }
115
+ }
116
+ }
117
+ /** Drops symbols whose identifier an earlier one of the same kind took (Xcode reports those). */
118
+ function dedupe(scope) {
119
+ const seen = new Set();
120
+ scope.symbols = scope.symbols.filter((symbol) => {
121
+ const key = `${symbol.kind}:${symbol.identifier}`;
122
+ if (seen.has(key))
123
+ return false;
124
+ seen.add(key);
125
+ return true;
126
+ });
127
+ for (const inner of scope.namespaces.values())
128
+ dedupe(inner);
129
+ }
130
+ /** Members a module's sources declare themselves (`static let floor1`), which a generated one would redeclare. */
131
+ export function declaredStaticMembers(sources) {
132
+ const names = new Set();
133
+ for (const text of sources) {
134
+ for (const match of text.matchAll(/\bstatic\s+(?:let|var)\s+(`?)([A-Za-z_][A-Za-z0-9_]*)\1/g))
135
+ names.add(match[2]);
136
+ }
137
+ return names;
138
+ }
139
+ function resourceMembers(scope, kind, indent) {
140
+ const type = kind === 'image' ? 'ImageResource' : 'ColorResource';
141
+ const lines = [];
142
+ for (const symbol of scope.symbols) {
143
+ if (symbol.kind !== kind)
144
+ continue;
145
+ lines.push(`${indent}static let ${symbol.identifier} = ${type}(name: ${JSON.stringify(symbol.name)}, bundle: FoundationBridge.Bundle.main)`);
146
+ }
147
+ for (const [name, inner] of scope.namespaces) {
148
+ const members = resourceMembers(inner, kind, `${indent} `);
149
+ if (members.length === 0)
150
+ continue;
151
+ lines.push(`${indent}enum ${name} {`, ...members, `${indent}}`);
152
+ }
153
+ return lines;
154
+ }
155
+ /**
156
+ * The Swift source of a module's asset symbols, for its catalogs (empty
157
+ * when they have no image, symbol or color sets). `extensions` adds the
158
+ * `Color` and `ShapeStyle` members of the top level's colors, except those
159
+ * SwiftUI has or the module declares itself (`declared`).
160
+ */
161
+ export function assetSymbolsSource(catalogs, options = {}) {
162
+ const root = { symbols: [], namespaces: new Map() };
163
+ for (const catalog of catalogs)
164
+ if (existsSync(catalog))
165
+ scan(catalog, '', root);
166
+ dedupe(root);
167
+ const images = resourceMembers(root, 'image', ' ');
168
+ const colors = resourceMembers(root, 'color', ' ');
169
+ if (images.length === 0 && colors.length === 0)
170
+ return '';
171
+ const out = [
172
+ '// Generated by @swiftbrowser/cli: the asset symbols Xcode generates for',
173
+ '// this module\'s asset catalogs (assetSymbols.ts).',
174
+ 'import SwiftUI',
175
+ 'import FoundationBridge',
176
+ '',
177
+ ];
178
+ if (images.length > 0)
179
+ out.push('extension ImageResource {', ...images, '}', '');
180
+ if (colors.length > 0)
181
+ out.push('extension ColorResource {', ...colors, '}', '');
182
+ if (options.extensions) {
183
+ const declared = options.declared ?? new Set();
184
+ const shortcuts = root.symbols.filter((symbol) => symbol.kind === 'color'
185
+ && !SWIFTUI_COLORS.has(symbol.identifier) && !declared.has(symbol.identifier.replace(/`/g, '')));
186
+ if (shortcuts.length > 0) {
187
+ const member = (symbol) => ` static var ${symbol.identifier}: Color { Color(ColorResource.${symbol.identifier}) }`;
188
+ out.push('extension Color {', ...shortcuts.map(member), '}', '');
189
+ out.push('extension ShapeStyle where Self == Color {', ...shortcuts.map(member), '}', '');
190
+ }
191
+ }
192
+ return out.join('\n');
193
+ }
194
+ /** The asset catalogs in a package target's folder (SwiftPM processes them as the target's resources). */
195
+ export function targetCatalogs(sourceDir) {
196
+ const out = [];
197
+ const walk = (dir) => {
198
+ let entries;
199
+ try {
200
+ entries = readdirSync(dir, { withFileTypes: true });
201
+ }
202
+ catch {
203
+ return;
204
+ }
205
+ for (const entry of entries) {
206
+ if (!entry.isDirectory() || entry.name.startsWith('.') || entry.name === 'Tests')
207
+ continue;
208
+ const full = path.join(dir, entry.name);
209
+ if (entry.name.endsWith('.xcassets'))
210
+ out.push(full);
211
+ else
212
+ walk(full);
213
+ }
214
+ };
215
+ walk(sourceDir);
216
+ return out.sort();
217
+ }
218
+ //# sourceMappingURL=assetSymbols.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assetSymbols.js","sourceRoot":"","sources":["../src/assetSymbols.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,4EAA4E;AAC5E,gEAAgE;AAChE,4EAA4E;AAC5E,uEAAuE;AACvE,6EAA6E;AAC7E,uEAAuE;AACvE,8DAA8D;AAC9D,uEAAuE;AACvE,kDAAkD;AAElD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,2DAA2D;AAC3D,MAAM,CAAC,MAAM,kBAAkB,GAAG,iCAAiC,CAAC;AAgBpE,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,gBAAgB,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO;IA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B,CAAC;IACH,CAAC,CAAC;IACF,IAAI,CAAC,SAAS,CAAC,CAAC;IAChB,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC;AACpB,CAAC"}
package/dist/build.d.ts CHANGED
@@ -4,6 +4,8 @@ import { type Toolchain } from './toolchain.js';
4
4
  export interface RunResult {
5
5
  status: number;
6
6
  output: string;
7
+ /** The signal that ended the process (`SIGSEGV`), if one did. */
8
+ signal?: string;
7
9
  }
8
10
  /** Runs a command, capturing stdout+stderr interleaved; `onOutput` streams it as it arrives. */
9
11
  export declare function run(command: string, args: string[], options: {
@@ -25,12 +27,35 @@ export interface BuildOptions {
25
27
  /** `swift build` for the host: compile errors only, no module produced that we use. */
26
28
  export declare function checkHost(options: BuildOptions): Promise<void>;
27
29
  /**
28
- * Builds the module for WebAssembly (release) and copies it to `wasmOutput(app)`;
30
+ * Builds the module for WebAssembly (release) and writes it to `wasmOutput(app)`;
29
31
  * with `wasmOpt` set it is also optimized for size and stripped (the ~2.5×
30
- * smaller download of a `build`; `dev` skips it for quick rebuilds).
32
+ * smaller download of a `build`; `dev` skips it for quick rebuilds). The
33
+ * autolink record is then dropped from the module (see wasm.ts).
31
34
  */
32
35
  export declare function buildWasm(options: BuildOptions & {
33
36
  wasmOpt?: string | null;
37
+ swiftFlags?: readonly string[];
34
38
  }): Promise<string>;
39
+ /**
40
+ * Builds the staged tests (`stage(…, { tests: true })`) for WebAssembly and
41
+ * returns the test modules to run. Debug: `@testable import` needs testing
42
+ * enabled, which SwiftPM turns on in debug builds, and debug compiles faster.
43
+ * Swift Build links a module per test target (`<Target>-test-runner.wasm`);
44
+ * the native build system, one for the package (`<Package>PackageTests.xctest`).
45
+ */
46
+ export declare function buildTests(options: BuildOptions & {
47
+ swiftFlags?: readonly string[];
48
+ }): Promise<string[]>;
49
+ /**
50
+ * Optimizes `input` for size and strips it into `output` with wasm-opt: what
51
+ * `build` does after the link, and what CI does to the unoptimized modules
52
+ * its tests ran on before deploying them (scripts/optimize-wasm.mjs).
53
+ */
54
+ export declare function optimizeWasm(wasmOpt: string, input: string, output: string, options: {
55
+ cwd: string;
56
+ env: NodeJS.ProcessEnv;
57
+ }): Promise<void>;
58
+ /** Drops the Swift driver's autolink record from a linked module (`wasm.ts`). */
59
+ export declare function stripAutolink(wasm: string): void;
35
60
  export declare function fileSize(file: string): number;
36
61
  export declare function formatBytes(bytes: number): string;
package/dist/build.js CHANGED
@@ -1,11 +1,13 @@
1
1
  // Compiling the staging package: natively for `check` (fast, same
2
- // diagnostics), for WebAssembly for `dev` and `build`, then wasm-opt.
2
+ // diagnostics), for WebAssembly for `dev`, `build` and `test`, then wasm-opt.
3
3
  import { spawn } from 'node:child_process';
4
- import { copyFileSync, existsSync, mkdirSync, statSync } from 'node:fs';
4
+ import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from 'node:fs';
5
5
  import path from 'node:path';
6
6
  import { CliError } from './log.js';
7
- import { remapDiagnostics, wasmOutput } from './stage.js';
8
- import { WASM_SDK, toolchainEnv } from './toolchain.js';
7
+ import { remapDiagnostics, scratchPathArgs, wasmOutput } from './stage.js';
8
+ import { wasmOptWithThreadStacks } from './threadStacks.js';
9
+ import { WASM_SDK, cacheDir, toolchainEnv } from './toolchain.js';
10
+ import { AUTOLINK_SECTION, rewriteCustomSections } from './wasm.js';
9
11
  /** Runs a command, capturing stdout+stderr interleaved; `onOutput` streams it as it arrives. */
10
12
  export function run(command, args, options) {
11
13
  return new Promise((resolve, reject) => {
@@ -19,7 +21,7 @@ export function run(command, args, options) {
19
21
  child.stdout.on('data', collect);
20
22
  child.stderr.on('data', collect);
21
23
  child.on('error', reject);
22
- child.on('close', (status) => resolve({ status: status ?? 1, output }));
24
+ child.on('close', (status, signal) => resolve({ status: status ?? 1, output, ...(signal ? { signal } : {}) }));
23
25
  });
24
26
  }
25
27
  /** Only the diagnostics and the summary lines of a SwiftPM build log. */
@@ -67,7 +69,7 @@ export function diagnosticsOnly(output) {
67
69
  /** `swift build` for the host: compile errors only, no module produced that we use. */
68
70
  export async function checkHost(options) {
69
71
  const { toolchain, staged, app } = options;
70
- const result = await run(toolchain.swift, ['build', '--product', app.name], {
72
+ const result = await run(toolchain.swift, ['build', ...scratchPathArgs(), '--product', app.name], {
71
73
  cwd: staged.dir,
72
74
  env: toolchainEnv(toolchain),
73
75
  ...(options.onOutput ? { onOutput: options.onOutput } : {}),
@@ -76,14 +78,17 @@ export async function checkHost(options) {
76
78
  throw new CliError(remapDiagnostics(diagnosticsOnly(result.output) || result.output, staged));
77
79
  }
78
80
  /**
79
- * Builds the module for WebAssembly (release) and copies it to `wasmOutput(app)`;
81
+ * Builds the module for WebAssembly (release) and writes it to `wasmOutput(app)`;
80
82
  * with `wasmOpt` set it is also optimized for size and stripped (the ~2.5×
81
- * smaller download of a `build`; `dev` skips it for quick rebuilds).
83
+ * smaller download of a `build`; `dev` skips it for quick rebuilds). The
84
+ * autolink record is then dropped from the module (see wasm.ts).
82
85
  */
83
86
  export async function buildWasm(options) {
84
87
  const { toolchain, staged, app } = options;
85
88
  const env = toolchainEnv(toolchain);
86
- const common = ['--swift-sdk', WASM_SDK, '-c', 'release'];
89
+ // `swiftFlags` reach every Swift target built for WebAssembly, packages
90
+ // included: the kit's module search path and macros (kit.ts).
91
+ const common = ['--swift-sdk', WASM_SDK, '-c', 'release', ...scratchPathArgs(), ...(options.swiftFlags ?? []).flatMap((flag) => ['-Xswiftc', flag])];
87
92
  const result = await run(toolchain.swift, ['build', ...common, '--product', app.name], {
88
93
  cwd: staged.dir,
89
94
  env,
@@ -100,17 +105,69 @@ export async function buildWasm(options) {
100
105
  const out = wasmOutput(app);
101
106
  mkdirSync(path.dirname(out), { recursive: true });
102
107
  if (options.wasmOpt) {
103
- // -Os without the slowest -Oz passes; the features come from the module.
104
- // --strip-debug drops DWARF and names, --strip-producers the toolchain record.
105
- const opt = await run(options.wasmOpt, ['-Os', '--strip-debug', '--strip-producers', built, '-o', out], { cwd: staged.dir, env });
106
- if (opt.status !== 0)
107
- throw new CliError(`wasm-opt failed:\n${opt.output}`);
108
+ await optimizeWasm(options.wasmOpt, built, out, { cwd: staged.dir, env });
108
109
  }
109
110
  else {
110
111
  copyFileSync(built, out);
111
112
  }
113
+ stripAutolink(out);
112
114
  return out;
113
115
  }
116
+ /**
117
+ * Builds the staged tests (`stage(…, { tests: true })`) for WebAssembly and
118
+ * returns the test modules to run. Debug: `@testable import` needs testing
119
+ * enabled, which SwiftPM turns on in debug builds, and debug compiles faster.
120
+ * Swift Build links a module per test target (`<Target>-test-runner.wasm`);
121
+ * the native build system, one for the package (`<Package>PackageTests.xctest`).
122
+ */
123
+ export async function buildTests(options) {
124
+ const { toolchain, staged } = options;
125
+ const env = toolchainEnv(toolchain);
126
+ const common = ['--swift-sdk', WASM_SDK, ...scratchPathArgs(), ...(options.swiftFlags ?? []).flatMap((flag) => ['-Xswiftc', flag])];
127
+ const result = await run(toolchain.swift, ['build', '--build-tests', ...common], {
128
+ cwd: staged.dir,
129
+ env,
130
+ ...(options.onOutput ? { onOutput: options.onOutput } : {}),
131
+ });
132
+ if (result.status !== 0)
133
+ throw new CliError(remapDiagnostics(diagnosticsOnly(result.output) || result.output, staged));
134
+ const binPath = await run(toolchain.swift, ['build', ...common, '--show-bin-path'], { cwd: staged.dir, env });
135
+ if (binPath.status !== 0)
136
+ throw new CliError(`swift build --show-bin-path failed:\n${binPath.output}`);
137
+ const bin = binPath.output.trim().split('\n').pop();
138
+ const modules = readdirSync(bin)
139
+ .filter((name) => name.endsWith('-test-runner.wasm') || name.endsWith('PackageTests.xctest'))
140
+ .sort()
141
+ .map((name) => path.join(bin, name));
142
+ if (modules.length === 0)
143
+ throw new CliError(`no test module in ${bin} after the build`);
144
+ return modules;
145
+ }
146
+ /**
147
+ * Optimizes `input` for size and strips it into `output` with wasm-opt: what
148
+ * `build` does after the link, and what CI does to the unoptimized modules
149
+ * its tests ran on before deploying them (scripts/optimize-wasm.mjs).
150
+ */
151
+ export async function optimizeWasm(wasmOpt, input, output, options) {
152
+ // -Oz: measured as fast as -Os on an 18 MB module (31 s either way) and
153
+ // 1.3% smaller. --strip-debug drops DWARF and names, --strip-producers
154
+ // the toolchain record.
155
+ const args = ['-Oz', '--strip-debug', '--strip-producers', input, '-o', output];
156
+ // Binaryen's musl builds give worker threads 128 KiB stacks, which a large
157
+ // module overflows; the copy this runs gives them 8 MiB (threadStacks.ts).
158
+ let opt = await run(wasmOptWithThreadStacks(wasmOpt, cacheDir()), args, options);
159
+ if (opt.signal) {
160
+ // Still too deep for a worker thread: on one thread the passes run on
161
+ // the main thread, whose stack the shell can raise.
162
+ opt = await run('/bin/sh', ['-c', 'ulimit -s unlimited 2>/dev/null || ulimit -s hard 2>/dev/null; exec "$0" "$@"', wasmOpt, ...args], { cwd: options.cwd, env: { ...options.env, BINARYEN_CORES: '1' } });
163
+ }
164
+ if (opt.status !== 0)
165
+ throw new CliError(`wasm-opt failed${opt.signal ? ` (${opt.signal})` : ''}:\n${opt.output}`);
166
+ }
167
+ /** Drops the Swift driver's autolink record from a linked module (`wasm.ts`). */
168
+ export function stripAutolink(wasm) {
169
+ writeFileSync(wasm, rewriteCustomSections(readFileSync(wasm), { drop: [AUTOLINK_SECTION] }));
170
+ }
114
171
  export function fileSize(file) {
115
172
  return statSync(file).size;
116
173
  }
package/dist/build.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,sEAAsE;AAEtE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,OAAO,EAAkB,gBAAgB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,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AG,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IACtE,IAAI,KAAK,IAAI,KAAK;QAAE,OAAO,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAC9D,OAAO,GAAG,KAAK,IAAI,CAAC;AACtB,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { SwiftLanguageMode } from './config.js';
2
+ export interface SwiftSettings {
3
+ /** `SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor`: `.defaultIsolation(MainActor.self)`. */
4
+ defaultIsolationMainActor: boolean;
5
+ /** Upcoming features to enable (`.enableUpcomingFeature`), in a stable order. */
6
+ upcomingFeatures: string[];
7
+ }
8
+ /**
9
+ * The concurrency settings of a target's merged build settings. Features the
10
+ * language mode already has are left out; `SWIFT_STRICT_CONCURRENCY =
11
+ * complete` is the `StrictConcurrency` feature in the Swift 5 mode.
12
+ */
13
+ export declare function swiftSettingsOf(settings: Readonly<Record<string, string>>, languageMode: SwiftLanguageMode): SwiftSettings;
14
+ /** The settings as `swiftSettings` entries of a manifest (none for the defaults). */
15
+ export declare function swiftSettingsEntries(settings: SwiftSettings | undefined): string[];
@@ -0,0 +1,74 @@
1
+ // The Xcode target's Swift concurrency settings, carried into the staging
2
+ // package's `swiftSettings` so the app compiles as it does in Xcode. Xcode 26
3
+ // templates make a target main-actor by default (`SWIFT_DEFAULT_ACTOR_ISOLATION
4
+ // = MainActor`) with "approachable concurrency" on; without them, an app
5
+ // written against that default fails with isolation errors (a main-actor
6
+ // default value of a nonisolated type, a conformance that crosses into
7
+ // main-actor code).
8
+ /** What `SWIFT_APPROACHABLE_CONCURRENCY = YES` turns on (Xcode 26). */
9
+ const APPROACHABLE_CONCURRENCY = [
10
+ 'DisableOutwardActorInference',
11
+ 'GlobalActorIsolatedTypesUsability',
12
+ 'InferIsolatedConformances',
13
+ 'InferSendableFromCaptures',
14
+ 'NonisolatedNonsendingByDefault',
15
+ ];
16
+ /** Upcoming features the Swift 6 language mode has on already (enabling one again is a warning). */
17
+ const SWIFT_6_FEATURES = new Set([
18
+ 'ConciseMagicFile',
19
+ 'DeprecateApplicationMain',
20
+ 'DisableOutwardActorInference',
21
+ 'DynamicActorIsolation',
22
+ 'ForwardTrailingClosures',
23
+ 'GlobalActorIsolatedTypesUsability',
24
+ 'GlobalConcurrency',
25
+ 'ImplicitOpenExistentials',
26
+ 'ImportObjcForwardDeclarations',
27
+ 'InferSendableFromCaptures',
28
+ 'IsolatedDefaultValues',
29
+ 'RegionBasedIsolation',
30
+ 'StrictConcurrency',
31
+ ]);
32
+ /** `SWIFT_UPCOMING_FEATURE_<NAME>` names whose feature is not the name in camel case. */
33
+ const FEATURE_NAMES = {
34
+ DISABLE_OUTWARD_ACTOR_ISOLATION: 'DisableOutwardActorInference',
35
+ IMPORT_OBJC_FORWARD_DECLS: 'ImportObjcForwardDeclarations',
36
+ };
37
+ const YES = /^(YES|TRUE|1)$/i;
38
+ /** `INFER_ISOLATED_CONFORMANCES` → `InferIsolatedConformances`. */
39
+ function featureName(setting) {
40
+ return FEATURE_NAMES[setting] ?? setting.toLowerCase().replace(/(^|_)([a-z0-9])/g, (_, __, c) => c.toUpperCase());
41
+ }
42
+ /**
43
+ * The concurrency settings of a target's merged build settings. Features the
44
+ * language mode already has are left out; `SWIFT_STRICT_CONCURRENCY =
45
+ * complete` is the `StrictConcurrency` feature in the Swift 5 mode.
46
+ */
47
+ export function swiftSettingsOf(settings, languageMode) {
48
+ const features = new Set();
49
+ if (YES.test(settings['SWIFT_APPROACHABLE_CONCURRENCY'] ?? ''))
50
+ for (const f of APPROACHABLE_CONCURRENCY)
51
+ features.add(f);
52
+ for (const [key, value] of Object.entries(settings)) {
53
+ const match = /^SWIFT_UPCOMING_FEATURE_([A-Z0-9_]+)$/.exec(key);
54
+ if (match && YES.test(value))
55
+ features.add(featureName(match[1]));
56
+ }
57
+ if ((settings['SWIFT_STRICT_CONCURRENCY'] ?? '').toLowerCase() === 'complete')
58
+ features.add('StrictConcurrency');
59
+ const upcomingFeatures = [...features].filter((f) => languageMode !== '6' || !SWIFT_6_FEATURES.has(f)).sort();
60
+ return {
61
+ defaultIsolationMainActor: (settings['SWIFT_DEFAULT_ACTOR_ISOLATION'] ?? '').trim() === 'MainActor',
62
+ upcomingFeatures,
63
+ };
64
+ }
65
+ /** The settings as `swiftSettings` entries of a manifest (none for the defaults). */
66
+ export function swiftSettingsEntries(settings) {
67
+ if (!settings)
68
+ return [];
69
+ return [
70
+ ...(settings.defaultIsolationMainActor ? ['.defaultIsolation(MainActor.self)'] : []),
71
+ ...settings.upcomingFeatures.map((f) => `.enableUpcomingFeature(${JSON.stringify(f)})`),
72
+ ];
73
+ }
74
+ //# sourceMappingURL=buildSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildSettings.js","sourceRoot":"","sources":["../src/buildSettings.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,8EAA8E;AAC9E,gFAAgF;AAChF,yEAAyE;AACzE,yEAAyE;AACzE,uEAAuE;AACvE,oBAAoB;AAWpB,uEAAuE;AACvE,MAAM,wBAAwB,GAAG;IAC/B,8BAA8B;IAC9B,mCAAmC;IACnC,2BAA2B;IAC3B,2BAA2B;IAC3B,gCAAgC;CACjC,CAAC;AAEF,oGAAoG;AACpG,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC;IAC/B,kBAAkB;IAClB,0BAA0B;IAC1B,8BAA8B;IAC9B,uBAAuB;IACvB,yBAAyB;IACzB,mCAAmC;IACnC,mBAAmB;IACnB,0BAA0B;IAC1B,+BAA+B;IAC/B,2BAA2B;IAC3B,uBAAuB;IACvB,sBAAsB;IACtB,mBAAmB;CACpB,CAAC,CAAC;AAEH,yFAAyF;AACzF,MAAM,aAAa,GAAqC;IACtD,+BAA+B,EAAE,8BAA8B;IAC/D,yBAAyB,EAAE,+BAA+B;CAC3D,CAAC;AAEF,MAAM,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AC9G,OAAO;QACL,yBAAyB,EAAE,CAAC,QAAQ,CAAC,+BAA+B,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,WAAW;QACnG,gBAAgB;KACjB,CAAC;AACJ,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,oBAAoB,CAAC,QAAmC;IACtE,IAAI,CAAC,QAAQ;QAAE,OAAO,EAAE,CAAC;IACzB,OAAO;QACL,GAAG,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,mCAAmC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACpF,GAAG,QAAQ,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,0BAA0B,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC;KACxF,CAAC;AACJ,CAAC"}
package/dist/cli.d.ts CHANGED
@@ -1,2 +1,8 @@
1
1
  export declare const VERSION = "0.1.0";
2
+ /**
3
+ * `--host` may stand alone (every interface), which parseArgs cannot express
4
+ * for an option that also takes a value: a bare `--host` becomes `--host=`
5
+ * unless an address follows it.
6
+ */
7
+ export declare function normalizeHostFlag(argv: string[]): string[];
2
8
  export declare function main(argv: string[]): Promise<number>;