@stillwind/host 0.0.0-stage → 0.1.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1243 @@
1
+ import { C as PluginPathCompletion, D as EditorRequest, E as EditorEdit, O as EditorResult, S as defaultPluginExport, T as EditorCompletion, _ as TypeFactsBackend, a as SemanticDependency, b as PluginHost, c as TypeScriptFactsStats, d as TypeScriptProject, f as resolveTypeFactsEnvironment, g as TypeFactSource, h as SemanticInputs, i as ModuleCompileOptions, l as TypeFactsEnvironment, m as CheckerSpan, n as PluginRuntime, o as TypeFact, p as AvailableFacts, r as ModuleAnalysis, s as TypeScriptFactsService, t as EditorSnapshot, u as TypeFactsInputs, v as TypeFactsError, w as EditorColor, x as TailwindSettings, y as UnverifiedRange } from "./index-CprPvXxv.js";
2
+ import { BindingDiagnostic, BindingOutput, BindingRejectedIdentifier, BindingReport, NativeAssetRecord, NativeCompilerOptions, NativeCssResource, NativeDesignSystemLoader, NativeDiagnosticBatch, NativeEditorQuery, NativeModuleSummary, NativeProjectSession, NativeSkippedCss, NativeTypeFact } from "@stillwind/native";
3
+ import { PreparedSource as PreparedSource$1, ProjectInput, ScriptSyntax, SourceDocument } from "@stillwind/projection";
4
+ import { EncodedSourceMap } from "@jridgewell/gen-mapping";
5
+ import { SourceMap } from "@jridgewell/remapping";
6
+ import { EncodedSourceMap as EncodedSourceMap$1, SourceMapInput } from "@jridgewell/trace-mapping";
7
+ import { AnalysisProjectConfig, BaseConfig, CapturedProjectConfig, PluginDirectoryEntry, PreviewOptions, StillwindPlugin } from "@stillwind/config";
8
+ import { ResolverFactory } from "oxc-resolver";
9
+ /** Source identities and parser metadata supplied by a host before preparation or compilation. */
10
+ type ModuleDescriptor = Pick<ProjectInput, "moduleId" | "checkerFileName" | "projectionFileName" | "syntax" | "framework"> & {
11
+ /** Original document identity and format. The compiler obtains its text through the host. */
12
+ document: Omit<SourceDocument, "code">;
13
+ };
14
+ /**
15
+ * Infers the source format and parser language from a module path.
16
+ *
17
+ * @param id - Source identity whose query or fragment is removed before case-insensitive extension
18
+ * matching.
19
+ * @returns Parser settings with unambiguous module kind and the inferred source format. TypeScript
20
+ * and JSX extensions choose their parser languages. Declaration files use `dts`, and SFC
21
+ * extensions select projected formats. Unrecognized extensions default to JavaScript script input.
22
+ */
23
+ export declare function fileSourceKind(id: string): {
24
+ /** Parser language and module kind inferred from the cleaned extension. */
25
+ syntax: ScriptSyntax;
26
+ /** Original document format used to select direct input or framework projection. */
27
+ format: SourceDocument["format"];
28
+ };
29
+ /**
30
+ * Removes a filesystem identity's query or fragment before a disk operation.
31
+ *
32
+ * @param id - Resolver identity, including any query or fragment suffix.
33
+ * @returns The identity up to its first `?` or `#`. IDs beginning with NUL or `virtual:` are
34
+ * returned unchanged.
35
+ */
36
+ export declare function cleanModuleId(id: string): string;
37
+ /**
38
+ * Source metadata, dependency resolution, reads, watches, and warnings supplied to
39
+ * module compilation. Hosts must preserve a stable correspondence between resolver and
40
+ * compiler module identities.
41
+ */
42
+ interface CompilerHost {
43
+ /** Requests checker import resolutions. A non-null host resolve result still takes precedence. */
44
+ typeFactsResolution?: boolean;
45
+ /**
46
+ * Loads source before or after preparation, including its original document and projection.
47
+ *
48
+ * @param id - Full resolver identity. The returned resolverId must equal this value.
49
+ * @returns Original input for preparation or a prepared source. Omission uses describe and read.
50
+ * @throws If loading or preparation fails.
51
+ */
52
+ load?(id: string): Promise<ProjectInput | PreparedSource$1>;
53
+ /**
54
+ * Determines whether a resolved dependency supplies source that Stillwind can analyze.
55
+ *
56
+ * @param id - Full resolved identity, including query suffixes.
57
+ * @returns Whether source traversal can continue. Omission checks for supported JS/TS and SFC extensions.
58
+ */
59
+ supports?(id: string): boolean;
60
+ /**
61
+ * Describes one resolved source before it is scanned or compiled.
62
+ *
63
+ * @param id - Full resolver identity of the source, including any query suffix.
64
+ * @returns Compiler and checker identities, parser metadata, and original document metadata.
65
+ */
66
+ describe(id: string): ModuleDescriptor;
67
+ /**
68
+ * Resolves a semantic dependency relative to its importing source.
69
+ *
70
+ * @param specifier - Authored module request text.
71
+ * @param importer - Full resolver identity of the importing source.
72
+ * @param options - Optional resolver policy. Compilation passes `skipSelf: true`.
73
+ * @returns A promise for a resolved identity and optional external status, or null when
74
+ * unresolved. Unresolved and external modules are skipped by semantic dependency traversal.
75
+ */
76
+ resolve(specifier: string, importer: string, options?: {
77
+ /** Requests resolution without calling the initiating plugin again. */
78
+ skipSelf: boolean;
79
+ }): Promise<{
80
+ /** Full host identity used to load the resolved source. */
81
+ id: string;
82
+ /** Truthy values mark a dependency that the host does not load as source. */
83
+ external?: boolean | string;
84
+ } | null>;
85
+ /**
86
+ * Reads one resolved dependency before source preparation.
87
+ *
88
+ * @param id - Full resolver identity, including any query selecting transformed source.
89
+ * @returns A promise for source text. Read failures reject the compilation.
90
+ */
91
+ read(id: string): Promise<string>;
92
+ /**
93
+ * Records the identity correspondence before a source is prepared.
94
+ *
95
+ * This callback can run before preparation fails. Callers must not treat it as proof of a
96
+ * successful compilation.
97
+ *
98
+ * @param moduleId - Stable identity used by the compiler and checker results.
99
+ * @param resolverId - Full host identity used to resolve and read this source.
100
+ */
101
+ onModule?(moduleId: string, resolverId: string): void;
102
+ /**
103
+ * Registers a resolved semantic dependency for change tracking.
104
+ *
105
+ * @param id - Full dependency identity selected by the host resolver.
106
+ */
107
+ watch(id: string): void;
108
+ /**
109
+ * Reports a lint warning or a rejected generated name through the host.
110
+ *
111
+ * @param message - Formatted warning text. No structured diagnostic location is implied.
112
+ */
113
+ warn(message: string): void;
114
+ }
115
+ /** Keeps prepared sources and checker inputs between analyses of one project. */
116
+ declare class CompilationProject {
117
+ #private;
118
+ /** Revision that a pending load must still match before it stores a source. */
119
+ get revision(): number;
120
+ /**
121
+ * Finds a source prepared since its last invalidation.
122
+ *
123
+ * @param id - Full resolver ID. Windows path spelling may differ in case or slashes.
124
+ * @returns The shared source, or undefined when it has not been prepared. Do not mutate it.
125
+ */
126
+ source(id: string): PreparedSource$1 | undefined;
127
+ /** Returns the prepared documents' original text so plugins can find candidates together. */
128
+ texts(): string[];
129
+ /**
130
+ * Finds the scan results for a prepared source.
131
+ *
132
+ * @param source - Source whose text has not changed since preparation.
133
+ * @returns Shared scan results, or undefined when the source is not retained. Do not mutate them.
134
+ */
135
+ summary(source: PreparedSource$1): NativeModuleSummary | undefined;
136
+ /**
137
+ * Stores a source and its successful scan results, copying the source before retaining it.
138
+ *
139
+ * @param source - Source passed to the scanner.
140
+ * @param summary - Successful scan results for that source. Do not mutate them after this call.
141
+ * @param revision - Revision captured before loading. Defaults to the current revision.
142
+ * Old revisions and sources already stored under the same ID have no effect.
143
+ */
144
+ retain(source: PreparedSource$1, summary: NativeModuleSummary, revision?: number): void;
145
+ /**
146
+ * Loads and scans targets together, then resolves their imports through the host.
147
+ * Analysis retries failed loads and scans so it can report each target's own error.
148
+ *
149
+ * @param ids - Full resolver IDs of the targets to prepare.
150
+ * @param host - Host used by later analysis of these targets.
151
+ * @param session - Initialized native session that will analyze the prepared sources.
152
+ * @returns Completion of preparation. Invalidation stops old work from storing results.
153
+ * @throws If host import resolution fails. Source loading and scan failures are left for analysis.
154
+ */
155
+ prepare(ids: readonly string[], host: CompilerHost, session: NativeProjectSession): Promise<void>;
156
+ /**
157
+ * Removes changed sources and clears all import links and cached resolution answers.
158
+ *
159
+ * @param ids - One changed resolver ID or several IDs. Omission removes every source.
160
+ * Advances the revision so pending loads cannot restore the removed sources.
161
+ */
162
+ invalidate(ids?: string | Iterable<string>): void;
163
+ /**
164
+ * Installs prepared checker inputs when their sources, import links, or supplied files change.
165
+ *
166
+ * @param backend - Backend used by later queries. Receives inputs if it supports setProjectSources.
167
+ * @param sources - Sources requested by the current analysis, with any known import resolutions.
168
+ * @param inputs - File overlays and ambient declarations for these sources.
169
+ * @returns Shared checker sources in the requested order. Do not mutate them.
170
+ * @throws If a requested source's checker environment or backend installation fails.
171
+ * Other sources with unavailable framework dependencies are left out of the installed inputs.
172
+ */
173
+ install(backend: TypeFactsBackend, sources: readonly TypeFactSource[], inputs?: SemanticInputs): TypeFactSource[];
174
+ /**
175
+ * @returns Declarations grouped by module ID. The arrays belong to the retained scans.
176
+ */
177
+ assets(): ReadonlyMap<string, readonly NativeAssetRecord[]>;
178
+ /**
179
+ * Resolves imports and caches the answers until checker inputs change.
180
+ *
181
+ * @param backend - Backend that resolves imports. Backends without setProjectSources query only sources.
182
+ * @param sources - Sources requested by the current analysis, with any known import resolutions.
183
+ * @param inputs - File overlays and ambient declarations for this analysis.
184
+ * @returns Shared maps from resolver ID to authored specifier and resolved ID. Do not mutate them.
185
+ * @throws If checker input preparation, installation, or import resolution fails.
186
+ */
187
+ resolve(backend: TypeFactsBackend, sources: readonly TypeFactSource[], inputs?: SemanticInputs): Promise<ReadonlyMap<string, ReadonlyMap<string, string>>>;
188
+ }
189
+ /**
190
+ * Analyzes an entry and its semantic dependencies without requiring stylesheet delivery IDs.
191
+ * Source failures return diagnostic batches. Unavailable semantic information records unverified
192
+ * ranges. Entry I/O and native transport failures reject.
193
+ * The caller owns the initialized session and the lazy checker service.
194
+ *
195
+ * @param session - Native project session with an initialized design system.
196
+ * @param factsService - Supplies a checker configured for the host's TypeScript environment,
197
+ * or undefined when semantic facts are unavailable.
198
+ * @param id - Full resolver identity of the entry, including query suffixes.
199
+ * @param host - Source loading, resolution, metadata, and dependency tracking operations.
200
+ * @param typeFactsInputs - Captured overlays and ambient declarations for this analysis.
201
+ * @param project - Optional sources prepared by earlier analyses of this project.
202
+ * The caller must invalidate changed sources before analysis starts.
203
+ * @returns Reports and sources for the semantic dependencies demanded by the entry.
204
+ * @throws If entry I/O fails, a host changes resolver identity, or native transport operations fail.
205
+ */
206
+ export declare function analyzeModule(session: NativeProjectSession, factsService: () => TypeFactsBackend | undefined, id: string, host: CompilerHost, typeFactsInputs?: TypeFactsInputs, project?: CompilationProject): Promise<ModuleAnalysis>;
207
+ /**
208
+ * Compiles an entry buffer and its demanded semantic dependencies into a project session.
209
+ * The host descriptor supplies the module identity and parser metadata for each source.
210
+ * Type facts are requested lazily for original-coordinate probes in JS/TS or SFC inputs.
211
+ *
212
+ * Collect mode retains compiler and checker reports, including known syntax and projection
213
+ * failures. The default throw mode rejects compiler diagnostics. Lint findings only produce warnings.
214
+ * Host I/O, checker process, and malformed native transport failures propagate in both modes.
215
+ * Failed compilation can still update the session, register watches, and send warnings.
216
+ *
217
+ * @param session - Native project session with an initialized design system.
218
+ * @param factsService - Supplies the type-facts service when the source graph needs semantic facts.
219
+ * @param code - Entry source before Stillwind transformation.
220
+ * @param id - Full resolver identity of the entry source, including its query suffix.
221
+ * @param host - Source metadata, resolution, reading, dependency tracking, and warning operations.
222
+ * @param options - Diagnostic behavior, captured checker inputs, and generated imports for the entry.
223
+ * @returns A promise for the entry output and composition metadata, or undefined when normal mode
224
+ * produces no entry code.
225
+ * @throws If compilation rejects diagnostics, source preparation fails, or host or checker operations fail.
226
+ */
227
+ export declare function compileModule(session: NativeProjectSession, factsService: () => TypeFactsBackend | undefined, code: string, id: string, host: CompilerHost, options?: ModuleCompileOptions): Promise<{
228
+ hasModuleCssImport: boolean;
229
+ compositionModules: string[];
230
+ compositionTopology: string;
231
+ diagnostics: BindingDiagnostic[];
232
+ reports: BindingReport[];
233
+ composition: Array<import("@stillwind/native").NativeStyleDependency>;
234
+ moduleId: string;
235
+ resources: Array<import("@stillwind/native").NativeModuleResource>;
236
+ css: string;
237
+ code: string | null;
238
+ mappings: Array<import("@stillwind/native").NativeTransformMapping>;
239
+ classes: Array<import("@stillwind/native").NativeGeneratedClass>;
240
+ symbols: Array<import("@stillwind/native").NativeGeneratedSymbol>;
241
+ rejectedNames: Array<BindingRejectedIdentifier>;
242
+ dynamicCandidates: Array<string>;
243
+ lintFindings: Array<import("@stillwind/native").BindingLintFinding>;
244
+ lintSettings: Record<string, "warn" | "deny" | "off">;
245
+ } | undefined>;
246
+ /**
247
+ * Reports naming fallbacks through the host warning channel without a source location.
248
+ *
249
+ * @param rejected - Generator rejections in request order.
250
+ * @param warn - Receives the family, input hash, and rejection reason for each fallback.
251
+ */
252
+ export declare function warnRejectedNames(rejected: readonly BindingRejectedIdentifier[], warn: (message: string) => void): void;
253
+ /**
254
+ * Derives a compiler module identity relative to a filesystem root.
255
+ *
256
+ * @param root - Filesystem directory from which the identity is made relative.
257
+ * @param id - Filesystem path to identify. Callers remove resolver queries before using this
258
+ * helper.
259
+ * @returns A relative path with forward slashes. Paths outside the root retain `..` segments. This
260
+ * function does not enforce containment.
261
+ */
262
+ export declare function compilerModuleId(root: string, id: string): string;
263
+ /**
264
+ * Infers parser metadata from a filesystem path and assigns compiler and checker identities.
265
+ *
266
+ * @param root - Project directory used for relative compiler identities.
267
+ * @param id - Absolute source path, optionally followed by a query or fragment suffix.
268
+ * @returns Metadata for the file after removing its query or fragment suffix.
269
+ */
270
+ export declare function fileModuleDescriptor(root: string, id: string): ModuleDescriptor;
271
+ /**
272
+ * Half-open UTF-16 range removed from the compiled buffer during host finalization. The current
273
+ * finalizer returns no removed ranges.
274
+ */
275
+ type FinalizedModuleEdit = {
276
+ /** Inclusive UTF-16 offset in the compiled buffer before finalization. */
277
+ from: number;
278
+ /** Exclusive UTF-16 offset in that same buffer. */
279
+ to: number;
280
+ };
281
+ /**
282
+ * Finalizes compiled JavaScript and describes the inserted prefix for source-map generation.
283
+ *
284
+ * @param code - Compiled JavaScript before host finalization.
285
+ * @param stylesheetSpecifier - Optional side-effect import specifier. A falsy value inserts no
286
+ * import.
287
+ * @returns Final code, the exact prefix inserted before it, and an empty list of removed ranges.
288
+ */
289
+ export declare function finalizeModuleWithMap(code: string, stylesheetSpecifier?: string): {
290
+ code: string;
291
+ prefix: string;
292
+ removed: FinalizedModuleEdit[];
293
+ };
294
+ /**
295
+ * Compilation failure carrying diagnostic batches for the same report format used by collect mode.
296
+ * Its message renders those reports with source locations.
297
+ */
298
+ export declare class CompilationFailure extends Error {
299
+ /**
300
+ * Report batches grouped by compiler module identity. The supplied array is retained without
301
+ * copying.
302
+ */
303
+ readonly batches: readonly NativeDiagnosticBatch[];
304
+ /**
305
+ * Builds an error message from the supplied reports and preserves an optional cause.
306
+ *
307
+ * @param batches - Reports to retain, in message order.
308
+ * @param cause - Optional preparation or checker failure that produced these reports.
309
+ */
310
+ constructor(batches: readonly NativeDiagnosticBatch[], cause?: unknown);
311
+ }
312
+ /**
313
+ * Prepared direct or projected source with optional semantic facts in original UTF-8 coordinates.
314
+ * The host attaches these facts before native compilation.
315
+ */
316
+ type PreparedSource = PreparedSource$1 & {
317
+ /** Semantic answers for original UTF-8 probe ranges. Omission supplies no additional facts. */
318
+ typeFacts?: TypeFact[];
319
+ };
320
+ /**
321
+ * Traces framework output through a Stillwind transform when embedded source text identifies the
322
+ * transformed input.
323
+ *
324
+ * @param generated - Framework output map.
325
+ * @param original - Map or map chain from the Stillwind-transformed input back to original sources.
326
+ * @param transformedSource - Exact text to match against the generated map's `sourcesContent`.
327
+ * @returns A composed map. Only matching immediate sources are replaced. Other sources retain their
328
+ * mappings.
329
+ * @throws If a supplied source map cannot be decoded or composed.
330
+ */
331
+ export declare function composeFrameworkSourceMap(generated: SourceMapInput, original: SourceMapInput | readonly SourceMapInput[], transformedSource: string): SourceMap;
332
+ /**
333
+ * Traces a CSS pipeline map through the original map of its carrier resource.
334
+ *
335
+ * @param generated - Pipeline output map, or a map chain accepted by the composition library.
336
+ * @param original - Map or chain from the CSS carrier back to authored sources.
337
+ * @param resource - Absolute carrier path with forward slashes. File URLs are decoded, and relative
338
+ * source paths are resolved against the process working directory before comparison.
339
+ * @returns A composed map that replaces only immediate sources resolving to the carrier path.
340
+ * @throws If a supplied source map cannot be decoded or composed.
341
+ */
342
+ export declare function composeCarrierSourceMap(generated: SourceMapInput | SourceMapInput[], original: SourceMapInput | readonly SourceMapInput[], resource: string): SourceMap;
343
+ /**
344
+ * Map or ordered map chain from a module's input back to its original sources. Null and undefined
345
+ * mean that no upstream map is available. Each map may be serialized or supplied as an object.
346
+ */
347
+ type UpstreamSourceMap = SourceMapInput | readonly SourceMapInput[] | undefined | null;
348
+ /**
349
+ * Composes the native output map with the upstream loader map or ordered map chain
350
+ * describing its input. Without upstream, returns the generated object unchanged.
351
+ * Invalid maps or incompatible chains may throw from the mapping library.
352
+ *
353
+ * @param generated - Map from compiled JavaScript back to the input received by Stillwind.
354
+ * @param upstream - Optional map or ordered map chain from that input back to original sources.
355
+ * @returns The generated map unchanged when no upstream map is supplied, otherwise a composed map.
356
+ * @throws If map decoding fails or a supplied map chain is incompatible.
357
+ */
358
+ export declare function composeModuleSourceMap(generated: EncodedSourceMap, upstream: UpstreamSourceMap): EncodedSourceMap | SourceMap;
359
+ /**
360
+ * One compiler replacement before host finalization inserts a prefix or removes text.
361
+ * All offsets are absolute UTF-16 code units in the original and compiled buffers.
362
+ * Replacement gaps without expression intervals map to `originalStart`.
363
+ */
364
+ interface CompilerMapping {
365
+ /** Inclusive original offset. Equals end for insertion. */
366
+ originalStart: number;
367
+ /** Exclusive original offset, at or after start. */
368
+ originalEnd: number;
369
+ /** Inclusive offset in the complete compiled buffer. */
370
+ generatedStart: number;
371
+ /** Exclusive compiled offset. Equals start for deletion. */
372
+ generatedEnd: number;
373
+ /**
374
+ * Nonempty, nonoverlapping intervals contained in this replacement, sorted by
375
+ * generated start. Source order may differ. Missing/empty means anchor-only mapping.
376
+ */
377
+ expressions?: {
378
+ /** Inclusive original offset. The anchor for a nonexact interval. */
379
+ originalStart: number;
380
+ /** Exclusive original offset of the expression or encoded character. */
381
+ originalEnd: number;
382
+ /** Inclusive compiled offset, before host edits. */
383
+ generatedStart: number;
384
+ /** Exclusive compiled offset, strictly greater than start. */
385
+ generatedEnd: number;
386
+ /** True requires identical text/equal lengths. False anchors all units at original start. */
387
+ exact: boolean;
388
+ }[];
389
+ }
390
+ /**
391
+ * Builds a JavaScript source map from compiler replacements and host finalization edits.
392
+ *
393
+ * Unchanged text maps character by character. Replacement text maps to its original start unless an
394
+ * expression interval provides a more precise correspondence. All offsets use UTF-16 code units.
395
+ *
396
+ * @param source - Original source whose text is embedded in the map.
397
+ * @param compiled - Compiler output before the host inserts a prefix or removes intervals.
398
+ * @param id - Source identity used as the map's file and sole source name.
399
+ * @param mappings - Nonoverlapping compiler replacements in generated-start order, with valid
400
+ * original and generated ranges.
401
+ * @param removed - Nonoverlapping ranges removed from `compiled`, in ascending order.
402
+ * @param prefix - Exact text inserted before the retained compiler output. It advances generated
403
+ * positions without receiving original mappings.
404
+ * @returns An encoded version 3 map for the finalized output with original source content.
405
+ */
406
+ export declare function moduleSourceMap(source: string, compiled: string, id: string, mappings: readonly CompilerMapping[], removed: readonly {
407
+ /** Inclusive UTF-16 offset removed from compiled. */
408
+ from: number;
409
+ /** Exclusive UTF-16 offset in the same compiled buffer. */
410
+ to: number;
411
+ }[], prefix: string): EncodedSourceMap;
412
+ /**
413
+ * Adds notices before a CSS body without changing the body.
414
+ *
415
+ * @param output - CSS body and the notices that it requires, in the form that
416
+ * {@link cssBannerPrefix} accepts.
417
+ * @returns The published stylesheet text, or an empty string when the body is blank.
418
+ */
419
+ export declare function finalizeCss(output: {
420
+ css: string;
421
+ banners?: readonly string[];
422
+ }): string;
423
+ /**
424
+ * Producer map used to trace native CSS locations from a transformed script or component back to
425
+ * its authored source.
426
+ */
427
+ interface CssUpstreamMap {
428
+ /**
429
+ * Producer filesystem identity used as the base for relative map sources. Ordinary query and
430
+ * fragment suffixes may follow its path.
431
+ */
432
+ id: string;
433
+ /** Exact source name in the native CSS map to which this producer map applies. */
434
+ sourceMapSource: string;
435
+ /** JSON text for an encoded version 3 map from producer input to authored sources. */
436
+ map: string;
437
+ }
438
+ /**
439
+ * Native locations linking generated CSS intervals to authored text. All interval offsets count
440
+ * UTF-8 bytes before resource placeholders are replaced.
441
+ */
442
+ interface CssLocations {
443
+ /** Source table indexed by each entry's `source` field. */
444
+ sources: {
445
+ /** Source identity recorded in the emitted version 3 map. */
446
+ sourceMapSource: string;
447
+ /**
448
+ * Authored source text used to derive original lines, UTF-16 columns, and optional
449
+ * `sourcesContent`.
450
+ */
451
+ content: string;
452
+ }[];
453
+ /**
454
+ * Nonoverlapping generated CSS intervals. Rendering sorts them by generated start. Callers must
455
+ * supply valid source indexes and byte boundaries.
456
+ */
457
+ entries: {
458
+ /** Zero-based index into `sources` for the authored interval. */
459
+ source: number;
460
+ /** Inclusive UTF-8 byte offset in generated CSS before resource replacement. */
461
+ generatedStart: number;
462
+ /** Exclusive UTF-8 byte offset in that CSS, at or after `generatedStart`. */
463
+ generatedEnd: number;
464
+ /** Inclusive UTF-8 byte offset in the selected source's content. */
465
+ originalStart: number;
466
+ /** Exclusive UTF-8 byte offset in that content, at or after `originalStart`. */
467
+ originalEnd: number;
468
+ /**
469
+ * True maps matching text byte for byte from `originalStart`. False maps the generated interval
470
+ * to its original start.
471
+ */
472
+ exact: boolean;
473
+ }[];
474
+ }
475
+ /** CSS and native source locations before resource URLs and upstream maps are composed. */
476
+ interface CssSourceMapInput {
477
+ /** Preserved notices selected for this CSS body. */
478
+ banners?: readonly string[];
479
+ /** Stylesheet text containing any unresolved resource placeholder tokens. */
480
+ css: string;
481
+ /** Native source locations whose generated offsets count UTF-8 bytes in `css`. */
482
+ sourceMap: CssLocations;
483
+ }
484
+ /**
485
+ * Rewrites resource placeholders while retaining native UTF-8 source locations.
486
+ *
487
+ * @param output - CSS and native source locations before resource replacement. Source indexes and
488
+ * byte boundaries must be valid for the supplied CSS and authored text.
489
+ * @param replacements - Resource placeholders mapped to escaped URL text.
490
+ * @param upstream - Optional maps from producer input back to its original source, in composition order.
491
+ * @param includeSourcesContent - Whether the inline map retains source text. Defaults to true.
492
+ * @returns Resolved CSS with an inline version 3 map, or an empty string when the input CSS is empty.
493
+ * @throws If an upstream map cannot be decoded, its source URLs are invalid, or composition fails.
494
+ */
495
+ export declare function cssWithSourceMap(output: CssSourceMapInput, replacements: ReadonlyMap<string, string>, upstream?: CssUpstreamMap | readonly CssUpstreamMap[], includeSourcesContent?: boolean): string;
496
+ /** Stylesheet text and its decoded inline source map, ready for a bundler's CSS pipeline. */
497
+ interface DecodedCssSourceMap {
498
+ /** CSS with the recognized trailing inline source-map comment removed. */
499
+ code: string;
500
+ /**
501
+ * Decoded version 3 map with mutable arrays and string source identities, or null when the CSS
502
+ * has no recognized trailing map.
503
+ */
504
+ map: (EncodedSourceMap$1 & {
505
+ /** Source identities indexed by the decoded map's segments. */
506
+ sources: string[];
507
+ }) | null;
508
+ }
509
+ /**
510
+ * Decodes the trailing inline map emitted by `cssWithSourceMap` or a compatible CSS carrier.
511
+ *
512
+ * @param css - Stylesheet text. A recognized map must contain a base64-encoded version 3 JSON map
513
+ * in the trailing comment format emitted by `cssWithSourceMap`.
514
+ * @returns CSS and its decoded map. Without a recognized trailing map, the CSS is unchanged and
515
+ * the map is null. JSON is decoded without validating its source-map fields.
516
+ * @throws If a recognized inline map contains invalid JSON.
517
+ */
518
+ export declare function decodeCssSourceMap(css: string): DecodedCssSourceMap;
519
+ /**
520
+ * Checks whether an identity names a stylesheet.
521
+ *
522
+ * @param id - Resolver identity or file path.
523
+ * @returns Whether the complete identity ends in `.css`, ignoring case. The check includes any
524
+ * query suffix.
525
+ */
526
+ export declare function isStylesheet(id: string): boolean;
527
+ /**
528
+ * A CSS graph for interactive queries. Recovered text must never supply lint fixes or builds.
529
+ */
530
+ interface EditorCssGraph extends Omit<LoadedCssGraph, "skipped"> {
531
+ /** Whether incomplete sources were replaced with recovered definitions. */
532
+ recovered: boolean;
533
+ }
534
+ /**
535
+ * Loads original CSS, then retries with recovered definitions if that load fails.
536
+ *
537
+ * @param root - Resolved CSS entrypoint.
538
+ * @param options - Compiler policies used by semantic queries.
539
+ * @param host - Resolver and reads of the captured original buffers.
540
+ * @param pluginInputs - Plugins for `@plugin` statements, as {@link loadCssGraph} describes.
541
+ * @returns A query graph and whether its sources were recovered. Original buffers remain unchanged.
542
+ * The recovered graph must only supply editor queries, because its text omits authored rules.
543
+ * @throws If both loads fail, including unresolved imports or unreadable files.
544
+ */
545
+ export declare function loadEditorCssGraph(root: string, options: NativeCompilerOptions, host: CssHost, pluginInputs?: CssPluginInputs): Promise<EditorCssGraph>;
546
+ /**
547
+ * Host operations that load the CSS graph and preserve document and source-map identities. Resolved
548
+ * IDs must be accepted by the reader, identity functions, and watcher.
549
+ */
550
+ interface CssHost {
551
+ /**
552
+ * Resolves an import from one CSS file.
553
+ *
554
+ * @param specifier - Import request text from the stylesheet.
555
+ * @param importer - Resolved identity of the importing stylesheet.
556
+ * @returns A promise for a file identity accepted by the other host operations. Resolution
557
+ * failures reject.
558
+ */
559
+ resolve(specifier: string, importer: string): Promise<string>;
560
+ /**
561
+ * Reads the text of a resolved CSS file.
562
+ *
563
+ * @param id - Identity returned by the resolver, or the resolved root identity.
564
+ * @returns A promise for stylesheet text. Read failures reject.
565
+ */
566
+ read(id: string): Promise<string>;
567
+ /**
568
+ * Assigns the document identity used by compiler diagnostics.
569
+ *
570
+ * @param id - Resolved CSS file identity.
571
+ * @returns A stable document URI for this file.
572
+ */
573
+ documentUri(id: string): string;
574
+ /**
575
+ * Assigns the source name recorded in CSS source maps.
576
+ *
577
+ * @param id - Resolved CSS file identity.
578
+ * @returns The source identity used for mapping emitted CSS back to this file.
579
+ */
580
+ sourceMapSource(id: string): string;
581
+ /**
582
+ * Registers a resolved CSS file for dependency tracking.
583
+ *
584
+ * @param id - Root or dependency identity accepted by the host reader.
585
+ */
586
+ watch(id: string): void;
587
+ /**
588
+ * Registers a directory that a plugin lists, so that adding, removing, or renaming an entry
589
+ * reloads the graph. Omission ignores directory registrations, which suits a host that loads
590
+ * the graph once or reloads it after every file addition or removal.
591
+ *
592
+ * @param id - Absolute directory path.
593
+ */
594
+ watchDirectory?(id: string): void;
595
+ /**
596
+ * Decides whether stylesheet lint checks a file. Omission selects {@link lintsStylesheet}.
597
+ *
598
+ * @param id - Resolved CSS file identity.
599
+ * @param importer - Identity of the importing file and whether lint checks it, or undefined for
600
+ * the root.
601
+ * @param specifier - Import request text, or undefined for the root.
602
+ * @returns Whether to mark the file for stylesheet lint. Lint never changes compiled output.
603
+ */
604
+ lint?(id: string, importer?: {
605
+ /** Resolved identity of the importing file. */
606
+ id: string;
607
+ /** Whether lint checks the importing file. */
608
+ lint: boolean;
609
+ }, specifier?: string): boolean;
610
+ /**
611
+ * Loads plugin packages and the files that plugins read. Omission limits the graph to
612
+ * configured plugins, whose `resolve` finds nothing and whose `read` fails.
613
+ */
614
+ plugins?: PluginHost;
615
+ }
616
+ /**
617
+ * Plugins, Tailwind settings, and project inputs for the `@plugin` statements of one CSS graph.
618
+ */
619
+ interface CssPluginInputs extends TailwindSettings {
620
+ /** Plugins configured for the project. */
621
+ plugins?: readonly StillwindPlugin[];
622
+ /** Absolute project directory passed to plugins. */
623
+ root: string;
624
+ /** Runtime of an earlier load of the same project, whose candidates are resolved again. */
625
+ previous?: PluginRuntime;
626
+ }
627
+ /**
628
+ * Selects the user's own CSS for stylesheet lint. The root is linted unless it lies under
629
+ * `node_modules`. An import is linted when lint checks its importer, its specifier is a relative
630
+ * or absolute path, and its file does not lie under `node_modules`. A package specifier such as
631
+ * `stillwind` or `tailwindcss` therefore excludes the package and everything it imports, even when
632
+ * the package resolves outside `node_modules`.
633
+ *
634
+ * @param id - Resolved CSS file identity.
635
+ * @param importer - Importing file and its lint mark, or undefined for the root.
636
+ * @param specifier - Import request text, or undefined for the root.
637
+ * @returns Whether stylesheet lint checks the file.
638
+ */
639
+ export declare function lintsStylesheet(id: string, importer?: {
640
+ /** Resolved identity of the importing file. */
641
+ id: string;
642
+ /** Whether lint checks the importing file. */
643
+ lint: boolean;
644
+ }, specifier?: string): boolean;
645
+ /**
646
+ * Completed design-system loader and resource references discovered in its CSS graph.
647
+ */
648
+ interface LoadedCssGraph {
649
+ /** Native loader whose complete CSS graph is ready for compilation. */
650
+ loader: NativeDesignSystemLoader;
651
+ /** Authored resource references that the adapter must resolve and replace in emitted CSS. */
652
+ resources: NativeCssResource[];
653
+ /** Identities of the files marked for stylesheet lint, in the order the loader accepted them. */
654
+ lintSources: string[];
655
+ /**
656
+ * Statements that loading skipped instead of failing, such as an import that cannot be resolved,
657
+ * ordered by source and position. Hosts that do not run stylesheet lint report them as warnings.
658
+ */
659
+ skipped: NativeSkippedCss[];
660
+ /**
661
+ * Plugins of the graph's `@plugin` statements and the definitions that they have added. Absent
662
+ * for a graph that a host assembled without loading plugins.
663
+ */
664
+ plugins?: PluginRuntime;
665
+ }
666
+ /**
667
+ * Loads a CSS graph and returns the completed native loader and its resource references.
668
+ * `root` must already be resolved and accepted by the host's read and watch methods.
669
+ * `options` configures a new loader. If `suppliedLoader` is given, it must not have
670
+ * received any input yet, and this function uses its existing configuration.
671
+ * `rootContent` skips reading the root file. The function still watches that file
672
+ * and all resolved dependencies. Each file is marked for stylesheet lint as `host.lint` decides,
673
+ * or as {@link lintsStylesheet} decides when the host omits it.
674
+ * Canonical queries build their indexes on first use.
675
+ *
676
+ * Reads run concurrently, and each request ID is read only once. Responses ready
677
+ * in the same event-loop turn are sent together to reduce native calls. Faster reads
678
+ * can reveal more imports without waiting for slower reads.
679
+ * Resolution, read, and native loading errors reject the promise. Reads already
680
+ * started continue, and files already registered with the watcher stay registered.
681
+ *
682
+ * @param root - Resolved CSS entrypoint accepted by the host's read and watch operations.
683
+ * @param options - Compiler settings used when creating a new loader.
684
+ * @param host - CSS resolver, reader, source identity operations, and dependency watcher.
685
+ * @param rootContent - Optional entrypoint text that replaces the initial filesystem read.
686
+ * @param suppliedLoader - Optional configured loader that has not received any CSS input.
687
+ * @param pluginInputs - Plugins for `@plugin` statements. Omission uses no configured plugins,
688
+ * the root's directory as the project directory, and the host's plugin operations.
689
+ * @returns A promise for the completed native loader and its authored resource references.
690
+ * @throws If resolving, reading, or loading the CSS graph fails.
691
+ */
692
+ export declare function loadCssGraph(root: string, options: NativeCompilerOptions, host: CssHost, rootContent?: string, suppliedLoader?: NativeDesignSystemLoader, pluginInputs?: CssPluginInputs): Promise<LoadedCssGraph>;
693
+ /**
694
+ * Associates a session with the plugin runtime of the CSS graph that it was created or reloaded
695
+ * from, so that compilation can define dynamic candidates.
696
+ *
697
+ * @param session - Native session.
698
+ * @param runtime - Runtime returned with the graph, or undefined to detach.
699
+ * @param generation - Definition generation of the loader that the session uses. Defaults to
700
+ * zero, the generation of the graph's original loader.
701
+ */
702
+ export declare function attachPlugins(session: NativeProjectSession, runtime?: PluginRuntime, generation?: number): void;
703
+ /**
704
+ * Compiles with the definitions of the attached plugins, and defines the dynamic candidates that
705
+ * the compilation reports.
706
+ *
707
+ * A session whose design system lacks definitions that the runtime added later is reloaded
708
+ * first. After each compilation, new candidates go to the plugins, and when they return CSS the
709
+ * session is reloaded and `compile` runs again, at most `rounds` more times. A session without
710
+ * plugins runs `compile` once.
711
+ *
712
+ * @param session - Native session whose output `compile` returns.
713
+ * @param compile - Compiles the graph into the session and returns its module outputs.
714
+ * @param rounds - Most reloads after the first compilation.
715
+ * @returns The output of the last compilation.
716
+ * @throws If a plugin, a reload, or `compile` fails.
717
+ */
718
+ export declare function compileWithPlugins<Output extends {
719
+ modules: readonly {
720
+ dynamicCandidates: readonly string[];
721
+ }[];
722
+ }>(session: NativeProjectSession, compile: () => Output, rounds: number): Promise<Output>;
723
+ /**
724
+ * Returns the loader whose design system a session uses after plugin definitions were added.
725
+ *
726
+ * @param session - Native session.
727
+ * @returns The loader of the last reload with definitions, or undefined when the session still
728
+ * uses the loader that it was created or attached with.
729
+ */
730
+ export declare function pluginLoader(session: NativeProjectSession): NativeDesignSystemLoader | undefined;
731
+ /**
732
+ * Loads compiler inputs and CSS for one Node analysis project. AnalysisProject serializes calls
733
+ * and installs captured document contents before asking this backend to resolve or load modules.
734
+ */
735
+ interface AnalysisHost extends CompilerHost {
736
+ /** Absolute project directory used for identities and CSS paths. */
737
+ root: string;
738
+ /**
739
+ * Compiler and preview settings fixed for this host's lifetime. Relative CSS and tsconfig paths
740
+ * use root.
741
+ */
742
+ config: BaseConfig & {
743
+ preview?: PreviewOptions;
744
+ };
745
+ /** CSS resolution and reads using the same captured document buffers as source loading. */
746
+ css: CssHost;
747
+ /** Fixed TypeScript settings selected when this host opens. */
748
+ readonly typeFactsEnvironment: TypeFactsEnvironment;
749
+ /** False disables additional semantic queries for this project. */
750
+ readonly typeFacts?: false;
751
+ /**
752
+ * Checks whether a resolved target can be analyzed by this host.
753
+ *
754
+ * @param id - Full resolver identity of the target.
755
+ * @returns Whether load can supply supported source for the identity.
756
+ */
757
+ supports(id: string): boolean;
758
+ /**
759
+ * Replaces all buffers used by subsequent source and CSS reads.
760
+ *
761
+ * @param documents - Absolute file paths to captured text. Missing entries use backend reads.
762
+ * @returns A promise that resolves when subsequent reads can use the supplied snapshot.
763
+ * @throws If the backend cannot install the supplied buffers.
764
+ */
765
+ setDocuments(documents: ReadonlyMap<string, string>): Promise<void>;
766
+ /**
767
+ * Discards backend caches before the next transaction. Must not overlap resolution or loads.
768
+ *
769
+ * @returns A promise that resolves when cached reads and resolutions have been invalidated.
770
+ * @throws If backend invalidation fails.
771
+ */
772
+ invalidate(): Promise<void>;
773
+ /**
774
+ * Releases backend resources. The caller first waits for pending host operations.
775
+ *
776
+ * @returns A promise for cleanup completion.
777
+ * @throws If backend cleanup fails.
778
+ */
779
+ close(): Promise<void>;
780
+ }
781
+ /**
782
+ * Result of an unpublished analysis at one project revision.
783
+ */
784
+ interface AnalysisResult {
785
+ /** Entry resolver identity supplied to analyze. */
786
+ entry: string;
787
+ /** Project change counter captured when analysis was queued. */
788
+ revision: number;
789
+ /**
790
+ * Complete describes available analysis inputs, even if reports contain compiler errors.
791
+ * Incomplete retains partial findings or an exception. Stale and cancelled omit reports and graph.
792
+ */
793
+ status: "complete" | "incomplete" | "stale" | "cancelled";
794
+ /** Findings mapped to original document URIs and zero-based UTF-16 positions. */
795
+ reports: BindingReport[];
796
+ /** Observed semantic graph, including dependency status and unavailable facts. Omitted on discard or early failure. */
797
+ graph?: ModuleAnalysis;
798
+ /** Caught exception as text. Compiler reports alone do not populate this field. */
799
+ error?: string;
800
+ }
801
+ /**
802
+ * Owns open buffers, checker queries, and serialized analysis for one host.
803
+ */
804
+ export declare class AnalysisProject {
805
+ #private;
806
+ /** Owned host. The project serializes its operations and closes it during cleanup. */
807
+ readonly host: AnalysisHost;
808
+ /**
809
+ * Takes ownership of a backend without loading CSS or starting a checker.
810
+ *
811
+ * @param host - Initialized backend whose TypeScript environment uses the same root. Release
812
+ * this project with `close` when its analysis services are no longer needed.
813
+ * @param backend - Optional lazy semantic backend factory. Omission selects the Node checker.
814
+ */
815
+ constructor(host: AnalysisHost, backend?: () => TypeFactsBackend);
816
+ /**
817
+ * Reads counters from the owned Node checker without exposing its mutable statistics object.
818
+ * @returns A copy of the counters, or undefined before checker creation or with a custom backend.
819
+ */
820
+ get checkerStats(): TypeScriptFactsStats | undefined;
821
+ /**
822
+ * Stores an unsaved buffer. Changed text advances the revision and makes pending results stale.
823
+ *
824
+ * @param id - File path resolved from the process working directory when relative.
825
+ * @param source - Complete original document text.
826
+ * @param version - Safe integer greater than the open buffer's version. An identical buffer and
827
+ * version have no effect. Identical text with a newer version updates only the version.
828
+ * A document can restart its version sequence after closeDocument.
829
+ * @throws If the version is invalid or does not increase for a changed open buffer.
830
+ */
831
+ update(id: string, source: string, version: number): void;
832
+ /**
833
+ * Removes an unsaved buffer and advances the revision when one existed.
834
+ *
835
+ * @param id - File path, resolved in the same way as update. Later reads use the host's source
836
+ * provider. Unknown paths have no effect.
837
+ */
838
+ closeDocument(id: string): void;
839
+ /** Makes pending results stale. The next transaction rebuilds CSS and backend caches. */
840
+ invalidate(): void;
841
+ /**
842
+ * Lists the stylesheets that this project lints, using the document contents captured when this
843
+ * method is called.
844
+ *
845
+ * @param editor - When false (the default), loads the original CSS and rejects invalid input.
846
+ * When true, retries a failed load with recovered definitions so incomplete CSS can still
847
+ * determine membership for completion, hover, and colors.
848
+ * @returns Identities of the CSS entry and the imported files that the CSS host marks for lint,
849
+ * in load order. Package CSS is excluded unless the host marks it. Returns an empty list
850
+ * if the captured buffers become outdated before loading starts.
851
+ * @throws If the project is closed, installing buffers or invalidating caches fails, or the
852
+ * selected CSS loading mode fails.
853
+ */
854
+ stylesheets(editor?: boolean): Promise<string[]>;
855
+ /**
856
+ * Queues analysis using the document contents and revision captured when this method is called.
857
+ *
858
+ * @param entry - Full resolver identity of a supported target, or of a stylesheet that
859
+ * {@link stylesheets} lists. A stylesheet's reports are its stylesheet lint findings, and its
860
+ * result has no graph. Membership filtering is performed by AnalysisWorkspace, not by this
861
+ * project.
862
+ * @param signal - Optional cancellation checked before and after queued work. Cancellation
863
+ * discards results without interrupting a checker query that has already started.
864
+ * @returns Reports for the entry and demanded semantic dependencies. Host failures appear as
865
+ * incomplete results with error text. Unavailable semantic information appears in the graph's
866
+ * unverified ranges. Stale and cancelled results omit reports and graphs.
867
+ */
868
+ analyze(entry: string, signal?: AbortSignal): Promise<AnalysisResult>;
869
+ /**
870
+ * Loads targets together and prepares plugin candidates using the current buffers.
871
+ *
872
+ * @param entries - Full resolver IDs. The workspace must apply project membership rules first.
873
+ * @returns Completion of preparation. Closed or outdated requests stop without publishing results.
874
+ * Loading and plugin failures are left for each target's analysis to report. A failed plugin
875
+ * runtime is discarded before retrying.
876
+ */
877
+ prepare(entries: readonly string[]): Promise<void>;
878
+ /**
879
+ * Queries the captured analysis for an entry. Buffer changes or cancellation discard its answer.
880
+ * CSS completion, hover, resolution, and colors can load recovered definitions for incomplete
881
+ * input. CSS sorting and lint fixes require the original graph to load successfully.
882
+ * Plugin path completion and links read captured CSS inside the project root without loading
883
+ * its graph or executing plugins.
884
+ *
885
+ * @param entry - Full resolver identity. The workspace applies target membership filtering.
886
+ * @param request - Operation with offsets in the original UTF-16 document.
887
+ * @param signal - Optional cancellation checked before and after queued work.
888
+ * @returns The current editor answer, or undefined after closure, cancellation, a revision change,
889
+ * failed entry analysis, or a semantic CSS query outside the graph's stylesheets marked for lint.
890
+ * @throws If preparing a CSS query fails or the editor query rejects a candidate or preview.
891
+ */
892
+ query(entry: string, request: EditorRequest, signal?: AbortSignal): Promise<EditorResult | undefined>;
893
+ /**
894
+ * Marks the project closed, discards pending results, and waits for queued work before cleanup.
895
+ * Repeated calls return without requesting further cleanup.
896
+ *
897
+ * @throws If checker or backend cleanup fails.
898
+ * @returns A promise that resolves after queued analysis and cleanup. Repeated calls made after
899
+ * closure starts return immediately. They do not wait for the first call's cleanup.
900
+ */
901
+ close(): Promise<void>;
902
+ }
903
+ /** Versioned source buffer that can replace a filesystem read during editor analysis. */
904
+ interface EditorDocument {
905
+ /**
906
+ * Resolver identity of the document. Editor operations remove query and fragment suffixes for
907
+ * ordinary file IDs.
908
+ */
909
+ id: string;
910
+ /**
911
+ * Safe integer, including negative values, that must increase for each update while this
912
+ * document stays open.
913
+ */
914
+ version: number;
915
+ /** Current unsaved document text supplied to source preparation and compilation. */
916
+ source: string;
917
+ }
918
+ /**
919
+ * Result of analyzing one document against a captured editor revision, with any previously
920
+ * successful preview.
921
+ */
922
+ interface EditorAnalysis {
923
+ /** Copy of the entry buffer captured when analysis started. */
924
+ document: EditorDocument;
925
+ /**
926
+ * Project change counter captured at analysis start. Any document update, close of an open
927
+ * document, or invalidation advances it.
928
+ */
929
+ revision: number;
930
+ /** Observed coverage: the result includes only dependencies demanded by this analysis. */
931
+ coverage: "observed";
932
+ /**
933
+ * Success means usable code without compiler errors or deny-level lint. Partial retains an
934
+ * incomplete or rejected result. Stale means the project revision changed. Cancelled means the
935
+ * signal was aborted. Stale and cancelled results omit output.
936
+ */
937
+ status: "success" | "partial" | "stale" | "cancelled";
938
+ /**
939
+ * Current compilation output, including reports for partial results when available. Stale or
940
+ * cancelled analysis removes this field.
941
+ */
942
+ output?: BindingOutput;
943
+ /**
944
+ * Caught exception message. Compiler reports returned in collect mode do not populate this field.
945
+ */
946
+ error?: string;
947
+ /**
948
+ * Distinct dependency resolver identities observed by the compilation, in first observation
949
+ * order, including those observed before failure.
950
+ */
951
+ dependencies: string[];
952
+ /**
953
+ * Copy of checker counters when this analysis needed type facts. Omitted when no checker was
954
+ * created.
955
+ */
956
+ checkerStats?: TypeScriptFactsStats;
957
+ /**
958
+ * Successful preview retained for this document when analysis started. Failed, stale, or
959
+ * cancelled attempts do not replace the stored success.
960
+ */
961
+ previousSuccess?: {
962
+ /** Document version that produced the retained preview. */
963
+ version: number;
964
+ /** Project revision captured by the successful analysis. */
965
+ revision: number;
966
+ /** Successful compiler output retained for editor preview. */
967
+ output: BindingOutput;
968
+ };
969
+ }
970
+ /** Versioned, unpublished previews. Each request owns its compiler session. */
971
+ export declare class EditorProject {
972
+ #private;
973
+ /** Filesystem root used to initialize the type-facts service when an analysis needs it. */
974
+ readonly root: string;
975
+ /**
976
+ * Dependency resolver and source metadata operations. Open buffers override its reader during
977
+ * analysis.
978
+ */
979
+ readonly host: CompilerHost;
980
+ /**
981
+ * Factory that must return a completed design-system loader suitable for a new compiler session
982
+ * on every analysis, or a loaded CSS graph whose plugins define dynamic candidates.
983
+ */
984
+ readonly designSystem: () => NativeDesignSystemLoader | Pick<LoadedCssGraph, "loader" | "plugins">;
985
+ /**
986
+ * Creates an editor project without opening documents or creating a checker.
987
+ *
988
+ * @param root - Filesystem project root used for checker resolution.
989
+ * @param host - Source descriptors, dependency resolver, and reader used by analysis.
990
+ * @param designSystem - Factory returning a loaded design system, or a loaded CSS graph with its
991
+ * plugins, for each independent analysis.
992
+ * @param typeFactsEnvironment - Fixed checker settings whose root matches this project. Omission
993
+ * selects an existing root tsconfig or isolated defaults.
994
+ */
995
+ constructor(root: string, host: CompilerHost, designSystem: () => NativeDesignSystemLoader | Pick<LoadedCssGraph, "loader" | "plugins">, typeFactsEnvironment?: TypeFactsEnvironment);
996
+ /**
997
+ * Stores an unsaved buffer and advances the project revision.
998
+ *
999
+ * @param document - Buffer with a safe integer version greater than the current version for its
1000
+ * cleaned identity. A copy is stored.
1001
+ * @throws If the version is not a safe integer or does not increase for an open document.
1002
+ */
1003
+ update(document: EditorDocument): void;
1004
+ /**
1005
+ * Removes an open buffer and its retained successful preview.
1006
+ *
1007
+ * @param id - Document identity, cleaned in the same way as `update`. Removing an open buffer
1008
+ * advances the revision. An unknown identity has no effect.
1009
+ */
1010
+ close(id: string): void;
1011
+ /**
1012
+ * Advances the revision after disk dependencies or the design system change, making in-progress
1013
+ * analysis stale.
1014
+ */
1015
+ invalidate(): void;
1016
+ /**
1017
+ * Compiles an open document with the unsaved buffers captured at analysis start.
1018
+ *
1019
+ * The analysis owns a new compiler session and closes any checker it creates. Dependency reads
1020
+ * prefer captured open buffers. Compiler diagnostics are collected. Other failures become the
1021
+ * returned error text. Stale or cancelled work retains neither current output nor a new
1022
+ * successful preview.
1023
+ *
1024
+ * @param id - Identity of an open document. Ordinary query and fragment suffixes are removed.
1025
+ * @param signal - Optional cancellation signal checked around asynchronous dependency operations
1026
+ * and before returning.
1027
+ * @returns A promise for the versioned result, observed dependencies, optional checker counters,
1028
+ * and the success retained when analysis started.
1029
+ * @throws If the document is not open. Cleanup failures can also reject the promise.
1030
+ */
1031
+ analyze(id: string, signal?: AbortSignal): Promise<EditorAnalysis>;
1032
+ }
1033
+ /**
1034
+ * Creates a Node analysis host with captured buffers, source providers, and CSS resolution.
1035
+ * Custom source resolution takes precedence over identities supplied by the semantic backend.
1036
+ *
1037
+ * @param config - One evaluated project. Custom source and projection callbacks receive the
1038
+ * buffers installed by setDocuments. Prepared inputs bypass custom projection preparation.
1039
+ * @param directory - Configuration directory used to resolve a relative project root.
1040
+ * @returns An owned host with fixed TypeScript settings. CSS and checker creation remain lazy.
1041
+ * @throws If TypeScript settings cannot be selected or the CSS resolver cannot be initialized.
1042
+ */
1043
+ export declare function createFileSystemAnalysisHost(config: AnalysisProjectConfig, directory: string): AnalysisHost;
1044
+ /**
1045
+ * Selects the design-system stylesheet request.
1046
+ *
1047
+ * @param config - Compiler settings. css identifies the stylesheet.
1048
+ * @returns The authored path without resolving it. The caller applies the project root.
1049
+ * @throws If css does not supply a nonempty stylesheet path.
1050
+ */
1051
+ export declare function cssEntrypoint(config: BaseConfig): string;
1052
+ /**
1053
+ * Applies host defaults to settings passed to a native design-system loader.
1054
+ *
1055
+ * @param config - Shared compiler settings. Naming callbacks are passed separately to sessions.
1056
+ * @returns Native loader options. CSS evaluation supplies utility and variant definitions.
1057
+ */
1058
+ export declare function compilerOptions(config: BaseConfig): NativeCompilerOptions;
1059
+ /**
1060
+ * Loads plugin packages and plugin files with Node module resolution from the stylesheet that
1061
+ * contains the `@plugin` statement, and reads files from the filesystem.
1062
+ *
1063
+ * A package specifier is imported with Node's module cache, so a changed package takes effect only
1064
+ * in a new process. A relative or absolute path is bundled with its local imports and evaluated
1065
+ * again after any of those files changes.
1066
+ */
1067
+ export declare const nodePluginHost: PluginHost;
1068
+ /**
1069
+ * Creates a stylesheet package resolver for hosts whose own resolver selects JavaScript entries.
1070
+ *
1071
+ * @returns A function that resolves a specifier from an importing file to a path, or to
1072
+ * undefined when the specifier does not resolve.
1073
+ */
1074
+ export declare function createStylesheetResolver(): (specifier: string, importer: string) => Promise<string | undefined>;
1075
+ /** A project's configuration and results, retained independently when scopes overlap. */
1076
+ interface WorkspaceProject {
1077
+ /** Evaluated project settings. Relative root and scope globs use configFile's directory and host root. */
1078
+ readonly config: CapturedProjectConfig;
1079
+ /** Absolute path of the configuration that owns this project. */
1080
+ readonly configFile: string;
1081
+ /** Owned analysis state. Buffers outside this project's target scope can still be dependencies. */
1082
+ readonly analysis: AnalysisProject;
1083
+ }
1084
+ /** Analysis results for one explicitly enumerated target in one project. */
1085
+ interface WorkspaceResult {
1086
+ /** Zero-based index into the workspace's projects array. */
1087
+ project: number;
1088
+ /** Absolute configuration path used to group this result. */
1089
+ config: string;
1090
+ /** Captured result whose reports have been filtered to this project's configured scope. */
1091
+ result: AnalysisResult;
1092
+ }
1093
+ /** Owns every project in one evaluated configuration and keeps overlapping scopes independent. */
1094
+ export declare class AnalysisWorkspace {
1095
+ #private;
1096
+ /** Absolute path evaluated when this workspace opened. Reopen the workspace to apply configuration changes. */
1097
+ readonly configFile: string;
1098
+ /** Fixed project records in configuration order. Each analysis service owns mutable state. */
1099
+ readonly projects: readonly WorkspaceProject[];
1100
+ /**
1101
+ * Retains the evaluated configuration and takes ownership of its initialized projects.
1102
+ *
1103
+ * @param configFile - Absolute configuration path.
1104
+ * @param projects - Successfully opened hosts in configuration order.
1105
+ * @param dependencies - Absolute configuration and import paths recorded during evaluation.
1106
+ */
1107
+ private constructor();
1108
+ /**
1109
+ * Evaluates configuration and opens every project, closing earlier hosts if initialization fails.
1110
+ *
1111
+ * @param configFile - Trusted configuration path. Relative paths use the process working directory.
1112
+ * @returns A workspace that owns its project hosts. Close it when replacing the configuration.
1113
+ * @throws If configuration evaluation or project initialization fails.
1114
+ */
1115
+ static open(configFile: string): Promise<AnalysisWorkspace>;
1116
+ /**
1117
+ * Matches target scope independently of whether the source exists on disk.
1118
+ *
1119
+ * @param project - Project whose root, include globs, and exclusions define membership.
1120
+ * @param file - Absolute file path to test.
1121
+ * @returns Whether the path matches files without matching excludes, node_modules, or .git.
1122
+ * Dependency traversal does not use this filter.
1123
+ */
1124
+ includes(project: WorkspaceProject, file: string): boolean;
1125
+ /**
1126
+ * Checks whether the project lints a stylesheet. Loading the project's CSS graph decides it.
1127
+ *
1128
+ * @param project - Project whose CSS graph lists its linted stylesheets.
1129
+ * @param file - Absolute file path to test.
1130
+ * @param editor - When false (the default), requires the original CSS graph to load successfully.
1131
+ * When true, retries a failed load with recovered definitions so completion, hover, and colors
1132
+ * can still identify stylesheet membership while the CSS is incomplete.
1133
+ * @returns Whether the file is the CSS entry or an imported file that the CSS host marks for
1134
+ * lint. Returns false for other extensions or when the selected loading mode fails. Ordinary
1135
+ * script analysis reports CSS loading failures.
1136
+ */
1137
+ lintsStylesheet(project: WorkspaceProject, file: string, editor?: boolean): Promise<boolean>;
1138
+ /**
1139
+ * Enumerates existing target files independently of dependency traversal.
1140
+ *
1141
+ * @param project - Project whose files and excludes globs are relative to its host root.
1142
+ * @param patterns - Optional additional include globs relative to the same root. An empty list
1143
+ * adds no filtering. These patterns cannot expand the configured scope.
1144
+ * @param options - Target kinds to add to the configured script targets.
1145
+ * @returns Sorted absolute target paths. Unsaved files absent from disk are not enumerated.
1146
+ * @throws If filesystem enumeration fails.
1147
+ */
1148
+ targets(project: WorkspaceProject, patterns?: string[], options?: {
1149
+ /** Adds the stylesheets that the project lints, as {@link lintsStylesheet} selects them. */
1150
+ stylesheets?: boolean;
1151
+ }): Promise<string[]>;
1152
+ /**
1153
+ * Keeps editor answers separate when several projects include the same target.
1154
+ *
1155
+ * @param file - Absolute target path used for independent scope checks.
1156
+ * @param request - Operation in the original document's UTF-16 coordinates.
1157
+ * @param signal - Optional cancellation forwarded to each project's queued query.
1158
+ * @returns Available answers in configuration order, including overlapping project memberships.
1159
+ * CSS membership checks allow recovered definitions when the original graph cannot load.
1160
+ * Plugin path completion and links also accept CSS files inside a project's root.
1161
+ * @throws If a project's editor query fails.
1162
+ */
1163
+ query(file: string, request: EditorRequest, signal?: AbortSignal): Promise<{
1164
+ /** Zero-based index into the configured projects. */
1165
+ project: number;
1166
+ /** Absolute configuration path that owns this project. */
1167
+ config: string;
1168
+ /** Answer tied to the captured original source and design system. */
1169
+ result: EditorResult;
1170
+ }[]>;
1171
+ /**
1172
+ * Updates all hosts because an open file can be a dependency outside their target scope.
1173
+ *
1174
+ * @param file - File path resolved by each project from the process working directory if relative.
1175
+ * @param source - Complete unsaved document text.
1176
+ * @param version - Increasing safe integer for the open buffer. Identical repeated updates have no effect.
1177
+ * @throws If a project rejects the version. Updates already applied to earlier projects are retained.
1178
+ */
1179
+ update(file: string, source: string, version: number): void;
1180
+ /**
1181
+ * Removes a buffer from every project so later reads use its source provider.
1182
+ *
1183
+ * @param file - File path resolved in the same way as update. Unknown buffers have no effect.
1184
+ */
1185
+ closeDocument(file: string): void;
1186
+ /**
1187
+ * Checks whether save or watch notifications need a new workspace.
1188
+ *
1189
+ * @param files - File paths reported by the notification. Relative paths use the working directory.
1190
+ * @returns True when every file has an open buffer and none is a configuration dependency,
1191
+ * a tsconfig, or package.json. This method does not read disk or reopen projects.
1192
+ */
1193
+ refresh(files: readonly string[]): boolean;
1194
+ /**
1195
+ * Advances every project revision and requests CSS and resolver cache refresh before its next analysis.
1196
+ */
1197
+ invalidate(): void;
1198
+ /**
1199
+ * Analyzes a target separately in every matching project and filters reports to each scope.
1200
+ * A project matches a script target in its configured scope and a stylesheet that it lints.
1201
+ *
1202
+ * @param file - Absolute target path. The file need not exist on disk when an open buffer supplies it.
1203
+ * @param signal - Optional cancellation checked by each project's queued analysis.
1204
+ * @returns Results in project order, or an empty list when no project includes the target.
1205
+ * Dependency information remains available even when its reports lie outside the target scope.
1206
+ */
1207
+ analyze(file: string, signal?: AbortSignal): Promise<WorkspaceResult[]>;
1208
+ /**
1209
+ * Analyzes every selected target, including files unreachable from an application entry, and
1210
+ * every stylesheet that a project lints.
1211
+ *
1212
+ * @param patterns - Optional additional globs relative to each project's root. Empty or omitted
1213
+ * filters check every configured target.
1214
+ * @returns Scoped results in project order, then sorted target order. Overlapping memberships remain separate.
1215
+ * @throws If target enumeration fails. Analysis failures are represented in individual results.
1216
+ */
1217
+ lint(patterns?: string[]): Promise<WorkspaceResult[]>;
1218
+ /**
1219
+ * Prepares targets together in each project that includes them.
1220
+ *
1221
+ * @param files - Absolute target paths. Files outside a project's target globs are skipped.
1222
+ * @returns Completion of preparation. Each target's analysis reports its own source failures.
1223
+ */
1224
+ prepare(files: readonly string[]): Promise<void>;
1225
+ /**
1226
+ * Keeps dependency context while filtering findings from known sources to the project's target scope.
1227
+ *
1228
+ * @param project - Project whose host and globs identify owned source documents.
1229
+ * @param result - Captured analysis with original document URIs.
1230
+ * @returns A copy with filtered reports. Reports for unknown source documents remain available.
1231
+ * @throws If a file URI in a report cannot be converted to a path.
1232
+ */
1233
+ private scopedResult;
1234
+ /**
1235
+ * Closes every project and waits for all cleanup attempts before reporting failures.
1236
+ *
1237
+ * @returns A promise that resolves after project cleanup.
1238
+ * @throws An AggregateError containing all project cleanup failures.
1239
+ */
1240
+ close(): Promise<void>;
1241
+ }
1242
+ export { type AnalysisHost, type AnalysisResult, type AvailableFacts, type CheckerSpan, type CompilerHost, type CompilerMapping, type CssHost, type CssLocations, type CssPluginInputs, type CssSourceMapInput, type CssUpstreamMap, type DecodedCssSourceMap, type EditorAnalysis, type EditorColor, type EditorCompletion, type EditorCssGraph, type EditorDocument, type EditorEdit, type EditorRequest, type EditorResult, EditorSnapshot, type FinalizedModuleEdit, type LoadedCssGraph, type ModuleAnalysis, type ModuleCompileOptions, type ModuleDescriptor, type PluginHost, type PluginPathCompletion, PluginRuntime, type PreparedSource, type SemanticDependency, type SemanticInputs, type TailwindSettings, type TypeFact, type TypeFactSource, type TypeFactsBackend, type TypeFactsEnvironment, TypeFactsError, type TypeFactsInputs, TypeScriptFactsService, type TypeScriptFactsStats, type TypeScriptProject, type UnverifiedRange, type UpstreamSourceMap, type WorkspaceProject, type WorkspaceResult, defaultPluginExport, resolveTypeFactsEnvironment };
1243
+ //# sourceMappingURL=index.d.ts.map