🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

oxfmt

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oxfmt - npm Package Compare versions

Comparing version
0.59.0
to
0.60.0
+124
dist/apis-Bk5AVt85.js
import { o as __toESM } from "./rolldown-runtime-CE-6LUnI.js";
//#region src-js/libs/apis.ts
const CACHES = {
prettier: null,
sveltePlugin: null,
tailwindPlugin: null,
tailwindSorter: null,
oxfmtPlugin: null
};
async function loadCached(key, loader) {
CACHES[key] ??= await loader();
return CACHES[key];
}
async function loadPrettier() {
return loadCached("prettier", async () => {
const prettier = await import("./prettier-CEZwFZsY.js");
const { formatOptionsHiddenDefaults } = prettier.__internal;
formatOptionsHiddenDefaults.parentParser = null;
formatOptionsHiddenDefaults.__onHtmlRoot = null;
formatOptionsHiddenDefaults.__inJsTemplate = null;
return prettier;
});
}
/**
* Format non-js file
*
* @returns Formatted code
*/
async function formatFile({ code, options }) {
const prettier = CACHES.prettier ?? await loadPrettier();
if ("_useSveltePlugin" in options) await setupSveltePlugin(options);
if ("_useTailwindPlugin" in options) await setupTailwindPlugin(options);
if ("_oxfmtPluginOptionsJson" in options) await setupOxfmtPlugin(options);
return prettier.format(code, options);
}
/**
* Format non-js code snippets into formatted string.
* Mainly used for formatting code fences within JSDoc,
* and is also used as a temporary fallback for html-in-js.
*
* @returns Formatted code snippet
*/
async function formatEmbeddedCode({ code, options }) {
const prettier = CACHES.prettier ?? await loadPrettier();
if ("_useTailwindPlugin" in options) await setupTailwindPlugin(options);
return prettier.format(code, options);
}
/**
* Format non-js code snippets into Prettier `Doc` JSON strings.
*
* This makes our printer correctly handle `printWidth` even for embedded code.
* - For gql-in-js, `texts` contains multiple parts split by `${}` in a template literal
* - For others, `texts` always contains a single string with `${}` parts replaced by placeholders
* However, this function does not need to be aware of that,
* as it simply formats each text part independently and returns an array of formatted parts.
*
* @returns Doc JSON strings
*/
async function formatEmbeddedDoc({ texts, options }) {
const prettier = CACHES.prettier ?? await loadPrettier();
if ("_useTailwindPlugin" in options) await setupTailwindPlugin(options);
return Promise.all(texts.map(async (text) => {
const metadata = {};
if (options.parser === "html" || options.parser === "angular") {
options.parentParser = "OXFMT";
options.__onHtmlRoot = (root) => metadata.htmlHasMultipleRootElements = (root.children?.length ?? 0) > 1;
}
if (options.parser === "markdown") options.__inJsTemplate = true;
const doc = await prettier.__debug.printToDoc(text, options);
const symbolToNumber = /* @__PURE__ */ new Map();
let nextId = 1;
return JSON.stringify([doc, metadata], (_key, value) => {
if (typeof value === "symbol") {
if (!symbolToNumber.has(value)) symbolToNumber.set(value, nextId++);
return symbolToNumber.get(value);
}
if (value === -Infinity) return "__NEGATIVE_INFINITY__";
return value;
});
}));
}
/**
* Load Tailwind CSS plugin.
* Option mapping (sortTailwindcss.xxx → tailwindXxx) is also done in Rust side.
*/
async function setupTailwindPlugin(options) {
CACHES.tailwindPlugin ??= await loadCached("tailwindPlugin", () => import("./dist-I4seA-OP.js"));
options.plugins ??= [];
options.plugins.push(CACHES.tailwindPlugin);
}
/**
* Process Tailwind CSS classes found in JS/TS files in batch.
* @param args - Object containing classes and options (filepath is in options.filepath)
* @returns Array of sorted class strings (same order/length as input)
*/
async function sortTailwindClasses({ classes, options }) {
CACHES.tailwindSorter ??= await loadCached("tailwindSorter", () => import("./sorter-DY6KoBV3.js"));
const { createSorter } = CACHES.tailwindSorter;
return (await createSorter({
filepath: options.filepath,
stylesheetPath: options.tailwindStylesheet,
configPath: options.tailwindConfig,
preserveWhitespace: options.tailwindPreserveWhitespace,
preserveDuplicates: options.tailwindPreserveDuplicates
})).sortClassAttributes(classes);
}
/**
* Load prettier-plugin-svelte to provide the `svelte` parser.
*/
async function setupSveltePlugin(options) {
CACHES.sveltePlugin ??= await loadCached("sveltePlugin", async () => await import("./plugin-B4312L3R.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1)));
options.plugins ??= [];
options.plugins.push(CACHES.sveltePlugin);
}
/**
* Load oxfmt plugin for js-in-xxx parsers.
*/
async function setupOxfmtPlugin(options) {
CACHES.oxfmtPlugin ??= await loadCached("oxfmtPlugin", async () => await import("./prettier-plugin-oxfmt-Dj6FaAil.js"));
options.plugins ??= [];
options.plugins.push(CACHES.oxfmtPlugin);
}
//#endregion
export { sortTailwindClasses as i, formatEmbeddedDoc as n, formatFile as r, formatEmbeddedCode as t };
import { r as __exportAll } from "./rolldown-runtime-CE-6LUnI.js";
import { createRequire } from "module";
//#region src-js/bindings.js
var bindings_exports = /* @__PURE__ */ __exportAll({
Severity: () => Severity,
format: () => format,
jsTextToDoc: () => jsTextToDoc,
runCli: () => runCli
});
const require = createRequire(import.meta.url);
new URL(".", import.meta.url).pathname;
const { readFileSync } = require("fs");
let nativeBinding = null;
const loadErrors = [];
const isMusl = () => {
let musl = false;
if (process.platform === "linux") {
musl = isMuslFromFilesystem();
if (musl === null) musl = isMuslFromReport();
if (musl === null) musl = isMuslFromChildProcess();
}
return musl;
};
const isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
const isMuslFromFilesystem = () => {
try {
return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
} catch {
return null;
}
};
const isMuslFromReport = () => {
let report = null;
if (process.report && typeof process.report.getReport === "function") {
process.report.excludeNetwork = true;
report = process.report.getReport();
}
if (!report) return null;
if (report.header && report.header.glibcVersionRuntime) return false;
if (Array.isArray(report.sharedObjects)) {
if (report.sharedObjects.some(isFileMusl)) return true;
}
return false;
};
const isMuslFromChildProcess = () => {
try {
return require("child_process").execSync("ldd --version", { encoding: "utf8" }).includes("musl");
} catch (e) {
return false;
}
};
function requireNative() {
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) try {
return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
} catch (err) {
loadErrors.push(err);
}
else if (process.platform === "android") if (process.arch === "arm64") {
try {
return require("./oxfmt.android-arm64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-android-arm64");
const bindingPackageVersion = require("@oxfmt/binding-android-arm64/package.json").version;
if (bindingPackageVersion !== "0.60.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.60.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "arm") {
try {
return require("./oxfmt.android-arm-eabi.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-android-arm-eabi");
const bindingPackageVersion = require("@oxfmt/binding-android-arm-eabi/package.json").version;
if (bindingPackageVersion !== "0.60.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.60.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Android ${process.arch}`));
else if (process.platform === "win32") if (process.arch === "x64") if (process.config && process.config.variables && process.config.variables.shlib_suffix === "dll.a" || process.config && process.config.variables && process.config.variables.node_target_type === "shared_library") {
try {
return require("./oxfmt.win32-x64-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-win32-x64-gnu");
const bindingPackageVersion = require("@oxfmt/binding-win32-x64-gnu/package.json").version;
if (bindingPackageVersion !== "0.60.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.60.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else {
try {
return require("./oxfmt.win32-x64-msvc.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-win32-x64-msvc");
const bindingPackageVersion = require("@oxfmt/binding-win32-x64-msvc/package.json").version;
if (bindingPackageVersion !== "0.60.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.60.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
}
else if (process.arch === "ia32") {
try {
return require("./oxfmt.win32-ia32-msvc.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-win32-ia32-msvc");
const bindingPackageVersion = require("@oxfmt/binding-win32-ia32-msvc/package.json").version;
if (bindingPackageVersion !== "0.60.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.60.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "arm64") {
try {
return require("./oxfmt.win32-arm64-msvc.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-win32-arm64-msvc");
const bindingPackageVersion = require("@oxfmt/binding-win32-arm64-msvc/package.json").version;
if (bindingPackageVersion !== "0.60.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.60.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Windows: ${process.arch}`));
else if (process.platform === "darwin") {
try {
return require("./oxfmt.darwin-universal.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-darwin-universal");
const bindingPackageVersion = require("@oxfmt/binding-darwin-universal/package.json").version;
if (bindingPackageVersion !== "0.60.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.60.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
if (process.arch === "x64") {
try {
return require("./oxfmt.darwin-x64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-darwin-x64");
const bindingPackageVersion = require("@oxfmt/binding-darwin-x64/package.json").version;
if (bindingPackageVersion !== "0.60.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.60.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "arm64") {
try {
return require("./oxfmt.darwin-arm64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-darwin-arm64");
const bindingPackageVersion = require("@oxfmt/binding-darwin-arm64/package.json").version;
if (bindingPackageVersion !== "0.60.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.60.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on macOS: ${process.arch}`));
} else if (process.platform === "freebsd") if (process.arch === "x64") {
try {
return require("./oxfmt.freebsd-x64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-freebsd-x64");
const bindingPackageVersion = require("@oxfmt/binding-freebsd-x64/package.json").version;
if (bindingPackageVersion !== "0.60.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.60.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "arm64") {
try {
return require("./oxfmt.freebsd-arm64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-freebsd-arm64");
const bindingPackageVersion = require("@oxfmt/binding-freebsd-arm64/package.json").version;
if (bindingPackageVersion !== "0.60.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.60.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on FreeBSD: ${process.arch}`));
else if (process.platform === "linux") if (process.arch === "x64") if (isMusl()) {
try {
return require("./oxfmt.linux-x64-musl.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-linux-x64-musl");
const bindingPackageVersion = require("@oxfmt/binding-linux-x64-musl/package.json").version;
if (bindingPackageVersion !== "0.60.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.60.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else {
try {
return require("./oxfmt.linux-x64-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-linux-x64-gnu");
const bindingPackageVersion = require("@oxfmt/binding-linux-x64-gnu/package.json").version;
if (bindingPackageVersion !== "0.60.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.60.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
}
else if (process.arch === "arm64") if (isMusl()) {
try {
return require("./oxfmt.linux-arm64-musl.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-linux-arm64-musl");
const bindingPackageVersion = require("@oxfmt/binding-linux-arm64-musl/package.json").version;
if (bindingPackageVersion !== "0.60.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.60.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else {
try {
return require("./oxfmt.linux-arm64-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-linux-arm64-gnu");
const bindingPackageVersion = require("@oxfmt/binding-linux-arm64-gnu/package.json").version;
if (bindingPackageVersion !== "0.60.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.60.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
}
else if (process.arch === "arm") if (isMusl()) {
try {
return require("./oxfmt.linux-arm-musleabihf.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-linux-arm-musleabihf");
const bindingPackageVersion = require("@oxfmt/binding-linux-arm-musleabihf/package.json").version;
if (bindingPackageVersion !== "0.60.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.60.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else {
try {
return require("./oxfmt.linux-arm-gnueabihf.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-linux-arm-gnueabihf");
const bindingPackageVersion = require("@oxfmt/binding-linux-arm-gnueabihf/package.json").version;
if (bindingPackageVersion !== "0.60.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.60.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
}
else if (process.arch === "loong64") if (isMusl()) {
try {
return require("./oxfmt.linux-loong64-musl.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-linux-loong64-musl");
const bindingPackageVersion = require("@oxfmt/binding-linux-loong64-musl/package.json").version;
if (bindingPackageVersion !== "0.60.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.60.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else {
try {
return require("./oxfmt.linux-loong64-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-linux-loong64-gnu");
const bindingPackageVersion = require("@oxfmt/binding-linux-loong64-gnu/package.json").version;
if (bindingPackageVersion !== "0.60.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.60.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
}
else if (process.arch === "riscv64") if (isMusl()) {
try {
return require("./oxfmt.linux-riscv64-musl.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-linux-riscv64-musl");
const bindingPackageVersion = require("@oxfmt/binding-linux-riscv64-musl/package.json").version;
if (bindingPackageVersion !== "0.60.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.60.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else {
try {
return require("./oxfmt.linux-riscv64-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-linux-riscv64-gnu");
const bindingPackageVersion = require("@oxfmt/binding-linux-riscv64-gnu/package.json").version;
if (bindingPackageVersion !== "0.60.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.60.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
}
else if (process.arch === "ppc64") {
try {
return require("./oxfmt.linux-ppc64-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-linux-ppc64-gnu");
const bindingPackageVersion = require("@oxfmt/binding-linux-ppc64-gnu/package.json").version;
if (bindingPackageVersion !== "0.60.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.60.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "s390x") {
try {
return require("./oxfmt.linux-s390x-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-linux-s390x-gnu");
const bindingPackageVersion = require("@oxfmt/binding-linux-s390x-gnu/package.json").version;
if (bindingPackageVersion !== "0.60.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.60.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Linux: ${process.arch}`));
else if (process.platform === "openharmony") if (process.arch === "arm64") {
try {
return require("./oxfmt.openharmony-arm64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-openharmony-arm64");
const bindingPackageVersion = require("@oxfmt/binding-openharmony-arm64/package.json").version;
if (bindingPackageVersion !== "0.60.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.60.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "x64") {
try {
return require("./oxfmt.openharmony-x64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-openharmony-x64");
const bindingPackageVersion = require("@oxfmt/binding-openharmony-x64/package.json").version;
if (bindingPackageVersion !== "0.60.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.60.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "arm") {
try {
return require("./oxfmt.openharmony-arm.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-openharmony-arm");
const bindingPackageVersion = require("@oxfmt/binding-openharmony-arm/package.json").version;
if (bindingPackageVersion !== "0.60.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.60.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`));
else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`));
}
nativeBinding = requireNative();
const forceWasi = process.env.NAPI_RS_FORCE_WASI === "true" || process.env.NAPI_RS_FORCE_WASI === "error";
if (!nativeBinding || forceWasi) {
let wasiBinding = null;
let wasiBindingError = null;
try {
wasiBinding = require("./oxfmt.wasi.cjs");
nativeBinding = wasiBinding;
} catch (err) {
if (forceWasi) wasiBindingError = err;
}
if (!nativeBinding || forceWasi) try {
wasiBinding = require("@oxfmt/binding-wasm32-wasi");
nativeBinding = wasiBinding;
} catch (err) {
if (forceWasi) {
if (!wasiBindingError) wasiBindingError = err;
else wasiBindingError.cause = err;
loadErrors.push(err);
}
}
if (process.env.NAPI_RS_FORCE_WASI === "error" && !wasiBinding) {
const error = /* @__PURE__ */ new Error("WASI binding not found and NAPI_RS_FORCE_WASI is set to error");
error.cause = wasiBindingError;
throw error;
}
}
if (!nativeBinding) {
if (loadErrors.length > 0) {
const error = /* @__PURE__ */ new Error("Cannot find native binding. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.");
error.cause = loadErrors.reduce((err, cur) => {
cur.cause = err;
return cur;
});
throw error;
}
throw new Error(`Failed to load native binding`);
}
const { Severity, format, jsTextToDoc, runCli } = nativeBinding;
//#endregion
export { runCli as n, bindings_exports as t };
import { createRequire } from "node:module";
//#region ../../node_modules/.pnpm/prettier-plugin-tailwindcss@0.0.0-insiders.2b6f3c2_prettier-plugin-svelte@4.1.1_prettie_e8e3951fdd3f2f4e3de4f0eca24b95a4/node_modules/prettier-plugin-tailwindcss/dist/chunk-DSjvVL_1.mjs
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
var __exportAll = (all, symbols) => {
let target = {};
for (var name in all) __defProp(target, name, {
get: all[name],
enumerable: true
});
if (symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
return target;
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
key = keys[i];
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: ((k) => from[k]).bind(null, key),
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
value: mod,
enumerable: true
}) : target, mod));
var __require = /* @__PURE__ */ createRequire(import.meta.url);
//#endregion
export { __toESM as a, __require as i, __esmMin as n, __exportAll as r, __commonJSMin as t };
import { o as __toESM } from "./rolldown-runtime-CE-6LUnI.js";
import { n as init_babel, parsers as Aa, t as babel_exports } from "./babel-7tfAjQas.js";
import index_exports, { t as init_prettier } from "./prettier-CEZwFZsY.js";
import { a as __toESM$1, t as __commonJSMin } from "./chunk-DSjvVL_1-D3-3th-9.js";
import { a as sortClasses, c as cacheForDirs, d as expiringMap, f as loadIfExists, i as sortClassList, l as spliceChangesIntoString, n as error, o as warn, p as maybeResolve, r as getTailwindConfig$1, u as visit } from "./sorter-BZkvDMjt-DLXDdrqx.js";
import { parsers as Cn, t as init_angular } from "./angular-Clx-wbm6.js";
import { n as postcss_exports, parsers as cn, t as init_postcss } from "./postcss-DuOoF7OX.js";
import * as path from "node:path";
import { isAbsolute } from "path";
//#region ../../node_modules/.pnpm/prettier-plugin-tailwindcss@0.0.0-insiders.2b6f3c2_prettier-plugin-svelte@4.1.1_prettie_e8e3951fdd3f2f4e3de4f0eca24b95a4/node_modules/prettier-plugin-tailwindcss/dist/index.mjs
init_angular();
init_babel();
init_postcss();
init_prettier();
var require_isarray = /* @__PURE__ */ __commonJSMin(((exports, module) => {
var toString = {}.toString;
module.exports = Array.isArray || function(arr) {
return toString.call(arr) == "[object Array]";
};
}));
/*!
* isobject <https://github.com/jonschlinkert/isobject>
*
* Copyright (c) 2014-2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
var require_isobject = /* @__PURE__ */ __commonJSMin(((exports, module) => {
var isArray = require_isarray();
module.exports = function isObject(val) {
return val != null && typeof val === "object" && isArray(val) === false;
};
}));
var import_line_column = /* @__PURE__ */ __toESM$1((/* @__PURE__ */ __commonJSMin(((exports, module) => {
var isArray = require_isarray();
var isObject = require_isobject();
Array.prototype.slice;
module.exports = LineColumnFinder;
function LineColumnFinder(str, options) {
if (!(this instanceof LineColumnFinder)) {
if (typeof options === "number") return new LineColumnFinder(str).fromIndex(options);
return new LineColumnFinder(str, options);
}
this.str = str || "";
this.lineToIndex = buildLineToIndex(this.str);
options = options || {};
this.origin = typeof options.origin === "undefined" ? 1 : options.origin;
}
LineColumnFinder.prototype.fromIndex = function(index) {
if (index < 0 || index >= this.str.length || isNaN(index)) return null;
var line = findLowerIndexInRangeArray(index, this.lineToIndex);
return {
line: line + this.origin,
col: index - this.lineToIndex[line] + this.origin
};
};
LineColumnFinder.prototype.toIndex = function(line, column) {
if (typeof column === "undefined") {
if (isArray(line) && line.length >= 2) return this.toIndex(line[0], line[1]);
if (isObject(line) && "line" in line && ("col" in line || "column" in line)) return this.toIndex(line.line, "col" in line ? line.col : line.column);
return -1;
}
if (isNaN(line) || isNaN(column)) return -1;
line -= this.origin;
column -= this.origin;
if (line >= 0 && column >= 0 && line < this.lineToIndex.length) {
var lineIndex = this.lineToIndex[line];
var nextIndex = line === this.lineToIndex.length - 1 ? this.str.length : this.lineToIndex[line + 1];
if (column < nextIndex - lineIndex) return lineIndex + column;
}
return -1;
};
function buildLineToIndex(str) {
var lines = str.split("\n"), lineToIndex = new Array(lines.length), index = 0;
for (var i = 0, l = lines.length; i < l; i++) {
lineToIndex[i] = index;
index += lines[i].length + 1;
}
return lineToIndex;
}
function findLowerIndexInRangeArray(value, arr) {
if (value >= arr[arr.length - 1]) return arr.length - 1;
var min = 0, max = arr.length - 2, mid;
while (min < max) {
mid = min + (max - min >> 1);
if (value < arr[mid]) max = mid - 1;
else if (value >= arr[mid + 1]) min = mid + 1;
else {
min = mid;
break;
}
}
return min;
}
})))(), 1);
let prettierConfigCache = expiringMap(1e4);
async function resolvePrettierConfigDir(filePath, inputDir) {
let cached = prettierConfigCache.get(inputDir);
if (cached !== void 0) return cached ?? process.cwd();
const resolve = async () => {
try {
return await index_exports.resolveConfigFile(filePath);
} catch (err) {
error("prettier-config-not-found", "Failed to resolve Prettier Config");
error("prettier-config-not-found-err", err);
return null;
}
};
let prettierConfig = await resolve();
if (prettierConfig) {
let configDir = path.dirname(prettierConfig);
cacheForDirs(prettierConfigCache, inputDir, configDir, configDir);
return configDir;
} else {
prettierConfigCache.set(inputDir, null);
return process.cwd();
}
}
async function getTailwindConfig(options) {
let cwd = process.cwd();
let inputDir = options.filepath ? path.dirname(options.filepath) : cwd;
let needsPrettierConfig = options.tailwindConfig && !path.isAbsolute(options.tailwindConfig) || options.tailwindStylesheet && !path.isAbsolute(options.tailwindStylesheet) || options.tailwindEntryPoint && !path.isAbsolute(options.tailwindEntryPoint);
let configDir;
if (needsPrettierConfig) configDir = await resolvePrettierConfigDir(options.filepath, inputDir);
else configDir = cwd;
let configPath = options.tailwindConfig && !options.tailwindConfig.endsWith(".css") ? options.tailwindConfig : void 0;
let stylesheetPath = options.tailwindStylesheet;
if (!stylesheetPath && options.tailwindEntryPoint) {
warn("entrypoint-is-deprecated", configDir, "Deprecated: Use the `tailwindStylesheet` option for v4 projects instead of `tailwindEntryPoint`.");
stylesheetPath = options.tailwindEntryPoint;
}
if (!stylesheetPath && options.tailwindConfig && options.tailwindConfig.endsWith(".css")) {
warn("config-as-css-is-deprecated", configDir, "Deprecated: Use the `tailwindStylesheet` option for v4 projects instead of `tailwindConfig`.");
stylesheetPath = options.tailwindConfig;
}
return getTailwindConfig$1({
base: configDir,
filepath: options.filepath,
configPath,
stylesheetPath,
packageName: options.tailwindPackageName
});
}
const options = {
tailwindConfig: {
type: "string",
category: "Tailwind CSS",
description: "Path to Tailwind configuration file"
},
tailwindEntryPoint: {
type: "string",
category: "Tailwind CSS",
description: "Path to the CSS entrypoint in your Tailwind project (v4+)"
},
tailwindStylesheet: {
type: "string",
category: "Tailwind CSS",
description: "Path to the CSS stylesheet in your Tailwind project (v4+)"
},
tailwindAttributes: {
type: "string",
array: true,
default: [{ value: [] }],
category: "Tailwind CSS",
description: "List of attributes/props that contain sortable Tailwind classes"
},
tailwindFunctions: {
type: "string",
array: true,
default: [{ value: [] }],
category: "Tailwind CSS",
description: "List of functions and tagged templates that contain sortable Tailwind classes"
},
tailwindPreserveWhitespace: {
type: "boolean",
default: false,
category: "Tailwind CSS",
description: "Preserve whitespace around Tailwind classes when sorting"
},
tailwindPreserveDuplicates: {
type: "boolean",
default: false,
category: "Tailwind CSS",
description: "Preserve duplicate classes inside a class list when sorting"
},
tailwindPackageName: {
type: "string",
default: "tailwindcss",
category: "Tailwind CSS",
description: "The package name to use when loading Tailwind CSS"
}
};
function createMatcher(options, parser, defaults) {
let staticAttrs = new Set(defaults.staticAttrs);
let dynamicAttrs = new Set(defaults.dynamicAttrs);
let functions = new Set(defaults.functions);
let staticAttrsRegex = [...defaults.staticAttrsRegex];
let functionsRegex = [...defaults.functionsRegex];
for (let attr of options.tailwindAttributes ?? []) {
let regex = parseRegex(attr);
if (regex) staticAttrsRegex.push(regex);
else if (parser === "vue" && attr.startsWith(":")) staticAttrs.add(attr.slice(1));
else if (parser === "vue" && attr.startsWith("v-bind:")) staticAttrs.add(attr.slice(7));
else if (parser === "vue" && attr.startsWith("v-")) dynamicAttrs.add(attr);
else if (parser === "angular" && attr.startsWith("[") && attr.endsWith("]")) staticAttrs.add(attr.slice(1, -1));
else staticAttrs.add(attr);
}
for (let attr of staticAttrs) if (parser === "vue") {
dynamicAttrs.add(`:${attr}`);
dynamicAttrs.add(`v-bind:${attr}`);
} else if (parser === "angular") dynamicAttrs.add(`[${attr}]`);
for (let fn of options.tailwindFunctions ?? []) {
let regex = parseRegex(fn);
if (regex) functionsRegex.push(regex);
else functions.add(fn);
}
return {
hasStaticAttr: (name) => {
if (nameFromDynamicAttr(name, parser)) return false;
return hasMatch(name, staticAttrs, staticAttrsRegex);
},
hasDynamicAttr: (name) => {
if (hasMatch(name, dynamicAttrs, [])) return true;
let newName = nameFromDynamicAttr(name, parser);
if (!newName) return false;
return hasMatch(newName, staticAttrs, staticAttrsRegex);
},
hasFunction: (name) => hasMatch(name, functions, functionsRegex)
};
}
function nameFromDynamicAttr(name, parser) {
if (parser === "vue") {
if (name.startsWith(":")) return name.slice(1);
if (name.startsWith("v-bind:")) return name.slice(7);
if (name.startsWith("v-")) return name;
return null;
}
if (parser === "angular") {
if (name.startsWith("[") && name.endsWith("]")) return name.slice(1, -1);
return null;
}
return null;
}
function hasMatch(name, list, patterns) {
if (list.has(name)) return true;
for (let regex of patterns) if (regex.test(name)) return true;
return false;
}
function parseRegex(str) {
if (!str.startsWith("/")) return null;
let lastSlash = str.lastIndexOf("/");
if (lastSlash <= 0) return null;
try {
let pattern = str.slice(1, lastSlash);
let flags = str.slice(lastSlash + 1);
return new RegExp(pattern, flags);
} catch {
return null;
}
}
function createPlugin(transforms) {
let parsers = Object.create(null);
let printers = Object.create(null);
for (let opts of transforms) {
for (let [name, meta] of Object.entries(opts.parsers)) parsers[name] = async () => {
var _plugin$parsers;
let original = (_plugin$parsers = (await loadPlugins(meta.load ?? opts.load ?? [])).parsers) === null || _plugin$parsers === void 0 ? void 0 : _plugin$parsers[name];
if (!original) return;
parsers[name] = await createParser({
name,
original,
opts
});
return parsers[name];
};
for (let [name, _meta] of Object.entries(opts.printers ?? {})) printers[name] = async () => {
var _plugin$printers;
let original = (_plugin$printers = (await loadPlugins(opts.load ?? [])).printers) === null || _plugin$printers === void 0 ? void 0 : _plugin$printers[name];
if (!original) return;
printers[name] = createPrinter({
original,
opts
});
return printers[name];
};
}
return {
parsers,
printers
};
}
async function createParser({ name, original, opts }) {
let parser = { ...original };
async function load(options) {
let parser = { ...original };
for (const pluginName of opts.compatible || []) {
var _plugin$parsers2;
let plugin = await findEnabledPlugin(options, pluginName);
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]);
}
return parser;
}
parser.preprocess = async (code, options) => {
let parser = await load(options);
return parser.preprocess ? parser.preprocess(code, options) : code;
};
parser.parse = async (code, options) => {
let ast = await (await load(options)).parse(code, options, options);
let env = await loadTailwindCSS({
opts,
options
});
transformAst({
ast,
env,
opts,
options
});
options.__tailwindcss__ = env;
return ast;
};
return parser;
}
function createPrinter({ original, opts }) {
let printer = { ...original };
let reprint = opts.reprint;
if (reprint) {
printer.print = new Proxy(original.print, { apply(target, thisArg, args) {
let [path, options] = args;
let env = options.__tailwindcss__;
reprint(path, {
...env,
options
});
return Reflect.apply(target, thisArg, args);
} });
if (original.embed) printer.embed = new Proxy(original.embed, { apply(target, thisArg, args) {
let [path, options] = args;
let env = options.__tailwindcss__;
reprint(path, {
...env,
options
});
return Reflect.apply(target, thisArg, args);
} });
}
return printer;
}
async function loadPlugins(fns) {
let plugin = {
parsers: Object.create(null),
printers: Object.create(null),
options: Object.create(null),
defaultOptions: Object.create(null),
languages: []
};
for (let source of fns) {
let loaded = await loadPlugin(source);
Object.assign(plugin.parsers, loaded.parsers ?? {});
Object.assign(plugin.printers, loaded.printers ?? {});
Object.assign(plugin.options, loaded.options ?? {});
Object.assign(plugin.defaultOptions, loaded.defaultOptions ?? {});
plugin.languages = [...plugin.languages ?? [], ...loaded.languages ?? []];
}
return plugin;
}
const EMPTY_PLUGIN = {
parsers: {},
printers: {},
languages: [],
options: {},
defaultOptions: {}
};
async function loadPlugin(source) {
if ("importer" in source && typeof source.importer === "function") return normalizePlugin(await source.importer());
return source;
}
function normalizePlugin(source) {
if (source === null || typeof source !== "object") return EMPTY_PLUGIN;
let plugin = source.default;
return plugin && typeof plugin === "object" ? plugin : source;
}
function findEnabledPlugin(options, name) {
for (let plugin of options.plugins) {
if (plugin instanceof URL) {
if (plugin.protocol !== "file:") continue;
if (plugin.hostname !== "") continue;
plugin = plugin.pathname;
}
if (typeof plugin !== "string") {
if (!plugin.name) continue;
plugin = plugin.name;
}
if (plugin === name || isAbsolute(plugin) && plugin.includes(name) && maybeResolve(name) === plugin) return loadIfExists(name);
}
}
async function loadTailwindCSS({ options, opts }) {
var _parsers$parser, _parsers$parser2;
let parsers = opts.parsers;
let parser = options.parser;
return {
context: await getTailwindConfig(options),
matcher: createMatcher(options, parser, {
staticAttrs: new Set(((_parsers$parser = parsers[parser]) === null || _parsers$parser === void 0 ? void 0 : _parsers$parser.staticAttrs) ?? opts.staticAttrs ?? []),
dynamicAttrs: new Set(((_parsers$parser2 = parsers[parser]) === null || _parsers$parser2 === void 0 ? void 0 : _parsers$parser2.dynamicAttrs) ?? opts.dynamicAttrs ?? []),
functions: /* @__PURE__ */ new Set(),
staticAttrsRegex: [],
dynamicAttrsRegex: [],
functionsRegex: []
}),
options,
changes: []
};
}
function transformAst({ ast, env, opts }) {
let transform = opts.transform;
if (transform) transform(ast, env);
}
function defineTransform(opts) {
return opts;
}
function tryParseAngularAttribute(value, env) {
try {
return Cn.__ng_directive.parse(value, env.options);
} catch (err) {
console.warn("prettier-plugin-tailwindcss: Unable to parse angular directive");
console.warn(err);
return null;
}
}
function transformDynamicAngularAttribute(attr, env) {
let directiveAst = tryParseAngularAttribute(attr.value, env);
if (!directiveAst) return;
let changes = [];
visit(directiveAst, {
StringLiteral(node, path) {
if (!node.value) return;
let collapseWhitespace = canCollapseWhitespaceIn(path, env);
changes.push({
start: node.start + 1,
end: node.end - 1,
before: node.value,
after: sortClasses(node.value, {
env,
collapseWhitespace
})
});
},
TemplateLiteral(node, path) {
if (!node.quasis.length) return;
let collapseWhitespace = canCollapseWhitespaceIn(path, env);
for (let i = 0; i < node.quasis.length; i++) {
let quasi = node.quasis[i];
changes.push({
start: quasi.start,
end: quasi.end,
before: quasi.value.raw,
after: sortClasses(quasi.value.raw, {
env,
ignoreFirst: i > 0 && !/^\s/.test(quasi.value.raw),
ignoreLast: i < node.expressions.length && !/\s$/.test(quasi.value.raw),
collapseWhitespace: collapseWhitespace ? {
start: collapseWhitespace.start && i === 0,
end: collapseWhitespace.end && i >= node.expressions.length
} : false
})
});
}
}
});
attr.value = spliceChangesIntoString(attr.value, changes);
}
function transformDynamicJsAttribute(attr, env) {
let { matcher } = env;
let source = `let __prettier_temp__ = ${attr.value}`;
let ast = Aa["babel-ts"].parse(source, env.options);
let didChange = false;
let changes = [];
function findConcatEntry(path) {
return path.find((entry) => {
var _entry$parent;
return ((_entry$parent = entry.parent) === null || _entry$parent === void 0 ? void 0 : _entry$parent.type) === "BinaryExpression" && entry.parent.operator === "+";
});
}
function addChange(start, end, after) {
if (start == null || end == null) return;
let offsetStart = start - 24;
let offsetEnd = end - 24;
if (offsetStart < 0 || offsetEnd < 0) return;
didChange = true;
changes.push({
start: offsetStart,
end: offsetEnd,
before: attr.value.slice(offsetStart, offsetEnd),
after
});
}
visit(ast, {
StringLiteral(node, path) {
let concat = findConcatEntry(path);
if (sortStringLiteral(node, {
env,
collapseWhitespace: {
start: (concat === null || concat === void 0 ? void 0 : concat.key) !== "right",
end: (concat === null || concat === void 0 ? void 0 : concat.key) !== "left"
}
})) {
var _node$extra;
let raw = ((_node$extra = node.extra) === null || _node$extra === void 0 ? void 0 : _node$extra.raw) ?? node.raw;
if (typeof raw === "string") addChange(node.start, node.end, raw);
}
},
Literal(node, path) {
if (!isStringLiteral(node)) return;
let concat = findConcatEntry(path);
if (sortStringLiteral(node, {
env,
collapseWhitespace: {
start: (concat === null || concat === void 0 ? void 0 : concat.key) !== "right",
end: (concat === null || concat === void 0 ? void 0 : concat.key) !== "left"
}
})) {
var _node$extra2;
let raw = ((_node$extra2 = node.extra) === null || _node$extra2 === void 0 ? void 0 : _node$extra2.raw) ?? node.raw;
if (typeof raw === "string") addChange(node.start, node.end, raw);
}
},
TemplateLiteral(node, path) {
let concat = findConcatEntry(path);
let originalQuasis = node.quasis.map((quasi) => quasi.value.raw);
if (sortTemplateLiteral(node, {
env,
collapseWhitespace: {
start: (concat === null || concat === void 0 ? void 0 : concat.key) !== "right",
end: (concat === null || concat === void 0 ? void 0 : concat.key) !== "left"
}
})) for (let i = 0; i < node.quasis.length; i++) {
let quasi = node.quasis[i];
if (quasi.value.raw !== originalQuasis[i]) addChange(quasi.start, quasi.end, quasi.value.raw);
}
},
TaggedTemplateExpression(node, path) {
if (!isSortableTemplateExpression(node, matcher)) return;
let concat = findConcatEntry(path);
let originalQuasis = node.quasi.quasis.map((quasi) => quasi.value.raw);
if (sortTemplateLiteral(node.quasi, {
env,
collapseWhitespace: {
start: (concat === null || concat === void 0 ? void 0 : concat.key) !== "right",
end: (concat === null || concat === void 0 ? void 0 : concat.key) !== "left"
}
})) for (let i = 0; i < node.quasi.quasis.length; i++) {
let quasi = node.quasi.quasis[i];
if (quasi.value.raw !== originalQuasis[i]) addChange(quasi.start, quasi.end, quasi.value.raw);
}
}
});
if (didChange) attr.value = spliceChangesIntoString(attr.value, changes);
}
function transformHtml(ast, env) {
let { matcher } = env;
let { parser } = env.options;
for (let attr of ast.attrs ?? []) if (matcher.hasStaticAttr(attr.name)) attr.value = sortClasses(attr.value, { env });
else if (matcher.hasDynamicAttr(attr.name)) {
if (!/[`'"]/.test(attr.value)) continue;
if (parser === "angular") transformDynamicAngularAttribute(attr, env);
else transformDynamicJsAttribute(attr, env);
}
for (let child of ast.children ?? []) transformHtml(child, env);
}
function transformGlimmer(ast, env) {
let { matcher } = env;
visit(ast, {
AttrNode(attr, _path, meta) {
if (matcher.hasStaticAttr(attr.name) && attr.value) meta.sortTextNodes = true;
},
TextNode(node, path, meta) {
if (!meta.sortTextNodes) return;
let concat = path.find((entry) => {
return entry.parent && entry.parent.type === "ConcatStatement";
});
let siblings = {
prev: concat === null || concat === void 0 ? void 0 : concat.parent.parts[concat.index - 1],
next: concat === null || concat === void 0 ? void 0 : concat.parent.parts[concat.index + 1]
};
node.chars = sortClasses(node.chars, {
env,
ignoreFirst: siblings.prev && !/^\s/.test(node.chars),
ignoreLast: siblings.next && !/\s$/.test(node.chars),
collapseWhitespace: {
start: !siblings.prev,
end: !siblings.next
}
});
},
StringLiteral(node, path, meta) {
if (!meta.sortTextNodes) return;
let concat = path.find((entry) => {
return entry.parent && entry.parent.type === "SubExpression" && entry.parent.path.original === "concat";
});
node.value = sortClasses(node.value, {
env,
ignoreLast: Boolean(concat) && !/[^\S\r\n]$/.test(node.value),
collapseWhitespace: {
start: false,
end: !concat
}
});
}
});
}
function transformLiquid(ast, env) {
let { matcher } = env;
function isClassAttr(node) {
return Array.isArray(node.name) ? node.name.every((n) => n.type === "TextNode" && matcher.hasStaticAttr(n.value)) : matcher.hasStaticAttr(node.name);
}
function hasSurroundingQuotes(str) {
let start = str[0];
return start === str[str.length - 1] && (start === "\"" || start === "'" || start === "`");
}
let sources = [];
let changes = [];
function sortAttribute(attr) {
for (let i = 0; i < attr.value.length; i++) {
let node = attr.value[i];
if (node.type === "TextNode") {
let after = sortClasses(node.value, {
env,
ignoreFirst: i > 0 && !/^\s/.test(node.value),
ignoreLast: i < attr.value.length - 1 && !/\s$/.test(node.value),
removeDuplicates: false,
collapseWhitespace: false
});
changes.push({
start: node.position.start,
end: node.position.end,
before: node.value,
after
});
} else if ((node.type === "LiquidDrop" || node.type === "LiquidVariableOutput") && typeof node.markup === "object" && node.markup.type === "LiquidVariable") visit(node.markup.expression, { String(node) {
let pos = { ...node.position };
if (hasSurroundingQuotes(node.source.slice(pos.start, pos.end))) {
pos.start += 1;
pos.end -= 1;
}
let after = sortClasses(node.value, { env });
changes.push({
start: pos.start,
end: pos.end,
before: node.value,
after
});
} });
}
}
visit(ast, {
LiquidTag(node) {
sources.push(node);
},
HtmlElement(node) {
sources.push(node);
},
AttrSingleQuoted(node) {
if (isClassAttr(node)) {
sources.push(node);
sortAttribute(node);
}
},
AttrDoubleQuoted(node) {
if (isClassAttr(node)) {
sources.push(node);
sortAttribute(node);
}
}
});
for (let node of sources) node.source = spliceChangesIntoString(node.source, changes);
}
function sortStringLiteral(node, { env, removeDuplicates, collapseWhitespace = {
start: true,
end: true
} }) {
var _node$extra3;
let raw = ((_node$extra3 = node.extra) === null || _node$extra3 === void 0 ? void 0 : _node$extra3.raw) ?? node.raw;
let quote = raw[0];
let rawContent = raw.slice(1, -1);
let sortedRaw = sortClasses(rawContent, {
env,
removeDuplicates,
collapseWhitespace
});
if (sortedRaw === rawContent) return false;
let sortedCooked = rawContent === node.value ? sortedRaw : sortClasses(node.value, {
env,
removeDuplicates,
collapseWhitespace
});
node.value = sortedCooked;
let newRaw = quote + sortedRaw + quote;
if (node.extra) node.extra = {
...node.extra,
rawValue: sortedCooked,
raw: newRaw
};
else node.raw = newRaw;
return true;
}
function isStringLiteral(node) {
return node.type === "StringLiteral" || node.type === "Literal" && typeof node.value === "string";
}
function sortTemplateLiteral(node, { env, removeDuplicates, collapseWhitespace = {
start: true,
end: true
} }) {
let didChange = false;
for (let i = 0; i < node.quasis.length; i++) {
let quasi = node.quasis[i];
let same = quasi.value.raw === quasi.value.cooked;
let originalRaw = quasi.value.raw;
let originalCooked = quasi.value.cooked;
quasi.value.raw = sortClasses(quasi.value.raw, {
env,
removeDuplicates,
ignoreFirst: i > 0 && !/^\s/.test(quasi.value.raw),
ignoreLast: i < node.expressions.length && !/\s$/.test(quasi.value.raw),
collapseWhitespace: collapseWhitespace && {
start: collapseWhitespace && collapseWhitespace.start && i === 0,
end: collapseWhitespace && collapseWhitespace.end && i >= node.expressions.length
}
});
quasi.value.cooked = same ? quasi.value.raw : sortClasses(quasi.value.cooked, {
env,
ignoreFirst: i > 0 && !/^\s/.test(quasi.value.cooked),
ignoreLast: i < node.expressions.length && !/\s$/.test(quasi.value.cooked),
removeDuplicates,
collapseWhitespace: collapseWhitespace && {
start: collapseWhitespace && collapseWhitespace.start && i === 0,
end: collapseWhitespace && collapseWhitespace.end && i >= node.expressions.length
}
});
if (quasi.value.raw !== originalRaw || quasi.value.cooked !== originalCooked) didChange = true;
}
return didChange;
}
function isSortableTemplateExpression(node, matcher) {
return isSortableExpression(node.tag, matcher);
}
function isSortableCallExpression(node, matcher) {
var _node$arguments;
if (!((_node$arguments = node.arguments) === null || _node$arguments === void 0 ? void 0 : _node$arguments.length)) return false;
return isSortableExpression(node.callee, matcher);
}
function isSortableExpression(node, matcher) {
while (node.type === "CallExpression" || node.type === "MemberExpression") if (node.type === "CallExpression") node = node.callee;
else if (node.type === "MemberExpression") node = node.object;
if (node.type === "Identifier") return matcher.hasFunction(node.name);
return false;
}
function canCollapseWhitespaceIn(path, env) {
if (env.options.tailwindPreserveWhitespace) return false;
let start = true;
let end = true;
for (let entry of path) {
if (!entry.parent) continue;
if (entry.parent.type === "BinaryExpression" && entry.parent.operator === "+") {
start && (start = entry.key !== "right");
end && (end = entry.key !== "left");
}
if (entry.parent.type === "TemplateLiteral") {
let nodeStart = entry.node.start ?? null;
let nodeEnd = entry.node.end ?? null;
for (let quasi of entry.parent.quasis) {
let quasiStart = quasi.start ?? null;
let quasiEnd = quasi.end ?? null;
if (nodeStart !== null && quasiEnd !== null && nodeStart - quasiEnd <= 2) start && (start = /^\s/.test(quasi.value.raw));
if (nodeEnd !== null && quasiStart !== null && nodeEnd - quasiStart <= 2) end && (end = /\s$/.test(quasi.value.raw));
}
}
}
return {
start,
end
};
}
function transformJavaScript(ast, env) {
let { matcher } = env;
function sortInside(ast) {
visit(ast, (node, path) => {
let collapseWhitespace = canCollapseWhitespaceIn(path, env);
if (isStringLiteral(node)) sortStringLiteral(node, {
env,
collapseWhitespace
});
else if (node.type === "TemplateLiteral") sortTemplateLiteral(node, {
env,
collapseWhitespace
});
else if (node.type === "TaggedTemplateExpression") {
if (isSortableTemplateExpression(node, matcher)) sortTemplateLiteral(node.quasi, {
env,
collapseWhitespace
});
}
});
}
visit(ast, {
JSXAttribute(node) {
node = node;
if (!node.value) return;
if (typeof node.name.name !== "string") return;
if (!matcher.hasStaticAttr(node.name.name)) return;
if (isStringLiteral(node.value)) sortStringLiteral(node.value, { env });
else if (node.value.type === "JSXExpressionContainer") sortInside(node.value);
},
CallExpression(node) {
node = node;
if (!isSortableCallExpression(node, matcher)) return;
node.arguments.forEach((arg) => sortInside(arg));
},
TaggedTemplateExpression(node, path) {
node = node;
if (!isSortableTemplateExpression(node, matcher)) return;
let collapseWhitespace = canCollapseWhitespaceIn(path, env);
sortTemplateLiteral(node.quasi, {
env,
collapseWhitespace
});
}
});
}
function transformCss(ast, env) {
function tryParseAtRuleParams(name, params) {
if (typeof params !== "string") return params;
try {
return cn.css.parse(`@import ${params};`, { ...env.options }).nodes[0].params;
} catch (err) {
console.warn(`[prettier-plugin-tailwindcss] Unable to parse at rule`);
console.warn({
name,
params
});
console.warn(err);
}
return params;
}
ast.walk((node) => {
if (node.name === "plugin" || node.name === "config" || node.name === "source") node.params = tryParseAtRuleParams(node.name, node.params);
if (node.type === "css-atrule" && node.name === "apply") {
let isImportant = /\s+(?:!important|#{(['"]*)!important\1})\s*$/.test(node.params);
let classList = node.params;
let prefix = "";
let suffix = "";
if (classList.startsWith("~\"") && classList.endsWith("\"")) {
prefix = "~\"";
suffix = "\"";
classList = classList.slice(2, -1);
isImportant = false;
} else if (classList.startsWith("~'") && classList.endsWith("'")) {
prefix = "~'";
suffix = "'";
classList = classList.slice(2, -1);
isImportant = false;
}
classList = sortClasses(classList, {
env,
ignoreLast: isImportant,
collapseWhitespace: {
start: false,
end: !isImportant
}
});
node.params = `${prefix}${classList}${suffix}`;
}
});
}
function transformAstro(ast, env) {
let { matcher } = env;
if (ast.type === "element" || ast.type === "custom-element" || ast.type === "component") {
for (let attr of ast.attributes ?? []) if (matcher.hasStaticAttr(attr.name) && attr.type === "attribute" && attr.kind === "quoted") attr.value = sortClasses(attr.value, { env });
else if (matcher.hasDynamicAttr(attr.name) && attr.type === "attribute" && attr.kind === "expression" && typeof attr.value === "string") transformDynamicJsAttribute(attr, env);
}
for (let child of ast.children ?? []) transformAstro(child, env);
}
function transformMarko(ast, env) {
let { matcher } = env;
const nodesToVisit = [ast];
while (nodesToVisit.length > 0) {
const currentNode = nodesToVisit.pop();
switch (currentNode.type) {
case "File":
nodesToVisit.push(currentNode.program);
break;
case "Program":
nodesToVisit.push(...currentNode.body);
break;
case "MarkoTag":
nodesToVisit.push(...currentNode.attributes);
nodesToVisit.push(currentNode.body);
break;
case "MarkoTagBody":
nodesToVisit.push(...currentNode.body);
break;
case "MarkoAttribute":
if (!matcher.hasStaticAttr(currentNode.name)) break;
switch (currentNode.value.type) {
case "ArrayExpression":
const classList = currentNode.value.elements;
for (const node of classList) if (node.type === "StringLiteral") node.value = sortClasses(node.value, { env });
break;
case "StringLiteral":
currentNode.value.value = sortClasses(currentNode.value.value, { env });
break;
}
break;
}
}
}
function transformTwig(ast, env) {
let { matcher } = env;
for (let child of ast.expressions ?? []) transformTwig(child, env);
visit(ast, {
Attribute(node, _path, meta) {
if (!matcher.hasStaticAttr(node.name.name)) return;
meta.sortTextNodes = true;
},
CallExpression(node, _path, meta) {
while (node.type === "CallExpression" || node.type === "MemberExpression") if (node.type === "CallExpression") node = node.callee;
else if (node.type === "MemberExpression") node = node.property;
if (node.type === "Identifier") {
if (!matcher.hasFunction(node.name)) return;
}
meta.sortTextNodes = true;
},
StringLiteral(node, path, meta) {
if (!meta.sortTextNodes) return;
const concat = path.find((entry) => {
return entry.parent && (entry.parent.type === "BinaryConcatExpression" || entry.parent.type === "BinaryAddExpression");
});
node.value = sortClasses(node.value, {
env,
ignoreFirst: (concat === null || concat === void 0 ? void 0 : concat.key) === "right" && !/^[^\S\r\n]/.test(node.value),
ignoreLast: (concat === null || concat === void 0 ? void 0 : concat.key) === "left" && !/[^\S\r\n]$/.test(node.value),
collapseWhitespace: {
start: (concat === null || concat === void 0 ? void 0 : concat.key) !== "right",
end: (concat === null || concat === void 0 ? void 0 : concat.key) !== "left"
}
});
}
});
}
function transformPug(ast, env) {
let { matcher } = env;
for (const token of ast.tokens) if (token.type === "attribute" && matcher.hasStaticAttr(token.name)) token.val = [
token.val.slice(0, 1),
sortClasses(token.val.slice(1, -1), { env }),
token.val.slice(-1)
].join("");
let startIdx = -1;
let endIdx = -1;
let ranges = [];
for (let i = 0; i < ast.tokens.length; i++) if (ast.tokens[i].type === "class") {
startIdx = startIdx === -1 ? i : startIdx;
endIdx = i;
} else if (startIdx !== -1) {
ranges.push([startIdx, endIdx]);
startIdx = -1;
endIdx = -1;
}
if (startIdx !== -1) {
ranges.push([startIdx, endIdx]);
startIdx = -1;
endIdx = -1;
}
for (const [startIdx, endIdx] of ranges) {
const { classList } = sortClassList({
classList: ast.tokens.slice(startIdx, endIdx + 1).map((token) => token.val),
api: env.context,
removeDuplicates: false
});
for (let i = startIdx; i <= endIdx; i++) ast.tokens[i].val = classList[i - startIdx];
}
}
function transformSvelte(ast, env) {
let { matcher, changes } = env;
for (let attr of ast.attributes ?? []) {
if (!matcher.hasStaticAttr(attr.name) || attr.type !== "Attribute") continue;
let values = getSvelteAttributeValues(attr);
for (let i = 0; i < values.length; i++) {
let value = values[i];
if (value.type === "Text") {
let same = value.raw === value.data;
value.raw = sortClasses(value.raw, {
env,
ignoreFirst: i > 0 && !/^\s/.test(value.raw),
ignoreLast: i < values.length - 1 && !/\s$/.test(value.raw),
removeDuplicates: true,
collapseWhitespace: false
});
value.data = same ? value.raw : sortClasses(value.data, {
env,
ignoreFirst: i > 0 && !/^\s/.test(value.data),
ignoreLast: i < values.length - 1 && !/\s$/.test(value.data),
removeDuplicates: true,
collapseWhitespace: false
});
} else if (value.type === "MustacheTag" || value.type === "ExpressionTag") visit(value.expression, {
Literal(node) {
if (isStringLiteral(node)) {
let before = node.raw;
if (sortStringLiteral(node, {
env,
removeDuplicates: false,
collapseWhitespace: false
})) changes.push({
before,
after: node.raw,
start: node.loc.start,
end: node.loc.end
});
}
},
TemplateLiteral(node) {
let before = node.quasis.map((quasi) => quasi.value.raw);
if (sortTemplateLiteral(node, {
env,
removeDuplicates: false,
collapseWhitespace: false
})) for (let [idx, quasi] of node.quasis.entries()) changes.push({
before: before[idx],
after: quasi.value.raw,
start: quasi.loc.start,
end: quasi.loc.end
});
}
});
}
}
for (let child of getSvelteChildNodes(ast)) transformSvelte(child, env);
}
function getSvelteAttributeValues(attr) {
if (Array.isArray(attr.value)) return attr.value;
if (attr.value && typeof attr.value === "object") return [attr.value];
return [];
}
function getSvelteChildNodes(node) {
let children = [];
for (let key of [
"children",
"nodes",
"fragment",
"html",
"else",
"consequent",
"alternate",
"body",
"fallback",
"pending",
"then",
"catch"
]) children.push(...getSvelteNodes(node[key]));
return children;
}
function getSvelteNodes(value) {
if (Array.isArray(value)) return value.filter((node) => node === null || node === void 0 ? void 0 : node.type);
if (Array.isArray(value === null || value === void 0 ? void 0 : value.nodes)) return value.nodes;
if (Array.isArray(value === null || value === void 0 ? void 0 : value.children)) return value.children;
if (value === null || value === void 0 ? void 0 : value.type) return [value];
return [];
}
const { parsers, printers } = createPlugin([
defineTransform({
staticAttrs: ["class"],
load: [{
name: "prettier/plugins/html",
importer: () => import("./html--849eFzc.js")
}],
compatible: ["prettier-plugin-organize-attributes"],
parsers: {
html: {},
lwc: {},
angular: { dynamicAttrs: ["[ngClass]"] },
vue: { dynamicAttrs: [":class", "v-bind:class"] }
},
transform: transformHtml
}),
defineTransform({
staticAttrs: ["class"],
load: [{
name: "prettier/plugins/glimmer",
importer: () => import("./glimmer-B5hfTXAX.js")
}],
parsers: { glimmer: {} },
transform: transformGlimmer
}),
defineTransform({
load: [postcss_exports],
compatible: ["prettier-plugin-css-order"],
parsers: {
css: {},
scss: {},
less: {}
},
transform: transformCss
}),
defineTransform({
staticAttrs: ["class", "className"],
compatible: [
"prettier-plugin-multiline-arrays",
"@ianvs/prettier-plugin-sort-imports",
"@trivago/prettier-plugin-sort-imports",
"prettier-plugin-organize-imports",
"prettier-plugin-sort-imports",
"prettier-plugin-jsdoc"
],
parsers: {
babel: { load: [babel_exports] },
"babel-flow": { load: [babel_exports] },
"babel-ts": { load: [babel_exports] },
__js_expression: { load: [babel_exports] },
typescript: { load: [{
name: "prettier/plugins/typescript",
importer: () => import("./typescript-Cvdwz3-D.js")
}] },
meriyah: { load: [{
name: "prettier/plugins/meriyah",
importer: () => import("./meriyah-B5wbO5kj.js")
}] },
acorn: { load: [{
name: "prettier/plugins/acorn",
importer: () => import("./acorn-Dxp-n4ed.js")
}] },
flow: { load: [{
name: "prettier/plugins/flow",
importer: () => import("./flow-BH5imzwC.js")
}] },
oxc: { load: [{
name: "@prettier/plugin-oxc",
importer: () => import("@prettier/plugin-oxc")
}] },
"oxc-ts": { load: [{
name: "@prettier/plugin-oxc",
importer: () => import("@prettier/plugin-oxc")
}] },
hermes: { load: [{
name: "@prettier/plugin-hermes",
importer: () => import("@prettier/plugin-hermes")
}] },
astroExpressionParser: {
load: [{
name: "prettier-plugin-astro",
importer: () => {
return import("prettier-plugin-astro");
}
}],
staticAttrs: ["class"],
dynamicAttrs: ["class:list"]
}
},
transform: transformJavaScript
}),
defineTransform({
staticAttrs: ["class"],
load: [{
name: "prettier-plugin-svelte",
importer: () => import("./plugin-B4312L3R.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1))
}],
parsers: { svelte: {} },
printers: { "svelte-ast": {} },
transform: transformSvelte,
reprint(path, { options, changes }) {
if (options.__mutatedOriginalText) return;
options.__mutatedOriginalText = true;
if (!(changes === null || changes === void 0 ? void 0 : changes.length)) return;
let finder = (0, import_line_column.default)(options.originalText);
let stringChanges = changes.map((change) => ({
...change,
start: finder.toIndex(change.start.line, change.start.column + 1),
end: finder.toIndex(change.end.line, change.end.column + 1)
}));
options.originalText = spliceChangesIntoString(options.originalText, stringChanges);
}
}),
defineTransform({
staticAttrs: ["class", "className"],
dynamicAttrs: ["class:list", "className"],
load: [{
name: "prettier-plugin-astro",
importer: () => {
return import("prettier-plugin-astro");
}
}],
parsers: { astro: {} },
transform: transformAstro
}),
defineTransform({
staticAttrs: ["class"],
load: [{
name: "prettier-plugin-marko",
importer: () => import("prettier-plugin-marko")
}],
parsers: { marko: {} },
transform: transformMarko
}),
defineTransform({
staticAttrs: ["class"],
load: [{
name: "@zackad/prettier-plugin-twig",
importer: () => {
return import("@zackad/prettier-plugin-twig");
}
}],
parsers: { twig: {} },
transform: transformTwig
}),
defineTransform({
staticAttrs: ["class"],
load: [{
name: "@prettier/plugin-pug",
importer: () => import("@prettier/plugin-pug")
}],
parsers: { pug: {} },
transform: transformPug
}),
defineTransform({
staticAttrs: ["class"],
load: [{
name: "@shopify/prettier-plugin-liquid",
importer: () => import("@shopify/prettier-plugin-liquid")
}],
parsers: { "liquid-html": {} },
transform: transformLiquid
})
]);
//#endregion
export { options, parsers, printers };

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

import { r as getTailwindConfig, t as createSorter } from "./sorter-BZkvDMjt-DLXDdrqx.js";
export { createSorter, getTailwindConfig };

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

+1
-1

@@ -1,2 +0,2 @@

import { i as sortTailwindClasses, n as formatEmbeddedDoc, r as formatFile, t as formatEmbeddedCode } from "./apis-D299uPBa.js";
import { i as sortTailwindClasses, n as formatEmbeddedDoc, r as formatFile, t as formatEmbeddedCode } from "./apis-Bk5AVt85.js";
export { formatEmbeddedCode, formatEmbeddedDoc, formatFile, sortTailwindClasses };
import { n as toNullable, t as toFormatFileResult } from "./napi-callbacks-Sb-usWTs.js";
import { n as runCli } from "./bindings-CjOHPMBU.js";
import { n as runCli } from "./bindings-DGt9AQLs.js";
import Tinypool from "tinypool";

@@ -4,0 +4,0 @@ import { fileURLToPath, pathToFileURL } from "node:url";

@@ -1,2 +0,2 @@

import { i as sortTailwindClasses, n as formatEmbeddedDoc, r as formatFile, t as formatEmbeddedCode } from "./apis-D299uPBa.js";
import { i as sortTailwindClasses, n as formatEmbeddedDoc, r as formatFile, t as formatEmbeddedCode } from "./apis-Bk5AVt85.js";
import { n as toNullable, t as toFormatFileResult } from "./napi-callbacks-Sb-usWTs.js";

@@ -17,3 +17,3 @@ //#region src-js/index.ts

if (typeof sourceText !== "string") throw new TypeError("`sourceText` must be a string");
BINDINGS_CACHE ??= await import("./bindings-CjOHPMBU.js").then((n) => n.t);
BINDINGS_CACHE ??= await import("./bindings-DGt9AQLs.js").then((n) => n.t);
return BINDINGS_CACHE.format(fileName, sourceText, options ?? {}, (options, code) => toFormatFileResult(formatFile({

@@ -37,3 +37,3 @@ options,

async function jsTextToDoc(sourceExt, sourceText, oxfmtPluginOptionsJson, parentContext) {
BINDINGS_CACHE ??= await import("./bindings-CjOHPMBU.js").then((n) => n.t);
BINDINGS_CACHE ??= await import("./bindings-DGt9AQLs.js").then((n) => n.t);
return BINDINGS_CACHE.jsTextToDoc(sourceExt, sourceText, oxfmtPluginOptionsJson, parentContext, () => toFormatFileResult(Promise.reject("formatFile is unavailable for jsTextToDoc")), (options, code) => toNullable(formatEmbeddedCode({

@@ -40,0 +40,0 @@ options,

{
"name": "oxfmt",
"version": "0.59.0",
"version": "0.60.0",
"description": "Formatter for the JavaScript Oxidation Compiler",

@@ -89,22 +89,22 @@ "keywords": [

"optionalDependencies": {
"@oxfmt/binding-darwin-arm64": "0.59.0",
"@oxfmt/binding-android-arm64": "0.59.0",
"@oxfmt/binding-win32-arm64-msvc": "0.59.0",
"@oxfmt/binding-linux-arm64-gnu": "0.59.0",
"@oxfmt/binding-linux-arm64-musl": "0.59.0",
"@oxfmt/binding-openharmony-arm64": "0.59.0",
"@oxfmt/binding-android-arm-eabi": "0.59.0",
"@oxfmt/binding-linux-arm-gnueabihf": "0.59.0",
"@oxfmt/binding-linux-arm-musleabihf": "0.59.0",
"@oxfmt/binding-win32-ia32-msvc": "0.59.0",
"@oxfmt/binding-linux-ppc64-gnu": "0.59.0",
"@oxfmt/binding-linux-riscv64-gnu": "0.59.0",
"@oxfmt/binding-linux-riscv64-musl": "0.59.0",
"@oxfmt/binding-linux-s390x-gnu": "0.59.0",
"@oxfmt/binding-darwin-x64": "0.59.0",
"@oxfmt/binding-win32-x64-msvc": "0.59.0",
"@oxfmt/binding-freebsd-x64": "0.59.0",
"@oxfmt/binding-linux-x64-gnu": "0.59.0",
"@oxfmt/binding-linux-x64-musl": "0.59.0"
"@oxfmt/binding-darwin-arm64": "0.60.0",
"@oxfmt/binding-android-arm64": "0.60.0",
"@oxfmt/binding-win32-arm64-msvc": "0.60.0",
"@oxfmt/binding-linux-arm64-gnu": "0.60.0",
"@oxfmt/binding-linux-arm64-musl": "0.60.0",
"@oxfmt/binding-openharmony-arm64": "0.60.0",
"@oxfmt/binding-android-arm-eabi": "0.60.0",
"@oxfmt/binding-linux-arm-gnueabihf": "0.60.0",
"@oxfmt/binding-linux-arm-musleabihf": "0.60.0",
"@oxfmt/binding-win32-ia32-msvc": "0.60.0",
"@oxfmt/binding-linux-ppc64-gnu": "0.60.0",
"@oxfmt/binding-linux-riscv64-gnu": "0.60.0",
"@oxfmt/binding-linux-riscv64-musl": "0.60.0",
"@oxfmt/binding-linux-s390x-gnu": "0.60.0",
"@oxfmt/binding-darwin-x64": "0.60.0",
"@oxfmt/binding-win32-x64-msvc": "0.60.0",
"@oxfmt/binding-freebsd-x64": "0.60.0",
"@oxfmt/binding-linux-x64-gnu": "0.60.0",
"@oxfmt/binding-linux-x64-musl": "0.60.0"
}
}

@@ -21,3 +21,2 @@ <p align="center">

[![Code Coverage][code-coverage-badge]][code-coverage-url]
[![Sponsors][sponsors-badge]][sponsors-url]

@@ -39,4 +38,2 @@ [![Discord chat][discord-badge]][discord-url]

[code-coverage-url]: https://codecov.io/gh/oxc-project/oxc
[sponsors-badge]: https://img.shields.io/github/sponsors/Boshen
[sponsors-url]: https://github.com/sponsors/Boshen
[playground-badge]: https://img.shields.io/badge/Playground-blue?color=9BE4E0

@@ -43,0 +40,0 @@ [playground-url]: https://playground.oxc.rs/

import { o as __toESM } from "./rolldown-runtime-CE-6LUnI.js";
//#region src-js/libs/apis.ts
const CACHES = {
prettier: null,
sveltePlugin: null,
tailwindPlugin: null,
tailwindSorter: null,
oxfmtPlugin: null
};
async function loadCached(key, loader) {
CACHES[key] ??= await loader();
return CACHES[key];
}
async function loadPrettier() {
return loadCached("prettier", async () => {
const prettier = await import("./prettier-CEZwFZsY.js");
const { formatOptionsHiddenDefaults } = prettier.__internal;
formatOptionsHiddenDefaults.parentParser = null;
formatOptionsHiddenDefaults.__onHtmlRoot = null;
formatOptionsHiddenDefaults.__inJsTemplate = null;
return prettier;
});
}
/**
* Format non-js file
*
* @returns Formatted code
*/
async function formatFile({ code, options }) {
const prettier = CACHES.prettier ?? await loadPrettier();
if ("_useSveltePlugin" in options) await setupSveltePlugin(options);
if ("_useTailwindPlugin" in options) await setupTailwindPlugin(options);
if ("_oxfmtPluginOptionsJson" in options) await setupOxfmtPlugin(options);
return prettier.format(code, options);
}
/**
* Format non-js code snippets into formatted string.
* Mainly used for formatting code fences within JSDoc,
* and is also used as a temporary fallback for html-in-js.
*
* @returns Formatted code snippet
*/
async function formatEmbeddedCode({ code, options }) {
const prettier = CACHES.prettier ?? await loadPrettier();
if ("_useTailwindPlugin" in options) await setupTailwindPlugin(options);
return prettier.format(code, options);
}
/**
* Format non-js code snippets into Prettier `Doc` JSON strings.
*
* This makes our printer correctly handle `printWidth` even for embedded code.
* - For gql-in-js, `texts` contains multiple parts split by `${}` in a template literal
* - For others, `texts` always contains a single string with `${}` parts replaced by placeholders
* However, this function does not need to be aware of that,
* as it simply formats each text part independently and returns an array of formatted parts.
*
* @returns Doc JSON strings
*/
async function formatEmbeddedDoc({ texts, options }) {
const prettier = CACHES.prettier ?? await loadPrettier();
if ("_useTailwindPlugin" in options) await setupTailwindPlugin(options);
return Promise.all(texts.map(async (text) => {
const metadata = {};
if (options.parser === "html" || options.parser === "angular") {
options.parentParser = "OXFMT";
options.__onHtmlRoot = (root) => metadata.htmlHasMultipleRootElements = (root.children?.length ?? 0) > 1;
}
if (options.parser === "markdown") options.__inJsTemplate = true;
const doc = await prettier.__debug.printToDoc(text, options);
const symbolToNumber = /* @__PURE__ */ new Map();
let nextId = 1;
return JSON.stringify([doc, metadata], (_key, value) => {
if (typeof value === "symbol") {
if (!symbolToNumber.has(value)) symbolToNumber.set(value, nextId++);
return symbolToNumber.get(value);
}
if (value === -Infinity) return "__NEGATIVE_INFINITY__";
return value;
});
}));
}
/**
* Load Tailwind CSS plugin.
* Option mapping (sortTailwindcss.xxx → tailwindXxx) is also done in Rust side.
*/
async function setupTailwindPlugin(options) {
CACHES.tailwindPlugin ??= await loadCached("tailwindPlugin", () => import("./dist-Byfj_1s9.js"));
options.plugins ??= [];
options.plugins.push(CACHES.tailwindPlugin);
}
/**
* Process Tailwind CSS classes found in JS/TS files in batch.
* @param args - Object containing classes and options (filepath is in options.filepath)
* @returns Array of sorted class strings (same order/length as input)
*/
async function sortTailwindClasses({ classes, options }) {
CACHES.tailwindSorter ??= await loadCached("tailwindSorter", () => import("./sorter-Cm0Z2eGI.js"));
const { createSorter } = CACHES.tailwindSorter;
return (await createSorter({
filepath: options.filepath,
stylesheetPath: options.tailwindStylesheet,
configPath: options.tailwindConfig,
preserveWhitespace: options.tailwindPreserveWhitespace,
preserveDuplicates: options.tailwindPreserveDuplicates
})).sortClassAttributes(classes);
}
/**
* Load prettier-plugin-svelte to provide the `svelte` parser.
*/
async function setupSveltePlugin(options) {
CACHES.sveltePlugin ??= await loadCached("sveltePlugin", async () => await import("./plugin-D1B0s0iv.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1)));
options.plugins ??= [];
options.plugins.push(CACHES.sveltePlugin);
}
/**
* Load oxfmt plugin for js-in-xxx parsers.
*/
async function setupOxfmtPlugin(options) {
CACHES.oxfmtPlugin ??= await loadCached("oxfmtPlugin", async () => await import("./prettier-plugin-oxfmt-Dj6FaAil.js"));
options.plugins ??= [];
options.plugins.push(CACHES.oxfmtPlugin);
}
//#endregion
export { sortTailwindClasses as i, formatEmbeddedDoc as n, formatFile as r, formatEmbeddedCode as t };
import { r as __exportAll } from "./rolldown-runtime-CE-6LUnI.js";
import { createRequire } from "module";
//#region src-js/bindings.js
var bindings_exports = /* @__PURE__ */ __exportAll({
Severity: () => Severity,
format: () => format,
jsTextToDoc: () => jsTextToDoc,
runCli: () => runCli
});
const require = createRequire(import.meta.url);
new URL(".", import.meta.url).pathname;
const { readFileSync } = require("fs");
let nativeBinding = null;
const loadErrors = [];
const isMusl = () => {
let musl = false;
if (process.platform === "linux") {
musl = isMuslFromFilesystem();
if (musl === null) musl = isMuslFromReport();
if (musl === null) musl = isMuslFromChildProcess();
}
return musl;
};
const isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
const isMuslFromFilesystem = () => {
try {
return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
} catch {
return null;
}
};
const isMuslFromReport = () => {
let report = null;
if (process.report && typeof process.report.getReport === "function") {
process.report.excludeNetwork = true;
report = process.report.getReport();
}
if (!report) return null;
if (report.header && report.header.glibcVersionRuntime) return false;
if (Array.isArray(report.sharedObjects)) {
if (report.sharedObjects.some(isFileMusl)) return true;
}
return false;
};
const isMuslFromChildProcess = () => {
try {
return require("child_process").execSync("ldd --version", { encoding: "utf8" }).includes("musl");
} catch (e) {
return false;
}
};
function requireNative() {
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) try {
return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
} catch (err) {
loadErrors.push(err);
}
else if (process.platform === "android") if (process.arch === "arm64") {
try {
return require("./oxfmt.android-arm64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-android-arm64");
const bindingPackageVersion = require("@oxfmt/binding-android-arm64/package.json").version;
if (bindingPackageVersion !== "0.59.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.59.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "arm") {
try {
return require("./oxfmt.android-arm-eabi.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-android-arm-eabi");
const bindingPackageVersion = require("@oxfmt/binding-android-arm-eabi/package.json").version;
if (bindingPackageVersion !== "0.59.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.59.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Android ${process.arch}`));
else if (process.platform === "win32") if (process.arch === "x64") if (process.config && process.config.variables && process.config.variables.shlib_suffix === "dll.a" || process.config && process.config.variables && process.config.variables.node_target_type === "shared_library") {
try {
return require("./oxfmt.win32-x64-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-win32-x64-gnu");
const bindingPackageVersion = require("@oxfmt/binding-win32-x64-gnu/package.json").version;
if (bindingPackageVersion !== "0.59.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.59.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else {
try {
return require("./oxfmt.win32-x64-msvc.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-win32-x64-msvc");
const bindingPackageVersion = require("@oxfmt/binding-win32-x64-msvc/package.json").version;
if (bindingPackageVersion !== "0.59.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.59.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
}
else if (process.arch === "ia32") {
try {
return require("./oxfmt.win32-ia32-msvc.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-win32-ia32-msvc");
const bindingPackageVersion = require("@oxfmt/binding-win32-ia32-msvc/package.json").version;
if (bindingPackageVersion !== "0.59.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.59.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "arm64") {
try {
return require("./oxfmt.win32-arm64-msvc.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-win32-arm64-msvc");
const bindingPackageVersion = require("@oxfmt/binding-win32-arm64-msvc/package.json").version;
if (bindingPackageVersion !== "0.59.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.59.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Windows: ${process.arch}`));
else if (process.platform === "darwin") {
try {
return require("./oxfmt.darwin-universal.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-darwin-universal");
const bindingPackageVersion = require("@oxfmt/binding-darwin-universal/package.json").version;
if (bindingPackageVersion !== "0.59.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.59.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
if (process.arch === "x64") {
try {
return require("./oxfmt.darwin-x64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-darwin-x64");
const bindingPackageVersion = require("@oxfmt/binding-darwin-x64/package.json").version;
if (bindingPackageVersion !== "0.59.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.59.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "arm64") {
try {
return require("./oxfmt.darwin-arm64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-darwin-arm64");
const bindingPackageVersion = require("@oxfmt/binding-darwin-arm64/package.json").version;
if (bindingPackageVersion !== "0.59.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.59.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on macOS: ${process.arch}`));
} else if (process.platform === "freebsd") if (process.arch === "x64") {
try {
return require("./oxfmt.freebsd-x64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-freebsd-x64");
const bindingPackageVersion = require("@oxfmt/binding-freebsd-x64/package.json").version;
if (bindingPackageVersion !== "0.59.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.59.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "arm64") {
try {
return require("./oxfmt.freebsd-arm64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-freebsd-arm64");
const bindingPackageVersion = require("@oxfmt/binding-freebsd-arm64/package.json").version;
if (bindingPackageVersion !== "0.59.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.59.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on FreeBSD: ${process.arch}`));
else if (process.platform === "linux") if (process.arch === "x64") if (isMusl()) {
try {
return require("./oxfmt.linux-x64-musl.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-linux-x64-musl");
const bindingPackageVersion = require("@oxfmt/binding-linux-x64-musl/package.json").version;
if (bindingPackageVersion !== "0.59.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.59.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else {
try {
return require("./oxfmt.linux-x64-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-linux-x64-gnu");
const bindingPackageVersion = require("@oxfmt/binding-linux-x64-gnu/package.json").version;
if (bindingPackageVersion !== "0.59.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.59.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
}
else if (process.arch === "arm64") if (isMusl()) {
try {
return require("./oxfmt.linux-arm64-musl.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-linux-arm64-musl");
const bindingPackageVersion = require("@oxfmt/binding-linux-arm64-musl/package.json").version;
if (bindingPackageVersion !== "0.59.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.59.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else {
try {
return require("./oxfmt.linux-arm64-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-linux-arm64-gnu");
const bindingPackageVersion = require("@oxfmt/binding-linux-arm64-gnu/package.json").version;
if (bindingPackageVersion !== "0.59.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.59.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
}
else if (process.arch === "arm") if (isMusl()) {
try {
return require("./oxfmt.linux-arm-musleabihf.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-linux-arm-musleabihf");
const bindingPackageVersion = require("@oxfmt/binding-linux-arm-musleabihf/package.json").version;
if (bindingPackageVersion !== "0.59.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.59.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else {
try {
return require("./oxfmt.linux-arm-gnueabihf.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-linux-arm-gnueabihf");
const bindingPackageVersion = require("@oxfmt/binding-linux-arm-gnueabihf/package.json").version;
if (bindingPackageVersion !== "0.59.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.59.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
}
else if (process.arch === "loong64") if (isMusl()) {
try {
return require("./oxfmt.linux-loong64-musl.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-linux-loong64-musl");
const bindingPackageVersion = require("@oxfmt/binding-linux-loong64-musl/package.json").version;
if (bindingPackageVersion !== "0.59.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.59.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else {
try {
return require("./oxfmt.linux-loong64-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-linux-loong64-gnu");
const bindingPackageVersion = require("@oxfmt/binding-linux-loong64-gnu/package.json").version;
if (bindingPackageVersion !== "0.59.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.59.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
}
else if (process.arch === "riscv64") if (isMusl()) {
try {
return require("./oxfmt.linux-riscv64-musl.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-linux-riscv64-musl");
const bindingPackageVersion = require("@oxfmt/binding-linux-riscv64-musl/package.json").version;
if (bindingPackageVersion !== "0.59.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.59.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else {
try {
return require("./oxfmt.linux-riscv64-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-linux-riscv64-gnu");
const bindingPackageVersion = require("@oxfmt/binding-linux-riscv64-gnu/package.json").version;
if (bindingPackageVersion !== "0.59.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.59.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
}
else if (process.arch === "ppc64") {
try {
return require("./oxfmt.linux-ppc64-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-linux-ppc64-gnu");
const bindingPackageVersion = require("@oxfmt/binding-linux-ppc64-gnu/package.json").version;
if (bindingPackageVersion !== "0.59.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.59.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "s390x") {
try {
return require("./oxfmt.linux-s390x-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-linux-s390x-gnu");
const bindingPackageVersion = require("@oxfmt/binding-linux-s390x-gnu/package.json").version;
if (bindingPackageVersion !== "0.59.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.59.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Linux: ${process.arch}`));
else if (process.platform === "openharmony") if (process.arch === "arm64") {
try {
return require("./oxfmt.openharmony-arm64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-openharmony-arm64");
const bindingPackageVersion = require("@oxfmt/binding-openharmony-arm64/package.json").version;
if (bindingPackageVersion !== "0.59.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.59.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "x64") {
try {
return require("./oxfmt.openharmony-x64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-openharmony-x64");
const bindingPackageVersion = require("@oxfmt/binding-openharmony-x64/package.json").version;
if (bindingPackageVersion !== "0.59.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.59.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "arm") {
try {
return require("./oxfmt.openharmony-arm.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = require("@oxfmt/binding-openharmony-arm");
const bindingPackageVersion = require("@oxfmt/binding-openharmony-arm/package.json").version;
if (bindingPackageVersion !== "0.59.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.59.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`));
else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`));
}
nativeBinding = requireNative();
const forceWasi = process.env.NAPI_RS_FORCE_WASI === "true" || process.env.NAPI_RS_FORCE_WASI === "error";
if (!nativeBinding || forceWasi) {
let wasiBinding = null;
let wasiBindingError = null;
try {
wasiBinding = require("./oxfmt.wasi.cjs");
nativeBinding = wasiBinding;
} catch (err) {
if (forceWasi) wasiBindingError = err;
}
if (!nativeBinding || forceWasi) try {
wasiBinding = require("@oxfmt/binding-wasm32-wasi");
nativeBinding = wasiBinding;
} catch (err) {
if (forceWasi) {
if (!wasiBindingError) wasiBindingError = err;
else wasiBindingError.cause = err;
loadErrors.push(err);
}
}
if (process.env.NAPI_RS_FORCE_WASI === "error" && !wasiBinding) {
const error = /* @__PURE__ */ new Error("WASI binding not found and NAPI_RS_FORCE_WASI is set to error");
error.cause = wasiBindingError;
throw error;
}
}
if (!nativeBinding) {
if (loadErrors.length > 0) {
const error = /* @__PURE__ */ new Error("Cannot find native binding. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.");
error.cause = loadErrors.reduce((err, cur) => {
cur.cause = err;
return cur;
});
throw error;
}
throw new Error(`Failed to load native binding`);
}
const { Severity, format, jsTextToDoc, runCli } = nativeBinding;
//#endregion
export { runCli as n, bindings_exports as t };
import { createRequire } from "node:module";
//#region ../../node_modules/.pnpm/prettier-plugin-tailwindcss@0.0.0-insiders.2b6f3c2_prettier-plugin-svelte@4.1.1_prettie_98ae334cd105e01916eac934f27a76de/node_modules/prettier-plugin-tailwindcss/dist/chunk-DSjvVL_1.mjs
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
var __exportAll = (all, symbols) => {
let target = {};
for (var name in all) __defProp(target, name, {
get: all[name],
enumerable: true
});
if (symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
return target;
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
key = keys[i];
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: ((k) => from[k]).bind(null, key),
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
value: mod,
enumerable: true
}) : target, mod));
var __require = /* @__PURE__ */ createRequire(import.meta.url);
//#endregion
export { __toESM as a, __require as i, __esmMin as n, __exportAll as r, __commonJSMin as t };
import { o as __toESM } from "./rolldown-runtime-CE-6LUnI.js";
import { n as init_babel, parsers as Aa, t as babel_exports } from "./babel-7tfAjQas.js";
import index_exports, { t as init_prettier } from "./prettier-CEZwFZsY.js";
import { a as __toESM$1, t as __commonJSMin } from "./chunk-DSjvVL_1-Do0Iorfu.js";
import { a as sortClasses, c as cacheForDirs, d as expiringMap, f as loadIfExists, i as sortClassList, l as spliceChangesIntoString, n as error, o as warn, p as maybeResolve, r as getTailwindConfig$1, u as visit } from "./sorter-BZkvDMjt-DFTeIPU-.js";
import { parsers as Cn, t as init_angular } from "./angular-Clx-wbm6.js";
import { n as postcss_exports, parsers as cn, t as init_postcss } from "./postcss-DuOoF7OX.js";
import * as path from "node:path";
import { isAbsolute } from "path";
//#region ../../node_modules/.pnpm/prettier-plugin-tailwindcss@0.0.0-insiders.2b6f3c2_prettier-plugin-svelte@4.1.1_prettie_98ae334cd105e01916eac934f27a76de/node_modules/prettier-plugin-tailwindcss/dist/index.mjs
init_angular();
init_babel();
init_postcss();
init_prettier();
var require_isarray = /* @__PURE__ */ __commonJSMin(((exports, module) => {
var toString = {}.toString;
module.exports = Array.isArray || function(arr) {
return toString.call(arr) == "[object Array]";
};
}));
/*!
* isobject <https://github.com/jonschlinkert/isobject>
*
* Copyright (c) 2014-2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
var require_isobject = /* @__PURE__ */ __commonJSMin(((exports, module) => {
var isArray = require_isarray();
module.exports = function isObject(val) {
return val != null && typeof val === "object" && isArray(val) === false;
};
}));
var import_line_column = /* @__PURE__ */ __toESM$1((/* @__PURE__ */ __commonJSMin(((exports, module) => {
var isArray = require_isarray();
var isObject = require_isobject();
Array.prototype.slice;
module.exports = LineColumnFinder;
function LineColumnFinder(str, options) {
if (!(this instanceof LineColumnFinder)) {
if (typeof options === "number") return new LineColumnFinder(str).fromIndex(options);
return new LineColumnFinder(str, options);
}
this.str = str || "";
this.lineToIndex = buildLineToIndex(this.str);
options = options || {};
this.origin = typeof options.origin === "undefined" ? 1 : options.origin;
}
LineColumnFinder.prototype.fromIndex = function(index) {
if (index < 0 || index >= this.str.length || isNaN(index)) return null;
var line = findLowerIndexInRangeArray(index, this.lineToIndex);
return {
line: line + this.origin,
col: index - this.lineToIndex[line] + this.origin
};
};
LineColumnFinder.prototype.toIndex = function(line, column) {
if (typeof column === "undefined") {
if (isArray(line) && line.length >= 2) return this.toIndex(line[0], line[1]);
if (isObject(line) && "line" in line && ("col" in line || "column" in line)) return this.toIndex(line.line, "col" in line ? line.col : line.column);
return -1;
}
if (isNaN(line) || isNaN(column)) return -1;
line -= this.origin;
column -= this.origin;
if (line >= 0 && column >= 0 && line < this.lineToIndex.length) {
var lineIndex = this.lineToIndex[line];
var nextIndex = line === this.lineToIndex.length - 1 ? this.str.length : this.lineToIndex[line + 1];
if (column < nextIndex - lineIndex) return lineIndex + column;
}
return -1;
};
function buildLineToIndex(str) {
var lines = str.split("\n"), lineToIndex = new Array(lines.length), index = 0;
for (var i = 0, l = lines.length; i < l; i++) {
lineToIndex[i] = index;
index += lines[i].length + 1;
}
return lineToIndex;
}
function findLowerIndexInRangeArray(value, arr) {
if (value >= arr[arr.length - 1]) return arr.length - 1;
var min = 0, max = arr.length - 2, mid;
while (min < max) {
mid = min + (max - min >> 1);
if (value < arr[mid]) max = mid - 1;
else if (value >= arr[mid + 1]) min = mid + 1;
else {
min = mid;
break;
}
}
return min;
}
})))(), 1);
let prettierConfigCache = expiringMap(1e4);
async function resolvePrettierConfigDir(filePath, inputDir) {
let cached = prettierConfigCache.get(inputDir);
if (cached !== void 0) return cached ?? process.cwd();
const resolve = async () => {
try {
return await index_exports.resolveConfigFile(filePath);
} catch (err) {
error("prettier-config-not-found", "Failed to resolve Prettier Config");
error("prettier-config-not-found-err", err);
return null;
}
};
let prettierConfig = await resolve();
if (prettierConfig) {
let configDir = path.dirname(prettierConfig);
cacheForDirs(prettierConfigCache, inputDir, configDir, configDir);
return configDir;
} else {
prettierConfigCache.set(inputDir, null);
return process.cwd();
}
}
async function getTailwindConfig(options) {
let cwd = process.cwd();
let inputDir = options.filepath ? path.dirname(options.filepath) : cwd;
let needsPrettierConfig = options.tailwindConfig && !path.isAbsolute(options.tailwindConfig) || options.tailwindStylesheet && !path.isAbsolute(options.tailwindStylesheet) || options.tailwindEntryPoint && !path.isAbsolute(options.tailwindEntryPoint);
let configDir;
if (needsPrettierConfig) configDir = await resolvePrettierConfigDir(options.filepath, inputDir);
else configDir = cwd;
let configPath = options.tailwindConfig && !options.tailwindConfig.endsWith(".css") ? options.tailwindConfig : void 0;
let stylesheetPath = options.tailwindStylesheet;
if (!stylesheetPath && options.tailwindEntryPoint) {
warn("entrypoint-is-deprecated", configDir, "Deprecated: Use the `tailwindStylesheet` option for v4 projects instead of `tailwindEntryPoint`.");
stylesheetPath = options.tailwindEntryPoint;
}
if (!stylesheetPath && options.tailwindConfig && options.tailwindConfig.endsWith(".css")) {
warn("config-as-css-is-deprecated", configDir, "Deprecated: Use the `tailwindStylesheet` option for v4 projects instead of `tailwindConfig`.");
stylesheetPath = options.tailwindConfig;
}
return getTailwindConfig$1({
base: configDir,
filepath: options.filepath,
configPath,
stylesheetPath,
packageName: options.tailwindPackageName
});
}
const options = {
tailwindConfig: {
type: "string",
category: "Tailwind CSS",
description: "Path to Tailwind configuration file"
},
tailwindEntryPoint: {
type: "string",
category: "Tailwind CSS",
description: "Path to the CSS entrypoint in your Tailwind project (v4+)"
},
tailwindStylesheet: {
type: "string",
category: "Tailwind CSS",
description: "Path to the CSS stylesheet in your Tailwind project (v4+)"
},
tailwindAttributes: {
type: "string",
array: true,
default: [{ value: [] }],
category: "Tailwind CSS",
description: "List of attributes/props that contain sortable Tailwind classes"
},
tailwindFunctions: {
type: "string",
array: true,
default: [{ value: [] }],
category: "Tailwind CSS",
description: "List of functions and tagged templates that contain sortable Tailwind classes"
},
tailwindPreserveWhitespace: {
type: "boolean",
default: false,
category: "Tailwind CSS",
description: "Preserve whitespace around Tailwind classes when sorting"
},
tailwindPreserveDuplicates: {
type: "boolean",
default: false,
category: "Tailwind CSS",
description: "Preserve duplicate classes inside a class list when sorting"
},
tailwindPackageName: {
type: "string",
default: "tailwindcss",
category: "Tailwind CSS",
description: "The package name to use when loading Tailwind CSS"
}
};
function createMatcher(options, parser, defaults) {
let staticAttrs = new Set(defaults.staticAttrs);
let dynamicAttrs = new Set(defaults.dynamicAttrs);
let functions = new Set(defaults.functions);
let staticAttrsRegex = [...defaults.staticAttrsRegex];
let functionsRegex = [...defaults.functionsRegex];
for (let attr of options.tailwindAttributes ?? []) {
let regex = parseRegex(attr);
if (regex) staticAttrsRegex.push(regex);
else if (parser === "vue" && attr.startsWith(":")) staticAttrs.add(attr.slice(1));
else if (parser === "vue" && attr.startsWith("v-bind:")) staticAttrs.add(attr.slice(7));
else if (parser === "vue" && attr.startsWith("v-")) dynamicAttrs.add(attr);
else if (parser === "angular" && attr.startsWith("[") && attr.endsWith("]")) staticAttrs.add(attr.slice(1, -1));
else staticAttrs.add(attr);
}
for (let attr of staticAttrs) if (parser === "vue") {
dynamicAttrs.add(`:${attr}`);
dynamicAttrs.add(`v-bind:${attr}`);
} else if (parser === "angular") dynamicAttrs.add(`[${attr}]`);
for (let fn of options.tailwindFunctions ?? []) {
let regex = parseRegex(fn);
if (regex) functionsRegex.push(regex);
else functions.add(fn);
}
return {
hasStaticAttr: (name) => {
if (nameFromDynamicAttr(name, parser)) return false;
return hasMatch(name, staticAttrs, staticAttrsRegex);
},
hasDynamicAttr: (name) => {
if (hasMatch(name, dynamicAttrs, [])) return true;
let newName = nameFromDynamicAttr(name, parser);
if (!newName) return false;
return hasMatch(newName, staticAttrs, staticAttrsRegex);
},
hasFunction: (name) => hasMatch(name, functions, functionsRegex)
};
}
function nameFromDynamicAttr(name, parser) {
if (parser === "vue") {
if (name.startsWith(":")) return name.slice(1);
if (name.startsWith("v-bind:")) return name.slice(7);
if (name.startsWith("v-")) return name;
return null;
}
if (parser === "angular") {
if (name.startsWith("[") && name.endsWith("]")) return name.slice(1, -1);
return null;
}
return null;
}
function hasMatch(name, list, patterns) {
if (list.has(name)) return true;
for (let regex of patterns) if (regex.test(name)) return true;
return false;
}
function parseRegex(str) {
if (!str.startsWith("/")) return null;
let lastSlash = str.lastIndexOf("/");
if (lastSlash <= 0) return null;
try {
let pattern = str.slice(1, lastSlash);
let flags = str.slice(lastSlash + 1);
return new RegExp(pattern, flags);
} catch {
return null;
}
}
function createPlugin(transforms) {
let parsers = Object.create(null);
let printers = Object.create(null);
for (let opts of transforms) {
for (let [name, meta] of Object.entries(opts.parsers)) parsers[name] = async () => {
var _plugin$parsers;
let original = (_plugin$parsers = (await loadPlugins(meta.load ?? opts.load ?? [])).parsers) === null || _plugin$parsers === void 0 ? void 0 : _plugin$parsers[name];
if (!original) return;
parsers[name] = await createParser({
name,
original,
opts
});
return parsers[name];
};
for (let [name, _meta] of Object.entries(opts.printers ?? {})) printers[name] = async () => {
var _plugin$printers;
let original = (_plugin$printers = (await loadPlugins(opts.load ?? [])).printers) === null || _plugin$printers === void 0 ? void 0 : _plugin$printers[name];
if (!original) return;
printers[name] = createPrinter({
original,
opts
});
return printers[name];
};
}
return {
parsers,
printers
};
}
async function createParser({ name, original, opts }) {
let parser = { ...original };
async function load(options) {
let parser = { ...original };
for (const pluginName of opts.compatible || []) {
var _plugin$parsers2;
let plugin = await findEnabledPlugin(options, pluginName);
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]);
}
return parser;
}
parser.preprocess = async (code, options) => {
let parser = await load(options);
return parser.preprocess ? parser.preprocess(code, options) : code;
};
parser.parse = async (code, options) => {
let ast = await (await load(options)).parse(code, options, options);
let env = await loadTailwindCSS({
opts,
options
});
transformAst({
ast,
env,
opts,
options
});
options.__tailwindcss__ = env;
return ast;
};
return parser;
}
function createPrinter({ original, opts }) {
let printer = { ...original };
let reprint = opts.reprint;
if (reprint) {
printer.print = new Proxy(original.print, { apply(target, thisArg, args) {
let [path, options] = args;
let env = options.__tailwindcss__;
reprint(path, {
...env,
options
});
return Reflect.apply(target, thisArg, args);
} });
if (original.embed) printer.embed = new Proxy(original.embed, { apply(target, thisArg, args) {
let [path, options] = args;
let env = options.__tailwindcss__;
reprint(path, {
...env,
options
});
return Reflect.apply(target, thisArg, args);
} });
}
return printer;
}
async function loadPlugins(fns) {
let plugin = {
parsers: Object.create(null),
printers: Object.create(null),
options: Object.create(null),
defaultOptions: Object.create(null),
languages: []
};
for (let source of fns) {
let loaded = await loadPlugin(source);
Object.assign(plugin.parsers, loaded.parsers ?? {});
Object.assign(plugin.printers, loaded.printers ?? {});
Object.assign(plugin.options, loaded.options ?? {});
Object.assign(plugin.defaultOptions, loaded.defaultOptions ?? {});
plugin.languages = [...plugin.languages ?? [], ...loaded.languages ?? []];
}
return plugin;
}
const EMPTY_PLUGIN = {
parsers: {},
printers: {},
languages: [],
options: {},
defaultOptions: {}
};
async function loadPlugin(source) {
if ("importer" in source && typeof source.importer === "function") return normalizePlugin(await source.importer());
return source;
}
function normalizePlugin(source) {
if (source === null || typeof source !== "object") return EMPTY_PLUGIN;
let plugin = source.default;
return plugin && typeof plugin === "object" ? plugin : source;
}
function findEnabledPlugin(options, name) {
for (let plugin of options.plugins) {
if (plugin instanceof URL) {
if (plugin.protocol !== "file:") continue;
if (plugin.hostname !== "") continue;
plugin = plugin.pathname;
}
if (typeof plugin !== "string") {
if (!plugin.name) continue;
plugin = plugin.name;
}
if (plugin === name || isAbsolute(plugin) && plugin.includes(name) && maybeResolve(name) === plugin) return loadIfExists(name);
}
}
async function loadTailwindCSS({ options, opts }) {
var _parsers$parser, _parsers$parser2;
let parsers = opts.parsers;
let parser = options.parser;
return {
context: await getTailwindConfig(options),
matcher: createMatcher(options, parser, {
staticAttrs: new Set(((_parsers$parser = parsers[parser]) === null || _parsers$parser === void 0 ? void 0 : _parsers$parser.staticAttrs) ?? opts.staticAttrs ?? []),
dynamicAttrs: new Set(((_parsers$parser2 = parsers[parser]) === null || _parsers$parser2 === void 0 ? void 0 : _parsers$parser2.dynamicAttrs) ?? opts.dynamicAttrs ?? []),
functions: /* @__PURE__ */ new Set(),
staticAttrsRegex: [],
dynamicAttrsRegex: [],
functionsRegex: []
}),
options,
changes: []
};
}
function transformAst({ ast, env, opts }) {
let transform = opts.transform;
if (transform) transform(ast, env);
}
function defineTransform(opts) {
return opts;
}
function tryParseAngularAttribute(value, env) {
try {
return Cn.__ng_directive.parse(value, env.options);
} catch (err) {
console.warn("prettier-plugin-tailwindcss: Unable to parse angular directive");
console.warn(err);
return null;
}
}
function transformDynamicAngularAttribute(attr, env) {
let directiveAst = tryParseAngularAttribute(attr.value, env);
if (!directiveAst) return;
let changes = [];
visit(directiveAst, {
StringLiteral(node, path) {
if (!node.value) return;
let collapseWhitespace = canCollapseWhitespaceIn(path, env);
changes.push({
start: node.start + 1,
end: node.end - 1,
before: node.value,
after: sortClasses(node.value, {
env,
collapseWhitespace
})
});
},
TemplateLiteral(node, path) {
if (!node.quasis.length) return;
let collapseWhitespace = canCollapseWhitespaceIn(path, env);
for (let i = 0; i < node.quasis.length; i++) {
let quasi = node.quasis[i];
changes.push({
start: quasi.start,
end: quasi.end,
before: quasi.value.raw,
after: sortClasses(quasi.value.raw, {
env,
ignoreFirst: i > 0 && !/^\s/.test(quasi.value.raw),
ignoreLast: i < node.expressions.length && !/\s$/.test(quasi.value.raw),
collapseWhitespace: collapseWhitespace ? {
start: collapseWhitespace.start && i === 0,
end: collapseWhitespace.end && i >= node.expressions.length
} : false
})
});
}
}
});
attr.value = spliceChangesIntoString(attr.value, changes);
}
function transformDynamicJsAttribute(attr, env) {
let { matcher } = env;
let source = `let __prettier_temp__ = ${attr.value}`;
let ast = Aa["babel-ts"].parse(source, env.options);
let didChange = false;
let changes = [];
function findConcatEntry(path) {
return path.find((entry) => {
var _entry$parent;
return ((_entry$parent = entry.parent) === null || _entry$parent === void 0 ? void 0 : _entry$parent.type) === "BinaryExpression" && entry.parent.operator === "+";
});
}
function addChange(start, end, after) {
if (start == null || end == null) return;
let offsetStart = start - 24;
let offsetEnd = end - 24;
if (offsetStart < 0 || offsetEnd < 0) return;
didChange = true;
changes.push({
start: offsetStart,
end: offsetEnd,
before: attr.value.slice(offsetStart, offsetEnd),
after
});
}
visit(ast, {
StringLiteral(node, path) {
let concat = findConcatEntry(path);
if (sortStringLiteral(node, {
env,
collapseWhitespace: {
start: (concat === null || concat === void 0 ? void 0 : concat.key) !== "right",
end: (concat === null || concat === void 0 ? void 0 : concat.key) !== "left"
}
})) {
var _node$extra;
let raw = ((_node$extra = node.extra) === null || _node$extra === void 0 ? void 0 : _node$extra.raw) ?? node.raw;
if (typeof raw === "string") addChange(node.start, node.end, raw);
}
},
Literal(node, path) {
if (!isStringLiteral(node)) return;
let concat = findConcatEntry(path);
if (sortStringLiteral(node, {
env,
collapseWhitespace: {
start: (concat === null || concat === void 0 ? void 0 : concat.key) !== "right",
end: (concat === null || concat === void 0 ? void 0 : concat.key) !== "left"
}
})) {
var _node$extra2;
let raw = ((_node$extra2 = node.extra) === null || _node$extra2 === void 0 ? void 0 : _node$extra2.raw) ?? node.raw;
if (typeof raw === "string") addChange(node.start, node.end, raw);
}
},
TemplateLiteral(node, path) {
let concat = findConcatEntry(path);
let originalQuasis = node.quasis.map((quasi) => quasi.value.raw);
if (sortTemplateLiteral(node, {
env,
collapseWhitespace: {
start: (concat === null || concat === void 0 ? void 0 : concat.key) !== "right",
end: (concat === null || concat === void 0 ? void 0 : concat.key) !== "left"
}
})) for (let i = 0; i < node.quasis.length; i++) {
let quasi = node.quasis[i];
if (quasi.value.raw !== originalQuasis[i]) addChange(quasi.start, quasi.end, quasi.value.raw);
}
},
TaggedTemplateExpression(node, path) {
if (!isSortableTemplateExpression(node, matcher)) return;
let concat = findConcatEntry(path);
let originalQuasis = node.quasi.quasis.map((quasi) => quasi.value.raw);
if (sortTemplateLiteral(node.quasi, {
env,
collapseWhitespace: {
start: (concat === null || concat === void 0 ? void 0 : concat.key) !== "right",
end: (concat === null || concat === void 0 ? void 0 : concat.key) !== "left"
}
})) for (let i = 0; i < node.quasi.quasis.length; i++) {
let quasi = node.quasi.quasis[i];
if (quasi.value.raw !== originalQuasis[i]) addChange(quasi.start, quasi.end, quasi.value.raw);
}
}
});
if (didChange) attr.value = spliceChangesIntoString(attr.value, changes);
}
function transformHtml(ast, env) {
let { matcher } = env;
let { parser } = env.options;
for (let attr of ast.attrs ?? []) if (matcher.hasStaticAttr(attr.name)) attr.value = sortClasses(attr.value, { env });
else if (matcher.hasDynamicAttr(attr.name)) {
if (!/[`'"]/.test(attr.value)) continue;
if (parser === "angular") transformDynamicAngularAttribute(attr, env);
else transformDynamicJsAttribute(attr, env);
}
for (let child of ast.children ?? []) transformHtml(child, env);
}
function transformGlimmer(ast, env) {
let { matcher } = env;
visit(ast, {
AttrNode(attr, _path, meta) {
if (matcher.hasStaticAttr(attr.name) && attr.value) meta.sortTextNodes = true;
},
TextNode(node, path, meta) {
if (!meta.sortTextNodes) return;
let concat = path.find((entry) => {
return entry.parent && entry.parent.type === "ConcatStatement";
});
let siblings = {
prev: concat === null || concat === void 0 ? void 0 : concat.parent.parts[concat.index - 1],
next: concat === null || concat === void 0 ? void 0 : concat.parent.parts[concat.index + 1]
};
node.chars = sortClasses(node.chars, {
env,
ignoreFirst: siblings.prev && !/^\s/.test(node.chars),
ignoreLast: siblings.next && !/\s$/.test(node.chars),
collapseWhitespace: {
start: !siblings.prev,
end: !siblings.next
}
});
},
StringLiteral(node, path, meta) {
if (!meta.sortTextNodes) return;
let concat = path.find((entry) => {
return entry.parent && entry.parent.type === "SubExpression" && entry.parent.path.original === "concat";
});
node.value = sortClasses(node.value, {
env,
ignoreLast: Boolean(concat) && !/[^\S\r\n]$/.test(node.value),
collapseWhitespace: {
start: false,
end: !concat
}
});
}
});
}
function transformLiquid(ast, env) {
let { matcher } = env;
function isClassAttr(node) {
return Array.isArray(node.name) ? node.name.every((n) => n.type === "TextNode" && matcher.hasStaticAttr(n.value)) : matcher.hasStaticAttr(node.name);
}
function hasSurroundingQuotes(str) {
let start = str[0];
return start === str[str.length - 1] && (start === "\"" || start === "'" || start === "`");
}
let sources = [];
let changes = [];
function sortAttribute(attr) {
for (let i = 0; i < attr.value.length; i++) {
let node = attr.value[i];
if (node.type === "TextNode") {
let after = sortClasses(node.value, {
env,
ignoreFirst: i > 0 && !/^\s/.test(node.value),
ignoreLast: i < attr.value.length - 1 && !/\s$/.test(node.value),
removeDuplicates: false,
collapseWhitespace: false
});
changes.push({
start: node.position.start,
end: node.position.end,
before: node.value,
after
});
} else if ((node.type === "LiquidDrop" || node.type === "LiquidVariableOutput") && typeof node.markup === "object" && node.markup.type === "LiquidVariable") visit(node.markup.expression, { String(node) {
let pos = { ...node.position };
if (hasSurroundingQuotes(node.source.slice(pos.start, pos.end))) {
pos.start += 1;
pos.end -= 1;
}
let after = sortClasses(node.value, { env });
changes.push({
start: pos.start,
end: pos.end,
before: node.value,
after
});
} });
}
}
visit(ast, {
LiquidTag(node) {
sources.push(node);
},
HtmlElement(node) {
sources.push(node);
},
AttrSingleQuoted(node) {
if (isClassAttr(node)) {
sources.push(node);
sortAttribute(node);
}
},
AttrDoubleQuoted(node) {
if (isClassAttr(node)) {
sources.push(node);
sortAttribute(node);
}
}
});
for (let node of sources) node.source = spliceChangesIntoString(node.source, changes);
}
function sortStringLiteral(node, { env, removeDuplicates, collapseWhitespace = {
start: true,
end: true
} }) {
var _node$extra3;
let raw = ((_node$extra3 = node.extra) === null || _node$extra3 === void 0 ? void 0 : _node$extra3.raw) ?? node.raw;
let quote = raw[0];
let rawContent = raw.slice(1, -1);
let sortedRaw = sortClasses(rawContent, {
env,
removeDuplicates,
collapseWhitespace
});
if (sortedRaw === rawContent) return false;
let sortedCooked = rawContent === node.value ? sortedRaw : sortClasses(node.value, {
env,
removeDuplicates,
collapseWhitespace
});
node.value = sortedCooked;
let newRaw = quote + sortedRaw + quote;
if (node.extra) node.extra = {
...node.extra,
rawValue: sortedCooked,
raw: newRaw
};
else node.raw = newRaw;
return true;
}
function isStringLiteral(node) {
return node.type === "StringLiteral" || node.type === "Literal" && typeof node.value === "string";
}
function sortTemplateLiteral(node, { env, removeDuplicates, collapseWhitespace = {
start: true,
end: true
} }) {
let didChange = false;
for (let i = 0; i < node.quasis.length; i++) {
let quasi = node.quasis[i];
let same = quasi.value.raw === quasi.value.cooked;
let originalRaw = quasi.value.raw;
let originalCooked = quasi.value.cooked;
quasi.value.raw = sortClasses(quasi.value.raw, {
env,
removeDuplicates,
ignoreFirst: i > 0 && !/^\s/.test(quasi.value.raw),
ignoreLast: i < node.expressions.length && !/\s$/.test(quasi.value.raw),
collapseWhitespace: collapseWhitespace && {
start: collapseWhitespace && collapseWhitespace.start && i === 0,
end: collapseWhitespace && collapseWhitespace.end && i >= node.expressions.length
}
});
quasi.value.cooked = same ? quasi.value.raw : sortClasses(quasi.value.cooked, {
env,
ignoreFirst: i > 0 && !/^\s/.test(quasi.value.cooked),
ignoreLast: i < node.expressions.length && !/\s$/.test(quasi.value.cooked),
removeDuplicates,
collapseWhitespace: collapseWhitespace && {
start: collapseWhitespace && collapseWhitespace.start && i === 0,
end: collapseWhitespace && collapseWhitespace.end && i >= node.expressions.length
}
});
if (quasi.value.raw !== originalRaw || quasi.value.cooked !== originalCooked) didChange = true;
}
return didChange;
}
function isSortableTemplateExpression(node, matcher) {
return isSortableExpression(node.tag, matcher);
}
function isSortableCallExpression(node, matcher) {
var _node$arguments;
if (!((_node$arguments = node.arguments) === null || _node$arguments === void 0 ? void 0 : _node$arguments.length)) return false;
return isSortableExpression(node.callee, matcher);
}
function isSortableExpression(node, matcher) {
while (node.type === "CallExpression" || node.type === "MemberExpression") if (node.type === "CallExpression") node = node.callee;
else if (node.type === "MemberExpression") node = node.object;
if (node.type === "Identifier") return matcher.hasFunction(node.name);
return false;
}
function canCollapseWhitespaceIn(path, env) {
if (env.options.tailwindPreserveWhitespace) return false;
let start = true;
let end = true;
for (let entry of path) {
if (!entry.parent) continue;
if (entry.parent.type === "BinaryExpression" && entry.parent.operator === "+") {
start && (start = entry.key !== "right");
end && (end = entry.key !== "left");
}
if (entry.parent.type === "TemplateLiteral") {
let nodeStart = entry.node.start ?? null;
let nodeEnd = entry.node.end ?? null;
for (let quasi of entry.parent.quasis) {
let quasiStart = quasi.start ?? null;
let quasiEnd = quasi.end ?? null;
if (nodeStart !== null && quasiEnd !== null && nodeStart - quasiEnd <= 2) start && (start = /^\s/.test(quasi.value.raw));
if (nodeEnd !== null && quasiStart !== null && nodeEnd - quasiStart <= 2) end && (end = /\s$/.test(quasi.value.raw));
}
}
}
return {
start,
end
};
}
function transformJavaScript(ast, env) {
let { matcher } = env;
function sortInside(ast) {
visit(ast, (node, path) => {
let collapseWhitespace = canCollapseWhitespaceIn(path, env);
if (isStringLiteral(node)) sortStringLiteral(node, {
env,
collapseWhitespace
});
else if (node.type === "TemplateLiteral") sortTemplateLiteral(node, {
env,
collapseWhitespace
});
else if (node.type === "TaggedTemplateExpression") {
if (isSortableTemplateExpression(node, matcher)) sortTemplateLiteral(node.quasi, {
env,
collapseWhitespace
});
}
});
}
visit(ast, {
JSXAttribute(node) {
node = node;
if (!node.value) return;
if (typeof node.name.name !== "string") return;
if (!matcher.hasStaticAttr(node.name.name)) return;
if (isStringLiteral(node.value)) sortStringLiteral(node.value, { env });
else if (node.value.type === "JSXExpressionContainer") sortInside(node.value);
},
CallExpression(node) {
node = node;
if (!isSortableCallExpression(node, matcher)) return;
node.arguments.forEach((arg) => sortInside(arg));
},
TaggedTemplateExpression(node, path) {
node = node;
if (!isSortableTemplateExpression(node, matcher)) return;
let collapseWhitespace = canCollapseWhitespaceIn(path, env);
sortTemplateLiteral(node.quasi, {
env,
collapseWhitespace
});
}
});
}
function transformCss(ast, env) {
function tryParseAtRuleParams(name, params) {
if (typeof params !== "string") return params;
try {
return cn.css.parse(`@import ${params};`, { ...env.options }).nodes[0].params;
} catch (err) {
console.warn(`[prettier-plugin-tailwindcss] Unable to parse at rule`);
console.warn({
name,
params
});
console.warn(err);
}
return params;
}
ast.walk((node) => {
if (node.name === "plugin" || node.name === "config" || node.name === "source") node.params = tryParseAtRuleParams(node.name, node.params);
if (node.type === "css-atrule" && node.name === "apply") {
let isImportant = /\s+(?:!important|#{(['"]*)!important\1})\s*$/.test(node.params);
let classList = node.params;
let prefix = "";
let suffix = "";
if (classList.startsWith("~\"") && classList.endsWith("\"")) {
prefix = "~\"";
suffix = "\"";
classList = classList.slice(2, -1);
isImportant = false;
} else if (classList.startsWith("~'") && classList.endsWith("'")) {
prefix = "~'";
suffix = "'";
classList = classList.slice(2, -1);
isImportant = false;
}
classList = sortClasses(classList, {
env,
ignoreLast: isImportant,
collapseWhitespace: {
start: false,
end: !isImportant
}
});
node.params = `${prefix}${classList}${suffix}`;
}
});
}
function transformAstro(ast, env) {
let { matcher } = env;
if (ast.type === "element" || ast.type === "custom-element" || ast.type === "component") {
for (let attr of ast.attributes ?? []) if (matcher.hasStaticAttr(attr.name) && attr.type === "attribute" && attr.kind === "quoted") attr.value = sortClasses(attr.value, { env });
else if (matcher.hasDynamicAttr(attr.name) && attr.type === "attribute" && attr.kind === "expression" && typeof attr.value === "string") transformDynamicJsAttribute(attr, env);
}
for (let child of ast.children ?? []) transformAstro(child, env);
}
function transformMarko(ast, env) {
let { matcher } = env;
const nodesToVisit = [ast];
while (nodesToVisit.length > 0) {
const currentNode = nodesToVisit.pop();
switch (currentNode.type) {
case "File":
nodesToVisit.push(currentNode.program);
break;
case "Program":
nodesToVisit.push(...currentNode.body);
break;
case "MarkoTag":
nodesToVisit.push(...currentNode.attributes);
nodesToVisit.push(currentNode.body);
break;
case "MarkoTagBody":
nodesToVisit.push(...currentNode.body);
break;
case "MarkoAttribute":
if (!matcher.hasStaticAttr(currentNode.name)) break;
switch (currentNode.value.type) {
case "ArrayExpression":
const classList = currentNode.value.elements;
for (const node of classList) if (node.type === "StringLiteral") node.value = sortClasses(node.value, { env });
break;
case "StringLiteral":
currentNode.value.value = sortClasses(currentNode.value.value, { env });
break;
}
break;
}
}
}
function transformTwig(ast, env) {
let { matcher } = env;
for (let child of ast.expressions ?? []) transformTwig(child, env);
visit(ast, {
Attribute(node, _path, meta) {
if (!matcher.hasStaticAttr(node.name.name)) return;
meta.sortTextNodes = true;
},
CallExpression(node, _path, meta) {
while (node.type === "CallExpression" || node.type === "MemberExpression") if (node.type === "CallExpression") node = node.callee;
else if (node.type === "MemberExpression") node = node.property;
if (node.type === "Identifier") {
if (!matcher.hasFunction(node.name)) return;
}
meta.sortTextNodes = true;
},
StringLiteral(node, path, meta) {
if (!meta.sortTextNodes) return;
const concat = path.find((entry) => {
return entry.parent && (entry.parent.type === "BinaryConcatExpression" || entry.parent.type === "BinaryAddExpression");
});
node.value = sortClasses(node.value, {
env,
ignoreFirst: (concat === null || concat === void 0 ? void 0 : concat.key) === "right" && !/^[^\S\r\n]/.test(node.value),
ignoreLast: (concat === null || concat === void 0 ? void 0 : concat.key) === "left" && !/[^\S\r\n]$/.test(node.value),
collapseWhitespace: {
start: (concat === null || concat === void 0 ? void 0 : concat.key) !== "right",
end: (concat === null || concat === void 0 ? void 0 : concat.key) !== "left"
}
});
}
});
}
function transformPug(ast, env) {
let { matcher } = env;
for (const token of ast.tokens) if (token.type === "attribute" && matcher.hasStaticAttr(token.name)) token.val = [
token.val.slice(0, 1),
sortClasses(token.val.slice(1, -1), { env }),
token.val.slice(-1)
].join("");
let startIdx = -1;
let endIdx = -1;
let ranges = [];
for (let i = 0; i < ast.tokens.length; i++) if (ast.tokens[i].type === "class") {
startIdx = startIdx === -1 ? i : startIdx;
endIdx = i;
} else if (startIdx !== -1) {
ranges.push([startIdx, endIdx]);
startIdx = -1;
endIdx = -1;
}
if (startIdx !== -1) {
ranges.push([startIdx, endIdx]);
startIdx = -1;
endIdx = -1;
}
for (const [startIdx, endIdx] of ranges) {
const { classList } = sortClassList({
classList: ast.tokens.slice(startIdx, endIdx + 1).map((token) => token.val),
api: env.context,
removeDuplicates: false
});
for (let i = startIdx; i <= endIdx; i++) ast.tokens[i].val = classList[i - startIdx];
}
}
function transformSvelte(ast, env) {
let { matcher, changes } = env;
for (let attr of ast.attributes ?? []) {
if (!matcher.hasStaticAttr(attr.name) || attr.type !== "Attribute") continue;
let values = getSvelteAttributeValues(attr);
for (let i = 0; i < values.length; i++) {
let value = values[i];
if (value.type === "Text") {
let same = value.raw === value.data;
value.raw = sortClasses(value.raw, {
env,
ignoreFirst: i > 0 && !/^\s/.test(value.raw),
ignoreLast: i < values.length - 1 && !/\s$/.test(value.raw),
removeDuplicates: true,
collapseWhitespace: false
});
value.data = same ? value.raw : sortClasses(value.data, {
env,
ignoreFirst: i > 0 && !/^\s/.test(value.data),
ignoreLast: i < values.length - 1 && !/\s$/.test(value.data),
removeDuplicates: true,
collapseWhitespace: false
});
} else if (value.type === "MustacheTag" || value.type === "ExpressionTag") visit(value.expression, {
Literal(node) {
if (isStringLiteral(node)) {
let before = node.raw;
if (sortStringLiteral(node, {
env,
removeDuplicates: false,
collapseWhitespace: false
})) changes.push({
before,
after: node.raw,
start: node.loc.start,
end: node.loc.end
});
}
},
TemplateLiteral(node) {
let before = node.quasis.map((quasi) => quasi.value.raw);
if (sortTemplateLiteral(node, {
env,
removeDuplicates: false,
collapseWhitespace: false
})) for (let [idx, quasi] of node.quasis.entries()) changes.push({
before: before[idx],
after: quasi.value.raw,
start: quasi.loc.start,
end: quasi.loc.end
});
}
});
}
}
for (let child of getSvelteChildNodes(ast)) transformSvelte(child, env);
}
function getSvelteAttributeValues(attr) {
if (Array.isArray(attr.value)) return attr.value;
if (attr.value && typeof attr.value === "object") return [attr.value];
return [];
}
function getSvelteChildNodes(node) {
let children = [];
for (let key of [
"children",
"nodes",
"fragment",
"html",
"else",
"consequent",
"alternate",
"body",
"fallback",
"pending",
"then",
"catch"
]) children.push(...getSvelteNodes(node[key]));
return children;
}
function getSvelteNodes(value) {
if (Array.isArray(value)) return value.filter((node) => node === null || node === void 0 ? void 0 : node.type);
if (Array.isArray(value === null || value === void 0 ? void 0 : value.nodes)) return value.nodes;
if (Array.isArray(value === null || value === void 0 ? void 0 : value.children)) return value.children;
if (value === null || value === void 0 ? void 0 : value.type) return [value];
return [];
}
const { parsers, printers } = createPlugin([
defineTransform({
staticAttrs: ["class"],
load: [{
name: "prettier/plugins/html",
importer: () => import("./html--849eFzc.js")
}],
compatible: ["prettier-plugin-organize-attributes"],
parsers: {
html: {},
lwc: {},
angular: { dynamicAttrs: ["[ngClass]"] },
vue: { dynamicAttrs: [":class", "v-bind:class"] }
},
transform: transformHtml
}),
defineTransform({
staticAttrs: ["class"],
load: [{
name: "prettier/plugins/glimmer",
importer: () => import("./glimmer-B5hfTXAX.js")
}],
parsers: { glimmer: {} },
transform: transformGlimmer
}),
defineTransform({
load: [postcss_exports],
compatible: ["prettier-plugin-css-order"],
parsers: {
css: {},
scss: {},
less: {}
},
transform: transformCss
}),
defineTransform({
staticAttrs: ["class", "className"],
compatible: [
"prettier-plugin-multiline-arrays",
"@ianvs/prettier-plugin-sort-imports",
"@trivago/prettier-plugin-sort-imports",
"prettier-plugin-organize-imports",
"prettier-plugin-sort-imports",
"prettier-plugin-jsdoc"
],
parsers: {
babel: { load: [babel_exports] },
"babel-flow": { load: [babel_exports] },
"babel-ts": { load: [babel_exports] },
__js_expression: { load: [babel_exports] },
typescript: { load: [{
name: "prettier/plugins/typescript",
importer: () => import("./typescript-Cvdwz3-D.js")
}] },
meriyah: { load: [{
name: "prettier/plugins/meriyah",
importer: () => import("./meriyah-B5wbO5kj.js")
}] },
acorn: { load: [{
name: "prettier/plugins/acorn",
importer: () => import("./acorn-Dxp-n4ed.js")
}] },
flow: { load: [{
name: "prettier/plugins/flow",
importer: () => import("./flow-BH5imzwC.js")
}] },
oxc: { load: [{
name: "@prettier/plugin-oxc",
importer: () => import("@prettier/plugin-oxc")
}] },
"oxc-ts": { load: [{
name: "@prettier/plugin-oxc",
importer: () => import("@prettier/plugin-oxc")
}] },
hermes: { load: [{
name: "@prettier/plugin-hermes",
importer: () => import("@prettier/plugin-hermes")
}] },
astroExpressionParser: {
load: [{
name: "prettier-plugin-astro",
importer: () => {
return import("prettier-plugin-astro");
}
}],
staticAttrs: ["class"],
dynamicAttrs: ["class:list"]
}
},
transform: transformJavaScript
}),
defineTransform({
staticAttrs: ["class"],
load: [{
name: "prettier-plugin-svelte",
importer: () => import("./plugin-D1B0s0iv.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1))
}],
parsers: { svelte: {} },
printers: { "svelte-ast": {} },
transform: transformSvelte,
reprint(path, { options, changes }) {
if (options.__mutatedOriginalText) return;
options.__mutatedOriginalText = true;
if (!(changes === null || changes === void 0 ? void 0 : changes.length)) return;
let finder = (0, import_line_column.default)(options.originalText);
let stringChanges = changes.map((change) => ({
...change,
start: finder.toIndex(change.start.line, change.start.column + 1),
end: finder.toIndex(change.end.line, change.end.column + 1)
}));
options.originalText = spliceChangesIntoString(options.originalText, stringChanges);
}
}),
defineTransform({
staticAttrs: ["class", "className"],
dynamicAttrs: ["class:list", "className"],
load: [{
name: "prettier-plugin-astro",
importer: () => {
return import("prettier-plugin-astro");
}
}],
parsers: { astro: {} },
transform: transformAstro
}),
defineTransform({
staticAttrs: ["class"],
load: [{
name: "prettier-plugin-marko",
importer: () => import("prettier-plugin-marko")
}],
parsers: { marko: {} },
transform: transformMarko
}),
defineTransform({
staticAttrs: ["class"],
load: [{
name: "@zackad/prettier-plugin-twig",
importer: () => {
return import("@zackad/prettier-plugin-twig");
}
}],
parsers: { twig: {} },
transform: transformTwig
}),
defineTransform({
staticAttrs: ["class"],
load: [{
name: "@prettier/plugin-pug",
importer: () => import("@prettier/plugin-pug")
}],
parsers: { pug: {} },
transform: transformPug
}),
defineTransform({
staticAttrs: ["class"],
load: [{
name: "@shopify/prettier-plugin-liquid",
importer: () => import("@shopify/prettier-plugin-liquid")
}],
parsers: { "liquid-html": {} },
transform: transformLiquid
})
]);
//#endregion
export { options, parsers, printers };

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

import { r as getTailwindConfig, t as createSorter } from "./sorter-BZkvDMjt-DFTeIPU-.js";
export { createSorter, getTailwindConfig };

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display