@stateward/core 1.2.2 → 1.3.1

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 (75) hide show
  1. package/dist/analyses.d.ts +37 -0
  2. package/dist/analyses.js +57 -0
  3. package/dist/backend/fingerprints.d.ts +3 -1
  4. package/dist/backend/fingerprints.js +198 -9
  5. package/dist/backend/program-record.d.ts +7 -0
  6. package/dist/backend/program-size.d.ts +32 -0
  7. package/dist/backend/program-size.js +166 -0
  8. package/dist/backend/typescript6.d.ts +62 -32
  9. package/dist/backend/typescript6.js +1615 -164
  10. package/dist/baseline.d.ts +1 -1
  11. package/dist/baseline.js +14 -10
  12. package/dist/cache.d.ts +92 -4
  13. package/dist/cache.js +257 -68
  14. package/dist/checker.d.ts +28 -3
  15. package/dist/checker.js +42 -8
  16. package/dist/class-id.d.ts +34 -0
  17. package/dist/class-id.js +93 -0
  18. package/dist/code-text.d.ts +8 -0
  19. package/dist/code-text.js +66 -0
  20. package/dist/config-file.js +7 -5
  21. package/dist/config.d.ts +10 -2
  22. package/dist/config.js +490 -48
  23. package/dist/define.d.ts +8 -2
  24. package/dist/disk-cache.d.ts +34 -2
  25. package/dist/disk-cache.js +82 -15
  26. package/dist/engine.d.ts +64 -3
  27. package/dist/engine.js +474 -59
  28. package/dist/fact-lines.d.ts +31 -0
  29. package/dist/fact-lines.js +197 -0
  30. package/dist/facts-versions.d.ts +27 -0
  31. package/dist/facts-versions.js +99 -0
  32. package/dist/fixes.js +4 -1
  33. package/dist/ignores.d.ts +11 -0
  34. package/dist/ignores.js +74 -27
  35. package/dist/implementation.d.ts +0 -6
  36. package/dist/implementation.js +0 -17
  37. package/dist/index.d.ts +9 -9
  38. package/dist/index.js +12 -7
  39. package/dist/internal.d.ts +13 -6
  40. package/dist/internal.js +7 -3
  41. package/dist/journal.d.ts +40 -0
  42. package/dist/journal.js +197 -0
  43. package/dist/lazy.d.ts +8 -1
  44. package/dist/lazy.js +27 -2
  45. package/dist/ledger.d.ts +2 -2
  46. package/dist/ledger.js +2 -2
  47. package/dist/memory-plan.d.ts +121 -0
  48. package/dist/memory-plan.js +174 -0
  49. package/dist/off-by-default.d.ts +13 -0
  50. package/dist/off-by-default.js +15 -0
  51. package/dist/options.d.ts +21 -5
  52. package/dist/options.js +22 -7
  53. package/dist/package-facts.d.ts +211 -17
  54. package/dist/package-facts.js +520 -38
  55. package/dist/plan.d.ts +1 -1
  56. package/dist/plan.js +7 -2
  57. package/dist/release.d.ts +12 -21
  58. package/dist/release.js +26 -38
  59. package/dist/renamed.d.ts +22 -3
  60. package/dist/renamed.js +50 -16
  61. package/dist/rollout.js +7 -4
  62. package/dist/severity.d.ts +1 -1
  63. package/dist/severity.js +17 -3
  64. package/dist/test-runner.d.ts +18 -0
  65. package/dist/test-runner.js +483 -0
  66. package/dist/testing.d.ts +3 -3
  67. package/dist/testing.js +5 -5
  68. package/dist/timing.d.ts +17 -7
  69. package/dist/timing.js +60 -38
  70. package/dist/types.d.ts +704 -20
  71. package/dist/unread.d.ts +90 -0
  72. package/dist/unread.js +405 -0
  73. package/dist/vocabulary.d.ts +1 -1
  74. package/dist/vocabulary.js +1 -1
  75. package/package.json +4 -2
@@ -2,7 +2,9 @@ import ts from "typescript";
2
2
  import type { ResultCache } from "../cache.js";
3
3
  import type { MarkedComment } from "./comments.js";
4
4
  import type { DependenciesOf, IsPackageEntry, PackageOf } from "./fingerprints.js";
5
- import type { Config, FixForm, FixVerdict, SymbolRef, TextEdit, TypeQueries } from "../types.js";
5
+ import type { ProgramSize } from "./program-size.js";
6
+ import type { FactKeyCheck } from "../package-facts.js";
7
+ import type { Config, FixForm, FixVerdict, PackageFactsConfig, TextEdit, TypeQueries } from "../types.js";
6
8
  /** The tsconfig could not be read or is invalid. */
7
9
  export declare class TsconfigError extends Error {
8
10
  /** The one change that fixes it, shown on a `= fix:` line. */
@@ -81,16 +83,37 @@ export type ProjectUnit = {
81
83
  * TypeScript 6's default, on). Read from the tsconfig: no program is built for it.
82
84
  */
83
85
  readonly strictNullChecks: boolean;
86
+ /** The test-runner configs, absolute, whose test files could not be read (`test-runner.ts`). */
87
+ readonly unreadTestConfigs: readonly string[];
84
88
  /**
85
89
  * Whether `module` resolves to declarations (types) from the project's folder, by its options:
86
90
  * `react` does when `@types/react` or a typed `react` is installed. No program is built for it.
87
91
  */
88
92
  typesResolve(module: string): boolean;
93
+ /**
94
+ * What each key of the config's `facts` resolves to in this program (`checkFactKeys`). A
95
+ * project whose program a run proved unchanged answers from its record when the facts are the
96
+ * same; otherwise the program is built.
97
+ */
98
+ factKeys(facts: PackageFactsConfig): readonly FactKeyCheck[];
99
+ /**
100
+ * Whether an own file imports `module` or one of its subpaths (`importedModules`): a rule that
101
+ * reads a library by its types has nothing to say when no file uses the library.
102
+ */
103
+ importsModule(module: string): boolean;
89
104
  /**
90
105
  * Binds the program (creating its type checker), which gives every node its parent: call it
91
106
  * before a rule or a plugin sees a node of `files`. Parsing does not set parents.
92
107
  */
93
108
  bind(): void;
109
+ /**
110
+ * Lets the type checker and `types` go, and starts new ones on the same parsed program: a
111
+ * program built on this one, which reuses every parsed and bound file. Fingerprints, reads and
112
+ * fact checks are kept. Nothing changes when no question was asked since the last start. For a
113
+ * check that bounds the checker's memory (`CheckerSlicing`): what the old checker computed can
114
+ * be collected.
115
+ */
116
+ renewChecker(): void;
94
117
  /**
95
118
  * The comments of one of `files` that hold `stateward-ignore`, with the file's text: syntax
96
119
  * only, so it needs no type checker.
@@ -133,11 +156,38 @@ export type UnresolvedImport = {
133
156
  readonly start: number;
134
157
  readonly end: number;
135
158
  };
159
+ /**
160
+ * The package modules one file imports, as TypeScript reads its imports (not its text): import
161
+ * and export declarations, `import x = require(…)`, `import(…)`, `require(…)`, `import("…")`
162
+ * types, and the JSX runtime a file with JSX uses by the project's `jsx` option. Relative and
163
+ * absolute paths are left out: they name the project's own files.
164
+ */
165
+ export declare function importedModules(sourceFile: ts.SourceFile, options: ts.CompilerOptions): string[];
166
+ /** Whether `imported` (as `importedModules` gives them) names `module` or one of its subpaths. */
167
+ export declare function importsModuleIn(imported: readonly string[], module: string): boolean;
136
168
  /** Whether a project with these options checks with `strictNullChecks` (TypeScript 6: on unless turned off). */
137
169
  export declare function checksNulls(options: ts.CompilerOptions): boolean;
170
+ /**
171
+ * A project found but not built yet (`Backend.pending`): what the file phase opens, one at a time
172
+ * when the run keeps no program.
173
+ */
174
+ export type PendingUnit = {
175
+ readonly tsconfig: string;
176
+ /** The program's size, found without building it (`programSize`): what a memory budget plans from. */
177
+ size(): ProgramSize;
178
+ /** The unit, built on the first call (or taken from the record of the last run, as `open` does). */
179
+ open(): ProjectUnit;
180
+ /**
181
+ * Lets go of this project's program, its checker and its parsed files: the next `open` (of
182
+ * this or a later run) builds it from nothing.
183
+ */
184
+ release(): void;
185
+ };
138
186
  export type Backend = {
139
187
  /** One unit per project that has own files, in references order (depth first). */
140
188
  open(overlays: ReadonlyMap<string, string>): readonly ProjectUnit[];
189
+ /** `open`, with nothing built yet. */
190
+ pending(overlays: ReadonlyMap<string, string>): readonly PendingUnit[];
141
191
  /**
142
192
  * Lets go of the programs (and the parsed files kept to build the next ones on): the next
143
193
  * `open` builds them from nothing. For a caller that asks nothing more of this run's units.
@@ -161,6 +211,8 @@ type CachedSource = {
161
211
  text: string;
162
212
  sourceFile: ts.SourceFile;
163
213
  };
214
+ /** The library files parsed and kept for later programs (tests). */
215
+ export declare function cachedLibraryFiles(): readonly string[];
164
216
  /**
165
217
  * Serves the unsaved `overlays`. A source file is parsed again only when its text changed, so a
166
218
  * program built with `oldProgram` can reuse what did not.
@@ -169,20 +221,21 @@ export declare function hostWithOverlays(options: ts.CompilerOptions, overlays:
169
221
  /** Serve a file that is not in `overlays` from `cache` without reading it from disk. */
170
222
  trustCache?: boolean,
171
223
  /** Parse the JSDoc of TypeScript files too: a rule that is on reads it (`RuleMeta.needsJsDoc`). */
172
- jsDoc?: boolean,
173
- /**
174
- * The files kept in the process-wide `libraryCache` rather than in `cache`. A package's own
175
- * JavaScript (`openPackageSource`) goes in `cache`, so it is freed with the package's program:
176
- * kept for the process, the packages a first run reads held over 500 MB on a large app.
177
- */
178
- shared?: (fileName: string) => boolean): ts.CompilerHost;
224
+ jsDoc?: boolean): ts.CompilerHost;
179
225
  /** A file's name in qualified ids: relative to the project, with forward slashes. */
180
226
  export declare function idFileNames(root: string): (fileName: string) => string;
181
227
  /** The type questions the flow scan asks in one file before it stops (`TypeQueries.typedFlowsIn`). */
182
228
  export declare const FLOW_BUDGET = 200000;
229
+ /**
230
+ * The platform's packages every project has: Node's types. TypeScript's own lib is the platform
231
+ * too; the config's `platform` adds more (`bun-types`, `@cloudflare/workers-types`).
232
+ */
233
+ export declare const PLATFORM_PACKAGES: readonly string[];
183
234
  export declare function createTypeQueries(program: ts.Program, own: ReadonlySet<string>,
184
235
  /** The project folder qualified ids are relative to. */
185
- root: string, packageOf: PackageOf, isEntry: IsPackageEntry, dependenciesOf: DependenciesOf): TypeQueries;
236
+ root: string, packageOf: PackageOf, isEntry: IsPackageEntry, dependenciesOf: DependenciesOf,
237
+ /** Packages the config adds to the platform (`Config.platform`). */
238
+ platform?: readonly string[]): TypeQueries;
186
239
  /**
187
240
  * Builds one TypeScript program per project of the config's tsconfig (see `collectConfigs`) and
188
241
  * serves the unsaved overlays. Later `open` calls reuse the previous programs.
@@ -195,28 +248,5 @@ export declare function createBackend({ config, cwd, cache, jsDoc, }: {
195
248
  /** Parse the JSDoc of TypeScript files (`hostWithOverlays`). */
196
249
  jsDoc?: boolean;
197
250
  }): Backend;
198
- /**
199
- * A package's own JavaScript, read as the project's own code is (the fourth source of library facts): a small program over the files one entry reaches by relative imports and requires, never
200
- * into other packages, with TypeScript's ES2022 library for the platform's globals. Plugins
201
- * summarize its files with the same code as the project's, through these `TypeQueries`.
202
- */
203
- export type PackageSource = {
204
- /** The package's files the program loaded, absolute, sorted: the entry and what it reaches. */
205
- readonly files: readonly string[];
206
- sourceFile(file: string): ts.SourceFile | undefined;
207
- /** Own files are the package's loaded files; qualified ids are relative to the package root. */
208
- readonly types: TypeQueries;
209
- /**
210
- * The declaration a module exports under `path` (`["remote"]`, `["Client", "get"]`): an ES
211
- * export, a CommonJS `exports.x = …` or `module.exports = { x }`, or `module.exports = fn` for
212
- * `["default"]` or its own name. Undefined when the module does not export it.
213
- */
214
- exported(file: string, path: readonly string[]): SymbolRef | undefined;
215
- };
216
- /**
217
- * Opens the package at `root` from `entry` (a JavaScript file in it). Its files are parsed with
218
- * the library files' cache, so a later package or project shares TypeScript's lib files.
219
- */
220
- export declare function openPackageSource(root: string, entry: string): PackageSource;
221
251
  export {};
222
252
  //# sourceMappingURL=typescript6.d.ts.map