prettier-plugin-stillwind 0.0.0 → 0.1.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Stillwind contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,88 @@
1
+ # Stillwind Prettier plugin
2
+
3
+ Stillwind compiles Tailwind CSS v4 utilities into component props and static CSS.
4
+ It uses theme rules and compiler checks to keep styling code in order, even when
5
+ AI agents write much of it.
6
+
7
+ `prettier-plugin-stillwind` is Stillwind's Prettier plugin. It sorts recognized
8
+ Stillwind inputs before Prettier formats a document.
9
+
10
+ ## Install
11
+
12
+ Install the plugin alongside Prettier 3.7 or newer within the 3.x series:
13
+
14
+ ```sh
15
+ vp i -D prettier prettier-plugin-stillwind
16
+ ```
17
+
18
+ ```js
19
+ // prettier.config.mjs
20
+ export default {
21
+ plugins: ["prettier-plugin-stillwind"],
22
+ };
23
+ ```
24
+
25
+ ## Languages and plugin order
26
+
27
+ JavaScript, JSX, TypeScript, TSX, and CSS use Prettier's existing parsers and printers. CSS sorting
28
+ uses `sort.applyUtilities` (true by default), `sort.applyStatements`, and `sort.variantBlocks`
29
+ (both false by default). Vue uses its built-in parser. Svelte and Astro require their language
30
+ plugins to be installed and loaded
31
+ before the Stillwind plugin:
32
+
33
+ ```js
34
+ export default {
35
+ plugins: ["prettier-plugin-svelte", "prettier-plugin-astro", "prettier-plugin-stillwind"],
36
+ };
37
+ ```
38
+
39
+ ## Configuration and behavior
40
+
41
+ The plugin uses the nearest `stillwind.config.*` above the file, including its project
42
+ scopes, theme CSS, and `sort` options. Sorting runs independently of the
43
+ `prefer-sorted-utilities` lint severity. Lint suppression comments control lint
44
+ diagnostics and fixes; explicit formatting still sorts.
45
+
46
+ Create a [Stillwind project configuration](https://stillwind.dev/docs/configuration)
47
+ before formatting. `stillwindConfig` can select an explicit configuration path relative to the working directory.
48
+ API callers must supply `filepath`; the plugin analyzes the supplied text, including unsaved
49
+ buffers. Files without a discovered configuration or outside its project scopes keep ordinary
50
+ Prettier formatting. Invalid explicit configuration and incomplete or conflicting analysis fail
51
+ the formatting request. The default entry runs in Node.js.
52
+
53
+ `prettier-ignore` protects the following syntax node from sorting. Range formatting protects
54
+ source outside the supplied range. CSS statement and variant movement also preserves the relative
55
+ order of competing property writes. Sorting preserves token spellings and source length, and
56
+ the adapter keeps cursors attached to uniquely identifiable tokens within reordered literals.
57
+ Duplicate or ambiguous tokens retain their relative cursor offset within the replacement.
58
+
59
+ The plugin only sorts. Canonical utility replacements are available through `stillwind lint --fix`.
60
+ Prettier owns saving files. The plugin reloads project configuration for each formatting request.
61
+
62
+ See [Editor sorting](https://github.com/SegaraRai/stillwind/blob/main/docs/standalone-analysis.md#editor-sorting)
63
+ for the shared sorting contract and [Lint policies](https://github.com/SegaraRai/stillwind/blob/main/docs/standalone-analysis.md#utility-lint-policies)
64
+ for canonical replacements and other checks.
65
+
66
+ ## Browser entry
67
+
68
+ Browsers cannot start the Node analysis process. `prettier-plugin-stillwind/browser` exports
69
+ `createStillwindPlugin(resolve)`, and the host supplies the sorting service through `resolve`:
70
+
71
+ ```js
72
+ import { createStillwindPlugin } from "prettier-plugin-stillwind/browser";
73
+ import { format } from "prettier/standalone";
74
+
75
+ const stillwind = createStillwindPlugin((filepath) =>
76
+ isProjectFile(filepath) ? (input) => sortWithLanguageServer(filepath, input) : undefined,
77
+ );
78
+ await format(source, {
79
+ filepath,
80
+ plugins: [estree, typescript, stillwind],
81
+ });
82
+ ```
83
+
84
+ `resolve` receives the filepath and the Prettier options. It returns `undefined` to keep ordinary
85
+ formatting, or a function that sorts `input.source`. That function must leave
86
+ `input.protectedRanges` untouched and return the sorted `code` with its `edits` in the original
87
+ text. The browser entry wraps Prettier's built-in parsers only, so Svelte and Astro files keep
88
+ ordinary formatting.
@@ -0,0 +1,12 @@
1
+ import { i as StillwindOptions, n as SortOutput, r as SortResolver, t as SortInput } from "./plugin-CnOVvMxh.js";
2
+ import { Plugin } from "prettier";
3
+ /**
4
+ * Creates a plugin object that sorts with a host-supplied service.
5
+ *
6
+ * @param resolve - Selects the sorting service for each formatted file. Returning `undefined`
7
+ * keeps ordinary Prettier formatting for that file.
8
+ * @returns A plugin to pass in Prettier's `plugins` option after language plugins.
9
+ */
10
+ export declare function createStillwindPlugin(resolve: SortResolver): Plugin;
11
+ export type { SortInput, SortOutput, SortResolver, StillwindOptions };
12
+ //# sourceMappingURL=browser.d.ts.map
@@ -0,0 +1,18 @@
1
+ import { n as createParsers, r as options, t as builtinParsers } from "./plugin-Dzvv8pEn.js";
2
+ // src/browser.ts
3
+ /**
4
+ * Creates a plugin object that sorts with a host-supplied service.
5
+ *
6
+ * @param resolve - Selects the sorting service for each formatted file. Returning `undefined`
7
+ * keeps ordinary Prettier formatting for that file.
8
+ * @returns A plugin to pass in Prettier's `plugins` option after language plugins.
9
+ */
10
+ function createStillwindPlugin(resolve) {
11
+ return {
12
+ options,
13
+ parsers: createParsers(builtinParsers, resolve)
14
+ };
15
+ }
16
+ export { createStillwindPlugin };
17
+
18
+ //# sourceMappingURL=browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.js","names":[],"sources":["../src/browser.ts"],"sourcesContent":["/**\n * Browser entry of the Stillwind Prettier plugin. Browsers cannot start the Node analysis\n * process, so the host supplies the sorting service, for example a language server that has\n * the project open. The plugin wraps Prettier's built-in JavaScript, TypeScript, Flow, Vue, and\n * CSS parsers. Svelte and Astro files keep ordinary formatting.\n */\n\nimport type { Plugin } from \"prettier\";\n\nimport { builtinParsers, createParsers, options, type SortResolver } from \"./plugin.ts\";\n\nexport type { SortInput, SortOutput, SortResolver, StillwindOptions } from \"./plugin.ts\";\n\n/**\n * Creates a plugin object that sorts with a host-supplied service.\n *\n * @param resolve - Selects the sorting service for each formatted file. Returning `undefined`\n * keeps ordinary Prettier formatting for that file.\n * @returns A plugin to pass in Prettier's `plugins` option after language plugins.\n */\nexport function createStillwindPlugin(resolve: SortResolver): Plugin {\n return {\n options,\n parsers: createParsers(builtinParsers, resolve),\n };\n}\n"],"mappings":";;;;;;;;;AAoBA,SAAgB,sBAAsB,SAA+B;CACnE,OAAO;EACL;EACA,SAAS,cAAc,gBAAgB,OAAO;CAChD;AACF"}
@@ -0,0 +1,5 @@
1
+ import { a as options } from "./plugin-CnOVvMxh.js";
2
+ import { Parser } from "prettier";
3
+ export declare const parsers: Record<string, Parser>;
4
+ export { options };
5
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,64 @@
1
+ import { n as createParsers, r as options, t as builtinParsers } from "./plugin-Dzvv8pEn.js";
2
+ import path from "node:path";
3
+ import { SourceFormatter, findFormatterConfig } from "@stillwind/analysis/node";
4
+ import process from "node:process";
5
+ // src/session.ts
6
+ /** Formatters shared by the exact configuration path across calls in this Node process. */
7
+ const sessions = /* @__PURE__ */ new Map();
8
+ /**
9
+ * Reuses a formatter for the configuration and releases it after 250 ms with no pending calls.
10
+ *
11
+ * @param config - Absolute configuration path used as the process-cache key.
12
+ * @param input - Unsaved original buffer and protected sorting ranges, in original UTF-16 coordinates.
13
+ * @returns Sorting output without writing the file. The pending count is restored on success or failure.
14
+ * @throws If the formatter cannot load the project or compute a valid rewrite.
15
+ */
16
+ async function sortBuffer(config, input) {
17
+ let session = sessions.get(config);
18
+ if (!session) {
19
+ session = {
20
+ formatter: new SourceFormatter(config),
21
+ pending: 0
22
+ };
23
+ sessions.set(config, session);
24
+ }
25
+ clearTimeout(session.timer);
26
+ session.pending++;
27
+ try {
28
+ return await session.formatter.format(input);
29
+ } finally {
30
+ session.pending--;
31
+ if (!session.pending) {
32
+ const current = session;
33
+ session.timer = setTimeout(() => {
34
+ sessions.delete(config);
35
+ current.formatter.close().catch((error) => process.stderr.write(String(error) + "\n"));
36
+ }, 250);
37
+ session.timer.unref();
38
+ }
39
+ }
40
+ }
41
+ // src/index.ts
42
+ /**
43
+ * Sorts recognized Stillwind inputs before the selected Prettier parser runs. Place this plugin
44
+ * after language plugins. The Node analysis process evaluates stillwind.config.ts and theme CSS;
45
+ * the adapter uses unsaved text and leaves file writes to Prettier.
46
+ */
47
+ const bases = { ...builtinParsers };
48
+ for (const name of ["prettier-plugin-svelte", "prettier-plugin-astro"]) try {
49
+ const plugin = await import(name);
50
+ Object.assign(bases, plugin.parsers);
51
+ } catch (error) {
52
+ if (!(error instanceof Error && "code" in error && error.code === "ERR_MODULE_NOT_FOUND" && error.message.includes(`'${name}'`))) throw error;
53
+ }
54
+ const parsers = createParsers(bases, (filepath, current) => {
55
+ const file = path.resolve(filepath);
56
+ const config = findFormatterConfig(file, current.stillwindConfig);
57
+ return config ? (input) => sortBuffer(config, {
58
+ ...input,
59
+ file
60
+ }) : void 0;
61
+ });
62
+ export { options, parsers };
63
+
64
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/session.ts","../src/index.ts"],"sourcesContent":["import process from \"node:process\";\n\nimport { SourceFormatter, type RewriteInput, type RewriteResult } from \"@stillwind/analysis/node\";\n\n/** Formatters shared by the exact configuration path across calls in this Node process. */\nconst sessions = new Map<\n string,\n {\n /** Isolated analysis process with serialized formatting requests. */\n formatter: SourceFormatter;\n /** Number of calls that have not settled, including calls waiting in the formatter queue. */\n pending: number;\n /** Unreferenced 250 ms timer that releases the idle process after the last call settles. */\n timer?: ReturnType<typeof setTimeout>;\n }\n>();\n\n/**\n * Reuses a formatter for the configuration and releases it after 250 ms with no pending calls.\n *\n * @param config - Absolute configuration path used as the process-cache key.\n * @param input - Unsaved original buffer and protected sorting ranges, in original UTF-16 coordinates.\n * @returns Sorting output without writing the file. The pending count is restored on success or failure.\n * @throws If the formatter cannot load the project or compute a valid rewrite.\n */\nexport async function sortBuffer(config: string, input: RewriteInput): Promise<RewriteResult> {\n let session = sessions.get(config);\n if (!session) {\n session = {\n formatter: new SourceFormatter(config),\n pending: 0,\n };\n sessions.set(config, session);\n }\n clearTimeout(session.timer);\n session.pending++;\n try {\n return await session.formatter.format(input);\n } finally {\n session.pending--;\n if (!session.pending) {\n const current = session;\n session.timer = setTimeout(() => {\n sessions.delete(config);\n void current.formatter\n .close()\n .catch((error: unknown) => process.stderr.write(String(error) + \"\\n\"));\n }, 250);\n session.timer.unref();\n }\n }\n}\n","/**\n * Sorts recognized Stillwind inputs before the selected Prettier parser runs. Place this plugin\n * after language plugins. The Node analysis process evaluates stillwind.config.ts and theme CSS;\n * the adapter uses unsaved text and leaves file writes to Prettier.\n */\n\nimport path from \"node:path\";\n\nimport { findFormatterConfig } from \"@stillwind/analysis/node\";\nimport type { Parser, Plugin } from \"prettier\";\n\nimport { builtinParsers, createParsers } from \"./plugin.ts\";\nimport { sortBuffer } from \"./session.ts\";\n\nexport { options } from \"./plugin.ts\";\n\nconst bases: Record<string, Parser> = { ...builtinParsers };\n\nfor (const name of [\"prettier-plugin-svelte\", \"prettier-plugin-astro\"] as const) {\n try {\n const plugin = (await import(name)) as Plugin;\n Object.assign(bases, plugin.parsers);\n } catch (error) {\n if (\n !(\n error instanceof Error &&\n \"code\" in error &&\n error.code === \"ERR_MODULE_NOT_FOUND\" &&\n error.message.includes(`'${name}'`)\n )\n ) {\n throw error;\n }\n }\n}\n\nexport const parsers: Record<string, Parser> = createParsers(bases, (filepath, current) => {\n const file = path.resolve(filepath);\n const config = findFormatterConfig(file, current.stillwindConfig);\n return config ? (input) => sortBuffer(config, { ...input, file }) : undefined;\n});\n"],"mappings":";;;;;;AAKA,MAAM,2BAAW,IAAI,IAUnB;;;;;;;;;AAUF,eAAsB,WAAW,QAAgB,OAA6C;CAC5F,IAAI,UAAU,SAAS,IAAI,MAAM;CACjC,IAAI,CAAC,SAAS;EACZ,UAAU;GACR,WAAW,IAAI,gBAAgB,MAAM;GACrC,SAAS;EACX;EACA,SAAS,IAAI,QAAQ,OAAO;CAC9B;CACA,aAAa,QAAQ,KAAK;CAC1B,QAAQ;CACR,IAAI;EACF,OAAO,MAAM,QAAQ,UAAU,OAAO,KAAK;CAC7C,UAAU;EACR,QAAQ;EACR,IAAI,CAAC,QAAQ,SAAS;GACpB,MAAM,UAAU;GAChB,QAAQ,QAAQ,iBAAiB;IAC/B,SAAS,OAAO,MAAM;IACtB,QAAa,UACV,MAAM,CAAC,CACP,OAAO,UAAmB,QAAQ,OAAO,MAAM,OAAO,KAAK,IAAI,IAAI,CAAC;GACzE,GAAG,GAAG;GACN,QAAQ,MAAM,MAAM;EACtB;CACF;AACF;;;;;;;ACnCA,MAAM,QAAgC,EAAE,GAAG,eAAe;AAE1D,KAAK,MAAM,QAAQ,CAAC,0BAA0B,uBAAuB,GACnE,IAAI;CACF,MAAM,SAAU,MAAM,OAAO;CAC7B,OAAO,OAAO,OAAO,OAAO,OAAO;AACrC,SAAS,OAAO;CACd,IACE,EACE,iBAAiB,SACjB,UAAU,SACV,MAAM,SAAS,0BACf,MAAM,QAAQ,SAAS,IAAI,KAAK,EAAE,IAGpC,MAAM;AAEV;AAGF,MAAa,UAAkC,cAAc,QAAQ,UAAU,YAAY;CACzF,MAAM,OAAO,KAAK,QAAQ,QAAQ;CAClC,MAAM,SAAS,oBAAoB,MAAM,QAAQ,eAAe;CAChE,OAAO,UAAU,UAAU,WAAW,QAAQ;EAAE,GAAG;EAAO;CAAK,CAAC,IAAI,KAAA;AACtE,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { Parser, ParserOptions, SupportOptions } from "prettier";
2
+ declare const processed: unique symbol;
3
+ /**
4
+ * Prettier options shared with the delegated parser during one formatting operation.
5
+ */
6
+ type StillwindOptions = ParserOptions & {
7
+ /** Configuration path resolved from cwd. Omission searches above the formatted file. */
8
+ stillwindConfig?: string;
9
+ /** Original UTF-16 cursor position, updated after sorting. A negative value disables mapping. */
10
+ cursorOffset?: number;
11
+ /** Marks an options object whose Stillwind preprocessing has already begun, including nested parses. */
12
+ [processed]?: boolean;
13
+ };
14
+ /**
15
+ * Original buffer and the ranges that sorting must leave untouched.
16
+ */
17
+ interface SortInput {
18
+ /** Complete original text against which edits are measured. */
19
+ source: string;
20
+ /** Half-open UTF-16 ranges in `source`, from ignore directives and the formatting range. */
21
+ protectedRanges: {
22
+ /** Inclusive original UTF-16 offset. */
23
+ start: number;
24
+ /** Exclusive original UTF-16 offset. */
25
+ end: number;
26
+ }[];
27
+ }
28
+ /**
29
+ * Sorted buffer and the edits that produced it.
30
+ */
31
+ interface SortOutput {
32
+ /** Complete text after sorting. */
33
+ code: string;
34
+ /** Nonoverlapping replacements in `SortInput.source`, in ascending start order. */
35
+ edits: readonly {
36
+ /** Inclusive original UTF-16 offset. */
37
+ start: number;
38
+ /** Exclusive original UTF-16 offset. */
39
+ end: number;
40
+ /** Replacement text. */
41
+ newText: string;
42
+ }[];
43
+ }
44
+ /**
45
+ * Selects the sorting service for one file before the wrapper parses it.
46
+ *
47
+ * @param filepath - Filepath supplied by Prettier, before path resolution.
48
+ * @param options - Resolved Prettier options for this formatting operation.
49
+ * @returns A function that sorts the buffer, or `undefined` to keep ordinary Prettier formatting.
50
+ * @throws If the project configuration is invalid. The formatting request fails.
51
+ */
52
+ type SortResolver = (filepath: string, options: StillwindOptions) => ((input: SortInput) => Promise<SortOutput>) | undefined | Promise<((input: SortInput) => Promise<SortOutput>) | undefined>;
53
+ declare const options: SupportOptions;
54
+ export { options as a, StillwindOptions as i, SortOutput as n, SortResolver as r, SortInput as t };
55
+ //# sourceMappingURL=plugin-CnOVvMxh.d.ts.map
@@ -0,0 +1,270 @@
1
+ import { parsers } from "prettier/plugins/babel";
2
+ import { parsers as parsers$1 } from "prettier/plugins/flow";
3
+ import { parsers as parsers$2 } from "prettier/plugins/html";
4
+ import { parsers as parsers$3 } from "prettier/plugins/postcss";
5
+ import { parsers as parsers$4 } from "prettier/plugins/typescript";
6
+ // src/cursor.ts
7
+ /**
8
+ * Maps an original UTF-16 cursor offset through nonoverlapping edits ordered by start.
9
+ * Negative offsets return unchanged. A cursor follows a token whose spelling occurs once in
10
+ * its replacement. Otherwise, the cursor keeps its relative position within the replacement.
11
+ *
12
+ * @param offset - Original UTF-16 cursor position, or a negative Prettier sentinel.
13
+ * @param source - Original text addressed by every edit range.
14
+ * @param edits - Nonoverlapping replacements in ascending original offset order.
15
+ * @returns The cursor position after the edits. A relative position is clamped to the replacement's
16
+ * length when no unique matching token is available. The input edits remain unchanged.
17
+ */
18
+ function mapOffset(offset, source, edits) {
19
+ if (offset < 0) return offset;
20
+ let delta = 0;
21
+ for (const edit of edits) {
22
+ if (offset < edit.start) break;
23
+ if (offset >= edit.end) {
24
+ delta += edit.newText.length - (edit.end - edit.start);
25
+ continue;
26
+ }
27
+ const token = [...source.slice(edit.start, edit.end).matchAll(/\S+/gu)].find((match) => match.index <= offset - edit.start && offset - edit.start < match.index + match[0].length);
28
+ if (token) {
29
+ const start = edit.newText.indexOf(token[0]);
30
+ if (start >= 0 && start === edit.newText.lastIndexOf(token[0])) return edit.start + delta + start + offset - edit.start - token.index;
31
+ }
32
+ return edit.start + delta + Math.min(offset - edit.start, edit.newText.length);
33
+ }
34
+ return offset + delta;
35
+ }
36
+ // src/ignore.ts
37
+ /**
38
+ * Finds ignored nodes and returns half-open UTF-16 ranges in the original source.
39
+ * Vue and Astro script bodies are parsed separately when they contain ignore directives.
40
+ *
41
+ * @param ast - AST parsed from `source` by `parser` before Stillwind edits are applied.
42
+ * @param parser - Parser whose location functions return original UTF-16 offsets for that AST.
43
+ * @param source - Original buffer, including comments and any embedded script delimiters.
44
+ * @param options - Parser options reused for embedded TypeScript parsing with its own original text.
45
+ * @returns Protected ranges in discovery order. Ranges can overlap, and an unmatched ignore-start
46
+ * protects the remaining source. Neither the AST nor the options object is changed.
47
+ * @throws If a parser location function fails or an embedded script cannot be parsed.
48
+ */
49
+ async function ignoredRanges(ast, parser, source, options) {
50
+ const nodes = [];
51
+ const scripts = [];
52
+ const seen = /* @__PURE__ */ new Set();
53
+ /**
54
+ * Collects valid node locations and embedded scripts while avoiding cycles and AST metadata.
55
+ *
56
+ * @param value - Root, child, or array from the supplied AST. Visited objects are added to `seen`,
57
+ * and valid source ranges are appended to `nodes` and `scripts` without changing those objects.
58
+ * @throws If the parser cannot provide a location for a node with a string kind.
59
+ */
60
+ const visit = (value) => {
61
+ if (!value || typeof value !== "object" || seen.has(value)) return;
62
+ seen.add(value);
63
+ if (Array.isArray(value)) {
64
+ for (const child of value) visit(child);
65
+ return;
66
+ }
67
+ const node = value;
68
+ const kind = node.type ?? node.kind;
69
+ if (typeof kind === "string") {
70
+ const start = parser.locStart(node);
71
+ const end = parser.locEnd(node);
72
+ if (Number.isInteger(start) && Number.isInteger(end) && start >= 0 && end > start && end <= source.length) {
73
+ nodes.push({
74
+ start,
75
+ end,
76
+ comment: /comment|^(?:Line|Block)$/i.test(kind)
77
+ });
78
+ if (kind === "AstroFrontmatter") scripts.push({
79
+ start: start + 3,
80
+ end: end - 3
81
+ });
82
+ else if (kind === "element" && node.name === "script" && Array.isArray(node.children)) for (const child of node.children) scripts.push({
83
+ start: parser.locStart(child),
84
+ end: parser.locEnd(child)
85
+ });
86
+ }
87
+ }
88
+ for (const [key, child] of Object.entries(node)) if (![
89
+ "parent",
90
+ "tokens",
91
+ "loc",
92
+ "position"
93
+ ].includes(key)) visit(child);
94
+ };
95
+ visit(ast);
96
+ const ranges = [];
97
+ const comments = nodes.filter((node) => node.comment).sort((a, b) => a.start - b.start);
98
+ let rangeStart;
99
+ for (const comment of comments) {
100
+ const text = source.slice(comment.start, comment.end).replace(/^(?:\/\/|\/\*|<!--)|(?:\*\/|-->)$/g, "").trim();
101
+ if (text === "prettier-ignore-start") rangeStart = comment.end;
102
+ else if (text === "prettier-ignore-end" && rangeStart !== void 0) {
103
+ ranges.push({
104
+ start: rangeStart,
105
+ end: comment.start
106
+ });
107
+ rangeStart = void 0;
108
+ } else if (text === "prettier-ignore") {
109
+ const next = nodes.filter((node) => !node.comment && node.start >= comment.end && source.slice(node.start, node.end).trim()).sort((a, b) => a.start - b.start || b.end - a.end)[0];
110
+ if (next) ranges.push({
111
+ start: next.start,
112
+ end: next.end
113
+ });
114
+ }
115
+ }
116
+ if (rangeStart !== void 0) ranges.push({
117
+ start: rangeStart,
118
+ end: source.length
119
+ });
120
+ for (const script of scripts) {
121
+ const text = source.slice(script.start, script.end);
122
+ if (text.includes("prettier-ignore")) {
123
+ const scriptParser = parsers$4.typescript;
124
+ const scriptOptions = {
125
+ ...options,
126
+ originalText: text
127
+ };
128
+ const protectedRanges = await ignoredRanges(await scriptParser.parse(text, scriptOptions), scriptParser, text, scriptOptions);
129
+ ranges.push(...protectedRanges.map((range) => ({
130
+ start: script.start + range.start,
131
+ end: script.start + range.end
132
+ })));
133
+ }
134
+ }
135
+ return ranges;
136
+ }
137
+ // src/plugin.ts
138
+ const processed = Symbol("stillwind.preprocessed");
139
+ const options = { stillwindConfig: {
140
+ type: "path",
141
+ category: "Stillwind",
142
+ description: "Path to stillwind.config.ts. Omission searches above the formatted file."
143
+ } };
144
+ /**
145
+ * Prettier's built-in parsers that the wrappers delegate to when no preceding plugin applies.
146
+ */
147
+ const builtinParsers = {
148
+ babel: parsers.babel,
149
+ "babel-ts": parsers["babel-ts"],
150
+ flow: parsers$1.flow,
151
+ typescript: parsers$4.typescript,
152
+ vue: parsers$2.vue,
153
+ css: parsers$3.css
154
+ };
155
+ /**
156
+ * Wraps each parser so that it sorts the original buffer before delegating.
157
+ *
158
+ * @param bases - Fallback parsers keyed by Prettier parser name.
159
+ * @param resolve - Selects the sorting service for each formatted file.
160
+ * @returns Wrapper parsers with the same keys as `bases`.
161
+ */
162
+ function createParsers(bases, resolve) {
163
+ return Object.fromEntries(Object.entries(bases).map(([name, base]) => {
164
+ const wrapper = {
165
+ ...base,
166
+ /**
167
+ * Sorts the original buffer before delegating language-specific preprocessing.
168
+ *
169
+ * @param text - Original source supplied by Prettier for this parser invocation.
170
+ * @param rawOptions - Resolved Prettier options. The shared processed marker prevents nested
171
+ * invocations from sorting again, and `cursorOffset` is mapped through the sorting edits.
172
+ * Ignore directives and text outside the formatting range are protected from sorting.
173
+ * @returns Sorted text after the delegate's preprocessing, or delegated original text when
174
+ * the file is unsupported, already processed, or has no sorting service.
175
+ * @throws If delegate loading, parsing, ignore extraction, configuration, or sorting fails.
176
+ */
177
+ async preprocess(text, rawOptions) {
178
+ const current = rawOptions;
179
+ const delegate = await delegateParser(name, wrapper, base, current);
180
+ /**
181
+ * Applies the delegate's preprocessing with the current shared options.
182
+ *
183
+ * @param source - Original or sorted buffer selected for this formatting invocation.
184
+ * @returns The delegate's synchronous or asynchronous result, or unchanged text when absent.
185
+ * @throws If the delegate fails, synchronously or through its returned promise.
186
+ */
187
+ const preprocess = (source) => delegate.preprocess ? delegate.preprocess(source, current) : source;
188
+ const source = text;
189
+ if (current[processed] || !current.filepath || !matchesFile(name, current.filepath)) return preprocess(source);
190
+ current[processed] = true;
191
+ const sort = await resolve(current.filepath, current);
192
+ if (!sort) return preprocess(source);
193
+ const protectedRanges = await ignoredRanges(await delegate.parse(source, {
194
+ ...current,
195
+ originalText: source
196
+ }), delegate, source, current);
197
+ if (current.rangeStart > 0) protectedRanges.push({
198
+ start: 0,
199
+ end: current.rangeStart
200
+ });
201
+ if (current.rangeEnd < source.length) protectedRanges.push({
202
+ start: current.rangeEnd,
203
+ end: source.length
204
+ });
205
+ const result = await sort({
206
+ source,
207
+ protectedRanges
208
+ });
209
+ current.cursorOffset = mapOffset(current.cursorOffset ?? -1, source, result.edits);
210
+ return preprocess(result.code);
211
+ },
212
+ /**
213
+ * Parses the preprocessed buffer using the nearest preceding language plugin.
214
+ *
215
+ * @param text - Buffer after this wrapper's preprocessing.
216
+ * @param rawOptions - Resolved Prettier options shared with the selected delegate.
217
+ * @returns The delegate's AST without changing its representation.
218
+ * @throws If delegate loading or parsing fails.
219
+ */
220
+ async parse(text, rawOptions) {
221
+ const current = rawOptions;
222
+ return (await delegateParser(name, wrapper, base, current)).parse(text, current);
223
+ }
224
+ };
225
+ return [name, wrapper];
226
+ }));
227
+ }
228
+ /**
229
+ * Selects the nearest preceding plugin that supplies the same parser name.
230
+ *
231
+ * @param name - Parser registry key used by this wrapper.
232
+ * @param wrapper - Parser object used to identify this plugin in the resolved plugin list.
233
+ * @param fallback - Built-in or optional language parser used when no preceding parser is found.
234
+ * @param current - Resolved options whose object-valued plugins retain Prettier's plugin order.
235
+ * @returns The selected parser, awaiting its factory when present. An absent wrapper also uses
236
+ * the fallback.
237
+ * @throws If the selected parser factory fails.
238
+ */
239
+ async function delegateParser(name, wrapper, fallback, current) {
240
+ const plugins = current.plugins.filter((plugin) => typeof plugin === "object");
241
+ const ownIndex = plugins.findIndex((plugin) => plugin.parsers?.[name] === wrapper);
242
+ for (let index = ownIndex - 1; index >= 0; index--) {
243
+ const parser = plugins[index].parsers?.[name];
244
+ if (parser) {
245
+ const candidate = parser;
246
+ return typeof candidate === "function" ? candidate() : candidate;
247
+ }
248
+ }
249
+ return fallback;
250
+ }
251
+ /**
252
+ * Checks whether a filepath can be analyzed by the selected parser.
253
+ *
254
+ * @param parser - Prettier parser name. Component parsers require their exact lowercase suffix.
255
+ * @param file - Filepath supplied by Prettier, before resolution to an absolute path.
256
+ * @returns Whether the component suffix matches, the CSS parser has a case-insensitive `.css`
257
+ * suffix, or a JS/TS suffix matches without a TypeScript declaration suffix.
258
+ */
259
+ function matchesFile(parser, file) {
260
+ if (parser === "css") return /\.css$/i.test(file);
261
+ if ([
262
+ "vue",
263
+ "svelte",
264
+ "astro"
265
+ ].includes(parser)) return file.endsWith(`.${parser}`);
266
+ return /\.[cm]?[jt]sx?$/i.test(file) && !/\.d\.[cm]?ts$/i.test(file);
267
+ }
268
+ export { createParsers as n, options as r, builtinParsers as t };
269
+
270
+ //# sourceMappingURL=plugin-Dzvv8pEn.js.map
@@ -0,0 +1 @@
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,OAAO;GACT,MAAM,QAAQ,KAAK,QAAQ,QAAQ,MAAM,EAAE;GAC3C,IAAI,SAAS,KAAK,UAAU,KAAK,QAAQ,YAAY,MAAM,EAAE,GAC3D,OAAO,KAAK,QAAQ,QAA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,OAAO,QAAQ;KACf,KAAK,OAAO;IACd,CAAC;IAEH,MAAM,SAAS,MAAM,KAAK;KAAE;KAAQ;IAAgB,CAAC;IACrD,QAAQ,eAAe,UAAU,QAAQ,gBAAgB,IAAI,QAAQ,OAAO,KAAK;IACjF,OAAO,WAAW,OAAO,IAAI;GAC/B;;;;;;;;;GASA,MAAM,MAAM,MAAM,YAAY;IAC5B,MAAM,UAAU;IAChB,QAAQ,MAAM,eAAe,MAAM,SAAS,MAAM,OAAO,EAAA,CAAG,MAAM,MAAM,OAAO;GACjF;EACF;EACA,OAAO,CAAC,MAAM,OAAO;CACvB,CAAC,CACH;AACF;;;;;;;;;;;;AAaA,eAAe,eACb,MACA,SACA,UACA,SACiB;CACjB,MAAM,UAAU,QAAQ,QAAQ,QAAQ,WAA6B,OAAO,WAAW,QAAQ;CAC/F,MAAM,WAAW,QAAQ,WAAW,WAAW,OAAO,UAAU,UAAU,OAAO;CACjF,KAAK,IAAI,QAAQ,WAAW,GAAG,SAAS,GAAG,SAAS;EAClD,MAAM,SAAS,QAAQ,MAAM,CAAC,UAAU;EACxC,IAAI,QAAQ;GACV,MAAM,YAAY;GAClB,OAAO,OAAO,cAAc,aAAa,UAAU,IAAI;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,11 +1,59 @@
1
1
  {
2
2
  "name": "prettier-plugin-stillwind",
3
- "version": "0.0.0",
4
- "description": "Placeholder for prettier-plugin-stillwind",
5
- "main": "index.js",
6
- "scripts": {},
7
- "keywords": [],
8
- "author": "segararai (https://www.npmjs.com/~segararai)",
9
- "license": "UNLICENSED",
10
- "private": false
3
+ "version": "0.1.0-rc.0",
4
+ "description": "Stillwind utility sorting for Prettier",
5
+ "homepage": "https://stillwind.dev/",
6
+ "bugs": {
7
+ "url": "https://github.com/SegaraRai/stillwind/issues"
8
+ },
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/SegaraRai/stillwind.git",
13
+ "directory": "packages/prettier-plugin"
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "type": "module",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "default": "./dist/index.js"
23
+ },
24
+ "./browser": {
25
+ "types": "./dist/browser.d.ts",
26
+ "default": "./dist/browser.js"
27
+ },
28
+ "./package.json": "./package.json"
29
+ },
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "dependencies": {
34
+ "@stillwind/analysis": "0.1.0-rc.0"
35
+ },
36
+ "devDependencies": {
37
+ "@stillwind-internal/tools-workspace": "0.0.0",
38
+ "@types/node": "^26.6.5",
39
+ "prettier": "^3.9.10",
40
+ "prettier-plugin-astro": "^1.1.2",
41
+ "prettier-plugin-svelte": "^4.1.1",
42
+ "svelte": "^5.57.3",
43
+ "typescript": "^6.0.3",
44
+ "vite-plus": "1.4.0"
45
+ },
46
+ "peerDependencies": {
47
+ "prettier": ">=3.7.0 <4",
48
+ "prettier-plugin-astro": ">=0.14 <2",
49
+ "prettier-plugin-svelte": ">=3 <5"
50
+ },
51
+ "peerDependenciesMeta": {
52
+ "prettier-plugin-astro": {
53
+ "optional": true
54
+ },
55
+ "prettier-plugin-svelte": {
56
+ "optional": true
57
+ }
58
+ }
11
59
  }
package/index.js DELETED
@@ -1 +0,0 @@
1
- // Placeholder