prettier-plugin-stillwind 0.11.0 → 0.12.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # prettier-plugin-stillwind
2
2
 
3
+ ## 0.12.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Make editor integrations clearer. The VS Code extension shows a Stillwind status bar item that tells whether the project's `@stillwind/cli` or the bundled language server runs, and opens the output channel on click. A change to `stillwind.configFile` restarts the language server. **Stillwind: Sort Utilities** reports in the status bar when the utilities are already sorted. Stillwind at-rules in CSS files show descriptions and syntax on hover and in completion, and the Command Palette no longer lists internal commands. Diagnostics use `stillwind` as their source, and add the project path only when several projects report on the same file. Color utilities complete with color swatches, completion lists report when the catalog has more entries than they show, resolved completions keep their detail, Quick Fixes link to their diagnostics and mark the primary fix as preferred, and hovers name the project only when several projects give different results. The Prettier `stillwindConfig` option describes every `stillwind.config.*` format.
8
+
9
+ - Updated dependencies:
10
+ - @stillwind/analysis@0.12.0
11
+
3
12
  ## 0.11.0
4
13
 
5
14
  ### Patch Changes
package/README.md CHANGED
@@ -11,7 +11,7 @@ Stillwind inputs before Prettier formats a document.
11
11
  Install the plugin alongside Prettier 3.7 or newer within the 3.x series:
12
12
 
13
13
  ```sh
14
- vp i -D prettier prettier-plugin-stillwind
14
+ npm install -D prettier prettier-plugin-stillwind
15
15
  ```
16
16
 
17
17
  ```js
@@ -58,9 +58,9 @@ Duplicate or ambiguous tokens retain their relative cursor offset within the rep
58
58
  The plugin only sorts. Canonical utility replacements are available through `stillwind lint --fix`.
59
59
  Prettier owns saving files. The plugin reloads project configuration for each formatting request.
60
60
 
61
- See [Editor sorting](https://github.com/SegaraRai/stillwind/blob/main/docs/standalone-analysis.md#editor-sorting)
62
- for the shared sorting contract and [Lint policies](https://github.com/SegaraRai/stillwind/blob/main/docs/standalone-analysis.md#utility-lint-policies)
63
- for canonical replacements and other checks.
61
+ See [Formatters](https://stillwind.dev/docs/formatters) and
62
+ [Sorting](https://stillwind.dev/docs/configuration#sorting) for sorting options, and
63
+ [Lint](https://stillwind.dev/docs/configuration#lint) for canonical replacements and other checks.
64
64
 
65
65
  ## Browser entry
66
66
 
package/dist/browser.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as createParsers, r as options, t as builtinParsers } from "./plugin-Dzvv8pEn.js";
1
+ import { n as createParsers, r as options, t as builtinParsers } from "./plugin-BHTxJrTf.js";
2
2
  // src/browser.ts
3
3
  /**
4
4
  * Creates a plugin object that sorts with a host-supplied service.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as createParsers, r as options, t as builtinParsers } from "./plugin-Dzvv8pEn.js";
1
+ import { n as createParsers, r as options, t as builtinParsers } from "./plugin-BHTxJrTf.js";
2
2
  import path from "node:path";
3
3
  import { SourceFormatter, findFormatterConfig } from "@stillwind/analysis/node";
4
4
  import process from "node:process";
@@ -139,7 +139,7 @@ const processed = Symbol("stillwind.preprocessed");
139
139
  const options = { stillwindConfig: {
140
140
  type: "path",
141
141
  category: "Stillwind",
142
- description: "Path to stillwind.config.ts. Omission searches above the formatted file."
142
+ description: "Path to a stillwind.config.* file. Omission searches above the formatted file."
143
143
  } };
144
144
  /**
145
145
  * Prettier's built-in parsers that the wrappers delegate to when no preceding plugin applies.
@@ -267,4 +267,4 @@ function matchesFile(parser, file) {
267
267
  }
268
268
  export { createParsers as n, options as r, builtinParsers as t };
269
269
 
270
- //# sourceMappingURL=plugin-Dzvv8pEn.js.map
270
+ //# sourceMappingURL=plugin-BHTxJrTf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-BHTxJrTf.js","names":["typescriptParsers","babelParsers","flowParsers","typescriptParsers","htmlParsers","cssParsers"],"sources":["../src/cursor.ts","../src/ignore.ts","../src/plugin.ts"],"sourcesContent":["import type { SortOutput } from \"./plugin.ts\";\n\n/**\n * Maps an original UTF-16 cursor offset through nonoverlapping edits ordered by start.\n * Negative offsets return unchanged. A cursor follows a token whose spelling occurs once in\n * its replacement. Otherwise, the cursor keeps its relative position within the replacement.\n *\n * @param offset - Original UTF-16 cursor position, or a negative Prettier sentinel.\n * @param source - Original text addressed by every edit range.\n * @param edits - Nonoverlapping replacements in ascending original offset order.\n * @returns The cursor position after the edits. A relative position is clamped to the replacement's\n * length when no unique matching token is available. The input edits remain unchanged.\n */\nexport function mapOffset(offset: number, source: string, edits: SortOutput[\"edits\"]): number {\n if (offset < 0) {\n return offset;\n }\n let delta = 0;\n for (const edit of edits) {\n if (offset < edit.start) {\n break;\n }\n if (offset >= edit.end) {\n delta += edit.newText.length - (edit.end - edit.start);\n continue;\n }\n const previous = source.slice(edit.start, edit.end);\n const token = [...previous.matchAll(/\\S+/gu)].find(\n (match) =>\n match.index <= offset - edit.start && offset - edit.start < match.index + match[0].length,\n );\n if (token) {\n const start = edit.newText.indexOf(token[0]);\n if (start >= 0 && start === edit.newText.lastIndexOf(token[0])) {\n return edit.start + delta + start + offset - edit.start - token.index;\n }\n }\n return edit.start + delta + Math.min(offset - edit.start, edit.newText.length);\n }\n return offset + delta;\n}\n","import type { Parser, ParserOptions } from \"prettier\";\nimport { parsers as typescriptParsers } from \"prettier/plugins/typescript\";\n\n/** Original text that Stillwind sorting must leave untouched. */\ninterface SourceRange {\n /** Inclusive UTF-16 offset in the original buffer. */\n start: number;\n /** Exclusive UTF-16 offset in the original buffer. */\n end: number;\n}\n\n/**\n * Finds ignored nodes and returns half-open UTF-16 ranges in the original source.\n * Vue and Astro script bodies are parsed separately when they contain ignore directives.\n *\n * @param ast - AST parsed from `source` by `parser` before Stillwind edits are applied.\n * @param parser - Parser whose location functions return original UTF-16 offsets for that AST.\n * @param source - Original buffer, including comments and any embedded script delimiters.\n * @param options - Parser options reused for embedded TypeScript parsing with its own original text.\n * @returns Protected ranges in discovery order. Ranges can overlap, and an unmatched ignore-start\n * protects the remaining source. Neither the AST nor the options object is changed.\n * @throws If a parser location function fails or an embedded script cannot be parsed.\n */\nexport async function ignoredRanges(\n ast: unknown,\n parser: Parser,\n source: string,\n options: ParserOptions,\n): Promise<SourceRange[]> {\n const nodes: (SourceRange & {\n /** Whether the parser's kind string identifies this node as a comment. */\n comment: boolean;\n })[] = [];\n const scripts: SourceRange[] = [];\n const seen = new Set<object>();\n\n /**\n * Collects valid node locations and embedded scripts while avoiding cycles and AST metadata.\n *\n * @param value - Root, child, or array from the supplied AST. Visited objects are added to `seen`,\n * and valid source ranges are appended to `nodes` and `scripts` without changing those objects.\n * @throws If the parser cannot provide a location for a node with a string kind.\n */\n const visit = (value: unknown) => {\n if (!value || typeof value !== \"object\" || seen.has(value)) {\n return;\n }\n seen.add(value);\n if (Array.isArray(value)) {\n for (const child of value) {\n visit(child);\n }\n return;\n }\n const node = value as Record<string, unknown>;\n const kind = node.type ?? node.kind;\n if (typeof kind === \"string\") {\n const start = parser.locStart(node);\n const end = parser.locEnd(node);\n if (\n Number.isInteger(start) &&\n Number.isInteger(end) &&\n start >= 0 &&\n end > start &&\n end <= source.length\n ) {\n nodes.push({ start, end, comment: /comment|^(?:Line|Block)$/i.test(kind) });\n if (kind === \"AstroFrontmatter\") {\n scripts.push({ start: start + 3, end: end - 3 });\n } else if (kind === \"element\" && node.name === \"script\" && Array.isArray(node.children)) {\n for (const child of node.children) {\n scripts.push({ start: parser.locStart(child), end: parser.locEnd(child) });\n }\n }\n }\n }\n for (const [key, child] of Object.entries(node)) {\n if (![\"parent\", \"tokens\", \"loc\", \"position\"].includes(key)) {\n visit(child);\n }\n }\n };\n visit(ast);\n\n const ranges: SourceRange[] = [];\n const comments = nodes.filter((node) => node.comment).sort((a, b) => a.start - b.start);\n let rangeStart: number | undefined;\n for (const comment of comments) {\n const text = source\n .slice(comment.start, comment.end)\n .replace(/^(?:\\/\\/|\\/\\*|<!--)|(?:\\*\\/|-->)$/g, \"\")\n .trim();\n if (text === \"prettier-ignore-start\") {\n rangeStart = comment.end;\n } else if (text === \"prettier-ignore-end\" && rangeStart !== undefined) {\n ranges.push({\n start: rangeStart,\n end: comment.start,\n });\n rangeStart = undefined;\n } else if (text === \"prettier-ignore\") {\n const next = nodes\n .filter(\n (node) =>\n !node.comment && node.start >= comment.end && source.slice(node.start, node.end).trim(),\n )\n .sort((a, b) => a.start - b.start || b.end - a.end)[0];\n if (next) {\n ranges.push({\n start: next.start,\n end: next.end,\n });\n }\n }\n }\n if (rangeStart !== undefined) {\n ranges.push({\n start: rangeStart,\n end: source.length,\n });\n }\n\n for (const script of scripts) {\n const text = source.slice(script.start, script.end);\n if (text.includes(\"prettier-ignore\")) {\n const scriptParser = typescriptParsers.typescript;\n const scriptOptions = { ...options, originalText: text };\n const scriptAst = await scriptParser.parse(text, scriptOptions);\n const protectedRanges = await ignoredRanges(scriptAst, scriptParser, text, scriptOptions);\n ranges.push(\n ...protectedRanges.map((range) => ({\n start: script.start + range.start,\n end: script.start + range.end,\n })),\n );\n }\n }\n\n return ranges;\n}\n","/**\n * Parser wrappers shared by the Node and browser entries. A wrapper sorts recognized Stillwind\n * inputs before the selected Prettier parser runs. The entry supplies the sorting service.\n */\n\nimport type { Parser, ParserOptions, Plugin, SupportOptions } from \"prettier\";\nimport { parsers as babelParsers } from \"prettier/plugins/babel\";\nimport { parsers as flowParsers } from \"prettier/plugins/flow\";\nimport { parsers as htmlParsers } from \"prettier/plugins/html\";\nimport { parsers as cssParsers } from \"prettier/plugins/postcss\";\nimport { parsers as typescriptParsers } from \"prettier/plugins/typescript\";\n\nimport { mapOffset } from \"./cursor.ts\";\nimport { ignoredRanges } from \"./ignore.ts\";\n\nconst processed = Symbol(\"stillwind.preprocessed\");\n\n/**\n * Prettier options shared with the delegated parser during one formatting operation.\n */\nexport type StillwindOptions = ParserOptions & {\n /** Configuration path resolved from cwd. Omission searches above the formatted file. */\n stillwindConfig?: string;\n /** Original UTF-16 cursor position, updated after sorting. A negative value disables mapping. */\n cursorOffset?: number;\n /** Marks an options object whose Stillwind preprocessing has already begun, including nested parses. */\n [processed]?: boolean;\n};\n\n/**\n * Original buffer and the ranges that sorting must leave untouched.\n */\nexport interface SortInput {\n /** Complete original text against which edits are measured. */\n source: string;\n /** Half-open UTF-16 ranges in `source`, from ignore directives and the formatting range. */\n protectedRanges: {\n /** Inclusive original UTF-16 offset. */\n start: number;\n /** Exclusive original UTF-16 offset. */\n end: number;\n }[];\n}\n\n/**\n * Sorted buffer and the edits that produced it.\n */\nexport interface SortOutput {\n /** Complete text after sorting. */\n code: string;\n /** Nonoverlapping replacements in `SortInput.source`, in ascending start order. */\n edits: readonly {\n /** Inclusive original UTF-16 offset. */\n start: number;\n /** Exclusive original UTF-16 offset. */\n end: number;\n /** Replacement text. */\n newText: string;\n }[];\n}\n\n/**\n * Selects the sorting service for one file before the wrapper parses it.\n *\n * @param filepath - Filepath supplied by Prettier, before path resolution.\n * @param options - Resolved Prettier options for this formatting operation.\n * @returns A function that sorts the buffer, or `undefined` to keep ordinary Prettier formatting.\n * @throws If the project configuration is invalid. The formatting request fails.\n */\nexport type SortResolver = (\n filepath: string,\n options: StillwindOptions,\n) =>\n | ((input: SortInput) => Promise<SortOutput>)\n | undefined\n | Promise<((input: SortInput) => Promise<SortOutput>) | undefined>;\n\nexport const options: SupportOptions = {\n stillwindConfig: {\n type: \"path\",\n category: \"Stillwind\",\n description: \"Path to a stillwind.config.* file. Omission searches above the formatted file.\",\n },\n};\n\n/**\n * Prettier's built-in parsers that the wrappers delegate to when no preceding plugin applies.\n */\nexport const builtinParsers: Record<string, Parser> = {\n babel: babelParsers.babel,\n \"babel-ts\": babelParsers[\"babel-ts\"],\n flow: flowParsers.flow,\n typescript: typescriptParsers.typescript,\n vue: htmlParsers.vue,\n css: cssParsers.css,\n};\n\n/**\n * Wraps each parser so that it sorts the original buffer before delegating.\n *\n * @param bases - Fallback parsers keyed by Prettier parser name.\n * @param resolve - Selects the sorting service for each formatted file.\n * @returns Wrapper parsers with the same keys as `bases`.\n */\nexport function createParsers(\n bases: Record<string, Parser>,\n resolve: SortResolver,\n): Record<string, Parser> {\n return Object.fromEntries(\n Object.entries(bases).map(([name, base]) => {\n const wrapper: Parser = {\n ...base,\n /**\n * Sorts the original buffer before delegating language-specific preprocessing.\n *\n * @param text - Original source supplied by Prettier for this parser invocation.\n * @param rawOptions - Resolved Prettier options. The shared processed marker prevents nested\n * invocations from sorting again, and `cursorOffset` is mapped through the sorting edits.\n * Ignore directives and text outside the formatting range are protected from sorting.\n * @returns Sorted text after the delegate's preprocessing, or delegated original text when\n * the file is unsupported, already processed, or has no sorting service.\n * @throws If delegate loading, parsing, ignore extraction, configuration, or sorting fails.\n */\n async preprocess(text, rawOptions) {\n const current = rawOptions as StillwindOptions;\n const delegate = await delegateParser(name, wrapper, base, current);\n /**\n * Applies the delegate's preprocessing with the current shared options.\n *\n * @param source - Original or sorted buffer selected for this formatting invocation.\n * @returns The delegate's synchronous or asynchronous result, or unchanged text when absent.\n * @throws If the delegate fails, synchronously or through its returned promise.\n */\n const preprocess = (source: string) =>\n delegate.preprocess ? delegate.preprocess(source, current) : source;\n const source = text;\n if (current[processed] || !current.filepath || !matchesFile(name, current.filepath)) {\n return preprocess(source);\n }\n current[processed] = true;\n const sort = await resolve(current.filepath, current);\n if (!sort) {\n return preprocess(source);\n }\n const ast = await delegate.parse(source, {\n ...current,\n originalText: source,\n });\n const protectedRanges = await ignoredRanges(ast, delegate, source, current);\n if (current.rangeStart > 0) {\n protectedRanges.push({\n start: 0,\n end: current.rangeStart,\n });\n }\n if (current.rangeEnd < source.length) {\n protectedRanges.push({\n start: current.rangeEnd,\n end: source.length,\n });\n }\n const result = await sort({ source, protectedRanges });\n current.cursorOffset = mapOffset(current.cursorOffset ?? -1, source, result.edits);\n return preprocess(result.code);\n },\n /**\n * Parses the preprocessed buffer using the nearest preceding language plugin.\n *\n * @param text - Buffer after this wrapper's preprocessing.\n * @param rawOptions - Resolved Prettier options shared with the selected delegate.\n * @returns The delegate's AST without changing its representation.\n * @throws If delegate loading or parsing fails.\n */\n async parse(text, rawOptions) {\n const current = rawOptions as StillwindOptions;\n return (await delegateParser(name, wrapper, base, current)).parse(text, current);\n },\n };\n return [name, wrapper];\n }),\n );\n}\n\n/**\n * Selects the nearest preceding plugin that supplies the same parser name.\n *\n * @param name - Parser registry key used by this wrapper.\n * @param wrapper - Parser object used to identify this plugin in the resolved plugin list.\n * @param fallback - Built-in or optional language parser used when no preceding parser is found.\n * @param current - Resolved options whose object-valued plugins retain Prettier's plugin order.\n * @returns The selected parser, awaiting its factory when present. An absent wrapper also uses\n * the fallback.\n * @throws If the selected parser factory fails.\n */\nasync function delegateParser(\n name: string,\n wrapper: Parser,\n fallback: Parser,\n current: StillwindOptions,\n): Promise<Parser> {\n const plugins = current.plugins.filter((plugin): plugin is Plugin => typeof plugin === \"object\");\n const ownIndex = plugins.findIndex((plugin) => plugin.parsers?.[name] === wrapper);\n for (let index = ownIndex - 1; index >= 0; index--) {\n const parser = plugins[index].parsers?.[name];\n if (parser) {\n const candidate = parser as Parser | (() => Parser | Promise<Parser>);\n return typeof candidate === \"function\" ? candidate() : candidate;\n }\n }\n return fallback;\n}\n\n/**\n * Checks whether a filepath can be analyzed by the selected parser.\n *\n * @param parser - Prettier parser name. Component parsers require their exact lowercase suffix.\n * @param file - Filepath supplied by Prettier, before resolution to an absolute path.\n * @returns Whether the component suffix matches, the CSS parser has a case-insensitive `.css`\n * suffix, or a JS/TS suffix matches without a TypeScript declaration suffix.\n */\nfunction matchesFile(parser: string, file: string): boolean {\n if (parser === \"css\") {\n return /\\.css$/i.test(file);\n }\n if ([\"vue\", \"svelte\", \"astro\"].includes(parser)) {\n return file.endsWith(`.${parser}`);\n }\n return /\\.[cm]?[jt]sx?$/i.test(file) && !/\\.d\\.[cm]?ts$/i.test(file);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAaA,SAAgB,UAAU,QAAgB,QAAgB,OAAoC;CAC5F,IAAI,SAAS,GACX,OAAO;CAET,IAAI,QAAQ;CACZ,KAAK,MAAM,QAAQ,OAAO;EACxB,IAAI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;EACzD;CACF;CACA,OAAO;AACT;;;;;;;;;AAUA,SAAS,YAAY,QAAgB,MAAuB;CAC1D,IAAI,WAAW,OACb,OAAO,UAAU,KAAK,IAAI;CAE5B,IAAI;EAAC;EAAO;EAAU;CAAO,CAAC,CAAC,SAAS,MAAM,GAC5C,OAAO,KAAK,SAAS,IAAI,QAAQ;CAEnC,OAAO,mBAAmB,KAAK,IAAI,KAAK,CAAC,iBAAiB,KAAK,IAAI;AACrE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prettier-plugin-stillwind",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "Prettier plugin that sorts Stillwind utilities in JavaScript, TypeScript, Astro, Svelte, Vue, and CSS files",
5
5
  "keywords": [
6
6
  "astro",
@@ -46,7 +46,7 @@
46
46
  "access": "public"
47
47
  },
48
48
  "dependencies": {
49
- "@stillwind/analysis": "0.11.0"
49
+ "@stillwind/analysis": "0.12.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@stillwind-internal/tools-workspace": "0.0.0",
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin-Dzvv8pEn.js","names":["typescriptParsers","babelParsers","flowParsers","typescriptParsers","htmlParsers","cssParsers"],"sources":["../src/cursor.ts","../src/ignore.ts","../src/plugin.ts"],"sourcesContent":["import type { SortOutput } from \"./plugin.ts\";\n\n/**\n * Maps an original UTF-16 cursor offset through nonoverlapping edits ordered by start.\n * Negative offsets return unchanged. A cursor follows a token whose spelling occurs once in\n * its replacement. Otherwise, the cursor keeps its relative position within the replacement.\n *\n * @param offset - Original UTF-16 cursor position, or a negative Prettier sentinel.\n * @param source - Original text addressed by every edit range.\n * @param edits - Nonoverlapping replacements in ascending original offset order.\n * @returns The cursor position after the edits. A relative position is clamped to the replacement's\n * length when no unique matching token is available. The input edits remain unchanged.\n */\nexport function mapOffset(offset: number, source: string, edits: SortOutput[\"edits\"]): number {\n if (offset < 0) {\n return offset;\n }\n let delta = 0;\n for (const edit of edits) {\n if (offset < edit.start) {\n break;\n }\n if (offset >= edit.end) {\n delta += edit.newText.length - (edit.end - edit.start);\n continue;\n }\n const previous = source.slice(edit.start, edit.end);\n const token = [...previous.matchAll(/\\S+/gu)].find(\n (match) =>\n match.index <= offset - edit.start && offset - edit.start < match.index + match[0].length,\n );\n if (token) {\n const start = edit.newText.indexOf(token[0]);\n if (start >= 0 && start === edit.newText.lastIndexOf(token[0])) {\n return edit.start + delta + start + offset - edit.start - token.index;\n }\n }\n return edit.start + delta + Math.min(offset - edit.start, edit.newText.length);\n }\n return offset + delta;\n}\n","import type { Parser, ParserOptions } from \"prettier\";\nimport { parsers as typescriptParsers } from \"prettier/plugins/typescript\";\n\n/** Original text that Stillwind sorting must leave untouched. */\ninterface SourceRange {\n /** Inclusive UTF-16 offset in the original buffer. */\n start: number;\n /** Exclusive UTF-16 offset in the original buffer. */\n end: number;\n}\n\n/**\n * Finds ignored nodes and returns half-open UTF-16 ranges in the original source.\n * Vue and Astro script bodies are parsed separately when they contain ignore directives.\n *\n * @param ast - AST parsed from `source` by `parser` before Stillwind edits are applied.\n * @param parser - Parser whose location functions return original UTF-16 offsets for that AST.\n * @param source - Original buffer, including comments and any embedded script delimiters.\n * @param options - Parser options reused for embedded TypeScript parsing with its own original text.\n * @returns Protected ranges in discovery order. Ranges can overlap, and an unmatched ignore-start\n * protects the remaining source. Neither the AST nor the options object is changed.\n * @throws If a parser location function fails or an embedded script cannot be parsed.\n */\nexport async function ignoredRanges(\n ast: unknown,\n parser: Parser,\n source: string,\n options: ParserOptions,\n): Promise<SourceRange[]> {\n const nodes: (SourceRange & {\n /** Whether the parser's kind string identifies this node as a comment. */\n comment: boolean;\n })[] = [];\n const scripts: SourceRange[] = [];\n const seen = new Set<object>();\n\n /**\n * Collects valid node locations and embedded scripts while avoiding cycles and AST metadata.\n *\n * @param value - Root, child, or array from the supplied AST. Visited objects are added to `seen`,\n * and valid source ranges are appended to `nodes` and `scripts` without changing those objects.\n * @throws If the parser cannot provide a location for a node with a string kind.\n */\n const visit = (value: unknown) => {\n if (!value || typeof value !== \"object\" || seen.has(value)) {\n return;\n }\n seen.add(value);\n if (Array.isArray(value)) {\n for (const child of value) {\n visit(child);\n }\n return;\n }\n const node = value as Record<string, unknown>;\n const kind = node.type ?? node.kind;\n if (typeof kind === \"string\") {\n const start = parser.locStart(node);\n const end = parser.locEnd(node);\n if (\n Number.isInteger(start) &&\n Number.isInteger(end) &&\n start >= 0 &&\n end > start &&\n end <= source.length\n ) {\n nodes.push({ start, end, comment: /comment|^(?:Line|Block)$/i.test(kind) });\n if (kind === \"AstroFrontmatter\") {\n scripts.push({ start: start + 3, end: end - 3 });\n } else if (kind === \"element\" && node.name === \"script\" && Array.isArray(node.children)) {\n for (const child of node.children) {\n scripts.push({ start: parser.locStart(child), end: parser.locEnd(child) });\n }\n }\n }\n }\n for (const [key, child] of Object.entries(node)) {\n if (![\"parent\", \"tokens\", \"loc\", \"position\"].includes(key)) {\n visit(child);\n }\n }\n };\n visit(ast);\n\n const ranges: SourceRange[] = [];\n const comments = nodes.filter((node) => node.comment).sort((a, b) => a.start - b.start);\n let rangeStart: number | undefined;\n for (const comment of comments) {\n const text = source\n .slice(comment.start, comment.end)\n .replace(/^(?:\\/\\/|\\/\\*|<!--)|(?:\\*\\/|-->)$/g, \"\")\n .trim();\n if (text === \"prettier-ignore-start\") {\n rangeStart = comment.end;\n } else if (text === \"prettier-ignore-end\" && rangeStart !== undefined) {\n ranges.push({\n start: rangeStart,\n end: comment.start,\n });\n rangeStart = undefined;\n } else if (text === \"prettier-ignore\") {\n const next = nodes\n .filter(\n (node) =>\n !node.comment && node.start >= comment.end && source.slice(node.start, node.end).trim(),\n )\n .sort((a, b) => a.start - b.start || b.end - a.end)[0];\n if (next) {\n ranges.push({\n start: next.start,\n end: next.end,\n });\n }\n }\n }\n if (rangeStart !== undefined) {\n ranges.push({\n start: rangeStart,\n end: source.length,\n });\n }\n\n for (const script of scripts) {\n const text = source.slice(script.start, script.end);\n if (text.includes(\"prettier-ignore\")) {\n const scriptParser = typescriptParsers.typescript;\n const scriptOptions = { ...options, originalText: text };\n const scriptAst = await scriptParser.parse(text, scriptOptions);\n const protectedRanges = await ignoredRanges(scriptAst, scriptParser, text, scriptOptions);\n ranges.push(\n ...protectedRanges.map((range) => ({\n start: script.start + range.start,\n end: script.start + range.end,\n })),\n );\n }\n }\n\n return ranges;\n}\n","/**\n * Parser wrappers shared by the Node and browser entries. A wrapper sorts recognized Stillwind\n * inputs before the selected Prettier parser runs. The entry supplies the sorting service.\n */\n\nimport type { Parser, ParserOptions, Plugin, SupportOptions } from \"prettier\";\nimport { parsers as babelParsers } from \"prettier/plugins/babel\";\nimport { parsers as flowParsers } from \"prettier/plugins/flow\";\nimport { parsers as htmlParsers } from \"prettier/plugins/html\";\nimport { parsers as cssParsers } from \"prettier/plugins/postcss\";\nimport { parsers as typescriptParsers } from \"prettier/plugins/typescript\";\n\nimport { mapOffset } from \"./cursor.ts\";\nimport { ignoredRanges } from \"./ignore.ts\";\n\nconst processed = Symbol(\"stillwind.preprocessed\");\n\n/**\n * Prettier options shared with the delegated parser during one formatting operation.\n */\nexport type StillwindOptions = ParserOptions & {\n /** Configuration path resolved from cwd. Omission searches above the formatted file. */\n stillwindConfig?: string;\n /** Original UTF-16 cursor position, updated after sorting. A negative value disables mapping. */\n cursorOffset?: number;\n /** Marks an options object whose Stillwind preprocessing has already begun, including nested parses. */\n [processed]?: boolean;\n};\n\n/**\n * Original buffer and the ranges that sorting must leave untouched.\n */\nexport interface SortInput {\n /** Complete original text against which edits are measured. */\n source: string;\n /** Half-open UTF-16 ranges in `source`, from ignore directives and the formatting range. */\n protectedRanges: {\n /** Inclusive original UTF-16 offset. */\n start: number;\n /** Exclusive original UTF-16 offset. */\n end: number;\n }[];\n}\n\n/**\n * Sorted buffer and the edits that produced it.\n */\nexport interface SortOutput {\n /** Complete text after sorting. */\n code: string;\n /** Nonoverlapping replacements in `SortInput.source`, in ascending start order. */\n edits: readonly {\n /** Inclusive original UTF-16 offset. */\n start: number;\n /** Exclusive original UTF-16 offset. */\n end: number;\n /** Replacement text. */\n newText: string;\n }[];\n}\n\n/**\n * Selects the sorting service for one file before the wrapper parses it.\n *\n * @param filepath - Filepath supplied by Prettier, before path resolution.\n * @param options - Resolved Prettier options for this formatting operation.\n * @returns A function that sorts the buffer, or `undefined` to keep ordinary Prettier formatting.\n * @throws If the project configuration is invalid. The formatting request fails.\n */\nexport type SortResolver = (\n filepath: string,\n options: StillwindOptions,\n) =>\n | ((input: SortInput) => Promise<SortOutput>)\n | undefined\n | Promise<((input: SortInput) => Promise<SortOutput>) | undefined>;\n\nexport const options: SupportOptions = {\n stillwindConfig: {\n type: \"path\",\n category: \"Stillwind\",\n description: \"Path to stillwind.config.ts. Omission searches above the formatted file.\",\n },\n};\n\n/**\n * Prettier's built-in parsers that the wrappers delegate to when no preceding plugin applies.\n */\nexport const builtinParsers: Record<string, Parser> = {\n babel: babelParsers.babel,\n \"babel-ts\": babelParsers[\"babel-ts\"],\n flow: flowParsers.flow,\n typescript: typescriptParsers.typescript,\n vue: htmlParsers.vue,\n css: cssParsers.css,\n};\n\n/**\n * Wraps each parser so that it sorts the original buffer before delegating.\n *\n * @param bases - Fallback parsers keyed by Prettier parser name.\n * @param resolve - Selects the sorting service for each formatted file.\n * @returns Wrapper parsers with the same keys as `bases`.\n */\nexport function createParsers(\n bases: Record<string, Parser>,\n resolve: SortResolver,\n): Record<string, Parser> {\n return Object.fromEntries(\n Object.entries(bases).map(([name, base]) => {\n const wrapper: Parser = {\n ...base,\n /**\n * Sorts the original buffer before delegating language-specific preprocessing.\n *\n * @param text - Original source supplied by Prettier for this parser invocation.\n * @param rawOptions - Resolved Prettier options. The shared processed marker prevents nested\n * invocations from sorting again, and `cursorOffset` is mapped through the sorting edits.\n * Ignore directives and text outside the formatting range are protected from sorting.\n * @returns Sorted text after the delegate's preprocessing, or delegated original text when\n * the file is unsupported, already processed, or has no sorting service.\n * @throws If delegate loading, parsing, ignore extraction, configuration, or sorting fails.\n */\n async preprocess(text, rawOptions) {\n const current = rawOptions as StillwindOptions;\n const delegate = await delegateParser(name, wrapper, base, current);\n /**\n * Applies the delegate's preprocessing with the current shared options.\n *\n * @param source - Original or sorted buffer selected for this formatting invocation.\n * @returns The delegate's synchronous or asynchronous result, or unchanged text when absent.\n * @throws If the delegate fails, synchronously or through its returned promise.\n */\n const preprocess = (source: string) =>\n delegate.preprocess ? delegate.preprocess(source, current) : source;\n const source = text;\n if (current[processed] || !current.filepath || !matchesFile(name, current.filepath)) {\n return preprocess(source);\n }\n current[processed] = true;\n const sort = await resolve(current.filepath, current);\n if (!sort) {\n return preprocess(source);\n }\n const ast = await delegate.parse(source, {\n ...current,\n originalText: source,\n });\n const protectedRanges = await ignoredRanges(ast, delegate, source, current);\n if (current.rangeStart > 0) {\n protectedRanges.push({\n start: 0,\n end: current.rangeStart,\n });\n }\n if (current.rangeEnd < source.length) {\n protectedRanges.push({\n start: current.rangeEnd,\n end: source.length,\n });\n }\n const result = await sort({ source, protectedRanges });\n current.cursorOffset = mapOffset(current.cursorOffset ?? -1, source, result.edits);\n return preprocess(result.code);\n },\n /**\n * Parses the preprocessed buffer using the nearest preceding language plugin.\n *\n * @param text - Buffer after this wrapper's preprocessing.\n * @param rawOptions - Resolved Prettier options shared with the selected delegate.\n * @returns The delegate's AST without changing its representation.\n * @throws If delegate loading or parsing fails.\n */\n async parse(text, rawOptions) {\n const current = rawOptions as StillwindOptions;\n return (await delegateParser(name, wrapper, base, current)).parse(text, current);\n },\n };\n return [name, wrapper];\n }),\n );\n}\n\n/**\n * Selects the nearest preceding plugin that supplies the same parser name.\n *\n * @param name - Parser registry key used by this wrapper.\n * @param wrapper - Parser object used to identify this plugin in the resolved plugin list.\n * @param fallback - Built-in or optional language parser used when no preceding parser is found.\n * @param current - Resolved options whose object-valued plugins retain Prettier's plugin order.\n * @returns The selected parser, awaiting its factory when present. An absent wrapper also uses\n * the fallback.\n * @throws If the selected parser factory fails.\n */\nasync function delegateParser(\n name: string,\n wrapper: Parser,\n fallback: Parser,\n current: StillwindOptions,\n): Promise<Parser> {\n const plugins = current.plugins.filter((plugin): plugin is Plugin => typeof plugin === \"object\");\n const ownIndex = plugins.findIndex((plugin) => plugin.parsers?.[name] === wrapper);\n for (let index = ownIndex - 1; index >= 0; index--) {\n const parser = plugins[index].parsers?.[name];\n if (parser) {\n const candidate = parser as Parser | (() => Parser | Promise<Parser>);\n return typeof candidate === \"function\" ? candidate() : candidate;\n }\n }\n return fallback;\n}\n\n/**\n * Checks whether a filepath can be analyzed by the selected parser.\n *\n * @param parser - Prettier parser name. Component parsers require their exact lowercase suffix.\n * @param file - Filepath supplied by Prettier, before resolution to an absolute path.\n * @returns Whether the component suffix matches, the CSS parser has a case-insensitive `.css`\n * suffix, or a JS/TS suffix matches without a TypeScript declaration suffix.\n */\nfunction matchesFile(parser: string, file: string): boolean {\n if (parser === \"css\") {\n return /\\.css$/i.test(file);\n }\n if ([\"vue\", \"svelte\", \"astro\"].includes(parser)) {\n return file.endsWith(`.${parser}`);\n }\n return /\\.[cm]?[jt]sx?$/i.test(file) && !/\\.d\\.[cm]?ts$/i.test(file);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAaA,SAAgB,UAAU,QAAgB,QAAgB,OAAoC;CAC5F,IAAI,SAAS,GACX,OAAO;CAET,IAAI,QAAQ;CACZ,KAAK,MAAM,QAAQ,OAAO;EACxB,IAAI,SAAS,KAAK,OAChB;EAEF,IAAI,UAAU,KAAK,KAAK;GACtB,SAAS,KAAK,QAAQ,UAAU,KAAK,MAAM,KAAK;GAChD;EACF;EAEA,MAAM,QAAQ,CAAC,GADE,OAAO,MAAM,KAAK,OAAO,KAAK,GACtB,CAAC,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,MAC3C,UACC,MAAM,SAAS,SAAS,KAAK,SAAS,SAAS,KAAK,QAAQ,MAAM,QAAQ,MAAM,EAAE,CAAC,MACvF;EACA,IAAI,O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