@stillwind/host 0.11.0 → 0.13.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.
@@ -1,3 +1,124 @@
1
+ // src/css/plugins/tailwind/segment.ts
2
+ /**
3
+ * Splits text at a separator outside quotes and bracket groups, as Tailwind's `segment()` does.
4
+ *
5
+ * A backslash escapes the next character. A `'` or `"` starts a string that ends at the same
6
+ * quote, and backslashes escape characters inside it. `(`, `[`, and `{` open groups that only
7
+ * their own closer ends. A closer that does not match the innermost open group is ignored.
8
+ *
9
+ * @param input - Text to split.
10
+ * @param separator - One character, such as `,`, `/`, or ` `. Its first UTF-16 code unit is
11
+ * compared.
12
+ * @returns The parts without trimming, including empty ones. Text without the separator is one
13
+ * part.
14
+ */
15
+ function segment(input, separator) {
16
+ const closers = [];
17
+ const parts = [];
18
+ const delimiter = separator.charCodeAt(0);
19
+ let start = 0;
20
+ for (let index = 0; index < input.length; index++) {
21
+ const code = input.charCodeAt(index);
22
+ if (closers.length === 0 && code === delimiter) {
23
+ parts.push(input.slice(start, index));
24
+ start = index + 1;
25
+ continue;
26
+ }
27
+ index = skip(input, index, code, closers);
28
+ }
29
+ parts.push(input.slice(start));
30
+ return parts;
31
+ }
32
+ /**
33
+ * Whether an arbitrary value is usable, as Tailwind's `isValidArbitrary()` decides.
34
+ *
35
+ * The value is rejected when it has a `;` outside groups, a `)` or `]` that does not close the
36
+ * innermost group, a closer without an open group, or an unclosed `(` or `[`. A `{` opens no group,
37
+ * so a `}` is rejected outside groups and ignored inside them.
38
+ *
39
+ * @param input - Decoded arbitrary value.
40
+ * @returns Whether Tailwind accepts the value.
41
+ */
42
+ function isValidArbitrary(input) {
43
+ const closers = [];
44
+ for (let index = 0; index < input.length; index++) {
45
+ const code = input.charCodeAt(index);
46
+ switch (code) {
47
+ case BACKSLASH:
48
+ case SINGLE_QUOTE:
49
+ case DOUBLE_QUOTE:
50
+ index = skip(input, index, code, closers);
51
+ break;
52
+ case OPEN_PAREN:
53
+ closers.push(CLOSE_PAREN);
54
+ break;
55
+ case OPEN_BRACKET:
56
+ closers.push(CLOSE_BRACKET);
57
+ break;
58
+ case CLOSE_BRACKET:
59
+ case CLOSE_CURLY:
60
+ case CLOSE_PAREN:
61
+ if (closers.length === 0) return false;
62
+ if (code === closers.at(-1)) closers.pop();
63
+ else if (code !== CLOSE_CURLY) return false;
64
+ break;
65
+ case SEMICOLON: if (closers.length === 0) return false;
66
+ }
67
+ }
68
+ return closers.length === 0;
69
+ }
70
+ const BACKSLASH = 92;
71
+ const SINGLE_QUOTE = 39;
72
+ const DOUBLE_QUOTE = 34;
73
+ const OPEN_PAREN = 40;
74
+ const CLOSE_PAREN = 41;
75
+ const OPEN_BRACKET = 91;
76
+ const CLOSE_BRACKET = 93;
77
+ const OPEN_CURLY = 123;
78
+ const CLOSE_CURLY = 125;
79
+ const SEMICOLON = 59;
80
+ /**
81
+ * Reads one character of {@link segment} outside a string.
82
+ *
83
+ * @param input - Scanned text.
84
+ * @param index - Index of the character.
85
+ * @param code - UTF-16 code unit at `index`.
86
+ * @param closers - Closers of the open groups, innermost last. A group opener pushes its closer,
87
+ * and a matching closer pops it.
88
+ * @returns The index of the last character that the call consumed: after an escape, the escaped
89
+ * character, and after a quote, its closing quote or the last character of `input`.
90
+ */
91
+ function skip(input, index, code, closers) {
92
+ switch (code) {
93
+ case BACKSLASH: return index + 1;
94
+ case SINGLE_QUOTE:
95
+ case DOUBLE_QUOTE:
96
+ while (++index < input.length) {
97
+ const next = input.charCodeAt(index);
98
+ if (next === BACKSLASH) {
99
+ index += 1;
100
+ continue;
101
+ }
102
+ if (next === code) break;
103
+ }
104
+ return index;
105
+ case OPEN_PAREN:
106
+ closers.push(CLOSE_PAREN);
107
+ return index;
108
+ case OPEN_BRACKET:
109
+ closers.push(CLOSE_BRACKET);
110
+ return index;
111
+ case OPEN_CURLY:
112
+ closers.push(CLOSE_CURLY);
113
+ return index;
114
+ case CLOSE_BRACKET:
115
+ case CLOSE_CURLY:
116
+ case CLOSE_PAREN:
117
+ if (closers.length > 0 && code === closers.at(-1)) closers.pop();
118
+ return index;
119
+ default: return index;
120
+ }
121
+ }
1
122
  // src/css/plugins/tailwind/css.ts
2
123
  /**
3
124
  * Serializes a plugin CSS object, as plugins pass it to Tailwind's API, while preserving
@@ -214,7 +335,7 @@ function utilityRules(input, register, global, wrappers = []) {
214
335
  for (const [selector, body] of Object.entries(input)) if (selector.startsWith("@keyframes ") || selector.startsWith("@property ")) global(wrap(`${selector}{${serializeCss(body)}}`));
215
336
  else if (scopeRule(selector)) throw new Error(`Tailwind plugin utility selectors cannot be nested in @scope outside a selector: ${selector}`);
216
337
  else if (selector.startsWith("@")) utilityRules(body, register, global, [...wrappers, selector]);
217
- else for (const branch of splitTopLevel(selector, ",").map((part) => part.trim())) {
338
+ else for (const branch of segment(selector, ",").map((part) => part.trim())) {
218
339
  const classes = utilityClasses(branch);
219
340
  if (!classes.length) throw new Error(`Tailwind plugin utility requires a class selector: ${selector}`);
220
341
  for (const anchor of classes) {
@@ -287,49 +408,12 @@ function utilityBodies(input, selector = "&", conditions = []) {
287
408
  if (key.startsWith("@keyframes ") || key.startsWith("@property ")) result.push(conditions.reduceRight((body, condition) => `${condition}{${body}}`, `${key}{${serializeCss(value)}}`));
288
409
  else if (scopeRule(key)) place(`${key}{${serializeCss(value)}}`);
289
410
  else if (key.startsWith("@")) result.push(...utilityBodies(value, selector, [...conditions, key]));
290
- else for (const parent of splitTopLevel(selector, ",").map((part) => part.trim())) for (const child of splitTopLevel(key, ",").map((part) => part.trim())) result.push(...utilityBodies(value, substituteNesting(child, parent) ?? `${parent} ${child}`, conditions));
411
+ else for (const parent of segment(selector, ",").map((part) => part.trim())) for (const child of segment(key, ",").map((part) => part.trim())) result.push(...utilityBodies(value, substituteNesting(child, parent) ?? `${parent} ${child}`, conditions));
291
412
  } else declarations[key] = value;
292
413
  flush();
293
414
  return result;
294
415
  }
295
416
  /**
296
- * Splits text at a delimiter outside CSS strings, brackets, and function calls.
297
- *
298
- * @param value - Text to split. Escaped characters never delimit.
299
- * @param delimiter - One character, such as `,` or `/`.
300
- * @returns The parts without trimming, including empty ones. Text without the delimiter is one
301
- * part.
302
- */
303
- function splitTopLevel(value, delimiter) {
304
- const parts = [];
305
- let start = 0;
306
- let depth = 0;
307
- let quote = "";
308
- for (let index = 0; index < value.length; index++) {
309
- const char = value[index];
310
- if (char === "\\") {
311
- index++;
312
- continue;
313
- }
314
- if (quote) {
315
- if (char === quote) quote = "";
316
- continue;
317
- }
318
- if (char === "\"" || char === "'") {
319
- quote = char;
320
- continue;
321
- }
322
- if (char === "[" || char === "(") depth++;
323
- else if (char === "]" || char === ")") depth--;
324
- else if (depth === 0 && char === delimiter) {
325
- parts.push(value.slice(start, index));
326
- start = index + 1;
327
- }
328
- }
329
- parts.push(value.slice(start));
330
- return parts;
331
- }
332
- /**
333
417
  * Converts the declarations of a Tailwind `@plugin` options block into the values that
334
418
  * `plugin.withOptions()` factories receive.
335
419
  *
@@ -342,7 +426,7 @@ function splitTopLevel(value, delimiter) {
342
426
  function pluginOptions(options) {
343
427
  const result = {};
344
428
  for (const { name, value: text } of options) {
345
- const entries = splitTopLevel(text, ",").map((part) => {
429
+ const entries = segment(text, ",").map((part) => {
346
430
  const value = part.trim();
347
431
  if (value === "true") return true;
348
432
  if (value === "false") return false;
@@ -418,6 +502,6 @@ function darkModeVariant(setting) {
418
502
  default: return;
419
503
  }
420
504
  }
421
- export { splitTopLevel as a, withAlpha as c, configurePlugin, darkModeVariant, serializeCss as i, identifier as n, utilityBodies as o, selectorRules as r, resolveConfig, utilityRules as s, cssString as t };
505
+ export { utilityBodies as a, isValidArbitrary as c, configurePlugin, darkModeVariant, serializeCss as i, segment as l, identifier as n, utilityRules as o, selectorRules as r, resolveConfig, withAlpha as s, cssString as t };
422
506
 
423
- //# sourceMappingURL=configuration-MQZe6ufN.js.map
507
+ //# sourceMappingURL=configuration-BckWlAj2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration-BckWlAj2.js","names":[],"sources":["../src/css/plugins/tailwind/segment.ts","../src/css/plugins/tailwind/css.ts","../src/css/plugins/tailwind/configuration.ts"],"sourcesContent":["// Ported from Tailwind CSS 4.3.5 (MIT), utils/segment.ts and utils/is-valid-arbitrary.ts. Keep\n// the scanning rules aligned with upstream: Tailwind splits plugin selectors, candidate parts, and\n// arbitrary values with them, so a CSS tokenizer would accept or split text that Tailwind does not.\n\n/**\n * Splits text at a separator outside quotes and bracket groups, as Tailwind's `segment()` does.\n *\n * A backslash escapes the next character. A `'` or `\"` starts a string that ends at the same\n * quote, and backslashes escape characters inside it. `(`, `[`, and `{` open groups that only\n * their own closer ends. A closer that does not match the innermost open group is ignored.\n *\n * @param input - Text to split.\n * @param separator - One character, such as `,`, `/`, or ` `. Its first UTF-16 code unit is\n * compared.\n * @returns The parts without trimming, including empty ones. Text without the separator is one\n * part.\n */\nexport function segment(input: string, separator: string): string[] {\n const closers: number[] = [];\n const parts: string[] = [];\n const delimiter = separator.charCodeAt(0);\n let start = 0;\n for (let index = 0; index < input.length; index++) {\n const code = input.charCodeAt(index);\n if (closers.length === 0 && code === delimiter) {\n parts.push(input.slice(start, index));\n start = index + 1;\n continue;\n }\n index = skip(input, index, code, closers);\n }\n parts.push(input.slice(start));\n return parts;\n}\n\n/**\n * Whether an arbitrary value is usable, as Tailwind's `isValidArbitrary()` decides.\n *\n * The value is rejected when it has a `;` outside groups, a `)` or `]` that does not close the\n * innermost group, a closer without an open group, or an unclosed `(` or `[`. A `{` opens no group,\n * so a `}` is rejected outside groups and ignored inside them.\n *\n * @param input - Decoded arbitrary value.\n * @returns Whether Tailwind accepts the value.\n */\nexport function isValidArbitrary(input: string): boolean {\n const closers: number[] = [];\n for (let index = 0; index < input.length; index++) {\n const code = input.charCodeAt(index);\n switch (code) {\n case BACKSLASH:\n case SINGLE_QUOTE:\n case DOUBLE_QUOTE:\n index = skip(input, index, code, closers);\n break;\n\n case OPEN_PAREN:\n closers.push(CLOSE_PAREN);\n break;\n\n case OPEN_BRACKET:\n closers.push(CLOSE_BRACKET);\n break;\n\n case CLOSE_BRACKET:\n case CLOSE_CURLY:\n case CLOSE_PAREN:\n if (closers.length === 0) {\n return false;\n }\n if (code === closers.at(-1)) {\n closers.pop();\n } else if (code !== CLOSE_CURLY) {\n return false;\n }\n break;\n\n case SEMICOLON:\n if (closers.length === 0) {\n return false;\n }\n break;\n }\n }\n return closers.length === 0;\n}\n\nconst BACKSLASH = 0x5c;\nconst SINGLE_QUOTE = 0x27;\nconst DOUBLE_QUOTE = 0x22;\nconst OPEN_PAREN = 0x28;\nconst CLOSE_PAREN = 0x29;\nconst OPEN_BRACKET = 0x5b;\nconst CLOSE_BRACKET = 0x5d;\nconst OPEN_CURLY = 0x7b;\nconst CLOSE_CURLY = 0x7d;\nconst SEMICOLON = 0x3b;\n\n/**\n * Reads one character of {@link segment} outside a string.\n *\n * @param input - Scanned text.\n * @param index - Index of the character.\n * @param code - UTF-16 code unit at `index`.\n * @param closers - Closers of the open groups, innermost last. A group opener pushes its closer,\n * and a matching closer pops it.\n * @returns The index of the last character that the call consumed: after an escape, the escaped\n * character, and after a quote, its closing quote or the last character of `input`.\n */\nfunction skip(input: string, index: number, code: number, closers: number[]): number {\n switch (code) {\n case BACKSLASH:\n return index + 1;\n\n case SINGLE_QUOTE:\n case DOUBLE_QUOTE:\n while (++index < input.length) {\n const next = input.charCodeAt(index);\n if (next === BACKSLASH) {\n index += 1;\n continue;\n }\n if (next === code) {\n break;\n }\n }\n return index;\n\n case OPEN_PAREN:\n closers.push(CLOSE_PAREN);\n return index;\n\n case OPEN_BRACKET:\n closers.push(CLOSE_BRACKET);\n return index;\n\n case OPEN_CURLY:\n closers.push(CLOSE_CURLY);\n return index;\n\n case CLOSE_BRACKET:\n case CLOSE_CURLY:\n case CLOSE_PAREN:\n if (closers.length > 0 && code === closers.at(-1)) {\n closers.pop();\n }\n return index;\n\n default:\n return index;\n }\n}\n","import type { NativePluginOption } from \"@stillwind/native\";\n\nimport { segment } from \"./segment.ts\";\n\n/**\n * Serializes a plugin CSS object, as plugins pass it to Tailwind's API, while preserving\n * repeated declarations and nested rules.\n *\n * @param input - CSS-in-JS object or array of them. An array value of a property repeats the\n * declaration, camel-case property names become kebab-case, and null, undefined, and false\n * values are skipped. `@slot` keys and values become `@slot` statements.\n * @returns CSS declarations and rules without surrounding braces, or an empty string for input\n * that is not an object.\n */\nexport function serializeCss(input: unknown): string {\n if (Array.isArray(input)) {\n return input.map(serializeCss).join(\"\\n\");\n }\n if (!input || typeof input !== \"object\") {\n return \"\";\n }\n let output = \"\";\n for (const [key, value] of Object.entries(input)) {\n if (value === null || value === undefined || value === false) {\n continue;\n }\n if (key === \"@slot\") {\n output += \"@slot;\";\n continue;\n }\n if (!key.startsWith(\"--\") && value === \"@slot\") {\n output += `${key}{@slot;}`;\n continue;\n }\n if (statement(key, value)) {\n output += `${key};`;\n continue;\n }\n const values = Array.isArray(value) ? value : [value];\n for (const entry of values) {\n if (entry && typeof entry === \"object\") {\n output += `${key}{${serializeCss(entry)}}`;\n } else if (entry !== null && entry !== undefined && entry !== false) {\n const property = key.startsWith(\"--\")\n ? key\n : key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`).replace(/^ms-/, \"-ms-\");\n output += `${property}:${String(entry)};`;\n }\n }\n }\n return output;\n}\n\n/**\n * Whether an entry is an at-rule without a block, such as `{ \"@apply p-4\": {} }`, which\n * Tailwind serializes as the statement `@apply p-4;`.\n *\n * @param key - Entry key.\n * @param value - Entry value.\n * @returns Whether the key is an at-rule and the value an empty object.\n */\nfunction statement(key: string, value: unknown): boolean {\n return (\n key.startsWith(\"@\") &&\n typeof value === \"object\" &&\n value !== null &&\n !Array.isArray(value) &&\n Object.keys(value).length === 0\n );\n}\n\n/**\n * Escapes a complete candidate as one CSS identifier, including arbitrary-value punctuation.\n *\n * @param value - Candidate or variant name, such as `-probe-[3px]/mirror`.\n * @returns An identifier whose CSS escapes decode to `value`. A leading digit becomes a\n * six-digit hexadecimal escape.\n */\nexport function identifier(value: string): string {\n return Array.from(value)\n .map((character, index) => {\n if (/[_a-zA-Z\\u0080-\\uffff-]/u.test(character) || (index > 0 && /\\d/.test(character))) {\n return character;\n }\n if (/\\d/.test(character)) {\n return `\\\\${character.codePointAt(0)!.toString(16).padStart(6, \"0\")}`;\n }\n return `\\\\${character}`;\n })\n .join(\"\");\n}\n\n/**\n * Applies an alpha value to a color as Tailwind's `withAlpha()` does.\n *\n * Every plain number is multiplied by 100, so `0.5` means 50% and `50` means 5000%, which\n * `color-mix()` rejects. Tailwind applies this to the `/50` of `theme(\"colors.red.500 / 50\")`,\n * while a `/50` color modifier of a utility arrives here already as `50%`.\n *\n * @param value - CSS color.\n * @param alpha - Number, percentage, or other CSS value such as `var(--opacity)`.\n * @returns The color itself for `100%`, and a `color-mix()` toward transparent otherwise.\n */\nexport function withAlpha(value: string, alpha: string): string {\n const number = Number(alpha);\n const percentage = Number.isNaN(number) ? alpha : `${number * 100}%`;\n return percentage === \"100%\" ? value : `color-mix(in oklab, ${value} ${percentage}, transparent)`;\n}\n\n/** Class names that Tailwind's `addUtilities()` registers. */\nconst IS_VALID_UTILITY_NAME = /^[a-z@][a-zA-Z0-9/%._-]*$/;\n\n/**\n * Finds the classes that a plugin selector registers, as Tailwind's `addUtilities()` does: every\n * class outside attribute selectors and outside the arguments of `:not()`, `:nth-child()`, and\n * `:nth-last-child()`, whose classes are conditions rather than utilities. `.outer .inner`\n * registers both `outer` and `inner`.\n *\n * @param selector - One complex selector without top-level commas.\n * @returns The decoded class names with the range of each `.name`, in source order.\n */\nfunction utilityClasses(selector: string): { name: string; start: number; end: number }[] {\n const classes: {\n name: string;\n start: number;\n end: number;\n }[] = [];\n const parentheses: boolean[] = [];\n let excluded = 0;\n let attribute = 0;\n let quote = \"\";\n for (let index = 0; index < selector.length; index++) {\n const char = selector[index];\n if (char === \"\\\\\") {\n index++;\n } else if (quote) {\n quote = char === quote ? \"\" : quote;\n } else if (char === '\"' || char === \"'\") {\n quote = char;\n } else if (char === \"[\") {\n attribute++;\n } else if (char === \"]\") {\n attribute--;\n } else if (char === \"(\") {\n const condition = /:(?:not|nth-child|nth-last-child)$/i.test(selector.slice(0, index));\n parentheses.push(condition);\n excluded += condition ? 1 : 0;\n } else if (char === \")\") {\n excluded -= parentheses.pop() ? 1 : 0;\n } else if (char === \".\" && !excluded && !attribute) {\n const { name, end } = readIdentifier(selector, index + 1);\n if (IS_VALID_UTILITY_NAME.test(name)) {\n classes.push({\n name,\n start: index,\n end,\n });\n }\n index = end - 1;\n }\n }\n return classes;\n}\n\n/**\n * Reads a CSS identifier and decodes its escapes.\n *\n * @param text - Text that contains the identifier.\n * @param start - Index of the first character of the identifier.\n * @returns The decoded name, empty when no identifier starts at `start`, and the index after it.\n */\nfunction readIdentifier(text: string, start: number): { name: string; end: number } {\n let end = start;\n let name = \"\";\n while (end < text.length) {\n const next = text[end];\n if (next === \"\\\\\") {\n const hex = /^[0-9a-f]{1,6}\\s?/i.exec(text.slice(end + 1));\n name += hex ? String.fromCodePoint(Number.parseInt(hex[0], 16)) : text[end + 1];\n end += 1 + (hex ? hex[0].length : 1);\n } else if (/[\\w\\u0080-￿-]/u.test(next)) {\n name += next;\n end++;\n } else {\n break;\n }\n }\n return {\n name,\n end,\n };\n}\n\n/**\n * Serializes text as a CSS string.\n *\n * @param value - Text, such as generated CSS.\n * @returns A double-quoted CSS string whose escapes decode to `value`.\n */\nexport function cssString(value: string): string {\n return `\"${value\n .replace(/[\"\\\\]/g, \"\\\\$&\")\n .replace(/[\\n\\r\\f]/g, (character) => `\\\\${character.codePointAt(0)!.toString(16)} `)}\"`;\n}\n\n/**\n * Replaces every `&` outside strings and attribute selectors.\n *\n * @param selector - Selector that may contain `&`.\n * @param parent - Replacement for `&`.\n * @returns The selector with the parent substituted, or undefined when it has no `&`.\n */\nfunction substituteNesting(selector: string, parent: string): string | undefined {\n let output = \"\";\n let nested = false;\n let attribute = 0;\n let quote = \"\";\n for (let index = 0; index < selector.length; index++) {\n const char = selector[index];\n if (char === \"\\\\\") {\n output += selector.slice(index, index + 2);\n index++;\n continue;\n }\n if (quote) {\n quote = char === quote ? \"\" : quote;\n } else if (char === '\"' || char === \"'\") {\n quote = char;\n } else if (char === \"[\") {\n attribute++;\n } else if (char === \"]\") {\n attribute--;\n } else if (char === \"&\" && !attribute) {\n output += parent;\n nested = true;\n continue;\n }\n output += char;\n }\n return nested ? output : undefined;\n}\n\n/**\n * Converts the rules that `addUtilities()` receives into utility bodies. At-rules retain their\n * enclosing conditions.\n *\n * @param input - CSS-in-JS object keyed by selectors and at-rules, or an array of them.\n * @param register - Receives the anchor class of a selector and one body for it, once for each\n * selector of the body.\n * @param global - Receives top-level `@keyframes` and `@property` rules, which apply whether or\n * not a utility is used. The compiler emits such rules nested in a utility body only with that\n * utility.\n * @param wrappers - Enclosing at-rule preludes, outermost first.\n * @throws If a selector has no class outside `:not()` and attribute selectors, or if an\n * `@scope` rule encloses a selector.\n */\nexport function utilityRules(\n input: unknown,\n register: (name: string, body: string) => void,\n global: (css: string) => void,\n wrappers: string[] = [],\n): void {\n if (Array.isArray(input)) {\n for (const entry of input) {\n utilityRules(entry, register, global, wrappers);\n }\n return;\n }\n if (!input || typeof input !== \"object\") {\n return;\n }\n /**\n * Wraps CSS in the enclosing at-rules.\n * @param body - CSS inside the innermost at-rule.\n * @returns The wrapped CSS.\n */\n const wrap = (body: string) => wrappers.reduceRight((css, rule) => `${rule}{${css}}`, body);\n for (const [selector, body] of Object.entries(input)) {\n if (selector.startsWith(\"@keyframes \") || selector.startsWith(\"@property \")) {\n global(wrap(`${selector}{${serializeCss(body)}}`));\n } else if (scopeRule(selector)) {\n // A utility body is nested in its class rule, and nesting changes `@scope` there:\n // `.item{@scope (.theme){color:red}}` colors `.theme` elements inside `.item`, while\n // `@scope (.theme){.item{color:red}}` colors `.item` elements inside `.theme`.\n throw new Error(\n `Tailwind plugin utility selectors cannot be nested in @scope outside a selector: ${selector}`,\n );\n } else if (selector.startsWith(\"@\")) {\n utilityRules(body, register, global, [...wrappers, selector]);\n } else {\n for (const branch of segment(selector, \",\").map((part) => part.trim())) {\n const classes = utilityClasses(branch);\n if (!classes.length) {\n throw new Error(`Tailwind plugin utility requires a class selector: ${selector}`);\n }\n // Each class becomes `&` in its own registration and stays literal in the others.\n for (const anchor of classes) {\n const relative = `${branch.slice(0, anchor.start)}&${branch.slice(anchor.end)}`;\n for (const css of utilityBodies(body, relative, wrappers)) {\n register(anchor.name, css);\n }\n }\n }\n }\n }\n}\n\n/**\n * Whether a CSS-in-JS key is an `@scope` rule.\n *\n * @param key - Entry key.\n * @returns Whether the key is `@scope` with or without a prelude.\n */\nfunction scopeRule(key: string): boolean {\n return /^@scope(?![\\w-])/.test(key);\n}\n\n/**\n * Lists the selectors of the nested rules in CSS-in-JS input, each as an empty rule, so that\n * the compiler can collect the classes that they name without the declarations.\n *\n * @param input - CSS-in-JS body, or an array of them.\n * @returns Each selector key as written followed by `{}`, in source order. Selectors inside\n * conditional at-rules are included, and `@keyframes` and `@property` rules are skipped.\n */\nexport function selectorRules(input: unknown): string[] {\n if (Array.isArray(input)) {\n return input.flatMap(selectorRules);\n }\n if (!input || typeof input !== \"object\") {\n return [];\n }\n const rules: string[] = [];\n for (const [key, value] of Object.entries(input)) {\n // An array of strings is a declaration with fallback values, as in `utilityBodies`.\n if (\n !value ||\n typeof value !== \"object\" ||\n statement(key, value) ||\n (Array.isArray(value) && !value.some((entry) => entry && typeof entry === \"object\")) ||\n key.startsWith(\"@keyframes \") ||\n key.startsWith(\"@property \")\n ) {\n continue;\n }\n if (!key.startsWith(\"@\")) {\n rules.push(`${key}{}`);\n }\n rules.push(...selectorRules(value));\n }\n return rules;\n}\n\n/**\n * Flattens nested selector rules into utility bodies with one selector block each, which the\n * compiler composes as independent targets.\n *\n * @param input - CSS-in-JS body, or an array of them.\n * @param selector - Selector of the body relative to the utility class, `&` for the class itself.\n * @param conditions - Enclosing at-rule preludes, outermost first.\n * @returns Bodies in source order. Each one is either declarations, possibly inside\n * conditions, for `&`, one rule for another selector, one `@scope` rule with its nested rules\n * for `&` or another selector, or one `@keyframes` or `@property` rule inside its conditions.\n */\nexport function utilityBodies(input: unknown, selector = \"&\", conditions: string[] = []): string[] {\n if (Array.isArray(input)) {\n return input.flatMap((entry) => utilityBodies(entry, selector, conditions));\n }\n if (!input || typeof input !== \"object\") {\n return [];\n }\n const result: string[] = [];\n let declarations: Record<string, unknown> = {};\n /**\n * Adds CSS as one body for the current selector inside the current conditions.\n *\n * @param css - Declarations or rules for the current selector.\n */\n const place = (css: string) => {\n const body = conditions.reduceRight((body, condition) => `${condition}{${body}}`, css);\n result.push(selector === \"&\" ? body : `${selector}{${body}}`);\n };\n /** Adds the declarations collected so far as one body and starts a new collection. */\n const flush = () => {\n const css = serializeCss(declarations);\n if (css) {\n place(css);\n }\n declarations = {};\n };\n for (const [key, value] of Object.entries(input)) {\n if (\n value &&\n typeof value === \"object\" &&\n !statement(key, value) &&\n (!Array.isArray(value) || value.some((entry) => entry && typeof entry === \"object\"))\n ) {\n flush();\n if (key.startsWith(\"@keyframes \") || key.startsWith(\"@property \")) {\n result.push(\n conditions.reduceRight(\n (body, condition) => `${condition}{${body}}`,\n `${key}{${serializeCss(value)}}`,\n ),\n );\n } else if (scopeRule(key)) {\n // Nested rules stay inside `@scope`, because `:scope` in a selector means the scoping\n // root only there. Moved out, `:where(:scope > :first-child)` from `@scope (&)` becomes\n // the prelude `& :where(:scope > :first-child)`, where `:scope` matches `:root`.\n place(`${key}{${serializeCss(value)}}`);\n } else if (key.startsWith(\"@\")) {\n result.push(...utilityBodies(value, selector, [...conditions, key]));\n } else {\n // Each target keeps one selector, because a utility body holds one selector block.\n for (const parent of segment(selector, \",\").map((part) => part.trim())) {\n for (const child of segment(key, \",\").map((part) => part.trim())) {\n result.push(\n ...utilityBodies(\n value,\n substituteNesting(child, parent) ?? `${parent} ${child}`,\n conditions,\n ),\n );\n }\n }\n }\n } else {\n declarations[key] = value;\n }\n }\n flush();\n return result;\n}\n\n/**\n * Converts the declarations of a Tailwind `@plugin` options block into the values that\n * `plugin.withOptions()` factories receive.\n *\n * @param options - Declarations in authored order, such as `prefix` with the value `\"x\"`.\n * @returns Options by name, converted as Tailwind converts them. A later declaration of a\n * name replaces an earlier one. `true`, `false`, `null`, and numeric text become those values.\n * A quoted string loses its quotes and keeps its backslashes. Other text stays a string, and a\n * comma-separated list becomes an array.\n */\nexport function pluginOptions(options: readonly NativePluginOption[]): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const { name, value: text } of options) {\n const entries = segment(text, \",\").map((part) => {\n const value = part.trim();\n if (value === \"true\") {\n return true;\n }\n if (value === \"false\") {\n return false;\n }\n if (value === \"null\") {\n return null;\n }\n if (!Number.isNaN(Number(value))) {\n return Number(value);\n }\n return (value.startsWith('\"') && value.endsWith('\"')) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\"))\n ? value.slice(1, -1)\n : value;\n });\n result[name] = entries.length === 1 ? entries[0] : entries;\n }\n return result;\n}\n","import type { NativePluginOption } from \"@stillwind/native\";\nimport type { PluginCreator, PluginWithConfig } from \"tailwindcss/plugin\";\n\nimport type { TailwindPlugin } from \"../host.ts\";\nimport { pluginOptions } from \"./css.ts\";\n\n/**\n * Normalizes a Tailwind plugin export to `{ handler, config }` and applies the options of its\n * `@plugin` statement.\n *\n * @param plugin - Handler, `{ handler, config }`, or factory from `plugin.withOptions()`.\n * @param options - Declarations of the statement's options block, empty without a block.\n * @returns The factory's result for converted `options`, or the plugin in object form.\n * @throws If a handler that is not a factory receives options, or an option value is invalid.\n */\nexport function configurePlugin(\n plugin: TailwindPlugin,\n options: readonly NativePluginOption[],\n): PluginWithConfig {\n if (\n typeof plugin === \"function\" &&\n \"__isOptionsFunction\" in plugin &&\n plugin.__isOptionsFunction\n ) {\n return (plugin as unknown as (options: Record<string, unknown>) => PluginWithConfig)(\n pluginOptions(options),\n );\n }\n if (options.length) {\n throw new Error(\"This Tailwind plugin does not accept options\");\n }\n return typeof plugin === \"function\"\n ? {\n handler: plugin as PluginCreator,\n }\n : (plugin as PluginWithConfig);\n}\n\n/**\n * Builds the part of Tailwind's resolved config that `config()` reads besides `theme`.\n *\n * Like Tailwind, the result keeps only `darkMode`, `prefix`, `blocklist`, and `important` from\n * the configs, so `config(\"custom\")` returns the fallback. The last config that defines one of\n * these keys sets it, and a `null` value restores the default.\n *\n * @param configs - Plugin configs in registration order, presets first.\n * @returns The resolved keys with Tailwind's defaults for the others.\n */\nexport function resolveConfig(\n configs: readonly Record<string, unknown>[],\n): Record<string, unknown> {\n const defaults: Record<string, unknown> = {\n darkMode: null,\n prefix: \"\",\n blocklist: [],\n important: false,\n };\n const result: Record<string, unknown> = {\n ...defaults,\n future: {},\n experimental: {},\n plugins: [],\n content: {\n files: [],\n },\n };\n for (const config of configs) {\n for (const [key, fallback] of Object.entries(defaults)) {\n if (config[key] !== undefined) {\n result[key] = config[key] ?? fallback;\n }\n }\n }\n return result;\n}\n\n/**\n * Returns the `dark` variant that Tailwind's `darkMode` configuration key defines.\n *\n * @param setting - `\"media\"`, `\"selector\"`, `\"class\"`, or a tuple of one of these modes and a\n * selector, which defaults to `.dark`. `[\"variant\", selectors]` uses a selector or a list of\n * selectors, and each must contain `&`.\n * @returns The value for `addVariant()`, or undefined when the setting defines no variant,\n * including `null`, `false`, and the `variant` mode with a selector that Tailwind rejects.\n */\nexport function darkModeVariant(setting: unknown): string | string[] | undefined {\n const [mode, selector = \".dark\"] = Array.isArray(setting) ? setting : [setting];\n switch (mode) {\n case \"media\":\n return \"@media (prefers-color-scheme: dark)\";\n\n case \"selector\":\n return `&:where(${selector}, ${selector} *)`;\n\n case \"class\":\n return `&:is(${selector} *)`;\n\n case \"variant\": {\n const selectors: unknown[] = Array.isArray(selector) ? selector : [selector];\n // Tailwind warns and defines no variant for the default selector or a selector without `&`.\n return selectors.every(\n (entry): entry is string =>\n typeof entry === \"string\" && entry !== \".dark\" && ent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aAAa,OAAO,QAAQ,QAAQ,GACnD,IAAI,OAAO,SAAS,KAAA,GAClB,OAAO,OAAO,OAAO,QAAQ;CAInC,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,gBAAgB,SAAiD;CAC/E,MAAM,CAAC,MAAM,WAAW,WAAW,MAAM,QAAQ,OAAO,IAAI,UAAU,CAAC,OAAO;CAC9E,QAAQ,MAAR;EACE,KAAK,SACH,OAAO;EAET,KAAK,YACH,OAAO,WAAW,SAAS,IAAI,SAAS;EAE1C,KAAK,SACH,OAAO,QAAQ,SAAS;EAE1B,KAAK,WAAW;GACd,MAAM,YAAuB,MAAM,QAAQ,QAAQ,IAAI,WAAW,CAAC,QAAQ;GAE3E,OAAO,UAAU,OACd,UACC,OAAO,UAAU,YAAY,UAAU,WAAW,MAAM,SAAS,GAAG,CACxE,IACK,YACD,KAAA;EACN;EAEA,SACE;CACJ;AACF"}
@@ -30,6 +30,11 @@ interface EditorCompletion extends EditorEdit {
30
30
  snippet?: string;
31
31
  /** Requests another completion after the client inserts this item. */
32
32
  retrigger?: boolean;
33
+ /**
34
+ * Concrete color of a color utility as `#rrggbb` or `#rrggbbaa`. Absent for other candidates
35
+ * and for colors that depend on the color scheme.
36
+ */
37
+ color?: string;
33
38
  /** Completion category for host-resolved plugin names, files, and directories. */
34
39
  category?: "module" | "file" | "directory";
35
40
  /** Lexical priority key supplied by the semantic catalog. Omission sorts by label. */
@@ -189,6 +194,11 @@ interface EditorResult {
189
194
  }[];
190
195
  /** Prefix-matching candidates with their full replacement ranges. CSS loads on resolve. */
191
196
  completions?: EditorCompletion[];
197
+ /**
198
+ * True when the plugin catalog had more matching names than one request lists, so a longer
199
+ * prefix can produce other completions.
200
+ */
201
+ completionsIncomplete?: boolean;
192
202
  /** Concrete colors resolved against the active design system. */
193
203
  colors?: EditorColor[];
194
204
  /** Nonoverlapping replacements in ascending original offset order. */
@@ -842,6 +852,8 @@ type DesignSystemRequest = {
842
852
  kind: "utilities" | "variants";
843
853
  /** Decoded candidates. A `*` outside brackets and parentheses makes a pattern. */
844
854
  targets: readonly string[];
855
+ /** Omits formatted CSS previews from returned candidates. */
856
+ namesOnly?: boolean;
845
857
  };
846
858
  /**
847
859
  * Origin of a token: the project's `@theme`, or a default that `@theme` can override.
@@ -855,22 +867,24 @@ interface DesignToken {
855
867
  name: string;
856
868
  /** CSS value as written, including references to other tokens. */
857
869
  value: string;
870
+ /** CSS value with known theme `var()` references substituted. Absent when unchanged. */
871
+ resolvedValue?: string;
858
872
  /** Origin of the active definition. */
859
873
  source: DesignTokenSource;
860
874
  /** Whether utilities write the value of the token instead of a reference to it. */
861
875
  inline: boolean;
862
876
  }
863
877
  /**
864
- * One utility, variant, or marker class, with its CSS.
878
+ * One utility, variant, marker class, or functional utility pattern, with its CSS.
865
879
  */
866
880
  interface DesignCandidate {
867
881
  /** Decoded candidate. Variant names have no trailing colon. */
868
882
  name: string;
869
883
  /** Kind of input that the name selects. */
870
- kind: "utility" | "variant" | "marker";
884
+ kind: "utility" | "variant" | "marker" | "pattern";
871
885
  /** Whether the name resolves in this design system. */
872
886
  valid: boolean;
873
- /** Formatted CSS. It is empty for an invalid name and for a marker without CSS. */
887
+ /** Formatted CSS. It is empty for an invalid name, a pattern, a marker without CSS, or namesOnly. */
874
888
  css: string;
875
889
  /** Closest valid spelling of an invalid name. Absent when no spelling is close enough. */
876
890
  suggestion?: string;
@@ -968,4 +982,4 @@ declare class EditorSnapshot {
968
982
  query(id: string, request: EditorRequest): EditorResult | undefined;
969
983
  }
970
984
  export { PluginPathCompletion as A, TypeFactSource as C, PluginHost as D, UnverifiedRange as E, EditorResult as F, EditorCompletion as M, EditorEdit as N, TailwindSettings as O, EditorRequest as P, SemanticInputs as S, TypeFactsError as T, TypeFactsInputs as _, DesignSystemResult as a, AvailableFacts as b, queryDesignSystem as c, ModuleCompileOptions as d, SemanticDependency as f, TypeFactsEnvironment as g, TypeScriptFactsStats as h, DesignSystemRequest as i, EditorColor as j, defaultPluginExport as k, PluginRuntime as l, TypeScriptFactsService as m, DesignCandidate as n, DesignToken as o, TypeFact as p, DesignSystemContext as r, DesignTokenSource as s, EditorSnapshot as t, ModuleAnalysis as u, TypeScriptProject as v, TypeFactsBackend as w, CheckerSpan as x, resolveTypeFactsEnvironment as y };
971
- //# sourceMappingURL=index-DdFR_SNl.d.ts.map
985
+ //# sourceMappingURL=index-vMSKY1Nh.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as PluginPathCompletion, C as TypeFactSource, D as PluginHost, E as UnverifiedRange, F as EditorResult, M as EditorCompletion, N as EditorEdit, O as TailwindSettings, P as EditorRequest, S as SemanticInputs, T as TypeFactsError, _ as TypeFactsInputs, a as DesignSystemResult, b as AvailableFacts, c as queryDesignSystem, d as ModuleCompileOptions, f as SemanticDependency, g as TypeFactsEnvironment, h as TypeScriptFactsStats, i as DesignSystemRequest, j as EditorColor, k as defaultPluginExport, l as PluginRuntime, m as TypeScriptFactsService, n as DesignCandidate, o as DesignToken, p as TypeFact, r as DesignSystemContext, s as DesignTokenSource, t as EditorSnapshot, u as ModuleAnalysis, v as TypeScriptProject, w as TypeFactsBackend, x as CheckerSpan, y as resolveTypeFactsEnvironment } from "./index-DdFR_SNl.js";
1
+ import { A as PluginPathCompletion, C as TypeFactSource, D as PluginHost, E as UnverifiedRange, F as EditorResult, M as EditorCompletion, N as EditorEdit, O as TailwindSettings, P as EditorRequest, S as SemanticInputs, T as TypeFactsError, _ as TypeFactsInputs, a as DesignSystemResult, b as AvailableFacts, c as queryDesignSystem, d as ModuleCompileOptions, f as SemanticDependency, g as TypeFactsEnvironment, h as TypeScriptFactsStats, i as DesignSystemRequest, j as EditorColor, k as defaultPluginExport, l as PluginRuntime, m as TypeScriptFactsService, n as DesignCandidate, o as DesignToken, p as TypeFact, r as DesignSystemContext, s as DesignTokenSource, t as EditorSnapshot, u as ModuleAnalysis, v as TypeScriptProject, w as TypeFactsBackend, x as CheckerSpan, y as resolveTypeFactsEnvironment } from "./index-vMSKY1Nh.js";
2
2
  import { BindingDiagnostic, BindingOutput, BindingRejectedIdentifier, BindingReport, NativeAssetRecord, NativeCompilerOptions, NativeCssResource, NativeDesignSystemLoader, NativeDiagnosticBatch, NativeEditorQuery, NativeModuleSummary, NativeProjectSession, NativeSkippedCss, NativeTypeFact } from "@stillwind/native";
3
3
  import { PreparedSource as PreparedSource$1, ProjectInput, ScriptSyntax, SourceDocument } from "@stillwind/projection";
4
4
  import { EncodedSourceMap } from "@jridgewell/gen-mapping";
@@ -97,6 +97,23 @@ interface CompilerHost {
97
97
  /** Truthy values mark a dependency that the host does not load as source. */
98
98
  external?: boolean | string;
99
99
  } | null>;
100
+ /**
101
+ * Resolves an import that only decides CSS order between modules. Ordering follows imports that
102
+ * semantic traversal does not need, such as a component that a module renders, so a host whose
103
+ * `resolve` leaves script imports to the checker can answer them here.
104
+ *
105
+ * @param specifier - Authored module request text.
106
+ * @param importer - Full resolver identity of the importing source.
107
+ * @returns A promise for a resolved identity and optional external status, or null when
108
+ * unresolved. Omission uses `resolve`. Mark package modules external, because ordering does not
109
+ * follow them.
110
+ */
111
+ resolveOrdering?(specifier: string, importer: string): Promise<{
112
+ /** Full host identity used to load the resolved source. */
113
+ id: string;
114
+ /** Truthy values mark a dependency that ordering does not follow. */
115
+ external?: boolean | string;
116
+ } | null>;
100
117
  /**
101
118
  * Reads one resolved dependency before source preparation.
102
119
  *
@@ -163,6 +180,16 @@ export declare class CompilationProject {
163
180
  constructor(fixedSources?: boolean);
164
181
  /** Revision that a pending load must still match before it stores a source. */
165
182
  get revision(): number;
183
+ /**
184
+ * Returns a map that CSS order traversals share until the next invalidation. Every change to a
185
+ * file advances the revision, so an entry never outlives the text that it was derived from.
186
+ *
187
+ * @param name - Name of the map. Include the resolver domain when the entries depend on import
188
+ * resolution.
189
+ * @returns The map for the current revision. Callers store only values derived from module text
190
+ * and import resolution.
191
+ */
192
+ orderingCache<T>(name: string): Map<string, T>;
166
193
  /**
167
194
  * Finds a source prepared since its last invalidation.
168
195
  *
@@ -172,8 +199,24 @@ export declare class CompilationProject {
172
199
  source(id: string): PreparedSource$1 | undefined;
173
200
  /** Returns the normalized identities of the prepared sources, as {@link sourceKey} defines them. */
174
201
  sourceKeys(): string[];
175
- /** Returns the prepared documents' original text so plugins can find candidates together. */
176
- texts(): string[];
202
+ /**
203
+ * Records a file that a CSS order traversal read without retaining it as a source.
204
+ *
205
+ * @param id - Full resolver ID of the file.
206
+ */
207
+ recordOrderingRead(id: string): void;
208
+ /**
209
+ * Returns the normalized identities of files that only CSS order traversals read, as
210
+ * {@link sourceKey} defines them. A full {@link invalidate} clears them.
211
+ */
212
+ orderingReadKeys(): string[];
213
+ /**
214
+ * Returns the candidates that the local scans of the prepared sources found, so that plugins
215
+ * can define them together.
216
+ *
217
+ * @returns Candidates and variant prefixes, possibly repeated.
218
+ */
219
+ candidates(): string[];
177
220
  /**
178
221
  * Finds the scan results for a prepared source.
179
222
  *
@@ -417,6 +460,19 @@ export declare class CompilationFailure extends Error {
417
460
  */
418
461
  constructor(batches: readonly NativeDiagnosticBatch[], cause?: unknown);
419
462
  }
463
+ /**
464
+ * Formats a compiler report for an Error message or terminal output.
465
+ *
466
+ * @param report - Structured report with a primary label, related labels, and notes.
467
+ * @param options - `primaryLocation: false` omits the primary path and range, for hosts that
468
+ * display the primary location separately, such as the Vite error overlay.
469
+ * @returns Text with one-based line and column ranges for source labels, followed by related labels
470
+ * and notes. Document-scoped primary labels use only the path.
471
+ */
472
+ export declare function formatReport(report: BindingReport, options?: {
473
+ /** False omits the primary path and range. Omission includes them. */
474
+ primaryLocation?: boolean;
475
+ }): string;
420
476
  /**
421
477
  * Prepared direct or projected source with optional semantic facts in original UTF-8 coordinates.
422
478
  * The host attaches these facts before native compilation.
@@ -983,7 +1039,8 @@ export declare class AnalysisProject {
983
1039
  /**
984
1040
  * Lists the files that analysis has observed, for comparison with paths in watch notifications.
985
1041
  *
986
- * @returns Keys from `sourceKey` for prepared sources, files that CSS or plugins read, and paths
1042
+ * @returns Keys from `sourceKey` for prepared sources, files that only CSS order traversals
1043
+ * read, files that CSS or plugins read, and paths
987
1044
  * that the checker read or tested, including missing paths. A custom semantic backend contributes
988
1045
  * nothing.
989
1046
  */
@@ -1395,10 +1452,12 @@ export declare class AnalysisWorkspace {
1395
1452
  *
1396
1453
  * @param patterns - Optional additional globs relative to each project's root. Empty or omitted
1397
1454
  * filters check every configured target.
1455
+ * @param projects - Optional zero-based project indices to analyze. Omission analyzes every
1456
+ * project. Indices that no project has are ignored.
1398
1457
  * @returns Scoped results in project order, then sorted target order. Overlapping memberships remain separate.
1399
1458
  * @throws If target enumeration fails. Analysis failures are represented in individual results.
1400
1459
  */
1401
- lint(patterns?: string[]): Promise<WorkspaceResult[]>;
1460
+ lint(patterns?: string[], projects?: readonly number[]): Promise<WorkspaceResult[]>;
1402
1461
  /**
1403
1462
  * Prepares targets together in each project that includes them.
1404
1463
  *
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as fileSourceKind, C as CompilationFailure, D as ResolutionMismatchError, E as CompilationProject, F as prepareSourcePlugins, M as attachPlugins, N as compileWithPlugins, O as sourceKey, P as pluginLoader, S as warnRejectedNames, T as tracePhase, _ as defaultPluginExport, a as pluginDirectory, b as analyzeModule, c as CheckerSource, d as queryDesignSystem, f as isStylesheet, g as PluginRuntime, h as loadEditorCssGraph, i as completePluginPaths, j as TypeFactsError, k as cleanModuleId, l as checkerId, m as loadCssGraph, n as cssEntrypoint, o as queryPluginPaths, p as lintsStylesheet, r as StylesheetEditor, s as EditorSnapshot, t as compilerOptions, u as withRequestedProbes, v as cssBannerPrefix, w as startPhase, x as compileModule, y as finalizeCss } from "./options-CA4ymTHc.js";
1
+ import { A as cleanModuleId, C as CompilationFailure, D as CompilationProject, E as tracePhase, F as pluginLoader, I as prepareSourcePlugins, M as TypeFactsError, N as attachPlugins, O as ResolutionMismatchError, P as compileWithPlugins, S as warnRejectedNames, T as startPhase, _ as defaultPluginExport, a as pluginDirectory, b as analyzeModule, c as CheckerSource, d as queryDesignSystem, f as isStylesheet, g as PluginRuntime, h as loadEditorCssGraph, i as completePluginPaths, j as fileSourceKind, k as sourceKey, l as checkerId, m as loadCssGraph, n as cssEntrypoint, o as queryPluginPaths, p as lintsStylesheet, r as StylesheetEditor, s as EditorSnapshot, t as compilerOptions, u as withRequestedProbes, v as cssBannerPrefix, w as formatReport, x as compileModule, y as finalizeCss } from "./options-B0m3Ajj9.js";
2
2
  import { createRequire, syncBuiltinESMExports } from "node:module";
3
3
  import { NativeProjectSession, fingerprint } from "@stillwind/native";
4
4
  import path, { isAbsolute, relative, resolve } from "node:path";
@@ -1924,12 +1924,17 @@ var AnalysisProject = class {
1924
1924
  /**
1925
1925
  * Lists the files that analysis has observed, for comparison with paths in watch notifications.
1926
1926
  *
1927
- * @returns Keys from `sourceKey` for prepared sources, files that CSS or plugins read, and paths
1927
+ * @returns Keys from `sourceKey` for prepared sources, files that only CSS order traversals
1928
+ * read, files that CSS or plugins read, and paths
1928
1929
  * that the checker read or tested, including missing paths. A custom semantic backend contributes
1929
1930
  * nothing.
1930
1931
  */
1931
1932
  reads() {
1932
- return /* @__PURE__ */ new Set([...this.#compilation.sourceKeys(), ...[...this.#css.dependencies, ...this.#facts?.dependencies ?? []].map(sourceKey)]);
1933
+ return /* @__PURE__ */ new Set([
1934
+ ...this.#compilation.sourceKeys(),
1935
+ ...this.#compilation.orderingReadKeys(),
1936
+ ...[...this.#css.dependencies, ...this.#facts?.dependencies ?? []].map(sourceKey)
1937
+ ]);
1933
1938
  }
1934
1939
  /** Makes pending results stale. The next transaction rebuilds CSS and backend caches. */
1935
1940
  invalidate() {
@@ -2009,7 +2014,7 @@ var AnalysisProject = class {
2009
2014
  const loader = await this.#css.load();
2010
2015
  if (this.#discardReason(revision)) return;
2011
2016
  await this.#compilation.prepare(entries, this.host, this.#css.session);
2012
- await prepareSourcePlugins(this.#css.session, loader, this.#compilation.texts());
2017
+ await prepareSourcePlugins(this.#css.session, loader, this.#compilation.candidates());
2013
2018
  } catch {
2014
2019
  this.#css.discardPlugins();
2015
2020
  }
@@ -2553,6 +2558,36 @@ function createFileSystemAnalysisHost(config, directory) {
2553
2558
  references: "auto"
2554
2559
  } : void 0
2555
2560
  });
2561
+ const orderingResolver = new ResolverFactory({
2562
+ extensions: [
2563
+ ".tsx",
2564
+ ".ts",
2565
+ ".mts",
2566
+ ".cts",
2567
+ ".jsx",
2568
+ ".js",
2569
+ ".mjs",
2570
+ ".cjs",
2571
+ ".astro",
2572
+ ".svelte",
2573
+ ".vue"
2574
+ ],
2575
+ extensionAlias: {
2576
+ ".js": [
2577
+ ".ts",
2578
+ ".tsx",
2579
+ ".js",
2580
+ ".jsx"
2581
+ ],
2582
+ ".mjs": [".mts", ".mjs"],
2583
+ ".cjs": [".cts", ".cjs"]
2584
+ },
2585
+ conditionNames: ["import", "default"],
2586
+ tsconfig: typeFactsEnvironment.project.kind === "configured" ? {
2587
+ configFile: typeFactsEnvironment.project.configPath,
2588
+ references: "auto"
2589
+ } : void 0
2590
+ });
2556
2591
  let documents = /* @__PURE__ */ new Map();
2557
2592
  let buffers = /* @__PURE__ */ new Map();
2558
2593
  /**
@@ -2592,6 +2627,33 @@ function createFileSystemAnalysisHost(config, directory) {
2592
2627
  * @returns Whether the path has a supported extension and is not a TypeScript declaration file.
2593
2628
  */
2594
2629
  const supports = (id) => /\.(?:[cm]?[jt]sx?|vue|svelte|astro)$/i.test(id) && !/\.d\.[cm]?ts$/i.test(id);
2630
+ /**
2631
+ * Resolves custom sources and framework components. Other script imports return null, because
2632
+ * semantic traversal takes their identities from the checker.
2633
+ *
2634
+ * @param specifier - Authored module request.
2635
+ * @param importer - Absolute path of the importing source.
2636
+ * @returns The resolved identity, or null when the request is left to the checker or does not
2637
+ * resolve.
2638
+ */
2639
+ const resolve = async (specifier, importer) => {
2640
+ if (config.sources?.kind === "custom") {
2641
+ const id = await config.sources.resolve?.(specifier, importer, {
2642
+ root,
2643
+ documents
2644
+ });
2645
+ return id ? { id } : null;
2646
+ }
2647
+ if (/\.(?:vue|svelte|astro)$/i.test(specifier)) {
2648
+ if (specifier.startsWith(".") || path.isAbsolute(specifier)) {
2649
+ const id = path.resolve(path.dirname(importer), specifier);
2650
+ if (buffers.has(documentKey(id))) return { id };
2651
+ }
2652
+ const id = (await frameworkResolver.async(path.dirname(importer), specifier)).path;
2653
+ return id ? { id } : null;
2654
+ }
2655
+ return null;
2656
+ };
2595
2657
  return {
2596
2658
  root,
2597
2659
  config: resolvedConfig,
@@ -2616,23 +2678,16 @@ function createFileSystemAnalysisHost(config, directory) {
2616
2678
  };
2617
2679
  return !("kind" in input) && config.projection?.kind === "custom" ? config.projection.prepare(input) : input;
2618
2680
  },
2619
- resolve: async (specifier, importer) => {
2620
- if (config.sources?.kind === "custom") {
2621
- const id = await config.sources.resolve?.(specifier, importer, {
2622
- root,
2623
- documents
2624
- });
2625
- return id ? { id } : null;
2626
- }
2627
- if (/\.(?:vue|svelte|astro)$/i.test(specifier)) {
2628
- if (specifier.startsWith(".") || path.isAbsolute(specifier)) {
2629
- const id = path.resolve(path.dirname(importer), specifier);
2630
- if (buffers.has(documentKey(id))) return { id };
2631
- }
2632
- const id = (await frameworkResolver.async(path.dirname(importer), specifier)).path;
2633
- return id ? { id } : null;
2634
- }
2635
- return null;
2681
+ resolve,
2682
+ resolveOrdering: async (specifier, importer) => {
2683
+ const own = await resolve(specifier, importer);
2684
+ if (own || config.sources?.kind === "custom") return own;
2685
+ const id = (await orderingResolver.async(path.dirname(importer), specifier)).path;
2686
+ if (!id) return null;
2687
+ return /[\\/]node_modules[\\/]/.test(id) ? {
2688
+ id,
2689
+ external: true
2690
+ } : { id };
2636
2691
  },
2637
2692
  watch: () => {},
2638
2693
  warn: () => {},
@@ -2688,6 +2743,7 @@ function createFileSystemAnalysisHost(config, directory) {
2688
2743
  invalidate: async () => {
2689
2744
  cssResolver.clearCache();
2690
2745
  frameworkResolver.clearCache();
2746
+ orderingResolver.clearCache();
2691
2747
  },
2692
2748
  close: async () => {}
2693
2749
  };
@@ -2966,12 +3022,15 @@ var AnalysisWorkspace = class AnalysisWorkspace {
2966
3022
  *
2967
3023
  * @param patterns - Optional additional globs relative to each project's root. Empty or omitted
2968
3024
  * filters check every configured target.
3025
+ * @param projects - Optional zero-based project indices to analyze. Omission analyzes every
3026
+ * project. Indices that no project has are ignored.
2969
3027
  * @returns Scoped results in project order, then sorted target order. Overlapping memberships remain separate.
2970
3028
  * @throws If target enumeration fails. Analysis failures are represented in individual results.
2971
3029
  */
2972
- async lint(patterns) {
3030
+ async lint(patterns, projects) {
2973
3031
  const results = [];
2974
3032
  for (const [index, project] of this.projects.entries()) {
3033
+ if (projects && !projects.includes(index)) continue;
2975
3034
  const files = await this.targets(project, patterns, { stylesheets: true });
2976
3035
  await project.analysis.prepare(files);
2977
3036
  for (const file of files) results.push({
@@ -3026,6 +3085,6 @@ var AnalysisWorkspace = class AnalysisWorkspace {
3026
3085
  if (errors.length) throw new AggregateError(errors, "Failed to close Stillwind analysis hosts");
3027
3086
  }
3028
3087
  };
3029
- export { AnalysisProject, AnalysisWorkspace, CompilationFailure, CompilationProject, EditorProject, EditorSnapshot, PluginRuntime, ResolutionMismatchError, TypeFactsError, TypeScriptFactsService, analyzeModule, attachPlugins, cleanModuleId, compileModule, compileWithPlugins, compilerModuleId, compilerOptions, composeCarrierSourceMap, composeFrameworkSourceMap, composeModuleSourceMap, createFileSystemAnalysisHost, createStylesheetResolver, cssEntrypoint, cssWithSourceMap, decodeCssSourceMap, defaultPluginExport, fileModuleDescriptor, fileSourceKind, finalizeCss, finalizeModuleWithMap, isStylesheet, lintsStylesheet, loadCssGraph, loadEditorCssGraph, moduleSourceMap, nodePluginHost, pluginLoader, queryDesignSystem, resolveTypeFactsEnvironment, startPhase, tracePhase, warnRejectedNames };
3088
+ export { AnalysisProject, AnalysisWorkspace, CompilationFailure, CompilationProject, EditorProject, EditorSnapshot, PluginRuntime, ResolutionMismatchError, TypeFactsError, TypeScriptFactsService, analyzeModule, attachPlugins, cleanModuleId, compileModule, compileWithPlugins, compilerModuleId, compilerOptions, composeCarrierSourceMap, composeFrameworkSourceMap, composeModuleSourceMap, createFileSystemAnalysisHost, createStylesheetResolver, cssEntrypoint, cssWithSourceMap, decodeCssSourceMap, defaultPluginExport, fileModuleDescriptor, fileSourceKind, finalizeCss, finalizeModuleWithMap, formatReport, isStylesheet, lintsStylesheet, loadCssGraph, loadEditorCssGraph, moduleSourceMap, nodePluginHost, pluginLoader, queryDesignSystem, resolveTypeFactsEnvironment, startPhase, tracePhase, warnRejectedNames };
3030
3089
 
3031
3090
  //# sourceMappingURL=index.js.map