@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
package/dist/objc.js ADDED
@@ -0,0 +1,319 @@
1
+ // Objective-C idioms that Swift without the Objective-C runtime rejects, and
2
+ // how a source is adjusted so it compiles for the browser. Each rewrite keeps
3
+ // every line where it was (diagnostics keep their places): what is added goes
4
+ // on an existing line, and what is removed becomes blank lines.
5
+ //
6
+ // - `@objc` protocols are class-bound, and their `optional` requirements
7
+ // become plain requirements with default implementations
8
+ // (`objcProtocols`); calls written for an optional requirement
9
+ // (`delegate?.method?(…)`) call it plainly (`optionalRequirementCalls`).
10
+ // - An `override` in an extension, which Swift allows only for `@objc`
11
+ // members, is removed: the superclass's member stays
12
+ // (`extensionOverrides`).
13
+ // - `#keyPath(Type.property)` becomes the string `"property"`, which is all
14
+ // key-value coding on Apple platforms takes from it (`keyPathStrings`).
15
+ import { matchingBrace } from './stage.js';
16
+ const ATTRIBUTE = String.raw `@[A-Za-z_][A-Za-z0-9_]*(?:\([^()\n]*(?:\([^()\n]*\)[^()\n]*)*\))?`;
17
+ const ACCESS = String.raw `(?:public|package|internal|fileprivate|private|open)`;
18
+ /** An `@objc` protocol's head, up to its `{`. */
19
+ const OBJC_PROTOCOL = new RegExp(String.raw `^([ \t]*)((?:${ATTRIBUTE}[ \t]+|${ATTRIBUTE}[ \t]*\r?\n[ \t]*)*)(?:(${ACCESS})[ \t]+)?protocol[ \t]+([A-Za-z_][A-Za-z0-9_]*)([^{\n]*)\{`, 'gm');
20
+ /** An `optional` requirement inside a protocol body: its attributes, then `optional`, then `func` or `var`. */
21
+ const OPTIONAL_REQUIREMENT = new RegExp(String.raw `((?:${ATTRIBUTE}[ \t]+)*)\boptional[ \t]+(?=(?:${ATTRIBUTE}[ \t]+)*(?:func|var|static|class)\b)`, 'g');
22
+ /**
23
+ * `@objc protocol Delegate { @objc optional func didFinish() }` →
24
+ * `protocol Delegate: AnyObject { func didFinish() } extension Delegate { func didFinish() {} }`
25
+ * (the extension on the line of the closing brace).
26
+ *
27
+ * A default answers what an unimplemented optional requirement left to its
28
+ * caller as nil: nothing for `Void`, `nil` for an optional, and the type's
29
+ * zero for the common value types (`false`, `0`, `""`, empty collections).
30
+ * A call that read nil as "not implemented" (`delegate?.isEnabled ?? true`)
31
+ * now gets that zero instead. A requirement of another type has no value to
32
+ * answer and traps if a conformer leaves it out.
33
+ */
34
+ export function objcProtocols(text) {
35
+ if (!/@objc\b/.test(text) || !/\bprotocol\b/.test(text))
36
+ return text;
37
+ let result = '';
38
+ let index = 0;
39
+ OBJC_PROTOCOL.lastIndex = 0;
40
+ for (;;) {
41
+ OBJC_PROTOCOL.lastIndex = index;
42
+ const match = OBJC_PROTOCOL.exec(text);
43
+ if (!match)
44
+ break;
45
+ const attributes = match[2] ?? '';
46
+ const open = match.index + match[0].length - 1;
47
+ if (!/@objc\b/.test(attributes)) {
48
+ result += text.slice(index, open + 1);
49
+ index = open + 1;
50
+ continue;
51
+ }
52
+ const close = matchingBrace(text, open);
53
+ if (close < 0)
54
+ break;
55
+ const access = match[3];
56
+ const name = match[4];
57
+ const inheritance = match[5];
58
+ // The head, class-bound: Objective-C protocols are.
59
+ const headStart = match.index + match[0].length - 1 - inheritance.length;
60
+ result += text.slice(index, headStart);
61
+ result += classBound(inheritance);
62
+ result += '{';
63
+ const body = text.slice(open + 1, close);
64
+ const defaults = [];
65
+ let rewritten = '';
66
+ let bodyIndex = 0;
67
+ for (const requirement of body.matchAll(OPTIONAL_REQUIREMENT)) {
68
+ const start = requirement.index;
69
+ if (start < bodyIndex)
70
+ continue;
71
+ const attrs = requirement[1] ?? '';
72
+ const declaration = requirementAt(body, start + requirement[0].length);
73
+ const above = attributeLinesAbove(body, start);
74
+ if (declaration && unavailableInSwift(above.text + attrs)) {
75
+ // Obsoleted in Swift (a renamed Objective-C spelling): nothing calls
76
+ // it, and only an `@objc` protocol may have unavailable members.
77
+ rewritten += body.slice(bodyIndex, above.start) + blank(body.slice(above.start, declaration.end));
78
+ bodyIndex = declaration.end;
79
+ continue;
80
+ }
81
+ rewritten += body.slice(bodyIndex, start) + attrs;
82
+ bodyIndex = start + requirement[0].length;
83
+ if (declaration)
84
+ defaults.push(defaultImplementation(above.text + attrs, declaration));
85
+ }
86
+ result += rewritten + body.slice(bodyIndex);
87
+ const publicAccess = access === 'public' || access === 'open' ? 'public ' : '';
88
+ result += '}';
89
+ if (defaults.length > 0)
90
+ result += `; ${publicAccess}extension ${name} { ${defaults.join('; ')} }`;
91
+ index = close + 1;
92
+ }
93
+ result += text.slice(index);
94
+ return result;
95
+ }
96
+ /** The lines just above `offset` that hold only attributes (or comments), and where they start. */
97
+ function attributeLinesAbove(body, offset) {
98
+ let start = body.lastIndexOf('\n', offset - 1) + 1;
99
+ // Only when the requirement starts its line (after its own attributes).
100
+ if (body.slice(start, offset).trim() !== '')
101
+ return { start: offset, text: '' };
102
+ const attributeLine = new RegExp(String.raw `^[ \t]*(?:(?:${ATTRIBUTE})[ \t]*)+(?://.*)?\r?$|^[ \t]*//.*$`);
103
+ let text = '';
104
+ while (start > 0) {
105
+ const previousStart = body.lastIndexOf('\n', start - 2) + 1;
106
+ const line = body.slice(previousStart, start - 1);
107
+ if (!attributeLine.test(line))
108
+ break;
109
+ if (!/^[ \t]*\/\//.test(line))
110
+ text = `${line.trim()} ${text}`;
111
+ start = previousStart;
112
+ }
113
+ return { start, text };
114
+ }
115
+ /** Whether the attributes make a declaration unavailable to Swift (`@available(swift, obsoleted: 1)`, `@available(*, unavailable)`). */
116
+ function unavailableInSwift(attributes) {
117
+ return /@available\(\s*swift\s*,[^)]*\bobsoleted\b/.test(attributes) || /@available\(\s*\*\s*,[^)]*\bunavailable\b/.test(attributes);
118
+ }
119
+ /** `text` with everything but its line breaks removed. */
120
+ function blank(text) {
121
+ return text.replace(/[^\n]/g, '');
122
+ }
123
+ /** `: NSObjectProtocol ` → `: NSObjectProtocol, AnyObject `; nothing → `: AnyObject `. */
124
+ function classBound(inheritance) {
125
+ if (/\b(?:AnyObject|class)\b/.test(inheritance))
126
+ return inheritance;
127
+ const where = /\bwhere\b/.exec(inheritance);
128
+ const clause = where ? inheritance.slice(0, where.index) : inheritance;
129
+ const rest = where ? inheritance.slice(where.index) : '';
130
+ if (/:/.test(clause))
131
+ return `${clause.replace(/\s*$/, '')}, AnyObject ${rest}`.replace(/\s+$/, ' ');
132
+ return `${clause.replace(/\s*$/, '')}: AnyObject ${rest}`.replace(/\s+$/, ' ');
133
+ }
134
+ /** The requirement declared at `start` (just after `optional `). */
135
+ function requirementAt(body, start) {
136
+ const rest = body.slice(start);
137
+ const funcMatch = /^((?:[A-Za-z_@][^\n(]*?)?\bfunc[ \t]+[^(\n]+)\(/.exec(rest);
138
+ if (funcMatch) {
139
+ const open = funcMatch[0].length - 1;
140
+ const close = matchingParenthesis(rest, open);
141
+ if (close < 0)
142
+ return undefined;
143
+ // What follows the parameters: effects and a result, up to the end of
144
+ // the line (or the next line when it continues with `->`).
145
+ const after = rest.slice(close + 1);
146
+ const lineEnd = after.indexOf('\n');
147
+ let tail = lineEnd < 0 ? after : after.slice(0, lineEnd);
148
+ let length = close + 1 + tail.length;
149
+ if (!/->/.test(tail) && lineEnd >= 0) {
150
+ const next = after.slice(lineEnd + 1).split('\n')[0] ?? '';
151
+ if (/^\s*(?:->|async\b|throws\b|rethrows\b)/.test(next)) {
152
+ tail = `${tail} ${next}`;
153
+ length += 1 + next.length;
154
+ }
155
+ }
156
+ tail = tail.replace(/\/\/.*$/, '').replace(/\{.*$/, '').trim();
157
+ const signature = `${rest.slice(0, close + 1)} ${tail}`.replace(/\s+/g, ' ').trim();
158
+ const arrow = /->\s*(.+?)(?:\s+where\b.*)?$/.exec(tail);
159
+ return { signature, kind: 'func', end: start + length, type: arrow?.[1]?.trim(), settable: false };
160
+ }
161
+ const varMatch = /^((?:[A-Za-z_@][^\n]*?)?\bvar[ \t]+[A-Za-z_][A-Za-z0-9_]*[ \t]*:[ \t]*([^{\n]+?))[ \t]*\{([^}]*)\}/.exec(rest);
162
+ if (varMatch) {
163
+ return { signature: varMatch[1].replace(/\s+/g, ' ').trim(), kind: 'var', end: start + varMatch[0].length, type: varMatch[2].trim(), settable: /\bset\b/.test(varMatch[3]) };
164
+ }
165
+ return undefined;
166
+ }
167
+ function matchingParenthesis(text, open) {
168
+ let depth = 0;
169
+ for (let i = open; i < text.length; i += 1) {
170
+ if (text[i] === '(')
171
+ depth += 1;
172
+ else if (text[i] === ')') {
173
+ depth -= 1;
174
+ if (depth === 0)
175
+ return i;
176
+ }
177
+ }
178
+ return -1;
179
+ }
180
+ /** The default implementation of an optional requirement, on one line. */
181
+ function defaultImplementation(attributes, requirement) {
182
+ const kept = attributes.replace(/@objc\b(?:\([^)\n]*\))?[ \t]*/g, '').replace(/\s+/g, ' ').trim();
183
+ const value = zeroValue(requirement.type);
184
+ const prefix = kept ? `${kept} ` : '';
185
+ if (requirement.kind === 'func') {
186
+ const body = value === undefined ? '' : ` ${value} `;
187
+ return `${prefix}${requirement.signature} {${body}}`;
188
+ }
189
+ const getter = value ?? 'fatalError("no default for an optional requirement")';
190
+ return requirement.settable
191
+ ? `${prefix}${requirement.signature} { get { ${getter} } set {} }`
192
+ : `${prefix}${requirement.signature} { ${getter} }`;
193
+ }
194
+ /** What a default answers for `type`: undefined for none (`Void`). */
195
+ function zeroValue(type) {
196
+ if (!type || type === 'Void' || type === '()')
197
+ return undefined;
198
+ if (/[?!]$/.test(type) || /^Optional</.test(type))
199
+ return 'nil';
200
+ if (type === 'Bool')
201
+ return 'false';
202
+ if (/^(?:U?Int(?:8|16|32|64)?|Double|Float|CGFloat|TimeInterval|NSInteger|NSUInteger)$/.test(type))
203
+ return '0';
204
+ if (type === 'String')
205
+ return '""';
206
+ if (/^\[[^:\]]*\]$/.test(type))
207
+ return '[]';
208
+ if (/^\[.*:.*\]$/.test(type))
209
+ return '[:]';
210
+ return `fatalError("no default for an optional requirement returning ${type.replace(/"/g, '')}")`;
211
+ }
212
+ /** The names of the `optional` requirements the sources declare. */
213
+ export function optionalRequirementNames(texts) {
214
+ const names = new Set();
215
+ const pattern = /\boptional[ \t]+(?:@[A-Za-z_]+[ \t]+)*(?:static[ \t]+|class[ \t]+)?(?:func|var)[ \t]+([A-Za-z_][A-Za-z0-9_]*)/g;
216
+ for (const text of texts) {
217
+ for (const match of text.matchAll(pattern))
218
+ names.add(match[1]);
219
+ }
220
+ return names;
221
+ }
222
+ /**
223
+ * Calls of optional requirements, as plain calls: `delegate?.method?(…)` →
224
+ * `delegate?.method(…)`, `delegate.method?(…)` → `delegate.method(…)`, and
225
+ * `if let impl = delegate.method {` → `if let impl = Optional(delegate.method) {`
226
+ * (the requirement is always there now).
227
+ */
228
+ export function optionalRequirementCalls(text, names) {
229
+ if (names.size === 0)
230
+ return text;
231
+ let out = text;
232
+ for (const name of names) {
233
+ if (!out.includes(name))
234
+ continue;
235
+ out = out.replace(new RegExp(String.raw `\.${name}\?(\s*\()`, 'g'), `.${name}$1`);
236
+ out = out.replace(new RegExp(String.raw `\b((?:if|guard)[ \t]+(?:let|var)[ \t]+[A-Za-z_][A-Za-z0-9_]*[ \t]*=[ \t]*)([A-Za-z_][\w.?]*\.${name})(?=[ \t]*(?:\{|,|else\b))`, 'g'), '$1Optional($2)');
237
+ }
238
+ return out;
239
+ }
240
+ /**
241
+ * Blanks every `override` member declared in an extension. Swift allows
242
+ * one only for an `@objc` member of the superclass (`description`,
243
+ * `isEqual(_:)` on NSObject subclasses), which needs the Objective-C
244
+ * runtime; without it, the superclass's member stays.
245
+ */
246
+ export function extensionOverrides(text) {
247
+ if (!/\boverride\b/.test(text) || !/\bextension\b/.test(text))
248
+ return text;
249
+ const extensionHead = new RegExp(String.raw `^[ \t]*(?:${ATTRIBUTE}[ \t]+)*(?:${ACCESS}[ \t]+)?extension[ \t]+[^{\n]*\{`, 'gm');
250
+ const blanks = [];
251
+ for (const match of text.matchAll(extensionHead)) {
252
+ const open = match.index + match[0].length - 1;
253
+ const close = matchingBrace(text, open);
254
+ if (close < 0)
255
+ continue;
256
+ // Members at the extension's top level.
257
+ let i = open + 1;
258
+ while (i < close) {
259
+ const lineEnd = text.indexOf('\n', i);
260
+ const end = lineEnd < 0 || lineEnd > close ? close : lineEnd;
261
+ const line = text.slice(i, end);
262
+ const member = new RegExp(String.raw `^[ \t]*(?:(?:${ATTRIBUTE}|${ACCESS}(?:\(set\))?|final|dynamic|@objc)[ \t]+)*override\b[^{\n]*\{`).exec(line);
263
+ if (member) {
264
+ const braceOpen = i + member[0].length - 1;
265
+ const braceClose = matchingBrace(text, braceOpen);
266
+ if (braceClose < 0 || braceClose > close)
267
+ break;
268
+ // Attribute lines just above go with it.
269
+ let start = i;
270
+ for (;;) {
271
+ if (start === 0 || text[start - 1] !== '\n')
272
+ break;
273
+ const previousStart = text.lastIndexOf('\n', start - 2) + 1;
274
+ if (previousStart <= open || !new RegExp(String.raw `^[ \t]*${ATTRIBUTE}[ \t]*\r?$`).test(text.slice(previousStart, start - 1)))
275
+ break;
276
+ start = previousStart;
277
+ }
278
+ blanks.push([start, braceClose + 1]);
279
+ const next = text.indexOf('\n', braceClose);
280
+ i = next < 0 ? close : next + 1;
281
+ continue;
282
+ }
283
+ // Skip nested bodies (a member's body is not the extension's top level).
284
+ const brace = line.indexOf('{');
285
+ if (brace >= 0) {
286
+ const nestedClose = matchingBrace(text, i + brace);
287
+ if (nestedClose < 0 || nestedClose > close)
288
+ break;
289
+ const next = text.indexOf('\n', nestedClose);
290
+ i = next < 0 ? close : next + 1;
291
+ continue;
292
+ }
293
+ i = end + 1;
294
+ }
295
+ }
296
+ if (blanks.length === 0)
297
+ return text;
298
+ let result = '';
299
+ let index = 0;
300
+ for (const [start, end] of blanks.sort((a, b) => a[0] - b[0])) {
301
+ if (start < index)
302
+ continue;
303
+ result += text.slice(index, start) + text.slice(start, end).replace(/[^\n]/g, '');
304
+ index = end;
305
+ }
306
+ return result + text.slice(index);
307
+ }
308
+ /** `#keyPath(Type.isFinished)` → `"isFinished"`; `#keyPath(model.name)` → `"model.name"`. */
309
+ export function keyPathStrings(text) {
310
+ if (!text.includes('#keyPath'))
311
+ return text;
312
+ return text.replace(/#keyPath\(\s*([A-Za-z_][\w.]*)\s*\)/g, (_, path) => {
313
+ const parts = path.split('.');
314
+ if (parts.length > 1 && /^[A-Z]/.test(parts[0]))
315
+ parts.shift();
316
+ return JSON.stringify(parts.join('.'));
317
+ });
318
+ }
319
+ //# sourceMappingURL=objc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objc.js","s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M,UAAU,cAAc,CAAC,IAAY;IACzC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO,IAAI,CAAC;IAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,sCAAsC,EAAE,CAAC,CAAC,EAAE,IAAY,EAAE,EAAE;QAC9E,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9B,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC;YAAE,KAAK,CAAC,KAAK,EAAE,CAAC;QAChE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,24 @@
1
+ export interface PackageEdit {
2
+ /** The file, relative to the package's root. */
3
+ file: string;
4
+ /** What it does, for the build log and the error. */
5
+ why: string;
6
+ /** The exact passage, found once in the file. */
7
+ find: string;
8
+ replace: string;
9
+ }
10
+ export interface PackagePatch {
11
+ /** The release the patch was written for. */
12
+ version: string;
13
+ edits: readonly PackageEdit[];
14
+ }
15
+ /** Patches by SwiftPM identity. */
16
+ export declare const PACKAGE_PATCHES: Readonly<Record<string, PackagePatch>>;
17
+ /**
18
+ * Checks that every edit of `patch` applies to the package at `packageDir`
19
+ * (its passage is in its file exactly once), and throws a `CliError` naming
20
+ * the first that does not.
21
+ */
22
+ export declare function checkPatch(identity: string, version: string, packageDir: string, patch: PackagePatch): void;
23
+ /** `text` (the file at `relative` in the package) with the patch's edits of it applied. */
24
+ export declare function applyPatch(patch: PackagePatch | undefined, relative: string, text: string): string;
@@ -0,0 +1,107 @@
1
+ // Edits SwiftBrowser makes to a package's sources before building it against
2
+ // the shim, for what neither the shim nor the source adjustments (stage.ts,
3
+ // objc.ts) can cover: code that only works with the Objective-C runtime or
4
+ // relies on Apple's type identities. Each edit replaces one exact passage of
5
+ // one file, in the package as published, before the usual adjustments; the
6
+ // copy is changed, never SwiftPM's checkout. A replacement keeps the
7
+ // passage's line count (it is padded with blank lines), so diagnostics in
8
+ // the rest of the file keep their places.
9
+ //
10
+ // A patch is written against one release. When a passage is not in the
11
+ // resolved version exactly once, the build stops and says which: the patch
12
+ // has to be brought up to date for that release (or the package pinned to
13
+ // the release it was written for).
14
+ import { existsSync, readFileSync } from 'node:fs';
15
+ import path from 'node:path';
16
+ import { CliError } from './log.js';
17
+ const lines = (...parts) => parts.join('\n');
18
+ /** Patches by SwiftPM identity. */
19
+ export const PACKAGE_PATCHES = {
20
+ // RevenueCat's SDK (the product `RevenueCat`). Its purchases go to StoreKit,
21
+ // which in the browser has no products and refuses payments
22
+ // (Sources/StoreKit); its backend is reached over URLSession.
23
+ 'purchases-ios-spm': {
24
+ version: '5.92.0',
25
+ edits: [
26
+ {
27
+ file: 'Sources/Attribution/ASIdManagerProxy.swift',
28
+ why: 'the advertising identifier: a method called on a class found by name (none is found)',
29
+ find: 'return classType.sharedManager().value(forKey: Self.mangledIdentifierPropertyName.rot13()) as? UUID',
30
+ replace: '_ = classType; return nil',
31
+ },
32
+ {
33
+ file: 'Sources/Attribution/TrackingManagerProxy.swift',
34
+ why: 'the tracking authorization: a method called on a class found by name (none is found)',
35
+ find: 'return classType.trackingAuthorizationStatus()',
36
+ replace: '_ = classType; return 0',
37
+ },
38
+ {
39
+ file: 'Sources/Attribution/AttributionFetcher.swift',
40
+ why: 'the tracking authorization through a method implementation (IMP) cast to a C function: not determined',
41
+ find: lines(' typealias ClosureType = @convention(c) (AnyObject, Selector) -> FakeTrackingManagerAuthorizationStatus', ' let authStatusMethodImplementation = trackingManagerProxy.method(for: authStatusSelector)', ' let authStatusMethod: ClosureType = unsafeBitCast(authStatusMethodImplementation, to: ClosureType.self)', ' let authStatus = authStatusMethod(trackingManagerProxy, authStatusSelector)', ' return authStatus'),
42
+ replace: ' return .notDetermined',
43
+ },
44
+ {
45
+ file: 'Sources/Support/ManageSubscriptionsHelper.swift',
46
+ why: "opening the management URL through UIApplication's openURL method implementation: UIApplication.open instead",
47
+ find: lines(' typealias ClosureType = @convention(c) (AnyObject, Selector, NSURL, NSDictionary?, Any?) -> Void', '', ' let selector: Selector = NSSelectorFromString("openURL:options:completionHandler:")', ' let methodIMP: IMP! = application.method(for: selector)', ' let openURLMethod = unsafeBitCast(methodIMP, to: ClosureType.self)', ' openURLMethod(application, selector, url as NSURL, nil, nil)'),
48
+ replace: ' Task { @MainActor in application.open(url) }',
49
+ },
50
+ {
51
+ file: 'Sources/Error Handling/PurchasesError.swift',
52
+ why: 'an initializer overloaded on [NSError.UserInfoKey: Any], which is [String: Any] here',
53
+ find: lines(' init(error: ErrorCode, userInfo: [NSError.UserInfoKey: Any]) {', ' self.init(error: error, userInfo: userInfo as [String: Any])', ' }'),
54
+ replace: '',
55
+ },
56
+ {
57
+ file: 'Sources/Error Handling/ErrorUtils.swift',
58
+ why: 'a method overloaded on [NSError.UserInfoKey: Any], which is [String: Any] here',
59
+ find: lines(' @_disfavoredOverload', ' func addingUserInfo<Result: NSError>(_ userInfo: [NSError.UserInfoKey: Any]) -> Result {', ' return self.addingUserInfo(userInfo as [String: Any])', ' }'),
60
+ replace: '',
61
+ },
62
+ {
63
+ file: 'Sources/Error Handling/ErrorUtils.swift',
64
+ why: "an NSError subclass made from its metatype, which needs a required initializer corelibs' NSError lacks",
65
+ find: lines(' return .init(domain: nsError.domain,', ' code: nsError.code,', ' userInfo: nsError.userInfo + userInfo)'),
66
+ replace: lines(' return NSError(domain: nsError.domain,', ' code: nsError.code,', ' userInfo: nsError.userInfo + userInfo) as! Result'),
67
+ },
68
+ ],
69
+ },
70
+ };
71
+ /** `replace`, padded with line breaks to `find`'s line count. */
72
+ function padded(edit) {
73
+ const missing = edit.find.split('\n').length - edit.replace.split('\n').length;
74
+ if (missing < 0)
75
+ throw new Error(`a patch edit of ${edit.file} adds lines`);
76
+ return edit.replace + '\n'.repeat(missing);
77
+ }
78
+ /**
79
+ * Checks that every edit of `patch` applies to the package at `packageDir`
80
+ * (its passage is in its file exactly once), and throws a `CliError` naming
81
+ * the first that does not.
82
+ */
83
+ export function checkPatch(identity, version, packageDir, patch) {
84
+ for (const edit of patch.edits) {
85
+ const file = path.join(packageDir, edit.file);
86
+ const text = existsSync(file) ? readFileSync(file, 'utf8') : undefined;
87
+ const count = text === undefined ? 0 : text.split(edit.find).length - 1;
88
+ if (count === 1)
89
+ continue;
90
+ const problem = text === undefined ? 'the file is not there' : count === 0 ? 'the passage it replaces is not there' : `the passage it replaces is there ${count} times`;
91
+ throw new CliError(`SwiftBrowser's patch for ${identity} does not apply to ${version}: ${edit.file}, ${edit.why}: ${problem}. ` +
92
+ `The patch was written for ${patch.version}; pin the package to ${patch.version} in Xcode, or update the patch (packages/cli/src/packagePatches.ts).`);
93
+ }
94
+ }
95
+ /** `text` (the file at `relative` in the package) with the patch's edits of it applied. */
96
+ export function applyPatch(patch, relative, text) {
97
+ if (!patch)
98
+ return text;
99
+ const normalized = relative.split(path.sep).join('/');
100
+ let out = text;
101
+ for (const edit of patch.edits) {
102
+ if (edit.file === normalized)
103
+ out = out.replace(edit.find, () => padded(edit));
104
+ }
105
+ return out;
106
+ }
107
+ //# sourceMappingURL=packagePatches.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packagePatches.js","sourceRoot":"","sources":["../src/packagePatches.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,4EAA4E;AAC5E,2EAA2E;AAC3E,6EAA6E;AAC7E,2EAA2E;AAC3E,qEAAqE;AACrE,0EAA0E;AAC1E,0CAA0C;AAC1C,EAAE;AACF,uEAAuE;AACvE,2EAA2E;AAC3E,0EAA0E;AAC1E,mCAAmC;AAEnC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU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CAAC;YAAE,SAAS;QAC1B,MAAM,OAAO,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,sCAAsC,CAAC,CAAC,CAAC,oCAAoC,KAAK,QAAQ,CAAC;QACxK,MAAM,IAAI,QAAQ,CAChB,4BAA4B,QAAQ,sBAAsB,OAAO,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,KAAK,OAAO,IAAI;YAC1G,6BAA6B,KAAK,CAAC,OAAO,wBAAwB,KAAK,CAAC,OAAO,sEAAsE,CACxJ,CAAC;IACJ,CAAC;AACH,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,UAAU,CAAC,KAA+B,EAAE,QAAgB,EAAE,IAAY;IACxF,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,MAAM,UAAU,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtD,IAAI,GAAG,GAAG,IAAI,CAAC;IACf,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAC/B,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU;YAAE,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { type SwiftPackageReference, type SwiftPackageRequirement } from '@swiftbrowser/xcodeproj';
2
+ import type { ConfigPackage } from './config.js';
3
+ /** A package the app target links, with the products it links from it. */
4
+ export interface AppPackage {
5
+ /** Absent when the project names the product but no package (or folder holding a `Package.swift`) provides it. */
6
+ reference?: SwiftPackageReference;
7
+ products: string[];
8
+ }
9
+ /**
10
+ * Packages the shim stands in for, by SwiftPM identity, with the reason the
11
+ * real one cannot be used and the products it provides. Each product is a
12
+ * module of the SwiftBrowser package (Sources/<Product>), listed in
13
+ * `STAND_IN_FRAMEWORKS`. When another package depends on one, the staging
14
+ * gives that package a redirect in its place (vendor.ts).
15
+ */
16
+ export declare const PACKAGE_STAND_INS: Readonly<Record<string, PackageStandIn>>;
17
+ export interface PackageStandIn {
18
+ reason: string;
19
+ products: readonly string[];
20
+ }
21
+ export type PackagePlan =
22
+ /** Not fetched: the shim's module of the same name is linked instead. */
23
+ {
24
+ kind: 'stand-in';
25
+ package: AppPackage;
26
+ reason: string;
27
+ }
28
+ /** Fetched and built by SwiftPM: `declaration` goes in the manifest's `dependencies`. */
29
+ | {
30
+ kind: 'dependency';
31
+ package: AppPackage;
32
+ identity: string;
33
+ declaration: string;
34
+ }
35
+ /** Left out, with what is missing; the build reports the imports that fail. */
36
+ | {
37
+ kind: 'unresolved';
38
+ package: AppPackage;
39
+ problem: string;
40
+ };
41
+ /** `swiftbrowser.json`'s packages (config.ts), as the Xcode project's are: paths relative to `root`. */
42
+ export declare function configPackages(packages: readonly ConfigPackage[], root: string): AppPackage[];
43
+ /** Groups a target's package products by package, in the order the project lists them. */
44
+ export declare function groupPackageProducts(dependencies: readonly {
45
+ product: string;
46
+ package?: SwiftPackageReference;
47
+ }[]): AppPackage[];
48
+ /** What the staging does with each package (`standIns` for tests: none today). */
49
+ export declare function planPackages(packages: readonly AppPackage[], standIns?: Readonly<Record<string, PackageStandIn>>): PackagePlan[];
50
+ /** Xcode's dependency rule as the argument of SwiftPM's `.package(url:…)`. */
51
+ export declare function requirementArgument(requirement: SwiftPackageRequirement): string;
52
+ /** The rule in words, as Xcode's package list shows it. */
53
+ export declare function describeRequirement(requirement: SwiftPackageRequirement): string;
54
+ /** A package as people name it: the URL's last component (case kept), or the folder. */
55
+ export declare function packageDisplayName(entry: AppPackage): string;
56
+ /** Where a package comes from, and on what rule, for the `check` report. */
57
+ export declare function packageSource(entry: AppPackage): string;
58
+ /** Module names the dependency packages provide, guessed as their product names → the package's name. */
59
+ export declare function packageModules(plans: readonly PackagePlan[]): Map<string, string>;