@stillwind/host 0.0.0-stage → 0.1.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,844 @@
1
+ import { BindingEdit, BindingReport, NativeAssetRecord, NativeCheckerBinding, NativeCompilerOptions, NativeCssFileInput, NativeCssRequest, NativeDesignSystemLoader, NativeDiagnosticBatch, NativeEditorQuery, NativeProjectSession, NativeSourceIssue, NativeTypeFact, ProjectModuleOutput } from "@stillwind/native";
2
+ import { CheckerBuffer, PreparedSource } from "@stillwind/projection";
3
+ import "typescript-7/unstable/sync";
4
+ import { BaseConfig, PluginDirectoryEntry, PluginWatchKind, PreviewOptions, StillwindPlugin, TailwindConfig } from "@stillwind/config";
5
+ import "typescript-7/unstable/ast";
6
+ /**
7
+ * A replacement in the original document, using half-open UTF-16 offsets.
8
+ */
9
+ interface EditorEdit {
10
+ /** Inclusive UTF-16 offset in the original document. */
11
+ start: number;
12
+ /** Exclusive UTF-16 offset in the original document. */
13
+ end: number;
14
+ /** Source spelling inserted at the range, including escapes required by its source context. */
15
+ newText: string;
16
+ }
17
+ /**
18
+ * Completion text replaces the entire candidate at the supplied original range.
19
+ */
20
+ interface EditorCompletion extends EditorEdit {
21
+ /** Directive names use the keyword category. Other inputs use candidate categories. */
22
+ keyword?: boolean;
23
+ /** True for a variant, including CSS variant labels without a trailing colon. */
24
+ variant?: boolean;
25
+ /** True for a label that adds a marker class or starts the modifier of a modifiable marker. */
26
+ marker?: boolean;
27
+ /** Static description for a CSS directive or plugin path. CSS summaries load on resolve. */
28
+ detail?: string;
29
+ /** Replacement encoded as an LSP snippet when the requesting client supports snippets. */
30
+ snippet?: string;
31
+ /** Requests another completion after the client inserts this item. */
32
+ retrigger?: boolean;
33
+ /** Completion category for host-resolved plugin names, files, and directories. */
34
+ category?: "module" | "file" | "directory";
35
+ /** Lexical priority key supplied by the semantic catalog. Omission sorts by label. */
36
+ sortText?: string;
37
+ /** Visible completion text; surrounding group variants are omitted. */
38
+ label: string;
39
+ /** Full candidate used for lazy CSS resolution, including surrounding group variants. */
40
+ candidate: string;
41
+ /** Original UTF-16 input identity used for completion resolution. */
42
+ input: number;
43
+ /** Fingerprint of the captured query inputs. Resolve requires this exact value. */
44
+ snapshot: string;
45
+ }
46
+ /**
47
+ * A concrete sRGB color at an original candidate range.
48
+ */
49
+ interface EditorColor {
50
+ /** Inclusive UTF-16 offset of the authored candidate. */
51
+ start: number;
52
+ /** Exclusive UTF-16 offset of the authored candidate. */
53
+ end: number;
54
+ /** Red component in the inclusive range 0..1. */
55
+ red: number;
56
+ /** Green component in the inclusive range 0..1. */
57
+ green: number;
58
+ /** Blue component in the inclusive range 0..1. */
59
+ blue: number;
60
+ /** Effective opacity after utility modifiers, in the inclusive range 0..1. */
61
+ alpha: number;
62
+ }
63
+ /**
64
+ * Requests address original document UTF-16 offsets, including incomplete candidate text.
65
+ */
66
+ type EditorRequest = {
67
+ /** Requests the original definition of a CSS variable or theme reference. */
68
+ kind: "definition";
69
+ /** Original UTF-16 cursor offset within the reference. */
70
+ offset: number;
71
+ } | {
72
+ /** Requests plugin module links in the original stylesheet. */
73
+ kind: "links";
74
+ } | {
75
+ /** Requests CSS or documentation for a candidate, expression, or CSS directive. */
76
+ kind: "hover";
77
+ /** Original UTF-16 cursor offset at the input to describe. */
78
+ offset: number;
79
+ } | {
80
+ /** Requests matching candidates and variant prefixes for an insertion point. */
81
+ kind: "completion";
82
+ /** Includes CSS registry directives. Defaults to false and does not affect compilation. */
83
+ registryDirectives?: boolean;
84
+ /** Includes placeholders for clients that support completion snippets. */
85
+ snippets?: boolean;
86
+ /** Original UTF-16 insertion point; text before this point determines the prefix. */
87
+ offset: number;
88
+ } | {
89
+ /** Requests CSS or documentation for a completion from the same captured snapshot. */
90
+ kind: "resolve";
91
+ /** CSS discovery setting used for the original completion. A change makes it stale. */
92
+ registryDirectives?: boolean;
93
+ /** Snippet setting captured when completion was requested. */
94
+ snippets?: boolean;
95
+ /** Full candidate or CSS label returned by completion. */
96
+ candidate: string;
97
+ /** Original UTF-16 boundary returned as `EditorCompletion.input`. */
98
+ input: number;
99
+ /** Captured fingerprint returned by completion; a mismatch omits hover output. */
100
+ snapshot: string;
101
+ } | {
102
+ /** Requests concrete colors for recognized utility candidates in the source. */
103
+ kind: "colors";
104
+ } | {
105
+ /** Requests each report's first fix action for this source revision, with enabled sorting. */
106
+ kind: "fixes";
107
+ } | {
108
+ /** Requests configured sorting independently of lint severity. */
109
+ kind: "sort";
110
+ /** Half-open original UTF-16 ranges that sorting must leave untouched. */
111
+ protectedRanges?: readonly {
112
+ /** Inclusive original UTF-16 offset of the protected text. */
113
+ start: number;
114
+ /** Exclusive original UTF-16 offset of the protected text. */
115
+ end: number;
116
+ }[];
117
+ } | {
118
+ /** Requests a replacement candidate for a range returned by the colors query. */
119
+ kind: "colorPresentation";
120
+ /** Inclusive original UTF-16 offset returned by the colors query. */
121
+ start: number;
122
+ /** Exclusive original UTF-16 offset returned by the colors query. */
123
+ end: number;
124
+ /** Desired sRGB components and effective opacity, each in 0..1. */
125
+ color: Pick<EditorColor, "red" | "green" | "blue" | "alpha">;
126
+ };
127
+ /**
128
+ * Editor data belongs to the exact source fingerprint in revision. Absent fields mean no answer.
129
+ */
130
+ interface EditorResult {
131
+ /** Original CSS definitions with zero-based line and UTF-16 column coordinates. */
132
+ definitions?: {
133
+ uri: string;
134
+ startLine: number;
135
+ startColumn: number;
136
+ endLine: number;
137
+ endColumn: number;
138
+ }[];
139
+ /** Plugin paths at half-open original UTF-16 ranges. An absent target means unresolved or configured-only. */
140
+ links?: {
141
+ start: number;
142
+ end: number;
143
+ target?: string;
144
+ }[];
145
+ /** Fingerprint of the original source text used to compute every range and edit. */
146
+ revision: string;
147
+ /** Formatted CSS at a half-open original UTF-16 range. Generated element subjects use `&`.
148
+ * Lazy completion resolution uses the sentinel range `[0, 0)`.
149
+ */
150
+ hover?: {
151
+ /** Inclusive original UTF-16 boundary, or zero for completion resolution. */
152
+ start: number;
153
+ /** Exclusive original UTF-16 boundary, or zero for completion resolution. */
154
+ end: number;
155
+ /** Generated CSS or an active theme declaration. Empty for documentation-only hovers. */
156
+ css: string;
157
+ /** Short CSS summary or plugin description for the selected completion. */
158
+ detail?: string;
159
+ /** Markdown for CSS directives, output slots, theme references, plugin paths, or marker classes. */
160
+ documentation?: string;
161
+ /** Authored runtime key expressions, deduplicated in dependency traversal order.
162
+ * Absent when the preview has no runtime key expression to explain.
163
+ */
164
+ runtimeNames?: string[];
165
+ };
166
+ /** Prefix-matching candidates with their full replacement ranges. CSS loads on resolve. */
167
+ completions?: EditorCompletion[];
168
+ /** Concrete colors resolved against the active design system. */
169
+ colors?: EditorColor[];
170
+ /** Nonoverlapping replacements in ascending original offset order. */
171
+ edits?: EditorEdit[];
172
+ }
173
+ /**
174
+ * A complete module specifier that an editor can insert into a CSS string.
175
+ */
176
+ interface PluginPathCompletion {
177
+ specifier: string;
178
+ kind: "module" | "file" | "directory";
179
+ }
180
+ /**
181
+ * File resolution and completion used by plugin path navigation. No plugin evaluation is required.
182
+ */
183
+ interface PluginPathHost {
184
+ /**
185
+ * Lists complete specifiers for an editor without evaluating their modules.
186
+ *
187
+ * @param prefix - Decoded path text before the CSS cursor.
188
+ * @param importer - Absolute identity of the stylesheet containing the path.
189
+ * @param root - Absolute project directory used to find package metadata.
190
+ * @returns Full specifiers with trailing slashes for directory prefixes.
191
+ */
192
+ complete?(prefix: string, importer: string, root: string): Promise<readonly PluginPathCompletion[]>;
193
+ /**
194
+ * Resolves a module request for plugin file reads and editor navigation without evaluating it.
195
+ *
196
+ * @param specifier - Package specifier with an optional subpath, or a relative or absolute path.
197
+ * @param importer - Resolved identity of the stylesheet that contains the statement.
198
+ * @returns The resolved path, or undefined when the request does not resolve.
199
+ */
200
+ resolve(specifier: string, importer: string): Promise<string | undefined>;
201
+ }
202
+ /**
203
+ * A plugin written against Tailwind CSS v4's JavaScript plugin API: a handler, `{ handler,
204
+ * config }`, or a factory from `plugin.withOptions`. The host loads its adapter, and with it the
205
+ * `tailwindcss` package, only when a `@plugin` statement selects such a plugin.
206
+ */
207
+ type TailwindPlugin = ((...args: never[]) => unknown) | {
208
+ /** Handler that receives Tailwind's plugin API. */
209
+ handler: (...args: never[]) => unknown;
210
+ /** v3-style config, such as `theme.extend`. */
211
+ config?: object;
212
+ };
213
+ /**
214
+ * Project settings that the Tailwind plugin adapter applies to the whole CSS graph.
215
+ */
216
+ interface TailwindSettings {
217
+ /** Tailwind configuration, or a promise for one, which replaces Tailwind's `@config`. */
218
+ tailwind?: TailwindConfig | Promise<TailwindConfig>;
219
+ /** Value of Tailwind's `important` configuration key. */
220
+ important?: true | string;
221
+ }
222
+ /**
223
+ * A native Stillwind plugin or a plugin using Tailwind v4's JavaScript API.
224
+ */
225
+ type LoadedPlugin = StillwindPlugin | TailwindPlugin;
226
+ /**
227
+ * Host operations for plugin packages and the files that plugins read. Paths are absolute host
228
+ * identities, which the host's `read` accepts.
229
+ */
230
+ interface PluginHost extends PluginPathHost {
231
+ /**
232
+ * Loads the plugin package that an `@plugin` statement names when no configured plugin has
233
+ * that name.
234
+ *
235
+ * @param specifier - Package specifier or path from the statement.
236
+ * @param importer - Resolved identity of the stylesheet that contains the statement.
237
+ * @param watch - Registers each file whose change must load the plugin again. A host that
238
+ * returns the same plugin for unchanged files still registers them on every call.
239
+ * @returns The plugin that the module exports by default, as {@link defaultPluginExport} checks.
240
+ * @throws If resolution or evaluation fails, or the default export is not a plugin.
241
+ */
242
+ load(specifier: string, importer: string, watch: (path: string) => void): Promise<LoadedPlugin>;
243
+ /**
244
+ * Reads a text file requested by a plugin.
245
+ *
246
+ * @param path - Absolute file path.
247
+ * @returns The file's text.
248
+ * @throws If the file does not exist or cannot be read.
249
+ */
250
+ read(path: string): Promise<string>;
251
+ /**
252
+ * Lists a directory requested by a plugin. Omission makes plugin directory reads fail.
253
+ *
254
+ * @param path - Absolute directory path.
255
+ * @returns The directory's own entries.
256
+ * @throws If the directory does not exist or cannot be read.
257
+ */
258
+ list?(path: string): Promise<readonly PluginDirectoryEntry[]>;
259
+ }
260
+ /**
261
+ * Selects the plugin that a module exports by default.
262
+ *
263
+ * @param module - Evaluated module namespace.
264
+ * @param specifier - Request that loaded the module, used in the error message.
265
+ * @returns The default export.
266
+ * @throws If the default export is neither a Stillwind plugin object nor a Tailwind v4 plugin.
267
+ */
268
+ declare function defaultPluginExport(module: unknown, specifier: string): LoadedPlugin;
269
+ /**
270
+ * Failure to map, validate, or recover declaration identities for one source. The compiler turns
271
+ * this error into a source report using its original-coordinate range.
272
+ */
273
+ declare class TypeFactsError extends Error {
274
+ /** Compiler module identity used to locate the original prepared source. */
275
+ readonly moduleId: string;
276
+ /**
277
+ * Inclusive original UTF-8 byte offset when the checker can identify it. Omission permits a
278
+ * document-scoped report.
279
+ */
280
+ readonly start?: number;
281
+ /**
282
+ * Exclusive original UTF-8 byte offset when known. The compiler uses a source range only when
283
+ * both endpoints are present.
284
+ */
285
+ readonly end?: number;
286
+ /** Issue category and detail passed to native source-failure reporting. */
287
+ readonly issue: NativeSourceIssue;
288
+ /**
289
+ * Records a checker contract failure in original source coordinates.
290
+ *
291
+ * @param moduleId - Compiler identity of the affected source.
292
+ * @param start - Optional inclusive original UTF-8 byte offset.
293
+ * @param end - Optional exclusive original UTF-8 byte offset.
294
+ * @param kind - Native issue category, such as checker mapping, assignment, or identity
295
+ * resolution.
296
+ * @param detail - Error message also stored as the issue detail.
297
+ */
298
+ constructor(moduleId: string, start: number | undefined, end: number | undefined, kind: NativeSourceIssue["kind"], detail: string);
299
+ }
300
+ /** Original UTF-8 expression range and its validated projected UTF-16 range. */
301
+ interface CheckerSpan {
302
+ /** Correspondence role matched when mapping a producer, expression, or module specifier. */
303
+ role: string;
304
+ /** Inclusive UTF-8 byte offset in the original document. */
305
+ start: number;
306
+ /** Exclusive UTF-8 byte offset in the original document, at or after `start`. */
307
+ end: number;
308
+ /** Inclusive UTF-16 offset in the unedited projected parser buffer. */
309
+ projectedStart: number;
310
+ /** Exclusive UTF-16 offset in the projected buffer, at or after `projectedStart`. */
311
+ projectedEnd: number;
312
+ }
313
+ /** Original-coordinate requests for one module and its optional parser projection. */
314
+ type TypeFactSource = PreparedSource & {
315
+ /**
316
+ * Original expressions queried for lowering or optional macro recognition. Every probe must
317
+ * match an expression in a checker AST.
318
+ */
319
+ probes: readonly {
320
+ /** Inclusive UTF-8 byte offset of the original expression. */
321
+ start: number;
322
+ /** Exclusive UTF-8 byte offset of the original expression. */
323
+ end: number;
324
+ /**
325
+ * True makes unresolved identities optional for macro recognition. Otherwise missing or
326
+ * unresolved types and nonfinite Stillwind candidates are errors.
327
+ */
328
+ recognitionOnly?: boolean;
329
+ }[];
330
+ /** Validated original-byte to projected-UTF-16 correspondences from the frontend. */
331
+ checkerSpans?: readonly CheckerSpan[];
332
+ /** Validated generated references that must use their global helper declarations. */
333
+ checkerBindings?: readonly NativeCheckerBinding[];
334
+ /** Alternative checker buffers, including independent Astro client modules. */
335
+ checkerBuffers?: readonly CheckerBuffer[];
336
+ /** Absolute framework declaration files included in the checker project. */
337
+ checkerTypes?: readonly string[];
338
+ /** Import resolutions used to rewrite checker module paths. */
339
+ resolutions?: readonly {
340
+ /**
341
+ * Full resolved source identity. The checker rewrites this to the matching checker filename
342
+ * when one is supplied.
343
+ */
344
+ id: string;
345
+ /** Inclusive UTF-8 byte offset of the original module string literal, including its quotes. */
346
+ start: number;
347
+ /** Exclusive UTF-8 byte offset of the original module string literal. */
348
+ end: number;
349
+ }[];
350
+ };
351
+ /** An original UTF-8 range whose dependency or checker information could not be verified. */
352
+ interface UnverifiedRange {
353
+ /** Compiler module identity of the original document. */
354
+ moduleId: string;
355
+ /** Inclusive original UTF-8 byte offset. Omission identifies unavailable information for the module. */
356
+ start?: number;
357
+ /** Exclusive original UTF-8 byte offset when a specific expression range is known. */
358
+ end?: number;
359
+ /** Explanation of the missing dependency, checker result, or source correspondence. */
360
+ reason: string;
361
+ }
362
+ /** Captured declarations and source buffers supplied to a semantic backend. */
363
+ interface SemanticInputs {
364
+ /** Captured original text keyed by absolute checker file path. Entries override filesystem reads. */
365
+ overlayFiles?: ReadonlyMap<string, string>;
366
+ /** Ambient declaration text keyed by absolute checker file path, supplied without writing to disk. */
367
+ ambientDeclarations?: ReadonlyMap<string, string>;
368
+ }
369
+ /** Available facts remain usable when other expressions cannot be verified. */
370
+ interface AvailableFacts {
371
+ /** Available native facts grouped by compiler module identity. */
372
+ facts: Map<string, NativeTypeFact[]>;
373
+ /** Ranges for queries that could not be verified. Facts for other queries remain usable. */
374
+ unverified: UnverifiedRange[];
375
+ }
376
+ /** Semantic queries implemented by a Node checker or an embedding application's checker worker. */
377
+ interface TypeFactsBackend {
378
+ /**
379
+ * Sets the sources available to later checker queries. Each query still selects its own probes.
380
+ * Call again after changing these inputs. Without this method, each query prepares its own sources.
381
+ *
382
+ * @param sources - All prepared sources for this project, in a stable order.
383
+ * @param assets - Declarations grouped by compiler module ID for those sources.
384
+ * @param inputs - File overlays and ambient declarations. Omission supplies no extra files.
385
+ * The backend may retain these objects. Do not mutate them while they are installed.
386
+ * Replacing the inputs clears the backend's prepared checker buffers.
387
+ */
388
+ setProjectSources?(sources: readonly TypeFactSource[], assets: ReadonlyMap<string, readonly NativeAssetRecord[]>, inputs?: SemanticInputs): void;
389
+ /**
390
+ * Resolves imports using the checker environment before source-provider fallback resolution.
391
+ *
392
+ * @param sources - Prepared sources with original probes and checker correspondences.
393
+ * @param assets - Compiler declaration metadata grouped by module identity.
394
+ * @param inputs - Captured overlays and ambient declarations for the same analysis.
395
+ * @returns Import request to resolved identity maps, grouped by source resolver identity.
396
+ * @throws If checker setup or resolution cannot complete.
397
+ */
398
+ resolveModules(sources: readonly TypeFactSource[], assets: ReadonlyMap<string, readonly NativeAssetRecord[]>, inputs?: SemanticInputs): ReadonlyMap<string, ReadonlyMap<string, string>> | Promise<ReadonlyMap<string, ReadonlyMap<string, string>>>;
399
+ /**
400
+ * Collects semantic facts and validates declaration contracts for required probes.
401
+ *
402
+ * @param sources - Prepared sources with original UTF-8 probe ranges.
403
+ * @param assets - Compiler declarations grouped by module identity.
404
+ * @param inputs - Captured overlays and declarations. Omission permits backend reads.
405
+ * @returns Native facts grouped by compiler module identity.
406
+ * @throws If a required type, declaration identity, or source correspondence cannot be verified.
407
+ */
408
+ collect(sources: readonly TypeFactSource[], assets: ReadonlyMap<string, readonly NativeAssetRecord[]>, inputs?: SemanticInputs): Map<string, NativeTypeFact[]> | Promise<Map<string, NativeTypeFact[]>>;
409
+ /**
410
+ * Keeps verified facts while recording unavailable queries.
411
+ *
412
+ * @param sources - Prepared sources with original UTF-8 probe ranges.
413
+ * @param assets - Compiler declarations grouped by module identity.
414
+ * @param inputs - Captured overlays and declarations for this analysis.
415
+ * @returns Facts for successful queries and original ranges with explanations for other queries.
416
+ * @throws If backend setup or transport fails, or checker results conflict for one original range.
417
+ */
418
+ collectAvailable(sources: readonly TypeFactSource[], assets: ReadonlyMap<string, readonly NativeAssetRecord[]>, inputs?: SemanticInputs): AvailableFacts | Promise<AvailableFacts>;
419
+ /**
420
+ * Discards cached filesystem state before subsequent queries. Call between analysis transactions.
421
+ *
422
+ * @returns Nothing, or a promise that resolves after invalidation.
423
+ */
424
+ invalidate(): void | Promise<void>;
425
+ /**
426
+ * Releases checker resources after pending queries complete.
427
+ *
428
+ * @returns Nothing, or a promise that resolves after cleanup.
429
+ * @throws If checker cleanup fails.
430
+ */
431
+ close(): void | Promise<void>;
432
+ }
433
+ /**
434
+ * TypeScript settings inherited by the generated project used for semantic queries.
435
+ */
436
+ type TypeScriptProject = {
437
+ /** Selects settings inherited from a consumer tsconfig. */
438
+ readonly kind: "configured";
439
+ /** Absolute path to the consumer's tsconfig. */
440
+ readonly configPath: string;
441
+ } | {
442
+ /** Selects Stillwind's defaults without a consumer tsconfig. */
443
+ readonly kind: "isolated";
444
+ };
445
+ /**
446
+ * Fixed filesystem and TypeScript settings shared by collections in one checker service.
447
+ */
448
+ interface TypeFactsEnvironment {
449
+ /** Absolute directory used for checker resolution and generated configuration paths. */
450
+ readonly root: string;
451
+ /** Settings inherited by the checker. Isolated projects use Stillwind's compiler defaults. */
452
+ readonly project: TypeScriptProject;
453
+ }
454
+ /**
455
+ * Selects the TypeScript environment before starting a checker.
456
+ *
457
+ * @param root - Filesystem project directory, resolved to an absolute path.
458
+ * @param tsconfig - Absolute or root-relative config path. Omission selects an existing root
459
+ * `tsconfig.json`. False selects isolated defaults even when that file exists.
460
+ * @returns Fixed settings without evaluating configuration or starting the checker.
461
+ * @throws If an explicitly selected path is empty or its configuration file does not exist.
462
+ */
463
+ declare function resolveTypeFactsEnvironment(root: string, tsconfig?: string | false): TypeFactsEnvironment;
464
+ /**
465
+ * File contents captured for one collection. Ambient declarations override overlays at matching
466
+ * paths. Prepared checker sources and the generated configuration override both maps.
467
+ */
468
+ interface TypeFactsInputs {
469
+ /** Absolute paths to replacement text. Files participate only when the checker references them. */
470
+ overlayFiles?: ReadonlyMap<string, string>;
471
+ /** Absolute declaration paths to text. Every supplied declaration becomes a project root file. */
472
+ ambientDeclarations?: ReadonlyMap<string, string>;
473
+ }
474
+ /**
475
+ * Cumulative checker lifecycle and filesystem counters for one service. They include recovery
476
+ * attempts and are not reset between collections.
477
+ */
478
+ interface TypeScriptFactsStats {
479
+ /** Number of API construction attempts, including starts after invalidation or query failure. */
480
+ starts: number;
481
+ /**
482
+ * Number of snapshot updates that returned a snapshot, including updates followed by a query
483
+ * failure.
484
+ */
485
+ snapshots: number;
486
+ /** Number of snapshot updates made while a previous snapshot was retained. */
487
+ incrementalSnapshots: number;
488
+ /** Number of recovery restarts attempted after a failure other than `TypeFactsError`. */
489
+ restarts: number;
490
+ /** Number of checker read callbacks answered with text from the virtual overlay. */
491
+ overlayReads: number;
492
+ /**
493
+ * Number of checker read callbacks delegated to the filesystem because the overlay had no text. A
494
+ * request does not imply a successful disk read.
495
+ */
496
+ diskReadRequests: number;
497
+ }
498
+ /**
499
+ * Native declaration record carrying an identity, metadata, and the original-byte range of its
500
+ * producer call.
501
+ */
502
+ type AssetRecord = NativeAssetRecord;
503
+ /** Semantic value attached to an original UTF-8 expression range for native lowering. */
504
+ type TypeFact = NativeTypeFact;
505
+ /**
506
+ * Collects declaration facts with a reusable Node checker. Close the service after pending queries finish.
507
+ */
508
+ declare class TypeScriptFactsService implements TypeFactsBackend {
509
+ #private;
510
+ /** Paths observed by disk reads and existence checks, including missing paths and overlay checks. */
511
+ readonly dependencies: Set<string>;
512
+ /**
513
+ * Live cumulative counters updated by this service. Consumers needing a stable report must copy
514
+ * their values.
515
+ */
516
+ readonly stats: TypeScriptFactsStats;
517
+ /**
518
+ * Creates a service and starts its checker process without opening a snapshot.
519
+ *
520
+ * @param environment - Fixed project root and TypeScript settings.
521
+ * @throws If the checker process cannot start.
522
+ */
523
+ constructor(environment: TypeFactsEnvironment);
524
+ /**
525
+ * Keeps project inputs for later queries and clears prepared checker buffers.
526
+ *
527
+ * @param sources - Prepared project sources, retained by reference until replaced.
528
+ * @param assets - Declarations grouped by compiler module ID, retained with the sources.
529
+ * @param inputs - File overlays and ambient declarations. Omission supplies no extra files.
530
+ * Do not mutate these inputs while they are installed. Queries select their own probes and sources.
531
+ */
532
+ setProjectSources(sources: readonly TypeFactSource[], assets: ReadonlyMap<string, readonly AssetRecord[]>, inputs?: TypeFactsInputs): void;
533
+ /**
534
+ * Collects finite declaration candidates for original-coordinate probes.
535
+ *
536
+ * Queries reuse the current snapshot when files have not changed. Mapping, assignment, and
537
+ * identity errors throw TypeFactsError. Other checker failures restart the API and retry once.
538
+ * Only diagnostics about Stillwind declaration contracts affect the result.
539
+ *
540
+ * @param sources - Prepared sources and original-byte probes, with validated projection
541
+ * correspondences where needed.
542
+ * @param assetsByModuleId - Declaration records keyed by compiler module identity.
543
+ * @param inputs - Overlays and ambient declarations for an independent query. Omission supplies none.
544
+ * When project sources are installed, preparation uses their installed inputs instead.
545
+ * @returns Facts keyed by compiler module identity. Facts for the same original range are
546
+ * deduplicated across buffers. Conflicting values throw. Known non-asset types produce null facts.
547
+ * Unresolved recognition-only probes produce no fact.
548
+ * @throws If the service is closed, preparation or checker contracts fail, or the API fails. A
549
+ * failed query retry throws an AggregateError containing both query failures.
550
+ */
551
+ collect(sources: readonly TypeFactSource[], assetsByModuleId: ReadonlyMap<string, readonly AssetRecord[]>, inputs?: TypeFactsInputs): Map<string, TypeFact[]>;
552
+ /**
553
+ * Collects verified facts, reusing the snapshot when files have not changed.
554
+ *
555
+ * @param sources - Prepared sources and original UTF-8 probes with validated checker correspondences.
556
+ * @param assetsByModuleId - Declaration records grouped by compiler module identity.
557
+ * @param inputs - Overlays and ambient declarations for an independent query. Omission supplies none.
558
+ * When project sources are installed, preparation uses their installed inputs instead.
559
+ * @returns Verified facts and unavailable original ranges. Unavailable queries do not discard
560
+ * facts collected for other expressions.
561
+ * @throws If the service is closed, project preparation fails, facts conflict, or checker restart and retry fail.
562
+ */
563
+ collectAvailable(sources: readonly TypeFactSource[], assetsByModuleId: ReadonlyMap<string, readonly AssetRecord[]>, inputs?: TypeFactsInputs): AvailableFacts;
564
+ /**
565
+ * Resolves authored imports and exports using module symbols in the selected TypeScript settings.
566
+ *
567
+ * @param sources - Prepared sources whose checker buffers contain the authored module requests.
568
+ * Independent resolution ignores probes. An installed project also prepares its probes for later queries.
569
+ * @param assetsByModuleId - Declaration records used to expose generated helper types.
570
+ * @param inputs - Overlays and ambient declarations for independent resolution. Omission supplies none.
571
+ * An installed project uses the inputs supplied by setProjectSources.
572
+ * @returns Request-to-identity maps grouped by source resolver identity. Prepared checker paths
573
+ * map back to resolver identities. Other resolutions retain checker filenames, including declarations.
574
+ * Requests without a matching module symbol are omitted.
575
+ * @throws If the service is closed, project preparation fails, or checker resolution fails.
576
+ */
577
+ resolveModules(sources: readonly TypeFactSource[], assetsByModuleId: ReadonlyMap<string, readonly AssetRecord[]>, inputs?: TypeFactsInputs): Map<string, Map<string, string>>;
578
+ /**
579
+ * Marks the service closed, disposes its retained snapshot, and closes the checker API. Repeated
580
+ * calls return without further work.
581
+ *
582
+ * @throws If snapshot disposal or API cleanup fails.
583
+ */
584
+ close(): void;
585
+ /**
586
+ * Discards cached disk contents and the retained snapshot while keeping the selected environment.
587
+ * The next collection opens a new project. Calls after close have no effect.
588
+ *
589
+ * @throws If checker cleanup or restart fails.
590
+ */
591
+ invalidate(): void;
592
+ }
593
+ /**
594
+ * Current reports and sources for the semantic graph demanded by one entry.
595
+ */
596
+ interface ModuleAnalysis {
597
+ /** Compiler identity of the entry after loading its descriptor. */
598
+ entry: string;
599
+ /** Traversal covers dependencies demanded by semantic probes, rather than all application imports. */
600
+ coverage: "observed";
601
+ /** Outputs produced by native project compilation, including diagnostic-only outputs. */
602
+ modules: ProjectModuleOutput[];
603
+ /** Structured diagnostic batches keyed by compiler module identity. */
604
+ batches: NativeDiagnosticBatch[];
605
+ /** Nonempty first fix actions in report order, excluding editor sorting actions. */
606
+ fixes: BindingEdit[][];
607
+ /** Prepared original sources retained for mapping reports, including sources that later fail scanning. */
608
+ sources: PreparedSource[];
609
+ /** Import requests and their resolution or support status observed during traversal. */
610
+ dependencies: SemanticDependency[];
611
+ /** Original UTF-8 ranges that lack information needed for semantic checks or code generation. */
612
+ unverified: UnverifiedRange[];
613
+ /** Blocked when compiler errors or missing facts needed for lowering prevent reliable code generation. */
614
+ generation: "complete" | "blocked";
615
+ }
616
+ /**
617
+ * One semantic import observed while answering an entry's type probes.
618
+ */
619
+ interface SemanticDependency {
620
+ /** Full resolver identity of the importing source. */
621
+ importer: string;
622
+ /** Authored import request text. */
623
+ specifier: string;
624
+ /** Resolved identity, when resolution succeeded. */
625
+ id?: string;
626
+ /**
627
+ * Resolved means analyzable source. External modules and dependencies handled through checker
628
+ * declarations (`types`) are not traversed. Unresolved or unsupported dependencies leave analysis incomplete.
629
+ */
630
+ status: "resolved" | "external" | "unresolved" | "unsupported" | "types";
631
+ }
632
+ /**
633
+ * Diagnostics, captured checker inputs, and generated imports for one module compilation.
634
+ */
635
+ interface ModuleCompileOptions {
636
+ /** Files captured for this compilation's semantic queries. Omission uses disk dependencies. */
637
+ typeFactsInputs?: TypeFactsInputs;
638
+ /**
639
+ * Whether compiler and checker diagnostics reject compilation or are returned in reports.
640
+ * Defaults to `throw`. Host I/O and malformed transport failures still reject in `collect` mode.
641
+ */
642
+ diagnostics?: "throw" | "collect";
643
+ /** Module specifiers injected into the entry source to activate its styles, in import order. */
644
+ stylesheetImports?: string[];
645
+ /**
646
+ * JavaScript module exporting CSS for an explicit `stillwind/module-css` import in the entry.
647
+ * Omission produces a compiler diagnostic when the entry contains that import.
648
+ */
649
+ moduleCssImport?: string;
650
+ }
651
+ /**
652
+ * A recorded answer to one loader request, keyed by importer, specifier, and options.
653
+ */
654
+ type RecordedAnswer = Omit<NativeCssFileInput, "id">;
655
+ /**
656
+ * Runs the plugins of one CSS graph and defines candidates of their dynamic families on demand.
657
+ *
658
+ * The runtime records every answer of the graph's load, so {@link PluginRuntime.replay} loads the
659
+ * same graph again without host I/O, with the definitions that plugins have added since. A
660
+ * candidate that a plugin leaves undefined is not requested again for the runtime's lifetime.
661
+ *
662
+ * Tailwind plugins of the graph share one adapter runtime, which {@link PluginRuntime.initialize}
663
+ * creates after the first load because their handlers read the complete CSS theme.
664
+ */
665
+ declare class PluginRuntime {
666
+ #private;
667
+ readonly options: NativeCompilerOptions;
668
+ readonly plugins: readonly StillwindPlugin[];
669
+ readonly root: string;
670
+ readonly host: PluginHost | undefined;
671
+ readonly watch: (path: string, kind?: PluginWatchKind) => void;
672
+ readonly previous?: PluginRuntime | undefined;
673
+ readonly settings?: TailwindSettings | undefined;
674
+ /**
675
+ * Creates a runtime for one load.
676
+ *
677
+ * @param options - Compiler options of the load, reused by {@link PluginRuntime.replay}.
678
+ * @param plugins - Plugins configured for the project, which take precedence over packages.
679
+ * @param root - Absolute project directory passed to plugins.
680
+ * @param host - Loads plugin packages and plugin files, or undefined when the host can only use
681
+ * configured plugins.
682
+ * @param watch - Registers files and directories that plugins read.
683
+ * @param previous - Runtime of an earlier load of the same project. A statement with the same
684
+ * specifier, options, and plugin resolves the earlier load's candidates of its families again.
685
+ * @param settings - Project's Tailwind settings. Either field makes the graph use the Tailwind
686
+ * plugin adapter, as a Tailwind `@plugin` statement does.
687
+ */
688
+ constructor(options: NativeCompilerOptions, plugins: readonly StillwindPlugin[], root: string, host: PluginHost | undefined, watch: (path: string, kind?: PluginWatchKind) => void, previous?: PluginRuntime | undefined, settings?: TailwindSettings | undefined);
689
+ /** Number of definition batches added after the original load. */
690
+ get generation(): number;
691
+ /** Whether project settings or a loaded plugin require the Tailwind adapter. */
692
+ get tailwind(): boolean;
693
+ /** Whether any loaded plugin declares a dynamic family. */
694
+ get dynamic(): boolean;
695
+ /**
696
+ * Records the root answer of the load.
697
+ *
698
+ * @param answer - Root input without its request ID.
699
+ */
700
+ recordRoot(answer: RecordedAnswer): void;
701
+ /**
702
+ * Records the answer to an `@import` request so that a replay can repeat it.
703
+ *
704
+ * @param request - Loader request.
705
+ * @param answer - File input supplied for it, without its request ID.
706
+ */
707
+ recordImport(request: NativeCssRequest, answer: RecordedAnswer): void;
708
+ /**
709
+ * Runs the plugin of an `@plugin` request and returns the answer for it.
710
+ *
711
+ * The answer's definitions are the user's own when the host loads the plugin from a
712
+ * relative or absolute path and `own` is true. Otherwise, they belong to the plugin that the
713
+ * specifier names, including a plugin configured for the project.
714
+ *
715
+ * @param request - Loader request whose `pluginOptions` is set.
716
+ * @param own - Whether the stylesheet that contains the statement is the user's own CSS.
717
+ * @returns File input without its request ID. Its name identifies the specifier and options.
718
+ * @throws If no plugin has the specifier's name and the host cannot load it, or the plugin fails.
719
+ */
720
+ answerPlugin(request: NativeCssRequest, own?: boolean): Promise<RecordedAnswer>;
721
+ /**
722
+ * Evaluates Tailwind handlers with the complete CSS theme, then resolves the candidates of
723
+ * dynamic families that the graph's CSS applies with `@apply` and `@variant`.
724
+ *
725
+ * Tailwind handlers run after the first load because their `theme()` calls read the complete
726
+ * CSS theme. Their output then needs one more load of the recorded graph. Dynamic candidates in
727
+ * the graph's CSS need one more load when a plugin defines any of them, with or without
728
+ * Tailwind. Canonical queries prepare spelling indexes on demand.
729
+ *
730
+ * Each later load requests the Tailwind settings after the root stylesheet, as
731
+ * {@link TailwindRuntime.settingsCss} describes.
732
+ *
733
+ * @param loader - Loader of the completed original load. With Tailwind plugins or settings, it
734
+ * can skip its canonical spelling index, as {@link PluginRuntime.tailwind} allows.
735
+ * @returns `loader` when no plugin adds CSS, and otherwise a loader with the added CSS.
736
+ * @throws If the Tailwind configuration is rejected or invalid, a plugin, a handler, or a
737
+ * callback fails, or the native loader rejects the generated CSS.
738
+ */
739
+ initialize(loader: NativeDesignSystemLoader): Promise<NativeDesignSystemLoader>;
740
+ /**
741
+ * Loads the runtime's current CSS definitions once per definition generation.
742
+ *
743
+ * @returns The shared loader for editor queries. Do not add CSS or session usage to it.
744
+ * @throws If the native loader rejects the plugin definitions.
745
+ */
746
+ snapshot(): NativeDesignSystemLoader;
747
+ /**
748
+ * Resolves one editor candidate in a separate loader without changing a session's used CSS.
749
+ *
750
+ * @param candidate - Candidate as an editor offers it, such as `probe-4` or `state-open:`.
751
+ * @returns Queries over the shared loader containing the candidate's definitions.
752
+ * @throws If a plugin fails or the native loader rejects the generated CSS.
753
+ */
754
+ query(candidate: string): Promise<NativeEditorQuery>;
755
+ /**
756
+ * Passes new candidates to the plugins that declare their families.
757
+ *
758
+ * @param candidates - Compiler requests for native utility names, complete Tailwind utility
759
+ * keys, or variant names with an `@variant ` prefix. Previously requested keys are skipped.
760
+ * @returns Whether any plugin returned CSS, so that the design system must be loaded again.
761
+ * @throws If a plugin fails.
762
+ */
763
+ resolve(candidates: Iterable<string>): Promise<boolean>;
764
+ /**
765
+ * Lists the candidates that editors complete for the loaded dynamic families.
766
+ *
767
+ * @param input - Utility text before an editor's cursor, without variants, or an empty string
768
+ * for the candidates that editors always offer.
769
+ * @returns Candidate names that start with `input`, from every plugin with a catalog, sorted
770
+ * and deduplicated. Names that end with `-` are incomplete. The runtime keeps the answers for
771
+ * the empty input and for the {@link CATALOG_INPUTS} most recent other inputs.
772
+ */
773
+ catalog(input?: string): Promise<readonly string[]>;
774
+ /**
775
+ * Loads the recorded graph again into a loader of `session`, with the current definitions.
776
+ *
777
+ * @param session - Session whose source IDs the new loader shares. Omission shares the
778
+ * original loader's source IDs.
779
+ * @param intermediate - Skips preparing the canonical spelling index for a loader that only
780
+ * serves a later load or a short query. Canonical queries still prepare it on first use.
781
+ * @returns A complete loader with the load's compiler options, for
782
+ * {@link NativeProjectSession.reload}.
783
+ * @throws If the recorded graph is incomplete or the native loader rejects it.
784
+ */
785
+ replay(session?: NativeProjectSession, intermediate?: boolean): NativeDesignSystemLoader;
786
+ }
787
+ /**
788
+ * Runs source editor requests and sorting diagnostics against captured compiler output.
789
+ */
790
+ declare class EditorSnapshot {
791
+ #private;
792
+ /**
793
+ * Captures recognized producers and compiler output for one set of source revisions.
794
+ * Copies source metadata, dependencies, fix actions, and sorting settings before indexing them.
795
+ * Building the source index also scans graph sources in the session.
796
+ *
797
+ * @param graph - Original sources, demanded dependencies, emitted CSS, and lint reports.
798
+ * @param session - Session that compiled the graph and recognizes its producer identities.
799
+ * @param loader - Completed design system with the same compiler options as the session.
800
+ * @param config - Sorting targets and preview comments to capture. Effective lint policy comes
801
+ * from the loader.
802
+ * @param catalog - Finite plugin candidates offered without running their callbacks.
803
+ * @param plugins - Runtime for resolving selected plugin completions without changing the session.
804
+ * @throws If source transport, a projection map, or an original UTF-8 boundary is invalid.
805
+ */
806
+ constructor(graph: ModuleAnalysis, session: NativeProjectSession, loader: NativeDesignSystemLoader, config: BaseConfig & {
807
+ preview?: PreviewOptions;
808
+ }, catalog?: readonly string[], plugins?: PluginRuntime);
809
+ /**
810
+ * Loads plugin suggestions for a completion input, and callback-generated CSS for a selected
811
+ * completion from this captured snapshot, so that a following {@link EditorSnapshot.query} can
812
+ * use them. Other requests are ignored.
813
+ *
814
+ * @param id - Full resolver identity of the requested source.
815
+ * @param request - Editor request. A `completion` request loads the plugin suggestions for the
816
+ * candidate at its cursor. A `resolve` request for this snapshot's revision loads CSS, once for
817
+ * each candidate.
818
+ * @throws If a plugin fails or the native loader rejects the generated CSS.
819
+ */
820
+ prepare(id: string, request: EditorRequest): Promise<void>;
821
+ /**
822
+ * Computes sorting diagnostics for all graph sources and caches them by module identity.
823
+ * Effective lint severity and source suppression determine which reports are returned.
824
+ * Compilation reports already present in the graph remain separate.
825
+ *
826
+ * @returns Independent copies of sorting reports for the captured sources.
827
+ * @throws If candidate ranking fails or native report construction rejects a source URI or range.
828
+ */
829
+ reports(): BindingReport[];
830
+ /**
831
+ * Queries a source by resolver identity. Unknown or unmapped positions produce no data.
832
+ * Queries may populate caches, and returned edits leave the original document unchanged.
833
+ *
834
+ * @param id - Full resolver identity captured in the graph, including any query suffix.
835
+ * @param request - Operation and positions in the original document's UTF-16 coordinate space.
836
+ * Completion resolution must reuse the candidate, input boundary, and snapshot fingerprint.
837
+ * @returns Data with the original source fingerprint, or undefined for an unknown source.
838
+ * A known source with no applicable answer returns a result with the relevant field absent or empty.
839
+ * @throws If native candidate resolution, CSS formatting, or lint suppression checks fail.
840
+ */
841
+ query(id: string, request: EditorRequest): EditorResult | undefined;
842
+ }
843
+ export { PluginPathCompletion as C, EditorRequest as D, EditorEdit as E, EditorResult as O, defaultPluginExport as S, EditorCompletion as T, TypeFactsBackend as _, SemanticDependency as a, PluginHost as b, TypeScriptFactsStats as c, TypeScriptProject as d, resolveTypeFactsEnvironment as f, TypeFactSource as g, SemanticInputs as h, ModuleCompileOptions as i, TypeFactsEnvironment as l, CheckerSpan as m, PluginRuntime as n, TypeFact as o, AvailableFacts as p, ModuleAnalysis as r, TypeScriptFactsService as s, EditorSnapshot as t, TypeFactsInputs as u, TypeFactsError as v, EditorColor as w, TailwindSettings as x, UnverifiedRange as y };
844
+ //# sourceMappingURL=index-CprPvXxv.d.ts.map