@valbuild/shared 0.148.6 → 0.149.7

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 (70) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/client/dist/valbuild-shared-client.cjs.dev.js +2 -1
  3. package/client/dist/valbuild-shared-client.cjs.prod.js +2 -1
  4. package/client/dist/valbuild-shared-client.esm.js +2 -1
  5. package/dist/acquireTypes-50960f2c.esm.js +1801 -0
  6. package/dist/acquireTypes-de10005d.cjs.dev.js +1815 -0
  7. package/dist/acquireTypes-e9467a2a.cjs.prod.js +1815 -0
  8. package/dist/createForOfIteratorHelper-3db5d737.esm.js +121 -0
  9. package/dist/createForOfIteratorHelper-90e6a8b6.cjs.prod.js +129 -0
  10. package/dist/createForOfIteratorHelper-d86bb352.cjs.dev.js +129 -0
  11. package/dist/declarations/src/internal/ApiRoutes.d.ts +3 -3
  12. package/dist/declarations/src/internal/index.d.ts +1 -0
  13. package/dist/declarations/src/internal/selfCheck.d.ts +51 -0
  14. package/dist/declarations/src/publish/buildProposal.d.ts +106 -0
  15. package/dist/declarations/src/publish/builder.d.ts +22 -0
  16. package/dist/declarations/src/publish/callJson.d.ts +21 -0
  17. package/dist/declarations/src/publish/index.d.ts +23 -0
  18. package/dist/declarations/src/publish/jobClient.d.ts +96 -0
  19. package/dist/declarations/src/publish/loadedLayer.d.ts +50 -0
  20. package/dist/declarations/src/publish/proposalProject.d.ts +2 -0
  21. package/dist/declarations/src/publish/publishClient.d.ts +95 -0
  22. package/dist/declarations/src/publish/runStudioDeploy.d.ts +244 -0
  23. package/dist/declarations/src/publish/runStudioJob.d.ts +102 -0
  24. package/dist/declarations/src/publish/runStudioPublish.d.ts +80 -0
  25. package/dist/declarations/src/typecheck/acquireTypes.d.ts +109 -0
  26. package/dist/declarations/src/typecheck/adeptSources.d.ts +9 -0
  27. package/dist/declarations/src/typecheck/index.d.ts +20 -0
  28. package/dist/declarations/src/typecheck/linkedFileSystem.d.ts +53 -0
  29. package/dist/declarations/src/typecheck/lockedVersions.d.ts +14 -0
  30. package/dist/declarations/src/typecheck/pnpmLayout.d.ts +95 -0
  31. package/dist/declarations/src/typecheck/pnpmLockfile.d.ts +57 -0
  32. package/dist/declarations/src/typecheck/proposalTypecheck.d.ts +76 -0
  33. package/dist/declarations/src/typecheck/testing/index.d.ts +6 -0
  34. package/dist/declarations/src/typecheck/testing/nodeModulesSources.d.ts +5 -0
  35. package/dist/declarations/src/typecheck/typecheckProject.d.ts +89 -0
  36. package/dist/declarations/src/typecheck/typescriptCompiler.d.ts +52 -0
  37. package/dist/{getSitemapTree-40d76bf8.cjs.prod.js → getSitemapTree-0fa0569c.cjs.dev.js} +5 -131
  38. package/dist/{getSitemapTree-cd006a36.esm.js → getSitemapTree-5afbc3ac.esm.js} +2 -121
  39. package/dist/{getSitemapTree-a7f2cc6d.cjs.dev.js → getSitemapTree-667bcb3c.cjs.prod.js} +5 -131
  40. package/dist/proposalProject-28550146.cjs.prod.js +18 -0
  41. package/dist/proposalProject-a3d3ad76.esm.js +16 -0
  42. package/dist/proposalProject-cdc53711.cjs.dev.js +18 -0
  43. package/dist/protocol-1c13de0d.cjs.prod.js +433 -0
  44. package/dist/protocol-3b9ef786.esm.js +413 -0
  45. package/dist/protocol-d8a6efda.cjs.dev.js +433 -0
  46. package/dist/slicedToArray-62e428df.cjs.dev.js +309 -0
  47. package/dist/slicedToArray-6cd80315.esm.js +299 -0
  48. package/dist/slicedToArray-af50e684.cjs.prod.js +309 -0
  49. package/internal/dist/valbuild-shared-internal.cjs.dev.js +419 -888
  50. package/internal/dist/valbuild-shared-internal.cjs.prod.js +419 -888
  51. package/internal/dist/valbuild-shared-internal.esm.js +236 -707
  52. package/package.json +28 -5
  53. package/publish/dist/valbuild-shared-publish.cjs.d.ts +2 -0
  54. package/publish/dist/valbuild-shared-publish.cjs.dev.js +2466 -0
  55. package/publish/dist/valbuild-shared-publish.cjs.js +7 -0
  56. package/publish/dist/valbuild-shared-publish.cjs.prod.js +2466 -0
  57. package/publish/dist/valbuild-shared-publish.esm.js +2428 -0
  58. package/publish/package.json +4 -0
  59. package/typecheck/dist/valbuild-shared-typecheck.cjs.d.ts +2 -0
  60. package/typecheck/dist/valbuild-shared-typecheck.cjs.dev.js +1173 -0
  61. package/typecheck/dist/valbuild-shared-typecheck.cjs.js +7 -0
  62. package/typecheck/dist/valbuild-shared-typecheck.cjs.prod.js +1173 -0
  63. package/typecheck/dist/valbuild-shared-typecheck.esm.js +1152 -0
  64. package/typecheck/package.json +4 -0
  65. package/typecheck/testing/dist/valbuild-shared-typecheck-testing.cjs.d.ts +2 -0
  66. package/typecheck/testing/dist/valbuild-shared-typecheck-testing.cjs.dev.js +202 -0
  67. package/typecheck/testing/dist/valbuild-shared-typecheck-testing.cjs.js +7 -0
  68. package/typecheck/testing/dist/valbuild-shared-typecheck-testing.cjs.prod.js +202 -0
  69. package/typecheck/testing/dist/valbuild-shared-typecheck-testing.esm.js +177 -0
  70. package/typecheck/testing/package.json +4 -0
@@ -0,0 +1,1152 @@
1
+ import { _ as _inherits, a as _createClass, c as _wrapNativeSuper, e as _classCallCheck, f as _callSuper, b as _asyncToGenerator, d as _regenerator, h as _toConsumableArray, g as _slicedToArray } from '../../dist/slicedToArray-6cd80315.esm.js';
2
+ import { a as _createForOfIteratorHelper, _ as _typeof, b as _objectSpread2 } from '../../dist/createForOfIteratorHelper-3db5d737.esm.js';
3
+ import { parse } from 'yaml';
4
+ import { p as parsePnpmLockfile, c as computePnpmLayout, l as layoutOptionsOfWorkspace, a as packageDirOf, T as TypeAcquisition, b as parentOf, n as normalizePath, L as LinkedFileSystem, S as SourceError } from '../../dist/acquireTypes-50960f2c.esm.js';
5
+ export { e as LockfileError, S as SourceError, U as UnsupportedLayoutError, d as packageNameOf, t as typesPackageOf } from '../../dist/acquireTypes-50960f2c.esm.js';
6
+ import { p as proposalProject } from '../../dist/proposalProject-a3d3ad76.esm.js';
7
+
8
+ function _regeneratorValues(e) {
9
+ if (null != e) {
10
+ var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
11
+ r = 0;
12
+ if (t) return t.call(e);
13
+ if ("function" == typeof e.next) return e;
14
+ if (!isNaN(e.length)) return {
15
+ next: function () {
16
+ return e && r >= e.length && (e = void 0), {
17
+ value: e && e[r++],
18
+ done: !e
19
+ };
20
+ }
21
+ };
22
+ }
23
+ throw new TypeError(typeof e + " is not iterable");
24
+ }
25
+
26
+ /**
27
+ * Read straight from a pnpm lockfile's text, with no YAML parser: what
28
+ * `/val/adept` lists, and which TypeScript the typecheck loads.
29
+ * `pnpmLockfile.ts` is the full reader.
30
+ */
31
+
32
+ /** The registry packages a pnpm 9 lockfile's `packages:` section names. */
33
+ function lockedPackages(lockfile) {
34
+ var out = [];
35
+ var inPackages = false;
36
+ var current = null;
37
+ var _iterator = _createForOfIteratorHelper(lockfile.split("\n")),
38
+ _step;
39
+ try {
40
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
41
+ var line = _step.value;
42
+ if (/^\S/.test(line)) {
43
+ inPackages = line.startsWith("packages:");
44
+ current = null;
45
+ continue;
46
+ }
47
+ if (!inPackages) continue;
48
+ var head = /^ {2}['"]?(.+?)['"]?:\s*$/.exec(line);
49
+ if (head) {
50
+ var key = head[1];
51
+ var at = key.lastIndexOf("@");
52
+ var version = key.slice(at + 1);
53
+ current = null;
54
+ if (at > 0 && /^\d+\.\d+\.\d+/.test(version)) {
55
+ current = {
56
+ name: key.slice(0, at),
57
+ version: version
58
+ };
59
+ out.push(current);
60
+ }
61
+ continue;
62
+ }
63
+ var integrity = /integrity: (sha512-[^,}\s]+)/.exec(line);
64
+ if (current && integrity) current.integrity = integrity[1];
65
+ }
66
+ } catch (err) {
67
+ _iterator.e(err);
68
+ } finally {
69
+ _iterator.f();
70
+ }
71
+ return out;
72
+ }
73
+
74
+ /** The version the root importer's lockfile entry gives `typescript`. */
75
+ function typescriptVersion(lockfile) {
76
+ var _exec$, _exec;
77
+ var start = lockfile.indexOf("\n .:\n");
78
+ if (start < 0) return null;
79
+ var end = lockfile.indexOf("\n\n", start + 1);
80
+ var root = lockfile.slice(start, end < 0 ? undefined : end);
81
+ return (_exec$ = (_exec = /\n {6}typescript:\n {8}specifier: [^\n]+\n {8}version: (\d+\.\d+\.\d+[^\s(]*)/.exec(root)) === null || _exec === void 0 ? void 0 : _exec[1]) !== null && _exec$ !== void 0 ? _exec$ : null;
82
+ }
83
+
84
+ /** The TypeScript API, from whichever `typescript.js` was loaded. */
85
+
86
+ /** adept's `/compiler/<version>`: `lib/typescript.js` and every `lib/lib.*.d.ts`. */
87
+
88
+ /**
89
+ * The TypeScript a project gets when its own cannot run here.
90
+ *
91
+ * TypeScript 7 and later are a native compiler with no JavaScript one
92
+ * (`lib/typescript.js`), so they cannot run in a browser; a project with no
93
+ * `typescript` at all has none to choose. Both are checked with this 6.x,
94
+ * the one the Studio itself is built and tested with
95
+ * (`typescriptCompiler.test.ts` keeps the two the same). It is fetched from
96
+ * adept like any other, rather than shipped in the Studio's bundle, which is
97
+ * embedded in every Val server.
98
+ */
99
+ var BUNDLED_TYPESCRIPT = "6.0.3";
100
+
101
+ /** Which TypeScript checks a project, and why that one. */
102
+
103
+ function chooseCompiler(wanted) {
104
+ var _exec$, _exec;
105
+ if (wanted === null) {
106
+ return {
107
+ version: BUNDLED_TYPESCRIPT,
108
+ wanted: wanted,
109
+ reason: "no-typescript"
110
+ };
111
+ }
112
+ var major = Number((_exec$ = (_exec = /^(\d+)\./.exec(wanted)) === null || _exec === void 0 ? void 0 : _exec[1]) !== null && _exec$ !== void 0 ? _exec$ : NaN);
113
+ if (major >= 7) {
114
+ return {
115
+ version: BUNDLED_TYPESCRIPT,
116
+ wanted: wanted,
117
+ reason: "no-js-compiler"
118
+ };
119
+ }
120
+ return {
121
+ version: wanted,
122
+ wanted: wanted,
123
+ reason: "project"
124
+ };
125
+ }
126
+
127
+ /**
128
+ * Whether `value` is the TypeScript API. Checked by the functions this
129
+ * typechecker calls, which every version since 4 has.
130
+ */
131
+ function isTypeScript(value) {
132
+ if (_typeof(value) !== "object" || value === null) return false;
133
+ return ["createLanguageService", "createDocumentRegistry", "parseJsonConfigFileContent", "readConfigFile", "preProcessFile", "getPreEmitDiagnostics", "flattenDiagnosticMessageText", "getDefaultLibFileName", "sortAndDeduplicateDiagnostics"].every(function (name) {
134
+ return typeof Reflect.get(value, name) === "function";
135
+ });
136
+ }
137
+
138
+ /** A TypeScript that does not have what a typecheck needs. */
139
+ var CompilerError = /*#__PURE__*/function (_Error) {
140
+ function CompilerError() {
141
+ _classCallCheck(this, CompilerError);
142
+ return _callSuper(this, CompilerError, arguments);
143
+ }
144
+ _inherits(CompilerError, _Error);
145
+ return _createClass(CompilerError);
146
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
147
+
148
+ /**
149
+ * Evaluates `lib/typescript.js` and returns its API.
150
+ *
151
+ * It is a CommonJS module that also runs as a plain script, so it is given a
152
+ * `module` to assign to. `require` and `process` are given as `undefined`,
153
+ * as they are in a worker, so that it does not build a Node `ts.sys` when it
154
+ * runs under Node: everything it reads goes through the host this
155
+ * typechecker gives it.
156
+ */
157
+ function evaluateTypeScript(source) {
158
+ var module = {
159
+ exports: {}
160
+ };
161
+ // The compiler is text fetched at run time: evaluating it is the point.
162
+ var run = new Function("module", "exports", "require", "process", "__filename", "__dirname", source);
163
+ run(module, module.exports, undefined, undefined, undefined, undefined);
164
+ if (!isTypeScript(module.exports)) {
165
+ throw new CompilerError("lib/typescript.js did not give the TypeScript API this typecheck needs.");
166
+ }
167
+ return module.exports;
168
+ }
169
+
170
+ /**
171
+ * `ts.matchFiles`, which is how `tsc` expands a tsconfig's `include` and
172
+ * `exclude`. It is internal, but every `typescript.js` since 2.x has it on
173
+ * its API object, and using it is the only way to agree with `tsc` on hidden
174
+ * files, `node_modules` and implicit directory globs.
175
+ */
176
+
177
+ function isStringArray(value) {
178
+ return Array.isArray(value) && value.every(function (item) {
179
+ return typeof item === "string";
180
+ });
181
+ }
182
+ function matchFilesOf(ts) {
183
+ var internal = Reflect.get(ts, "matchFiles");
184
+ if (typeof internal !== "function") {
185
+ throw new CompilerError("TypeScript ".concat(ts.version, " has no matchFiles, so its tsconfig include patterns cannot be read here."));
186
+ }
187
+ return function () {
188
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
189
+ args[_key] = arguments[_key];
190
+ }
191
+ var files = Reflect.apply(internal, ts, args);
192
+ if (!isStringArray(files)) {
193
+ throw new CompilerError("TypeScript ".concat(ts.version, "'s matchFiles did not answer with file names."));
194
+ }
195
+ return files;
196
+ };
197
+ }
198
+
199
+ /**
200
+ * The type errors a project would have after `pnpm install`, computed in
201
+ * memory: the layout from the lockfile, the types its imports reach from
202
+ * adept, and the project's own TypeScript over both. See `docs` in
203
+ * valbuild/home's `adept.md`, step 4.
204
+ */
205
+
206
+ /** The project's root in the file system the checker builds. */
207
+ var PROJECT_ROOT = "/project";
208
+ var COMPILER_ROOT = "/typescript";
209
+
210
+ /**
211
+ * At most this many rounds of "build the programs, fetch what TypeScript
212
+ * looked for and did not find". Each round fetches only what the round
213
+ * before uncovered, so this is a guard against a loop, not a budget: the
214
+ * templates need one or two.
215
+ */
216
+ var MAX_RESOLUTION_ROUNDS = 8;
217
+
218
+ /** A tsconfig and the program it describes. */
219
+
220
+ function isRecord$1(value) {
221
+ return _typeof(value) === "object" && value !== null && !Array.isArray(value);
222
+ }
223
+ var relative = function relative(path) {
224
+ return path === PROJECT_ROOT ? "." : path.startsWith("".concat(PROJECT_ROOT, "/")) ? path.slice(PROJECT_ROOT.length + 1) : path;
225
+ };
226
+
227
+ /**
228
+ * Every `tsconfig.json` in the project, and every config their `references`
229
+ * name, in a stable order. A solution-style config (no files of its own,
230
+ * only references) is not a program; the configs it references are.
231
+ */
232
+ function readConfigs(ts, fs, projectFiles) {
233
+ var matchFiles = matchFilesOf(ts);
234
+ var host = {
235
+ useCaseSensitiveFileNames: true,
236
+ fileExists: function fileExists(path) {
237
+ return fs.fileExists(path);
238
+ },
239
+ readFile: function readFile(path) {
240
+ return fs.readFile(path);
241
+ },
242
+ readDirectory: function readDirectory(root, extensions, excludes, includes, depth) {
243
+ return matchFiles(root, extensions, excludes, includes, true, PROJECT_ROOT, depth, function (path) {
244
+ return {
245
+ files: fs.getFiles(path),
246
+ directories: fs.getDirectories(path)
247
+ };
248
+ }, function (path) {
249
+ return fs.realpath(path);
250
+ });
251
+ }
252
+ };
253
+ var queue = projectFiles.filter(function (path) {
254
+ return path.endsWith("/tsconfig.json") && !path.includes("/node_modules/");
255
+ }).sort();
256
+ var seen = new Set();
257
+ var configs = [];
258
+ for (var path = queue.shift(); path !== undefined; path = queue.shift()) {
259
+ var _parsed$projectRefere, _parsed$projectRefere2, _parsed$projectRefere3;
260
+ if (seen.has(path)) continue;
261
+ seen.add(path);
262
+ var read = ts.readConfigFile(path, function (file) {
263
+ return fs.readFile(file);
264
+ });
265
+ var dir = parentOf(path);
266
+ if (read.error) {
267
+ configs.push({
268
+ path: path,
269
+ options: {},
270
+ rootNames: [],
271
+ projectReferences: undefined,
272
+ errors: [read.error]
273
+ });
274
+ continue;
275
+ }
276
+ var parsed = ts.parseJsonConfigFileContent(read.config, host, dir, undefined, path);
277
+ var _iterator = _createForOfIteratorHelper((_parsed$projectRefere3 = parsed.projectReferences) !== null && _parsed$projectRefere3 !== void 0 ? _parsed$projectRefere3 : []),
278
+ _step;
279
+ try {
280
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
281
+ var reference = _step.value;
282
+ var target = normalizePath(reference.path);
283
+ queue.push(target.endsWith(".json") ? target : "".concat(target, "/tsconfig.json"));
284
+ }
285
+ } catch (err) {
286
+ _iterator.e(err);
287
+ } finally {
288
+ _iterator.f();
289
+ }
290
+ var solutionOnly = parsed.fileNames.length === 0 && ((_parsed$projectRefere = (_parsed$projectRefere2 = parsed.projectReferences) === null || _parsed$projectRefere2 === void 0 ? void 0 : _parsed$projectRefere2.length) !== null && _parsed$projectRefere !== void 0 ? _parsed$projectRefere : 0) > 0;
291
+ if (solutionOnly) continue;
292
+ configs.push({
293
+ path: path,
294
+ options: parsed.options,
295
+ rootNames: parsed.fileNames,
296
+ projectReferences: parsed.projectReferences,
297
+ errors: parsed.errors
298
+ });
299
+ }
300
+ return configs;
301
+ }
302
+
303
+ /** A language service over the in-memory files, for one tsconfig. */
304
+ function languageServiceFor(ts, fs, config, registry) {
305
+ var snapshots = new Map();
306
+ var host = {
307
+ getCompilationSettings: function getCompilationSettings() {
308
+ return config.options;
309
+ },
310
+ getScriptFileNames: function getScriptFileNames() {
311
+ return config.rootNames;
312
+ },
313
+ getProjectReferences: function getProjectReferences() {
314
+ return config.projectReferences;
315
+ },
316
+ // Nothing changes while a check runs: every file is at its first version.
317
+ getScriptVersion: function getScriptVersion() {
318
+ return "1";
319
+ },
320
+ getScriptSnapshot: function getScriptSnapshot(fileName) {
321
+ var snapshot = snapshots.get(fileName);
322
+ if (snapshot === undefined) {
323
+ var text = fs.readFile(fileName);
324
+ if (text === undefined) return undefined;
325
+ snapshot = ts.ScriptSnapshot.fromString(text);
326
+ snapshots.set(fileName, snapshot);
327
+ }
328
+ return snapshot;
329
+ },
330
+ getCurrentDirectory: function getCurrentDirectory() {
331
+ return PROJECT_ROOT;
332
+ },
333
+ getDefaultLibFileName: function getDefaultLibFileName(options) {
334
+ return "".concat(COMPILER_ROOT, "/lib/").concat(ts.getDefaultLibFileName(options));
335
+ },
336
+ fileExists: function fileExists(path) {
337
+ return fs.fileExists(path);
338
+ },
339
+ readFile: function readFile(path) {
340
+ return fs.readFile(path);
341
+ },
342
+ directoryExists: function directoryExists(path) {
343
+ return fs.directoryExists(path);
344
+ },
345
+ getDirectories: function getDirectories(path) {
346
+ return fs.getDirectories(path);
347
+ },
348
+ realpath: function realpath(path) {
349
+ return fs.realpath(path);
350
+ },
351
+ useCaseSensitiveFileNames: function useCaseSensitiveFileNames() {
352
+ return true;
353
+ }
354
+ };
355
+ return ts.createLanguageService(host, registry);
356
+ }
357
+
358
+ /**
359
+ * The diagnostics `tsc --noEmit -p <config>` prints: the config's own, then
360
+ * `getPreEmitDiagnostics` (options, global, syntactic, semantic, and
361
+ * declaration ones when the config emits declarations), sorted and
362
+ * deduplicated as `tsc` does.
363
+ */
364
+ function diagnosticsOf(ts, program, config) {
365
+ var all = ts.sortAndDeduplicateDiagnostics([].concat(_toConsumableArray(config.errors), _toConsumableArray(ts.getPreEmitDiagnostics(program))));
366
+ return all.filter(function (d) {
367
+ return d.category === ts.DiagnosticCategory.Error;
368
+ }).map(function (d) {
369
+ var position = d.file && d.start !== undefined ? d.file.getLineAndCharacterOfPosition(d.start) : null;
370
+ return {
371
+ file: d.file ? relative(d.file.fileName) : null,
372
+ line: position ? position.line + 1 : null,
373
+ column: position ? position.character + 1 : null,
374
+ code: d.code,
375
+ message: ts.flattenDiagnosticMessageText(d.messageText, "\n"),
376
+ tsconfig: relative(config.path)
377
+ };
378
+ });
379
+ }
380
+
381
+ /**
382
+ * Compilers already evaluated, by version: a worker that checks the base and
383
+ * then the upgrade evaluates 9 MB of `typescript.js` once.
384
+ */
385
+ var evaluated = new Map();
386
+ var elapsed = function elapsed(since) {
387
+ return Math.round(performance.now() - since);
388
+ };
389
+
390
+ /** Each workspace project's package name, which the hoist needs and the lockfile lacks. */
391
+ function workspaceNamesOf(lockfile, files) {
392
+ var names = {};
393
+ for (var _i = 0, _Object$keys = Object.keys(lockfile.importers); _i < _Object$keys.length; _i++) {
394
+ var id = _Object$keys[_i];
395
+ var text = files[id === "." ? "package.json" : "".concat(id, "/package.json")];
396
+ if (text === undefined) continue;
397
+ try {
398
+ var manifest = JSON.parse(text);
399
+ if (isRecord$1(manifest) && typeof manifest["name"] === "string") {
400
+ names[id] = manifest["name"];
401
+ }
402
+ } catch (_unused) {
403
+ // A package.json that is not JSON has no name to hoist; the
404
+ // typecheck itself reports it if anything reads it.
405
+ }
406
+ }
407
+ return names;
408
+ }
409
+ function layoutOf(input) {
410
+ var lockfile = parsePnpmLockfile(input.lockfile);
411
+ var workspace = input.workspace ? parse(input.workspace) : {};
412
+ var layout = computePnpmLayout(lockfile, _objectSpread2(_objectSpread2({}, layoutOptionsOfWorkspace(isRecord$1(workspace) ? workspace : {})), {}, {
413
+ root: PROJECT_ROOT,
414
+ workspaceNames: workspaceNamesOf(lockfile, input.files)
415
+ }));
416
+ return {
417
+ lockfile: lockfile,
418
+ layout: layout
419
+ };
420
+ }
421
+
422
+ /** Typechecks a project as it would be after `pnpm install`. */
423
+ function typecheckProject(_x) {
424
+ return _typecheckProject.apply(this, arguments);
425
+ }
426
+ function _typecheckProject() {
427
+ _typecheckProject = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(input) {
428
+ var _input$onProgress;
429
+ var started, progress, layoutStarted, _layoutOf, layout, layoutMs, compilerStarted, wanted, choice, compiler, source, ts, compilerMs, fs, _i2, _Object$entries, _Object$entries$_i, path, text, projectFiles, _i3, _Object$entries2, _Object$entries2$_i, _path, _text, absolute, typesStarted, configs, acquisition, reportFetching, _iterator3, _step3, _config$options$types, config, dir, _iterator5, _step5, name, _text2, _iterator6, _step6, types, jsxSource, registry, rounds, _loop, typesMs, checkStarted, errors, programs, _iterator4, _step4, _config2, service, program, found, sourceFiles, checkMs, stats, _t, _t2;
430
+ return _regenerator().w(function (_context2) {
431
+ while (1) switch (_context2.p = _context2.n) {
432
+ case 0:
433
+ started = performance.now();
434
+ progress = (_input$onProgress = input.onProgress) !== null && _input$onProgress !== void 0 ? _input$onProgress : function () {};
435
+ progress({
436
+ step: "layout"
437
+ });
438
+ layoutStarted = performance.now();
439
+ _layoutOf = layoutOf(input), layout = _layoutOf.layout;
440
+ layoutMs = elapsed(layoutStarted);
441
+ compilerStarted = performance.now();
442
+ wanted = typescriptVersion(input.lockfile);
443
+ choice = chooseCompiler(wanted);
444
+ progress({
445
+ step: "compiler",
446
+ version: choice.version
447
+ });
448
+ _context2.p = 1;
449
+ _context2.n = 2;
450
+ return input.sources.compiler(choice.version);
451
+ case 2:
452
+ compiler = _context2.v;
453
+ _context2.n = 6;
454
+ break;
455
+ case 3:
456
+ _context2.p = 3;
457
+ _t = _context2.v;
458
+ if (!(!(_t instanceof SourceError) || _t.code !== "no-js-compiler" || choice.reason !== "project")) {
459
+ _context2.n = 4;
460
+ break;
461
+ }
462
+ throw _t;
463
+ case 4:
464
+ choice = {
465
+ version: BUNDLED_TYPESCRIPT,
466
+ wanted: wanted,
467
+ reason: "no-js-compiler"
468
+ };
469
+ progress({
470
+ step: "compiler",
471
+ version: choice.version
472
+ });
473
+ _context2.n = 5;
474
+ return input.sources.compiler(choice.version);
475
+ case 5:
476
+ compiler = _context2.v;
477
+ case 6:
478
+ source = compiler.files["lib/typescript.js"];
479
+ if (!(source === undefined)) {
480
+ _context2.n = 7;
481
+ break;
482
+ }
483
+ throw new SourceError("adept's TypeScript ".concat(choice.version, " came without lib/typescript.js."), "unexpected-answer", false);
484
+ case 7:
485
+ ts = evaluated.get(choice.version);
486
+ if (ts === undefined) {
487
+ ts = evaluateTypeScript(source);
488
+ evaluated.set(choice.version, ts);
489
+ }
490
+ compilerMs = elapsed(compilerStarted);
491
+ fs = new LinkedFileSystem(layout.links);
492
+ for (_i2 = 0, _Object$entries = Object.entries(compiler.files); _i2 < _Object$entries.length; _i2++) {
493
+ _Object$entries$_i = _slicedToArray(_Object$entries[_i2], 2), path = _Object$entries$_i[0], text = _Object$entries$_i[1];
494
+ if (path.startsWith("lib/") && path.endsWith(".d.ts")) {
495
+ fs.writeFile("".concat(COMPILER_ROOT, "/").concat(path), text);
496
+ }
497
+ }
498
+ projectFiles = [];
499
+ _i3 = 0, _Object$entries2 = Object.entries(input.files);
500
+ case 8:
501
+ if (!(_i3 < _Object$entries2.length)) {
502
+ _context2.n = 11;
503
+ break;
504
+ }
505
+ _Object$entries2$_i = _slicedToArray(_Object$entries2[_i3], 2), _path = _Object$entries2$_i[0], _text = _Object$entries2$_i[1];
506
+ absolute = normalizePath("".concat(PROJECT_ROOT, "/").concat(_path));
507
+ if (!absolute.includes("/node_modules/")) {
508
+ _context2.n = 9;
509
+ break;
510
+ }
511
+ return _context2.a(3, 10);
512
+ case 9:
513
+ fs.writeFile(absolute, _text);
514
+ projectFiles.push(absolute);
515
+ case 10:
516
+ _i3++;
517
+ _context2.n = 8;
518
+ break;
519
+ case 11:
520
+ typesStarted = performance.now();
521
+ configs = readConfigs(ts, fs, projectFiles);
522
+ acquisition = new TypeAcquisition(ts, fs, layout, input.sources);
523
+ reportFetching = function reportFetching() {
524
+ return progress({
525
+ step: "types",
526
+ fetched: acquisition.stats.scanned + acquisition.stats.resolved
527
+ });
528
+ };
529
+ _iterator3 = _createForOfIteratorHelper(configs);
530
+ try {
531
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
532
+ config = _step3.value;
533
+ dir = parentOf(config.path);
534
+ _iterator5 = _createForOfIteratorHelper(config.rootNames);
535
+ try {
536
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
537
+ name = _step5.value;
538
+ _text2 = fs.readFile(name);
539
+ if (_text2 !== undefined) acquisition.wantImportsOf(name, _text2);
540
+ }
541
+ } catch (err) {
542
+ _iterator5.e(err);
543
+ } finally {
544
+ _iterator5.f();
545
+ }
546
+ _iterator6 = _createForOfIteratorHelper((_config$options$types = config.options.types) !== null && _config$options$types !== void 0 ? _config$options$types : []);
547
+ try {
548
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
549
+ types = _step6.value;
550
+ acquisition.wantSpecifier(dir, types);
551
+ }
552
+ } catch (err) {
553
+ _iterator6.e(err);
554
+ } finally {
555
+ _iterator6.f();
556
+ }
557
+ jsxSource = config.options.jsxImportSource;
558
+ if (jsxSource) acquisition.wantSpecifier(dir, "".concat(jsxSource, "/jsx-runtime"));
559
+ }
560
+ } catch (err) {
561
+ _iterator3.e(err);
562
+ } finally {
563
+ _iterator3.f();
564
+ }
565
+ reportFetching();
566
+ _context2.n = 12;
567
+ return acquisition.settle();
568
+ case 12:
569
+ /*
570
+ * The scan finds what the imports name. TypeScript also looks where no
571
+ * import says: `@types` for an untyped package, `typeRoots`, a package's
572
+ * `typesVersions` and peers. So the programs are built, every package
573
+ * TypeScript looked in and that is not fetched yet is fetched, and again,
574
+ * until a round looks nowhere new.
575
+ */
576
+ registry = ts.createDocumentRegistry(true, PROJECT_ROOT);
577
+ rounds = 0;
578
+ _loop = /*#__PURE__*/_regenerator().m(function _loop() {
579
+ var looked, _iterator7, _step7, _config, _iterator8, _step8, _dir;
580
+ return _regenerator().w(function (_context) {
581
+ while (1) switch (_context.n) {
582
+ case 0:
583
+ looked = new Set();
584
+ fs.onLookup = function (real) {
585
+ var dir = packageDirOf(real);
586
+ if (dir !== null && !acquisition.has(dir) && acquisition.packageAt(dir)) {
587
+ looked.add(dir);
588
+ }
589
+ };
590
+ _iterator7 = _createForOfIteratorHelper(configs);
591
+ try {
592
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
593
+ _config = _step7.value;
594
+ languageServiceFor(ts, fs, _config, registry).getProgram();
595
+ }
596
+ } catch (err) {
597
+ _iterator7.e(err);
598
+ } finally {
599
+ _iterator7.f();
600
+ }
601
+ fs.onLookup = null;
602
+ if (!(looked.size === 0)) {
603
+ _context.n = 1;
604
+ break;
605
+ }
606
+ return _context.a(2, 1);
607
+ case 1:
608
+ _iterator8 = _createForOfIteratorHelper(looked);
609
+ try {
610
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
611
+ _dir = _step8.value;
612
+ acquisition.wantPackage(_dir, "resolved");
613
+ }
614
+ } catch (err) {
615
+ _iterator8.e(err);
616
+ } finally {
617
+ _iterator8.f();
618
+ }
619
+ reportFetching();
620
+ _context.n = 2;
621
+ return acquisition.settle();
622
+ case 2:
623
+ return _context.a(2);
624
+ }
625
+ }, _loop);
626
+ });
627
+ case 13:
628
+ if (!(rounds < MAX_RESOLUTION_ROUNDS)) {
629
+ _context2.n = 16;
630
+ break;
631
+ }
632
+ return _context2.d(_regeneratorValues(_loop()), 14);
633
+ case 14:
634
+ if (!_context2.v) {
635
+ _context2.n = 15;
636
+ break;
637
+ }
638
+ return _context2.a(3, 16);
639
+ case 15:
640
+ rounds++;
641
+ _context2.n = 13;
642
+ break;
643
+ case 16:
644
+ typesMs = elapsed(typesStarted);
645
+ checkStarted = performance.now();
646
+ errors = [];
647
+ programs = [];
648
+ _iterator4 = _createForOfIteratorHelper(configs);
649
+ _context2.p = 17;
650
+ _iterator4.s();
651
+ case 18:
652
+ if ((_step4 = _iterator4.n()).done) {
653
+ _context2.n = 21;
654
+ break;
655
+ }
656
+ _config2 = _step4.value;
657
+ progress({
658
+ step: "check",
659
+ tsconfig: relative(_config2.path)
660
+ });
661
+ service = languageServiceFor(ts, fs, _config2, registry);
662
+ program = service.getProgram();
663
+ if (program) {
664
+ _context2.n = 19;
665
+ break;
666
+ }
667
+ return _context2.a(3, 20);
668
+ case 19:
669
+ found = diagnosticsOf(ts, program, _config2);
670
+ errors.push.apply(errors, _toConsumableArray(found));
671
+ sourceFiles = program.getSourceFiles();
672
+ programs.push(_objectSpread2({
673
+ tsconfig: relative(_config2.path),
674
+ files: sourceFiles.length,
675
+ errors: found.length
676
+ }, input.listFiles ? {
677
+ fileNames: sourceFiles.map(function (file) {
678
+ return relative(file.fileName);
679
+ })
680
+ } : {}));
681
+ service.dispose();
682
+ case 20:
683
+ _context2.n = 18;
684
+ break;
685
+ case 21:
686
+ _context2.n = 23;
687
+ break;
688
+ case 22:
689
+ _context2.p = 22;
690
+ _t2 = _context2.v;
691
+ _iterator4.e(_t2);
692
+ case 23:
693
+ _context2.p = 23;
694
+ _iterator4.f();
695
+ return _context2.f(23);
696
+ case 24:
697
+ checkMs = elapsed(checkStarted);
698
+ stats = acquisition.stats;
699
+ return _context2.a(2, {
700
+ errors: errors,
701
+ programs: programs,
702
+ typescript: choice,
703
+ bundles: _objectSpread2(_objectSpread2({}, stats), {}, {
704
+ count: stats.scanned + stats.resolved,
705
+ rounds: rounds
706
+ }),
707
+ missing: acquisition.missing,
708
+ timings: {
709
+ layoutMs: layoutMs,
710
+ compilerMs: compilerMs,
711
+ typesMs: typesMs,
712
+ checkMs: checkMs,
713
+ totalMs: elapsed(started)
714
+ }
715
+ });
716
+ }
717
+ }, _callee, null, [[17, 22, 23, 24], [1, 3]]);
718
+ }));
719
+ return _typecheckProject.apply(this, arguments);
720
+ }
721
+ var errorKey = function errorKey(error) {
722
+ var _error$file;
723
+ return "".concat((_error$file = error.file) !== null && _error$file !== void 0 ? _error$file : "", "\0").concat(error.code, "\0").concat(error.message);
724
+ };
725
+
726
+ /**
727
+ * The errors of `next` that `base` does not have (decision 20): an upgrade
728
+ * is judged only by the errors it adds. Errors are matched by file, code and
729
+ * message, not by position, so that an error which only moved is not new;
730
+ * and counted, so that a second copy of an error the base has once is.
731
+ */
732
+ function newErrors(base, next) {
733
+ var remaining = new Map();
734
+ var _iterator2 = _createForOfIteratorHelper(base),
735
+ _step2;
736
+ try {
737
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
738
+ var _remaining$get2;
739
+ var error = _step2.value;
740
+ var key = errorKey(error);
741
+ remaining.set(key, ((_remaining$get2 = remaining.get(key)) !== null && _remaining$get2 !== void 0 ? _remaining$get2 : 0) + 1);
742
+ }
743
+ } catch (err) {
744
+ _iterator2.e(err);
745
+ } finally {
746
+ _iterator2.f();
747
+ }
748
+ return next.filter(function (error) {
749
+ var _remaining$get;
750
+ var key = errorKey(error);
751
+ var left = (_remaining$get = remaining.get(key)) !== null && _remaining$get !== void 0 ? _remaining$get : 0;
752
+ if (left === 0) return true;
753
+ remaining.set(key, left - 1);
754
+ return false;
755
+ });
756
+ }
757
+
758
+ /**
759
+ * Type bundles and compilers from adept, by way of whoever proxies to it:
760
+ *
761
+ * - The Studio: `base` is `/api/val/publish-api/adept`, its own server, which
762
+ * proxies to content with the session (`STUDIO_ADEPT_BASE` in
763
+ * `@valbuild/ui`).
764
+ * - Home's upgrade page: `base` is content's `/v1/adept`, called with the
765
+ * person's own credential in `headers` (valbuild/home
766
+ * `docs/plans/upgrades-v2.md`, piece E).
767
+ * - adept itself (`http://127.0.0.1:4300/v1`), which is how the parity script
768
+ * runs.
769
+ *
770
+ * Both answers are immutable: a route that passes them on with their headers
771
+ * lets the browser answer repeats from its cache.
772
+ */
773
+ function isRecord(value) {
774
+ return _typeof(value) === "object" && value !== null && !Array.isArray(value);
775
+ }
776
+ function isTextFiles(value) {
777
+ return isRecord(value) && Object.values(value).every(function (v) {
778
+ return typeof v === "string";
779
+ });
780
+ }
781
+
782
+ /** An answer that was not a success: what it said, and its status. */
783
+ var AnswerError = /*#__PURE__*/function (_Error) {
784
+ function AnswerError(statusCode, message, body) {
785
+ var _this;
786
+ _classCallCheck(this, AnswerError);
787
+ _this = _callSuper(this, AnswerError, [message]);
788
+ _this.statusCode = statusCode;
789
+ _this.body = body;
790
+ return _this;
791
+ }
792
+ _inherits(AnswerError, _Error);
793
+ return _createClass(AnswerError);
794
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
795
+ /** Not now: a timeout, too many requests, a server or gateway error. */
796
+ var isTransient = function isTransient(status) {
797
+ return status >= 500 || status === 408 || status === 429;
798
+ };
799
+
800
+ /** adept's `{ error: { code, message, retryable } }`, or what else went wrong. */
801
+ function sourceErrorOf(error, what) {
802
+ if (error instanceof AnswerError) {
803
+ var _body = isRecord(error.body) ? error.body["error"] : undefined;
804
+ if (isRecord(_body) && typeof _body["message"] === "string") {
805
+ return new SourceError(_body["message"], typeof _body["code"] === "string" ? _body["code"] : String(error.statusCode), _body["retryable"] === true, error.statusCode);
806
+ }
807
+ return new SourceError("".concat(what, ": ").concat(error.message), String(error.statusCode),
808
+ // 501 is a deployment with no content service to ask: asking again
809
+ // gets the same answer.
810
+ isTransient(error.statusCode) && error.statusCode !== 501, error.statusCode);
811
+ }
812
+ return new SourceError("".concat(what, " could not be fetched: ").concat(error instanceof Error ? error.message : String(error)), "network", true);
813
+ }
814
+
815
+ /**
816
+ * One GET, as JSON. A body that is not JSON is a gateway, not adept or content
817
+ * answering, so it is `undefined` and the status carries the meaning.
818
+ */
819
+ function getJson(_x, _x2, _x3) {
820
+ return _getJson.apply(this, arguments);
821
+ }
822
+ function _getJson() {
823
+ _getJson = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(fetchImpl, url, init) {
824
+ var res, text, parsed, message;
825
+ return _regenerator().w(function (_context4) {
826
+ while (1) switch (_context4.n) {
827
+ case 0:
828
+ _context4.n = 1;
829
+ return fetchImpl(url, _objectSpread2(_objectSpread2({}, init), {}, {
830
+ method: "GET"
831
+ }));
832
+ case 1:
833
+ res = _context4.v;
834
+ _context4.n = 2;
835
+ return res.text();
836
+ case 2:
837
+ text = _context4.v;
838
+ try {
839
+ parsed = text === "" ? undefined : JSON.parse(text);
840
+ } catch (_unused) {
841
+ parsed = undefined;
842
+ }
843
+ if (res.ok) {
844
+ _context4.n = 3;
845
+ break;
846
+ }
847
+ message = isRecord(parsed) && typeof parsed["message"] === "string" ? parsed["message"] : "The answer was ".concat(res.status, ".");
848
+ throw new AnswerError(res.status, message, parsed);
849
+ case 3:
850
+ return _context4.a(2, parsed);
851
+ }
852
+ }, _callee4);
853
+ }));
854
+ return _getJson.apply(this, arguments);
855
+ }
856
+ function adeptSources(options) {
857
+ var _options$fetch, _options$credentials;
858
+ var fetchImpl = (_options$fetch = options.fetch) !== null && _options$fetch !== void 0 ? _options$fetch : function () {
859
+ return fetch.apply(void 0, arguments);
860
+ };
861
+ var init = _objectSpread2({
862
+ credentials: (_options$credentials = options.credentials) !== null && _options$credentials !== void 0 ? _options$credentials : "same-origin"
863
+ }, options.headers ? {
864
+ headers: options.headers
865
+ } : {});
866
+ var get = /*#__PURE__*/function () {
867
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(url, what) {
868
+ var _t;
869
+ return _regenerator().w(function (_context) {
870
+ while (1) switch (_context.p = _context.n) {
871
+ case 0:
872
+ _context.p = 0;
873
+ _context.n = 1;
874
+ return getJson(fetchImpl, url, init);
875
+ case 1:
876
+ return _context.a(2, _context.v);
877
+ case 2:
878
+ _context.p = 2;
879
+ _t = _context.v;
880
+ throw sourceErrorOf(_t, what);
881
+ case 3:
882
+ return _context.a(2);
883
+ }
884
+ }, _callee, null, [[0, 2]]);
885
+ }));
886
+ return function get(_x4, _x5) {
887
+ return _ref.apply(this, arguments);
888
+ };
889
+ }();
890
+ return {
891
+ types: function types(pkg) {
892
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
893
+ var what, query, answer, stubs;
894
+ return _regenerator().w(function (_context2) {
895
+ while (1) switch (_context2.n) {
896
+ case 0:
897
+ what = "The types of ".concat(pkg.name, "@").concat(pkg.version);
898
+ query = pkg.integrity ? "?integrity=".concat(encodeURIComponent(pkg.integrity)) : "";
899
+ _context2.n = 1;
900
+ return get("".concat(options.base, "/types/public/").concat(pkg.name, "@").concat(pkg.version).concat(query), what);
901
+ case 1:
902
+ answer = _context2.v;
903
+ if (!(!isRecord(answer) || !isTextFiles(answer["files"]))) {
904
+ _context2.n = 2;
905
+ break;
906
+ }
907
+ throw new SourceError("".concat(what, ": adept answered without a bundle."), "unexpected-answer", false);
908
+ case 2:
909
+ stubs = answer["stubs"];
910
+ return _context2.a(2, {
911
+ files: answer["files"],
912
+ stubs: Array.isArray(stubs) ? stubs.filter(function (stub) {
913
+ return typeof stub === "string";
914
+ }) : []
915
+ });
916
+ }
917
+ }, _callee2);
918
+ }))();
919
+ },
920
+ compiler: function compiler(version) {
921
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
922
+ var what, answer;
923
+ return _regenerator().w(function (_context3) {
924
+ while (1) switch (_context3.n) {
925
+ case 0:
926
+ what = "TypeScript ".concat(version);
927
+ _context3.n = 1;
928
+ return get("".concat(options.base, "/compiler/").concat(version), what);
929
+ case 1:
930
+ answer = _context3.v;
931
+ if (!(!isRecord(answer) || !isTextFiles(answer["files"]))) {
932
+ _context3.n = 2;
933
+ break;
934
+ }
935
+ throw new SourceError("".concat(what, ": adept answered without the compiler's files."), "unexpected-answer", false);
936
+ case 2:
937
+ return _context3.a(2, {
938
+ version: typeof answer["version"] === "string" ? answer["version"] : version,
939
+ files: answer["files"]
940
+ });
941
+ }
942
+ }, _callee3);
943
+ }))();
944
+ }
945
+ };
946
+ }
947
+
948
+ /*
949
+ * The typecheck of a proposal whose dependencies are its own (valbuild/home
950
+ * `docs/adept.md`, decision 20): the site's code with the site's lockfile --
951
+ * the base -- and the proposal's code with its lockfile, each checked as it
952
+ * would be after `pnpm install`, in the browser. Only the errors the base
953
+ * does not have count, and content is told them: a proposal with dependencies
954
+ * of its own is not published until a typecheck of what it stages has none.
955
+ */
956
+
957
+ /** At most this many of the new errors are sent; the count says how many. */
958
+ var MAX_REPORTED_ERRORS = 200;
959
+
960
+ /** What the typecheck is doing, as it says so. */
961
+
962
+ /** A new type error as content keeps it: a file always, a position always. */
963
+
964
+ /**
965
+ * The calls a proposal's typecheck makes: the Studio's through its origin,
966
+ * home's upgrade page to content directly. `T` is the report as content
967
+ * answers it.
968
+ */
969
+
970
+ var LOCKFILE = "pnpm-lock.yaml";
971
+ var WORKSPACE = "pnpm-workspace.yaml";
972
+
973
+ /** A type error as content keeps it: a file always, a position always. */
974
+ function reportedError(error) {
975
+ var _error$file, _error$line, _error$column;
976
+ return {
977
+ file: (_error$file = error.file) !== null && _error$file !== void 0 ? _error$file : "(".concat(error.tsconfig, ")"),
978
+ line: (_error$line = error.line) !== null && _error$line !== void 0 ? _error$line : 0,
979
+ column: (_error$column = error.column) !== null && _error$column !== void 0 ? _error$column : 0,
980
+ code: error.code,
981
+ message: error.message
982
+ };
983
+ }
984
+ function describe(progress) {
985
+ switch (progress.step) {
986
+ case "layout":
987
+ return "Laying out node_modules";
988
+ case "compiler":
989
+ return "Loading TypeScript ".concat(progress.version);
990
+ case "types":
991
+ return "Loading types (".concat(progress.fetched, ")");
992
+ case "check":
993
+ return "Checking ".concat(progress.tsconfig);
994
+ }
995
+ }
996
+ function runProposalTypecheck(_x) {
997
+ return _runProposalTypecheck.apply(this, arguments);
998
+ }
999
+
1000
+ /** New errors by file, each file's in order: how the dialog lists them. */
1001
+ function _runProposalTypecheck() {
1002
+ _runProposalTypecheck = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(deps) {
1003
+ var _deps$onStep, _yield$deps$siteSourc, _ref5, _recorded$LOCKFILE, _ref6, _recorded$WORKSPACE, _project$LOCKFILE, _project$WORKSPACE;
1004
+ var read, inputs, site, recorded, baseLockfile, _deps$onStep2, packageJson, baseWorkspace, withoutLockfile, project, checkOne, base, next, errors, typecheck, _t, _t2, _t3;
1005
+ return _regenerator().w(function (_context) {
1006
+ while (1) switch (_context.n) {
1007
+ case 0:
1008
+ (_deps$onStep = deps.onStep) === null || _deps$onStep === void 0 || _deps$onStep.call(deps, {
1009
+ step: "reading"
1010
+ });
1011
+ _context.n = 1;
1012
+ return deps.client.files(deps.name);
1013
+ case 1:
1014
+ read = _context.v;
1015
+ inputs = read.staged.inputs;
1016
+ if (!(inputs === null)) {
1017
+ _context.n = 2;
1018
+ break;
1019
+ }
1020
+ return _context.a(2, {
1021
+ status: "nothing-staged"
1022
+ });
1023
+ case 2:
1024
+ _context.n = 3;
1025
+ return deps.siteSource();
1026
+ case 3:
1027
+ _t2 = _yield$deps$siteSourc = _context.v;
1028
+ _t = _t2 !== null;
1029
+ if (!_t) {
1030
+ _context.n = 4;
1031
+ break;
1032
+ }
1033
+ _t = _yield$deps$siteSourc !== void 0;
1034
+ case 4:
1035
+ if (!_t) {
1036
+ _context.n = 5;
1037
+ break;
1038
+ }
1039
+ _t3 = _yield$deps$siteSourc;
1040
+ _context.n = 6;
1041
+ break;
1042
+ case 5:
1043
+ _t3 = {};
1044
+ case 6:
1045
+ site = _t3;
1046
+ _context.n = 7;
1047
+ return deps.siteDependencyFiles();
1048
+ case 7:
1049
+ recorded = _context.v;
1050
+ baseLockfile = (_ref5 = (_recorded$LOCKFILE = recorded[LOCKFILE]) !== null && _recorded$LOCKFILE !== void 0 ? _recorded$LOCKFILE : site[LOCKFILE]) !== null && _ref5 !== void 0 ? _ref5 : null;
1051
+ if (!(baseLockfile === null)) {
1052
+ _context.n = 10;
1053
+ break;
1054
+ }
1055
+ // A site made before proposals carried dependencies has no lockfile on
1056
+ // record: the base is checked against one computed from its package.json,
1057
+ // as `pnpm install` would make it.
1058
+ packageJson = site["package.json"];
1059
+ if (!(packageJson === undefined)) {
1060
+ _context.n = 8;
1061
+ break;
1062
+ }
1063
+ throw new Error("The site has no package.json, so there is nothing to check the proposal against.");
1064
+ case 8:
1065
+ (_deps$onStep2 = deps.onStep) === null || _deps$onStep2 === void 0 || _deps$onStep2.call(deps, {
1066
+ step: "lockfile"
1067
+ });
1068
+ _context.n = 9;
1069
+ return deps.computeLockfile(packageJson, deps.signal);
1070
+ case 9:
1071
+ baseLockfile = _context.v;
1072
+ case 10:
1073
+ baseWorkspace = (_ref6 = (_recorded$WORKSPACE = recorded[WORKSPACE]) !== null && _recorded$WORKSPACE !== void 0 ? _recorded$WORKSPACE : site[WORKSPACE]) !== null && _ref6 !== void 0 ? _ref6 : null;
1074
+ withoutLockfile = function withoutLockfile(files) {
1075
+ var out = _objectSpread2({}, files);
1076
+ delete out[LOCKFILE];
1077
+ return out;
1078
+ };
1079
+ project = proposalProject(site, read.files);
1080
+ checkOne = function checkOne(which, files, lockfile, workspace) {
1081
+ return deps.check({
1082
+ files: withoutLockfile(files),
1083
+ lockfile: lockfile,
1084
+ workspace: workspace
1085
+ }, {
1086
+ signal: deps.signal,
1087
+ onProgress: function onProgress(progress) {
1088
+ var _deps$onStep3;
1089
+ return (_deps$onStep3 = deps.onStep) === null || _deps$onStep3 === void 0 ? void 0 : _deps$onStep3.call(deps, {
1090
+ step: "checking",
1091
+ which: which,
1092
+ detail: describe(progress)
1093
+ });
1094
+ }
1095
+ });
1096
+ }; // One after the other: the worker that loaded the compiler for the first
1097
+ // reuses it for the second.
1098
+ _context.n = 11;
1099
+ return checkOne("site", site, baseLockfile, baseWorkspace);
1100
+ case 11:
1101
+ base = _context.v;
1102
+ _context.n = 12;
1103
+ return checkOne("proposal", project, (_project$LOCKFILE = project[LOCKFILE]) !== null && _project$LOCKFILE !== void 0 ? _project$LOCKFILE : baseLockfile, (_project$WORKSPACE = project[WORKSPACE]) !== null && _project$WORKSPACE !== void 0 ? _project$WORKSPACE : baseWorkspace);
1104
+ case 12:
1105
+ next = _context.v;
1106
+ errors = newErrors(base.errors, next.errors).map(reportedError);
1107
+ _context.n = 13;
1108
+ return deps.client.reportTypecheck(deps.name, _objectSpread2({
1109
+ inputs: inputs,
1110
+ newErrors: errors.slice(0, MAX_REPORTED_ERRORS)
1111
+ }, errors.length > MAX_REPORTED_ERRORS ? {
1112
+ count: errors.length
1113
+ } : {}));
1114
+ case 13:
1115
+ typecheck = _context.v;
1116
+ return _context.a(2, {
1117
+ status: "checked",
1118
+ inputs: inputs,
1119
+ errors: errors,
1120
+ typecheck: typecheck
1121
+ });
1122
+ }
1123
+ }, _callee);
1124
+ }));
1125
+ return _runProposalTypecheck.apply(this, arguments);
1126
+ }
1127
+ function errorsByFile(errors) {
1128
+ var files = new Map();
1129
+ var _iterator = _createForOfIteratorHelper(errors),
1130
+ _step;
1131
+ try {
1132
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
1133
+ var error = _step.value;
1134
+ var list = files.get(error.file);
1135
+ if (!list) files.set(error.file, list = []);
1136
+ list.push(error);
1137
+ }
1138
+ } catch (err) {
1139
+ _iterator.e(err);
1140
+ } finally {
1141
+ _iterator.f();
1142
+ }
1143
+ return _toConsumableArray(files).sort(function (_ref, _ref2) {
1144
+ var _ref3 = _slicedToArray(_ref, 1),
1145
+ a = _ref3[0];
1146
+ var _ref4 = _slicedToArray(_ref2, 1),
1147
+ b = _ref4[0];
1148
+ return a.localeCompare(b);
1149
+ });
1150
+ }
1151
+
1152
+ export { BUNDLED_TYPESCRIPT, CompilerError, MAX_REPORTED_ERRORS, PROJECT_ROOT, adeptSources, chooseCompiler, errorsByFile, layoutOf, lockedPackages, newErrors, reportedError, runProposalTypecheck, typecheckProject, typescriptVersion };