@swiftbrowser/cli 0.1.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 (45) hide show
  1. package/README.md +166 -0
  2. package/bin/swiftbrowser.js +11 -0
  3. package/dist/build.d.ts +36 -0
  4. package/dist/build.js +124 -0
  5. package/dist/build.js.map +1 -0
  6. package/dist/cli.d.ts +2 -0
  7. package/dist/cli.js +137 -0
  8. package/dist/cli.js.map +1 -0
  9. package/dist/commands/build.d.ts +8 -0
  10. package/dist/commands/build.js +33 -0
  11. package/dist/commands/build.js.map +1 -0
  12. package/dist/commands/check.d.ts +4 -0
  13. package/dist/commands/check.js +27 -0
  14. package/dist/commands/check.js.map +1 -0
  15. package/dist/commands/dev.d.ts +19 -0
  16. package/dist/commands/dev.js +83 -0
  17. package/dist/commands/dev.js.map +1 -0
  18. package/dist/commands/doctor.d.ts +12 -0
  19. package/dist/commands/doctor.js +66 -0
  20. package/dist/commands/doctor.js.map +1 -0
  21. package/dist/commands/shared.d.ts +23 -0
  22. package/dist/commands/shared.js +73 -0
  23. package/dist/commands/shared.js.map +1 -0
  24. package/dist/compat.d.ts +27 -0
  25. package/dist/compat.js +111 -0
  26. package/dist/compat.js.map +1 -0
  27. package/dist/config.d.ts +45 -0
  28. package/dist/config.js +70 -0
  29. package/dist/config.js.map +1 -0
  30. package/dist/icu.d.ts +94 -0
  31. package/dist/icu.js +368 -0
  32. package/dist/icu.js.map +1 -0
  33. package/dist/log.d.ts +16 -0
  34. package/dist/log.js +28 -0
  35. package/dist/log.js.map +1 -0
  36. package/dist/project.d.ts +56 -0
  37. package/dist/project.js +264 -0
  38. package/dist/project.js.map +1 -0
  39. package/dist/stage.d.ts +78 -0
  40. package/dist/stage.js +344 -0
  41. package/dist/stage.js.map +1 -0
  42. package/dist/toolchain.d.ts +42 -0
  43. package/dist/toolchain.js +159 -0
  44. package/dist/toolchain.js.map +1 -0
  45. package/package.json +37 -0
@@ -0,0 +1,264 @@
1
+ // Working out what to build from what the user points at: an `.xcodeproj`, a
2
+ // folder holding one, or a plain folder of Swift sources; plus the optional
3
+ // `swiftbrowser.json`.
4
+ import { existsSync, readdirSync, statSync } from 'node:fs';
5
+ import path from 'node:path';
6
+ import { loadConfig } from './config.js';
7
+ import { CliError } from './log.js';
8
+ /** Directories never searched for sources or catalogs. */
9
+ const SKIP_DIRS = new Set(['.build', '.swiftbrowser', '.git', 'node_modules', 'DerivedData', 'Pods', 'Carthage', 'build', 'Preview Content']);
10
+ /** `Guess The Flag` → `GuessTheFlag`; a leading digit gets an underscore. */
11
+ export function moduleName(raw) {
12
+ const cleaned = raw.replace(/[^A-Za-z0-9_]+/g, '');
13
+ if (!cleaned)
14
+ return 'App';
15
+ return /^[0-9]/.test(cleaned) ? `_${cleaned}` : cleaned;
16
+ }
17
+ function walk(dir, visit) {
18
+ for (const entry of readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
19
+ const full = path.join(dir, entry.name);
20
+ if (entry.isDirectory()) {
21
+ if (SKIP_DIRS.has(entry.name) || entry.name.startsWith('.') || /(Tests|UITests)$/.test(entry.name))
22
+ continue;
23
+ if (entry.name.endsWith('.xcassets') || entry.name.endsWith('.xcodeproj') || entry.name.endsWith('.xcworkspace')) {
24
+ visit(full, statSync(full));
25
+ continue;
26
+ }
27
+ walk(full, visit);
28
+ }
29
+ else if (entry.isFile()) {
30
+ visit(full, statSync(full));
31
+ }
32
+ }
33
+ }
34
+ /** Every `.swift` file and `.xcassets` folder under `dir`, by convention. */
35
+ export function discoverByConvention(dir) {
36
+ const sources = [];
37
+ const catalogs = [];
38
+ walk(dir, (file) => {
39
+ if (file.endsWith('.swift') && !/(Tests|UITests)\.swift$/.test(path.basename(file)) && !/Package\.swift$/.test(file))
40
+ sources.push(file);
41
+ else if (file.endsWith('.xcassets'))
42
+ catalogs.push(file);
43
+ });
44
+ return { sources, catalogs };
45
+ }
46
+ /** Swift files named by a config `sources` list: files as is, directories recursively. */
47
+ function expandSources(root, entries) {
48
+ const out = [];
49
+ for (const entry of entries) {
50
+ const full = path.resolve(root, entry);
51
+ if (!existsSync(full))
52
+ throw new CliError(`sources entry not found: ${entry}`);
53
+ if (statSync(full).isDirectory())
54
+ out.push(...discoverByConvention(full).sources);
55
+ else
56
+ out.push(full);
57
+ }
58
+ return out;
59
+ }
60
+ function applyExcludes(root, files, exclude) {
61
+ if (!exclude || exclude.length === 0)
62
+ return files;
63
+ const prefixes = exclude.map((entry) => path.resolve(root, entry));
64
+ return files.filter((file) => !prefixes.some((prefix) => file === prefix || file.startsWith(`${prefix}${path.sep}`)));
65
+ }
66
+ /** The largest PNG of the app icon set, for the home-screen manifest. */
67
+ export function findAppIcon(catalogs, iconName = 'AppIcon') {
68
+ for (const catalog of catalogs) {
69
+ const set = path.join(catalog, `${iconName}.appiconset`);
70
+ if (!existsSync(set))
71
+ continue;
72
+ const pngs = readdirSync(set)
73
+ .filter((name) => name.toLowerCase().endsWith('.png'))
74
+ .map((name) => path.join(set, name))
75
+ .sort((a, b) => statSync(b).size - statSync(a).size);
76
+ if (pngs[0])
77
+ return pngs[0];
78
+ }
79
+ return undefined;
80
+ }
81
+ /** `.xcodeproj` bundles directly in `dir`, else one level down. */
82
+ export function xcodeProjectsIn(dir) {
83
+ const direct = readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory() && e.name.endsWith('.xcodeproj')).map((e) => path.join(dir, e.name));
84
+ if (direct.length > 0)
85
+ return direct.sort();
86
+ const nested = [];
87
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
88
+ if (!entry.isDirectory() || SKIP_DIRS.has(entry.name) || entry.name.startsWith('.'))
89
+ continue;
90
+ for (const inner of readdirSync(path.join(dir, entry.name), { withFileTypes: true })) {
91
+ if (inner.isDirectory() && inner.name.endsWith('.xcodeproj'))
92
+ nested.push(path.join(dir, entry.name, inner.name));
93
+ }
94
+ }
95
+ return nested.sort();
96
+ }
97
+ /** Resources Xcode compiles rather than copies; nothing the browser could read. */
98
+ const COMPILED_RESOURCE = /\.(xcassets|storyboard|xib|xcdatamodeld?|intentdefinition|mlmodel|mlmodelc|metal|strings|stringsdict|lproj|entitlements|xcstrings)$/;
99
+ /** The Xcode target's copied resources: everything but asset catalogs and compiled resources, in project order. */
100
+ export function bundleResources(resources) {
101
+ const out = [];
102
+ for (const file of resources) {
103
+ if (COMPILED_RESOURCE.test(file) || path.basename(file) === 'Info.plist' || out.includes(file))
104
+ continue;
105
+ out.push(file);
106
+ }
107
+ return out;
108
+ }
109
+ /** Loaded lazily so the folder path needs no Xcode project reader. */
110
+ async function readXcode(projectPath) {
111
+ const mod = (await import('@swiftbrowser/xcodeproj'));
112
+ return mod.readXcodeProject(projectPath);
113
+ }
114
+ /** Resolves `input` (an .xcodeproj, a folder with one, or a folder of sources) to an app. */
115
+ export async function resolveApp(input, options = {}) {
116
+ const target = path.resolve(input);
117
+ if (!existsSync(target))
118
+ throw new CliError(`not found: ${input}`);
119
+ let projectPath = null;
120
+ let root;
121
+ if (target.endsWith('.xcodeproj')) {
122
+ projectPath = target;
123
+ root = path.dirname(target);
124
+ }
125
+ else {
126
+ if (!statSync(target).isDirectory())
127
+ throw new CliError(`${input} is neither a folder nor an .xcodeproj`);
128
+ root = target;
129
+ const projects = xcodeProjectsIn(target);
130
+ if (projects.length > 1) {
131
+ throw new CliError(`${input} holds several Xcode projects; point at one:\n ${projects.map((p) => path.relative(target, p)).join('\n ')}`);
132
+ }
133
+ if (projects.length === 1) {
134
+ projectPath = projects[0];
135
+ root = path.dirname(projectPath);
136
+ }
137
+ }
138
+ const config = loadConfig(root, options.configFile);
139
+ const swiftLanguageMode = config.swiftLanguageMode ?? '5';
140
+ const foundation = options.foundation ?? config.foundation ?? 'full';
141
+ const defines = config.defines ?? [];
142
+ const locales = config.locales ?? ['en'];
143
+ if (projectPath) {
144
+ const project = await readXcode(projectPath);
145
+ const apps = project.appTargets();
146
+ const wanted = options.target ?? config.target;
147
+ let chosen;
148
+ if (wanted) {
149
+ chosen = project.targets.find((t) => t.name === wanted);
150
+ if (!chosen)
151
+ throw new CliError(`no target "${wanted}" in ${path.basename(projectPath)}; targets: ${project.targets.map((t) => t.name).join(', ')}`);
152
+ }
153
+ else if (apps.length === 1) {
154
+ chosen = apps[0];
155
+ }
156
+ else if (apps.length === 0) {
157
+ throw new CliError(`${path.basename(projectPath)} has no iOS app target (targets: ${project.targets.map((t) => t.name).join(', ') || 'none'})`);
158
+ }
159
+ else {
160
+ throw new CliError(`${path.basename(projectPath)} has several app targets; pick one with --target:\n ${apps.map((t) => t.name).join('\n ')}`);
161
+ }
162
+ if (!chosen)
163
+ throw new CliError('no target chosen');
164
+ const sources = applyExcludes(root, config.sources ? expandSources(root, config.sources) : chosen.sources.filter((f) => f.endsWith('.swift')), config.exclude);
165
+ const catalogs = config.catalogs ? config.catalogs.map((c) => path.resolve(root, c)) : chosen.assetCatalogs;
166
+ const resources = config.resources ? config.resources.map((r) => path.resolve(root, r)) : bundleResources(chosen.resources ?? []);
167
+ const icon = config.icon ? path.resolve(root, config.icon) : findAppIcon(catalogs, chosen.appIconName);
168
+ const app = {
169
+ name: config.name ?? moduleName(chosen.productName || chosen.name),
170
+ displayName: config.displayName ?? chosen.displayName ?? chosen.productName ?? chosen.name,
171
+ root,
172
+ sources,
173
+ catalogs,
174
+ resources,
175
+ swiftLanguageMode: config.swiftLanguageMode ?? (chosen.swiftVersion?.startsWith('6') ? '6' : swiftLanguageMode),
176
+ foundation,
177
+ locales,
178
+ defines,
179
+ origin: { kind: 'xcodeproj', project: projectPath, target: chosen.name },
180
+ };
181
+ if (icon)
182
+ app.icon = icon;
183
+ return finish(app);
184
+ }
185
+ const discovered = discoverByConvention(root);
186
+ const sources = applyExcludes(root, config.sources ? expandSources(root, config.sources) : discovered.sources, config.exclude);
187
+ const catalogs = config.catalogs ? config.catalogs.map((c) => path.resolve(root, c)) : discovered.catalogs;
188
+ // A plain folder has no Copy Bundle Resources phase: resources come from the config only.
189
+ const resources = (config.resources ?? []).map((r) => path.resolve(root, r));
190
+ const icon = config.icon ? path.resolve(root, config.icon) : findAppIcon(catalogs);
191
+ const app = {
192
+ name: config.name ?? moduleName(path.basename(root)),
193
+ displayName: config.displayName ?? path.basename(root),
194
+ root,
195
+ sources,
196
+ catalogs,
197
+ resources,
198
+ swiftLanguageMode,
199
+ foundation,
200
+ locales,
201
+ defines,
202
+ origin: { kind: 'folder' },
203
+ };
204
+ if (icon)
205
+ app.icon = icon;
206
+ return finish(app);
207
+ }
208
+ /**
209
+ * The path as it exists on disk when it differs only in case: Xcode projects
210
+ * made on macOS (a case-insensitive disk) may say `BucketList/` for a folder
211
+ * named `Bucketlist/`. Each missing component is matched case-insensitively
212
+ * against its directory; the path comes back unchanged when nothing matches.
213
+ */
214
+ export function repairCase(file) {
215
+ if (existsSync(file))
216
+ return file;
217
+ const parts = file.split(path.sep);
218
+ let current = path.isAbsolute(file) ? path.sep : '';
219
+ for (const part of parts) {
220
+ if (part === '')
221
+ continue;
222
+ const candidate = path.join(current, part);
223
+ if (existsSync(candidate)) {
224
+ current = candidate;
225
+ continue;
226
+ }
227
+ if (!existsSync(current))
228
+ return file;
229
+ const match = readdirSync(current).find((entry) => entry.toLowerCase() === part.toLowerCase());
230
+ if (match === undefined)
231
+ return file;
232
+ current = path.join(current, match);
233
+ }
234
+ return current;
235
+ }
236
+ function finish(app) {
237
+ if (app.sources.length === 0)
238
+ throw new CliError(`no Swift sources found for ${app.name} in ${app.root}`);
239
+ // An Xcode project made on macOS can name files whose case differs from the
240
+ // disk's; repair what can be repaired, report the rest.
241
+ app.sources = app.sources.map(repairCase);
242
+ app.catalogs = app.catalogs.map(repairCase);
243
+ app.resources = app.resources.map(repairCase);
244
+ if (app.icon)
245
+ app.icon = repairCase(app.icon);
246
+ const missing = app.sources.filter((file) => !existsSync(file));
247
+ if (missing.length > 0) {
248
+ throw new CliError(`${missing.length} source file${missing.length === 1 ? '' : 's'} named by the project ${missing.length === 1 ? 'does' : 'do'} not exist:\n ${missing.join('\n ')}`);
249
+ }
250
+ const missingResources = app.resources.filter((file) => !existsSync(file));
251
+ if (missingResources.length > 0) {
252
+ throw new CliError(`${missingResources.length} resource${missingResources.length === 1 ? '' : 's'} named by the project ${missingResources.length === 1 ? 'does' : 'do'} not exist:\n ${missingResources.join('\n ')}`);
253
+ }
254
+ const names = new Map();
255
+ for (const file of app.sources) {
256
+ const base = path.basename(file);
257
+ const other = names.get(base);
258
+ if (other)
259
+ throw new CliError(`two sources share the file name ${base} (Swift needs unique names in a module):\n ${other}\n ${file}`);
260
+ names.set(base, file);
261
+ }
262
+ return app;
263
+ }
264
+ //# sourceMappingURL=project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.js","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,4EAA4E;AAC5E,uBAAuB;AAEvB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAA4D,UAAU,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AA+BpC,0DAA0D;AAC1D,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,eAAe,EAAE,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC;AAE9I,6EAA6E;AAC7E,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;IACnD,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAC3B,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CA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EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3E,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,QAAQ,CAAC,GAAG,gBAAgB,CAAC,MAAM,YAAY,gBAAgB,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,yBAAyB,gBAAgB,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,kBAAkB,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC5N,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;IACxC,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;QAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACjC,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC9B,IAAI,KAAK;YAAE,MAAM,IAAI,QAAQ,CAAC,mCAAmC,IAAI,+CAA+C,KAAK,OAAO,IAAI,EAAE,CAAC,CAAC;QACxI,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,78 @@
1
+ import { type ICUData } from './icu.js';
2
+ import type { ResolvedApp } from './project.js';
3
+ export interface StagedApp {
4
+ /** The staging package directory (holds Package.swift, Sources/, .build/). */
5
+ dir: string;
6
+ /** Staged file → original file, for mapping compiler diagnostics back. */
7
+ originals: Map<string, string>;
8
+ /** `#Preview` blocks removed, in total. */
9
+ previewsStripped: number;
10
+ }
11
+ /** Where an app's staging package lives. */
12
+ export declare function stagingDir(app: ResolvedApp): string;
13
+ /** The built module, optimized or not. */
14
+ export declare function wasmOutput(app: ResolvedApp): string;
15
+ export interface TransformResult {
16
+ text: string;
17
+ previewsStripped: number;
18
+ /** `import Foundation` lines rewritten. */
19
+ foundationRewrites: number;
20
+ }
21
+ /**
22
+ * Adjusts one source for the shim without moving any line, so compiler
23
+ * diagnostics keep their line numbers:
24
+ * - `import SwiftUI` also imports the Foundation modules (lean: FoundationEssentials
25
+ * + FoundationLite; full: Foundation + FoundationBridge), as Apple's SwiftUI
26
+ * re-exports Foundation;
27
+ * - lean: `import Foundation` → `import FoundationEssentials; import FoundationLite`,
28
+ * which is what the SwiftBrowser examples import by hand; in both modes the
29
+ * line also imports Observation (Apple's Foundation re-exports it, so
30
+ * `@Observable` works in a file that imports Foundation alone);
31
+ * - full: `import FoundationLite` → `import FoundationBridge` (the examples'
32
+ * `#if canImport(FoundationEssentials)` branch, against the real Foundation);
33
+ * - `#Preview { … }` blocks (and `#Preview("name", traits: …) { … }`) become
34
+ * blank lines: the shim has no preview macro and previews are not part of
35
+ * the app.
36
+ */
37
+ export declare function transformSource(text: string, options: {
38
+ foundation: 'lean' | 'full';
39
+ }): TransformResult;
40
+ /** Replaces every `#Preview …{ … }` block with blank lines of the same count. */
41
+ export declare function stripPreviews(text: string): {
42
+ text: string;
43
+ count: number;
44
+ };
45
+ /** Index of the `}` closing the `{` at `open`, skipping strings and comments; -1 when unbalanced. */
46
+ export declare function matchingBrace(text: string, open: number): number;
47
+ /** The Package.swift of the staging package. */
48
+ export declare function packageManifest(app: ResolvedApp, swiftPackagePath: string): string;
49
+ /** The staged file that settles names declared by both the shim and Foundation. */
50
+ export declare const FULL_FOUNDATION_FILE = "_SwiftBrowserFoundation.swift";
51
+ /**
52
+ * In full mode the app imports both the shim and the real Foundation, and
53
+ * both declare a few names (the shim cannot import Foundation itself, which
54
+ * would link it into every lean app; and a module does not shadow another's
55
+ * declarations, only the current module's do). A typealias in the app module
56
+ * does: these point the shared names at the shim's types (what its
57
+ * `frame(width:)` and friends take) and at FoundationBridge's `Timer` and
58
+ * `RunLoop`, which Foundation lacks on WASI (`RunLoop` is marked unavailable,
59
+ * its `Timer` needs CFRunLoop and does not link).
60
+ */
61
+ export declare function fullFoundationSource(): string;
62
+ /** The directory the staged sources keep their layout relative to. */
63
+ export declare function commonSourceBase(app: ResolvedApp): string;
64
+ export interface StageOptions {
65
+ /**
66
+ * The trimmed ICU data for a full-Foundation wasm build (`prepareICUData`);
67
+ * without it a full-mode staging builds on the host only.
68
+ */
69
+ icu?: ICUData | null;
70
+ }
71
+ /**
72
+ * Writes (or refreshes) the staging package. Files are written only when
73
+ * their content changed, so SwiftPM's incremental build stays incremental;
74
+ * staged files whose source is gone are removed.
75
+ */
76
+ export declare function stage(app: ResolvedApp, swiftPackagePath: string, options?: StageOptions): StagedApp;
77
+ /** Rewrites staged paths in compiler output back to the user's files. */
78
+ export declare function remapDiagnostics(output: string, staged: StagedApp): string;