oxfmt 0.49.0 → 0.50.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/configuration_schema.json +2 -2
- package/dist/{acorn-ay2Aj6GQ.js → acorn-sBRpswSh.js} +1 -1
- package/dist/{angular-z1ZEe5V_.js → angular-DtI-eDW8.js} +1 -1
- package/dist/{apis-By1xj7IP.js → apis-CKvPKBJI.js} +42 -7
- package/dist/{babel-Cs312VeV.js → babel-DaNjvh9L.js} +1 -1
- package/dist/{bindings-Cdg_nxGV.js → bindings-Dj_YoR0Z.js} +26 -26
- package/dist/cli-worker.js +1 -1
- package/dist/cli.js +5 -5
- package/dist/{dist-Bbs0xV9H.js → dist-D_YbN99t.js} +14 -17
- package/dist/{estree-DZBnPYMx.js → estree-CzfNsl8m.js} +1 -1
- package/dist/{flow-ChhAFZSt.js → flow-c9AjoQam.js} +1 -1
- package/dist/{glimmer-Cg8KQipT.js → glimmer-D_zkI0w_.js} +1 -1
- package/dist/{graphql-DsP-ifm0.js → graphql-BFXkB4Nq.js} +1 -1
- package/dist/{html-7pWx9LND.js → html-DkcPxRXg.js} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/{init-BbKOMZ57.js → init-C3nxU_Wc.js} +1 -1
- package/dist/{jiti-Bb1dT6Cw-DezGRPD7.js → jiti-Bb1dT6Cw-C0N20Za1.js} +2 -2
- package/dist/{markdown-CCrs3bBt.js → markdown-DVLNmbQg.js} +1 -1
- package/dist/{meriyah-TC7VDz8E.js → meriyah-BGPf00Rn.js} +1 -1
- package/dist/{migrate-biome-BMqs7-eg.js → migrate-biome-DclTzwKW.js} +1 -1
- package/dist/{migrate-prettier-Bze9N_6F.js → migrate-prettier-DLfviW85.js} +2 -2
- package/dist/{plugin-CwlqDRt_.js → plugin-DOdiccQR.js} +72 -28
- package/dist/{postcss-ZbUej7DN.js → postcss-D-ql-dm8.js} +1 -1
- package/dist/{prettier-s1WPCGVk.js → prettier-Cw36juP9.js} +15 -15
- package/dist/{prettier-plugin-oxfmt-BjdgYnLg.js → prettier-plugin-oxfmt-BlJcmKAv.js} +37 -3
- package/dist/{resolve-pWjAK-4f-BnquIxPb.js → sorter-BZkvDMjt-DpGe0QK9.js} +325 -4
- package/dist/{sorter-l2HyESZg.js → sorter-w0dgpoFw.js} +1 -2
- package/dist/{typescript-Cgpjcksz.js → typescript-C_eN_ThF.js} +1 -1
- package/dist/{v3-D-mr2VVh-Bw8A9MXh.js → v3-D-mr2VVh-CU7hQIit.js} +3 -4
- package/dist/{v4-C-HWEQJm-B81QD_Ac.js → v4-C-HWEQJm-C8EWwksG.js} +3 -4
- package/dist/{yaml-DLZBHI7f.js → yaml-Bqxyk-13.js} +1 -1
- package/package.json +20 -20
- package/dist/chunk-DSjvVL_1-B3jw0SMn.js +0 -36
- package/dist/chunk-HkwdBwDg.js +0 -37
- package/dist/sorter-BZkvDMjt-y2u_e1ZW.js +0 -212
- package/dist/utils-D8dQkKEd-Dgy5UIHl.js +0 -81
- /package/dist/{shared-BTEY2VsW.js → shared-BtJbjkue.js} +0 -0
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import { a as resolveJsFrom, t as expiringMap } from "./resolve-pWjAK-4f-BnquIxPb.js";
|
|
2
|
-
import { n as cacheForDirs, t as bigSign } from "./utils-D8dQkKEd-Dgy5UIHl.js";
|
|
3
|
-
import { pathToFileURL } from "node:url";
|
|
4
|
-
import * as path from "node:path";
|
|
5
|
-
import { dirname, resolve } from "path";
|
|
6
|
-
import { readdirSync, statSync } from "fs";
|
|
7
|
-
//#region ../../node_modules/.pnpm/prettier-plugin-tailwindcss@0.0.0-insiders.3997fbd_prettier-plugin-svelte@3.5.1_prettie_57f1f908c644a91a29f5821c3681dd20/node_modules/prettier-plugin-tailwindcss/dist/sorter-BZkvDMjt.mjs
|
|
8
|
-
let seen = /* @__PURE__ */ new Set();
|
|
9
|
-
function warn(key, arg, ...args) {
|
|
10
|
-
if (seen.has(key)) return;
|
|
11
|
-
seen.add(key);
|
|
12
|
-
console.warn(arg, ...args);
|
|
13
|
-
}
|
|
14
|
-
function error(key, arg, ...args) {
|
|
15
|
-
if (seen.has(key)) return;
|
|
16
|
-
seen.add(key);
|
|
17
|
-
console.error(arg, ...args);
|
|
18
|
-
}
|
|
19
|
-
function sync_default(start, callback) {
|
|
20
|
-
let dir = resolve(".", start);
|
|
21
|
-
let tmp;
|
|
22
|
-
if (!statSync(dir).isDirectory()) dir = dirname(dir);
|
|
23
|
-
while (true) {
|
|
24
|
-
tmp = callback(dir, readdirSync(dir));
|
|
25
|
-
if (tmp) return resolve(dir, tmp);
|
|
26
|
-
dir = dirname(tmp = dir);
|
|
27
|
-
if (tmp === dir) break;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function sortClasses(classStr, { env, ignoreFirst = false, ignoreLast = false, removeDuplicates = true, collapseWhitespace = {
|
|
31
|
-
start: true,
|
|
32
|
-
end: true
|
|
33
|
-
} }) {
|
|
34
|
-
if (typeof classStr !== "string" || classStr === "") return classStr;
|
|
35
|
-
if (classStr.includes("{{")) return classStr;
|
|
36
|
-
if (env.options.tailwindPreserveWhitespace) collapseWhitespace = false;
|
|
37
|
-
if (env.options.tailwindPreserveDuplicates) removeDuplicates = false;
|
|
38
|
-
if (collapseWhitespace && /^[\t\r\f\n ]+$/.test(classStr)) return " ";
|
|
39
|
-
let result = "";
|
|
40
|
-
let parts = classStr.split(/([\t\r\f\n ]+)/);
|
|
41
|
-
let classes = parts.filter((_, i) => i % 2 === 0);
|
|
42
|
-
let whitespace = parts.filter((_, i) => i % 2 !== 0);
|
|
43
|
-
if (classes[classes.length - 1] === "") classes.pop();
|
|
44
|
-
if (collapseWhitespace) whitespace = whitespace.map(() => " ");
|
|
45
|
-
let prefix = "";
|
|
46
|
-
if (ignoreFirst) prefix = `${classes.shift() ?? ""}${whitespace.shift() ?? ""}`;
|
|
47
|
-
let suffix = "";
|
|
48
|
-
if (ignoreLast) suffix = `${whitespace.pop() ?? ""}${classes.pop() ?? ""}`;
|
|
49
|
-
let { classList, removedIndices } = sortClassList({
|
|
50
|
-
classList: classes,
|
|
51
|
-
api: env.context,
|
|
52
|
-
removeDuplicates
|
|
53
|
-
});
|
|
54
|
-
whitespace = whitespace.filter((_, index) => !removedIndices.has(index + 1));
|
|
55
|
-
for (let i = 0; i < classList.length; i++) result += `${classList[i]}${whitespace[i] ?? ""}`;
|
|
56
|
-
if (collapseWhitespace) {
|
|
57
|
-
prefix = prefix.replace(/\s+$/g, " ");
|
|
58
|
-
suffix = suffix.replace(/^\s+/g, " ");
|
|
59
|
-
result = result.replace(/^\s+/, collapseWhitespace.start ? "" : " ").replace(/\s+$/, collapseWhitespace.end ? "" : " ");
|
|
60
|
-
}
|
|
61
|
-
return prefix + result + suffix;
|
|
62
|
-
}
|
|
63
|
-
function sortClassList({ classList, api, removeDuplicates }) {
|
|
64
|
-
let orderedClasses = api.getClassOrder(classList);
|
|
65
|
-
orderedClasses.sort(([nameA, a], [nameZ, z]) => {
|
|
66
|
-
if (nameA === "..." || nameA === "…") return 1;
|
|
67
|
-
if (nameZ === "..." || nameZ === "…") return -1;
|
|
68
|
-
if (a === z) return 0;
|
|
69
|
-
if (a === null) return -1;
|
|
70
|
-
if (z === null) return 1;
|
|
71
|
-
return bigSign(a - z);
|
|
72
|
-
});
|
|
73
|
-
let removedIndices = /* @__PURE__ */ new Set();
|
|
74
|
-
if (removeDuplicates) {
|
|
75
|
-
let seenClasses = /* @__PURE__ */ new Set();
|
|
76
|
-
orderedClasses = orderedClasses.filter(([cls, order], index) => {
|
|
77
|
-
if (seenClasses.has(cls)) {
|
|
78
|
-
removedIndices.add(index);
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
if (order !== null) seenClasses.add(cls);
|
|
82
|
-
return true;
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
return {
|
|
86
|
-
classList: orderedClasses.map(([className]) => className),
|
|
87
|
-
removedIndices
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
function resolveIfRelative(base, filePath) {
|
|
91
|
-
if (!filePath) return null;
|
|
92
|
-
return path.isAbsolute(filePath) ? filePath : path.resolve(base, filePath);
|
|
93
|
-
}
|
|
94
|
-
let pathToApiMap = expiringMap(1e4);
|
|
95
|
-
async function getTailwindConfig(options) {
|
|
96
|
-
let base = options.base ?? process.cwd();
|
|
97
|
-
let inputDir = options.filepath ? path.dirname(options.filepath) : base;
|
|
98
|
-
let configPath = resolveIfRelative(base, options.configPath);
|
|
99
|
-
let stylesheetPath = resolveIfRelative(base, options.stylesheetPath);
|
|
100
|
-
let [mod, pkgDir] = await resolveTailwindPath({ packageName: options.packageName }, inputDir);
|
|
101
|
-
let stylesheet = resolveStylesheet(stylesheetPath, base);
|
|
102
|
-
let jsConfig = resolveJsConfigPath(configPath);
|
|
103
|
-
if (!stylesheet && !(mod === null || mod === void 0 ? void 0 : mod.__unstable__loadDesignSystem)) jsConfig = jsConfig ?? findClosestJsConfig(inputDir);
|
|
104
|
-
if (jsConfig) {
|
|
105
|
-
if (!stylesheet) return pathToApiMap.remember(`${pkgDir}:${jsConfig}`, async () => {
|
|
106
|
-
const { loadV3 } = await import("./v3-D-mr2VVh-Bw8A9MXh.js");
|
|
107
|
-
return loadV3(pkgDir, jsConfig);
|
|
108
|
-
});
|
|
109
|
-
error("explicit-stylesheet-and-config-together", base, `You have specified a Tailwind CSS stylesheet and a Tailwind CSS config at the same time. Use stylesheetPath unless you are using v3. Preferring the stylesheet.`);
|
|
110
|
-
}
|
|
111
|
-
if (mod && !mod.__unstable__loadDesignSystem) {
|
|
112
|
-
if (!stylesheet) return pathToApiMap.remember(`${pkgDir}:${jsConfig}`, async () => {
|
|
113
|
-
const { loadV3 } = await import("./v3-D-mr2VVh-Bw8A9MXh.js");
|
|
114
|
-
return loadV3(pkgDir, jsConfig);
|
|
115
|
-
});
|
|
116
|
-
mod = null;
|
|
117
|
-
error("stylesheet-unsupported", base, "You have specified a Tailwind CSS stylesheet but your installed version of Tailwind CSS does not support this feature.");
|
|
118
|
-
}
|
|
119
|
-
if (mod && mod.__unstable__loadDesignSystem && pkgDir) stylesheet ?? (stylesheet = `${pkgDir}/theme.css`);
|
|
120
|
-
return pathToApiMap.remember(`${pkgDir}:${stylesheet}`, async () => {
|
|
121
|
-
const { loadV4 } = await import("./v4-C-HWEQJm-B81QD_Ac.js");
|
|
122
|
-
return loadV4(mod, stylesheet);
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
let resolvedModCache = expiringMap(1e4);
|
|
126
|
-
async function resolveTailwindPath(options, baseDir) {
|
|
127
|
-
let pkgName = options.packageName ?? "tailwindcss";
|
|
128
|
-
let makeKey = (dir) => `${pkgName}:${dir}`;
|
|
129
|
-
let cached = resolvedModCache.get(makeKey(baseDir));
|
|
130
|
-
if (cached !== void 0) return cached;
|
|
131
|
-
let resolve = async () => {
|
|
132
|
-
let pkgDir = null;
|
|
133
|
-
let mod = null;
|
|
134
|
-
try {
|
|
135
|
-
mod = await import(pathToFileURL(resolveJsFrom(baseDir, pkgName)).toString());
|
|
136
|
-
let pkgFile = resolveJsFrom(baseDir, `${pkgName}/package.json`);
|
|
137
|
-
pkgDir = path.dirname(pkgFile);
|
|
138
|
-
} catch {}
|
|
139
|
-
return [mod, pkgDir];
|
|
140
|
-
};
|
|
141
|
-
let result = await resolve();
|
|
142
|
-
let [, pkgDir] = result;
|
|
143
|
-
if (pkgDir) cacheForDirs(resolvedModCache, baseDir, result, pkgDir, makeKey);
|
|
144
|
-
else resolvedModCache.set(makeKey(baseDir), result);
|
|
145
|
-
return result;
|
|
146
|
-
}
|
|
147
|
-
function resolveJsConfigPath(configPath) {
|
|
148
|
-
if (!configPath) return null;
|
|
149
|
-
if (configPath.endsWith(".css")) return null;
|
|
150
|
-
return configPath;
|
|
151
|
-
}
|
|
152
|
-
let configPathCache = /* @__PURE__ */ new Map();
|
|
153
|
-
function findClosestJsConfig(inputDir) {
|
|
154
|
-
let cached = configPathCache.get(inputDir);
|
|
155
|
-
if (cached !== void 0) return cached;
|
|
156
|
-
let configPath = null;
|
|
157
|
-
try {
|
|
158
|
-
configPath = sync_default(inputDir, (_, names) => {
|
|
159
|
-
if (names.includes("tailwind.config.js")) return "tailwind.config.js";
|
|
160
|
-
if (names.includes("tailwind.config.cjs")) return "tailwind.config.cjs";
|
|
161
|
-
if (names.includes("tailwind.config.mjs")) return "tailwind.config.mjs";
|
|
162
|
-
if (names.includes("tailwind.config.ts")) return "tailwind.config.ts";
|
|
163
|
-
}) ?? null;
|
|
164
|
-
} catch {}
|
|
165
|
-
if (configPath) cacheForDirs(configPathCache, inputDir, configPath, path.dirname(configPath));
|
|
166
|
-
else configPathCache.set(inputDir, null);
|
|
167
|
-
return configPath;
|
|
168
|
-
}
|
|
169
|
-
function resolveStylesheet(stylesheetPath, base) {
|
|
170
|
-
if (!stylesheetPath) return null;
|
|
171
|
-
if (stylesheetPath.endsWith(".js") || stylesheetPath.endsWith(".mjs") || stylesheetPath.endsWith(".cjs") || stylesheetPath.endsWith(".ts") || stylesheetPath.endsWith(".mts") || stylesheetPath.endsWith(".cts")) error("stylesheet-is-js-file", base, "Your `stylesheetPath` option points to a JS/TS config file. You must point to your project's `.css` file for v4 projects.");
|
|
172
|
-
else if (stylesheetPath.endsWith(".sass") || stylesheetPath.endsWith(".scss") || stylesheetPath.endsWith(".less") || stylesheetPath.endsWith(".styl")) error("stylesheet-is-preprocessor-file", base, "Your `stylesheetPath` option points to a preprocessor file. This is unsupported and you may get unexpected results.");
|
|
173
|
-
else if (!stylesheetPath.endsWith(".css")) error("stylesheet-is-not-css-file", base, "Your `stylesheetPath` option does not point to a CSS file. This is unsupported and you may get unexpected results.");
|
|
174
|
-
return stylesheetPath;
|
|
175
|
-
}
|
|
176
|
-
async function createSorter(opts) {
|
|
177
|
-
let preserveDuplicates = opts.preserveDuplicates ?? false;
|
|
178
|
-
let preserveWhitespace = opts.preserveWhitespace ?? false;
|
|
179
|
-
let api = await getTailwindConfig({
|
|
180
|
-
base: opts.base,
|
|
181
|
-
filepath: opts.filepath,
|
|
182
|
-
configPath: opts.configPath,
|
|
183
|
-
stylesheetPath: opts.stylesheetPath,
|
|
184
|
-
packageName: opts.packageName
|
|
185
|
-
});
|
|
186
|
-
let env = {
|
|
187
|
-
context: api,
|
|
188
|
-
changes: [],
|
|
189
|
-
options: {
|
|
190
|
-
tailwindPreserveWhitespace: preserveWhitespace,
|
|
191
|
-
tailwindPreserveDuplicates: preserveDuplicates,
|
|
192
|
-
tailwindPackageName: opts.packageName
|
|
193
|
-
},
|
|
194
|
-
matcher: void 0
|
|
195
|
-
};
|
|
196
|
-
return {
|
|
197
|
-
sortClassLists(classes) {
|
|
198
|
-
return classes.map((list) => {
|
|
199
|
-
return sortClassList({
|
|
200
|
-
api,
|
|
201
|
-
classList: list,
|
|
202
|
-
removeDuplicates: !preserveDuplicates
|
|
203
|
-
}).classList;
|
|
204
|
-
});
|
|
205
|
-
},
|
|
206
|
-
sortClassAttributes(classes) {
|
|
207
|
-
return classes.map((list) => sortClasses(list, { env }));
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
//#endregion
|
|
212
|
-
export { sortClasses as a, sortClassList as i, error as n, warn as o, getTailwindConfig as r, createSorter as t };
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import * as path from "node:path";
|
|
2
|
-
//#region ../../node_modules/.pnpm/prettier-plugin-tailwindcss@0.0.0-insiders.3997fbd_prettier-plugin-svelte@3.5.1_prettie_57f1f908c644a91a29f5821c3681dd20/node_modules/prettier-plugin-tailwindcss/dist/utils-D8dQkKEd.mjs
|
|
3
|
-
function isNodeLike(value) {
|
|
4
|
-
return typeof (value === null || value === void 0 ? void 0 : value.type) === "string";
|
|
5
|
-
}
|
|
6
|
-
function visit(ast, callbackMap) {
|
|
7
|
-
function _visit(node, path, meta) {
|
|
8
|
-
if (typeof callbackMap === "function") {
|
|
9
|
-
if (callbackMap(node, path, meta) === false) return;
|
|
10
|
-
} else if (node.type in callbackMap) {
|
|
11
|
-
if (callbackMap[node.type](node, path, meta) === false) return;
|
|
12
|
-
}
|
|
13
|
-
const keys = Object.keys(node);
|
|
14
|
-
for (let i = 0; i < keys.length; i++) {
|
|
15
|
-
const child = node[keys[i]];
|
|
16
|
-
if (Array.isArray(child)) {
|
|
17
|
-
for (let j = 0; j < child.length; j++) if (isNodeLike(child[j])) {
|
|
18
|
-
let newMeta = { ...meta };
|
|
19
|
-
let newPath = [{
|
|
20
|
-
node: child[j],
|
|
21
|
-
parent: node,
|
|
22
|
-
key: keys[i],
|
|
23
|
-
index: j,
|
|
24
|
-
meta: newMeta
|
|
25
|
-
}, ...path];
|
|
26
|
-
_visit(child[j], newPath, newMeta);
|
|
27
|
-
}
|
|
28
|
-
} else if (isNodeLike(child)) {
|
|
29
|
-
let newMeta = { ...meta };
|
|
30
|
-
_visit(child, [{
|
|
31
|
-
node: child,
|
|
32
|
-
parent: node,
|
|
33
|
-
key: keys[i],
|
|
34
|
-
index: i,
|
|
35
|
-
meta: newMeta
|
|
36
|
-
}, ...path], newMeta);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
let newMeta = {};
|
|
41
|
-
_visit(ast, [{
|
|
42
|
-
node: ast,
|
|
43
|
-
parent: null,
|
|
44
|
-
key: null,
|
|
45
|
-
index: null,
|
|
46
|
-
meta: newMeta
|
|
47
|
-
}], newMeta);
|
|
48
|
-
}
|
|
49
|
-
function spliceChangesIntoString(str, changes) {
|
|
50
|
-
if (!changes[0]) return str;
|
|
51
|
-
changes.sort((a, b) => {
|
|
52
|
-
return a.end - b.end || a.start - b.start;
|
|
53
|
-
});
|
|
54
|
-
let result = "";
|
|
55
|
-
let previous = changes[0];
|
|
56
|
-
result += str.slice(0, previous.start);
|
|
57
|
-
result += previous.after;
|
|
58
|
-
for (let i = 1; i < changes.length; ++i) {
|
|
59
|
-
let change = changes[i];
|
|
60
|
-
result += str.slice(previous.end, change.start);
|
|
61
|
-
result += change.after;
|
|
62
|
-
previous = change;
|
|
63
|
-
}
|
|
64
|
-
result += str.slice(previous.end);
|
|
65
|
-
return result;
|
|
66
|
-
}
|
|
67
|
-
function bigSign(bigIntValue) {
|
|
68
|
-
return Number(bigIntValue > 0n) - Number(bigIntValue < 0n);
|
|
69
|
-
}
|
|
70
|
-
function cacheForDirs(cache, inputDir, value, targetDir, makeKey = (dir) => dir) {
|
|
71
|
-
let dir = inputDir;
|
|
72
|
-
while (dir !== path.dirname(dir) && dir.length >= targetDir.length) {
|
|
73
|
-
const key = makeKey(dir);
|
|
74
|
-
if (cache.get(key) !== void 0) break;
|
|
75
|
-
cache.set(key, value);
|
|
76
|
-
if (dir === targetDir) break;
|
|
77
|
-
dir = path.dirname(dir);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
//#endregion
|
|
81
|
-
export { visit as i, cacheForDirs as n, spliceChangesIntoString as r, bigSign as t };
|
|
File without changes
|