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