@swiftbrowser/cli 0.1.0 → 0.2.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 (84) hide show
  1. package/README.md +330 -64
  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 +17 -2
  6. package/dist/build.js +40 -13
  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 +60 -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 +57 -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 +25 -4
  28. package/dist/commands/shared.js +104 -10
  29. package/dist/commands/shared.js.map +1 -1
  30. package/dist/compat.d.ts +44 -6
  31. package/dist/compat.js +64 -36
  32. package/dist/compat.js.map +1 -1
  33. package/dist/config.d.ts +48 -10
  34. package/dist/config.js +64 -8
  35. package/dist/config.js.map +1 -1
  36. package/dist/coreml.d.ts +194 -0
  37. package/dist/coreml.js +626 -0
  38. package/dist/coreml.js.map +1 -0
  39. package/dist/icu.d.ts +17 -4
  40. package/dist/icu.js +32 -18
  41. package/dist/icu.js.map +1 -1
  42. package/dist/kit.d.ts +133 -0
  43. package/dist/kit.js +403 -0
  44. package/dist/kit.js.map +1 -0
  45. package/dist/objc.d.ts +31 -0
  46. package/dist/objc.js +319 -0
  47. package/dist/objc.js.map +1 -0
  48. package/dist/packagePatches.d.ts +24 -0
  49. package/dist/packagePatches.js +107 -0
  50. package/dist/packagePatches.js.map +1 -0
  51. package/dist/packages.d.ts +59 -0
  52. package/dist/packages.js +149 -0
  53. package/dist/packages.js.map +1 -0
  54. package/dist/project.d.ts +45 -4
  55. package/dist/project.js +91 -18
  56. package/dist/project.js.map +1 -1
  57. package/dist/protobuf.d.ts +62 -0
  58. package/dist/protobuf.js +233 -0
  59. package/dist/protobuf.js.map +1 -0
  60. package/dist/stage.d.ts +155 -27
  61. package/dist/stage.js +483 -79
  62. package/dist/stage.js.map +1 -1
  63. package/dist/strings.d.ts +44 -0
  64. package/dist/strings.js +386 -0
  65. package/dist/strings.js.map +1 -0
  66. package/dist/template.d.ts +29 -0
  67. package/dist/template.js +438 -0
  68. package/dist/template.js.map +1 -0
  69. package/dist/threadStacks.d.ts +14 -0
  70. package/dist/threadStacks.js +78 -0
  71. package/dist/threadStacks.js.map +1 -0
  72. package/dist/toolchain.d.ts +7 -1
  73. package/dist/toolchain.js +8 -2
  74. package/dist/toolchain.js.map +1 -1
  75. package/dist/urlSchemes.d.ts +11 -0
  76. package/dist/urlSchemes.js +58 -0
  77. package/dist/urlSchemes.js.map +1 -0
  78. package/dist/vendor.d.ts +109 -0
  79. package/dist/vendor.js +440 -0
  80. package/dist/vendor.js.map +1 -0
  81. package/dist/wasm.d.ts +28 -0
  82. package/dist/wasm.js +84 -0
  83. package/dist/wasm.js.map +1 -0
  84. package/package.json +7 -6
@@ -0,0 +1,58 @@
1
+ // The app's URL schemes, from its Info.plist: `CFBundleURLSchemes` of each
2
+ // `CFBundleURLTypes` entry. An app registers `myapp://` as its OAuth redirect
3
+ // and signs in with `ASWebAuthenticationSession`; in the browser that
4
+ // redirect has to come back through the page's callback page, and the shim
5
+ // swaps it in only for the app's own schemes (docs/ops-protocol.md, "Signing
6
+ // in"). The registry entry carries them to the page, which hands them to the
7
+ // app as `SB_URL_SCHEMES`.
8
+ import { readFileSync } from 'node:fs';
9
+ import path from 'node:path';
10
+ import { parseXmlPlist } from '@swiftbrowser/xcodeproj';
11
+ /** A URL scheme as RFC 3986 spells one. */
12
+ const SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/;
13
+ /** The URL schemes an Info.plist declares (XML plists only), in order, without duplicates. */
14
+ export function urlSchemesInPlist(text) {
15
+ let plist;
16
+ try {
17
+ plist = parseXmlPlist(text);
18
+ }
19
+ catch {
20
+ return [];
21
+ }
22
+ if (typeof plist !== 'object' || plist === null || Array.isArray(plist))
23
+ return [];
24
+ const types = plist['CFBundleURLTypes'];
25
+ if (!Array.isArray(types))
26
+ return [];
27
+ const schemes = [];
28
+ for (const type of types) {
29
+ if (typeof type !== 'object' || type === null || Array.isArray(type))
30
+ continue;
31
+ const names = type['CFBundleURLSchemes'];
32
+ if (!Array.isArray(names))
33
+ continue;
34
+ for (const name of names) {
35
+ if (typeof name === 'string' && SCHEME.test(name) && !schemes.includes(name))
36
+ schemes.push(name);
37
+ }
38
+ }
39
+ return schemes;
40
+ }
41
+ /** The URL schemes of the Info.plist at `file` (none when it cannot be read). */
42
+ export function urlSchemesInPlistFile(file) {
43
+ try {
44
+ return urlSchemesInPlist(readFileSync(file, 'utf8'));
45
+ }
46
+ catch {
47
+ return [];
48
+ }
49
+ }
50
+ /**
51
+ * The URL schemes of an Xcode target: its `INFOPLIST_FILE` (relative to the
52
+ * project's directory, `root`), when it has one.
53
+ */
54
+ export function urlSchemesOfTarget(target, root) {
55
+ const file = target.settings?.()['INFOPLIST_FILE'];
56
+ return file ? urlSchemesInPlistFile(path.resolve(root, file)) : [];
57
+ }
58
+ //# sourceMappingURL=urlSchemes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"urlSchemes.js","sourceRoot":"","sources":["../src/urlSchemes.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,8EAA8E;AAC9E,sEAAsE;AACt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,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnG,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,qBAAqB,CAAC,IAAY;IAChD,IAAI,CAAC;QACH,OAAO,iBAAiB,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IACvD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAyE,EAAE,IAAY;IACxH,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC,gBAAgB,CAAC,CAAC;IACnD,OAAO,IAAI,CAAC,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACrE,CAAC"}
@@ -0,0 +1,109 @@
1
+ import { type PackagePlan } from './packages.js';
2
+ import type { ResolvedApp } from './project.js';
3
+ import { type StageFeatures } from './stage.js';
4
+ import { type Toolchain } from './toolchain.js';
5
+ /** Modules the SwiftBrowser package provides in place of Apple's: a package importing one is built against the shim. */
6
+ export declare const SHIM_MODULES: ReadonlySet<string>;
7
+ /** A package of the build, as `swift package show-dependencies` lists it. */
8
+ export interface PackageNode {
9
+ identity: string;
10
+ name: string;
11
+ /** The repository URL, or the folder of a local package. */
12
+ url: string;
13
+ /** A version, or `unspecified` for a local package or a branch. */
14
+ version: string;
15
+ /** Where its sources are: SwiftPM's checkout, or the local folder. */
16
+ path: string;
17
+ /** Identities of the packages it depends on. */
18
+ dependencies: string[];
19
+ }
20
+ /** A package copied into the staging package and built against the shim. */
21
+ export interface VendoredPackage {
22
+ identity: string;
23
+ name: string;
24
+ /** Where it came from (checkout or local folder). */
25
+ source: string;
26
+ /** Whether `source` is a folder of the user's (a local package) rather than SwiftPM's checkout. */
27
+ local: boolean;
28
+ version: string;
29
+ /** The copy: `<staging>/Packages/<identity>`. */
30
+ dir: string;
31
+ /**
32
+ * Its targets that import a shim module: the shim modules they import, and
33
+ * the products they link; none for a package copied only because it
34
+ * depends on one.
35
+ */
36
+ /**
37
+ * `uses`: why a target that imports no shim module is built against it
38
+ * anyway (Objective-C selectors, POSIX mutexes, Dispatch).
39
+ */
40
+ targets: {
41
+ name: string;
42
+ imports: string[];
43
+ modules: string[];
44
+ uses?: string[];
45
+ }[];
46
+ /** For a package SwiftBrowser stands in for, why: `dir` holds a redirect to the shim's modules, not a copy. */
47
+ standIn?: string;
48
+ /** The modules it provides (its regular targets), which a source may import. */
49
+ modules?: string[];
50
+ /** How many edits SwiftBrowser's patch made to it (packagePatches.ts). */
51
+ patched?: number;
52
+ /** Its targets' asset catalogs (in `source`), which join the app's on the page. */
53
+ catalogs?: string[];
54
+ }
55
+ /** Identity → the copy; empty when no package imports a shim module. */
56
+ export type Vendored = ReadonlyMap<string, VendoredPackage>;
57
+ /** The packages of a `show-dependencies --format json` tree, root excluded, each once. */
58
+ export declare function packageNodes(tree: unknown): PackageNode[];
59
+ /** The Package.swift that only resolves the app's package dependencies. */
60
+ export declare function resolveManifest(plans: readonly PackagePlan[]): string;
61
+ /**
62
+ * The package that takes a stand-in's place for the packages that depend on
63
+ * it: a library per product, each forwarding to SwiftBrowser's module of the
64
+ * same name, through a target of its own (`_<Product>StandIn`, empty).
65
+ */
66
+ export declare function redirectManifest(name: string, products: readonly string[], reason: string, swiftPackagePath: string): string;
67
+ /** `// swift-tools-version: 5.9` → [5, 9]; [5, 0] when the line is missing or unreadable. */
68
+ export declare function toolsVersion(manifest: string): [number, number];
69
+ /**
70
+ * The lines appended to a copied package's manifest: the SwiftBrowser package,
71
+ * the shim products and `SWIFTBROWSER` for `targets`, and its dependencies on
72
+ * other copied packages (`copies`, identity → folder) pointed at the copies.
73
+ * Reading a dependency's location (`Package.Dependency.kind`) takes tools
74
+ * version 5.6; an older manifest keeps its URLs, and the staging manifest's
75
+ * declaration of the copy takes their place (with a warning from SwiftPM).
76
+ */
77
+ export declare function manifestPatch(targets: readonly {
78
+ name: string;
79
+ modules: readonly string[];
80
+ }[], swiftPackagePath: string, copies?: ReadonlyMap<string, string>, tools?: readonly [number, number]): string;
81
+ /** The shim products a target needs for its imports: the app's set (stage.ts), minus what only apps use. */
82
+ export declare function targetProducts(features: StageFeatures): string[];
83
+ /**
84
+ * Whether a package's sources import a shim module: a quick scan before
85
+ * asking SwiftPM. The sources are the folders SwiftPM looks in by default
86
+ * (`Sources`, `Source`, `src`, `srcs`) when the package has one, else the
87
+ * whole package; manifests and tests never count, nor a demo app beside the
88
+ * library.
89
+ */
90
+ export declare function importsShim(dir: string): boolean;
91
+ /**
92
+ * `Bundle.module` on the bridge's `Bundle`. SwiftPM's generated accessor
93
+ * declares `module` on Foundation's `Bundle` (for a target with resources),
94
+ * but in a staged target `Bundle` is the bridge's (the alias file), so
95
+ * `Bundle.module` and `bundle: .module` would find nothing. This one is the
96
+ * folder SwiftPM names the target's resources (`<package>_<target>.bundle`)
97
+ * inside the app's bundle, or the app's bundle when there is none.
98
+ */
99
+ export declare function moduleBundleSource(bundleName: string): string;
100
+ /** Where the copies live, and the package that resolves the originals. */
101
+ export declare function vendorDir(app: ResolvedApp): string;
102
+ /**
103
+ * Resolves the app's package dependencies and copies the ones that import a
104
+ * shim module, and the ones that depend on those, into the staging package.
105
+ * Packages that are plain Swift all the way down are left to SwiftPM, as
106
+ * before. Returns the copies by identity; empty, without running SwiftPM,
107
+ * when the app has no packages to fetch.
108
+ */
109
+ export declare function vendorPackages(app: ResolvedApp, toolchain: Toolchain, swiftPackagePath: string): Promise<Map<string, VendoredPackage>>;
package/dist/vendor.js ADDED
@@ -0,0 +1,440 @@
1
+ // Swift packages that import SwiftUI (or another module the shim provides).
2
+ //
3
+ // SwiftPM builds a package dependency as its manifest says, and no manifest
4
+ // says to depend on SwiftBrowser: on iOS, `import SwiftUI` finds the system
5
+ // framework. So a package that imports one of the shim's modules is copied
6
+ // into the staging package (`Packages/<identity>/`) and built from there:
7
+ //
8
+ // - its sources get the same adjustments as the app's (`transformSource`);
9
+ // - each target that imports a shim module gets the generated alias file
10
+ // (`fullFoundationSource`), as the app module does;
11
+ // - its manifest keeps everything it declares, with a few lines appended that
12
+ // add the SwiftBrowser package and, to those targets, the shim products and
13
+ // the `SWIFTBROWSER` define.
14
+ //
15
+ // A package that depends on a copied one is copied too, unchanged but for
16
+ // its manifest, which points that dependency at the copy. The staging
17
+ // manifest depends on every copy by path (a transitive one as well: should a
18
+ // manifest be too old to repoint, SwiftPM lets the root's declaration take
19
+ // the place of the URL, with a warning).
20
+ //
21
+ // Which packages there are, at which versions and where SwiftPM checked them
22
+ // out, comes from resolving the project's dependencies in a package of their
23
+ // own (`Packages/.resolve/`), with `swift package show-dependencies`.
24
+ import { createHash } from 'node:crypto';
25
+ import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
26
+ import path from 'node:path';
27
+ import { ASSET_SYMBOLS_FILE, assetSymbolsSource, declaredStaticMembers, targetCatalogs } from './assetSymbols.js';
28
+ import { run } from './build.js';
29
+ import { LINKED_FRAMEWORKS, importsOf } from './compat.js';
30
+ import { CliError } from './log.js';
31
+ import { optionalRequirementNames } from './objc.js';
32
+ import { PACKAGE_PATCHES, applyPatch, checkPatch } from './packagePatches.js';
33
+ import { PACKAGE_STAND_INS, planPackages } from './packages.js';
34
+ import { FULL_FOUNDATION_FILE, declaredTypeNames, featuresOf, fullFoundationSource, stagingDir, transformSource, importsDispatch, importsObjectiveC, usesObjC, usesPosixMutex } from './stage.js';
35
+ import { toolchainEnv } from './toolchain.js';
36
+ /** Modules the SwiftBrowser package provides in place of Apple's: a package importing one is built against the shim. */
37
+ export const SHIM_MODULES = new Set(['SwiftUI', 'Charts', 'SwiftData', 'FoundationBridge', ...LINKED_FRAMEWORKS]);
38
+ /** The packages of a `show-dependencies --format json` tree, root excluded, each once. */
39
+ export function packageNodes(tree) {
40
+ const out = new Map();
41
+ const visit = (node) => {
42
+ for (const child of node['dependencies'] ?? []) {
43
+ const identity = String(child['identity']);
44
+ if (!out.has(identity)) {
45
+ out.set(identity, {
46
+ identity,
47
+ name: String(child['name']),
48
+ url: String(child['url']),
49
+ version: String(child['version']),
50
+ path: String(child['path']),
51
+ dependencies: (child['dependencies'] ?? []).map((d) => String(d['identity'])),
52
+ });
53
+ }
54
+ visit(child);
55
+ }
56
+ };
57
+ visit(tree);
58
+ return [...out.values()];
59
+ }
60
+ /** The Package.swift that only resolves the app's package dependencies. */
61
+ export function resolveManifest(plans) {
62
+ const dependencies = plans.flatMap((plan) => (plan.kind === 'dependency' ? [plan] : []));
63
+ const products = dependencies.flatMap((plan) => plan.package.products.map((p) => `.product(name: ${JSON.stringify(p)}, package: ${JSON.stringify(plan.identity)})`));
64
+ return `// swift-tools-version: 6.0
65
+ // Generated by @swiftbrowser/cli: resolves the app's package dependencies, so
66
+ // the ones that import SwiftUI can be built against the shim (vendor.ts).
67
+ import PackageDescription
68
+
69
+ let package = Package(
70
+ name: "Resolve",
71
+ dependencies: [
72
+ ${dependencies.map((plan) => plan.declaration).join(',\n ')},
73
+ ],
74
+ targets: [
75
+ .target(name: "Resolve", dependencies: [
76
+ ${products.join(',\n ')},
77
+ ], path: "Sources"),
78
+ ]
79
+ )
80
+ `;
81
+ }
82
+ /**
83
+ * The package that takes a stand-in's place for the packages that depend on
84
+ * it: a library per product, each forwarding to SwiftBrowser's module of the
85
+ * same name, through a target of its own (`_<Product>StandIn`, empty).
86
+ */
87
+ export function redirectManifest(name, products, reason, swiftPackagePath) {
88
+ const target = (product) => `_${product}StandIn`;
89
+ return `// swift-tools-version: 5.9
90
+ // Generated by @swiftbrowser/cli: SwiftBrowser stands in for ${name} (${reason}).
91
+ // Each product forwards to SwiftBrowser's module of the same name (vendor.ts).
92
+ import PackageDescription
93
+
94
+ let package = Package(
95
+ name: ${JSON.stringify(name)},
96
+ products: [
97
+ ${products.map((p) => ` .library(name: ${JSON.stringify(p)}, targets: [${JSON.stringify(target(p))}]),`).join('\n')}
98
+ ],
99
+ dependencies: [.package(name: "SwiftBrowser", path: ${JSON.stringify(swiftPackagePath)})],
100
+ targets: [
101
+ ${products.map((p) => ` .target(name: ${JSON.stringify(target(p))}, dependencies: [.product(name: ${JSON.stringify(p)}, package: "SwiftBrowser")], path: ${JSON.stringify(`Sources/${target(p)}`)}),`).join('\n')}
102
+ ]
103
+ )
104
+ `;
105
+ }
106
+ /** `// swift-tools-version: 5.9` → [5, 9]; [5, 0] when the line is missing or unreadable. */
107
+ export function toolsVersion(manifest) {
108
+ const match = /^\/\/\s*swift-tools-version\s*:\s*(\d+)(?:\.(\d+))?/.exec(manifest);
109
+ return match ? [Number(match[1]), Number(match[2] ?? 0)] : [5, 0];
110
+ }
111
+ /**
112
+ * The lines appended to a copied package's manifest: the SwiftBrowser package,
113
+ * the shim products and `SWIFTBROWSER` for `targets`, and its dependencies on
114
+ * other copied packages (`copies`, identity → folder) pointed at the copies.
115
+ * Reading a dependency's location (`Package.Dependency.kind`) takes tools
116
+ * version 5.6; an older manifest keeps its URLs, and the staging manifest's
117
+ * declaration of the copy takes their place (with a warning from SwiftPM).
118
+ */
119
+ export function manifestPatch(targets, swiftPackagePath, copies = new Map(), tools = [6, 0]) {
120
+ const lines = ['', '', '// Added by @swiftbrowser/cli to build this package in the browser (vendor.ts).'];
121
+ if (targets.length > 0) {
122
+ const entries = targets.map((t) => ` ${JSON.stringify(t.name)}: [${t.modules.map((m) => JSON.stringify(m)).join(', ')}],`);
123
+ lines.push('// These targets import SwiftUI (or another module SwiftBrowser provides),', '// so they build against its shim.', `package.dependencies.append(.package(name: "SwiftBrowser", path: ${JSON.stringify(swiftPackagePath)}))`, 'let _swiftBrowserProducts: [String: [String]] = [', ...entries, ']', 'for target in package.targets {', ' guard let products = _swiftBrowserProducts[target.name] else { continue }', ' target.dependencies += products.map { .product(name: $0, package: "SwiftBrowser") }', ' target.swiftSettings = (target.swiftSettings ?? []) + [.define("SWIFTBROWSER")]', '}');
124
+ }
125
+ lines.push('// The browser build is one module: a dynamic library (Backyard Birds\'s', '// packages are) would link the shim products into each library.', 'package.products = package.products.map { product in', ' guard let library = product as? Product.Library, library.type == .dynamic else { return product }', ' return .library(name: library.name, targets: library.targets)', '}');
126
+ const [major, minor] = tools;
127
+ if (copies.size > 0 && (major > 5 || (major === 5 && minor >= 6))) {
128
+ const entries = [...copies].map(([identity, dir]) => ` ${JSON.stringify(identity)}: ${JSON.stringify(dir)},`);
129
+ lines.push('// Packages it depends on that are built against the shim too, from their copies.', 'let _swiftBrowserCopies: [String: String] = [', ...entries, ']', 'package.dependencies = package.dependencies.map { dependency in', ' guard case .sourceControl(let name, let location, _) = dependency.kind else { return dependency }', ' var identity = String(location.split(separator: "/").last ?? "")', ' if identity.hasSuffix(".git") { identity.removeLast(4) }', ' guard let copy = _swiftBrowserCopies[identity.lowercased()] else { return dependency }',
130
+ // A path names the package after the copy's (lowercased) folder; a
131
+ // target that lists the product by itself ("SwiftSoup") finds it by
132
+ // the package's name, so the copy keeps the URL's.
133
+ ' return .package(name: name ?? identity, path: copy)', '}');
134
+ }
135
+ return `${lines.join('\n')}\n`;
136
+ }
137
+ /** The shim products a target needs for its imports: the app's set (stage.ts), minus what only apps use. */
138
+ export function targetProducts(features) {
139
+ return [...new Set(['SwiftUI', 'Charts', 'FoundationBridge', 'os', ...(features.swiftData ? ['SwiftData'] : []), ...features.frameworks])];
140
+ }
141
+ /** The manifests of a package: Package.swift and its version-specific variants. */
142
+ function manifestFiles(dir) {
143
+ return readdirSync(dir).filter((name) => /^Package(@swift-[\d.]+)?\.swift$/.test(name));
144
+ }
145
+ /** Swift sources under `dir`, recursively. */
146
+ function swiftFiles(dir, out = []) {
147
+ if (!existsSync(dir))
148
+ return out;
149
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
150
+ const full = path.join(dir, entry.name);
151
+ if (entry.isDirectory()) {
152
+ if (!entry.name.startsWith('.'))
153
+ swiftFiles(full, out);
154
+ }
155
+ else if (entry.name.endsWith('.swift')) {
156
+ out.push(full);
157
+ }
158
+ }
159
+ return out;
160
+ }
161
+ /**
162
+ * Whether a package's sources import a shim module: a quick scan before
163
+ * asking SwiftPM. The sources are the folders SwiftPM looks in by default
164
+ * (`Sources`, `Source`, `src`, `srcs`) when the package has one, else the
165
+ * whole package; manifests and tests never count, nor a demo app beside the
166
+ * library.
167
+ */
168
+ export function importsShim(dir) {
169
+ const roots = ['Sources', 'Source', 'src', 'srcs'].map((name) => path.join(dir, name)).filter((root) => existsSync(root));
170
+ const files = roots.length > 0 ? roots.flatMap((root) => swiftFiles(root)) : swiftFiles(dir);
171
+ for (const file of files) {
172
+ const relative = path.relative(dir, file);
173
+ if (!relative.includes(path.sep) && /^Package(@swift-[\d.]+)?\.swift$/.test(relative))
174
+ continue;
175
+ if (relative.split(path.sep).some((part) => part === 'Tests' || part === '.build'))
176
+ continue;
177
+ const text = readFileSync(file, 'utf8');
178
+ // Selectors and `@objc` need the bridge too (stage.ts, rewriteObjC), and
179
+ // so do POSIX mutexes (FoundationBridge/Locks.swift) and Dispatch.
180
+ if (importsOf(text).some((module) => SHIM_MODULES.has(module)) || usesObjC(text) || usesPosixMutex(text) || importsDispatch(text) || importsObjectiveC(text))
181
+ return true;
182
+ }
183
+ return false;
184
+ }
185
+ /**
186
+ * `Bundle.module` on the bridge's `Bundle`. SwiftPM's generated accessor
187
+ * declares `module` on Foundation's `Bundle` (for a target with resources),
188
+ * but in a staged target `Bundle` is the bridge's (the alias file), so
189
+ * `Bundle.module` and `bundle: .module` would find nothing. This one is the
190
+ * folder SwiftPM names the target's resources (`<package>_<target>.bundle`)
191
+ * inside the app's bundle, or the app's bundle when there is none.
192
+ */
193
+ export function moduleBundleSource(bundleName) {
194
+ return `
195
+ extension FoundationBridge.Bundle {
196
+ /// The resources of this package target (\`${bundleName}.bundle\` in the app's bundle).
197
+ static var module: FoundationBridge.Bundle {
198
+ let main = FoundationBridge.Bundle.main
199
+ return FoundationBridge.Bundle(path: main.bundlePath + "/${bundleName}.bundle").flatMap { Foundation.FileManager.default.fileExists(atPath: $0.bundlePath) ? $0 : nil } ?? main
200
+ }
201
+ }
202
+ `;
203
+ }
204
+ /** Where SwiftPM looks for a target's sources when the manifest gives no path. */
205
+ function targetDir(packageDir, target) {
206
+ if (target.path)
207
+ return path.join(packageDir, target.path);
208
+ for (const parent of ['Sources', 'Source', 'src', 'srcs']) {
209
+ const candidate = path.join(packageDir, parent, target.name);
210
+ if (existsSync(candidate))
211
+ return candidate;
212
+ }
213
+ return undefined;
214
+ }
215
+ function writeIfChanged(file, content) {
216
+ const bytes = typeof content === 'string' ? Buffer.from(content) : content;
217
+ if (existsSync(file) && readFileSync(file).equals(bytes))
218
+ return;
219
+ mkdirSync(path.dirname(file), { recursive: true });
220
+ writeFileSync(file, bytes);
221
+ }
222
+ /**
223
+ * Copies `from` into `to` (dot folders and `.build` left out), adjusting Swift
224
+ * sources (those under a `bridged` folder as sources of a module built against
225
+ * the bridge) after `patch`'s edits; removes what `from` no longer has.
226
+ */
227
+ function copyPackage(from, to, bridged = [], patch) {
228
+ const kept = new Set();
229
+ // Optional requirements are called in other files than the protocol's.
230
+ const optionalRequirements = optionalRequirementNames(swiftFiles(from).map((file) => readFileSync(file, 'utf8')));
231
+ const walk = (dir) => {
232
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
233
+ if (entry.name.startsWith('.'))
234
+ continue;
235
+ const full = path.join(dir, entry.name);
236
+ const target = path.join(to, path.relative(from, full));
237
+ if (entry.isDirectory()) {
238
+ walk(full);
239
+ }
240
+ else if (entry.isFile()) {
241
+ const isManifest = dir === from && /^Package(@swift-[\d.]+)?\.swift$/.test(entry.name);
242
+ const inBridged = bridged.some((dir) => full.startsWith(dir + path.sep));
243
+ const content = entry.name.endsWith('.swift') && !isManifest
244
+ ? transformSource(applyPatch(patch, path.relative(from, full), readFileSync(full, 'utf8')), { bridged: inBridged, optionalRequirements }).text
245
+ : readFileSync(full);
246
+ writeIfChanged(target, content);
247
+ kept.add(target);
248
+ }
249
+ }
250
+ };
251
+ walk(from);
252
+ return kept;
253
+ }
254
+ function removeStale(dir, keep) {
255
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
256
+ if (entry.name === '.build')
257
+ continue;
258
+ const full = path.join(dir, entry.name);
259
+ if (entry.isDirectory()) {
260
+ removeStale(full, keep);
261
+ if (readdirSync(full).length === 0)
262
+ rmSync(full, { recursive: true });
263
+ }
264
+ else if (!keep.has(full)) {
265
+ rmSync(full, { force: true });
266
+ }
267
+ }
268
+ }
269
+ /** Where the copies live, and the package that resolves the originals. */
270
+ export function vendorDir(app) {
271
+ return path.join(stagingDir(app), 'Packages');
272
+ }
273
+ /**
274
+ * Resolves the app's package dependencies and copies the ones that import a
275
+ * shim module, and the ones that depend on those, into the staging package.
276
+ * Packages that are plain Swift all the way down are left to SwiftPM, as
277
+ * before. Returns the copies by identity; empty, without running SwiftPM,
278
+ * when the app has no packages to fetch.
279
+ */
280
+ export async function vendorPackages(app, toolchain, swiftPackagePath) {
281
+ const vendored = new Map();
282
+ const plans = planPackages(app.packages);
283
+ if (!plans.some((plan) => plan.kind === 'dependency'))
284
+ return vendored;
285
+ const root = vendorDir(app);
286
+ const resolveDir = path.join(root, '.resolve');
287
+ writeIfChanged(path.join(resolveDir, 'Package.swift'), resolveManifest(plans));
288
+ writeIfChanged(path.join(resolveDir, 'Sources', 'Resolve.swift'), '// Nothing to build: the package only resolves dependencies.\n');
289
+ const treeFile = path.join(resolveDir, 'dependencies.json');
290
+ const env = toolchainEnv(toolchain);
291
+ const shown = await run(toolchain.swift, ['package', 'show-dependencies', '--format', 'json', '--output-path', treeFile], { cwd: resolveDir, env });
292
+ if (shown.status !== 0 || !existsSync(treeFile)) {
293
+ throw new CliError(`could not resolve the app's Swift packages:\n${shown.output.trim()}`);
294
+ }
295
+ const nodes = packageNodes(JSON.parse(readFileSync(treeFile, 'utf8')));
296
+ // The packages that import a shim module, and every package that depends on
297
+ // one of them (so that it depends on the copy).
298
+ // A package SwiftBrowser stands in for counts as copied: its "copy" is a redirect.
299
+ const copied = new Set(nodes.filter((node) => PACKAGE_STAND_INS[node.identity] || PACKAGE_PATCHES[node.identity] || (existsSync(node.path) && importsShim(node.path))).map((node) => node.identity));
300
+ for (let grew = true; grew;) {
301
+ grew = false;
302
+ for (const node of nodes) {
303
+ if (!copied.has(node.identity) && node.dependencies.some((identity) => copied.has(identity))) {
304
+ copied.add(node.identity);
305
+ grew = true;
306
+ }
307
+ }
308
+ }
309
+ const copyDir = (identity) => path.join(root, identity);
310
+ const keep = new Set([path.join(root, '.resolve')]);
311
+ for (const node of nodes) {
312
+ if (!copied.has(node.identity))
313
+ continue;
314
+ const dir = copyDir(node.identity);
315
+ const standIn = PACKAGE_STAND_INS[node.identity];
316
+ if (standIn) {
317
+ const files = new Set([path.join(dir, 'Package.swift')]);
318
+ writeIfChanged(path.join(dir, 'Package.swift'), redirectManifest(node.name, standIn.products, standIn.reason, swiftPackagePath));
319
+ for (const product of standIn.products) {
320
+ const file = path.join(dir, 'Sources', `_${product}StandIn`, `_${product}StandIn.swift`);
321
+ writeIfChanged(file, `// Empty: the product forwards to SwiftBrowser's ${product} module.\n`);
322
+ files.add(file);
323
+ }
324
+ removeStale(dir, files);
325
+ keep.add(dir);
326
+ vendored.set(node.identity, { identity: node.identity, name: node.name, source: node.path, local: false, version: node.version, dir, targets: [], standIn: standIn.reason, modules: [...standIn.products] });
327
+ continue;
328
+ }
329
+ const targets = [];
330
+ const moduleNames = [];
331
+ const cache = path.join(dir, TARGETS_CACHE);
332
+ // The targets built against the shim, found in the original sources
333
+ // first: their copies are adjusted as bridged modules.
334
+ const shimTargets = [];
335
+ mkdirSync(dir, { recursive: true });
336
+ for (const target of await dumpTargets(node.path, cache, toolchain)) {
337
+ if (target.type !== 'regular' && target.type !== 'executable')
338
+ continue;
339
+ moduleNames.push(target.name);
340
+ const sourceDir = targetDir(node.path, target);
341
+ if (!sourceDir)
342
+ continue;
343
+ const texts = swiftFiles(sourceDir).map((file) => readFileSync(file, 'utf8'));
344
+ const modules = new Set(texts.flatMap((text) => importsOf(text)).filter((module) => SHIM_MODULES.has(module)));
345
+ const uses = [
346
+ ...(texts.some(usesObjC) ? ['Objective-C selectors'] : []),
347
+ ...(texts.some(usesPosixMutex) ? ['POSIX mutexes'] : []),
348
+ ...(texts.some(importsDispatch) ? ['Dispatch'] : []),
349
+ ...(texts.some(importsObjectiveC) ? ['Objective-C associated objects'] : []),
350
+ ];
351
+ if (modules.size === 0 && uses.length === 0)
352
+ continue;
353
+ targets.push({ name: target.name, imports: [...modules].sort(), modules: targetProducts(featuresOf(texts)), ...(uses.length > 0 ? { uses } : {}) });
354
+ shimTargets.push({ name: target.name, sourceDir, texts });
355
+ }
356
+ // SwiftBrowser's edits, checked against this version before anything is copied.
357
+ const patch = PACKAGE_PATCHES[node.identity];
358
+ if (patch)
359
+ checkPatch(node.identity, node.version, node.path, patch);
360
+ const files = copyPackage(node.path, dir, shimTargets.map((target) => target.sourceDir), patch);
361
+ files.add(cache);
362
+ const catalogs = [];
363
+ for (const { name, sourceDir, texts } of shimTargets) {
364
+ const aliases = path.join(dir, path.relative(node.path, sourceDir), FULL_FOUNDATION_FILE);
365
+ writeIfChanged(aliases, fullFoundationSource(featuresOf(texts), declaredTypeNames(texts)) + moduleBundleSource(`${node.identity}_${name}`));
366
+ files.add(aliases);
367
+ // Packages get the resource members only (Backyard Birds' declare their own `Color` members).
368
+ const targetCatalogList = targetCatalogs(sourceDir);
369
+ catalogs.push(...targetCatalogList);
370
+ const symbols = assetSymbolsSource(targetCatalogList, { declared: declaredStaticMembers(texts) });
371
+ if (symbols) {
372
+ const file = path.join(dir, path.relative(node.path, sourceDir), ASSET_SYMBOLS_FILE);
373
+ writeIfChanged(file, symbols);
374
+ files.add(file);
375
+ }
376
+ }
377
+ const copies = new Map(node.dependencies.filter((identity) => copied.has(identity)).map((identity) => [identity, copyDir(identity)]));
378
+ for (const manifest of manifestFiles(node.path)) {
379
+ const text = readFileSync(path.join(node.path, manifest), 'utf8');
380
+ writeIfChanged(path.join(dir, manifest), text + manifestPatch(targets, swiftPackagePath, copies, toolsVersion(text)));
381
+ }
382
+ removeStale(dir, files);
383
+ keep.add(dir);
384
+ vendored.set(node.identity, {
385
+ identity: node.identity,
386
+ name: node.name,
387
+ source: node.path,
388
+ local: !node.path.startsWith(`${resolveDir}${path.sep}`),
389
+ version: node.version,
390
+ dir,
391
+ targets,
392
+ modules: moduleNames,
393
+ ...(patch ? { patched: patch.edits.length } : {}),
394
+ ...(catalogs.length > 0 ? { catalogs } : {}),
395
+ });
396
+ }
397
+ // Copies of packages the app no longer uses.
398
+ for (const entry of readdirSync(root)) {
399
+ const full = path.join(root, entry);
400
+ if (!keep.has(full))
401
+ rmSync(full, { recursive: true, force: true });
402
+ }
403
+ return vendored;
404
+ }
405
+ /** Next to a copy: its targets, keyed by the manifests they were read from. */
406
+ const TARGETS_CACHE = '.swiftbrowser-targets.json';
407
+ /**
408
+ * The targets of a package's manifest. Evaluating a manifest takes a moment,
409
+ * so the result is kept in `cache` (in the copy, never in the user's folder)
410
+ * with a hash of the manifests it came from.
411
+ */
412
+ async function dumpTargets(packageDir, cache, toolchain) {
413
+ const hash = createHash('sha256');
414
+ for (const manifest of manifestFiles(packageDir).sort())
415
+ hash.update(manifest).update(readFileSync(path.join(packageDir, manifest)));
416
+ hash.update(toolchain.version);
417
+ const key = hash.digest('hex');
418
+ if (existsSync(cache)) {
419
+ try {
420
+ const cached = JSON.parse(readFileSync(cache, 'utf8'));
421
+ if (cached.key === key)
422
+ return cached.targets;
423
+ }
424
+ catch {
425
+ // Unreadable: read the manifest again.
426
+ }
427
+ }
428
+ // The scratch path keeps SwiftPM's caches out of the package's folder (it may be the user's).
429
+ const scratch = path.join(path.dirname(cache), '.build');
430
+ const dumped = await run(toolchain.swift, ['package', 'dump-package', '--package-path', packageDir, '--scratch-path', scratch], { cwd: path.dirname(cache), env: toolchainEnv(toolchain) });
431
+ if (dumped.status !== 0)
432
+ throw new CliError(`could not read the manifest of ${packageDir}:\n${dumped.output.trim()}`);
433
+ // stderr is interleaved; the JSON is the object from the first `{` at the start of a line.
434
+ const start = dumped.output.search(/^\{/m);
435
+ const manifest = JSON.parse(dumped.output.slice(start));
436
+ const targets = manifest.targets.map((t) => ({ name: t.name, type: t.type, path: t.path ?? null }));
437
+ writeIfChanged(cache, JSON.stringify({ key, targets }));
438
+ return targets;
439
+ }
440
+ //# sourceMappingURL=vendor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vendor.js","sourceRoot":"","sources":["../src/vendor.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,EAAE;AACF,4EAA4E;AAC5E,4EAA4E;AAC5E,2EAA2E;AAC3E,0EAA0E;AAC1E,EAAE;AACF,2EAA2E;AAC3E,yEAAyE;AACzE,sDAAsD;AACtD,8EAA8E;AAC9E,8EAA8E;AAC9E,+BAA+B;AAC/B,EAAE;AACF,0EAA0E;AAC1E,sEAAsE;AACtE,6EAA6E;AAC7E,2EAA2E;AAC3E,yCAAyC;AACzC,EAAE;AACF,6EAA6E;AAC7E,6EAA6E;AAC7E,sEAAsE;AAEtE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClG,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClH,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO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