oxfmt 0.38.0 → 0.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1210 @@
1
+ import { a as __toESM, t as __commonJSMin } from "./chunk-DSjvVL_1-BYdvZw3N.js";
2
+ import { n as loadIfExists, r as maybeResolve, t as expiringMap } from "./resolve-pWjAK-4f-C1Z6M6r2.js";
3
+ import { i as visit, n as cacheForDirs, r as spliceChangesIntoString } from "./utils-D8dQkKEd-BtAa7w-M.js";
4
+ import { a as sortClasses, i as sortClassList, n as error, o as warn, r as getTailwindConfig$1 } from "./sorter-BZkvDMjt-tVbe6MxP.js";
5
+ import { parsers as sn } from "./angular-BS7_jn7o.js";
6
+ import { parsers as ra, t as babel_exports } from "./babel-CL6HLzZ0.js";
7
+ import { parsers as en, t as postcss_exports } from "./postcss-k2aCwkzC.js";
8
+ import index_exports from "./prettier-DmvT5K0i.js";
9
+ import * as path from "node:path";
10
+ import { isAbsolute } from "path";
11
+ //#region ../../node_modules/.pnpm/prettier-plugin-tailwindcss@0.0.0-insiders.3997fbd_prettier@3.8.1/node_modules/prettier-plugin-tailwindcss/dist/index.mjs
12
+ var require_isarray = /* @__PURE__ */ __commonJSMin(((exports, module) => {
13
+ var toString = {}.toString;
14
+ module.exports = Array.isArray || function(arr) {
15
+ return toString.call(arr) == "[object Array]";
16
+ };
17
+ }));
18
+ /*!
19
+ * isobject <https://github.com/jonschlinkert/isobject>
20
+ *
21
+ * Copyright (c) 2014-2015, Jon Schlinkert.
22
+ * Licensed under the MIT License.
23
+ */
24
+ var require_isobject = /* @__PURE__ */ __commonJSMin(((exports, module) => {
25
+ var isArray = require_isarray();
26
+ module.exports = function isObject(val) {
27
+ return val != null && typeof val === "object" && isArray(val) === false;
28
+ };
29
+ }));
30
+ var import_line_column = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
31
+ var isArray = require_isarray();
32
+ var isObject = require_isobject();
33
+ Array.prototype.slice;
34
+ module.exports = LineColumnFinder;
35
+ function LineColumnFinder(str, options) {
36
+ if (!(this instanceof LineColumnFinder)) {
37
+ if (typeof options === "number") return new LineColumnFinder(str).fromIndex(options);
38
+ return new LineColumnFinder(str, options);
39
+ }
40
+ this.str = str || "";
41
+ this.lineToIndex = buildLineToIndex(this.str);
42
+ options = options || {};
43
+ this.origin = typeof options.origin === "undefined" ? 1 : options.origin;
44
+ }
45
+ LineColumnFinder.prototype.fromIndex = function(index) {
46
+ if (index < 0 || index >= this.str.length || isNaN(index)) return null;
47
+ var line = findLowerIndexInRangeArray(index, this.lineToIndex);
48
+ return {
49
+ line: line + this.origin,
50
+ col: index - this.lineToIndex[line] + this.origin
51
+ };
52
+ };
53
+ LineColumnFinder.prototype.toIndex = function(line, column) {
54
+ if (typeof column === "undefined") {
55
+ if (isArray(line) && line.length >= 2) return this.toIndex(line[0], line[1]);
56
+ if (isObject(line) && "line" in line && ("col" in line || "column" in line)) return this.toIndex(line.line, "col" in line ? line.col : line.column);
57
+ return -1;
58
+ }
59
+ if (isNaN(line) || isNaN(column)) return -1;
60
+ line -= this.origin;
61
+ column -= this.origin;
62
+ if (line >= 0 && column >= 0 && line < this.lineToIndex.length) {
63
+ var lineIndex = this.lineToIndex[line];
64
+ var nextIndex = line === this.lineToIndex.length - 1 ? this.str.length : this.lineToIndex[line + 1];
65
+ if (column < nextIndex - lineIndex) return lineIndex + column;
66
+ }
67
+ return -1;
68
+ };
69
+ function buildLineToIndex(str) {
70
+ var lines = str.split("\n"), lineToIndex = new Array(lines.length), index = 0;
71
+ for (var i = 0, l = lines.length; i < l; i++) {
72
+ lineToIndex[i] = index;
73
+ index += lines[i].length + 1;
74
+ }
75
+ return lineToIndex;
76
+ }
77
+ function findLowerIndexInRangeArray(value, arr) {
78
+ if (value >= arr[arr.length - 1]) return arr.length - 1;
79
+ var min = 0, max = arr.length - 2, mid;
80
+ while (min < max) {
81
+ mid = min + (max - min >> 1);
82
+ if (value < arr[mid]) max = mid - 1;
83
+ else if (value >= arr[mid + 1]) min = mid + 1;
84
+ else {
85
+ min = mid;
86
+ break;
87
+ }
88
+ }
89
+ return min;
90
+ }
91
+ })))(), 1);
92
+ let prettierConfigCache = expiringMap(1e4);
93
+ async function resolvePrettierConfigDir(filePath, inputDir) {
94
+ let cached = prettierConfigCache.get(inputDir);
95
+ if (cached !== void 0) return cached ?? process.cwd();
96
+ const resolve = async () => {
97
+ try {
98
+ return await index_exports.resolveConfigFile(filePath);
99
+ } catch (err) {
100
+ error("prettier-config-not-found", "Failed to resolve Prettier Config");
101
+ error("prettier-config-not-found-err", err);
102
+ return null;
103
+ }
104
+ };
105
+ let prettierConfig = await resolve();
106
+ if (prettierConfig) {
107
+ let configDir = path.dirname(prettierConfig);
108
+ cacheForDirs(prettierConfigCache, inputDir, configDir, configDir);
109
+ return configDir;
110
+ } else {
111
+ prettierConfigCache.set(inputDir, null);
112
+ return process.cwd();
113
+ }
114
+ }
115
+ async function getTailwindConfig(options) {
116
+ let cwd = process.cwd();
117
+ let inputDir = options.filepath ? path.dirname(options.filepath) : cwd;
118
+ let needsPrettierConfig = options.tailwindConfig && !path.isAbsolute(options.tailwindConfig) || options.tailwindStylesheet && !path.isAbsolute(options.tailwindStylesheet) || options.tailwindEntryPoint && !path.isAbsolute(options.tailwindEntryPoint);
119
+ let configDir;
120
+ if (needsPrettierConfig) configDir = await resolvePrettierConfigDir(options.filepath, inputDir);
121
+ else configDir = cwd;
122
+ let configPath = options.tailwindConfig && !options.tailwindConfig.endsWith(".css") ? options.tailwindConfig : void 0;
123
+ let stylesheetPath = options.tailwindStylesheet;
124
+ if (!stylesheetPath && options.tailwindEntryPoint) {
125
+ warn("entrypoint-is-deprecated", configDir, "Deprecated: Use the `tailwindStylesheet` option for v4 projects instead of `tailwindEntryPoint`.");
126
+ stylesheetPath = options.tailwindEntryPoint;
127
+ }
128
+ if (!stylesheetPath && options.tailwindConfig && options.tailwindConfig.endsWith(".css")) {
129
+ warn("config-as-css-is-deprecated", configDir, "Deprecated: Use the `tailwindStylesheet` option for v4 projects instead of `tailwindConfig`.");
130
+ stylesheetPath = options.tailwindConfig;
131
+ }
132
+ return getTailwindConfig$1({
133
+ base: configDir,
134
+ filepath: options.filepath,
135
+ configPath,
136
+ stylesheetPath,
137
+ packageName: options.tailwindPackageName
138
+ });
139
+ }
140
+ const options = {
141
+ tailwindConfig: {
142
+ type: "string",
143
+ category: "Tailwind CSS",
144
+ description: "Path to Tailwind configuration file"
145
+ },
146
+ tailwindEntryPoint: {
147
+ type: "string",
148
+ category: "Tailwind CSS",
149
+ description: "Path to the CSS entrypoint in your Tailwind project (v4+)"
150
+ },
151
+ tailwindStylesheet: {
152
+ type: "string",
153
+ category: "Tailwind CSS",
154
+ description: "Path to the CSS stylesheet in your Tailwind project (v4+)"
155
+ },
156
+ tailwindAttributes: {
157
+ type: "string",
158
+ array: true,
159
+ default: [{ value: [] }],
160
+ category: "Tailwind CSS",
161
+ description: "List of attributes/props that contain sortable Tailwind classes"
162
+ },
163
+ tailwindFunctions: {
164
+ type: "string",
165
+ array: true,
166
+ default: [{ value: [] }],
167
+ category: "Tailwind CSS",
168
+ description: "List of functions and tagged templates that contain sortable Tailwind classes"
169
+ },
170
+ tailwindPreserveWhitespace: {
171
+ type: "boolean",
172
+ default: false,
173
+ category: "Tailwind CSS",
174
+ description: "Preserve whitespace around Tailwind classes when sorting"
175
+ },
176
+ tailwindPreserveDuplicates: {
177
+ type: "boolean",
178
+ default: false,
179
+ category: "Tailwind CSS",
180
+ description: "Preserve duplicate classes inside a class list when sorting"
181
+ },
182
+ tailwindPackageName: {
183
+ type: "string",
184
+ default: "tailwindcss",
185
+ category: "Tailwind CSS",
186
+ description: "The package name to use when loading Tailwind CSS"
187
+ }
188
+ };
189
+ function createMatcher(options, parser, defaults) {
190
+ let staticAttrs = new Set(defaults.staticAttrs);
191
+ let dynamicAttrs = new Set(defaults.dynamicAttrs);
192
+ let functions = new Set(defaults.functions);
193
+ let staticAttrsRegex = [...defaults.staticAttrsRegex];
194
+ let functionsRegex = [...defaults.functionsRegex];
195
+ for (let attr of options.tailwindAttributes ?? []) {
196
+ let regex = parseRegex(attr);
197
+ if (regex) staticAttrsRegex.push(regex);
198
+ else if (parser === "vue" && attr.startsWith(":")) staticAttrs.add(attr.slice(1));
199
+ else if (parser === "vue" && attr.startsWith("v-bind:")) staticAttrs.add(attr.slice(7));
200
+ else if (parser === "vue" && attr.startsWith("v-")) dynamicAttrs.add(attr);
201
+ else if (parser === "angular" && attr.startsWith("[") && attr.endsWith("]")) staticAttrs.add(attr.slice(1, -1));
202
+ else staticAttrs.add(attr);
203
+ }
204
+ for (let attr of staticAttrs) if (parser === "vue") {
205
+ dynamicAttrs.add(`:${attr}`);
206
+ dynamicAttrs.add(`v-bind:${attr}`);
207
+ } else if (parser === "angular") dynamicAttrs.add(`[${attr}]`);
208
+ for (let fn of options.tailwindFunctions ?? []) {
209
+ let regex = parseRegex(fn);
210
+ if (regex) functionsRegex.push(regex);
211
+ else functions.add(fn);
212
+ }
213
+ return {
214
+ hasStaticAttr: (name) => {
215
+ if (nameFromDynamicAttr(name, parser)) return false;
216
+ return hasMatch(name, staticAttrs, staticAttrsRegex);
217
+ },
218
+ hasDynamicAttr: (name) => {
219
+ if (hasMatch(name, dynamicAttrs, [])) return true;
220
+ let newName = nameFromDynamicAttr(name, parser);
221
+ if (!newName) return false;
222
+ return hasMatch(newName, staticAttrs, staticAttrsRegex);
223
+ },
224
+ hasFunction: (name) => hasMatch(name, functions, functionsRegex)
225
+ };
226
+ }
227
+ function nameFromDynamicAttr(name, parser) {
228
+ if (parser === "vue") {
229
+ if (name.startsWith(":")) return name.slice(1);
230
+ if (name.startsWith("v-bind:")) return name.slice(7);
231
+ if (name.startsWith("v-")) return name;
232
+ return null;
233
+ }
234
+ if (parser === "angular") {
235
+ if (name.startsWith("[") && name.endsWith("]")) return name.slice(1, -1);
236
+ return null;
237
+ }
238
+ return null;
239
+ }
240
+ function hasMatch(name, list, patterns) {
241
+ if (list.has(name)) return true;
242
+ for (let regex of patterns) if (regex.test(name)) return true;
243
+ return false;
244
+ }
245
+ function parseRegex(str) {
246
+ if (!str.startsWith("/")) return null;
247
+ let lastSlash = str.lastIndexOf("/");
248
+ if (lastSlash <= 0) return null;
249
+ try {
250
+ let pattern = str.slice(1, lastSlash);
251
+ let flags = str.slice(lastSlash + 1);
252
+ return new RegExp(pattern, flags);
253
+ } catch {
254
+ return null;
255
+ }
256
+ }
257
+ function createPlugin(transforms) {
258
+ let parsers = Object.create(null);
259
+ let printers = Object.create(null);
260
+ for (let opts of transforms) {
261
+ for (let [name, meta] of Object.entries(opts.parsers)) parsers[name] = async () => {
262
+ var _plugin$parsers;
263
+ let original = (_plugin$parsers = (await loadPlugins(meta.load ?? opts.load ?? [])).parsers) === null || _plugin$parsers === void 0 ? void 0 : _plugin$parsers[name];
264
+ if (!original) return;
265
+ parsers[name] = await createParser({
266
+ name,
267
+ original,
268
+ opts
269
+ });
270
+ return parsers[name];
271
+ };
272
+ for (let [name, _meta] of Object.entries(opts.printers ?? {})) printers[name] = async () => {
273
+ var _plugin$printers;
274
+ let original = (_plugin$printers = (await loadPlugins(opts.load ?? [])).printers) === null || _plugin$printers === void 0 ? void 0 : _plugin$printers[name];
275
+ if (!original) return;
276
+ printers[name] = createPrinter({
277
+ original,
278
+ opts
279
+ });
280
+ return printers[name];
281
+ };
282
+ }
283
+ return {
284
+ parsers,
285
+ printers
286
+ };
287
+ }
288
+ async function createParser({ name, original, opts }) {
289
+ let parser = { ...original };
290
+ async function load(options) {
291
+ let parser = { ...original };
292
+ for (const pluginName of opts.compatible || []) {
293
+ var _plugin$parsers2;
294
+ let plugin = await findEnabledPlugin(options, pluginName);
295
+ if (plugin === null || plugin === void 0 || (_plugin$parsers2 = plugin.parsers) === null || _plugin$parsers2 === void 0 ? void 0 : _plugin$parsers2[name]) Object.assign(parser, plugin.parsers[name]);
296
+ }
297
+ return parser;
298
+ }
299
+ parser.preprocess = async (code, options) => {
300
+ let parser = await load(options);
301
+ return parser.preprocess ? parser.preprocess(code, options) : code;
302
+ };
303
+ parser.parse = async (code, options) => {
304
+ let ast = await (await load(options)).parse(code, options, options);
305
+ let env = await loadTailwindCSS({
306
+ opts,
307
+ options
308
+ });
309
+ transformAst({
310
+ ast,
311
+ env,
312
+ opts,
313
+ options
314
+ });
315
+ options.__tailwindcss__ = env;
316
+ return ast;
317
+ };
318
+ return parser;
319
+ }
320
+ function createPrinter({ original, opts }) {
321
+ let printer = { ...original };
322
+ let reprint = opts.reprint;
323
+ if (reprint) {
324
+ printer.print = new Proxy(original.print, { apply(target, thisArg, args) {
325
+ let [path, options] = args;
326
+ let env = options.__tailwindcss__;
327
+ reprint(path, {
328
+ ...env,
329
+ options
330
+ });
331
+ return Reflect.apply(target, thisArg, args);
332
+ } });
333
+ if (original.embed) printer.embed = new Proxy(original.embed, { apply(target, thisArg, args) {
334
+ let [path, options] = args;
335
+ let env = options.__tailwindcss__;
336
+ reprint(path, {
337
+ ...env,
338
+ options
339
+ });
340
+ return Reflect.apply(target, thisArg, args);
341
+ } });
342
+ }
343
+ return printer;
344
+ }
345
+ async function loadPlugins(fns) {
346
+ let plugin = {
347
+ parsers: Object.create(null),
348
+ printers: Object.create(null),
349
+ options: Object.create(null),
350
+ defaultOptions: Object.create(null),
351
+ languages: []
352
+ };
353
+ for (let source of fns) {
354
+ let loaded = await loadPlugin(source);
355
+ Object.assign(plugin.parsers, loaded.parsers ?? {});
356
+ Object.assign(plugin.printers, loaded.printers ?? {});
357
+ Object.assign(plugin.options, loaded.options ?? {});
358
+ Object.assign(plugin.defaultOptions, loaded.defaultOptions ?? {});
359
+ plugin.languages = [...plugin.languages ?? [], ...loaded.languages ?? []];
360
+ }
361
+ return plugin;
362
+ }
363
+ const EMPTY_PLUGIN = {
364
+ parsers: {},
365
+ printers: {},
366
+ languages: [],
367
+ options: {},
368
+ defaultOptions: {}
369
+ };
370
+ async function loadPlugin(source) {
371
+ if ("importer" in source && typeof source.importer === "function") return normalizePlugin(await source.importer());
372
+ return source;
373
+ }
374
+ function normalizePlugin(source) {
375
+ if (source === null || typeof source !== "object") return EMPTY_PLUGIN;
376
+ let plugin = source.default;
377
+ return plugin && typeof plugin === "object" ? plugin : source;
378
+ }
379
+ function findEnabledPlugin(options, name) {
380
+ for (let plugin of options.plugins) {
381
+ if (plugin instanceof URL) {
382
+ if (plugin.protocol !== "file:") continue;
383
+ if (plugin.hostname !== "") continue;
384
+ plugin = plugin.pathname;
385
+ }
386
+ if (typeof plugin !== "string") {
387
+ if (!plugin.name) continue;
388
+ plugin = plugin.name;
389
+ }
390
+ if (plugin === name || isAbsolute(plugin) && plugin.includes(name) && maybeResolve(name) === plugin) return loadIfExists(name);
391
+ }
392
+ }
393
+ async function loadTailwindCSS({ options, opts }) {
394
+ var _parsers$parser, _parsers$parser2;
395
+ let parsers = opts.parsers;
396
+ let parser = options.parser;
397
+ return {
398
+ context: await getTailwindConfig(options),
399
+ matcher: createMatcher(options, parser, {
400
+ staticAttrs: new Set(((_parsers$parser = parsers[parser]) === null || _parsers$parser === void 0 ? void 0 : _parsers$parser.staticAttrs) ?? opts.staticAttrs ?? []),
401
+ dynamicAttrs: new Set(((_parsers$parser2 = parsers[parser]) === null || _parsers$parser2 === void 0 ? void 0 : _parsers$parser2.dynamicAttrs) ?? opts.dynamicAttrs ?? []),
402
+ functions: /* @__PURE__ */ new Set(),
403
+ staticAttrsRegex: [],
404
+ dynamicAttrsRegex: [],
405
+ functionsRegex: []
406
+ }),
407
+ options,
408
+ changes: []
409
+ };
410
+ }
411
+ function transformAst({ ast, env, opts }) {
412
+ let transform = opts.transform;
413
+ if (transform) transform(ast, env);
414
+ }
415
+ function defineTransform(opts) {
416
+ return opts;
417
+ }
418
+ const ESCAPE_SEQUENCE_PATTERN = /\\(['"\\nrtbfv0-7xuU])/g;
419
+ function tryParseAngularAttribute(value, env) {
420
+ try {
421
+ return sn.__ng_directive.parse(value, env.options);
422
+ } catch (err) {
423
+ console.warn("prettier-plugin-tailwindcss: Unable to parse angular directive");
424
+ console.warn(err);
425
+ return null;
426
+ }
427
+ }
428
+ function transformDynamicAngularAttribute(attr, env) {
429
+ let directiveAst = tryParseAngularAttribute(attr.value, env);
430
+ if (!directiveAst) return;
431
+ let changes = [];
432
+ visit(directiveAst, {
433
+ StringLiteral(node, path) {
434
+ if (!node.value) return;
435
+ let collapseWhitespace = canCollapseWhitespaceIn(path, env);
436
+ changes.push({
437
+ start: node.start + 1,
438
+ end: node.end - 1,
439
+ before: node.value,
440
+ after: sortClasses(node.value, {
441
+ env,
442
+ collapseWhitespace
443
+ })
444
+ });
445
+ },
446
+ TemplateLiteral(node, path) {
447
+ if (!node.quasis.length) return;
448
+ let collapseWhitespace = canCollapseWhitespaceIn(path, env);
449
+ for (let i = 0; i < node.quasis.length; i++) {
450
+ let quasi = node.quasis[i];
451
+ changes.push({
452
+ start: quasi.start,
453
+ end: quasi.end,
454
+ before: quasi.value.raw,
455
+ after: sortClasses(quasi.value.raw, {
456
+ env,
457
+ ignoreFirst: i > 0 && !/^\s/.test(quasi.value.raw),
458
+ ignoreLast: i < node.expressions.length && !/\s$/.test(quasi.value.raw),
459
+ collapseWhitespace: collapseWhitespace ? {
460
+ start: collapseWhitespace.start && i === 0,
461
+ end: collapseWhitespace.end && i >= node.expressions.length
462
+ } : false
463
+ })
464
+ });
465
+ }
466
+ }
467
+ });
468
+ attr.value = spliceChangesIntoString(attr.value, changes);
469
+ }
470
+ function transformDynamicJsAttribute(attr, env) {
471
+ let { matcher } = env;
472
+ let source = `let __prettier_temp__ = ${attr.value}`;
473
+ let ast = ra["babel-ts"].parse(source, env.options);
474
+ let didChange = false;
475
+ let changes = [];
476
+ function findConcatEntry(path) {
477
+ return path.find((entry) => {
478
+ var _entry$parent;
479
+ return ((_entry$parent = entry.parent) === null || _entry$parent === void 0 ? void 0 : _entry$parent.type) === "BinaryExpression" && entry.parent.operator === "+";
480
+ });
481
+ }
482
+ function addChange(start, end, after) {
483
+ if (start == null || end == null) return;
484
+ let offsetStart = start - 24;
485
+ let offsetEnd = end - 24;
486
+ if (offsetStart < 0 || offsetEnd < 0) return;
487
+ didChange = true;
488
+ changes.push({
489
+ start: offsetStart,
490
+ end: offsetEnd,
491
+ before: attr.value.slice(offsetStart, offsetEnd),
492
+ after
493
+ });
494
+ }
495
+ visit(ast, {
496
+ StringLiteral(node, path) {
497
+ let concat = findConcatEntry(path);
498
+ if (sortStringLiteral(node, {
499
+ env,
500
+ collapseWhitespace: {
501
+ start: (concat === null || concat === void 0 ? void 0 : concat.key) !== "right",
502
+ end: (concat === null || concat === void 0 ? void 0 : concat.key) !== "left"
503
+ }
504
+ })) {
505
+ var _node$extra;
506
+ let raw = ((_node$extra = node.extra) === null || _node$extra === void 0 ? void 0 : _node$extra.raw) ?? node.raw;
507
+ if (typeof raw === "string") addChange(node.start, node.end, raw);
508
+ }
509
+ },
510
+ Literal(node, path) {
511
+ if (!isStringLiteral(node)) return;
512
+ let concat = findConcatEntry(path);
513
+ if (sortStringLiteral(node, {
514
+ env,
515
+ collapseWhitespace: {
516
+ start: (concat === null || concat === void 0 ? void 0 : concat.key) !== "right",
517
+ end: (concat === null || concat === void 0 ? void 0 : concat.key) !== "left"
518
+ }
519
+ })) {
520
+ var _node$extra2;
521
+ let raw = ((_node$extra2 = node.extra) === null || _node$extra2 === void 0 ? void 0 : _node$extra2.raw) ?? node.raw;
522
+ if (typeof raw === "string") addChange(node.start, node.end, raw);
523
+ }
524
+ },
525
+ TemplateLiteral(node, path) {
526
+ let concat = findConcatEntry(path);
527
+ let originalQuasis = node.quasis.map((quasi) => quasi.value.raw);
528
+ if (sortTemplateLiteral(node, {
529
+ env,
530
+ collapseWhitespace: {
531
+ start: (concat === null || concat === void 0 ? void 0 : concat.key) !== "right",
532
+ end: (concat === null || concat === void 0 ? void 0 : concat.key) !== "left"
533
+ }
534
+ })) for (let i = 0; i < node.quasis.length; i++) {
535
+ let quasi = node.quasis[i];
536
+ if (quasi.value.raw !== originalQuasis[i]) addChange(quasi.start, quasi.end, quasi.value.raw);
537
+ }
538
+ },
539
+ TaggedTemplateExpression(node, path) {
540
+ if (!isSortableTemplateExpression(node, matcher)) return;
541
+ let concat = findConcatEntry(path);
542
+ let originalQuasis = node.quasi.quasis.map((quasi) => quasi.value.raw);
543
+ if (sortTemplateLiteral(node.quasi, {
544
+ env,
545
+ collapseWhitespace: {
546
+ start: (concat === null || concat === void 0 ? void 0 : concat.key) !== "right",
547
+ end: (concat === null || concat === void 0 ? void 0 : concat.key) !== "left"
548
+ }
549
+ })) for (let i = 0; i < node.quasi.quasis.length; i++) {
550
+ let quasi = node.quasi.quasis[i];
551
+ if (quasi.value.raw !== originalQuasis[i]) addChange(quasi.start, quasi.end, quasi.value.raw);
552
+ }
553
+ }
554
+ });
555
+ if (didChange) attr.value = spliceChangesIntoString(attr.value, changes);
556
+ }
557
+ function transformHtml(ast, env) {
558
+ let { matcher } = env;
559
+ let { parser } = env.options;
560
+ for (let attr of ast.attrs ?? []) if (matcher.hasStaticAttr(attr.name)) attr.value = sortClasses(attr.value, { env });
561
+ else if (matcher.hasDynamicAttr(attr.name)) {
562
+ if (!/[`'"]/.test(attr.value)) continue;
563
+ if (parser === "angular") transformDynamicAngularAttribute(attr, env);
564
+ else transformDynamicJsAttribute(attr, env);
565
+ }
566
+ for (let child of ast.children ?? []) transformHtml(child, env);
567
+ }
568
+ function transformGlimmer(ast, env) {
569
+ let { matcher } = env;
570
+ visit(ast, {
571
+ AttrNode(attr, _path, meta) {
572
+ if (matcher.hasStaticAttr(attr.name) && attr.value) meta.sortTextNodes = true;
573
+ },
574
+ TextNode(node, path, meta) {
575
+ if (!meta.sortTextNodes) return;
576
+ let concat = path.find((entry) => {
577
+ return entry.parent && entry.parent.type === "ConcatStatement";
578
+ });
579
+ let siblings = {
580
+ prev: concat === null || concat === void 0 ? void 0 : concat.parent.parts[concat.index - 1],
581
+ next: concat === null || concat === void 0 ? void 0 : concat.parent.parts[concat.index + 1]
582
+ };
583
+ node.chars = sortClasses(node.chars, {
584
+ env,
585
+ ignoreFirst: siblings.prev && !/^\s/.test(node.chars),
586
+ ignoreLast: siblings.next && !/\s$/.test(node.chars),
587
+ collapseWhitespace: {
588
+ start: !siblings.prev,
589
+ end: !siblings.next
590
+ }
591
+ });
592
+ },
593
+ StringLiteral(node, path, meta) {
594
+ if (!meta.sortTextNodes) return;
595
+ let concat = path.find((entry) => {
596
+ return entry.parent && entry.parent.type === "SubExpression" && entry.parent.path.original === "concat";
597
+ });
598
+ node.value = sortClasses(node.value, {
599
+ env,
600
+ ignoreLast: Boolean(concat) && !/[^\S\r\n]$/.test(node.value),
601
+ collapseWhitespace: {
602
+ start: false,
603
+ end: !concat
604
+ }
605
+ });
606
+ }
607
+ });
608
+ }
609
+ function transformLiquid(ast, env) {
610
+ let { matcher } = env;
611
+ function isClassAttr(node) {
612
+ return Array.isArray(node.name) ? node.name.every((n) => n.type === "TextNode" && matcher.hasStaticAttr(n.value)) : matcher.hasStaticAttr(node.name);
613
+ }
614
+ function hasSurroundingQuotes(str) {
615
+ let start = str[0];
616
+ return start === str[str.length - 1] && (start === "\"" || start === "'" || start === "`");
617
+ }
618
+ let sources = [];
619
+ let changes = [];
620
+ function sortAttribute(attr) {
621
+ for (let i = 0; i < attr.value.length; i++) {
622
+ let node = attr.value[i];
623
+ if (node.type === "TextNode") {
624
+ let after = sortClasses(node.value, {
625
+ env,
626
+ ignoreFirst: i > 0 && !/^\s/.test(node.value),
627
+ ignoreLast: i < attr.value.length - 1 && !/\s$/.test(node.value),
628
+ removeDuplicates: false,
629
+ collapseWhitespace: false
630
+ });
631
+ changes.push({
632
+ start: node.position.start,
633
+ end: node.position.end,
634
+ before: node.value,
635
+ after
636
+ });
637
+ } else if ((node.type === "LiquidDrop" || node.type === "LiquidVariableOutput") && typeof node.markup === "object" && node.markup.type === "LiquidVariable") visit(node.markup.expression, { String(node) {
638
+ let pos = { ...node.position };
639
+ if (hasSurroundingQuotes(node.source.slice(pos.start, pos.end))) {
640
+ pos.start += 1;
641
+ pos.end -= 1;
642
+ }
643
+ let after = sortClasses(node.value, { env });
644
+ changes.push({
645
+ start: pos.start,
646
+ end: pos.end,
647
+ before: node.value,
648
+ after
649
+ });
650
+ } });
651
+ }
652
+ }
653
+ visit(ast, {
654
+ LiquidTag(node) {
655
+ sources.push(node);
656
+ },
657
+ HtmlElement(node) {
658
+ sources.push(node);
659
+ },
660
+ AttrSingleQuoted(node) {
661
+ if (isClassAttr(node)) {
662
+ sources.push(node);
663
+ sortAttribute(node);
664
+ }
665
+ },
666
+ AttrDoubleQuoted(node) {
667
+ if (isClassAttr(node)) {
668
+ sources.push(node);
669
+ sortAttribute(node);
670
+ }
671
+ }
672
+ });
673
+ for (let node of sources) node.source = spliceChangesIntoString(node.source, changes);
674
+ }
675
+ function sortStringLiteral(node, { env, removeDuplicates, collapseWhitespace = {
676
+ start: true,
677
+ end: true
678
+ } }) {
679
+ var _node$extra3, _node$extra4;
680
+ let result = sortClasses(node.value, {
681
+ env,
682
+ removeDuplicates,
683
+ collapseWhitespace
684
+ });
685
+ if (!(result !== node.value)) return false;
686
+ node.value = result;
687
+ let raw = ((_node$extra3 = node.extra) === null || _node$extra3 === void 0 ? void 0 : _node$extra3.raw) ?? node.raw;
688
+ let quote = raw[0];
689
+ let originalRawContent = raw.slice(1, -1);
690
+ let originalValue = ((_node$extra4 = node.extra) === null || _node$extra4 === void 0 ? void 0 : _node$extra4.rawValue) ?? node.value;
691
+ if (node.extra) {
692
+ if (originalRawContent !== originalValue && originalValue.includes("\\")) result = result.replace(ESCAPE_SEQUENCE_PATTERN, "\\\\$1");
693
+ node.extra = {
694
+ ...node.extra,
695
+ rawValue: result,
696
+ raw: quote + result + quote
697
+ };
698
+ } else node.raw = quote + result + quote;
699
+ return true;
700
+ }
701
+ function isStringLiteral(node) {
702
+ return node.type === "StringLiteral" || node.type === "Literal" && typeof node.value === "string";
703
+ }
704
+ function sortTemplateLiteral(node, { env, removeDuplicates, collapseWhitespace = {
705
+ start: true,
706
+ end: true
707
+ } }) {
708
+ let didChange = false;
709
+ for (let i = 0; i < node.quasis.length; i++) {
710
+ let quasi = node.quasis[i];
711
+ let same = quasi.value.raw === quasi.value.cooked;
712
+ let originalRaw = quasi.value.raw;
713
+ let originalCooked = quasi.value.cooked;
714
+ quasi.value.raw = sortClasses(quasi.value.raw, {
715
+ env,
716
+ removeDuplicates,
717
+ ignoreFirst: i > 0 && !/^\s/.test(quasi.value.raw),
718
+ ignoreLast: i < node.expressions.length && !/\s$/.test(quasi.value.raw),
719
+ collapseWhitespace: collapseWhitespace && {
720
+ start: collapseWhitespace && collapseWhitespace.start && i === 0,
721
+ end: collapseWhitespace && collapseWhitespace.end && i >= node.expressions.length
722
+ }
723
+ });
724
+ quasi.value.cooked = same ? quasi.value.raw : sortClasses(quasi.value.cooked, {
725
+ env,
726
+ ignoreFirst: i > 0 && !/^\s/.test(quasi.value.cooked),
727
+ ignoreLast: i < node.expressions.length && !/\s$/.test(quasi.value.cooked),
728
+ removeDuplicates,
729
+ collapseWhitespace: collapseWhitespace && {
730
+ start: collapseWhitespace && collapseWhitespace.start && i === 0,
731
+ end: collapseWhitespace && collapseWhitespace.end && i >= node.expressions.length
732
+ }
733
+ });
734
+ if (quasi.value.raw !== originalRaw || quasi.value.cooked !== originalCooked) didChange = true;
735
+ }
736
+ return didChange;
737
+ }
738
+ function isSortableTemplateExpression(node, matcher) {
739
+ return isSortableExpression(node.tag, matcher);
740
+ }
741
+ function isSortableCallExpression(node, matcher) {
742
+ var _node$arguments;
743
+ if (!((_node$arguments = node.arguments) === null || _node$arguments === void 0 ? void 0 : _node$arguments.length)) return false;
744
+ return isSortableExpression(node.callee, matcher);
745
+ }
746
+ function isSortableExpression(node, matcher) {
747
+ while (node.type === "CallExpression" || node.type === "MemberExpression") if (node.type === "CallExpression") node = node.callee;
748
+ else if (node.type === "MemberExpression") node = node.object;
749
+ if (node.type === "Identifier") return matcher.hasFunction(node.name);
750
+ return false;
751
+ }
752
+ function canCollapseWhitespaceIn(path, env) {
753
+ if (env.options.tailwindPreserveWhitespace) return false;
754
+ let start = true;
755
+ let end = true;
756
+ for (let entry of path) {
757
+ if (!entry.parent) continue;
758
+ if (entry.parent.type === "BinaryExpression" && entry.parent.operator === "+") {
759
+ start && (start = entry.key !== "right");
760
+ end && (end = entry.key !== "left");
761
+ }
762
+ if (entry.parent.type === "TemplateLiteral") {
763
+ let nodeStart = entry.node.start ?? null;
764
+ let nodeEnd = entry.node.end ?? null;
765
+ for (let quasi of entry.parent.quasis) {
766
+ let quasiStart = quasi.start ?? null;
767
+ let quasiEnd = quasi.end ?? null;
768
+ if (nodeStart !== null && quasiEnd !== null && nodeStart - quasiEnd <= 2) start && (start = /^\s/.test(quasi.value.raw));
769
+ if (nodeEnd !== null && quasiStart !== null && nodeEnd - quasiStart <= 2) end && (end = /\s$/.test(quasi.value.raw));
770
+ }
771
+ }
772
+ }
773
+ return {
774
+ start,
775
+ end
776
+ };
777
+ }
778
+ function transformJavaScript(ast, env) {
779
+ let { matcher } = env;
780
+ function sortInside(ast) {
781
+ visit(ast, (node, path) => {
782
+ let collapseWhitespace = canCollapseWhitespaceIn(path, env);
783
+ if (isStringLiteral(node)) sortStringLiteral(node, {
784
+ env,
785
+ collapseWhitespace
786
+ });
787
+ else if (node.type === "TemplateLiteral") sortTemplateLiteral(node, {
788
+ env,
789
+ collapseWhitespace
790
+ });
791
+ else if (node.type === "TaggedTemplateExpression") {
792
+ if (isSortableTemplateExpression(node, matcher)) sortTemplateLiteral(node.quasi, {
793
+ env,
794
+ collapseWhitespace
795
+ });
796
+ }
797
+ });
798
+ }
799
+ visit(ast, {
800
+ JSXAttribute(node) {
801
+ node = node;
802
+ if (!node.value) return;
803
+ if (typeof node.name.name !== "string") return;
804
+ if (!matcher.hasStaticAttr(node.name.name)) return;
805
+ if (isStringLiteral(node.value)) sortStringLiteral(node.value, { env });
806
+ else if (node.value.type === "JSXExpressionContainer") sortInside(node.value);
807
+ },
808
+ CallExpression(node) {
809
+ node = node;
810
+ if (!isSortableCallExpression(node, matcher)) return;
811
+ node.arguments.forEach((arg) => sortInside(arg));
812
+ },
813
+ TaggedTemplateExpression(node, path) {
814
+ node = node;
815
+ if (!isSortableTemplateExpression(node, matcher)) return;
816
+ let collapseWhitespace = canCollapseWhitespaceIn(path, env);
817
+ sortTemplateLiteral(node.quasi, {
818
+ env,
819
+ collapseWhitespace
820
+ });
821
+ }
822
+ });
823
+ }
824
+ function transformCss(ast, env) {
825
+ function tryParseAtRuleParams(name, params) {
826
+ if (typeof params !== "string") return params;
827
+ try {
828
+ return en.css.parse(`@import ${params};`, { ...env.options }).nodes[0].params;
829
+ } catch (err) {
830
+ console.warn(`[prettier-plugin-tailwindcss] Unable to parse at rule`);
831
+ console.warn({
832
+ name,
833
+ params
834
+ });
835
+ console.warn(err);
836
+ }
837
+ return params;
838
+ }
839
+ ast.walk((node) => {
840
+ if (node.name === "plugin" || node.name === "config" || node.name === "source") node.params = tryParseAtRuleParams(node.name, node.params);
841
+ if (node.type === "css-atrule" && node.name === "apply") {
842
+ let isImportant = /\s+(?:!important|#{(['"]*)!important\1})\s*$/.test(node.params);
843
+ let classList = node.params;
844
+ let prefix = "";
845
+ let suffix = "";
846
+ if (classList.startsWith("~\"") && classList.endsWith("\"")) {
847
+ prefix = "~\"";
848
+ suffix = "\"";
849
+ classList = classList.slice(2, -1);
850
+ isImportant = false;
851
+ } else if (classList.startsWith("~'") && classList.endsWith("'")) {
852
+ prefix = "~'";
853
+ suffix = "'";
854
+ classList = classList.slice(2, -1);
855
+ isImportant = false;
856
+ }
857
+ classList = sortClasses(classList, {
858
+ env,
859
+ ignoreLast: isImportant,
860
+ collapseWhitespace: {
861
+ start: false,
862
+ end: !isImportant
863
+ }
864
+ });
865
+ node.params = `${prefix}${classList}${suffix}`;
866
+ }
867
+ });
868
+ }
869
+ function transformAstro(ast, env) {
870
+ let { matcher } = env;
871
+ if (ast.type === "element" || ast.type === "custom-element" || ast.type === "component") {
872
+ for (let attr of ast.attributes ?? []) if (matcher.hasStaticAttr(attr.name) && attr.type === "attribute" && attr.kind === "quoted") attr.value = sortClasses(attr.value, { env });
873
+ else if (matcher.hasDynamicAttr(attr.name) && attr.type === "attribute" && attr.kind === "expression" && typeof attr.value === "string") transformDynamicJsAttribute(attr, env);
874
+ }
875
+ for (let child of ast.children ?? []) transformAstro(child, env);
876
+ }
877
+ function transformMarko(ast, env) {
878
+ let { matcher } = env;
879
+ const nodesToVisit = [ast];
880
+ while (nodesToVisit.length > 0) {
881
+ const currentNode = nodesToVisit.pop();
882
+ switch (currentNode.type) {
883
+ case "File":
884
+ nodesToVisit.push(currentNode.program);
885
+ break;
886
+ case "Program":
887
+ nodesToVisit.push(...currentNode.body);
888
+ break;
889
+ case "MarkoTag":
890
+ nodesToVisit.push(...currentNode.attributes);
891
+ nodesToVisit.push(currentNode.body);
892
+ break;
893
+ case "MarkoTagBody":
894
+ nodesToVisit.push(...currentNode.body);
895
+ break;
896
+ case "MarkoAttribute":
897
+ if (!matcher.hasStaticAttr(currentNode.name)) break;
898
+ switch (currentNode.value.type) {
899
+ case "ArrayExpression":
900
+ const classList = currentNode.value.elements;
901
+ for (const node of classList) if (node.type === "StringLiteral") node.value = sortClasses(node.value, { env });
902
+ break;
903
+ case "StringLiteral":
904
+ currentNode.value.value = sortClasses(currentNode.value.value, { env });
905
+ break;
906
+ }
907
+ break;
908
+ }
909
+ }
910
+ }
911
+ function transformTwig(ast, env) {
912
+ let { matcher } = env;
913
+ for (let child of ast.expressions ?? []) transformTwig(child, env);
914
+ visit(ast, {
915
+ Attribute(node, _path, meta) {
916
+ if (!matcher.hasStaticAttr(node.name.name)) return;
917
+ meta.sortTextNodes = true;
918
+ },
919
+ CallExpression(node, _path, meta) {
920
+ while (node.type === "CallExpression" || node.type === "MemberExpression") if (node.type === "CallExpression") node = node.callee;
921
+ else if (node.type === "MemberExpression") node = node.property;
922
+ if (node.type === "Identifier") {
923
+ if (!matcher.hasFunction(node.name)) return;
924
+ }
925
+ meta.sortTextNodes = true;
926
+ },
927
+ StringLiteral(node, path, meta) {
928
+ if (!meta.sortTextNodes) return;
929
+ const concat = path.find((entry) => {
930
+ return entry.parent && (entry.parent.type === "BinaryConcatExpression" || entry.parent.type === "BinaryAddExpression");
931
+ });
932
+ node.value = sortClasses(node.value, {
933
+ env,
934
+ ignoreFirst: (concat === null || concat === void 0 ? void 0 : concat.key) === "right" && !/^[^\S\r\n]/.test(node.value),
935
+ ignoreLast: (concat === null || concat === void 0 ? void 0 : concat.key) === "left" && !/[^\S\r\n]$/.test(node.value),
936
+ collapseWhitespace: {
937
+ start: (concat === null || concat === void 0 ? void 0 : concat.key) !== "right",
938
+ end: (concat === null || concat === void 0 ? void 0 : concat.key) !== "left"
939
+ }
940
+ });
941
+ }
942
+ });
943
+ }
944
+ function transformPug(ast, env) {
945
+ let { matcher } = env;
946
+ for (const token of ast.tokens) if (token.type === "attribute" && matcher.hasStaticAttr(token.name)) token.val = [
947
+ token.val.slice(0, 1),
948
+ sortClasses(token.val.slice(1, -1), { env }),
949
+ token.val.slice(-1)
950
+ ].join("");
951
+ let startIdx = -1;
952
+ let endIdx = -1;
953
+ let ranges = [];
954
+ for (let i = 0; i < ast.tokens.length; i++) if (ast.tokens[i].type === "class") {
955
+ startIdx = startIdx === -1 ? i : startIdx;
956
+ endIdx = i;
957
+ } else if (startIdx !== -1) {
958
+ ranges.push([startIdx, endIdx]);
959
+ startIdx = -1;
960
+ endIdx = -1;
961
+ }
962
+ if (startIdx !== -1) {
963
+ ranges.push([startIdx, endIdx]);
964
+ startIdx = -1;
965
+ endIdx = -1;
966
+ }
967
+ for (const [startIdx, endIdx] of ranges) {
968
+ const { classList } = sortClassList({
969
+ classList: ast.tokens.slice(startIdx, endIdx + 1).map((token) => token.val),
970
+ api: env.context,
971
+ removeDuplicates: false
972
+ });
973
+ for (let i = startIdx; i <= endIdx; i++) ast.tokens[i].val = classList[i - startIdx];
974
+ }
975
+ }
976
+ function transformSvelte(ast, env) {
977
+ let { matcher, changes } = env;
978
+ for (let attr of ast.attributes ?? []) {
979
+ if (!matcher.hasStaticAttr(attr.name) || attr.type !== "Attribute") continue;
980
+ for (let i = 0; i < attr.value.length; i++) {
981
+ let value = attr.value[i];
982
+ if (value.type === "Text") {
983
+ let same = value.raw === value.data;
984
+ value.raw = sortClasses(value.raw, {
985
+ env,
986
+ ignoreFirst: i > 0 && !/^\s/.test(value.raw),
987
+ ignoreLast: i < attr.value.length - 1 && !/\s$/.test(value.raw),
988
+ removeDuplicates: true,
989
+ collapseWhitespace: false
990
+ });
991
+ value.data = same ? value.raw : sortClasses(value.data, {
992
+ env,
993
+ ignoreFirst: i > 0 && !/^\s/.test(value.data),
994
+ ignoreLast: i < attr.value.length - 1 && !/\s$/.test(value.data),
995
+ removeDuplicates: true,
996
+ collapseWhitespace: false
997
+ });
998
+ } else if (value.type === "MustacheTag") visit(value.expression, {
999
+ Literal(node) {
1000
+ if (isStringLiteral(node)) {
1001
+ let before = node.raw;
1002
+ if (sortStringLiteral(node, {
1003
+ env,
1004
+ removeDuplicates: false,
1005
+ collapseWhitespace: false
1006
+ })) changes.push({
1007
+ before,
1008
+ after: node.raw,
1009
+ start: node.loc.start,
1010
+ end: node.loc.end
1011
+ });
1012
+ }
1013
+ },
1014
+ TemplateLiteral(node) {
1015
+ let before = node.quasis.map((quasi) => quasi.value.raw);
1016
+ if (sortTemplateLiteral(node, {
1017
+ env,
1018
+ removeDuplicates: false,
1019
+ collapseWhitespace: false
1020
+ })) for (let [idx, quasi] of node.quasis.entries()) changes.push({
1021
+ before: before[idx],
1022
+ after: quasi.value.raw,
1023
+ start: quasi.loc.start,
1024
+ end: quasi.loc.end
1025
+ });
1026
+ }
1027
+ });
1028
+ }
1029
+ }
1030
+ for (let child of ast.children ?? []) transformSvelte(child, env);
1031
+ if (ast.type === "IfBlock") {
1032
+ var _ast$else;
1033
+ for (let child of ((_ast$else = ast.else) === null || _ast$else === void 0 ? void 0 : _ast$else.children) ?? []) transformSvelte(child, env);
1034
+ }
1035
+ if (ast.type === "AwaitBlock") {
1036
+ let nodes = [
1037
+ ast.pending,
1038
+ ast.then,
1039
+ ast.catch
1040
+ ];
1041
+ for (let child of nodes) transformSvelte(child, env);
1042
+ }
1043
+ if (ast.html) transformSvelte(ast.html, env);
1044
+ }
1045
+ const { parsers, printers } = createPlugin([
1046
+ defineTransform({
1047
+ staticAttrs: ["class"],
1048
+ load: [{
1049
+ name: "prettier/plugins/html",
1050
+ importer: () => import("./html-cr_GTtzg.js")
1051
+ }],
1052
+ compatible: ["prettier-plugin-organize-attributes"],
1053
+ parsers: {
1054
+ html: {},
1055
+ lwc: {},
1056
+ angular: { dynamicAttrs: ["[ngClass]"] },
1057
+ vue: { dynamicAttrs: [":class", "v-bind:class"] }
1058
+ },
1059
+ transform: transformHtml
1060
+ }),
1061
+ defineTransform({
1062
+ staticAttrs: ["class"],
1063
+ load: [{
1064
+ name: "prettier/plugins/glimmer",
1065
+ importer: () => import("./glimmer-Dj-rhc3H.js")
1066
+ }],
1067
+ parsers: { glimmer: {} },
1068
+ transform: transformGlimmer
1069
+ }),
1070
+ defineTransform({
1071
+ load: [postcss_exports],
1072
+ compatible: ["prettier-plugin-css-order"],
1073
+ parsers: {
1074
+ css: {},
1075
+ scss: {},
1076
+ less: {}
1077
+ },
1078
+ transform: transformCss
1079
+ }),
1080
+ defineTransform({
1081
+ staticAttrs: ["class", "className"],
1082
+ compatible: [
1083
+ "prettier-plugin-multiline-arrays",
1084
+ "@ianvs/prettier-plugin-sort-imports",
1085
+ "@trivago/prettier-plugin-sort-imports",
1086
+ "prettier-plugin-organize-imports",
1087
+ "prettier-plugin-sort-imports",
1088
+ "prettier-plugin-jsdoc"
1089
+ ],
1090
+ parsers: {
1091
+ babel: { load: [babel_exports] },
1092
+ "babel-flow": { load: [babel_exports] },
1093
+ "babel-ts": { load: [babel_exports] },
1094
+ __js_expression: { load: [babel_exports] },
1095
+ typescript: { load: [{
1096
+ name: "prettier/plugins/typescript",
1097
+ importer: () => import("./typescript-8enly1_u.js")
1098
+ }] },
1099
+ meriyah: { load: [{
1100
+ name: "prettier/plugins/meriyah",
1101
+ importer: () => import("./meriyah-Dyll-d_f.js")
1102
+ }] },
1103
+ acorn: { load: [{
1104
+ name: "prettier/plugins/acorn",
1105
+ importer: () => import("./acorn-BnWlLI9w.js")
1106
+ }] },
1107
+ flow: { load: [{
1108
+ name: "prettier/plugins/flow",
1109
+ importer: () => import("./flow-JTvJzd2b.js")
1110
+ }] },
1111
+ oxc: { load: [{
1112
+ name: "@prettier/plugin-oxc",
1113
+ importer: () => import("@prettier/plugin-oxc")
1114
+ }] },
1115
+ "oxc-ts": { load: [{
1116
+ name: "@prettier/plugin-oxc",
1117
+ importer: () => import("@prettier/plugin-oxc")
1118
+ }] },
1119
+ hermes: { load: [{
1120
+ name: "@prettier/plugin-hermes",
1121
+ importer: () => import("@prettier/plugin-hermes")
1122
+ }] },
1123
+ astroExpressionParser: {
1124
+ load: [{
1125
+ name: "prettier-plugin-astro",
1126
+ importer: () => {
1127
+ return import("prettier-plugin-astro");
1128
+ }
1129
+ }],
1130
+ staticAttrs: ["class"],
1131
+ dynamicAttrs: ["class:list"]
1132
+ }
1133
+ },
1134
+ transform: transformJavaScript
1135
+ }),
1136
+ defineTransform({
1137
+ staticAttrs: ["class"],
1138
+ load: [{
1139
+ name: "prettier-plugin-svelte",
1140
+ importer: () => import("prettier-plugin-svelte")
1141
+ }],
1142
+ parsers: { svelte: {} },
1143
+ printers: { "svelte-ast": {} },
1144
+ transform: transformSvelte,
1145
+ reprint(path, { options, changes }) {
1146
+ if (options.__mutatedOriginalText) return;
1147
+ options.__mutatedOriginalText = true;
1148
+ if (!(changes === null || changes === void 0 ? void 0 : changes.length)) return;
1149
+ let finder = (0, import_line_column.default)(options.originalText);
1150
+ let stringChanges = changes.map((change) => ({
1151
+ ...change,
1152
+ start: finder.toIndex(change.start.line, change.start.column + 1),
1153
+ end: finder.toIndex(change.end.line, change.end.column + 1)
1154
+ }));
1155
+ options.originalText = spliceChangesIntoString(options.originalText, stringChanges);
1156
+ }
1157
+ }),
1158
+ defineTransform({
1159
+ staticAttrs: ["class", "className"],
1160
+ dynamicAttrs: ["class:list", "className"],
1161
+ load: [{
1162
+ name: "prettier-plugin-astro",
1163
+ importer: () => {
1164
+ return import("prettier-plugin-astro");
1165
+ }
1166
+ }],
1167
+ parsers: { astro: {} },
1168
+ transform: transformAstro
1169
+ }),
1170
+ defineTransform({
1171
+ staticAttrs: ["class"],
1172
+ load: [{
1173
+ name: "prettier-plugin-marko",
1174
+ importer: () => import("prettier-plugin-marko")
1175
+ }],
1176
+ parsers: { marko: {} },
1177
+ transform: transformMarko
1178
+ }),
1179
+ defineTransform({
1180
+ staticAttrs: ["class"],
1181
+ load: [{
1182
+ name: "@zackad/prettier-plugin-twig",
1183
+ importer: () => {
1184
+ return import("@zackad/prettier-plugin-twig");
1185
+ }
1186
+ }],
1187
+ parsers: { twig: {} },
1188
+ transform: transformTwig
1189
+ }),
1190
+ defineTransform({
1191
+ staticAttrs: ["class"],
1192
+ load: [{
1193
+ name: "@prettier/plugin-pug",
1194
+ importer: () => import("@prettier/plugin-pug")
1195
+ }],
1196
+ parsers: { pug: {} },
1197
+ transform: transformPug
1198
+ }),
1199
+ defineTransform({
1200
+ staticAttrs: ["class"],
1201
+ load: [{
1202
+ name: "@shopify/prettier-plugin-liquid",
1203
+ importer: () => import("@shopify/prettier-plugin-liquid")
1204
+ }],
1205
+ parsers: { "liquid-html": {} },
1206
+ transform: transformLiquid
1207
+ })
1208
+ ]);
1209
+ //#endregion
1210
+ export { options, parsers, printers };