@swipt/cli 0.1.0-nightly.77 → 0.1.0-nightly.79

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 (68) hide show
  1. package/dist/availability.d.ts +5 -0
  2. package/dist/availability.js +349 -0
  3. package/dist/availability.js.map +1 -0
  4. package/dist/client.d.ts +25 -0
  5. package/dist/client.js +248 -0
  6. package/dist/client.js.map +1 -0
  7. package/dist/connection.d.ts +24 -0
  8. package/dist/connection.js +293 -0
  9. package/dist/connection.js.map +1 -0
  10. package/dist/coredevice.d.ts +22 -0
  11. package/dist/coredevice.js +329 -0
  12. package/dist/coredevice.js.map +1 -0
  13. package/dist/device.d.ts +130 -0
  14. package/dist/device.js +539 -0
  15. package/dist/device.js.map +1 -0
  16. package/dist/i18n.d.ts +2 -0
  17. package/dist/i18n.js +57 -0
  18. package/dist/i18n.js.map +1 -0
  19. package/dist/ignore.d.ts +8 -0
  20. package/dist/ignore.js +112 -0
  21. package/dist/ignore.js.map +1 -0
  22. package/dist/metro.d.ts +10 -0
  23. package/dist/metro.js +349 -0
  24. package/dist/metro.js.map +1 -0
  25. package/dist/output.d.ts +20 -0
  26. package/dist/output.js +116 -0
  27. package/dist/output.js.map +1 -0
  28. package/dist/project.d.ts +18 -0
  29. package/dist/project.js +696 -0
  30. package/dist/project.js.map +1 -0
  31. package/dist/proto/common_pb.js +34 -0
  32. package/dist/proto/common_pb.js.map +1 -0
  33. package/dist/proto/logs_pb.js +15 -0
  34. package/dist/proto/logs_pb.js.map +1 -0
  35. package/dist/proto/repl_pb.js +15 -0
  36. package/dist/proto/repl_pb.js.map +1 -0
  37. package/dist/proto/swiplets_pb.js +28 -0
  38. package/dist/proto/swiplets_pb.js.map +1 -0
  39. package/dist/proto/system_pb.js +15 -0
  40. package/dist/proto/system_pb.js.map +1 -0
  41. package/dist/sideload.d.ts +17 -0
  42. package/dist/sideload.js +1098 -0
  43. package/dist/sideload.js.map +1 -0
  44. package/dist/swipt.d.ts +1 -0
  45. package/dist/swipt.js +631 -0
  46. package/dist/swipt.js.map +1 -0
  47. package/dist/version.d.ts +2 -0
  48. package/dist/version.js +15 -0
  49. package/dist/version.js.map +1 -0
  50. package/package.json +21 -7
  51. package/availability.mjs +0 -642
  52. package/client.mjs +0 -375
  53. package/connection.mjs +0 -450
  54. package/coredevice.mjs +0 -478
  55. package/device.mjs +0 -837
  56. package/i18n.mjs +0 -71
  57. package/ignore.mjs +0 -149
  58. package/metro.mjs +0 -432
  59. package/output.mjs +0 -177
  60. package/project.mjs +0 -1013
  61. package/proto/common_pb.js +0 -98
  62. package/proto/logs_pb.js +0 -34
  63. package/proto/repl_pb.js +0 -55
  64. package/proto/swiplets_pb.js +0 -179
  65. package/proto/system_pb.js +0 -27
  66. package/sideload.mjs +0 -1696
  67. package/swipt.mjs +0 -726
  68. package/version.mjs +0 -16
@@ -0,0 +1,5 @@
1
+ export declare class AvailabilityChecker {
2
+ #private;
3
+ check(project: any, metafiles: any): void;
4
+ close(): void;
5
+ }
@@ -0,0 +1,349 @@
1
+ import { language, tr } from "./i18n.js";
2
+ import { parseVersion, versionAtLeast } from "./version.js";
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ import { NodeFlags, SyntaxKind } from "typescript/unstable/ast";
6
+ import { isTypeNode } from "typescript/unstable/ast/is";
7
+ import { API, SymbolFlags } from "typescript/unstable/sync";
8
+ // src/availability.ts
9
+ const requirements = {
10
+ apiLevel: {
11
+ parse: (text) => /^[1-9]\d*$/.test(text) ? Number(text) : void 0,
12
+ covers: (level, needed) => level >= needed,
13
+ describe: (level) => tr("API level {level}", { level })
14
+ },
15
+ iOS: {
16
+ parse: parseVersion,
17
+ covers: versionAtLeast,
18
+ describe: (version) => `iOS ${version.join(".")}`
19
+ }
20
+ };
21
+ const lists = new Intl.ListFormat(language, { type: "conjunction" });
22
+ const merge = (into, from) => {
23
+ for (const [name, needed] of Object.entries(from)) if (into[name] === void 0 || !requirements[name].covers(into[name], needed)) into[name] = needed;
24
+ return into;
25
+ };
26
+ const describe = (needed, missing) => lists.format(missing.map((name) => requirements[name].describe(needed[name])));
27
+ function parseAnnotation(text) {
28
+ const requirement = {};
29
+ for (const entry of text.split(",").map((part) => part.trim())) {
30
+ const [kind, value, ...rest] = entry.split(/\s+/);
31
+ const parsed = rest.length === 0 && Object.hasOwn(requirements, kind) ? requirements[kind].parse(value ?? "") : void 0;
32
+ if (parsed === void 0) return {
33
+ requirement,
34
+ invalid: entry
35
+ };
36
+ if (requirement[kind] !== void 0) return {
37
+ requirement,
38
+ repeated: kind
39
+ };
40
+ requirement[kind] = parsed;
41
+ }
42
+ return { requirement };
43
+ }
44
+ const tagText = (tag) => typeof tag.comment === "string" ? tag.comment : (tag.comment ?? []).map((part) => part.text).join("");
45
+ const annotationTags = (node) => (node.jsDoc ?? []).flatMap((comment) => (comment.tags ?? []).filter((tag) => tag.tagName.text === "available"));
46
+ const exits = (statement) => statement.kind === SyntaxKind.ReturnStatement || statement.kind === SyntaxKind.ThrowStatement || statement.kind === SyntaxKind.BreakStatement || statement.kind === SyntaxKind.ContinueStatement || statement.kind === SyntaxKind.Block && statement.statements.length > 0 && exits(statement.statements.at(-1));
47
+ const hasModifier = (node, kind) => node.modifiers?.some((modifier) => modifier.kind === kind) ?? false;
48
+ const functions = /* @__PURE__ */ new Set([
49
+ SyntaxKind.FunctionDeclaration,
50
+ SyntaxKind.FunctionExpression,
51
+ SyntaxKind.ArrowFunction,
52
+ SyntaxKind.MethodDeclaration,
53
+ SyntaxKind.GetAccessor,
54
+ SyntaxKind.SetAccessor,
55
+ SyntaxKind.Constructor
56
+ ]);
57
+ const classes = /* @__PURE__ */ new Set([SyntaxKind.ClassDeclaration, SyntaxKind.ClassExpression]);
58
+ const valueHolders = /* @__PURE__ */ new Set([
59
+ SyntaxKind.VariableDeclaration,
60
+ SyntaxKind.PropertyDeclaration,
61
+ SyntaxKind.PropertyAssignment
62
+ ]);
63
+ const objectMembers = /* @__PURE__ */ new Set([
64
+ SyntaxKind.PropertyAssignment,
65
+ SyntaxKind.ShorthandPropertyAssignment,
66
+ SyntaxKind.MethodDeclaration,
67
+ SyntaxKind.GetAccessor,
68
+ SyntaxKind.SetAccessor
69
+ ]);
70
+ const inert = /* @__PURE__ */ new Set([
71
+ SyntaxKind.ImportDeclaration,
72
+ SyntaxKind.ExportDeclaration,
73
+ SyntaxKind.InterfaceDeclaration,
74
+ SyntaxKind.TypeAliasDeclaration,
75
+ SyntaxKind.JsxClosingElement
76
+ ]);
77
+ function sourceFilesOf(root, metafiles) {
78
+ const files = /* @__PURE__ */ new Set();
79
+ for (const metafile of metafiles) for (const input of Object.keys(metafile.inputs)) {
80
+ const file = path.resolve(input);
81
+ if (!/^[a-z][\w-]+:/.test(input) && /\.[cm]?[jt]sx?$/.test(file) && !path.relative(root, file).startsWith("..") && !file.split(path.sep).includes("node_modules")) files.add(fs.realpathSync(file));
82
+ }
83
+ return [...files];
84
+ }
85
+ var AvailabilityChecker = class {
86
+ #api;
87
+ #open = /* @__PURE__ */ new Set();
88
+ check(project, metafiles) {
89
+ const files = sourceFilesOf(project.root, metafiles);
90
+ if (files.length === 0 && this.#open.size === 0) return;
91
+ this.#api ??= new API({ cwd: project.root });
92
+ if (this.#open.size > 0) this.#api.updateSnapshot({ closeFiles: [...this.#open] });
93
+ const snapshot = this.#api.updateSnapshot({
94
+ openFiles: files,
95
+ fileChanges: { invalidateAll: true }
96
+ });
97
+ this.#open = new Set(files);
98
+ if (files.length === 0) return;
99
+ const problems = {
100
+ lines: /* @__PURE__ */ new Set(),
101
+ guarding: false
102
+ };
103
+ const groups = Map.groupBy(files, (file) => snapshot.getDefaultProjectForFile(file));
104
+ for (const [typescript, owned] of groups) new Checker(typescript, project, files, problems).check(owned);
105
+ if (problems.lines.size > 0) throw new Error([...problems.lines, ...problems.guarding ? [tr("check these with available(), mark the code that uses them with @available, or raise \"swiplet.minimumAPILevel\" or \"swiplet.minimumIOSVersion\" in package.json")] : []].join("\n"));
106
+ }
107
+ close() {
108
+ this.#api?.close();
109
+ }
110
+ };
111
+ var Checker = class {
112
+ #project;
113
+ #checker;
114
+ #root;
115
+ #files;
116
+ #problems;
117
+ #minimum;
118
+ #entries;
119
+ #available;
120
+ #symbols = /* @__PURE__ */ new Map();
121
+ #requirements = /* @__PURE__ */ new Map();
122
+ #annotations = /* @__PURE__ */ new Map();
123
+ #facts = [/* @__PURE__ */ new Map(), /* @__PURE__ */ new Map()];
124
+ #types = /* @__PURE__ */ new Map();
125
+ constructor(typescript, project, files, problems) {
126
+ this.#project = typescript;
127
+ this.#checker = typescript.checker;
128
+ this.#root = project.root;
129
+ this.#files = new Set(files);
130
+ this.#problems = problems;
131
+ this.#minimum = {
132
+ apiLevel: project.config.minimumAPILevel ?? project.apiLevel,
133
+ iOS: parseVersion(project.config.minimumIOSVersion ?? project.minimumIOSVersion)
134
+ };
135
+ this.#entries = new Set([project.app, project.extension].filter(Boolean).map((entry) => fs.realpathSync(entry)));
136
+ this.#available = this.#availableSymbol(project.apiDirectory);
137
+ }
138
+ check(files) {
139
+ for (const file of files) {
140
+ const source = this.#project.program.getSourceFile(file);
141
+ const { identifiers, properties } = this.#collect(source);
142
+ const symbols = this.#checker.getSymbolAtLocation(identifiers);
143
+ for (const [index, node] of identifiers.entries()) this.#use(node, node.parent.kind === SyntaxKind.ShorthandPropertyAssignment ? this.#checker.getShorthandAssignmentValueSymbol(node.parent) : symbols[index]);
144
+ for (const node of properties) this.#use(node, this.#propertySymbol(node));
145
+ if (this.#entries.has(file)) {
146
+ for (const statement of source.statements) if (statement.name !== void 0 && hasModifier(statement, SyntaxKind.DefaultKeyword)) this.#useEntry(statement.name);
147
+ }
148
+ }
149
+ }
150
+ #collect(source) {
151
+ const identifiers = [];
152
+ const properties = [];
153
+ const visit = (node, checked) => {
154
+ for (const tag of annotationTags(node)) this.#parse(tagText(tag), tag);
155
+ const extended = node.kind === SyntaxKind.ExpressionWithTypeArguments && node.parent.token === SyntaxKind.ExtendsKeyword && classes.has(node.parent.parent.kind);
156
+ if (inert.has(node.kind) || isTypeNode(node) && !extended) checked = false;
157
+ if (checked && node.kind === SyntaxKind.Identifier) {
158
+ const { parent } = node;
159
+ const property = parent.kind === SyntaxKind.JsxAttribute || objectMembers.has(parent.kind) && parent.parent.kind === SyntaxKind.ObjectLiteralExpression && parent.name === node || parent.kind === SyntaxKind.BindingElement && parent.parent.kind === SyntaxKind.ObjectBindingPattern && (parent.propertyName ?? parent.name) === node;
160
+ if (property) properties.push(node);
161
+ if (parent.kind === SyntaxKind.ShorthandPropertyAssignment || !property && parent.propertyName !== node && (parent.name !== node || parent.kind === SyntaxKind.PropertyAccessExpression)) identifiers.push(node);
162
+ }
163
+ node.forEachChild((child) => visit(child, checked));
164
+ };
165
+ source.forEachChild((child) => visit(child, true));
166
+ return {
167
+ identifiers,
168
+ properties
169
+ };
170
+ }
171
+ #use(node, symbol) {
172
+ if (symbol === void 0) return;
173
+ const needed = this.#requirementOf(symbol);
174
+ const missing = Object.keys(needed).filter((name) => !this.#covered(name, needed[name], node));
175
+ if (missing.length > 0) {
176
+ this.#problems.guarding = true;
177
+ this.#problems.lines.add(tr("{location}: {name} needs {requirement}", {
178
+ location: this.#location(node),
179
+ name: node.text,
180
+ requirement: describe(needed, missing)
181
+ }));
182
+ }
183
+ }
184
+ #useEntry(name) {
185
+ const symbol = this.#checker.getSymbolAtLocation(name);
186
+ const needed = symbol === void 0 ? {} : this.#requirementOf(symbol);
187
+ const missing = Object.keys(needed).filter((kind) => !requirements[kind].covers(this.#minimum[kind], needed[kind]));
188
+ if (missing.length > 0) this.#problems.lines.add(tr("{location}: {name} is an entry of the swiplet and needs {requirement}; raise \"swiplet.minimumAPILevel\" or \"swiplet.minimumIOSVersion\" in package.json", {
189
+ location: this.#location(name),
190
+ name: name.text,
191
+ requirement: describe(needed, missing)
192
+ }));
193
+ }
194
+ #location(node) {
195
+ const source = sourceFileOf(node);
196
+ const { line, character } = source.getLineAndCharacterOfPosition(node.getStart(source));
197
+ return `${path.relative(this.#root, source.fileName)}:${line + 1}:${character + 1}`;
198
+ }
199
+ #parse(text, node) {
200
+ const { requirement, invalid, repeated } = parseAnnotation(text);
201
+ if (invalid !== void 0) this.#problems.lines.add(tr("{location}: @available has \"{entry}\"; it takes \"apiLevel <level>\" and \"iOS <version>\", separated by commas", {
202
+ location: this.#location(node),
203
+ entry: invalid
204
+ }));
205
+ else if (repeated !== void 0) this.#problems.lines.add(tr("{location}: @available names {kind} twice", {
206
+ location: this.#location(node),
207
+ kind: repeated
208
+ }));
209
+ return requirement;
210
+ }
211
+ #target(symbol) {
212
+ return symbol.flags & SymbolFlags.Alias ? this.#checker.getAliasedSymbol(symbol) : symbol;
213
+ }
214
+ #symbolOf(node) {
215
+ if (!this.#symbols.has(node)) {
216
+ const symbol = this.#checker.getSymbolAtLocation(node);
217
+ this.#symbols.set(node, symbol === void 0 ? void 0 : this.#target(symbol));
218
+ }
219
+ return this.#symbols.get(node);
220
+ }
221
+ #requirementOf(symbol) {
222
+ const target = this.#target(symbol);
223
+ if (!this.#requirements.has(target.id)) {
224
+ const requirement = {};
225
+ const declaration = (target.valueDeclaration ?? target.declarations[0])?.resolve(this.#project);
226
+ const external = declaration !== void 0 && !this.#files.has(sourceFileOf(declaration).fileName);
227
+ for (const tag of this.#checker.getJsDocTagsOfSymbol(target)) if (tag.name === "available") merge(requirement, external ? this.#parse(tag.text ?? "", declaration) : parseAnnotation(tag.text ?? "").requirement);
228
+ this.#requirements.set(target.id, requirement);
229
+ }
230
+ return this.#requirements.get(target.id);
231
+ }
232
+ #annotationOf(node) {
233
+ if (!this.#annotations.has(node)) {
234
+ const requirement = {};
235
+ const symbol = node.name?.kind === SyntaxKind.Identifier ? this.#checker.getSymbolAtLocation(node.name) : void 0;
236
+ if (symbol !== void 0) merge(requirement, this.#requirementOf(symbol));
237
+ for (const tag of annotationTags(node)) merge(requirement, parseAnnotation(tagText(tag)).requirement);
238
+ this.#annotations.set(node, requirement);
239
+ }
240
+ return this.#annotations.get(node);
241
+ }
242
+ #propertySymbol(name) {
243
+ const member = name.parent;
244
+ const container = member.parent;
245
+ if (!this.#types.has(container)) this.#types.set(container, member.kind === SyntaxKind.BindingElement ? this.#checker.getTypeAtLocation(container) : this.#checker.getContextualType(container));
246
+ const type = this.#types.get(container);
247
+ if (type === void 0) return;
248
+ for (const candidate of [type, ...type.getTypes?.() ?? []]) {
249
+ const property = this.#checker.getPropertyOfType(candidate, name.text);
250
+ if (property !== void 0) return property;
251
+ }
252
+ }
253
+ #covered(name, needed, reference) {
254
+ const { covers } = requirements[name];
255
+ if (covers(this.#minimum[name], needed)) return true;
256
+ let crossed = false;
257
+ for (let child = reference, parent = reference.parent; parent; child = parent, parent = parent.parent) {
258
+ const proven = this.#provenBy(parent, child, crossed)[name];
259
+ if (proven !== void 0 && covers(proven, needed)) return true;
260
+ crossed ||= functions.has(parent.kind);
261
+ }
262
+ return false;
263
+ }
264
+ #provenBy(parent, child, crossed) {
265
+ const proven = {};
266
+ switch (parent.kind) {
267
+ case SyntaxKind.IfStatement:
268
+ if (child === parent.thenStatement) merge(proven, this.#factsOf(parent.expression, true));
269
+ else if (child === parent.elseStatement) merge(proven, this.#factsOf(parent.expression, false));
270
+ break;
271
+ case SyntaxKind.ConditionalExpression:
272
+ if (child === parent.whenTrue) merge(proven, this.#factsOf(parent.condition, true));
273
+ else if (child === parent.whenFalse) merge(proven, this.#factsOf(parent.condition, false));
274
+ break;
275
+ case SyntaxKind.BinaryExpression: if (child === parent.right) {
276
+ const operator = parent.operatorToken.kind;
277
+ if (operator === SyntaxKind.AmpersandAmpersandToken) merge(proven, this.#factsOf(parent.left, true));
278
+ else if (operator === SyntaxKind.BarBarToken) merge(proven, this.#factsOf(parent.left, false));
279
+ }
280
+ }
281
+ for (const statement of parent.statements ?? []) {
282
+ if (statement === child) break;
283
+ if (statement.kind === SyntaxKind.IfStatement && statement.elseStatement === void 0 && exits(statement.thenStatement)) merge(proven, this.#factsOf(statement.expression, false));
284
+ }
285
+ if (functions.has(parent.kind) || classes.has(parent.kind) && (crossed || child.kind === SyntaxKind.PropertyDeclaration && !hasModifier(child, SyntaxKind.StaticKeyword)) || valueHolders.has(parent.kind) && crossed && child === parent.initializer) merge(proven, this.#annotationOf(parent));
286
+ return proven;
287
+ }
288
+ #factsOf(node, outcome) {
289
+ const cache = this.#facts[Number(outcome)];
290
+ if (!cache.has(node)) {
291
+ cache.set(node, {});
292
+ cache.set(node, this.#computeFacts(node, outcome));
293
+ }
294
+ return cache.get(node);
295
+ }
296
+ #computeFacts(node, outcome) {
297
+ switch (node.kind) {
298
+ case SyntaxKind.Identifier: {
299
+ const value = this.#constant(node);
300
+ return value === node ? {} : this.#factsOf(value, outcome);
301
+ }
302
+ case SyntaxKind.ParenthesizedExpression: return this.#factsOf(node.expression, outcome);
303
+ case SyntaxKind.PrefixUnaryExpression: return node.operator === SyntaxKind.ExclamationToken ? this.#factsOf(node.operand, !outcome) : {};
304
+ case SyntaxKind.CallExpression: return outcome && this.#isAvailable(node.expression) ? this.#requirementsOf(node.arguments[0]) : {};
305
+ case SyntaxKind.BinaryExpression: {
306
+ const operator = node.operatorToken.kind;
307
+ if (operator === SyntaxKind.AmpersandAmpersandToken) return outcome ? merge(merge({}, this.#factsOf(node.left, true)), this.#factsOf(node.right, true)) : {};
308
+ if (operator === SyntaxKind.BarBarToken) return outcome ? {} : merge(merge({}, this.#factsOf(node.left, false)), this.#factsOf(node.right, false));
309
+ return {};
310
+ }
311
+ }
312
+ return {};
313
+ }
314
+ #constant(node) {
315
+ for (const seen = /* @__PURE__ */ new Set(); node.kind === SyntaxKind.Identifier;) {
316
+ const declaration = this.#symbolOf(node)?.valueDeclaration?.resolve(this.#project);
317
+ if (declaration?.kind !== SyntaxKind.VariableDeclaration || declaration.initializer === void 0 || !(declaration.parent.flags & NodeFlags.Const) || seen.has(declaration)) break;
318
+ seen.add(declaration);
319
+ node = declaration.initializer;
320
+ }
321
+ return node;
322
+ }
323
+ #isAvailable(node) {
324
+ const name = node.kind === SyntaxKind.PropertyAccessExpression ? node.name : node;
325
+ return this.#available !== void 0 && name.kind === SyntaxKind.Identifier && this.#symbolOf(name)?.id === this.#available;
326
+ }
327
+ #requirementsOf(argument) {
328
+ const proven = {};
329
+ for (const property of argument?.kind === SyntaxKind.ObjectLiteralExpression ? argument.properties : []) {
330
+ const value = property.kind === SyntaxKind.PropertyAssignment && Object.hasOwn(requirements, property.name.text) ? this.#constant(property.initializer) : void 0;
331
+ if (value?.kind === SyntaxKind.NumericLiteral) {
332
+ const parsed = requirements[property.name.text].parse(String(Number(value.text)));
333
+ if (parsed !== void 0) proven[property.name.text] = parsed;
334
+ }
335
+ }
336
+ return proven;
337
+ }
338
+ #availableSymbol(apiDirectory) {
339
+ const declaration = this.#project.program.getSourceFile(fs.realpathSync(path.join(apiDirectory, "index.d.ts")))?.statements.find((statement) => statement.kind === SyntaxKind.FunctionDeclaration && statement.name?.text === "available");
340
+ return declaration === void 0 ? void 0 : this.#checker.getSymbolAtLocation(declaration.name)?.id;
341
+ }
342
+ };
343
+ function sourceFileOf(node) {
344
+ while (node.kind !== SyntaxKind.SourceFile) node = node.parent;
345
+ return node;
346
+ }
347
+ export { AvailabilityChecker };
348
+
349
+ //# sourceMappingURL=availability.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"availability.js","names":[],"sources":["../src/availability.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport { NodeFlags, SyntaxKind } from \"typescript/unstable/ast\";\nimport { isTypeNode } from \"typescript/unstable/ast/is\";\nimport { API, SymbolFlags } from \"typescript/unstable/sync\";\n\nimport { language, tr } from \"./i18n\";\nimport { parseVersion, versionAtLeast } from \"./version\";\n\nconst requirements = {\n apiLevel: {\n parse: (text) => (/^[1-9]\\d*$/.test(text) ? Number(text) : undefined),\n covers: (level, needed) => level >= needed,\n describe: (level) => tr(\"API level {level}\", { level }),\n },\n iOS: {\n parse: parseVersion,\n covers: versionAtLeast,\n describe: (version) => `iOS ${version.join(\".\")}`,\n },\n};\n\nconst lists = new Intl.ListFormat(language, { type: \"conjunction\" });\n\nconst merge = (into, from) => {\n for (const [name, needed] of Object.entries(from)) {\n if (\n into[name] === undefined ||\n !requirements[name].covers(into[name], needed)\n ) {\n into[name] = needed;\n }\n }\n return into;\n};\n\nconst describe = (needed, missing) =>\n lists.format(\n missing.map((name) => requirements[name].describe(needed[name])),\n );\n\nfunction parseAnnotation(text) {\n const requirement = {};\n for (const entry of text.split(\",\").map((part) => part.trim())) {\n const [kind, value, ...rest] = entry.split(/\\s+/);\n const parsed =\n rest.length === 0 && Object.hasOwn(requirements, kind)\n ? requirements[kind].parse(value ?? \"\")\n : undefined;\n if (parsed === undefined) {\n return { requirement, invalid: entry };\n }\n if (requirement[kind] !== undefined) {\n return { requirement, repeated: kind };\n }\n requirement[kind] = parsed;\n }\n return { requirement };\n}\n\nconst tagText = (tag) =>\n typeof tag.comment === \"string\"\n ? tag.comment\n : (tag.comment ?? []).map((part) => part.text).join(\"\");\n\nconst annotationTags = (node) =>\n (node.jsDoc ?? []).flatMap((comment) =>\n (comment.tags ?? []).filter((tag) => tag.tagName.text === \"available\"),\n );\n\nconst exits = (statement) =>\n statement.kind === SyntaxKind.ReturnStatement ||\n statement.kind === SyntaxKind.ThrowStatement ||\n statement.kind === SyntaxKind.BreakStatement ||\n statement.kind === SyntaxKind.ContinueStatement ||\n (statement.kind === SyntaxKind.Block &&\n statement.statements.length > 0 &&\n exits(statement.statements.at(-1)));\n\nconst hasModifier = (node, kind) =>\n node.modifiers?.some((modifier) => modifier.kind === kind) ?? false;\n\nconst functions = new Set([\n SyntaxKind.FunctionDeclaration,\n SyntaxKind.FunctionExpression,\n SyntaxKind.ArrowFunction,\n SyntaxKind.MethodDeclaration,\n SyntaxKind.GetAccessor,\n SyntaxKind.SetAccessor,\n SyntaxKind.Constructor,\n]);\n\nconst classes = new Set([\n SyntaxKind.ClassDeclaration,\n SyntaxKind.ClassExpression,\n]);\n\nconst valueHolders = new Set([\n SyntaxKind.VariableDeclaration,\n SyntaxKind.PropertyDeclaration,\n SyntaxKind.PropertyAssignment,\n]);\n\nconst objectMembers = new Set([\n SyntaxKind.PropertyAssignment,\n SyntaxKind.ShorthandPropertyAssignment,\n SyntaxKind.MethodDeclaration,\n SyntaxKind.GetAccessor,\n SyntaxKind.SetAccessor,\n]);\n\nconst inert = new Set([\n SyntaxKind.ImportDeclaration,\n SyntaxKind.ExportDeclaration,\n SyntaxKind.InterfaceDeclaration,\n SyntaxKind.TypeAliasDeclaration,\n SyntaxKind.JsxClosingElement,\n]);\n\nfunction sourceFilesOf(root, metafiles) {\n const files = new Set();\n for (const metafile of metafiles) {\n for (const input of Object.keys(metafile.inputs)) {\n const file = path.resolve(input);\n if (\n !/^[a-z][\\w-]+:/.test(input) &&\n /\\.[cm]?[jt]sx?$/.test(file) &&\n !path.relative(root, file).startsWith(\"..\") &&\n !file.split(path.sep).includes(\"node_modules\")\n ) {\n files.add(fs.realpathSync(file));\n }\n }\n }\n return [...files];\n}\n\nexport class AvailabilityChecker {\n #api;\n #open = new Set();\n\n check(project, metafiles) {\n const files = sourceFilesOf(project.root, metafiles);\n if (files.length === 0 && this.#open.size === 0) {\n return;\n }\n this.#api ??= new API({ cwd: project.root });\n // An open file keeps the content it was opened with, whatever fileChanges says\n // (typescript 7.0.2).\n if (this.#open.size > 0) {\n this.#api.updateSnapshot({ closeFiles: [...this.#open] });\n }\n const snapshot = this.#api.updateSnapshot({\n openFiles: files,\n fileChanges: { invalidateAll: true },\n });\n this.#open = new Set(files);\n if (files.length === 0) {\n return;\n }\n const problems = { lines: new Set(), guarding: false };\n const groups = Map.groupBy(files, (file) =>\n snapshot.getDefaultProjectForFile(file),\n );\n for (const [typescript, owned] of groups) {\n new Checker(typescript, project, files, problems).check(owned);\n }\n if (problems.lines.size > 0) {\n throw new Error(\n [\n ...problems.lines,\n ...(problems.guarding\n ? [\n tr(\n 'check these with available(), mark the code that uses them with @available, or raise \"swiplet.minimumAPILevel\" or \"swiplet.minimumIOSVersion\" in package.json',\n ),\n ]\n : []),\n ].join(\"\\n\"),\n );\n }\n }\n\n close() {\n this.#api?.close();\n }\n}\n\nclass Checker {\n #project;\n #checker;\n #root;\n #files;\n #problems;\n #minimum;\n #entries;\n #available;\n #symbols = new Map();\n #requirements = new Map();\n #annotations = new Map();\n #facts = [new Map(), new Map()];\n #types = new Map();\n\n constructor(typescript, project, files, problems) {\n this.#project = typescript;\n this.#checker = typescript.checker;\n this.#root = project.root;\n this.#files = new Set(files);\n this.#problems = problems;\n this.#minimum = {\n apiLevel: project.config.minimumAPILevel ?? project.apiLevel,\n iOS: parseVersion(\n project.config.minimumIOSVersion ?? project.minimumIOSVersion,\n ),\n };\n this.#entries = new Set(\n [project.app, project.extension]\n .filter(Boolean)\n .map((entry) => fs.realpathSync(entry)),\n );\n this.#available = this.#availableSymbol(project.apiDirectory);\n }\n\n check(files) {\n for (const file of files) {\n const source = this.#project.program.getSourceFile(file);\n const { identifiers, properties } = this.#collect(source);\n const symbols = this.#checker.getSymbolAtLocation(identifiers);\n for (const [index, node] of identifiers.entries()) {\n this.#use(\n node,\n node.parent.kind === SyntaxKind.ShorthandPropertyAssignment\n ? this.#checker.getShorthandAssignmentValueSymbol(node.parent)\n : symbols[index],\n );\n }\n for (const node of properties) {\n this.#use(node, this.#propertySymbol(node));\n }\n if (this.#entries.has(file)) {\n for (const statement of source.statements) {\n if (\n statement.name !== undefined &&\n hasModifier(statement, SyntaxKind.DefaultKeyword)\n ) {\n this.#useEntry(statement.name);\n }\n }\n }\n }\n }\n\n #collect(source) {\n const identifiers = [];\n const properties = [];\n const visit = (node, checked) => {\n for (const tag of annotationTags(node)) {\n this.#parse(tagText(tag), tag);\n }\n const extended =\n node.kind === SyntaxKind.ExpressionWithTypeArguments &&\n node.parent.token === SyntaxKind.ExtendsKeyword &&\n classes.has(node.parent.parent.kind);\n if (inert.has(node.kind) || (isTypeNode(node) && !extended)) {\n checked = false;\n }\n if (checked && node.kind === SyntaxKind.Identifier) {\n const { parent } = node;\n const property =\n parent.kind === SyntaxKind.JsxAttribute ||\n (objectMembers.has(parent.kind) &&\n parent.parent.kind === SyntaxKind.ObjectLiteralExpression &&\n parent.name === node) ||\n (parent.kind === SyntaxKind.BindingElement &&\n parent.parent.kind === SyntaxKind.ObjectBindingPattern &&\n (parent.propertyName ?? parent.name) === node);\n if (property) {\n properties.push(node);\n }\n if (\n parent.kind === SyntaxKind.ShorthandPropertyAssignment ||\n (!property &&\n parent.propertyName !== node &&\n (parent.name !== node ||\n parent.kind === SyntaxKind.PropertyAccessExpression))\n ) {\n identifiers.push(node);\n }\n }\n node.forEachChild((child) => visit(child, checked));\n };\n source.forEachChild((child) => visit(child, true));\n return { identifiers, properties };\n }\n\n #use(node, symbol) {\n if (symbol === undefined) {\n return;\n }\n const needed = this.#requirementOf(symbol);\n const missing = Object.keys(needed).filter(\n (name) => !this.#covered(name, needed[name], node),\n );\n if (missing.length > 0) {\n this.#problems.guarding = true;\n this.#problems.lines.add(\n tr(\"{location}: {name} needs {requirement}\", {\n location: this.#location(node),\n name: node.text,\n requirement: describe(needed, missing),\n }),\n );\n }\n }\n\n #useEntry(name) {\n const symbol = this.#checker.getSymbolAtLocation(name);\n const needed = symbol === undefined ? {} : this.#requirementOf(symbol);\n const missing = Object.keys(needed).filter(\n (kind) => !requirements[kind].covers(this.#minimum[kind], needed[kind]),\n );\n if (missing.length > 0) {\n this.#problems.lines.add(\n tr(\n '{location}: {name} is an entry of the swiplet and needs {requirement}; raise \"swiplet.minimumAPILevel\" or \"swiplet.minimumIOSVersion\" in package.json',\n {\n location: this.#location(name),\n name: name.text,\n requirement: describe(needed, missing),\n },\n ),\n );\n }\n }\n\n #location(node) {\n const source = sourceFileOf(node);\n const { line, character } = source.getLineAndCharacterOfPosition(\n node.getStart(source),\n );\n return `${path.relative(this.#root, source.fileName)}:${line + 1}:${character + 1}`;\n }\n\n #parse(text, node) {\n const { requirement, invalid, repeated } = parseAnnotation(text);\n if (invalid !== undefined) {\n this.#problems.lines.add(\n tr(\n '{location}: @available has \"{entry}\"; it takes \"apiLevel <level>\" and \"iOS <version>\", separated by commas',\n { location: this.#location(node), entry: invalid },\n ),\n );\n } else if (repeated !== undefined) {\n this.#problems.lines.add(\n tr(\"{location}: @available names {kind} twice\", {\n location: this.#location(node),\n kind: repeated,\n }),\n );\n }\n return requirement;\n }\n\n #target(symbol) {\n return symbol.flags & SymbolFlags.Alias\n ? this.#checker.getAliasedSymbol(symbol)\n : symbol;\n }\n\n #symbolOf(node) {\n if (!this.#symbols.has(node)) {\n const symbol = this.#checker.getSymbolAtLocation(node);\n this.#symbols.set(\n node,\n symbol === undefined ? undefined : this.#target(symbol),\n );\n }\n return this.#symbols.get(node);\n }\n\n #requirementOf(symbol) {\n const target = this.#target(symbol);\n if (!this.#requirements.has(target.id)) {\n const requirement = {};\n const declaration = (\n target.valueDeclaration ?? target.declarations[0]\n )?.resolve(this.#project);\n const external =\n declaration !== undefined &&\n !this.#files.has(sourceFileOf(declaration).fileName);\n for (const tag of this.#checker.getJsDocTagsOfSymbol(target)) {\n if (tag.name === \"available\") {\n merge(\n requirement,\n external\n ? this.#parse(tag.text ?? \"\", declaration)\n : parseAnnotation(tag.text ?? \"\").requirement,\n );\n }\n }\n this.#requirements.set(target.id, requirement);\n }\n return this.#requirements.get(target.id);\n }\n\n #annotationOf(node) {\n if (!this.#annotations.has(node)) {\n const requirement = {};\n const symbol =\n node.name?.kind === SyntaxKind.Identifier\n ? this.#checker.getSymbolAtLocation(node.name)\n : undefined;\n if (symbol !== undefined) {\n merge(requirement, this.#requirementOf(symbol));\n }\n for (const tag of annotationTags(node)) {\n merge(requirement, parseAnnotation(tagText(tag)).requirement);\n }\n this.#annotations.set(node, requirement);\n }\n return this.#annotations.get(node);\n }\n\n #propertySymbol(name) {\n const member = name.parent;\n const container = member.parent;\n if (!this.#types.has(container)) {\n this.#types.set(\n container,\n member.kind === SyntaxKind.BindingElement\n ? this.#checker.getTypeAtLocation(container)\n : this.#checker.getContextualType(container),\n );\n }\n const type = this.#types.get(container);\n if (type === undefined) {\n return undefined;\n }\n for (const candidate of [type, ...(type.getTypes?.() ?? [])]) {\n const property = this.#checker.getPropertyOfType(candidate, name.text);\n if (property !== undefined) {\n return property;\n }\n }\n return undefined;\n }\n\n #covered(name, needed, reference) {\n const { covers } = requirements[name];\n if (covers(this.#minimum[name], needed)) {\n return true;\n }\n let crossed = false;\n for (\n let child = reference, parent = reference.parent;\n parent;\n child = parent, parent = parent.parent\n ) {\n const proven = this.#provenBy(parent, child, crossed)[name];\n if (proven !== undefined && covers(proven, needed)) {\n return true;\n }\n crossed ||= functions.has(parent.kind);\n }\n return false;\n }\n\n #provenBy(parent, child, crossed) {\n const proven = {};\n switch (parent.kind) {\n case SyntaxKind.IfStatement:\n if (child === parent.thenStatement) {\n merge(proven, this.#factsOf(parent.expression, true));\n } else if (child === parent.elseStatement) {\n merge(proven, this.#factsOf(parent.expression, false));\n }\n break;\n case SyntaxKind.ConditionalExpression:\n if (child === parent.whenTrue) {\n merge(proven, this.#factsOf(parent.condition, true));\n } else if (child === parent.whenFalse) {\n merge(proven, this.#factsOf(parent.condition, false));\n }\n break;\n case SyntaxKind.BinaryExpression:\n if (child === parent.right) {\n const operator = parent.operatorToken.kind;\n if (operator === SyntaxKind.AmpersandAmpersandToken) {\n merge(proven, this.#factsOf(parent.left, true));\n } else if (operator === SyntaxKind.BarBarToken) {\n merge(proven, this.#factsOf(parent.left, false));\n }\n }\n break;\n }\n for (const statement of parent.statements ?? []) {\n if (statement === child) {\n break;\n }\n if (\n statement.kind === SyntaxKind.IfStatement &&\n statement.elseStatement === undefined &&\n exits(statement.thenStatement)\n ) {\n merge(proven, this.#factsOf(statement.expression, false));\n }\n }\n if (\n functions.has(parent.kind) ||\n (classes.has(parent.kind) &&\n (crossed ||\n (child.kind === SyntaxKind.PropertyDeclaration &&\n !hasModifier(child, SyntaxKind.StaticKeyword)))) ||\n (valueHolders.has(parent.kind) && crossed && child === parent.initializer)\n ) {\n merge(proven, this.#annotationOf(parent));\n }\n return proven;\n }\n\n #factsOf(node, outcome) {\n const cache = this.#facts[Number(outcome)];\n if (!cache.has(node)) {\n cache.set(node, {});\n cache.set(node, this.#computeFacts(node, outcome));\n }\n return cache.get(node);\n }\n\n #computeFacts(node, outcome) {\n switch (node.kind) {\n case SyntaxKind.Identifier: {\n const value = this.#constant(node);\n return value === node ? {} : this.#factsOf(value, outcome);\n }\n case SyntaxKind.ParenthesizedExpression:\n return this.#factsOf(node.expression, outcome);\n case SyntaxKind.PrefixUnaryExpression:\n return node.operator === SyntaxKind.ExclamationToken\n ? this.#factsOf(node.operand, !outcome)\n : {};\n case SyntaxKind.CallExpression:\n return outcome && this.#isAvailable(node.expression)\n ? this.#requirementsOf(node.arguments[0])\n : {};\n case SyntaxKind.BinaryExpression: {\n const operator = node.operatorToken.kind;\n if (operator === SyntaxKind.AmpersandAmpersandToken) {\n return outcome\n ? merge(\n merge({}, this.#factsOf(node.left, true)),\n this.#factsOf(node.right, true),\n )\n : {};\n }\n if (operator === SyntaxKind.BarBarToken) {\n return outcome\n ? {}\n : merge(\n merge({}, this.#factsOf(node.left, false)),\n this.#factsOf(node.right, false),\n );\n }\n return {};\n }\n }\n return {};\n }\n\n #constant(node) {\n for (const seen = new Set(); node.kind === SyntaxKind.Identifier;) {\n const declaration = this.#symbolOf(node)?.valueDeclaration?.resolve(\n this.#project,\n );\n if (\n declaration?.kind !== SyntaxKind.VariableDeclaration ||\n declaration.initializer === undefined ||\n !(declaration.parent.flags & NodeFlags.Const) ||\n seen.has(declaration)\n ) {\n break;\n }\n seen.add(declaration);\n node = declaration.initializer;\n }\n return node;\n }\n\n #isAvailable(node) {\n const name =\n node.kind === SyntaxKind.PropertyAccessExpression ? node.name : node;\n return (\n this.#available !== undefined &&\n name.kind === SyntaxKind.Identifier &&\n this.#symbolOf(name)?.id === this.#available\n );\n }\n\n #requirementsOf(argument) {\n const proven = {};\n for (const property of argument?.kind === SyntaxKind.ObjectLiteralExpression\n ? argument.properties\n : []) {\n const value =\n property.kind === SyntaxKind.PropertyAssignment &&\n Object.hasOwn(requirements, property.name.text)\n ? this.#constant(property.initializer)\n : undefined;\n if (value?.kind === SyntaxKind.NumericLiteral) {\n const parsed = requirements[property.name.text].parse(\n String(Number(value.text)),\n );\n if (parsed !== undefined) {\n proven[property.name.text] = parsed;\n }\n }\n }\n return proven;\n }\n\n #availableSymbol(apiDirectory) {\n const source = this.#project.program.getSourceFile(\n fs.realpathSync(path.join(apiDirectory, \"index.d.ts\")),\n );\n const declaration = source?.statements.find(\n (statement) =>\n statement.kind === SyntaxKind.FunctionDeclaration &&\n statement.name?.text === \"available\",\n );\n return declaration === undefined\n ? undefined\n : this.#checker.getSymbolAtLocation(declaration.name)?.id;\n }\n}\n\nfunction sourceFileOf(node) {\n while (node.kind !== SyntaxKind.SourceFile) {\n node = node.parent;\n }\n return node;\n}\n"],"mappings":";;;;;;;;AAUA,MAAM,eAAe;CACnB,UAAU;EACR,QAAQ,SAAU,aAAa,KAAK,IAAI,IAAI,OAAO,IAAI,IAAI,KAAA;EAC3D,SAAS,OAAO,WAAW,SAAS;EACpC,WAAW,UAAU,GAAG,qBAAqB,EAAE,MAAM,CAAC;CACxD;CACA,KAAK;EACH,OAAO;EACP,QAAQ;EACR,WAAW,YAAY,OAAO,QAAQ,KAAK,GAAG;CAChD;AACF;AAEA,MAAM,QAAQ,IAAI,KAAK,WAAW,UAAU,EAAE,MAAM,cAAc,CAAC;AAEnE,MAAM,SAAS,MAAM,SAAS;CAC5B,KAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,IAAI,GAC9C,IACE,KAAK,UAAU,KAAA,KACf,CAAC,aAAa,KAAK,CAAC,OAAO,KAAK,OAAO,MAAM,GAE7C,KAAK,QAAQ;CAGjB,OAAO;AACT;AAEA,MAAM,YAAY,QAAQ,YACxB,MAAM,OACJ,QAAQ,KAAK,SAAS,aAAa,KAAK,CAAC,SAAS,OAA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A,IACA,KAAK,SAAS,oBAAoB,YAAY,IAAI,CAAC,EAAE;CAC3D;AACF;AAEA,SAAS,aAAa,MAAM;CAC1B,OAAO,KAAK,SAAS,WAAW,YAC9B,OAAO,KAAK;CAEd,OAAO;AACT"}
@@ -0,0 +1,25 @@
1
+ export declare const Code: {
2
+ Canceled: number;
3
+ Unknown: number;
4
+ DeadlineExceeded: number;
5
+ NotFound: number;
6
+ Unimplemented: number;
7
+ Internal: number;
8
+ Unavailable: number;
9
+ Unauthenticated: number;
10
+ };
11
+ export declare class UsageError extends Error {}
12
+ export declare class RpcError extends Error {
13
+ code: number;
14
+ constructor(code: number, message?: string);
15
+ }
16
+ export declare function open({ url, token }: {
17
+ token: any;
18
+ url: any;
19
+ }): {
20
+ system: Record<string, any>;
21
+ logs: Record<string, any>;
22
+ swiplets: Record<string, any>;
23
+ repl: Record<string, any>;
24
+ };
25
+ export declare const unauthenticated: (error: any) => boolean;