Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| import { createRequire } from "node:module"; | ||
| //#region \0rolldown/runtime.js | ||
| 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), cb = null), mod.exports); | ||
| var __exportAll = (all, no_symbols) => { | ||
| let target = {}; | ||
| for (var name in all) __defProp(target, name, { | ||
| get: all[name], | ||
| enumerable: true | ||
| }); | ||
| if (!no_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 __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
| var __require = /* @__PURE__ */ createRequire(import.meta.url); | ||
| //#endregion | ||
| //#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-Cw36juP9.js"); | ||
| const { formatOptionsHiddenDefaults } = prettier.__internal; | ||
| formatOptionsHiddenDefaults.parentParser = null; | ||
| formatOptionsHiddenDefaults.__onHtmlRoot = null; | ||
| formatOptionsHiddenDefaults.__inJsTemplate = null; | ||
| return prettier; | ||
| }); | ||
| } | ||
| /** | ||
| * TODO: Plugins support | ||
| * - Read `plugins` field | ||
| * - Load plugins dynamically and parse `languages` field | ||
| * - Map file extensions and filenames to Prettier parsers | ||
| * | ||
| * @returns Array of loaded plugin's `languages` info | ||
| */ | ||
| async function resolvePlugins() { | ||
| return []; | ||
| } | ||
| /** | ||
| * 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-D_YbN99t.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-w0dgpoFw.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-DOdiccQR.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-BlJcmKAv.js")); | ||
| options.plugins ??= []; | ||
| options.plugins.push(CACHES.oxfmtPlugin); | ||
| } | ||
| //#endregion | ||
| export { sortTailwindClasses as a, __exportAll as c, __toESM as d, resolvePlugins as i, __require as l, formatEmbeddedDoc as n, __commonJSMin as o, formatFile as r, __esmMin as s, formatEmbeddedCode as t, __toCommonJS as u }; |
Sorry, the diff of this file is too big to display
| import { createRequire } from "node:module"; | ||
| //#region src-js/bindings.js | ||
| const require = createRequire(import.meta.url); | ||
| new URL(".", import.meta.url).pathname; | ||
| const { readFileSync } = require("node: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 (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.50.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.50.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.50.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.50.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?.variables?.shlib_suffix === "dll.a" || 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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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.50.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(); | ||
| if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) { | ||
| let wasiBinding = null; | ||
| let wasiBindingError = null; | ||
| try { | ||
| wasiBinding = require("./oxfmt.wasi.cjs"); | ||
| nativeBinding = wasiBinding; | ||
| } catch (err) { | ||
| if (process.env.NAPI_RS_FORCE_WASI) wasiBindingError = err; | ||
| } | ||
| if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) try { | ||
| wasiBinding = require("@oxfmt/binding-wasm32-wasi"); | ||
| nativeBinding = wasiBinding; | ||
| } catch (err) { | ||
| if (process.env.NAPI_RS_FORCE_WASI) { | ||
| 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) throw 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.", { cause: loadErrors.reduce((err, cur) => { | ||
| cur.cause = err; | ||
| return cur; | ||
| }) }); | ||
| throw new Error(`Failed to load native binding`); | ||
| } | ||
| const { Severity, format, jsTextToDoc, runCli } = nativeBinding; | ||
| //#endregion | ||
| export { jsTextToDoc as n, runCli as r, format as t }; |
| import { d as __toESM } from "./apis-CKvPKBJI.js"; | ||
| import { n as init_babel, parsers as ra, t as babel_exports } from "./babel-DaNjvh9L.js"; | ||
| import index_exports, { t as init_prettier } from "./prettier-Cw36juP9.js"; | ||
| import { a as sortClasses, b as __toESM$1, c as cacheForDirs, d as expiringMap, f as loadIfExists, g as __commonJSMin, 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-DpGe0QK9.js"; | ||
| import { parsers as fn, t as init_angular } from "./angular-DtI-eDW8.js"; | ||
| import { n as postcss_exports, parsers as en, t as init_postcss } from "./postcss-D-ql-dm8.js"; | ||
| import * as path from "node:path"; | ||
| import { isAbsolute } from "path"; | ||
| //#region ../../node_modules/.pnpm/prettier-plugin-tailwindcss@0.0.0-insiders.3997fbd_prettier-plugin-svelte@3.5.2_prettie_981079e52d31d99dd529b9a262e0d726/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; | ||
| } | ||
| const ESCAPE_SEQUENCE_PATTERN = /\\(['"\\nrtbfv0-7xuU])/g; | ||
| function tryParseAngularAttribute(value, env) { | ||
| try { | ||
| return fn.__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 = ra["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, _node$extra4; | ||
| let result = sortClasses(node.value, { | ||
| env, | ||
| removeDuplicates, | ||
| collapseWhitespace | ||
| }); | ||
| if (!(result !== node.value)) return false; | ||
| node.value = result; | ||
| let raw = ((_node$extra3 = node.extra) === null || _node$extra3 === void 0 ? void 0 : _node$extra3.raw) ?? node.raw; | ||
| let quote = raw[0]; | ||
| let originalRawContent = raw.slice(1, -1); | ||
| let originalValue = ((_node$extra4 = node.extra) === null || _node$extra4 === void 0 ? void 0 : _node$extra4.rawValue) ?? node.value; | ||
| if (node.extra) { | ||
| if (originalRawContent !== originalValue && originalValue.includes("\\")) result = result.replace(ESCAPE_SEQUENCE_PATTERN, "\\\\$1"); | ||
| node.extra = { | ||
| ...node.extra, | ||
| rawValue: result, | ||
| raw: quote + result + quote | ||
| }; | ||
| } else node.raw = quote + result + quote; | ||
| 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 en.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; | ||
| for (let i = 0; i < attr.value.length; i++) { | ||
| let value = attr.value[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 < attr.value.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 < attr.value.length - 1 && !/\s$/.test(value.data), | ||
| removeDuplicates: true, | ||
| collapseWhitespace: false | ||
| }); | ||
| } else if (value.type === "MustacheTag") 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 ast.children ?? []) transformSvelte(child, env); | ||
| if (ast.type === "IfBlock") { | ||
| var _ast$else; | ||
| for (let child of ((_ast$else = ast.else) === null || _ast$else === void 0 ? void 0 : _ast$else.children) ?? []) transformSvelte(child, env); | ||
| } | ||
| if (ast.type === "AwaitBlock") { | ||
| let nodes = [ | ||
| ast.pending, | ||
| ast.then, | ||
| ast.catch | ||
| ]; | ||
| for (let child of nodes) transformSvelte(child, env); | ||
| } | ||
| if (ast.html) transformSvelte(ast.html, env); | ||
| } | ||
| const { parsers, printers } = createPlugin([ | ||
| defineTransform({ | ||
| staticAttrs: ["class"], | ||
| load: [{ | ||
| name: "prettier/plugins/html", | ||
| importer: () => import("./html-DkcPxRXg.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-D_zkI0w_.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-C_eN_ThF.js") | ||
| }] }, | ||
| meriyah: { load: [{ | ||
| name: "prettier/plugins/meriyah", | ||
| importer: () => import("./meriyah-BGPf00Rn.js") | ||
| }] }, | ||
| acorn: { load: [{ | ||
| name: "prettier/plugins/acorn", | ||
| importer: () => import("./acorn-sBRpswSh.js") | ||
| }] }, | ||
| flow: { load: [{ | ||
| name: "prettier/plugins/flow", | ||
| importer: () => import("./flow-c9AjoQam.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-DOdiccQR.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 { s as __esmMin } from "./apis-CKvPKBJI.js"; | ||
| //#region ../../node_modules/.pnpm/prettier@3.8.3/node_modules/prettier/plugins/graphql.mjs | ||
| function x(e) { | ||
| return S(e), { | ||
| type: Ee, | ||
| contents: e | ||
| }; | ||
| } | ||
| function y(e, t = {}) { | ||
| return S(e), Y(t.expandedStates, !0), { | ||
| type: Te, | ||
| id: t.id, | ||
| contents: e, | ||
| break: !!t.shouldBreak, | ||
| expandedStates: t.expandedStates | ||
| }; | ||
| } | ||
| function I(e, t = "", n = {}) { | ||
| return S(e), t !== "" && S(t), { | ||
| type: Ne, | ||
| breakContents: e, | ||
| flatContents: t, | ||
| groupId: n.groupId | ||
| }; | ||
| } | ||
| function E(e, t) { | ||
| S(e), Y(t); | ||
| let n = []; | ||
| for (let i = 0; i < t.length; i++) i !== 0 && n.push(e), n.push(t[i]); | ||
| return n; | ||
| } | ||
| function j(e) { | ||
| return (t, n, i) => { | ||
| let r = !!i?.backwards; | ||
| if (n === !1) return !1; | ||
| let { length: s } = t, a = n; | ||
| for (; a >= 0 && a < s;) { | ||
| let u = t.charAt(a); | ||
| if (e instanceof RegExp) { | ||
| if (!e.test(u)) return a; | ||
| } else if (!e.includes(u)) return a; | ||
| r ? a-- : a++; | ||
| } | ||
| return a === -1 || a === s ? a : !1; | ||
| }; | ||
| } | ||
| function mt(e, t, n) { | ||
| let i = !!n?.backwards; | ||
| if (t === !1) return !1; | ||
| let r = e.charAt(t); | ||
| if (i) { | ||
| if (e.charAt(t - 1) === "\r" && r === ` | ||
| `) return t - 2; | ||
| if (Oe(r)) return t - 1; | ||
| } else { | ||
| if (r === "\r" && e.charAt(t + 1) === ` | ||
| `) return t + 2; | ||
| if (Oe(r)) return t + 1; | ||
| } | ||
| return t; | ||
| } | ||
| function Et(e, t, n = {}) { | ||
| let i = $(e, n.backwards ? t - 1 : t, n); | ||
| return i !== X(e, i, n); | ||
| } | ||
| function Tt(e, t) { | ||
| if (t === !1) return !1; | ||
| if (e.charAt(t) === "/" && e.charAt(t + 1) === "*") { | ||
| for (let n = t + 2; n < e.length; ++n) if (e.charAt(n) === "*" && e.charAt(n + 1) === "/") return n + 2; | ||
| } | ||
| return t; | ||
| } | ||
| function Nt(e, t) { | ||
| return t === !1 ? !1 : e.charAt(t) === "/" && e.charAt(t + 1) === "/" ? Ae(e, t) : t; | ||
| } | ||
| function xt(e, t) { | ||
| let n = null, i = t; | ||
| for (; i !== n;) n = i, i = ye(e, i), i = De(e, i), i = $(e, i); | ||
| return i = ge(e, i), i = X(e, i), i !== !1 && Ie(e, i); | ||
| } | ||
| function _t(e) { | ||
| return Array.isArray(e) && e.length > 0; | ||
| } | ||
| function w(e) { | ||
| if (P !== null && typeof P.property) { | ||
| let t = P; | ||
| return P = w.prototype = null, t; | ||
| } | ||
| return P = w.prototype = e ?? Object.create(null), new w(); | ||
| } | ||
| function ae(e) { | ||
| return w(e); | ||
| } | ||
| function At(e, t = "type") { | ||
| ae(e); | ||
| function n(i) { | ||
| let r = i[t], s = e[r]; | ||
| if (!Array.isArray(s)) throw Object.assign(/* @__PURE__ */ new Error(`Missing visitor keys for '${r}'.`), { node: i }); | ||
| return s; | ||
| } | ||
| return n; | ||
| } | ||
| function It(e, t, n) { | ||
| let { node: i } = e; | ||
| if (!i.description) return ""; | ||
| let r = [n("description")]; | ||
| return i.kind === "InputValueDefinition" && !i.description.block ? r.push(k) : r.push(f), r; | ||
| } | ||
| function Dt(e, t, n) { | ||
| let { node: i } = e; | ||
| switch (i.kind) { | ||
| case "Document": return [...E(f, g(e, t, n, "definitions")), f]; | ||
| case "OperationDefinition": { | ||
| let r = t.originalText[J(i)] !== "{", s = !!i.name; | ||
| return [ | ||
| A(e, t, n), | ||
| r ? i.operation : "", | ||
| r && s ? [" ", n("name")] : "", | ||
| r && !s && se(i.variableDefinitions) ? " " : "", | ||
| Be(e, n), | ||
| _(e, n, i), | ||
| !r && !s ? "" : " ", | ||
| n("selectionSet") | ||
| ]; | ||
| } | ||
| case "FragmentDefinition": return [ | ||
| A(e, t, n), | ||
| "fragment ", | ||
| n("name"), | ||
| Be(e, n), | ||
| " on ", | ||
| n("typeCondition"), | ||
| _(e, n, i), | ||
| " ", | ||
| n("selectionSet") | ||
| ]; | ||
| case "SelectionSet": return [ | ||
| "{", | ||
| x([f, E(f, g(e, t, n, "selections"))]), | ||
| f, | ||
| "}" | ||
| ]; | ||
| case "Field": return y([ | ||
| i.alias ? [n("alias"), ": "] : "", | ||
| n("name"), | ||
| i.arguments.length > 0 ? y([ | ||
| "(", | ||
| x([l, E([I("", ", "), l], g(e, t, n, "arguments"))]), | ||
| l, | ||
| ")" | ||
| ]) : "", | ||
| _(e, n, i), | ||
| i.selectionSet ? " " : "", | ||
| n("selectionSet") | ||
| ]); | ||
| case "Name": return i.value; | ||
| case "StringValue": | ||
| if (i.block) { | ||
| let r = U(0, i.value, "\"\"\"", "\\\"\"\"").split(` | ||
| `); | ||
| return r.length === 1 && (r[0] = r[0].trim()), r.every((s) => s === "") && (r.length = 0), E(f, [ | ||
| "\"\"\"", | ||
| ...r, | ||
| "\"\"\"" | ||
| ]); | ||
| } | ||
| return [ | ||
| "\"", | ||
| U(0, U(0, i.value, /["\\]/gu, "\\$&"), ` | ||
| `, "\\n"), | ||
| "\"" | ||
| ]; | ||
| case "IntValue": | ||
| case "FloatValue": | ||
| case "EnumValue": return i.value; | ||
| case "BooleanValue": return i.value ? "true" : "false"; | ||
| case "NullValue": return "null"; | ||
| case "Variable": return ["$", n("name")]; | ||
| case "ListValue": return y([ | ||
| "[", | ||
| x([l, E([I("", ", "), l], e.map(n, "values"))]), | ||
| l, | ||
| "]" | ||
| ]); | ||
| case "ObjectValue": { | ||
| let r = t.bracketSpacing && i.fields.length > 0 ? " " : ""; | ||
| return y([ | ||
| "{", | ||
| r, | ||
| x([l, E([I("", ", "), l], e.map(n, "fields"))]), | ||
| l, | ||
| I("", r), | ||
| "}" | ||
| ]); | ||
| } | ||
| case "ObjectField": | ||
| case "Argument": return [ | ||
| n("name"), | ||
| ": ", | ||
| n("value") | ||
| ]; | ||
| case "Directive": return [ | ||
| "@", | ||
| n("name"), | ||
| i.arguments.length > 0 ? y([ | ||
| "(", | ||
| x([l, E([I("", ", "), l], g(e, t, n, "arguments"))]), | ||
| l, | ||
| ")" | ||
| ]) : "" | ||
| ]; | ||
| case "NamedType": return n("name"); | ||
| case "VariableDefinition": return [ | ||
| A(e, t, n), | ||
| n("variable"), | ||
| ": ", | ||
| n("type"), | ||
| i.defaultValue ? [" = ", n("defaultValue")] : "", | ||
| _(e, n, i) | ||
| ]; | ||
| case "ObjectTypeExtension": | ||
| case "ObjectTypeDefinition": | ||
| case "InputObjectTypeExtension": | ||
| case "InputObjectTypeDefinition": | ||
| case "InterfaceTypeExtension": | ||
| case "InterfaceTypeDefinition": { | ||
| let { kind: r } = i, s = []; | ||
| return r.endsWith("TypeDefinition") ? s.push(A(e, t, n)) : s.push("extend "), r.startsWith("ObjectType") ? s.push("type") : r.startsWith("InputObjectType") ? s.push("input") : s.push("interface"), s.push(" ", n("name")), !r.startsWith("InputObjectType") && i.interfaces.length > 0 && s.push(" implements ", ...kt(e, t, n)), s.push(_(e, n, i)), i.fields.length > 0 && s.push([ | ||
| " {", | ||
| x([f, E(f, g(e, t, n, "fields"))]), | ||
| f, | ||
| "}" | ||
| ]), s; | ||
| } | ||
| case "FieldDefinition": return [ | ||
| A(e, t, n), | ||
| n("name"), | ||
| i.arguments.length > 0 ? y([ | ||
| "(", | ||
| x([l, E([I("", ", "), l], g(e, t, n, "arguments"))]), | ||
| l, | ||
| ")" | ||
| ]) : "", | ||
| ": ", | ||
| n("type"), | ||
| _(e, n, i) | ||
| ]; | ||
| case "DirectiveDefinition": return [ | ||
| A(e, t, n), | ||
| "directive ", | ||
| "@", | ||
| n("name"), | ||
| i.arguments.length > 0 ? y([ | ||
| "(", | ||
| x([l, E([I("", ", "), l], g(e, t, n, "arguments"))]), | ||
| l, | ||
| ")" | ||
| ]) : "", | ||
| i.repeatable ? " repeatable" : "", | ||
| " on ", | ||
| ...E(" | ", e.map(n, "locations")) | ||
| ]; | ||
| case "EnumTypeExtension": | ||
| case "EnumTypeDefinition": return [ | ||
| A(e, t, n), | ||
| i.kind === "EnumTypeExtension" ? "extend " : "", | ||
| "enum ", | ||
| n("name"), | ||
| _(e, n, i), | ||
| i.values.length > 0 ? [ | ||
| " {", | ||
| x([f, E(f, g(e, t, n, "values"))]), | ||
| f, | ||
| "}" | ||
| ] : "" | ||
| ]; | ||
| case "EnumValueDefinition": return [ | ||
| A(e, t, n), | ||
| n("name"), | ||
| _(e, n, i) | ||
| ]; | ||
| case "InputValueDefinition": return [ | ||
| A(e, t, n), | ||
| n("name"), | ||
| ": ", | ||
| n("type"), | ||
| i.defaultValue ? [" = ", n("defaultValue")] : "", | ||
| _(e, n, i) | ||
| ]; | ||
| case "SchemaExtension": return [ | ||
| "extend schema", | ||
| _(e, n, i), | ||
| ...i.operationTypes.length > 0 ? [ | ||
| " {", | ||
| x([f, E(f, g(e, t, n, "operationTypes"))]), | ||
| f, | ||
| "}" | ||
| ] : [] | ||
| ]; | ||
| case "SchemaDefinition": return [ | ||
| A(e, t, n), | ||
| "schema", | ||
| _(e, n, i), | ||
| " {", | ||
| i.operationTypes.length > 0 ? x([f, E(f, g(e, t, n, "operationTypes"))]) : "", | ||
| f, | ||
| "}" | ||
| ]; | ||
| case "OperationTypeDefinition": return [ | ||
| i.operation, | ||
| ": ", | ||
| n("type") | ||
| ]; | ||
| case "FragmentSpread": return [ | ||
| "...", | ||
| n("name"), | ||
| _(e, n, i) | ||
| ]; | ||
| case "InlineFragment": return [ | ||
| "...", | ||
| i.typeCondition ? [" on ", n("typeCondition")] : "", | ||
| _(e, n, i), | ||
| " ", | ||
| n("selectionSet") | ||
| ]; | ||
| case "UnionTypeExtension": | ||
| case "UnionTypeDefinition": return y([A(e, t, n), y([ | ||
| i.kind === "UnionTypeExtension" ? "extend " : "", | ||
| "union ", | ||
| n("name"), | ||
| _(e, n, i), | ||
| i.types.length > 0 ? [ | ||
| " =", | ||
| I("", " "), | ||
| x([I([k, "| "]), E([k, "| "], e.map(n, "types"))]) | ||
| ] : "" | ||
| ])]); | ||
| case "ScalarTypeExtension": | ||
| case "ScalarTypeDefinition": return [ | ||
| A(e, t, n), | ||
| i.kind === "ScalarTypeExtension" ? "extend " : "", | ||
| "scalar ", | ||
| n("name"), | ||
| _(e, n, i) | ||
| ]; | ||
| case "NonNullType": return [n("type"), "!"]; | ||
| case "ListType": return [ | ||
| "[", | ||
| n("type"), | ||
| "]" | ||
| ]; | ||
| default: throw new ke(i, "Graphql", "kind"); | ||
| } | ||
| } | ||
| function _(e, t, n) { | ||
| if (n.directives.length === 0) return ""; | ||
| let i = E(k, e.map(t, "directives")); | ||
| return n.kind === "FragmentDefinition" || n.kind === "OperationDefinition" ? y([k, i]) : [" ", y(x([l, i]))]; | ||
| } | ||
| function g(e, t, n, i) { | ||
| return e.map(({ isLast: r, node: s }) => { | ||
| let a = n(); | ||
| return !r && Se(t.originalText, q(s)) ? [a, f] : a; | ||
| }, i); | ||
| } | ||
| function gt(e) { | ||
| return e.kind !== "Comment"; | ||
| } | ||
| function St({ node: e }) { | ||
| if (e.kind === "Comment") return "#" + e.value.trimEnd(); | ||
| throw new Error("Not a comment: " + JSON.stringify(e)); | ||
| } | ||
| function kt(e, t, n) { | ||
| let { node: i } = e, r = [], { interfaces: s } = i, a = e.map(n, "interfaces"); | ||
| for (let u = 0; u < s.length; u++) { | ||
| let p = s[u]; | ||
| r.push(a[u]); | ||
| let T = s[u + 1]; | ||
| if (T) { | ||
| let D = t.originalText.slice(p.loc.end, T.loc.start).includes("#"); | ||
| r.push(" &", D ? k : " "); | ||
| } | ||
| } | ||
| return r; | ||
| } | ||
| function Be(e, t) { | ||
| let { node: n } = e; | ||
| return se(n.variableDefinitions) ? y([ | ||
| "(", | ||
| x([l, E([I("", ", "), l], e.map(t, "variableDefinitions"))]), | ||
| l, | ||
| ")" | ||
| ]) : ""; | ||
| } | ||
| function Ue(e, t) { | ||
| e.kind === "StringValue" && e.block && !e.value.includes(` | ||
| `) && (t.value = e.value.trim()); | ||
| } | ||
| function Ct(e) { | ||
| let { node: t } = e; | ||
| return t?.comments?.some((n) => n.value.trim() === "prettier-ignore"); | ||
| } | ||
| function Xe(e) { | ||
| return typeof e == "object" && e !== null; | ||
| } | ||
| function He(e, t) { | ||
| if (!!!e) throw new Error(t ?? "Unexpected invariant triggered."); | ||
| } | ||
| function M(e, t) { | ||
| let n = 0, i = 1; | ||
| for (let r of e.body.matchAll(bt)) { | ||
| if (typeof r.index == "number" || He(!1), r.index >= t) break; | ||
| n = r.index + r[0].length, i += 1; | ||
| } | ||
| return { | ||
| line: i, | ||
| column: t + 1 - n | ||
| }; | ||
| } | ||
| function qe(e) { | ||
| return ue(e.source, M(e.source, e.start)); | ||
| } | ||
| function ue(e, t) { | ||
| let n = e.locationOffset.column - 1, i = "".padStart(n) + e.body, r = t.line - 1, s = e.locationOffset.line - 1, a = t.line + s, u = t.line === 1 ? n : 0, p = t.column + u, T = `${e.name}:${a}:${p} | ||
| `, d = i.split(/\r\n|[\n\r]/g), D = d[r]; | ||
| if (D.length > 120) { | ||
| let O = Math.floor(p / 80), re = p % 80, N = []; | ||
| for (let v = 0; v < D.length; v += 80) N.push(D.slice(v, v + 80)); | ||
| return T + Je([ | ||
| [`${a} |`, N[0]], | ||
| ...N.slice(1, O + 1).map((v) => ["|", v]), | ||
| ["|", "^".padStart(re)], | ||
| ["|", N[O + 1]] | ||
| ]); | ||
| } | ||
| return T + Je([ | ||
| [`${a - 1} |`, d[r - 1]], | ||
| [`${a} |`, D], | ||
| ["|", "^".padStart(p)], | ||
| [`${a + 1} |`, d[r + 1]] | ||
| ]); | ||
| } | ||
| function Je(e) { | ||
| let t = e.filter(([i, r]) => r !== void 0), n = Math.max(...t.map(([i]) => i.length)); | ||
| return t.map(([i, r]) => i.padStart(n) + (r ? " " + r : "")).join(` | ||
| `); | ||
| } | ||
| function Lt(e) { | ||
| let t = e[0]; | ||
| return t == null || "kind" in t || "length" in t ? { | ||
| nodes: t, | ||
| source: e[1], | ||
| positions: e[2], | ||
| path: e[3], | ||
| originalError: e[4], | ||
| extensions: e[5] | ||
| } : t; | ||
| } | ||
| function Qe(e) { | ||
| return e === void 0 || e.length === 0 ? void 0 : e; | ||
| } | ||
| function h(e, t, n) { | ||
| return new Q(`Syntax Error: ${n}`, { | ||
| source: e, | ||
| positions: [t] | ||
| }); | ||
| } | ||
| function We(e) { | ||
| return e === 9 || e === 32; | ||
| } | ||
| function b(e) { | ||
| return e >= 48 && e <= 57; | ||
| } | ||
| function ze(e) { | ||
| return e >= 97 && e <= 122 || e >= 65 && e <= 90; | ||
| } | ||
| function pe(e) { | ||
| return ze(e) || e === 95; | ||
| } | ||
| function Ke(e) { | ||
| return ze(e) || b(e) || e === 95; | ||
| } | ||
| function Ze(e) { | ||
| var t; | ||
| let n = Number.MAX_SAFE_INTEGER, i = null, r = -1; | ||
| for (let a = 0; a < e.length; ++a) { | ||
| var s; | ||
| let u = e[a], p = Pt(u); | ||
| p !== u.length && (i = (s = i) !== null && s !== void 0 ? s : a, r = a, a !== 0 && p < n && (n = p)); | ||
| } | ||
| return e.map((a, u) => u === 0 ? a : a.slice(n)).slice((t = i) !== null && t !== void 0 ? t : 0, r + 1); | ||
| } | ||
| function Pt(e) { | ||
| let t = 0; | ||
| for (; t < e.length && We(e.charCodeAt(t));) ++t; | ||
| return t; | ||
| } | ||
| function tt(e) { | ||
| return e === o.BANG || e === o.DOLLAR || e === o.AMP || e === o.PAREN_L || e === o.PAREN_R || e === o.DOT || e === o.SPREAD || e === o.COLON || e === o.EQUALS || e === o.AT || e === o.BRACKET_L || e === o.BRACKET_R || e === o.BRACE_L || e === o.PIPE || e === o.BRACE_R; | ||
| } | ||
| function L(e) { | ||
| return e >= 0 && e <= 55295 || e >= 57344 && e <= 1114111; | ||
| } | ||
| function K(e, t) { | ||
| return nt(e.charCodeAt(t)) && rt(e.charCodeAt(t + 1)); | ||
| } | ||
| function nt(e) { | ||
| return e >= 55296 && e <= 56319; | ||
| } | ||
| function rt(e) { | ||
| return e >= 56320 && e <= 57343; | ||
| } | ||
| function R(e, t) { | ||
| let n = e.source.body.codePointAt(t); | ||
| if (n === void 0) return o.EOF; | ||
| if (n >= 32 && n <= 126) { | ||
| let i = String.fromCodePoint(n); | ||
| return i === "\"" ? `'"'` : `"${i}"`; | ||
| } | ||
| return "U+" + n.toString(16).toUpperCase().padStart(4, "0"); | ||
| } | ||
| function m(e, t, n, i, r) { | ||
| let s = e.line; | ||
| return new F(t, n, i, s, 1 + n - e.lineStart, r); | ||
| } | ||
| function wt(e, t) { | ||
| let n = e.source.body, i = n.length, r = t; | ||
| for (; r < i;) { | ||
| let s = n.charCodeAt(r); | ||
| switch (s) { | ||
| case 65279: | ||
| case 9: | ||
| case 32: | ||
| case 44: | ||
| ++r; | ||
| continue; | ||
| case 10: | ||
| ++r, ++e.line, e.lineStart = r; | ||
| continue; | ||
| case 13: | ||
| n.charCodeAt(r + 1) === 10 ? r += 2 : ++r, ++e.line, e.lineStart = r; | ||
| continue; | ||
| case 35: return Ft(e, r); | ||
| case 33: return m(e, o.BANG, r, r + 1); | ||
| case 36: return m(e, o.DOLLAR, r, r + 1); | ||
| case 38: return m(e, o.AMP, r, r + 1); | ||
| case 40: return m(e, o.PAREN_L, r, r + 1); | ||
| case 41: return m(e, o.PAREN_R, r, r + 1); | ||
| case 46: | ||
| if (n.charCodeAt(r + 1) === 46 && n.charCodeAt(r + 2) === 46) return m(e, o.SPREAD, r, r + 3); | ||
| break; | ||
| case 58: return m(e, o.COLON, r, r + 1); | ||
| case 61: return m(e, o.EQUALS, r, r + 1); | ||
| case 64: return m(e, o.AT, r, r + 1); | ||
| case 91: return m(e, o.BRACKET_L, r, r + 1); | ||
| case 93: return m(e, o.BRACKET_R, r, r + 1); | ||
| case 123: return m(e, o.BRACE_L, r, r + 1); | ||
| case 124: return m(e, o.PIPE, r, r + 1); | ||
| case 125: return m(e, o.BRACE_R, r, r + 1); | ||
| case 34: return n.charCodeAt(r + 1) === 34 && n.charCodeAt(r + 2) === 34 ? Yt(e, r) : Vt(e, r); | ||
| } | ||
| if (b(s) || s === 45) return Mt(e, r, s); | ||
| if (pe(s)) return jt(e, r); | ||
| throw h(e.source, r, s === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : L(s) || K(n, r) ? `Unexpected character: ${R(e, r)}.` : `Invalid character: ${R(e, r)}.`); | ||
| } | ||
| return m(e, o.EOF, i, i); | ||
| } | ||
| function Ft(e, t) { | ||
| let n = e.source.body, i = n.length, r = t + 1; | ||
| for (; r < i;) { | ||
| let s = n.charCodeAt(r); | ||
| if (s === 10 || s === 13) break; | ||
| if (L(s)) ++r; | ||
| else if (K(n, r)) r += 2; | ||
| else break; | ||
| } | ||
| return m(e, o.COMMENT, t, r, n.slice(t + 1, r)); | ||
| } | ||
| function Mt(e, t, n) { | ||
| let i = e.source.body, r = t, s = n, a = !1; | ||
| if (s === 45 && (s = i.charCodeAt(++r)), s === 48) { | ||
| if (s = i.charCodeAt(++r), b(s)) throw h(e.source, r, `Invalid number, unexpected digit after 0: ${R(e, r)}.`); | ||
| } else r = le(e, r, s), s = i.charCodeAt(r); | ||
| if (s === 46 && (a = !0, s = i.charCodeAt(++r), r = le(e, r, s), s = i.charCodeAt(r)), (s === 69 || s === 101) && (a = !0, s = i.charCodeAt(++r), (s === 43 || s === 45) && (s = i.charCodeAt(++r)), r = le(e, r, s), s = i.charCodeAt(r)), s === 46 || pe(s)) throw h(e.source, r, `Invalid number, expected digit but got: ${R(e, r)}.`); | ||
| return m(e, a ? o.FLOAT : o.INT, t, r, i.slice(t, r)); | ||
| } | ||
| function le(e, t, n) { | ||
| if (!b(n)) throw h(e.source, t, `Invalid number, expected digit but got: ${R(e, t)}.`); | ||
| let i = e.source.body, r = t + 1; | ||
| for (; b(i.charCodeAt(r));) ++r; | ||
| return r; | ||
| } | ||
| function Vt(e, t) { | ||
| let n = e.source.body, i = n.length, r = t + 1, s = r, a = ""; | ||
| for (; r < i;) { | ||
| let u = n.charCodeAt(r); | ||
| if (u === 34) return a += n.slice(s, r), m(e, o.STRING, t, r + 1, a); | ||
| if (u === 92) { | ||
| a += n.slice(s, r); | ||
| let p = n.charCodeAt(r + 1) === 117 ? n.charCodeAt(r + 2) === 123 ? Bt(e, r) : Ut(e, r) : Gt(e, r); | ||
| a += p.value, r += p.size, s = r; | ||
| continue; | ||
| } | ||
| if (u === 10 || u === 13) break; | ||
| if (L(u)) ++r; | ||
| else if (K(n, r)) r += 2; | ||
| else throw h(e.source, r, `Invalid character within String: ${R(e, r)}.`); | ||
| } | ||
| throw h(e.source, r, "Unterminated string."); | ||
| } | ||
| function Bt(e, t) { | ||
| let n = e.source.body, i = 0, r = 3; | ||
| for (; r < 12;) { | ||
| let s = n.charCodeAt(t + r++); | ||
| if (s === 125) { | ||
| if (r < 5 || !L(i)) break; | ||
| return { | ||
| value: String.fromCodePoint(i), | ||
| size: r | ||
| }; | ||
| } | ||
| if (i = i << 4 | V(s), i < 0) break; | ||
| } | ||
| throw h(e.source, t, `Invalid Unicode escape sequence: "${n.slice(t, t + r)}".`); | ||
| } | ||
| function Ut(e, t) { | ||
| let n = e.source.body, i = et(n, t + 2); | ||
| if (L(i)) return { | ||
| value: String.fromCodePoint(i), | ||
| size: 6 | ||
| }; | ||
| if (nt(i) && n.charCodeAt(t + 6) === 92 && n.charCodeAt(t + 7) === 117) { | ||
| let r = et(n, t + 8); | ||
| if (rt(r)) return { | ||
| value: String.fromCodePoint(i, r), | ||
| size: 12 | ||
| }; | ||
| } | ||
| throw h(e.source, t, `Invalid Unicode escape sequence: "${n.slice(t, t + 6)}".`); | ||
| } | ||
| function et(e, t) { | ||
| return V(e.charCodeAt(t)) << 12 | V(e.charCodeAt(t + 1)) << 8 | V(e.charCodeAt(t + 2)) << 4 | V(e.charCodeAt(t + 3)); | ||
| } | ||
| function V(e) { | ||
| return e >= 48 && e <= 57 ? e - 48 : e >= 65 && e <= 70 ? e - 55 : e >= 97 && e <= 102 ? e - 87 : -1; | ||
| } | ||
| function Gt(e, t) { | ||
| let n = e.source.body; | ||
| switch (n.charCodeAt(t + 1)) { | ||
| case 34: return { | ||
| value: "\"", | ||
| size: 2 | ||
| }; | ||
| case 92: return { | ||
| value: "\\", | ||
| size: 2 | ||
| }; | ||
| case 47: return { | ||
| value: "/", | ||
| size: 2 | ||
| }; | ||
| case 98: return { | ||
| value: "\b", | ||
| size: 2 | ||
| }; | ||
| case 102: return { | ||
| value: "\f", | ||
| size: 2 | ||
| }; | ||
| case 110: return { | ||
| value: ` | ||
| `, | ||
| size: 2 | ||
| }; | ||
| case 114: return { | ||
| value: "\r", | ||
| size: 2 | ||
| }; | ||
| case 116: return { | ||
| value: " ", | ||
| size: 2 | ||
| }; | ||
| } | ||
| throw h(e.source, t, `Invalid character escape sequence: "${n.slice(t, t + 2)}".`); | ||
| } | ||
| function Yt(e, t) { | ||
| let n = e.source.body, i = n.length, r = e.lineStart, s = t + 3, a = s, u = "", p = []; | ||
| for (; s < i;) { | ||
| let T = n.charCodeAt(s); | ||
| if (T === 34 && n.charCodeAt(s + 1) === 34 && n.charCodeAt(s + 2) === 34) { | ||
| u += n.slice(a, s), p.push(u); | ||
| let d = m(e, o.BLOCK_STRING, t, s + 3, Ze(p).join(` | ||
| `)); | ||
| return e.line += p.length - 1, e.lineStart = r, d; | ||
| } | ||
| if (T === 92 && n.charCodeAt(s + 1) === 34 && n.charCodeAt(s + 2) === 34 && n.charCodeAt(s + 3) === 34) { | ||
| u += n.slice(a, s), a = s + 1, s += 4; | ||
| continue; | ||
| } | ||
| if (T === 10 || T === 13) { | ||
| u += n.slice(a, s), p.push(u), T === 13 && n.charCodeAt(s + 1) === 10 ? s += 2 : ++s, u = "", a = s, r = s; | ||
| continue; | ||
| } | ||
| if (L(T)) ++s; | ||
| else if (K(n, s)) s += 2; | ||
| else throw h(e.source, s, `Invalid character within String: ${R(e, s)}.`); | ||
| } | ||
| throw h(e.source, s, "Unterminated string."); | ||
| } | ||
| function jt(e, t) { | ||
| let n = e.source.body, i = n.length, r = t + 1; | ||
| for (; r < i;) if (Ke(n.charCodeAt(r))) ++r; | ||
| else break; | ||
| return m(e, o.NAME, t, r, n.slice(t, r)); | ||
| } | ||
| function Z(e, t) { | ||
| if (!!!e) throw new Error(t); | ||
| } | ||
| function ee(e) { | ||
| return te(e, []); | ||
| } | ||
| function te(e, t) { | ||
| switch (typeof e) { | ||
| case "string": return JSON.stringify(e); | ||
| case "function": return e.name ? `[function ${e.name}]` : "[function]"; | ||
| case "object": return $t(e, t); | ||
| default: return String(e); | ||
| } | ||
| } | ||
| function $t(e, t) { | ||
| if (e === null) return "null"; | ||
| if (t.includes(e)) return "[Circular]"; | ||
| let n = [...t, e]; | ||
| if (Xt(e)) { | ||
| let i = e.toJSON(); | ||
| if (i !== e) return typeof i == "string" ? i : te(i, n); | ||
| } else if (Array.isArray(e)) return Jt(e, n); | ||
| return Ht(e, n); | ||
| } | ||
| function Xt(e) { | ||
| return typeof e.toJSON == "function"; | ||
| } | ||
| function Ht(e, t) { | ||
| let n = Object.entries(e); | ||
| return n.length === 0 ? "{}" : t.length > 2 ? "[" + qt(e) + "]" : "{ " + n.map(([r, s]) => r + ": " + te(s, t)).join(", ") + " }"; | ||
| } | ||
| function Jt(e, t) { | ||
| if (e.length === 0) return "[]"; | ||
| if (t.length > 2) return "[Array]"; | ||
| let n = Math.min(10, e.length), i = e.length - n, r = []; | ||
| for (let s = 0; s < n; ++s) r.push(te(e[s], t)); | ||
| return i === 1 ? r.push("... 1 more item") : i > 1 && r.push(`... ${i} more items`), "[" + r.join(", ") + "]"; | ||
| } | ||
| function qt(e) { | ||
| let t = Object.prototype.toString.call(e).replace(/^\[object /, "").replace(/]$/, ""); | ||
| if (t === "Object" && typeof e.constructor == "function") { | ||
| let n = e.constructor.name; | ||
| if (typeof n == "string" && n !== "") return n; | ||
| } | ||
| return t; | ||
| } | ||
| function st(e) { | ||
| return it(e, B); | ||
| } | ||
| function ot(e, t) { | ||
| let n = new fe(e, t), i = n.parseDocument(); | ||
| return Object.defineProperty(i, "tokenCount", { | ||
| enumerable: !1, | ||
| value: n.tokenCount | ||
| }), i; | ||
| } | ||
| function ne(e) { | ||
| let t = e.value; | ||
| return at(e.kind) + (t != null ? ` "${t}"` : ""); | ||
| } | ||
| function at(e) { | ||
| return tt(e) ? `"${e}"` : e; | ||
| } | ||
| function Wt(e, t) { | ||
| let n = /* @__PURE__ */ new SyntaxError(e + " (" + t.loc.start.line + ":" + t.loc.start.column + ")"); | ||
| return Object.assign(n, t); | ||
| } | ||
| function zt(e) { | ||
| let t = [], { startToken: n, endToken: i } = e.loc; | ||
| for (let r = n; r !== i; r = r.next) r.kind === "Comment" && t.push({ | ||
| ...r, | ||
| loc: { | ||
| start: r.start, | ||
| end: r.end | ||
| } | ||
| }); | ||
| return t; | ||
| } | ||
| function Zt(e) { | ||
| if (e?.name === "GraphQLError") { | ||
| let { message: t, locations: [n] } = e; | ||
| return ct(t, { | ||
| loc: { start: n }, | ||
| cause: e | ||
| }); | ||
| } | ||
| return e; | ||
| } | ||
| function en(e) { | ||
| let t; | ||
| try { | ||
| t = ot(e, Kt); | ||
| } catch (n) { | ||
| throw Zt(n); | ||
| } | ||
| return t.comments = zt(t), t; | ||
| } | ||
| var pt, de, ut, me, lt, U, ht, ie, Ee, Te, Ne, G, xe, S, Y, _e, k, l, f, $, ye, Ae, Oe, X, Ie, De, ge, Se, se, oe, ke, P, yt, Ce, H, F, ce, C, Re, be, J, q, Le, Pe, we, Fe, Me, Ve, A, Ge, Ye, $e, he, bt, Q, W, c, o, z, it, B, fe, ct, Kt, tn, nn; | ||
| //#endregion | ||
| __esmMin((() => { | ||
| pt = Object.defineProperty; | ||
| de = (e, t) => { | ||
| for (var n in t) pt(e, n, { | ||
| get: t[n], | ||
| enumerable: !0 | ||
| }); | ||
| }; | ||
| ut = {}; | ||
| de(ut, { | ||
| languages: () => Ye, | ||
| options: () => $e, | ||
| parsers: () => he, | ||
| printers: () => nn | ||
| }); | ||
| me = (e, t) => (n, i, ...r) => n | 1 && i == null ? void 0 : (t.call(i) ?? i[e]).apply(i, r); | ||
| lt = String.prototype.replaceAll ?? function(e, t) { | ||
| return e.global ? this.replace(e, t) : this.split(e).join(t); | ||
| }, U = me("replaceAll", function() { | ||
| if (typeof this == "string") return lt; | ||
| }); | ||
| ht = () => {}, ie = ht; | ||
| Ee = "indent"; | ||
| Te = "group"; | ||
| Ne = "if-break"; | ||
| G = "line"; | ||
| xe = "break-parent"; | ||
| S = ie, Y = ie; | ||
| _e = { type: xe }; | ||
| k = { type: G }, l = { | ||
| type: G, | ||
| soft: !0 | ||
| }, f = [{ | ||
| type: G, | ||
| hard: !0 | ||
| }, _e]; | ||
| $ = j(" "), ye = j(",; "), Ae = j(/[^\n\r]/u); | ||
| Oe = (e) => e === ` | ||
| ` || e === "\r" || e === "\u2028" || e === "\u2029"; | ||
| X = mt; | ||
| Ie = Et; | ||
| De = Tt; | ||
| ge = Nt; | ||
| Se = xt; | ||
| se = _t; | ||
| oe = class extends Error { | ||
| name = "UnexpectedNodeError"; | ||
| constructor(t, n, i = "type") { | ||
| super(`Unexpected ${n} node ${i}: ${JSON.stringify(t[i])}.`), this.node = t; | ||
| } | ||
| }, ke = oe; | ||
| P = null; | ||
| yt = 10; | ||
| for (let e = 0; e <= yt; e++) w(); | ||
| Ce = At, H = class { | ||
| constructor(t, n, i) { | ||
| this.start = t.start, this.end = n.end, this.startToken = t, this.endToken = n, this.source = i; | ||
| } | ||
| get [Symbol.toStringTag]() { | ||
| return "Location"; | ||
| } | ||
| toJSON() { | ||
| return { | ||
| start: this.start, | ||
| end: this.end | ||
| }; | ||
| } | ||
| }, F = class { | ||
| constructor(t, n, i, r, s, a) { | ||
| this.kind = t, this.start = n, this.end = i, this.line = r, this.column = s, this.value = a, this.prev = null, this.next = null; | ||
| } | ||
| get [Symbol.toStringTag]() { | ||
| return "Token"; | ||
| } | ||
| toJSON() { | ||
| return { | ||
| kind: this.kind, | ||
| value: this.value, | ||
| line: this.line, | ||
| column: this.column | ||
| }; | ||
| } | ||
| }, ce = { | ||
| Name: [], | ||
| Document: ["definitions"], | ||
| OperationDefinition: [ | ||
| "description", | ||
| "name", | ||
| "variableDefinitions", | ||
| "directives", | ||
| "selectionSet" | ||
| ], | ||
| VariableDefinition: [ | ||
| "description", | ||
| "variable", | ||
| "type", | ||
| "defaultValue", | ||
| "directives" | ||
| ], | ||
| Variable: ["name"], | ||
| SelectionSet: ["selections"], | ||
| Field: [ | ||
| "alias", | ||
| "name", | ||
| "arguments", | ||
| "directives", | ||
| "selectionSet" | ||
| ], | ||
| Argument: ["name", "value"], | ||
| FragmentSpread: ["name", "directives"], | ||
| InlineFragment: [ | ||
| "typeCondition", | ||
| "directives", | ||
| "selectionSet" | ||
| ], | ||
| FragmentDefinition: [ | ||
| "description", | ||
| "name", | ||
| "variableDefinitions", | ||
| "typeCondition", | ||
| "directives", | ||
| "selectionSet" | ||
| ], | ||
| IntValue: [], | ||
| FloatValue: [], | ||
| StringValue: [], | ||
| BooleanValue: [], | ||
| NullValue: [], | ||
| EnumValue: [], | ||
| ListValue: ["values"], | ||
| ObjectValue: ["fields"], | ||
| ObjectField: ["name", "value"], | ||
| Directive: ["name", "arguments"], | ||
| NamedType: ["name"], | ||
| ListType: ["type"], | ||
| NonNullType: ["type"], | ||
| SchemaDefinition: [ | ||
| "description", | ||
| "directives", | ||
| "operationTypes" | ||
| ], | ||
| OperationTypeDefinition: ["type"], | ||
| ScalarTypeDefinition: [ | ||
| "description", | ||
| "name", | ||
| "directives" | ||
| ], | ||
| ObjectTypeDefinition: [ | ||
| "description", | ||
| "name", | ||
| "interfaces", | ||
| "directives", | ||
| "fields" | ||
| ], | ||
| FieldDefinition: [ | ||
| "description", | ||
| "name", | ||
| "arguments", | ||
| "type", | ||
| "directives" | ||
| ], | ||
| InputValueDefinition: [ | ||
| "description", | ||
| "name", | ||
| "type", | ||
| "defaultValue", | ||
| "directives" | ||
| ], | ||
| InterfaceTypeDefinition: [ | ||
| "description", | ||
| "name", | ||
| "interfaces", | ||
| "directives", | ||
| "fields" | ||
| ], | ||
| UnionTypeDefinition: [ | ||
| "description", | ||
| "name", | ||
| "directives", | ||
| "types" | ||
| ], | ||
| EnumTypeDefinition: [ | ||
| "description", | ||
| "name", | ||
| "directives", | ||
| "values" | ||
| ], | ||
| EnumValueDefinition: [ | ||
| "description", | ||
| "name", | ||
| "directives" | ||
| ], | ||
| InputObjectTypeDefinition: [ | ||
| "description", | ||
| "name", | ||
| "directives", | ||
| "fields" | ||
| ], | ||
| DirectiveDefinition: [ | ||
| "description", | ||
| "name", | ||
| "arguments", | ||
| "locations" | ||
| ], | ||
| SchemaExtension: ["directives", "operationTypes"], | ||
| ScalarTypeExtension: ["name", "directives"], | ||
| ObjectTypeExtension: [ | ||
| "name", | ||
| "interfaces", | ||
| "directives", | ||
| "fields" | ||
| ], | ||
| InterfaceTypeExtension: [ | ||
| "name", | ||
| "interfaces", | ||
| "directives", | ||
| "fields" | ||
| ], | ||
| UnionTypeExtension: [ | ||
| "name", | ||
| "directives", | ||
| "types" | ||
| ], | ||
| EnumTypeExtension: [ | ||
| "name", | ||
| "directives", | ||
| "values" | ||
| ], | ||
| InputObjectTypeExtension: [ | ||
| "name", | ||
| "directives", | ||
| "fields" | ||
| ], | ||
| TypeCoordinate: ["name"], | ||
| MemberCoordinate: ["name", "memberName"], | ||
| ArgumentCoordinate: [ | ||
| "name", | ||
| "fieldName", | ||
| "argumentName" | ||
| ], | ||
| DirectiveCoordinate: ["name"], | ||
| DirectiveArgumentCoordinate: ["name", "argumentName"] | ||
| }; | ||
| new Set(Object.keys(ce)); | ||
| (function(e) { | ||
| e.QUERY = "query", e.MUTATION = "mutation", e.SUBSCRIPTION = "subscription"; | ||
| })(C || (C = {})); | ||
| Re = { ...ce }; | ||
| for (let e of [ | ||
| "ArgumentCoordinate", | ||
| "DirectiveArgumentCoordinate", | ||
| "DirectiveCoordinate", | ||
| "MemberCoordinate", | ||
| "TypeCoordinate" | ||
| ]) delete Re[e]; | ||
| be = Ce(Re, "kind"); | ||
| J = (e) => e.loc.start, q = (e) => e.loc.end; | ||
| Le = "format", Pe = /^\s*#[^\S\n]*@(?:noformat|noprettier)\s*(?:\n|$)/u, we = /^\s*#[^\S\n]*@(?:format|prettier)\s*(?:\n|$)/u; | ||
| Fe = (e) => we.test(e), Me = (e) => Pe.test(e), Ve = (e) => `# @${Le} | ||
| ${e}`; | ||
| A = It; | ||
| Ue.ignoredProperties = new Set(["loc", "comments"]); | ||
| Ge = { | ||
| print: Dt, | ||
| massageAstNode: Ue, | ||
| hasPrettierIgnore: Ct, | ||
| insertPragma: Ve, | ||
| printComment: St, | ||
| canAttachComment: gt, | ||
| getVisitorKeys: be | ||
| }; | ||
| Ye = [{ | ||
| name: "GraphQL", | ||
| type: "data", | ||
| aceMode: "graphqlschema", | ||
| extensions: [ | ||
| ".graphql", | ||
| ".gql", | ||
| ".graphqls" | ||
| ], | ||
| tmScope: "source.graphql", | ||
| parsers: ["graphql"], | ||
| vscodeLanguageIds: ["graphql"], | ||
| linguistLanguageId: 139 | ||
| }]; | ||
| $e = { bracketSpacing: { | ||
| bracketSpacing: { | ||
| category: "Common", | ||
| type: "boolean", | ||
| default: !0, | ||
| description: "Print spaces between brackets.", | ||
| oppositeDescription: "Do not print spaces between brackets." | ||
| }, | ||
| objectWrap: { | ||
| category: "Common", | ||
| type: "choice", | ||
| default: "preserve", | ||
| description: "How to wrap object literals.", | ||
| choices: [{ | ||
| value: "preserve", | ||
| description: "Keep as multi-line, if there is a newline between the opening brace and first property." | ||
| }, { | ||
| value: "collapse", | ||
| description: "Fit to a single line when possible." | ||
| }] | ||
| }, | ||
| singleQuote: { | ||
| category: "Common", | ||
| type: "boolean", | ||
| default: !1, | ||
| description: "Use single quotes instead of double quotes." | ||
| }, | ||
| proseWrap: { | ||
| category: "Common", | ||
| type: "choice", | ||
| default: "preserve", | ||
| description: "How to wrap prose.", | ||
| choices: [ | ||
| { | ||
| value: "always", | ||
| description: "Wrap prose if it exceeds the print width." | ||
| }, | ||
| { | ||
| value: "never", | ||
| description: "Do not wrap prose." | ||
| }, | ||
| { | ||
| value: "preserve", | ||
| description: "Wrap prose as-is." | ||
| } | ||
| ] | ||
| }, | ||
| bracketSameLine: { | ||
| category: "Common", | ||
| type: "boolean", | ||
| default: !1, | ||
| description: "Put > of opening tags on the last line instead of on a new line." | ||
| }, | ||
| singleAttributePerLine: { | ||
| category: "Common", | ||
| type: "boolean", | ||
| default: !1, | ||
| description: "Enforce single attribute per line in HTML, Vue and JSX." | ||
| } | ||
| }.bracketSpacing }; | ||
| he = {}; | ||
| de(he, { graphql: () => tn }); | ||
| bt = /\r\n|[\n\r]/g; | ||
| Q = class e extends Error { | ||
| constructor(t, ...n) { | ||
| var i, r, s; | ||
| let { nodes: a, source: u, positions: p, path: T, originalError: d, extensions: D } = Lt(n); | ||
| super(t), this.name = "GraphQLError", this.path = T ?? void 0, this.originalError = d ?? void 0, this.nodes = Qe(Array.isArray(a) ? a : a ? [a] : void 0); | ||
| let O = Qe((i = this.nodes) === null || i === void 0 ? void 0 : i.map((N) => N.loc).filter((N) => N != null)); | ||
| this.source = u ?? (O == null || (r = O[0]) === null || r === void 0 ? void 0 : r.source), this.positions = p ?? O?.map((N) => N.start), this.locations = p && u ? p.map((N) => M(u, N)) : O?.map((N) => M(N.source, N.start)); | ||
| let re = Xe(d?.extensions) ? d?.extensions : void 0; | ||
| this.extensions = (s = D ?? re) !== null && s !== void 0 ? s : Object.create(null), Object.defineProperties(this, { | ||
| message: { | ||
| writable: !0, | ||
| enumerable: !0 | ||
| }, | ||
| name: { enumerable: !1 }, | ||
| nodes: { enumerable: !1 }, | ||
| source: { enumerable: !1 }, | ||
| positions: { enumerable: !1 }, | ||
| originalError: { enumerable: !1 } | ||
| }), d != null && d.stack ? Object.defineProperty(this, "stack", { | ||
| value: d.stack, | ||
| writable: !0, | ||
| configurable: !0 | ||
| }) : Error.captureStackTrace ? Error.captureStackTrace(this, e) : Object.defineProperty(this, "stack", { | ||
| value: Error().stack, | ||
| writable: !0, | ||
| configurable: !0 | ||
| }); | ||
| } | ||
| get [Symbol.toStringTag]() { | ||
| return "GraphQLError"; | ||
| } | ||
| toString() { | ||
| let t = this.message; | ||
| if (this.nodes) for (let n of this.nodes) n.loc && (t += ` | ||
| ` + qe(n.loc)); | ||
| else if (this.source && this.locations) for (let n of this.locations) t += ` | ||
| ` + ue(this.source, n); | ||
| return t; | ||
| } | ||
| toJSON() { | ||
| let t = { message: this.message }; | ||
| return this.locations != null && (t.locations = this.locations), this.path != null && (t.path = this.path), this.extensions != null && Object.keys(this.extensions).length > 0 && (t.extensions = this.extensions), t; | ||
| } | ||
| }; | ||
| (function(e) { | ||
| e.QUERY = "QUERY", e.MUTATION = "MUTATION", e.SUBSCRIPTION = "SUBSCRIPTION", e.FIELD = "FIELD", e.FRAGMENT_DEFINITION = "FRAGMENT_DEFINITION", e.FRAGMENT_SPREAD = "FRAGMENT_SPREAD", e.INLINE_FRAGMENT = "INLINE_FRAGMENT", e.VARIABLE_DEFINITION = "VARIABLE_DEFINITION", e.SCHEMA = "SCHEMA", e.SCALAR = "SCALAR", e.OBJECT = "OBJECT", e.FIELD_DEFINITION = "FIELD_DEFINITION", e.ARGUMENT_DEFINITION = "ARGUMENT_DEFINITION", e.INTERFACE = "INTERFACE", e.UNION = "UNION", e.ENUM = "ENUM", e.ENUM_VALUE = "ENUM_VALUE", e.INPUT_OBJECT = "INPUT_OBJECT", e.INPUT_FIELD_DEFINITION = "INPUT_FIELD_DEFINITION"; | ||
| })(W || (W = {})); | ||
| (function(e) { | ||
| e.NAME = "Name", e.DOCUMENT = "Document", e.OPERATION_DEFINITION = "OperationDefinition", e.VARIABLE_DEFINITION = "VariableDefinition", e.SELECTION_SET = "SelectionSet", e.FIELD = "Field", e.ARGUMENT = "Argument", e.FRAGMENT_SPREAD = "FragmentSpread", e.INLINE_FRAGMENT = "InlineFragment", e.FRAGMENT_DEFINITION = "FragmentDefinition", e.VARIABLE = "Variable", e.INT = "IntValue", e.FLOAT = "FloatValue", e.STRING = "StringValue", e.BOOLEAN = "BooleanValue", e.NULL = "NullValue", e.ENUM = "EnumValue", e.LIST = "ListValue", e.OBJECT = "ObjectValue", e.OBJECT_FIELD = "ObjectField", e.DIRECTIVE = "Directive", e.NAMED_TYPE = "NamedType", e.LIST_TYPE = "ListType", e.NON_NULL_TYPE = "NonNullType", e.SCHEMA_DEFINITION = "SchemaDefinition", e.OPERATION_TYPE_DEFINITION = "OperationTypeDefinition", e.SCALAR_TYPE_DEFINITION = "ScalarTypeDefinition", e.OBJECT_TYPE_DEFINITION = "ObjectTypeDefinition", e.FIELD_DEFINITION = "FieldDefinition", e.INPUT_VALUE_DEFINITION = "InputValueDefinition", e.INTERFACE_TYPE_DEFINITION = "InterfaceTypeDefinition", e.UNION_TYPE_DEFINITION = "UnionTypeDefinition", e.ENUM_TYPE_DEFINITION = "EnumTypeDefinition", e.ENUM_VALUE_DEFINITION = "EnumValueDefinition", e.INPUT_OBJECT_TYPE_DEFINITION = "InputObjectTypeDefinition", e.DIRECTIVE_DEFINITION = "DirectiveDefinition", e.SCHEMA_EXTENSION = "SchemaExtension", e.SCALAR_TYPE_EXTENSION = "ScalarTypeExtension", e.OBJECT_TYPE_EXTENSION = "ObjectTypeExtension", e.INTERFACE_TYPE_EXTENSION = "InterfaceTypeExtension", e.UNION_TYPE_EXTENSION = "UnionTypeExtension", e.ENUM_TYPE_EXTENSION = "EnumTypeExtension", e.INPUT_OBJECT_TYPE_EXTENSION = "InputObjectTypeExtension", e.TYPE_COORDINATE = "TypeCoordinate", e.MEMBER_COORDINATE = "MemberCoordinate", e.ARGUMENT_COORDINATE = "ArgumentCoordinate", e.DIRECTIVE_COORDINATE = "DirectiveCoordinate", e.DIRECTIVE_ARGUMENT_COORDINATE = "DirectiveArgumentCoordinate"; | ||
| })(c || (c = {})); | ||
| (function(e) { | ||
| e.SOF = "<SOF>", e.EOF = "<EOF>", e.BANG = "!", e.DOLLAR = "$", e.AMP = "&", e.PAREN_L = "(", e.PAREN_R = ")", e.DOT = ".", e.SPREAD = "...", e.COLON = ":", e.EQUALS = "=", e.AT = "@", e.BRACKET_L = "[", e.BRACKET_R = "]", e.BRACE_L = "{", e.PIPE = "|", e.BRACE_R = "}", e.NAME = "Name", e.INT = "Int", e.FLOAT = "Float", e.STRING = "String", e.BLOCK_STRING = "BlockString", e.COMMENT = "Comment"; | ||
| })(o || (o = {})); | ||
| z = class { | ||
| constructor(t) { | ||
| let n = new F(o.SOF, 0, 0, 0, 0); | ||
| this.source = t, this.lastToken = n, this.token = n, this.line = 1, this.lineStart = 0; | ||
| } | ||
| get [Symbol.toStringTag]() { | ||
| return "Lexer"; | ||
| } | ||
| advance() { | ||
| return this.lastToken = this.token, this.token = this.lookahead(); | ||
| } | ||
| lookahead() { | ||
| let t = this.token; | ||
| if (t.kind !== o.EOF) do | ||
| if (t.next) t = t.next; | ||
| else { | ||
| let n = wt(this, t.end); | ||
| t.next = n, n.prev = t, t = n; | ||
| } | ||
| while (t.kind === o.COMMENT); | ||
| return t; | ||
| } | ||
| }; | ||
| it = globalThis.process && !0 ? function(t, n) { | ||
| return t instanceof n; | ||
| } : function(t, n) { | ||
| if (t instanceof n) return !0; | ||
| if (typeof t == "object" && t !== null) { | ||
| var i; | ||
| let r = n.prototype[Symbol.toStringTag]; | ||
| if (r === (Symbol.toStringTag in t ? t[Symbol.toStringTag] : (i = t.constructor) === null || i === void 0 ? void 0 : i.name)) { | ||
| let a = ee(t); | ||
| throw new Error(`Cannot use ${r} "${a}" from another module or realm. | ||
| Ensure that there is only one instance of "graphql" in the node_modules | ||
| directory. If different versions of "graphql" are the dependencies of other | ||
| relied on modules, use "resolutions" to ensure only one version is installed. | ||
| https://yarnpkg.com/en/docs/selective-version-resolutions | ||
| Duplicate "graphql" modules cannot be used at the same time since different | ||
| versions may have different capabilities and behavior. The data from one | ||
| version used in the function from another could produce confusing and | ||
| spurious results.`); | ||
| } | ||
| } | ||
| return !1; | ||
| }; | ||
| B = class { | ||
| constructor(t, n = "GraphQL request", i = { | ||
| line: 1, | ||
| column: 1 | ||
| }) { | ||
| typeof t == "string" || Z(!1, `Body must be a string. Received: ${ee(t)}.`), this.body = t, this.name = n, this.locationOffset = i, this.locationOffset.line > 0 || Z(!1, "line in locationOffset is 1-indexed and must be positive."), this.locationOffset.column > 0 || Z(!1, "column in locationOffset is 1-indexed and must be positive."); | ||
| } | ||
| get [Symbol.toStringTag]() { | ||
| return "Source"; | ||
| } | ||
| }; | ||
| fe = class { | ||
| constructor(t, n = {}) { | ||
| let { lexer: i, ...r } = n; | ||
| if (i) this._lexer = i; | ||
| else { | ||
| let s = st(t) ? t : new B(t); | ||
| this._lexer = new z(s); | ||
| } | ||
| this._options = r, this._tokenCounter = 0; | ||
| } | ||
| get tokenCount() { | ||
| return this._tokenCounter; | ||
| } | ||
| parseName() { | ||
| let t = this.expectToken(o.NAME); | ||
| return this.node(t, { | ||
| kind: c.NAME, | ||
| value: t.value | ||
| }); | ||
| } | ||
| parseDocument() { | ||
| return this.node(this._lexer.token, { | ||
| kind: c.DOCUMENT, | ||
| definitions: this.many(o.SOF, this.parseDefinition, o.EOF) | ||
| }); | ||
| } | ||
| parseDefinition() { | ||
| if (this.peek(o.BRACE_L)) return this.parseOperationDefinition(); | ||
| let t = this.peekDescription(), n = t ? this._lexer.lookahead() : this._lexer.token; | ||
| if (t && n.kind === o.BRACE_L) throw h(this._lexer.source, this._lexer.token.start, "Unexpected description, descriptions are not supported on shorthand queries."); | ||
| if (n.kind === o.NAME) { | ||
| switch (n.value) { | ||
| case "schema": return this.parseSchemaDefinition(); | ||
| case "scalar": return this.parseScalarTypeDefinition(); | ||
| case "type": return this.parseObjectTypeDefinition(); | ||
| case "interface": return this.parseInterfaceTypeDefinition(); | ||
| case "union": return this.parseUnionTypeDefinition(); | ||
| case "enum": return this.parseEnumTypeDefinition(); | ||
| case "input": return this.parseInputObjectTypeDefinition(); | ||
| case "directive": return this.parseDirectiveDefinition(); | ||
| } | ||
| switch (n.value) { | ||
| case "query": | ||
| case "mutation": | ||
| case "subscription": return this.parseOperationDefinition(); | ||
| case "fragment": return this.parseFragmentDefinition(); | ||
| } | ||
| if (t) throw h(this._lexer.source, this._lexer.token.start, "Unexpected description, only GraphQL definitions support descriptions."); | ||
| switch (n.value) { | ||
| case "extend": return this.parseTypeSystemExtension(); | ||
| } | ||
| } | ||
| throw this.unexpected(n); | ||
| } | ||
| parseOperationDefinition() { | ||
| let t = this._lexer.token; | ||
| if (this.peek(o.BRACE_L)) return this.node(t, { | ||
| kind: c.OPERATION_DEFINITION, | ||
| operation: C.QUERY, | ||
| description: void 0, | ||
| name: void 0, | ||
| variableDefinitions: [], | ||
| directives: [], | ||
| selectionSet: this.parseSelectionSet() | ||
| }); | ||
| let n = this.parseDescription(), i = this.parseOperationType(), r; | ||
| return this.peek(o.NAME) && (r = this.parseName()), this.node(t, { | ||
| kind: c.OPERATION_DEFINITION, | ||
| operation: i, | ||
| description: n, | ||
| name: r, | ||
| variableDefinitions: this.parseVariableDefinitions(), | ||
| directives: this.parseDirectives(!1), | ||
| selectionSet: this.parseSelectionSet() | ||
| }); | ||
| } | ||
| parseOperationType() { | ||
| let t = this.expectToken(o.NAME); | ||
| switch (t.value) { | ||
| case "query": return C.QUERY; | ||
| case "mutation": return C.MUTATION; | ||
| case "subscription": return C.SUBSCRIPTION; | ||
| } | ||
| throw this.unexpected(t); | ||
| } | ||
| parseVariableDefinitions() { | ||
| return this.optionalMany(o.PAREN_L, this.parseVariableDefinition, o.PAREN_R); | ||
| } | ||
| parseVariableDefinition() { | ||
| return this.node(this._lexer.token, { | ||
| kind: c.VARIABLE_DEFINITION, | ||
| description: this.parseDescription(), | ||
| variable: this.parseVariable(), | ||
| type: (this.expectToken(o.COLON), this.parseTypeReference()), | ||
| defaultValue: this.expectOptionalToken(o.EQUALS) ? this.parseConstValueLiteral() : void 0, | ||
| directives: this.parseConstDirectives() | ||
| }); | ||
| } | ||
| parseVariable() { | ||
| let t = this._lexer.token; | ||
| return this.expectToken(o.DOLLAR), this.node(t, { | ||
| kind: c.VARIABLE, | ||
| name: this.parseName() | ||
| }); | ||
| } | ||
| parseSelectionSet() { | ||
| return this.node(this._lexer.token, { | ||
| kind: c.SELECTION_SET, | ||
| selections: this.many(o.BRACE_L, this.parseSelection, o.BRACE_R) | ||
| }); | ||
| } | ||
| parseSelection() { | ||
| return this.peek(o.SPREAD) ? this.parseFragment() : this.parseField(); | ||
| } | ||
| parseField() { | ||
| let t = this._lexer.token, n = this.parseName(), i, r; | ||
| return this.expectOptionalToken(o.COLON) ? (i = n, r = this.parseName()) : r = n, this.node(t, { | ||
| kind: c.FIELD, | ||
| alias: i, | ||
| name: r, | ||
| arguments: this.parseArguments(!1), | ||
| directives: this.parseDirectives(!1), | ||
| selectionSet: this.peek(o.BRACE_L) ? this.parseSelectionSet() : void 0 | ||
| }); | ||
| } | ||
| parseArguments(t) { | ||
| let n = t ? this.parseConstArgument : this.parseArgument; | ||
| return this.optionalMany(o.PAREN_L, n, o.PAREN_R); | ||
| } | ||
| parseArgument(t = !1) { | ||
| let n = this._lexer.token, i = this.parseName(); | ||
| return this.expectToken(o.COLON), this.node(n, { | ||
| kind: c.ARGUMENT, | ||
| name: i, | ||
| value: this.parseValueLiteral(t) | ||
| }); | ||
| } | ||
| parseConstArgument() { | ||
| return this.parseArgument(!0); | ||
| } | ||
| parseFragment() { | ||
| let t = this._lexer.token; | ||
| this.expectToken(o.SPREAD); | ||
| let n = this.expectOptionalKeyword("on"); | ||
| return !n && this.peek(o.NAME) ? this.node(t, { | ||
| kind: c.FRAGMENT_SPREAD, | ||
| name: this.parseFragmentName(), | ||
| directives: this.parseDirectives(!1) | ||
| }) : this.node(t, { | ||
| kind: c.INLINE_FRAGMENT, | ||
| typeCondition: n ? this.parseNamedType() : void 0, | ||
| directives: this.parseDirectives(!1), | ||
| selectionSet: this.parseSelectionSet() | ||
| }); | ||
| } | ||
| parseFragmentDefinition() { | ||
| let t = this._lexer.token, n = this.parseDescription(); | ||
| return this.expectKeyword("fragment"), this._options.allowLegacyFragmentVariables === !0 ? this.node(t, { | ||
| kind: c.FRAGMENT_DEFINITION, | ||
| description: n, | ||
| name: this.parseFragmentName(), | ||
| variableDefinitions: this.parseVariableDefinitions(), | ||
| typeCondition: (this.expectKeyword("on"), this.parseNamedType()), | ||
| directives: this.parseDirectives(!1), | ||
| selectionSet: this.parseSelectionSet() | ||
| }) : this.node(t, { | ||
| kind: c.FRAGMENT_DEFINITION, | ||
| description: n, | ||
| name: this.parseFragmentName(), | ||
| typeCondition: (this.expectKeyword("on"), this.parseNamedType()), | ||
| directives: this.parseDirectives(!1), | ||
| selectionSet: this.parseSelectionSet() | ||
| }); | ||
| } | ||
| parseFragmentName() { | ||
| if (this._lexer.token.value === "on") throw this.unexpected(); | ||
| return this.parseName(); | ||
| } | ||
| parseValueLiteral(t) { | ||
| let n = this._lexer.token; | ||
| switch (n.kind) { | ||
| case o.BRACKET_L: return this.parseList(t); | ||
| case o.BRACE_L: return this.parseObject(t); | ||
| case o.INT: return this.advanceLexer(), this.node(n, { | ||
| kind: c.INT, | ||
| value: n.value | ||
| }); | ||
| case o.FLOAT: return this.advanceLexer(), this.node(n, { | ||
| kind: c.FLOAT, | ||
| value: n.value | ||
| }); | ||
| case o.STRING: | ||
| case o.BLOCK_STRING: return this.parseStringLiteral(); | ||
| case o.NAME: switch (this.advanceLexer(), n.value) { | ||
| case "true": return this.node(n, { | ||
| kind: c.BOOLEAN, | ||
| value: !0 | ||
| }); | ||
| case "false": return this.node(n, { | ||
| kind: c.BOOLEAN, | ||
| value: !1 | ||
| }); | ||
| case "null": return this.node(n, { kind: c.NULL }); | ||
| default: return this.node(n, { | ||
| kind: c.ENUM, | ||
| value: n.value | ||
| }); | ||
| } | ||
| case o.DOLLAR: | ||
| if (t) if (this.expectToken(o.DOLLAR), this._lexer.token.kind === o.NAME) { | ||
| let i = this._lexer.token.value; | ||
| throw h(this._lexer.source, n.start, `Unexpected variable "$${i}" in constant value.`); | ||
| } else throw this.unexpected(n); | ||
| return this.parseVariable(); | ||
| default: throw this.unexpected(); | ||
| } | ||
| } | ||
| parseConstValueLiteral() { | ||
| return this.parseValueLiteral(!0); | ||
| } | ||
| parseStringLiteral() { | ||
| let t = this._lexer.token; | ||
| return this.advanceLexer(), this.node(t, { | ||
| kind: c.STRING, | ||
| value: t.value, | ||
| block: t.kind === o.BLOCK_STRING | ||
| }); | ||
| } | ||
| parseList(t) { | ||
| let n = () => this.parseValueLiteral(t); | ||
| return this.node(this._lexer.token, { | ||
| kind: c.LIST, | ||
| values: this.any(o.BRACKET_L, n, o.BRACKET_R) | ||
| }); | ||
| } | ||
| parseObject(t) { | ||
| let n = () => this.parseObjectField(t); | ||
| return this.node(this._lexer.token, { | ||
| kind: c.OBJECT, | ||
| fields: this.any(o.BRACE_L, n, o.BRACE_R) | ||
| }); | ||
| } | ||
| parseObjectField(t) { | ||
| let n = this._lexer.token, i = this.parseName(); | ||
| return this.expectToken(o.COLON), this.node(n, { | ||
| kind: c.OBJECT_FIELD, | ||
| name: i, | ||
| value: this.parseValueLiteral(t) | ||
| }); | ||
| } | ||
| parseDirectives(t) { | ||
| let n = []; | ||
| for (; this.peek(o.AT);) n.push(this.parseDirective(t)); | ||
| return n; | ||
| } | ||
| parseConstDirectives() { | ||
| return this.parseDirectives(!0); | ||
| } | ||
| parseDirective(t) { | ||
| let n = this._lexer.token; | ||
| return this.expectToken(o.AT), this.node(n, { | ||
| kind: c.DIRECTIVE, | ||
| name: this.parseName(), | ||
| arguments: this.parseArguments(t) | ||
| }); | ||
| } | ||
| parseTypeReference() { | ||
| let t = this._lexer.token, n; | ||
| if (this.expectOptionalToken(o.BRACKET_L)) { | ||
| let i = this.parseTypeReference(); | ||
| this.expectToken(o.BRACKET_R), n = this.node(t, { | ||
| kind: c.LIST_TYPE, | ||
| type: i | ||
| }); | ||
| } else n = this.parseNamedType(); | ||
| return this.expectOptionalToken(o.BANG) ? this.node(t, { | ||
| kind: c.NON_NULL_TYPE, | ||
| type: n | ||
| }) : n; | ||
| } | ||
| parseNamedType() { | ||
| return this.node(this._lexer.token, { | ||
| kind: c.NAMED_TYPE, | ||
| name: this.parseName() | ||
| }); | ||
| } | ||
| peekDescription() { | ||
| return this.peek(o.STRING) || this.peek(o.BLOCK_STRING); | ||
| } | ||
| parseDescription() { | ||
| if (this.peekDescription()) return this.parseStringLiteral(); | ||
| } | ||
| parseSchemaDefinition() { | ||
| let t = this._lexer.token, n = this.parseDescription(); | ||
| this.expectKeyword("schema"); | ||
| let i = this.parseConstDirectives(), r = this.many(o.BRACE_L, this.parseOperationTypeDefinition, o.BRACE_R); | ||
| return this.node(t, { | ||
| kind: c.SCHEMA_DEFINITION, | ||
| description: n, | ||
| directives: i, | ||
| operationTypes: r | ||
| }); | ||
| } | ||
| parseOperationTypeDefinition() { | ||
| let t = this._lexer.token, n = this.parseOperationType(); | ||
| this.expectToken(o.COLON); | ||
| let i = this.parseNamedType(); | ||
| return this.node(t, { | ||
| kind: c.OPERATION_TYPE_DEFINITION, | ||
| operation: n, | ||
| type: i | ||
| }); | ||
| } | ||
| parseScalarTypeDefinition() { | ||
| let t = this._lexer.token, n = this.parseDescription(); | ||
| this.expectKeyword("scalar"); | ||
| let i = this.parseName(), r = this.parseConstDirectives(); | ||
| return this.node(t, { | ||
| kind: c.SCALAR_TYPE_DEFINITION, | ||
| description: n, | ||
| name: i, | ||
| directives: r | ||
| }); | ||
| } | ||
| parseObjectTypeDefinition() { | ||
| let t = this._lexer.token, n = this.parseDescription(); | ||
| this.expectKeyword("type"); | ||
| let i = this.parseName(), r = this.parseImplementsInterfaces(), s = this.parseConstDirectives(), a = this.parseFieldsDefinition(); | ||
| return this.node(t, { | ||
| kind: c.OBJECT_TYPE_DEFINITION, | ||
| description: n, | ||
| name: i, | ||
| interfaces: r, | ||
| directives: s, | ||
| fields: a | ||
| }); | ||
| } | ||
| parseImplementsInterfaces() { | ||
| return this.expectOptionalKeyword("implements") ? this.delimitedMany(o.AMP, this.parseNamedType) : []; | ||
| } | ||
| parseFieldsDefinition() { | ||
| return this.optionalMany(o.BRACE_L, this.parseFieldDefinition, o.BRACE_R); | ||
| } | ||
| parseFieldDefinition() { | ||
| let t = this._lexer.token, n = this.parseDescription(), i = this.parseName(), r = this.parseArgumentDefs(); | ||
| this.expectToken(o.COLON); | ||
| let s = this.parseTypeReference(), a = this.parseConstDirectives(); | ||
| return this.node(t, { | ||
| kind: c.FIELD_DEFINITION, | ||
| description: n, | ||
| name: i, | ||
| arguments: r, | ||
| type: s, | ||
| directives: a | ||
| }); | ||
| } | ||
| parseArgumentDefs() { | ||
| return this.optionalMany(o.PAREN_L, this.parseInputValueDef, o.PAREN_R); | ||
| } | ||
| parseInputValueDef() { | ||
| let t = this._lexer.token, n = this.parseDescription(), i = this.parseName(); | ||
| this.expectToken(o.COLON); | ||
| let r = this.parseTypeReference(), s; | ||
| this.expectOptionalToken(o.EQUALS) && (s = this.parseConstValueLiteral()); | ||
| let a = this.parseConstDirectives(); | ||
| return this.node(t, { | ||
| kind: c.INPUT_VALUE_DEFINITION, | ||
| description: n, | ||
| name: i, | ||
| type: r, | ||
| defaultValue: s, | ||
| directives: a | ||
| }); | ||
| } | ||
| parseInterfaceTypeDefinition() { | ||
| let t = this._lexer.token, n = this.parseDescription(); | ||
| this.expectKeyword("interface"); | ||
| let i = this.parseName(), r = this.parseImplementsInterfaces(), s = this.parseConstDirectives(), a = this.parseFieldsDefinition(); | ||
| return this.node(t, { | ||
| kind: c.INTERFACE_TYPE_DEFINITION, | ||
| description: n, | ||
| name: i, | ||
| interfaces: r, | ||
| directives: s, | ||
| fields: a | ||
| }); | ||
| } | ||
| parseUnionTypeDefinition() { | ||
| let t = this._lexer.token, n = this.parseDescription(); | ||
| this.expectKeyword("union"); | ||
| let i = this.parseName(), r = this.parseConstDirectives(), s = this.parseUnionMemberTypes(); | ||
| return this.node(t, { | ||
| kind: c.UNION_TYPE_DEFINITION, | ||
| description: n, | ||
| name: i, | ||
| directives: r, | ||
| types: s | ||
| }); | ||
| } | ||
| parseUnionMemberTypes() { | ||
| return this.expectOptionalToken(o.EQUALS) ? this.delimitedMany(o.PIPE, this.parseNamedType) : []; | ||
| } | ||
| parseEnumTypeDefinition() { | ||
| let t = this._lexer.token, n = this.parseDescription(); | ||
| this.expectKeyword("enum"); | ||
| let i = this.parseName(), r = this.parseConstDirectives(), s = this.parseEnumValuesDefinition(); | ||
| return this.node(t, { | ||
| kind: c.ENUM_TYPE_DEFINITION, | ||
| description: n, | ||
| name: i, | ||
| directives: r, | ||
| values: s | ||
| }); | ||
| } | ||
| parseEnumValuesDefinition() { | ||
| return this.optionalMany(o.BRACE_L, this.parseEnumValueDefinition, o.BRACE_R); | ||
| } | ||
| parseEnumValueDefinition() { | ||
| let t = this._lexer.token, n = this.parseDescription(), i = this.parseEnumValueName(), r = this.parseConstDirectives(); | ||
| return this.node(t, { | ||
| kind: c.ENUM_VALUE_DEFINITION, | ||
| description: n, | ||
| name: i, | ||
| directives: r | ||
| }); | ||
| } | ||
| parseEnumValueName() { | ||
| if (this._lexer.token.value === "true" || this._lexer.token.value === "false" || this._lexer.token.value === "null") throw h(this._lexer.source, this._lexer.token.start, `${ne(this._lexer.token)} is reserved and cannot be used for an enum value.`); | ||
| return this.parseName(); | ||
| } | ||
| parseInputObjectTypeDefinition() { | ||
| let t = this._lexer.token, n = this.parseDescription(); | ||
| this.expectKeyword("input"); | ||
| let i = this.parseName(), r = this.parseConstDirectives(), s = this.parseInputFieldsDefinition(); | ||
| return this.node(t, { | ||
| kind: c.INPUT_OBJECT_TYPE_DEFINITION, | ||
| description: n, | ||
| name: i, | ||
| directives: r, | ||
| fields: s | ||
| }); | ||
| } | ||
| parseInputFieldsDefinition() { | ||
| return this.optionalMany(o.BRACE_L, this.parseInputValueDef, o.BRACE_R); | ||
| } | ||
| parseTypeSystemExtension() { | ||
| let t = this._lexer.lookahead(); | ||
| if (t.kind === o.NAME) switch (t.value) { | ||
| case "schema": return this.parseSchemaExtension(); | ||
| case "scalar": return this.parseScalarTypeExtension(); | ||
| case "type": return this.parseObjectTypeExtension(); | ||
| case "interface": return this.parseInterfaceTypeExtension(); | ||
| case "union": return this.parseUnionTypeExtension(); | ||
| case "enum": return this.parseEnumTypeExtension(); | ||
| case "input": return this.parseInputObjectTypeExtension(); | ||
| } | ||
| throw this.unexpected(t); | ||
| } | ||
| parseSchemaExtension() { | ||
| let t = this._lexer.token; | ||
| this.expectKeyword("extend"), this.expectKeyword("schema"); | ||
| let n = this.parseConstDirectives(), i = this.optionalMany(o.BRACE_L, this.parseOperationTypeDefinition, o.BRACE_R); | ||
| if (n.length === 0 && i.length === 0) throw this.unexpected(); | ||
| return this.node(t, { | ||
| kind: c.SCHEMA_EXTENSION, | ||
| directives: n, | ||
| operationTypes: i | ||
| }); | ||
| } | ||
| parseScalarTypeExtension() { | ||
| let t = this._lexer.token; | ||
| this.expectKeyword("extend"), this.expectKeyword("scalar"); | ||
| let n = this.parseName(), i = this.parseConstDirectives(); | ||
| if (i.length === 0) throw this.unexpected(); | ||
| return this.node(t, { | ||
| kind: c.SCALAR_TYPE_EXTENSION, | ||
| name: n, | ||
| directives: i | ||
| }); | ||
| } | ||
| parseObjectTypeExtension() { | ||
| let t = this._lexer.token; | ||
| this.expectKeyword("extend"), this.expectKeyword("type"); | ||
| let n = this.parseName(), i = this.parseImplementsInterfaces(), r = this.parseConstDirectives(), s = this.parseFieldsDefinition(); | ||
| if (i.length === 0 && r.length === 0 && s.length === 0) throw this.unexpected(); | ||
| return this.node(t, { | ||
| kind: c.OBJECT_TYPE_EXTENSION, | ||
| name: n, | ||
| interfaces: i, | ||
| directives: r, | ||
| fields: s | ||
| }); | ||
| } | ||
| parseInterfaceTypeExtension() { | ||
| let t = this._lexer.token; | ||
| this.expectKeyword("extend"), this.expectKeyword("interface"); | ||
| let n = this.parseName(), i = this.parseImplementsInterfaces(), r = this.parseConstDirectives(), s = this.parseFieldsDefinition(); | ||
| if (i.length === 0 && r.length === 0 && s.length === 0) throw this.unexpected(); | ||
| return this.node(t, { | ||
| kind: c.INTERFACE_TYPE_EXTENSION, | ||
| name: n, | ||
| interfaces: i, | ||
| directives: r, | ||
| fields: s | ||
| }); | ||
| } | ||
| parseUnionTypeExtension() { | ||
| let t = this._lexer.token; | ||
| this.expectKeyword("extend"), this.expectKeyword("union"); | ||
| let n = this.parseName(), i = this.parseConstDirectives(), r = this.parseUnionMemberTypes(); | ||
| if (i.length === 0 && r.length === 0) throw this.unexpected(); | ||
| return this.node(t, { | ||
| kind: c.UNION_TYPE_EXTENSION, | ||
| name: n, | ||
| directives: i, | ||
| types: r | ||
| }); | ||
| } | ||
| parseEnumTypeExtension() { | ||
| let t = this._lexer.token; | ||
| this.expectKeyword("extend"), this.expectKeyword("enum"); | ||
| let n = this.parseName(), i = this.parseConstDirectives(), r = this.parseEnumValuesDefinition(); | ||
| if (i.length === 0 && r.length === 0) throw this.unexpected(); | ||
| return this.node(t, { | ||
| kind: c.ENUM_TYPE_EXTENSION, | ||
| name: n, | ||
| directives: i, | ||
| values: r | ||
| }); | ||
| } | ||
| parseInputObjectTypeExtension() { | ||
| let t = this._lexer.token; | ||
| this.expectKeyword("extend"), this.expectKeyword("input"); | ||
| let n = this.parseName(), i = this.parseConstDirectives(), r = this.parseInputFieldsDefinition(); | ||
| if (i.length === 0 && r.length === 0) throw this.unexpected(); | ||
| return this.node(t, { | ||
| kind: c.INPUT_OBJECT_TYPE_EXTENSION, | ||
| name: n, | ||
| directives: i, | ||
| fields: r | ||
| }); | ||
| } | ||
| parseDirectiveDefinition() { | ||
| let t = this._lexer.token, n = this.parseDescription(); | ||
| this.expectKeyword("directive"), this.expectToken(o.AT); | ||
| let i = this.parseName(), r = this.parseArgumentDefs(), s = this.expectOptionalKeyword("repeatable"); | ||
| this.expectKeyword("on"); | ||
| let a = this.parseDirectiveLocations(); | ||
| return this.node(t, { | ||
| kind: c.DIRECTIVE_DEFINITION, | ||
| description: n, | ||
| name: i, | ||
| arguments: r, | ||
| repeatable: s, | ||
| locations: a | ||
| }); | ||
| } | ||
| parseDirectiveLocations() { | ||
| return this.delimitedMany(o.PIPE, this.parseDirectiveLocation); | ||
| } | ||
| parseDirectiveLocation() { | ||
| let t = this._lexer.token, n = this.parseName(); | ||
| if (Object.prototype.hasOwnProperty.call(W, n.value)) return n; | ||
| throw this.unexpected(t); | ||
| } | ||
| parseSchemaCoordinate() { | ||
| let t = this._lexer.token, n = this.expectOptionalToken(o.AT), i = this.parseName(), r; | ||
| !n && this.expectOptionalToken(o.DOT) && (r = this.parseName()); | ||
| let s; | ||
| return (n || r) && this.expectOptionalToken(o.PAREN_L) && (s = this.parseName(), this.expectToken(o.COLON), this.expectToken(o.PAREN_R)), n ? s ? this.node(t, { | ||
| kind: c.DIRECTIVE_ARGUMENT_COORDINATE, | ||
| name: i, | ||
| argumentName: s | ||
| }) : this.node(t, { | ||
| kind: c.DIRECTIVE_COORDINATE, | ||
| name: i | ||
| }) : r ? s ? this.node(t, { | ||
| kind: c.ARGUMENT_COORDINATE, | ||
| name: i, | ||
| fieldName: r, | ||
| argumentName: s | ||
| }) : this.node(t, { | ||
| kind: c.MEMBER_COORDINATE, | ||
| name: i, | ||
| memberName: r | ||
| }) : this.node(t, { | ||
| kind: c.TYPE_COORDINATE, | ||
| name: i | ||
| }); | ||
| } | ||
| node(t, n) { | ||
| return this._options.noLocation !== !0 && (n.loc = new H(t, this._lexer.lastToken, this._lexer.source)), n; | ||
| } | ||
| peek(t) { | ||
| return this._lexer.token.kind === t; | ||
| } | ||
| expectToken(t) { | ||
| let n = this._lexer.token; | ||
| if (n.kind === t) return this.advanceLexer(), n; | ||
| throw h(this._lexer.source, n.start, `Expected ${at(t)}, found ${ne(n)}.`); | ||
| } | ||
| expectOptionalToken(t) { | ||
| return this._lexer.token.kind === t ? (this.advanceLexer(), !0) : !1; | ||
| } | ||
| expectKeyword(t) { | ||
| let n = this._lexer.token; | ||
| if (n.kind === o.NAME && n.value === t) this.advanceLexer(); | ||
| else throw h(this._lexer.source, n.start, `Expected "${t}", found ${ne(n)}.`); | ||
| } | ||
| expectOptionalKeyword(t) { | ||
| let n = this._lexer.token; | ||
| return n.kind === o.NAME && n.value === t ? (this.advanceLexer(), !0) : !1; | ||
| } | ||
| unexpected(t) { | ||
| let n = t ?? this._lexer.token; | ||
| return h(this._lexer.source, n.start, `Unexpected ${ne(n)}.`); | ||
| } | ||
| any(t, n, i) { | ||
| this.expectToken(t); | ||
| let r = []; | ||
| for (; !this.expectOptionalToken(i);) r.push(n.call(this)); | ||
| return r; | ||
| } | ||
| optionalMany(t, n, i) { | ||
| if (this.expectOptionalToken(t)) { | ||
| let r = []; | ||
| do | ||
| r.push(n.call(this)); | ||
| while (!this.expectOptionalToken(i)); | ||
| return r; | ||
| } | ||
| return []; | ||
| } | ||
| many(t, n, i) { | ||
| this.expectToken(t); | ||
| let r = []; | ||
| do | ||
| r.push(n.call(this)); | ||
| while (!this.expectOptionalToken(i)); | ||
| return r; | ||
| } | ||
| delimitedMany(t, n) { | ||
| this.expectOptionalToken(t); | ||
| let i = []; | ||
| do | ||
| i.push(n.call(this)); | ||
| while (this.expectOptionalToken(t)); | ||
| return i; | ||
| } | ||
| advanceLexer() { | ||
| let { maxTokens: t } = this._options, n = this._lexer.advance(); | ||
| if (n.kind !== o.EOF && (++this._tokenCounter, t !== void 0 && this._tokenCounter > t)) throw h(this._lexer.source, n.start, `Document contains more that ${t} tokens. Parsing aborted.`); | ||
| } | ||
| }; | ||
| ct = Wt; | ||
| Kt = { allowLegacyFragmentVariables: !0 }; | ||
| tn = { | ||
| parse: en, | ||
| astFormat: "graphql", | ||
| hasPragma: Fe, | ||
| hasIgnorePragma: Me, | ||
| locStart: J, | ||
| locEnd: q | ||
| }; | ||
| nn = { graphql: Ge }; | ||
| }))(); | ||
| export { ut as default, Ye as languages, $e as options, he as parsers, nn as printers }; |
Sorry, the diff of this file is too big to display
| import { i as saveOxfmtrcFile, n as exitWithError, r as hasOxfmtrcFile, t as createBlankOxfmtrcFile } from "./shared-BtJbjkue.js"; | ||
| //#region src-js/cli/migration/init.ts | ||
| /** | ||
| * Run the `--init` command to scaffold a default `.oxfmtrc.json` file. | ||
| */ | ||
| async function runInit() { | ||
| const cwd = process.cwd(); | ||
| if (await hasOxfmtrcFile(cwd)) return exitWithError("Oxfmt configuration file already exists."); | ||
| const oxfmtrc = await createBlankOxfmtrcFile(cwd); | ||
| const jsonStr = JSON.stringify(oxfmtrc, null, 2); | ||
| try { | ||
| await saveOxfmtrcFile(cwd, jsonStr); | ||
| console.log("Created `.oxfmtrc.json`."); | ||
| } catch { | ||
| return exitWithError("Failed to create `.oxfmtrc.json`."); | ||
| } | ||
| } | ||
| //#endregion | ||
| export { runInit }; |
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 { i as saveOxfmtrcFile, n as exitWithError, r as hasOxfmtrcFile, t as createBlankOxfmtrcFile } from "./shared-BtJbjkue.js"; | ||
| import { join } from "node:path"; | ||
| import { readFile } from "node:fs/promises"; | ||
| //#region src-js/cli/migration/migrate-biome.ts | ||
| const BIOME_DEFAULTS = { | ||
| lineWidth: 80, | ||
| indentStyle: "tab", | ||
| indentWidth: 2, | ||
| lineEnding: "lf", | ||
| attributePosition: "auto", | ||
| bracketSpacing: true, | ||
| quoteStyle: "double", | ||
| jsxQuoteStyle: "double", | ||
| quoteProperties: "asNeeded", | ||
| trailingCommas: "all", | ||
| semicolons: "always", | ||
| arrowParentheses: "always", | ||
| bracketSameLine: false | ||
| }; | ||
| /** | ||
| * Run the `--migrate biome` command to migrate Biome's config to `.oxfmtrc.json` file. | ||
| * https://biomejs.dev/reference/configuration/ | ||
| */ | ||
| async function runMigrateBiome() { | ||
| const cwd = process.cwd(); | ||
| if (await hasOxfmtrcFile(cwd)) return exitWithError("Oxfmt configuration file already exists."); | ||
| const biomeConfigPath = await resolveBiomeConfigFile(cwd); | ||
| if (!biomeConfigPath) { | ||
| console.log("No Biome configuration file found."); | ||
| const oxfmtrc = await createBlankOxfmtrcFile(cwd); | ||
| const jsonStr = JSON.stringify(oxfmtrc, null, 2); | ||
| try { | ||
| await saveOxfmtrcFile(cwd, jsonStr); | ||
| console.log("Created `.oxfmtrc.json` instead."); | ||
| } catch { | ||
| exitWithError("Failed to create `.oxfmtrc.json`."); | ||
| } | ||
| return; | ||
| } | ||
| let biomeConfig; | ||
| try { | ||
| biomeConfig = parseJSONC(await readFile(biomeConfigPath, "utf8")); | ||
| console.log("Found Biome configuration at:", biomeConfigPath); | ||
| } catch { | ||
| return exitWithError(`Failed to parse: ${biomeConfigPath}`); | ||
| } | ||
| const oxfmtrc = await createBlankOxfmtrcFile(cwd); | ||
| const formatterConfig = biomeConfig.formatter ?? {}; | ||
| const jsFormatterConfig = biomeConfig.javascript?.formatter ?? {}; | ||
| migrateIndentStyle(formatterConfig, jsFormatterConfig, oxfmtrc); | ||
| migrateIndentWidth(formatterConfig, jsFormatterConfig, oxfmtrc); | ||
| migrateLineWidth(formatterConfig, jsFormatterConfig, oxfmtrc); | ||
| migrateQuoteStyle(jsFormatterConfig, oxfmtrc); | ||
| migrateJsxQuoteStyle(jsFormatterConfig, oxfmtrc); | ||
| migrateQuoteProperties(jsFormatterConfig, oxfmtrc); | ||
| migrateTrailingCommas(jsFormatterConfig, oxfmtrc); | ||
| migrateSemicolons(jsFormatterConfig, oxfmtrc); | ||
| migrateArrowParentheses(jsFormatterConfig, oxfmtrc); | ||
| migrateBracketSameLine(formatterConfig, jsFormatterConfig, oxfmtrc); | ||
| migrateBracketSpacing(formatterConfig, jsFormatterConfig, oxfmtrc); | ||
| migrateAttributePosition(formatterConfig, jsFormatterConfig, oxfmtrc); | ||
| const ignores = extractIgnorePatterns(biomeConfig); | ||
| if (ignores.length > 0) console.log("Migrated ignore patterns from Biome config"); | ||
| delete oxfmtrc.ignorePatterns; | ||
| oxfmtrc.ignorePatterns = ignores; | ||
| if (biomeConfig.overrides && biomeConfig.overrides.length > 0) console.warn(` - "overrides" cannot be migrated automatically yet`); | ||
| const jsonStr = JSON.stringify(oxfmtrc, null, 2); | ||
| try { | ||
| await saveOxfmtrcFile(cwd, jsonStr); | ||
| console.log("Created `.oxfmtrc.json`."); | ||
| } catch { | ||
| return exitWithError("Failed to create `.oxfmtrc.json`."); | ||
| } | ||
| } | ||
| async function resolveBiomeConfigFile(cwd) { | ||
| for (const filename of ["biome.json", "biome.jsonc"]) { | ||
| const filepath = join(cwd, filename); | ||
| try { | ||
| await readFile(filepath, "utf8"); | ||
| return filepath; | ||
| } catch {} | ||
| } | ||
| return null; | ||
| } | ||
| const stringOrCommentRe = /("(?:\\?[^])*?")|(\/\/.*)|(\/\*[^]*?\*\/)/g; | ||
| const stringOrTrailingCommaRe = /("(?:\\?[^])*?")|(,\s*)(?=]|})/g; | ||
| function parseJSONC(text) { | ||
| text = String(text); | ||
| try { | ||
| return JSON.parse(text); | ||
| } catch { | ||
| return JSON.parse(text.replace(stringOrCommentRe, "$1").replace(stringOrTrailingCommaRe, "$1")); | ||
| } | ||
| } | ||
| function migrateIndentStyle(formatterConfig, jsFormatterConfig, oxfmtrc) { | ||
| const value = jsFormatterConfig.indentStyle ?? formatterConfig.indentStyle; | ||
| if (value !== void 0) oxfmtrc.useTabs = value === "tab"; | ||
| else oxfmtrc.useTabs = BIOME_DEFAULTS.indentStyle === "tab"; | ||
| } | ||
| function migrateIndentWidth(formatterConfig, jsFormatterConfig, oxfmtrc) { | ||
| const value = jsFormatterConfig.indentWidth ?? formatterConfig.indentWidth; | ||
| if (value !== void 0) oxfmtrc.tabWidth = value; | ||
| else oxfmtrc.tabWidth = BIOME_DEFAULTS.indentWidth; | ||
| } | ||
| function migrateLineWidth(formatterConfig, jsFormatterConfig, oxfmtrc) { | ||
| const value = jsFormatterConfig.lineWidth ?? formatterConfig.lineWidth; | ||
| if (value !== void 0) oxfmtrc.printWidth = value; | ||
| else oxfmtrc.printWidth = BIOME_DEFAULTS.lineWidth; | ||
| } | ||
| function migrateQuoteStyle(jsFormatterConfig, oxfmtrc) { | ||
| const value = jsFormatterConfig.quoteStyle; | ||
| if (value !== void 0) oxfmtrc.singleQuote = value === "single"; | ||
| else oxfmtrc.singleQuote = false; | ||
| } | ||
| function migrateJsxQuoteStyle(jsFormatterConfig, oxfmtrc) { | ||
| const value = jsFormatterConfig.jsxQuoteStyle; | ||
| if (value !== void 0) oxfmtrc.jsxSingleQuote = value === "single"; | ||
| else oxfmtrc.jsxSingleQuote = false; | ||
| } | ||
| function migrateQuoteProperties(jsFormatterConfig, oxfmtrc) { | ||
| const value = jsFormatterConfig.quoteProperties; | ||
| if (value !== void 0) { | ||
| if (value === "asNeeded") oxfmtrc.quoteProps = "as-needed"; | ||
| else if (value === "preserve") oxfmtrc.quoteProps = "preserve"; | ||
| } else oxfmtrc.quoteProps = "as-needed"; | ||
| } | ||
| function migrateTrailingCommas(jsFormatterConfig, oxfmtrc) { | ||
| const value = jsFormatterConfig.trailingCommas; | ||
| if (value !== void 0) oxfmtrc.trailingComma = value; | ||
| else oxfmtrc.trailingComma = BIOME_DEFAULTS.trailingCommas; | ||
| } | ||
| function migrateSemicolons(jsFormatterConfig, oxfmtrc) { | ||
| const value = jsFormatterConfig.semicolons; | ||
| if (value !== void 0) oxfmtrc.semi = value === "always"; | ||
| else oxfmtrc.semi = BIOME_DEFAULTS.semicolons === "always"; | ||
| } | ||
| function migrateArrowParentheses(jsFormatterConfig, oxfmtrc) { | ||
| const value = jsFormatterConfig.arrowParentheses; | ||
| if (value !== void 0) { | ||
| if (value === "always") oxfmtrc.arrowParens = "always"; | ||
| else if (value === "asNeeded") oxfmtrc.arrowParens = "avoid"; | ||
| } else oxfmtrc.arrowParens = BIOME_DEFAULTS.arrowParentheses === "always" ? "always" : "avoid"; | ||
| } | ||
| function migrateBracketSameLine(_formatterConfig, jsFormatterConfig, oxfmtrc) { | ||
| const value = jsFormatterConfig.bracketSameLine; | ||
| if (value !== void 0) oxfmtrc.bracketSameLine = value; | ||
| else oxfmtrc.bracketSameLine = BIOME_DEFAULTS.bracketSameLine; | ||
| } | ||
| function migrateBracketSpacing(formatterConfig, jsFormatterConfig, oxfmtrc) { | ||
| const value = jsFormatterConfig.bracketSpacing ?? formatterConfig.bracketSpacing; | ||
| if (value !== void 0) oxfmtrc.bracketSpacing = value; | ||
| else oxfmtrc.bracketSpacing = BIOME_DEFAULTS.bracketSpacing; | ||
| } | ||
| function migrateAttributePosition(formatterConfig, jsFormatterConfig, oxfmtrc) { | ||
| const value = jsFormatterConfig.attributePosition ?? formatterConfig.attributePosition; | ||
| if (value !== void 0) if (value === "multiline") oxfmtrc.singleAttributePerLine = true; | ||
| else oxfmtrc.singleAttributePerLine = false; | ||
| } | ||
| function extractIgnorePatterns(biomeConfig) { | ||
| const ignores = []; | ||
| if (biomeConfig.files?.includes) { | ||
| for (const pattern of biomeConfig.files.includes) if (pattern.startsWith("!") && !pattern.startsWith("!!")) ignores.push(pattern.slice(1)); | ||
| } | ||
| return ignores; | ||
| } | ||
| //#endregion | ||
| export { runMigrateBiome }; |
| import { i as saveOxfmtrcFile, n as exitWithError, r as hasOxfmtrcFile, t as createBlankOxfmtrcFile } from "./shared-BtJbjkue.js"; | ||
| import { join } from "node:path"; | ||
| import { readFile } from "node:fs/promises"; | ||
| //#region src-js/cli/migration/migrate-prettier.ts | ||
| /** | ||
| * Run the `--migrate prettier` command to migrate various Prettier's config to `.oxfmtrc.json` file. | ||
| * https://prettier.io/docs/configuration | ||
| */ | ||
| async function runMigratePrettier() { | ||
| const cwd = process.cwd(); | ||
| if (await hasOxfmtrcFile(cwd)) return exitWithError("Oxfmt configuration file already exists."); | ||
| const { resolveConfigFile, resolveConfig } = await import("./prettier-Cw36juP9.js"); | ||
| const prettierConfigPath = await resolveConfigFile(join(cwd, "dummy.js")); | ||
| if (!prettierConfigPath) { | ||
| console.log("No Prettier configuration file found."); | ||
| const oxfmtrc = await createBlankOxfmtrcFile(cwd); | ||
| const jsonStr = JSON.stringify(oxfmtrc, null, 2); | ||
| try { | ||
| await saveOxfmtrcFile(cwd, jsonStr); | ||
| console.log("Created `.oxfmtrc.json` instead."); | ||
| } catch { | ||
| exitWithError("Failed to create `.oxfmtrc.json`."); | ||
| } | ||
| return; | ||
| } | ||
| let prettierConfig; | ||
| try { | ||
| prettierConfig = await resolveConfig(prettierConfigPath, { editorconfig: false }); | ||
| console.log("Found Prettier configuration at:", prettierConfigPath); | ||
| } catch { | ||
| return exitWithError(`Failed to parse: ${prettierConfigPath}`); | ||
| } | ||
| const oxfmtrc = await createBlankOxfmtrcFile(cwd); | ||
| let hasSortPackageJsonPlugin = false; | ||
| for (const [key, value] of Object.entries(prettierConfig ?? {})) { | ||
| if (key === "plugins" && Array.isArray(value)) { | ||
| for (const plugin of value) if (plugin === "prettier-plugin-tailwindcss") migrateTailwindOptions(prettierConfig, oxfmtrc); | ||
| else if (plugin === "prettier-plugin-packagejson") hasSortPackageJsonPlugin = true; | ||
| else if (typeof plugin === "string") console.error(` - plugins: "${plugin}" is not supported, skipping...`); | ||
| else console.error(` - plugins: custom plugin module is not supported, skipping...`); | ||
| continue; | ||
| } | ||
| if (key === "endOfLine" && value === "auto") { | ||
| console.error(` - "endOfLine: auto" is not supported, skipping...`); | ||
| continue; | ||
| } | ||
| if (key === "experimentalTernaries" || key === "experimentalOperatorPosition") { | ||
| console.error(` - "${key}" is not supported in JS/TS files yet`); | ||
| continue; | ||
| } | ||
| if (key.startsWith("tailwind")) continue; | ||
| oxfmtrc[key] = value; | ||
| } | ||
| if (typeof oxfmtrc.printWidth !== "number") { | ||
| console.error(` - "printWidth" is not set in Prettier config, defaulting to 80 (Oxfmt default: 100)`); | ||
| oxfmtrc.printWidth = 80; | ||
| } | ||
| if (hasSortPackageJsonPlugin) { | ||
| oxfmtrc.sortPackageJson = {}; | ||
| console.error(` - Migrated "prettier-plugin-packagejson" to "sortPackageJson"`); | ||
| } else oxfmtrc.sortPackageJson = false; | ||
| if (oxfmtrc.embeddedLanguageFormatting !== "off") console.error(` - "embeddedLanguageFormatting" in JS/TS files is not fully supported yet`); | ||
| const ignores = await resolvePrettierIgnore(cwd); | ||
| if (ignores.length > 0) console.log("Migrated ignore patterns from `.prettierignore`"); | ||
| delete oxfmtrc.ignorePatterns; | ||
| oxfmtrc.ignorePatterns = ignores; | ||
| if ("overrides" in oxfmtrc) console.warn(` - "overrides" cannot be migrated automatically. See: https://github.com/oxc-project/oxc/issues/18215`); | ||
| const jsonStr = JSON.stringify(oxfmtrc, null, 2); | ||
| try { | ||
| await saveOxfmtrcFile(cwd, jsonStr); | ||
| console.log("Created `.oxfmtrc.json`."); | ||
| } catch { | ||
| return exitWithError("Failed to create `.oxfmtrc.json`."); | ||
| } | ||
| } | ||
| async function resolvePrettierIgnore(cwd) { | ||
| const ignores = []; | ||
| try { | ||
| const lines = (await readFile(join(cwd, ".prettierignore"), "utf8")).split("\n"); | ||
| for (let line of lines) { | ||
| line = line.trim(); | ||
| if (line === "" || line.startsWith("#")) continue; | ||
| ignores.push(line); | ||
| } | ||
| } catch {} | ||
| return ignores; | ||
| } | ||
| const TAILWIND_OPTION_MAPPING = { | ||
| config: "tailwindConfig", | ||
| stylesheet: "tailwindStylesheet", | ||
| functions: "tailwindFunctions", | ||
| attributes: "tailwindAttributes", | ||
| preserveWhitespace: "tailwindPreserveWhitespace", | ||
| preserveDuplicates: "tailwindPreserveDuplicates" | ||
| }; | ||
| /** | ||
| * Migrate prettier-plugin-tailwindcss options to Oxfmt's sortTailwindcss format. | ||
| * | ||
| * Prettier format: | ||
| * ```json | ||
| * { | ||
| * "plugins": ["prettier-plugin-tailwindcss"], | ||
| * "tailwindConfig": "./tailwind.config.js", | ||
| * "tailwindFunctions": ["clsx", "cn"] | ||
| * } | ||
| * ``` | ||
| * | ||
| * Oxfmt format: | ||
| * ```json | ||
| * { | ||
| * "sortTailwindcss": { | ||
| * "config": "./tailwind.config.js", | ||
| * "functions": ["clsx", "cn"] | ||
| * } | ||
| * } | ||
| * ``` | ||
| */ | ||
| function migrateTailwindOptions(prettierConfig, oxfmtrc) { | ||
| const tailwindOptions = {}; | ||
| for (const [oxfmtKey, prettierKey] of Object.entries(TAILWIND_OPTION_MAPPING)) { | ||
| const value = prettierConfig[prettierKey]; | ||
| if (value !== void 0) { | ||
| if ((prettierKey == "tailwindFunctions" || prettierKey == "tailwindAttributes") && Array.isArray(value)) { | ||
| for (const item of value) if (typeof item === "string" && item.startsWith("/") && item.endsWith("/")) { | ||
| console.warn(` - Do not support regex in "${prettierKey}" option yet, skipping: ${item}`); | ||
| continue; | ||
| } | ||
| } | ||
| tailwindOptions[oxfmtKey] = value; | ||
| } | ||
| } | ||
| oxfmtrc.sortTailwindcss = tailwindOptions; | ||
| console.log("Migrated prettier-plugin-tailwindcss options to sortTailwindcss"); | ||
| } | ||
| //#endregion | ||
| export { runMigratePrettier }; |
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 { jsTextToDoc } from "./index.js"; | ||
| //#region src-js/libs/prettier-plugin-oxfmt/text-to-doc.ts | ||
| const textToDoc = async (embeddedSourceText, textToDocOptions) => { | ||
| const { parser, parentParser, filepath, _oxfmtPluginOptionsJson } = textToDocOptions; | ||
| const docJSON = await jsTextToDoc(parser === "typescript" || parser === "babel-ts" ? filepath?.endsWith(".tsx") ? "tsx" : "ts" : "jsx", embeddedSourceText, _oxfmtPluginOptionsJson, detectParentContext(parentParser, textToDocOptions)); | ||
| if (docJSON === null) throw new Error("`oxfmt::textToDoc()` failed. Use `OXC_LOG` env var to see Rust-side logs."); | ||
| const { doc, refs } = JSON.parse(docJSON); | ||
| if (refs.length === 0) return doc; | ||
| return resolveRefs(doc, refs, Array.from({ length: refs.length })); | ||
| }; | ||
| /** | ||
| * Rust emits `Interned` sub-trees once into `refs` and references them via `{ _REF: <id> }` placeholders, | ||
| * preventing exponential JSON blowup when the same sub-tree is duplicated variants. | ||
| * | ||
| * Restore shared object references so Prettier sees the original (memory-shared) structure. | ||
| * Identity does not affect output because Prettier identifies groups by their `id` field, | ||
| * not by JS object identity. | ||
| * | ||
| * The `_REF` key (uppercase, prefixed) is chosen to never collide with valid Prettier Doc node keys, | ||
| * so the `typeof obj._REF === "number"` check uniquely identifies placeholders. | ||
| * | ||
| * Refs are resolved on-demand with memoization. | ||
| * A ref `i` may reference any other ref `j` (including `j < i`) because Rust caches `Interned` by pointer | ||
| * and an earlier-encountered `Interned` (smaller id) can also appear inside a later one's content. | ||
| * Topological / reverse-order resolution would observe `undefined` holes, so we recurse lazily. | ||
| */ | ||
| function resolveRefs(node, rawRefs, cache) { | ||
| if (node === null || typeof node !== "object") return node; | ||
| if (Array.isArray(node)) return node.map((n) => resolveRefs(n, rawRefs, cache)); | ||
| const obj = node; | ||
| if (typeof obj._REF === "number") { | ||
| const id = obj._REF; | ||
| const cached = cache[id]; | ||
| if (cached !== void 0) return cached; | ||
| const resolved = resolveRefs(rawRefs[id], rawRefs, cache); | ||
| cache[id] = resolved; | ||
| return resolved; | ||
| } | ||
| const out = {}; | ||
| for (const k in obj) out[k] = resolveRefs(obj[k], rawRefs, cache); | ||
| return out; | ||
| } | ||
| /** | ||
| * Detects Vue fragment mode from Prettier's internal flags. | ||
| * | ||
| * When Prettier formats Vue SFC templates, it calls textToDoc with special flags: | ||
| * - `__isVueForBindingLeft`: v-for left-hand side (e.g., `(item, index)` in `v-for="(item, index) in items"`) | ||
| * - `__isVueBindings`: v-slot bindings (e.g., `{ item }` in `#default="{ item }"`) | ||
| * - `__isEmbeddedTypescriptGenericParameters`: `<script generic="...">` type parameters | ||
| */ | ||
| function detectParentContext(parentParser, options) { | ||
| if (parentParser === "vue") { | ||
| if ("__isVueForBindingLeft" in options) return "vue-for-binding-left"; | ||
| if ("__isVueBindings" in options) return "vue-bindings"; | ||
| if ("__isEmbeddedTypescriptGenericParameters" in options) return "vue-script-generic"; | ||
| return "vue-script"; | ||
| } | ||
| if (parentParser === "svelte") return "svelte-script"; | ||
| return parentParser; | ||
| } | ||
| //#endregion | ||
| //#region src-js/libs/prettier-plugin-oxfmt/index.ts | ||
| /** | ||
| * Prettier plugin that uses `oxc_formatter` for (j|t)s-in-xxx part. | ||
| * | ||
| * When Prettier formats Vue/HTML (which can embed JS/TS code inside) files, | ||
| * it calls the `embed()` function for each block. | ||
| * | ||
| * By default, it uses the `babel` or `typescript` parser and `estree` printer. | ||
| * Therefore, by overriding these internally, we can use `oxc_formatter` instead. | ||
| * e.g. Now it's possible to apply our builtin sort-imports for JS/TS code inside Vue `<script>`. | ||
| */ | ||
| const options = { _oxfmtPluginOptionsJson: { | ||
| category: "JavaScript", | ||
| type: "string", | ||
| default: "{}", | ||
| description: "Bundled JSON string for oxfmt-plugin options" | ||
| } }; | ||
| const oxfmtParser = { | ||
| parse: textToDoc, | ||
| astFormat: "OXFMT", | ||
| locStart: () => -1, | ||
| locEnd: () => -1 | ||
| }; | ||
| const parsers = { | ||
| babel: oxfmtParser, | ||
| "babel-ts": oxfmtParser, | ||
| typescript: oxfmtParser | ||
| }; | ||
| const printers = { OXFMT: { print: ({ node }) => node } }; | ||
| //#endregion | ||
| export { options, parsers, printers }; |
| import { join } from "node:path"; | ||
| import { stat, writeFile } from "node:fs/promises"; | ||
| //#region src-js/cli/migration/shared.ts | ||
| async function hasOxfmtrcFile(cwd) { | ||
| return await isFile(join(cwd, ".oxfmtrc.json")) || await isFile(join(cwd, ".oxfmtrc.jsonc")); | ||
| } | ||
| const SCHEMA_RELATIVE_PATH = "./node_modules/oxfmt/configuration_schema.json"; | ||
| async function hasSchemaFile(cwd) { | ||
| return await isFile(join(cwd, "node_modules/oxfmt/configuration_schema.json")) ? SCHEMA_RELATIVE_PATH : null; | ||
| } | ||
| async function createBlankOxfmtrcFile(cwd) { | ||
| const config = { | ||
| $schema: await hasSchemaFile(cwd), | ||
| ignorePatterns: [] | ||
| }; | ||
| if (config.$schema === null) delete config.$schema; | ||
| return config; | ||
| } | ||
| async function saveOxfmtrcFile(cwd, jsonStr) { | ||
| await writeFile(join(cwd, ".oxfmtrc.json"), jsonStr + "\n", "utf8"); | ||
| } | ||
| function exitWithError(message) { | ||
| console.error(message); | ||
| process.exitCode = 1; | ||
| } | ||
| async function isFile(path) { | ||
| try { | ||
| return (await stat(path)).isFile(); | ||
| } catch { | ||
| return false; | ||
| } | ||
| } | ||
| //#endregion | ||
| export { saveOxfmtrcFile as i, exitWithError as n, hasOxfmtrcFile as r, createBlankOxfmtrcFile as t }; |
Sorry, the diff of this file is too big to display
| import { r as getTailwindConfig, t as createSorter } from "./sorter-BZkvDMjt-DpGe0QK9.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
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
@@ -648,3 +648,3 @@ { | ||
| "internalPattern": { | ||
| "description": "Specifies a prefix for identifying internal imports.\n\nThis is useful for distinguishing your own modules from external dependencies.\n\n- Default: `[\"~/\", \"@/\"]`", | ||
| "description": "Specifies a prefix for identifying internal imports.\n\nThis is useful for distinguishing your own modules from external dependencies.\n\n- Default: `[\"~/\", \"@/\", \"#\"]`", | ||
| "type": "array", | ||
@@ -654,3 +654,3 @@ "items": { | ||
| }, | ||
| "markdownDescription": "Specifies a prefix for identifying internal imports.\n\nThis is useful for distinguishing your own modules from external dependencies.\n\n- Default: `[\"~/\", \"@/\"]`" | ||
| "markdownDescription": "Specifies a prefix for identifying internal imports.\n\nThis is useful for distinguishing your own modules from external dependencies.\n\n- Default: `[\"~/\", \"@/\", \"#\"]`" | ||
| }, | ||
@@ -657,0 +657,0 @@ "newlinesBetween": { |
@@ -1,2 +0,2 @@ | ||
| import { a as sortTailwindClasses, n as formatEmbeddedDoc, r as formatFile, t as formatEmbeddedCode } from "./apis-By1xj7IP.js"; | ||
| import { a as sortTailwindClasses, n as formatEmbeddedDoc, r as formatFile, t as formatEmbeddedCode } from "./apis-CKvPKBJI.js"; | ||
| export { formatEmbeddedCode, formatEmbeddedDoc, formatFile, sortTailwindClasses }; |
+5
-5
@@ -1,3 +0,3 @@ | ||
| import { r as runCli } from "./bindings-Cdg_nxGV.js"; | ||
| import { i as resolvePlugins } from "./apis-By1xj7IP.js"; | ||
| import { i as resolvePlugins } from "./apis-CKvPKBJI.js"; | ||
| import { r as runCli } from "./bindings-Dj_YoR0Z.js"; | ||
| import Tinypool from "tinypool"; | ||
@@ -140,11 +140,11 @@ import { fileURLToPath, pathToFileURL } from "node:url"; | ||
| if (mode === "init") { | ||
| await import("./init-BbKOMZ57.js").then((m) => m.runInit()); | ||
| await import("./init-C3nxU_Wc.js").then((m) => m.runInit()); | ||
| return; | ||
| } | ||
| if (mode === "migrate:prettier") { | ||
| await import("./migrate-prettier-Bze9N_6F.js").then((m) => m.runMigratePrettier()); | ||
| await import("./migrate-prettier-DLfviW85.js").then((m) => m.runMigratePrettier()); | ||
| return; | ||
| } | ||
| if (mode === "migrate:biome") { | ||
| await import("./migrate-biome-BMqs7-eg.js").then((m) => m.runMigrateBiome()); | ||
| await import("./migrate-biome-DclTzwKW.js").then((m) => m.runMigrateBiome()); | ||
| return; | ||
@@ -151,0 +151,0 @@ } |
+1
-1
@@ -638,3 +638,3 @@ //#region src-js/bindings.d.ts | ||
| * | ||
| * - Default: `["~/", "@/"]` | ||
| * - Default: `["~/", "@/", "#"]` | ||
| */ | ||
@@ -641,0 +641,0 @@ internalPattern?: string[]; |
+2
-2
@@ -1,3 +0,3 @@ | ||
| import { n as jsTextToDoc$1, t as format$1 } from "./bindings-Cdg_nxGV.js"; | ||
| import { a as sortTailwindClasses, i as resolvePlugins, n as formatEmbeddedDoc, r as formatFile, t as formatEmbeddedCode } from "./apis-By1xj7IP.js"; | ||
| import { a as sortTailwindClasses, i as resolvePlugins, n as formatEmbeddedDoc, r as formatFile, t as formatEmbeddedCode } from "./apis-CKvPKBJI.js"; | ||
| import { n as jsTextToDoc$1, t as format$1 } from "./bindings-Dj_YoR0Z.js"; | ||
| //#region src-js/index.ts | ||
@@ -4,0 +4,0 @@ /** |
+20
-20
| { | ||
| "name": "oxfmt", | ||
| "version": "0.49.0", | ||
| "version": "0.50.0", | ||
| "description": "Formatter for the JavaScript Oxidation Compiler", | ||
@@ -85,22 +85,22 @@ "keywords": [ | ||
| "optionalDependencies": { | ||
| "@oxfmt/binding-darwin-arm64": "0.49.0", | ||
| "@oxfmt/binding-android-arm64": "0.49.0", | ||
| "@oxfmt/binding-win32-arm64-msvc": "0.49.0", | ||
| "@oxfmt/binding-linux-arm64-gnu": "0.49.0", | ||
| "@oxfmt/binding-linux-arm64-musl": "0.49.0", | ||
| "@oxfmt/binding-openharmony-arm64": "0.49.0", | ||
| "@oxfmt/binding-android-arm-eabi": "0.49.0", | ||
| "@oxfmt/binding-linux-arm-gnueabihf": "0.49.0", | ||
| "@oxfmt/binding-linux-arm-musleabihf": "0.49.0", | ||
| "@oxfmt/binding-win32-ia32-msvc": "0.49.0", | ||
| "@oxfmt/binding-linux-ppc64-gnu": "0.49.0", | ||
| "@oxfmt/binding-linux-riscv64-gnu": "0.49.0", | ||
| "@oxfmt/binding-linux-riscv64-musl": "0.49.0", | ||
| "@oxfmt/binding-linux-s390x-gnu": "0.49.0", | ||
| "@oxfmt/binding-darwin-x64": "0.49.0", | ||
| "@oxfmt/binding-win32-x64-msvc": "0.49.0", | ||
| "@oxfmt/binding-freebsd-x64": "0.49.0", | ||
| "@oxfmt/binding-linux-x64-gnu": "0.49.0", | ||
| "@oxfmt/binding-linux-x64-musl": "0.49.0" | ||
| "@oxfmt/binding-darwin-arm64": "0.50.0", | ||
| "@oxfmt/binding-android-arm64": "0.50.0", | ||
| "@oxfmt/binding-win32-arm64-msvc": "0.50.0", | ||
| "@oxfmt/binding-linux-arm64-gnu": "0.50.0", | ||
| "@oxfmt/binding-linux-arm64-musl": "0.50.0", | ||
| "@oxfmt/binding-openharmony-arm64": "0.50.0", | ||
| "@oxfmt/binding-android-arm-eabi": "0.50.0", | ||
| "@oxfmt/binding-linux-arm-gnueabihf": "0.50.0", | ||
| "@oxfmt/binding-linux-arm-musleabihf": "0.50.0", | ||
| "@oxfmt/binding-win32-ia32-msvc": "0.50.0", | ||
| "@oxfmt/binding-linux-ppc64-gnu": "0.50.0", | ||
| "@oxfmt/binding-linux-riscv64-gnu": "0.50.0", | ||
| "@oxfmt/binding-linux-riscv64-musl": "0.50.0", | ||
| "@oxfmt/binding-linux-s390x-gnu": "0.50.0", | ||
| "@oxfmt/binding-darwin-x64": "0.50.0", | ||
| "@oxfmt/binding-win32-x64-msvc": "0.50.0", | ||
| "@oxfmt/binding-freebsd-x64": "0.50.0", | ||
| "@oxfmt/binding-linux-x64-gnu": "0.50.0", | ||
| "@oxfmt/binding-linux-x64-musl": "0.50.0" | ||
| } | ||
| } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| import { o as __toESM } from "./chunk-HkwdBwDg.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-s1WPCGVk.js"); | ||
| const { formatOptionsHiddenDefaults } = prettier.__internal; | ||
| formatOptionsHiddenDefaults.parentParser = null; | ||
| formatOptionsHiddenDefaults.__onHtmlRoot = null; | ||
| formatOptionsHiddenDefaults.__inJsTemplate = null; | ||
| return prettier; | ||
| }); | ||
| } | ||
| /** | ||
| * TODO: Plugins support | ||
| * - Read `plugins` field | ||
| * - Load plugins dynamically and parse `languages` field | ||
| * - Map file extensions and filenames to Prettier parsers | ||
| * | ||
| * @returns Array of loaded plugin's `languages` info | ||
| */ | ||
| async function resolvePlugins() { | ||
| return []; | ||
| } | ||
| /** | ||
| * 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-Bbs0xV9H.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-l2HyESZg.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-CwlqDRt_.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-BjdgYnLg.js")); | ||
| options.plugins ??= []; | ||
| options.plugins.push(CACHES.oxfmtPlugin); | ||
| } | ||
| //#endregion | ||
| export { sortTailwindClasses as a, resolvePlugins as i, formatEmbeddedDoc as n, formatFile as r, formatEmbeddedCode as t }; |
Sorry, the diff of this file is too big to display
| import { createRequire } from "node:module"; | ||
| //#region src-js/bindings.js | ||
| const require = createRequire(import.meta.url); | ||
| new URL(".", import.meta.url).pathname; | ||
| const { readFileSync } = require("node: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 (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.49.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.49.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.49.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.49.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?.variables?.shlib_suffix === "dll.a" || 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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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.49.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(); | ||
| if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) { | ||
| let wasiBinding = null; | ||
| let wasiBindingError = null; | ||
| try { | ||
| wasiBinding = require("./oxfmt.wasi.cjs"); | ||
| nativeBinding = wasiBinding; | ||
| } catch (err) { | ||
| if (process.env.NAPI_RS_FORCE_WASI) wasiBindingError = err; | ||
| } | ||
| if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) try { | ||
| wasiBinding = require("@oxfmt/binding-wasm32-wasi"); | ||
| nativeBinding = wasiBinding; | ||
| } catch (err) { | ||
| if (process.env.NAPI_RS_FORCE_WASI) { | ||
| 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) throw 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.", { cause: loadErrors.reduce((err, cur) => { | ||
| cur.cause = err; | ||
| return cur; | ||
| }) }); | ||
| throw new Error(`Failed to load native binding`); | ||
| } | ||
| const { Severity, format, jsTextToDoc, runCli } = nativeBinding; | ||
| //#endregion | ||
| export { jsTextToDoc as n, runCli as r, format as t }; |
| import { createRequire } from "node:module"; | ||
| //#region ../../node_modules/.pnpm/prettier-plugin-tailwindcss@0.0.0-insiders.3997fbd_prettier-plugin-svelte@3.5.1_prettie_57f1f908c644a91a29f5821c3681dd20/node_modules/prettier-plugin-tailwindcss/dist/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 { createRequire } from "node:module"; | ||
| //#region \0rolldown/runtime.js | ||
| 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), cb = null), mod.exports); | ||
| var __exportAll = (all, no_symbols) => { | ||
| let target = {}; | ||
| for (var name in all) __defProp(target, name, { | ||
| get: all[name], | ||
| enumerable: true | ||
| }); | ||
| if (!no_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 __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
| var __require = /* @__PURE__ */ createRequire(import.meta.url); | ||
| //#endregion | ||
| export { __toCommonJS as a, __require as i, __esmMin as n, __toESM as o, __exportAll as r, __commonJSMin as t }; |
| import { o as __toESM } from "./chunk-HkwdBwDg.js"; | ||
| import { n as init_babel, parsers as ra, t as babel_exports } from "./babel-Cs312VeV.js"; | ||
| import index_exports, { t as init_prettier } from "./prettier-s1WPCGVk.js"; | ||
| import { a as __toESM$1, t as __commonJSMin } from "./chunk-DSjvVL_1-B3jw0SMn.js"; | ||
| import { n as loadIfExists, r as maybeResolve, t as expiringMap } from "./resolve-pWjAK-4f-BnquIxPb.js"; | ||
| import { i as visit, n as cacheForDirs, r as spliceChangesIntoString } from "./utils-D8dQkKEd-Dgy5UIHl.js"; | ||
| import { a as sortClasses, i as sortClassList, n as error, o as warn, r as getTailwindConfig$1 } from "./sorter-BZkvDMjt-y2u_e1ZW.js"; | ||
| import { parsers as fn, t as init_angular } from "./angular-z1ZEe5V_.js"; | ||
| import { n as postcss_exports, parsers as en, t as init_postcss } from "./postcss-ZbUej7DN.js"; | ||
| import * as path from "node:path"; | ||
| import { isAbsolute } from "path"; | ||
| //#region ../../node_modules/.pnpm/prettier-plugin-tailwindcss@0.0.0-insiders.3997fbd_prettier-plugin-svelte@3.5.1_prettie_57f1f908c644a91a29f5821c3681dd20/node_modules/prettier-plugin-tailwindcss/dist/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; | ||
| } | ||
| const ESCAPE_SEQUENCE_PATTERN = /\\(['"\\nrtbfv0-7xuU])/g; | ||
| function tryParseAngularAttribute(value, env) { | ||
| try { | ||
| return fn.__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 = ra["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, _node$extra4; | ||
| let result = sortClasses(node.value, { | ||
| env, | ||
| removeDuplicates, | ||
| collapseWhitespace | ||
| }); | ||
| if (!(result !== node.value)) return false; | ||
| node.value = result; | ||
| let raw = ((_node$extra3 = node.extra) === null || _node$extra3 === void 0 ? void 0 : _node$extra3.raw) ?? node.raw; | ||
| let quote = raw[0]; | ||
| let originalRawContent = raw.slice(1, -1); | ||
| let originalValue = ((_node$extra4 = node.extra) === null || _node$extra4 === void 0 ? void 0 : _node$extra4.rawValue) ?? node.value; | ||
| if (node.extra) { | ||
| if (originalRawContent !== originalValue && originalValue.includes("\\")) result = result.replace(ESCAPE_SEQUENCE_PATTERN, "\\\\$1"); | ||
| node.extra = { | ||
| ...node.extra, | ||
| rawValue: result, | ||
| raw: quote + result + quote | ||
| }; | ||
| } else node.raw = quote + result + quote; | ||
| 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 en.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; | ||
| for (let i = 0; i < attr.value.length; i++) { | ||
| let value = attr.value[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 < attr.value.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 < attr.value.length - 1 && !/\s$/.test(value.data), | ||
| removeDuplicates: true, | ||
| collapseWhitespace: false | ||
| }); | ||
| } else if (value.type === "MustacheTag") 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 ast.children ?? []) transformSvelte(child, env); | ||
| if (ast.type === "IfBlock") { | ||
| var _ast$else; | ||
| for (let child of ((_ast$else = ast.else) === null || _ast$else === void 0 ? void 0 : _ast$else.children) ?? []) transformSvelte(child, env); | ||
| } | ||
| if (ast.type === "AwaitBlock") { | ||
| let nodes = [ | ||
| ast.pending, | ||
| ast.then, | ||
| ast.catch | ||
| ]; | ||
| for (let child of nodes) transformSvelte(child, env); | ||
| } | ||
| if (ast.html) transformSvelte(ast.html, env); | ||
| } | ||
| const { parsers, printers } = createPlugin([ | ||
| defineTransform({ | ||
| staticAttrs: ["class"], | ||
| load: [{ | ||
| name: "prettier/plugins/html", | ||
| importer: () => import("./html-7pWx9LND.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-Cg8KQipT.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-Cgpjcksz.js") | ||
| }] }, | ||
| meriyah: { load: [{ | ||
| name: "prettier/plugins/meriyah", | ||
| importer: () => import("./meriyah-TC7VDz8E.js") | ||
| }] }, | ||
| acorn: { load: [{ | ||
| name: "prettier/plugins/acorn", | ||
| importer: () => import("./acorn-ay2Aj6GQ.js") | ||
| }] }, | ||
| flow: { load: [{ | ||
| name: "prettier/plugins/flow", | ||
| importer: () => import("./flow-ChhAFZSt.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-CwlqDRt_.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 { n as __esmMin } from "./chunk-HkwdBwDg.js"; | ||
| //#region ../../node_modules/.pnpm/prettier@3.8.3/node_modules/prettier/plugins/graphql.mjs | ||
| function x(e) { | ||
| return S(e), { | ||
| type: Ee, | ||
| contents: e | ||
| }; | ||
| } | ||
| function y(e, t = {}) { | ||
| return S(e), Y(t.expandedStates, !0), { | ||
| type: Te, | ||
| id: t.id, | ||
| contents: e, | ||
| break: !!t.shouldBreak, | ||
| expandedStates: t.expandedStates | ||
| }; | ||
| } | ||
| function I(e, t = "", n = {}) { | ||
| return S(e), t !== "" && S(t), { | ||
| type: Ne, | ||
| breakContents: e, | ||
| flatContents: t, | ||
| groupId: n.groupId | ||
| }; | ||
| } | ||
| function E(e, t) { | ||
| S(e), Y(t); | ||
| let n = []; | ||
| for (let i = 0; i < t.length; i++) i !== 0 && n.push(e), n.push(t[i]); | ||
| return n; | ||
| } | ||
| function j(e) { | ||
| return (t, n, i) => { | ||
| let r = !!i?.backwards; | ||
| if (n === !1) return !1; | ||
| let { length: s } = t, a = n; | ||
| for (; a >= 0 && a < s;) { | ||
| let u = t.charAt(a); | ||
| if (e instanceof RegExp) { | ||
| if (!e.test(u)) return a; | ||
| } else if (!e.includes(u)) return a; | ||
| r ? a-- : a++; | ||
| } | ||
| return a === -1 || a === s ? a : !1; | ||
| }; | ||
| } | ||
| function mt(e, t, n) { | ||
| let i = !!n?.backwards; | ||
| if (t === !1) return !1; | ||
| let r = e.charAt(t); | ||
| if (i) { | ||
| if (e.charAt(t - 1) === "\r" && r === ` | ||
| `) return t - 2; | ||
| if (Oe(r)) return t - 1; | ||
| } else { | ||
| if (r === "\r" && e.charAt(t + 1) === ` | ||
| `) return t + 2; | ||
| if (Oe(r)) return t + 1; | ||
| } | ||
| return t; | ||
| } | ||
| function Et(e, t, n = {}) { | ||
| let i = $(e, n.backwards ? t - 1 : t, n); | ||
| return i !== X(e, i, n); | ||
| } | ||
| function Tt(e, t) { | ||
| if (t === !1) return !1; | ||
| if (e.charAt(t) === "/" && e.charAt(t + 1) === "*") { | ||
| for (let n = t + 2; n < e.length; ++n) if (e.charAt(n) === "*" && e.charAt(n + 1) === "/") return n + 2; | ||
| } | ||
| return t; | ||
| } | ||
| function Nt(e, t) { | ||
| return t === !1 ? !1 : e.charAt(t) === "/" && e.charAt(t + 1) === "/" ? Ae(e, t) : t; | ||
| } | ||
| function xt(e, t) { | ||
| let n = null, i = t; | ||
| for (; i !== n;) n = i, i = ye(e, i), i = De(e, i), i = $(e, i); | ||
| return i = ge(e, i), i = X(e, i), i !== !1 && Ie(e, i); | ||
| } | ||
| function _t(e) { | ||
| return Array.isArray(e) && e.length > 0; | ||
| } | ||
| function w(e) { | ||
| if (P !== null && typeof P.property) { | ||
| let t = P; | ||
| return P = w.prototype = null, t; | ||
| } | ||
| return P = w.prototype = e ?? Object.create(null), new w(); | ||
| } | ||
| function ae(e) { | ||
| return w(e); | ||
| } | ||
| function At(e, t = "type") { | ||
| ae(e); | ||
| function n(i) { | ||
| let r = i[t], s = e[r]; | ||
| if (!Array.isArray(s)) throw Object.assign(/* @__PURE__ */ new Error(`Missing visitor keys for '${r}'.`), { node: i }); | ||
| return s; | ||
| } | ||
| return n; | ||
| } | ||
| function It(e, t, n) { | ||
| let { node: i } = e; | ||
| if (!i.description) return ""; | ||
| let r = [n("description")]; | ||
| return i.kind === "InputValueDefinition" && !i.description.block ? r.push(k) : r.push(f), r; | ||
| } | ||
| function Dt(e, t, n) { | ||
| let { node: i } = e; | ||
| switch (i.kind) { | ||
| case "Document": return [...E(f, g(e, t, n, "definitions")), f]; | ||
| case "OperationDefinition": { | ||
| let r = t.originalText[J(i)] !== "{", s = !!i.name; | ||
| return [ | ||
| A(e, t, n), | ||
| r ? i.operation : "", | ||
| r && s ? [" ", n("name")] : "", | ||
| r && !s && se(i.variableDefinitions) ? " " : "", | ||
| Be(e, n), | ||
| _(e, n, i), | ||
| !r && !s ? "" : " ", | ||
| n("selectionSet") | ||
| ]; | ||
| } | ||
| case "FragmentDefinition": return [ | ||
| A(e, t, n), | ||
| "fragment ", | ||
| n("name"), | ||
| Be(e, n), | ||
| " on ", | ||
| n("typeCondition"), | ||
| _(e, n, i), | ||
| " ", | ||
| n("selectionSet") | ||
| ]; | ||
| case "SelectionSet": return [ | ||
| "{", | ||
| x([f, E(f, g(e, t, n, "selections"))]), | ||
| f, | ||
| "}" | ||
| ]; | ||
| case "Field": return y([ | ||
| i.alias ? [n("alias"), ": "] : "", | ||
| n("name"), | ||
| i.arguments.length > 0 ? y([ | ||
| "(", | ||
| x([l, E([I("", ", "), l], g(e, t, n, "arguments"))]), | ||
| l, | ||
| ")" | ||
| ]) : "", | ||
| _(e, n, i), | ||
| i.selectionSet ? " " : "", | ||
| n("selectionSet") | ||
| ]); | ||
| case "Name": return i.value; | ||
| case "StringValue": | ||
| if (i.block) { | ||
| let r = U(0, i.value, "\"\"\"", "\\\"\"\"").split(` | ||
| `); | ||
| return r.length === 1 && (r[0] = r[0].trim()), r.every((s) => s === "") && (r.length = 0), E(f, [ | ||
| "\"\"\"", | ||
| ...r, | ||
| "\"\"\"" | ||
| ]); | ||
| } | ||
| return [ | ||
| "\"", | ||
| U(0, U(0, i.value, /["\\]/gu, "\\$&"), ` | ||
| `, "\\n"), | ||
| "\"" | ||
| ]; | ||
| case "IntValue": | ||
| case "FloatValue": | ||
| case "EnumValue": return i.value; | ||
| case "BooleanValue": return i.value ? "true" : "false"; | ||
| case "NullValue": return "null"; | ||
| case "Variable": return ["$", n("name")]; | ||
| case "ListValue": return y([ | ||
| "[", | ||
| x([l, E([I("", ", "), l], e.map(n, "values"))]), | ||
| l, | ||
| "]" | ||
| ]); | ||
| case "ObjectValue": { | ||
| let r = t.bracketSpacing && i.fields.length > 0 ? " " : ""; | ||
| return y([ | ||
| "{", | ||
| r, | ||
| x([l, E([I("", ", "), l], e.map(n, "fields"))]), | ||
| l, | ||
| I("", r), | ||
| "}" | ||
| ]); | ||
| } | ||
| case "ObjectField": | ||
| case "Argument": return [ | ||
| n("name"), | ||
| ": ", | ||
| n("value") | ||
| ]; | ||
| case "Directive": return [ | ||
| "@", | ||
| n("name"), | ||
| i.arguments.length > 0 ? y([ | ||
| "(", | ||
| x([l, E([I("", ", "), l], g(e, t, n, "arguments"))]), | ||
| l, | ||
| ")" | ||
| ]) : "" | ||
| ]; | ||
| case "NamedType": return n("name"); | ||
| case "VariableDefinition": return [ | ||
| A(e, t, n), | ||
| n("variable"), | ||
| ": ", | ||
| n("type"), | ||
| i.defaultValue ? [" = ", n("defaultValue")] : "", | ||
| _(e, n, i) | ||
| ]; | ||
| case "ObjectTypeExtension": | ||
| case "ObjectTypeDefinition": | ||
| case "InputObjectTypeExtension": | ||
| case "InputObjectTypeDefinition": | ||
| case "InterfaceTypeExtension": | ||
| case "InterfaceTypeDefinition": { | ||
| let { kind: r } = i, s = []; | ||
| return r.endsWith("TypeDefinition") ? s.push(A(e, t, n)) : s.push("extend "), r.startsWith("ObjectType") ? s.push("type") : r.startsWith("InputObjectType") ? s.push("input") : s.push("interface"), s.push(" ", n("name")), !r.startsWith("InputObjectType") && i.interfaces.length > 0 && s.push(" implements ", ...kt(e, t, n)), s.push(_(e, n, i)), i.fields.length > 0 && s.push([ | ||
| " {", | ||
| x([f, E(f, g(e, t, n, "fields"))]), | ||
| f, | ||
| "}" | ||
| ]), s; | ||
| } | ||
| case "FieldDefinition": return [ | ||
| A(e, t, n), | ||
| n("name"), | ||
| i.arguments.length > 0 ? y([ | ||
| "(", | ||
| x([l, E([I("", ", "), l], g(e, t, n, "arguments"))]), | ||
| l, | ||
| ")" | ||
| ]) : "", | ||
| ": ", | ||
| n("type"), | ||
| _(e, n, i) | ||
| ]; | ||
| case "DirectiveDefinition": return [ | ||
| A(e, t, n), | ||
| "directive ", | ||
| "@", | ||
| n("name"), | ||
| i.arguments.length > 0 ? y([ | ||
| "(", | ||
| x([l, E([I("", ", "), l], g(e, t, n, "arguments"))]), | ||
| l, | ||
| ")" | ||
| ]) : "", | ||
| i.repeatable ? " repeatable" : "", | ||
| " on ", | ||
| ...E(" | ", e.map(n, "locations")) | ||
| ]; | ||
| case "EnumTypeExtension": | ||
| case "EnumTypeDefinition": return [ | ||
| A(e, t, n), | ||
| i.kind === "EnumTypeExtension" ? "extend " : "", | ||
| "enum ", | ||
| n("name"), | ||
| _(e, n, i), | ||
| i.values.length > 0 ? [ | ||
| " {", | ||
| x([f, E(f, g(e, t, n, "values"))]), | ||
| f, | ||
| "}" | ||
| ] : "" | ||
| ]; | ||
| case "EnumValueDefinition": return [ | ||
| A(e, t, n), | ||
| n("name"), | ||
| _(e, n, i) | ||
| ]; | ||
| case "InputValueDefinition": return [ | ||
| A(e, t, n), | ||
| n("name"), | ||
| ": ", | ||
| n("type"), | ||
| i.defaultValue ? [" = ", n("defaultValue")] : "", | ||
| _(e, n, i) | ||
| ]; | ||
| case "SchemaExtension": return [ | ||
| "extend schema", | ||
| _(e, n, i), | ||
| ...i.operationTypes.length > 0 ? [ | ||
| " {", | ||
| x([f, E(f, g(e, t, n, "operationTypes"))]), | ||
| f, | ||
| "}" | ||
| ] : [] | ||
| ]; | ||
| case "SchemaDefinition": return [ | ||
| A(e, t, n), | ||
| "schema", | ||
| _(e, n, i), | ||
| " {", | ||
| i.operationTypes.length > 0 ? x([f, E(f, g(e, t, n, "operationTypes"))]) : "", | ||
| f, | ||
| "}" | ||
| ]; | ||
| case "OperationTypeDefinition": return [ | ||
| i.operation, | ||
| ": ", | ||
| n("type") | ||
| ]; | ||
| case "FragmentSpread": return [ | ||
| "...", | ||
| n("name"), | ||
| _(e, n, i) | ||
| ]; | ||
| case "InlineFragment": return [ | ||
| "...", | ||
| i.typeCondition ? [" on ", n("typeCondition")] : "", | ||
| _(e, n, i), | ||
| " ", | ||
| n("selectionSet") | ||
| ]; | ||
| case "UnionTypeExtension": | ||
| case "UnionTypeDefinition": return y([A(e, t, n), y([ | ||
| i.kind === "UnionTypeExtension" ? "extend " : "", | ||
| "union ", | ||
| n("name"), | ||
| _(e, n, i), | ||
| i.types.length > 0 ? [ | ||
| " =", | ||
| I("", " "), | ||
| x([I([k, "| "]), E([k, "| "], e.map(n, "types"))]) | ||
| ] : "" | ||
| ])]); | ||
| case "ScalarTypeExtension": | ||
| case "ScalarTypeDefinition": return [ | ||
| A(e, t, n), | ||
| i.kind === "ScalarTypeExtension" ? "extend " : "", | ||
| "scalar ", | ||
| n("name"), | ||
| _(e, n, i) | ||
| ]; | ||
| case "NonNullType": return [n("type"), "!"]; | ||
| case "ListType": return [ | ||
| "[", | ||
| n("type"), | ||
| "]" | ||
| ]; | ||
| default: throw new ke(i, "Graphql", "kind"); | ||
| } | ||
| } | ||
| function _(e, t, n) { | ||
| if (n.directives.length === 0) return ""; | ||
| let i = E(k, e.map(t, "directives")); | ||
| return n.kind === "FragmentDefinition" || n.kind === "OperationDefinition" ? y([k, i]) : [" ", y(x([l, i]))]; | ||
| } | ||
| function g(e, t, n, i) { | ||
| return e.map(({ isLast: r, node: s }) => { | ||
| let a = n(); | ||
| return !r && Se(t.originalText, q(s)) ? [a, f] : a; | ||
| }, i); | ||
| } | ||
| function gt(e) { | ||
| return e.kind !== "Comment"; | ||
| } | ||
| function St({ node: e }) { | ||
| if (e.kind === "Comment") return "#" + e.value.trimEnd(); | ||
| throw new Error("Not a comment: " + JSON.stringify(e)); | ||
| } | ||
| function kt(e, t, n) { | ||
| let { node: i } = e, r = [], { interfaces: s } = i, a = e.map(n, "interfaces"); | ||
| for (let u = 0; u < s.length; u++) { | ||
| let p = s[u]; | ||
| r.push(a[u]); | ||
| let T = s[u + 1]; | ||
| if (T) { | ||
| let D = t.originalText.slice(p.loc.end, T.loc.start).includes("#"); | ||
| r.push(" &", D ? k : " "); | ||
| } | ||
| } | ||
| return r; | ||
| } | ||
| function Be(e, t) { | ||
| let { node: n } = e; | ||
| return se(n.variableDefinitions) ? y([ | ||
| "(", | ||
| x([l, E([I("", ", "), l], e.map(t, "variableDefinitions"))]), | ||
| l, | ||
| ")" | ||
| ]) : ""; | ||
| } | ||
| function Ue(e, t) { | ||
| e.kind === "StringValue" && e.block && !e.value.includes(` | ||
| `) && (t.value = e.value.trim()); | ||
| } | ||
| function Ct(e) { | ||
| let { node: t } = e; | ||
| return t?.comments?.some((n) => n.value.trim() === "prettier-ignore"); | ||
| } | ||
| function Xe(e) { | ||
| return typeof e == "object" && e !== null; | ||
| } | ||
| function He(e, t) { | ||
| if (!!!e) throw new Error(t ?? "Unexpected invariant triggered."); | ||
| } | ||
| function M(e, t) { | ||
| let n = 0, i = 1; | ||
| for (let r of e.body.matchAll(bt)) { | ||
| if (typeof r.index == "number" || He(!1), r.index >= t) break; | ||
| n = r.index + r[0].length, i += 1; | ||
| } | ||
| return { | ||
| line: i, | ||
| column: t + 1 - n | ||
| }; | ||
| } | ||
| function qe(e) { | ||
| return ue(e.source, M(e.source, e.start)); | ||
| } | ||
| function ue(e, t) { | ||
| let n = e.locationOffset.column - 1, i = "".padStart(n) + e.body, r = t.line - 1, s = e.locationOffset.line - 1, a = t.line + s, u = t.line === 1 ? n : 0, p = t.column + u, T = `${e.name}:${a}:${p} | ||
| `, d = i.split(/\r\n|[\n\r]/g), D = d[r]; | ||
| if (D.length > 120) { | ||
| let O = Math.floor(p / 80), re = p % 80, N = []; | ||
| for (let v = 0; v < D.length; v += 80) N.push(D.slice(v, v + 80)); | ||
| return T + Je([ | ||
| [`${a} |`, N[0]], | ||
| ...N.slice(1, O + 1).map((v) => ["|", v]), | ||
| ["|", "^".padStart(re)], | ||
| ["|", N[O + 1]] | ||
| ]); | ||
| } | ||
| return T + Je([ | ||
| [`${a - 1} |`, d[r - 1]], | ||
| [`${a} |`, D], | ||
| ["|", "^".padStart(p)], | ||
| [`${a + 1} |`, d[r + 1]] | ||
| ]); | ||
| } | ||
| function Je(e) { | ||
| let t = e.filter(([i, r]) => r !== void 0), n = Math.max(...t.map(([i]) => i.length)); | ||
| return t.map(([i, r]) => i.padStart(n) + (r ? " " + r : "")).join(` | ||
| `); | ||
| } | ||
| function Lt(e) { | ||
| let t = e[0]; | ||
| return t == null || "kind" in t || "length" in t ? { | ||
| nodes: t, | ||
| source: e[1], | ||
| positions: e[2], | ||
| path: e[3], | ||
| originalError: e[4], | ||
| extensions: e[5] | ||
| } : t; | ||
| } | ||
| function Qe(e) { | ||
| return e === void 0 || e.length === 0 ? void 0 : e; | ||
| } | ||
| function h(e, t, n) { | ||
| return new Q(`Syntax Error: ${n}`, { | ||
| source: e, | ||
| positions: [t] | ||
| }); | ||
| } | ||
| function We(e) { | ||
| return e === 9 || e === 32; | ||
| } | ||
| function b(e) { | ||
| return e >= 48 && e <= 57; | ||
| } | ||
| function ze(e) { | ||
| return e >= 97 && e <= 122 || e >= 65 && e <= 90; | ||
| } | ||
| function pe(e) { | ||
| return ze(e) || e === 95; | ||
| } | ||
| function Ke(e) { | ||
| return ze(e) || b(e) || e === 95; | ||
| } | ||
| function Ze(e) { | ||
| var t; | ||
| let n = Number.MAX_SAFE_INTEGER, i = null, r = -1; | ||
| for (let a = 0; a < e.length; ++a) { | ||
| var s; | ||
| let u = e[a], p = Pt(u); | ||
| p !== u.length && (i = (s = i) !== null && s !== void 0 ? s : a, r = a, a !== 0 && p < n && (n = p)); | ||
| } | ||
| return e.map((a, u) => u === 0 ? a : a.slice(n)).slice((t = i) !== null && t !== void 0 ? t : 0, r + 1); | ||
| } | ||
| function Pt(e) { | ||
| let t = 0; | ||
| for (; t < e.length && We(e.charCodeAt(t));) ++t; | ||
| return t; | ||
| } | ||
| function tt(e) { | ||
| return e === o.BANG || e === o.DOLLAR || e === o.AMP || e === o.PAREN_L || e === o.PAREN_R || e === o.DOT || e === o.SPREAD || e === o.COLON || e === o.EQUALS || e === o.AT || e === o.BRACKET_L || e === o.BRACKET_R || e === o.BRACE_L || e === o.PIPE || e === o.BRACE_R; | ||
| } | ||
| function L(e) { | ||
| return e >= 0 && e <= 55295 || e >= 57344 && e <= 1114111; | ||
| } | ||
| function K(e, t) { | ||
| return nt(e.charCodeAt(t)) && rt(e.charCodeAt(t + 1)); | ||
| } | ||
| function nt(e) { | ||
| return e >= 55296 && e <= 56319; | ||
| } | ||
| function rt(e) { | ||
| return e >= 56320 && e <= 57343; | ||
| } | ||
| function R(e, t) { | ||
| let n = e.source.body.codePointAt(t); | ||
| if (n === void 0) return o.EOF; | ||
| if (n >= 32 && n <= 126) { | ||
| let i = String.fromCodePoint(n); | ||
| return i === "\"" ? `'"'` : `"${i}"`; | ||
| } | ||
| return "U+" + n.toString(16).toUpperCase().padStart(4, "0"); | ||
| } | ||
| function m(e, t, n, i, r) { | ||
| let s = e.line; | ||
| return new F(t, n, i, s, 1 + n - e.lineStart, r); | ||
| } | ||
| function wt(e, t) { | ||
| let n = e.source.body, i = n.length, r = t; | ||
| for (; r < i;) { | ||
| let s = n.charCodeAt(r); | ||
| switch (s) { | ||
| case 65279: | ||
| case 9: | ||
| case 32: | ||
| case 44: | ||
| ++r; | ||
| continue; | ||
| case 10: | ||
| ++r, ++e.line, e.lineStart = r; | ||
| continue; | ||
| case 13: | ||
| n.charCodeAt(r + 1) === 10 ? r += 2 : ++r, ++e.line, e.lineStart = r; | ||
| continue; | ||
| case 35: return Ft(e, r); | ||
| case 33: return m(e, o.BANG, r, r + 1); | ||
| case 36: return m(e, o.DOLLAR, r, r + 1); | ||
| case 38: return m(e, o.AMP, r, r + 1); | ||
| case 40: return m(e, o.PAREN_L, r, r + 1); | ||
| case 41: return m(e, o.PAREN_R, r, r + 1); | ||
| case 46: | ||
| if (n.charCodeAt(r + 1) === 46 && n.charCodeAt(r + 2) === 46) return m(e, o.SPREAD, r, r + 3); | ||
| break; | ||
| case 58: return m(e, o.COLON, r, r + 1); | ||
| case 61: return m(e, o.EQUALS, r, r + 1); | ||
| case 64: return m(e, o.AT, r, r + 1); | ||
| case 91: return m(e, o.BRACKET_L, r, r + 1); | ||
| case 93: return m(e, o.BRACKET_R, r, r + 1); | ||
| case 123: return m(e, o.BRACE_L, r, r + 1); | ||
| case 124: return m(e, o.PIPE, r, r + 1); | ||
| case 125: return m(e, o.BRACE_R, r, r + 1); | ||
| case 34: return n.charCodeAt(r + 1) === 34 && n.charCodeAt(r + 2) === 34 ? Yt(e, r) : Vt(e, r); | ||
| } | ||
| if (b(s) || s === 45) return Mt(e, r, s); | ||
| if (pe(s)) return jt(e, r); | ||
| throw h(e.source, r, s === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : L(s) || K(n, r) ? `Unexpected character: ${R(e, r)}.` : `Invalid character: ${R(e, r)}.`); | ||
| } | ||
| return m(e, o.EOF, i, i); | ||
| } | ||
| function Ft(e, t) { | ||
| let n = e.source.body, i = n.length, r = t + 1; | ||
| for (; r < i;) { | ||
| let s = n.charCodeAt(r); | ||
| if (s === 10 || s === 13) break; | ||
| if (L(s)) ++r; | ||
| else if (K(n, r)) r += 2; | ||
| else break; | ||
| } | ||
| return m(e, o.COMMENT, t, r, n.slice(t + 1, r)); | ||
| } | ||
| function Mt(e, t, n) { | ||
| let i = e.source.body, r = t, s = n, a = !1; | ||
| if (s === 45 && (s = i.charCodeAt(++r)), s === 48) { | ||
| if (s = i.charCodeAt(++r), b(s)) throw h(e.source, r, `Invalid number, unexpected digit after 0: ${R(e, r)}.`); | ||
| } else r = le(e, r, s), s = i.charCodeAt(r); | ||
| if (s === 46 && (a = !0, s = i.charCodeAt(++r), r = le(e, r, s), s = i.charCodeAt(r)), (s === 69 || s === 101) && (a = !0, s = i.charCodeAt(++r), (s === 43 || s === 45) && (s = i.charCodeAt(++r)), r = le(e, r, s), s = i.charCodeAt(r)), s === 46 || pe(s)) throw h(e.source, r, `Invalid number, expected digit but got: ${R(e, r)}.`); | ||
| return m(e, a ? o.FLOAT : o.INT, t, r, i.slice(t, r)); | ||
| } | ||
| function le(e, t, n) { | ||
| if (!b(n)) throw h(e.source, t, `Invalid number, expected digit but got: ${R(e, t)}.`); | ||
| let i = e.source.body, r = t + 1; | ||
| for (; b(i.charCodeAt(r));) ++r; | ||
| return r; | ||
| } | ||
| function Vt(e, t) { | ||
| let n = e.source.body, i = n.length, r = t + 1, s = r, a = ""; | ||
| for (; r < i;) { | ||
| let u = n.charCodeAt(r); | ||
| if (u === 34) return a += n.slice(s, r), m(e, o.STRING, t, r + 1, a); | ||
| if (u === 92) { | ||
| a += n.slice(s, r); | ||
| let p = n.charCodeAt(r + 1) === 117 ? n.charCodeAt(r + 2) === 123 ? Bt(e, r) : Ut(e, r) : Gt(e, r); | ||
| a += p.value, r += p.size, s = r; | ||
| continue; | ||
| } | ||
| if (u === 10 || u === 13) break; | ||
| if (L(u)) ++r; | ||
| else if (K(n, r)) r += 2; | ||
| else throw h(e.source, r, `Invalid character within String: ${R(e, r)}.`); | ||
| } | ||
| throw h(e.source, r, "Unterminated string."); | ||
| } | ||
| function Bt(e, t) { | ||
| let n = e.source.body, i = 0, r = 3; | ||
| for (; r < 12;) { | ||
| let s = n.charCodeAt(t + r++); | ||
| if (s === 125) { | ||
| if (r < 5 || !L(i)) break; | ||
| return { | ||
| value: String.fromCodePoint(i), | ||
| size: r | ||
| }; | ||
| } | ||
| if (i = i << 4 | V(s), i < 0) break; | ||
| } | ||
| throw h(e.source, t, `Invalid Unicode escape sequence: "${n.slice(t, t + r)}".`); | ||
| } | ||
| function Ut(e, t) { | ||
| let n = e.source.body, i = et(n, t + 2); | ||
| if (L(i)) return { | ||
| value: String.fromCodePoint(i), | ||
| size: 6 | ||
| }; | ||
| if (nt(i) && n.charCodeAt(t + 6) === 92 && n.charCodeAt(t + 7) === 117) { | ||
| let r = et(n, t + 8); | ||
| if (rt(r)) return { | ||
| value: String.fromCodePoint(i, r), | ||
| size: 12 | ||
| }; | ||
| } | ||
| throw h(e.source, t, `Invalid Unicode escape sequence: "${n.slice(t, t + 6)}".`); | ||
| } | ||
| function et(e, t) { | ||
| return V(e.charCodeAt(t)) << 12 | V(e.charCodeAt(t + 1)) << 8 | V(e.charCodeAt(t + 2)) << 4 | V(e.charCodeAt(t + 3)); | ||
| } | ||
| function V(e) { | ||
| return e >= 48 && e <= 57 ? e - 48 : e >= 65 && e <= 70 ? e - 55 : e >= 97 && e <= 102 ? e - 87 : -1; | ||
| } | ||
| function Gt(e, t) { | ||
| let n = e.source.body; | ||
| switch (n.charCodeAt(t + 1)) { | ||
| case 34: return { | ||
| value: "\"", | ||
| size: 2 | ||
| }; | ||
| case 92: return { | ||
| value: "\\", | ||
| size: 2 | ||
| }; | ||
| case 47: return { | ||
| value: "/", | ||
| size: 2 | ||
| }; | ||
| case 98: return { | ||
| value: "\b", | ||
| size: 2 | ||
| }; | ||
| case 102: return { | ||
| value: "\f", | ||
| size: 2 | ||
| }; | ||
| case 110: return { | ||
| value: ` | ||
| `, | ||
| size: 2 | ||
| }; | ||
| case 114: return { | ||
| value: "\r", | ||
| size: 2 | ||
| }; | ||
| case 116: return { | ||
| value: " ", | ||
| size: 2 | ||
| }; | ||
| } | ||
| throw h(e.source, t, `Invalid character escape sequence: "${n.slice(t, t + 2)}".`); | ||
| } | ||
| function Yt(e, t) { | ||
| let n = e.source.body, i = n.length, r = e.lineStart, s = t + 3, a = s, u = "", p = []; | ||
| for (; s < i;) { | ||
| let T = n.charCodeAt(s); | ||
| if (T === 34 && n.charCodeAt(s + 1) === 34 && n.charCodeAt(s + 2) === 34) { | ||
| u += n.slice(a, s), p.push(u); | ||
| let d = m(e, o.BLOCK_STRING, t, s + 3, Ze(p).join(` | ||
| `)); | ||
| return e.line += p.length - 1, e.lineStart = r, d; | ||
| } | ||
| if (T === 92 && n.charCodeAt(s + 1) === 34 && n.charCodeAt(s + 2) === 34 && n.charCodeAt(s + 3) === 34) { | ||
| u += n.slice(a, s), a = s + 1, s += 4; | ||
| continue; | ||
| } | ||
| if (T === 10 || T === 13) { | ||
| u += n.slice(a, s), p.push(u), T === 13 && n.charCodeAt(s + 1) === 10 ? s += 2 : ++s, u = "", a = s, r = s; | ||
| continue; | ||
| } | ||
| if (L(T)) ++s; | ||
| else if (K(n, s)) s += 2; | ||
| else throw h(e.source, s, `Invalid character within String: ${R(e, s)}.`); | ||
| } | ||
| throw h(e.source, s, "Unterminated string."); | ||
| } | ||
| function jt(e, t) { | ||
| let n = e.source.body, i = n.length, r = t + 1; | ||
| for (; r < i;) if (Ke(n.charCodeAt(r))) ++r; | ||
| else break; | ||
| return m(e, o.NAME, t, r, n.slice(t, r)); | ||
| } | ||
| function Z(e, t) { | ||
| if (!!!e) throw new Error(t); | ||
| } | ||
| function ee(e) { | ||
| return te(e, []); | ||
| } | ||
| function te(e, t) { | ||
| switch (typeof e) { | ||
| case "string": return JSON.stringify(e); | ||
| case "function": return e.name ? `[function ${e.name}]` : "[function]"; | ||
| case "object": return $t(e, t); | ||
| default: return String(e); | ||
| } | ||
| } | ||
| function $t(e, t) { | ||
| if (e === null) return "null"; | ||
| if (t.includes(e)) return "[Circular]"; | ||
| let n = [...t, e]; | ||
| if (Xt(e)) { | ||
| let i = e.toJSON(); | ||
| if (i !== e) return typeof i == "string" ? i : te(i, n); | ||
| } else if (Array.isArray(e)) return Jt(e, n); | ||
| return Ht(e, n); | ||
| } | ||
| function Xt(e) { | ||
| return typeof e.toJSON == "function"; | ||
| } | ||
| function Ht(e, t) { | ||
| let n = Object.entries(e); | ||
| return n.length === 0 ? "{}" : t.length > 2 ? "[" + qt(e) + "]" : "{ " + n.map(([r, s]) => r + ": " + te(s, t)).join(", ") + " }"; | ||
| } | ||
| function Jt(e, t) { | ||
| if (e.length === 0) return "[]"; | ||
| if (t.length > 2) return "[Array]"; | ||
| let n = Math.min(10, e.length), i = e.length - n, r = []; | ||
| for (let s = 0; s < n; ++s) r.push(te(e[s], t)); | ||
| return i === 1 ? r.push("... 1 more item") : i > 1 && r.push(`... ${i} more items`), "[" + r.join(", ") + "]"; | ||
| } | ||
| function qt(e) { | ||
| let t = Object.prototype.toString.call(e).replace(/^\[object /, "").replace(/]$/, ""); | ||
| if (t === "Object" && typeof e.constructor == "function") { | ||
| let n = e.constructor.name; | ||
| if (typeof n == "string" && n !== "") return n; | ||
| } | ||
| return t; | ||
| } | ||
| function st(e) { | ||
| return it(e, B); | ||
| } | ||
| function ot(e, t) { | ||
| let n = new fe(e, t), i = n.parseDocument(); | ||
| return Object.defineProperty(i, "tokenCount", { | ||
| enumerable: !1, | ||
| value: n.tokenCount | ||
| }), i; | ||
| } | ||
| function ne(e) { | ||
| let t = e.value; | ||
| return at(e.kind) + (t != null ? ` "${t}"` : ""); | ||
| } | ||
| function at(e) { | ||
| return tt(e) ? `"${e}"` : e; | ||
| } | ||
| function Wt(e, t) { | ||
| let n = /* @__PURE__ */ new SyntaxError(e + " (" + t.loc.start.line + ":" + t.loc.start.column + ")"); | ||
| return Object.assign(n, t); | ||
| } | ||
| function zt(e) { | ||
| let t = [], { startToken: n, endToken: i } = e.loc; | ||
| for (let r = n; r !== i; r = r.next) r.kind === "Comment" && t.push({ | ||
| ...r, | ||
| loc: { | ||
| start: r.start, | ||
| end: r.end | ||
| } | ||
| }); | ||
| return t; | ||
| } | ||
| function Zt(e) { | ||
| if (e?.name === "GraphQLError") { | ||
| let { message: t, locations: [n] } = e; | ||
| return ct(t, { | ||
| loc: { start: n }, | ||
| cause: e | ||
| }); | ||
| } | ||
| return e; | ||
| } | ||
| function en(e) { | ||
| let t; | ||
| try { | ||
| t = ot(e, Kt); | ||
| } catch (n) { | ||
| throw Zt(n); | ||
| } | ||
| return t.comments = zt(t), t; | ||
| } | ||
| var pt, de, ut, me, lt, U, ht, ie, Ee, Te, Ne, G, xe, S, Y, _e, k, l, f, $, ye, Ae, Oe, X, Ie, De, ge, Se, se, oe, ke, P, yt, Ce, H, F, ce, C, Re, be, J, q, Le, Pe, we, Fe, Me, Ve, A, Ge, Ye, $e, he, bt, Q, W, c, o, z, it, B, fe, ct, Kt, tn, nn; | ||
| //#endregion | ||
| __esmMin((() => { | ||
| pt = Object.defineProperty; | ||
| de = (e, t) => { | ||
| for (var n in t) pt(e, n, { | ||
| get: t[n], | ||
| enumerable: !0 | ||
| }); | ||
| }; | ||
| ut = {}; | ||
| de(ut, { | ||
| languages: () => Ye, | ||
| options: () => $e, | ||
| parsers: () => he, | ||
| printers: () => nn | ||
| }); | ||
| me = (e, t) => (n, i, ...r) => n | 1 && i == null ? void 0 : (t.call(i) ?? i[e]).apply(i, r); | ||
| lt = String.prototype.replaceAll ?? function(e, t) { | ||
| return e.global ? this.replace(e, t) : this.split(e).join(t); | ||
| }, U = me("replaceAll", function() { | ||
| if (typeof this == "string") return lt; | ||
| }); | ||
| ht = () => {}, ie = ht; | ||
| Ee = "indent"; | ||
| Te = "group"; | ||
| Ne = "if-break"; | ||
| G = "line"; | ||
| xe = "break-parent"; | ||
| S = ie, Y = ie; | ||
| _e = { type: xe }; | ||
| k = { type: G }, l = { | ||
| type: G, | ||
| soft: !0 | ||
| }, f = [{ | ||
| type: G, | ||
| hard: !0 | ||
| }, _e]; | ||
| $ = j(" "), ye = j(",; "), Ae = j(/[^\n\r]/u); | ||
| Oe = (e) => e === ` | ||
| ` || e === "\r" || e === "\u2028" || e === "\u2029"; | ||
| X = mt; | ||
| Ie = Et; | ||
| De = Tt; | ||
| ge = Nt; | ||
| Se = xt; | ||
| se = _t; | ||
| oe = class extends Error { | ||
| name = "UnexpectedNodeError"; | ||
| constructor(t, n, i = "type") { | ||
| super(`Unexpected ${n} node ${i}: ${JSON.stringify(t[i])}.`), this.node = t; | ||
| } | ||
| }, ke = oe; | ||
| P = null; | ||
| yt = 10; | ||
| for (let e = 0; e <= yt; e++) w(); | ||
| Ce = At, H = class { | ||
| constructor(t, n, i) { | ||
| this.start = t.start, this.end = n.end, this.startToken = t, this.endToken = n, this.source = i; | ||
| } | ||
| get [Symbol.toStringTag]() { | ||
| return "Location"; | ||
| } | ||
| toJSON() { | ||
| return { | ||
| start: this.start, | ||
| end: this.end | ||
| }; | ||
| } | ||
| }, F = class { | ||
| constructor(t, n, i, r, s, a) { | ||
| this.kind = t, this.start = n, this.end = i, this.line = r, this.column = s, this.value = a, this.prev = null, this.next = null; | ||
| } | ||
| get [Symbol.toStringTag]() { | ||
| return "Token"; | ||
| } | ||
| toJSON() { | ||
| return { | ||
| kind: this.kind, | ||
| value: this.value, | ||
| line: this.line, | ||
| column: this.column | ||
| }; | ||
| } | ||
| }, ce = { | ||
| Name: [], | ||
| Document: ["definitions"], | ||
| OperationDefinition: [ | ||
| "description", | ||
| "name", | ||
| "variableDefinitions", | ||
| "directives", | ||
| "selectionSet" | ||
| ], | ||
| VariableDefinition: [ | ||
| "description", | ||
| "variable", | ||
| "type", | ||
| "defaultValue", | ||
| "directives" | ||
| ], | ||
| Variable: ["name"], | ||
| SelectionSet: ["selections"], | ||
| Field: [ | ||
| "alias", | ||
| "name", | ||
| "arguments", | ||
| "directives", | ||
| "selectionSet" | ||
| ], | ||
| Argument: ["name", "value"], | ||
| FragmentSpread: ["name", "directives"], | ||
| InlineFragment: [ | ||
| "typeCondition", | ||
| "directives", | ||
| "selectionSet" | ||
| ], | ||
| FragmentDefinition: [ | ||
| "description", | ||
| "name", | ||
| "variableDefinitions", | ||
| "typeCondition", | ||
| "directives", | ||
| "selectionSet" | ||
| ], | ||
| IntValue: [], | ||
| FloatValue: [], | ||
| StringValue: [], | ||
| BooleanValue: [], | ||
| NullValue: [], | ||
| EnumValue: [], | ||
| ListValue: ["values"], | ||
| ObjectValue: ["fields"], | ||
| ObjectField: ["name", "value"], | ||
| Directive: ["name", "arguments"], | ||
| NamedType: ["name"], | ||
| ListType: ["type"], | ||
| NonNullType: ["type"], | ||
| SchemaDefinition: [ | ||
| "description", | ||
| "directives", | ||
| "operationTypes" | ||
| ], | ||
| OperationTypeDefinition: ["type"], | ||
| ScalarTypeDefinition: [ | ||
| "description", | ||
| "name", | ||
| "directives" | ||
| ], | ||
| ObjectTypeDefinition: [ | ||
| "description", | ||
| "name", | ||
| "interfaces", | ||
| "directives", | ||
| "fields" | ||
| ], | ||
| FieldDefinition: [ | ||
| "description", | ||
| "name", | ||
| "arguments", | ||
| "type", | ||
| "directives" | ||
| ], | ||
| InputValueDefinition: [ | ||
| "description", | ||
| "name", | ||
| "type", | ||
| "defaultValue", | ||
| "directives" | ||
| ], | ||
| InterfaceTypeDefinition: [ | ||
| "description", | ||
| "name", | ||
| "interfaces", | ||
| "directives", | ||
| "fields" | ||
| ], | ||
| UnionTypeDefinition: [ | ||
| "description", | ||
| "name", | ||
| "directives", | ||
| "types" | ||
| ], | ||
| EnumTypeDefinition: [ | ||
| "description", | ||
| "name", | ||
| "directives", | ||
| "values" | ||
| ], | ||
| EnumValueDefinition: [ | ||
| "description", | ||
| "name", | ||
| "directives" | ||
| ], | ||
| InputObjectTypeDefinition: [ | ||
| "description", | ||
| "name", | ||
| "directives", | ||
| "fields" | ||
| ], | ||
| DirectiveDefinition: [ | ||
| "description", | ||
| "name", | ||
| "arguments", | ||
| "locations" | ||
| ], | ||
| SchemaExtension: ["directives", "operationTypes"], | ||
| ScalarTypeExtension: ["name", "directives"], | ||
| ObjectTypeExtension: [ | ||
| "name", | ||
| "interfaces", | ||
| "directives", | ||
| "fields" | ||
| ], | ||
| InterfaceTypeExtension: [ | ||
| "name", | ||
| "interfaces", | ||
| "directives", | ||
| "fields" | ||
| ], | ||
| UnionTypeExtension: [ | ||
| "name", | ||
| "directives", | ||
| "types" | ||
| ], | ||
| EnumTypeExtension: [ | ||
| "name", | ||
| "directives", | ||
| "values" | ||
| ], | ||
| InputObjectTypeExtension: [ | ||
| "name", | ||
| "directives", | ||
| "fields" | ||
| ], | ||
| TypeCoordinate: ["name"], | ||
| MemberCoordinate: ["name", "memberName"], | ||
| ArgumentCoordinate: [ | ||
| "name", | ||
| "fieldName", | ||
| "argumentName" | ||
| ], | ||
| DirectiveCoordinate: ["name"], | ||
| DirectiveArgumentCoordinate: ["name", "argumentName"] | ||
| }; | ||
| new Set(Object.keys(ce)); | ||
| (function(e) { | ||
| e.QUERY = "query", e.MUTATION = "mutation", e.SUBSCRIPTION = "subscription"; | ||
| })(C || (C = {})); | ||
| Re = { ...ce }; | ||
| for (let e of [ | ||
| "ArgumentCoordinate", | ||
| "DirectiveArgumentCoordinate", | ||
| "DirectiveCoordinate", | ||
| "MemberCoordinate", | ||
| "TypeCoordinate" | ||
| ]) delete Re[e]; | ||
| be = Ce(Re, "kind"); | ||
| J = (e) => e.loc.start, q = (e) => e.loc.end; | ||
| Le = "format", Pe = /^\s*#[^\S\n]*@(?:noformat|noprettier)\s*(?:\n|$)/u, we = /^\s*#[^\S\n]*@(?:format|prettier)\s*(?:\n|$)/u; | ||
| Fe = (e) => we.test(e), Me = (e) => Pe.test(e), Ve = (e) => `# @${Le} | ||
| ${e}`; | ||
| A = It; | ||
| Ue.ignoredProperties = new Set(["loc", "comments"]); | ||
| Ge = { | ||
| print: Dt, | ||
| massageAstNode: Ue, | ||
| hasPrettierIgnore: Ct, | ||
| insertPragma: Ve, | ||
| printComment: St, | ||
| canAttachComment: gt, | ||
| getVisitorKeys: be | ||
| }; | ||
| Ye = [{ | ||
| name: "GraphQL", | ||
| type: "data", | ||
| aceMode: "graphqlschema", | ||
| extensions: [ | ||
| ".graphql", | ||
| ".gql", | ||
| ".graphqls" | ||
| ], | ||
| tmScope: "source.graphql", | ||
| parsers: ["graphql"], | ||
| vscodeLanguageIds: ["graphql"], | ||
| linguistLanguageId: 139 | ||
| }]; | ||
| $e = { bracketSpacing: { | ||
| bracketSpacing: { | ||
| category: "Common", | ||
| type: "boolean", | ||
| default: !0, | ||
| description: "Print spaces between brackets.", | ||
| oppositeDescription: "Do not print spaces between brackets." | ||
| }, | ||
| objectWrap: { | ||
| category: "Common", | ||
| type: "choice", | ||
| default: "preserve", | ||
| description: "How to wrap object literals.", | ||
| choices: [{ | ||
| value: "preserve", | ||
| description: "Keep as multi-line, if there is a newline between the opening brace and first property." | ||
| }, { | ||
| value: "collapse", | ||
| description: "Fit to a single line when possible." | ||
| }] | ||
| }, | ||
| singleQuote: { | ||
| category: "Common", | ||
| type: "boolean", | ||
| default: !1, | ||
| description: "Use single quotes instead of double quotes." | ||
| }, | ||
| proseWrap: { | ||
| category: "Common", | ||
| type: "choice", | ||
| default: "preserve", | ||
| description: "How to wrap prose.", | ||
| choices: [ | ||
| { | ||
| value: "always", | ||
| description: "Wrap prose if it exceeds the print width." | ||
| }, | ||
| { | ||
| value: "never", | ||
| description: "Do not wrap prose." | ||
| }, | ||
| { | ||
| value: "preserve", | ||
| description: "Wrap prose as-is." | ||
| } | ||
| ] | ||
| }, | ||
| bracketSameLine: { | ||
| category: "Common", | ||
| type: "boolean", | ||
| default: !1, | ||
| description: "Put > of opening tags on the last line instead of on a new line." | ||
| }, | ||
| singleAttributePerLine: { | ||
| category: "Common", | ||
| type: "boolean", | ||
| default: !1, | ||
| description: "Enforce single attribute per line in HTML, Vue and JSX." | ||
| } | ||
| }.bracketSpacing }; | ||
| he = {}; | ||
| de(he, { graphql: () => tn }); | ||
| bt = /\r\n|[\n\r]/g; | ||
| Q = class e extends Error { | ||
| constructor(t, ...n) { | ||
| var i, r, s; | ||
| let { nodes: a, source: u, positions: p, path: T, originalError: d, extensions: D } = Lt(n); | ||
| super(t), this.name = "GraphQLError", this.path = T ?? void 0, this.originalError = d ?? void 0, this.nodes = Qe(Array.isArray(a) ? a : a ? [a] : void 0); | ||
| let O = Qe((i = this.nodes) === null || i === void 0 ? void 0 : i.map((N) => N.loc).filter((N) => N != null)); | ||
| this.source = u ?? (O == null || (r = O[0]) === null || r === void 0 ? void 0 : r.source), this.positions = p ?? O?.map((N) => N.start), this.locations = p && u ? p.map((N) => M(u, N)) : O?.map((N) => M(N.source, N.start)); | ||
| let re = Xe(d?.extensions) ? d?.extensions : void 0; | ||
| this.extensions = (s = D ?? re) !== null && s !== void 0 ? s : Object.create(null), Object.defineProperties(this, { | ||
| message: { | ||
| writable: !0, | ||
| enumerable: !0 | ||
| }, | ||
| name: { enumerable: !1 }, | ||
| nodes: { enumerable: !1 }, | ||
| source: { enumerable: !1 }, | ||
| positions: { enumerable: !1 }, | ||
| originalError: { enumerable: !1 } | ||
| }), d != null && d.stack ? Object.defineProperty(this, "stack", { | ||
| value: d.stack, | ||
| writable: !0, | ||
| configurable: !0 | ||
| }) : Error.captureStackTrace ? Error.captureStackTrace(this, e) : Object.defineProperty(this, "stack", { | ||
| value: Error().stack, | ||
| writable: !0, | ||
| configurable: !0 | ||
| }); | ||
| } | ||
| get [Symbol.toStringTag]() { | ||
| return "GraphQLError"; | ||
| } | ||
| toString() { | ||
| let t = this.message; | ||
| if (this.nodes) for (let n of this.nodes) n.loc && (t += ` | ||
| ` + qe(n.loc)); | ||
| else if (this.source && this.locations) for (let n of this.locations) t += ` | ||
| ` + ue(this.source, n); | ||
| return t; | ||
| } | ||
| toJSON() { | ||
| let t = { message: this.message }; | ||
| return this.locations != null && (t.locations = this.locations), this.path != null && (t.path = this.path), this.extensions != null && Object.keys(this.extensions).length > 0 && (t.extensions = this.extensions), t; | ||
| } | ||
| }; | ||
| (function(e) { | ||
| e.QUERY = "QUERY", e.MUTATION = "MUTATION", e.SUBSCRIPTION = "SUBSCRIPTION", e.FIELD = "FIELD", e.FRAGMENT_DEFINITION = "FRAGMENT_DEFINITION", e.FRAGMENT_SPREAD = "FRAGMENT_SPREAD", e.INLINE_FRAGMENT = "INLINE_FRAGMENT", e.VARIABLE_DEFINITION = "VARIABLE_DEFINITION", e.SCHEMA = "SCHEMA", e.SCALAR = "SCALAR", e.OBJECT = "OBJECT", e.FIELD_DEFINITION = "FIELD_DEFINITION", e.ARGUMENT_DEFINITION = "ARGUMENT_DEFINITION", e.INTERFACE = "INTERFACE", e.UNION = "UNION", e.ENUM = "ENUM", e.ENUM_VALUE = "ENUM_VALUE", e.INPUT_OBJECT = "INPUT_OBJECT", e.INPUT_FIELD_DEFINITION = "INPUT_FIELD_DEFINITION"; | ||
| })(W || (W = {})); | ||
| (function(e) { | ||
| e.NAME = "Name", e.DOCUMENT = "Document", e.OPERATION_DEFINITION = "OperationDefinition", e.VARIABLE_DEFINITION = "VariableDefinition", e.SELECTION_SET = "SelectionSet", e.FIELD = "Field", e.ARGUMENT = "Argument", e.FRAGMENT_SPREAD = "FragmentSpread", e.INLINE_FRAGMENT = "InlineFragment", e.FRAGMENT_DEFINITION = "FragmentDefinition", e.VARIABLE = "Variable", e.INT = "IntValue", e.FLOAT = "FloatValue", e.STRING = "StringValue", e.BOOLEAN = "BooleanValue", e.NULL = "NullValue", e.ENUM = "EnumValue", e.LIST = "ListValue", e.OBJECT = "ObjectValue", e.OBJECT_FIELD = "ObjectField", e.DIRECTIVE = "Directive", e.NAMED_TYPE = "NamedType", e.LIST_TYPE = "ListType", e.NON_NULL_TYPE = "NonNullType", e.SCHEMA_DEFINITION = "SchemaDefinition", e.OPERATION_TYPE_DEFINITION = "OperationTypeDefinition", e.SCALAR_TYPE_DEFINITION = "ScalarTypeDefinition", e.OBJECT_TYPE_DEFINITION = "ObjectTypeDefinition", e.FIELD_DEFINITION = "FieldDefinition", e.INPUT_VALUE_DEFINITION = "InputValueDefinition", e.INTERFACE_TYPE_DEFINITION = "InterfaceTypeDefinition", e.UNION_TYPE_DEFINITION = "UnionTypeDefinition", e.ENUM_TYPE_DEFINITION = "EnumTypeDefinition", e.ENUM_VALUE_DEFINITION = "EnumValueDefinition", e.INPUT_OBJECT_TYPE_DEFINITION = "InputObjectTypeDefinition", e.DIRECTIVE_DEFINITION = "DirectiveDefinition", e.SCHEMA_EXTENSION = "SchemaExtension", e.SCALAR_TYPE_EXTENSION = "ScalarTypeExtension", e.OBJECT_TYPE_EXTENSION = "ObjectTypeExtension", e.INTERFACE_TYPE_EXTENSION = "InterfaceTypeExtension", e.UNION_TYPE_EXTENSION = "UnionTypeExtension", e.ENUM_TYPE_EXTENSION = "EnumTypeExtension", e.INPUT_OBJECT_TYPE_EXTENSION = "InputObjectTypeExtension", e.TYPE_COORDINATE = "TypeCoordinate", e.MEMBER_COORDINATE = "MemberCoordinate", e.ARGUMENT_COORDINATE = "ArgumentCoordinate", e.DIRECTIVE_COORDINATE = "DirectiveCoordinate", e.DIRECTIVE_ARGUMENT_COORDINATE = "DirectiveArgumentCoordinate"; | ||
| })(c || (c = {})); | ||
| (function(e) { | ||
| e.SOF = "<SOF>", e.EOF = "<EOF>", e.BANG = "!", e.DOLLAR = "$", e.AMP = "&", e.PAREN_L = "(", e.PAREN_R = ")", e.DOT = ".", e.SPREAD = "...", e.COLON = ":", e.EQUALS = "=", e.AT = "@", e.BRACKET_L = "[", e.BRACKET_R = "]", e.BRACE_L = "{", e.PIPE = "|", e.BRACE_R = "}", e.NAME = "Name", e.INT = "Int", e.FLOAT = "Float", e.STRING = "String", e.BLOCK_STRING = "BlockString", e.COMMENT = "Comment"; | ||
| })(o || (o = {})); | ||
| z = class { | ||
| constructor(t) { | ||
| let n = new F(o.SOF, 0, 0, 0, 0); | ||
| this.source = t, this.lastToken = n, this.token = n, this.line = 1, this.lineStart = 0; | ||
| } | ||
| get [Symbol.toStringTag]() { | ||
| return "Lexer"; | ||
| } | ||
| advance() { | ||
| return this.lastToken = this.token, this.token = this.lookahead(); | ||
| } | ||
| lookahead() { | ||
| let t = this.token; | ||
| if (t.kind !== o.EOF) do | ||
| if (t.next) t = t.next; | ||
| else { | ||
| let n = wt(this, t.end); | ||
| t.next = n, n.prev = t, t = n; | ||
| } | ||
| while (t.kind === o.COMMENT); | ||
| return t; | ||
| } | ||
| }; | ||
| it = globalThis.process && !0 ? function(t, n) { | ||
| return t instanceof n; | ||
| } : function(t, n) { | ||
| if (t instanceof n) return !0; | ||
| if (typeof t == "object" && t !== null) { | ||
| var i; | ||
| let r = n.prototype[Symbol.toStringTag]; | ||
| if (r === (Symbol.toStringTag in t ? t[Symbol.toStringTag] : (i = t.constructor) === null || i === void 0 ? void 0 : i.name)) { | ||
| let a = ee(t); | ||
| throw new Error(`Cannot use ${r} "${a}" from another module or realm. | ||
| Ensure that there is only one instance of "graphql" in the node_modules | ||
| directory. If different versions of "graphql" are the dependencies of other | ||
| relied on modules, use "resolutions" to ensure only one version is installed. | ||
| https://yarnpkg.com/en/docs/selective-version-resolutions | ||
| Duplicate "graphql" modules cannot be used at the same time since different | ||
| versions may have different capabilities and behavior. The data from one | ||
| version used in the function from another could produce confusing and | ||
| spurious results.`); | ||
| } | ||
| } | ||
| return !1; | ||
| }; | ||
| B = class { | ||
| constructor(t, n = "GraphQL request", i = { | ||
| line: 1, | ||
| column: 1 | ||
| }) { | ||
| typeof t == "string" || Z(!1, `Body must be a string. Received: ${ee(t)}.`), this.body = t, this.name = n, this.locationOffset = i, this.locationOffset.line > 0 || Z(!1, "line in locationOffset is 1-indexed and must be positive."), this.locationOffset.column > 0 || Z(!1, "column in locationOffset is 1-indexed and must be positive."); | ||
| } | ||
| get [Symbol.toStringTag]() { | ||
| return "Source"; | ||
| } | ||
| }; | ||
| fe = class { | ||
| constructor(t, n = {}) { | ||
| let { lexer: i, ...r } = n; | ||
| if (i) this._lexer = i; | ||
| else { | ||
| let s = st(t) ? t : new B(t); | ||
| this._lexer = new z(s); | ||
| } | ||
| this._options = r, this._tokenCounter = 0; | ||
| } | ||
| get tokenCount() { | ||
| return this._tokenCounter; | ||
| } | ||
| parseName() { | ||
| let t = this.expectToken(o.NAME); | ||
| return this.node(t, { | ||
| kind: c.NAME, | ||
| value: t.value | ||
| }); | ||
| } | ||
| parseDocument() { | ||
| return this.node(this._lexer.token, { | ||
| kind: c.DOCUMENT, | ||
| definitions: this.many(o.SOF, this.parseDefinition, o.EOF) | ||
| }); | ||
| } | ||
| parseDefinition() { | ||
| if (this.peek(o.BRACE_L)) return this.parseOperationDefinition(); | ||
| let t = this.peekDescription(), n = t ? this._lexer.lookahead() : this._lexer.token; | ||
| if (t && n.kind === o.BRACE_L) throw h(this._lexer.source, this._lexer.token.start, "Unexpected description, descriptions are not supported on shorthand queries."); | ||
| if (n.kind === o.NAME) { | ||
| switch (n.value) { | ||
| case "schema": return this.parseSchemaDefinition(); | ||
| case "scalar": return this.parseScalarTypeDefinition(); | ||
| case "type": return this.parseObjectTypeDefinition(); | ||
| case "interface": return this.parseInterfaceTypeDefinition(); | ||
| case "union": return this.parseUnionTypeDefinition(); | ||
| case "enum": return this.parseEnumTypeDefinition(); | ||
| case "input": return this.parseInputObjectTypeDefinition(); | ||
| case "directive": return this.parseDirectiveDefinition(); | ||
| } | ||
| switch (n.value) { | ||
| case "query": | ||
| case "mutation": | ||
| case "subscription": return this.parseOperationDefinition(); | ||
| case "fragment": return this.parseFragmentDefinition(); | ||
| } | ||
| if (t) throw h(this._lexer.source, this._lexer.token.start, "Unexpected description, only GraphQL definitions support descriptions."); | ||
| switch (n.value) { | ||
| case "extend": return this.parseTypeSystemExtension(); | ||
| } | ||
| } | ||
| throw this.unexpected(n); | ||
| } | ||
| parseOperationDefinition() { | ||
| let t = this._lexer.token; | ||
| if (this.peek(o.BRACE_L)) return this.node(t, { | ||
| kind: c.OPERATION_DEFINITION, | ||
| operation: C.QUERY, | ||
| description: void 0, | ||
| name: void 0, | ||
| variableDefinitions: [], | ||
| directives: [], | ||
| selectionSet: this.parseSelectionSet() | ||
| }); | ||
| let n = this.parseDescription(), i = this.parseOperationType(), r; | ||
| return this.peek(o.NAME) && (r = this.parseName()), this.node(t, { | ||
| kind: c.OPERATION_DEFINITION, | ||
| operation: i, | ||
| description: n, | ||
| name: r, | ||
| variableDefinitions: this.parseVariableDefinitions(), | ||
| directives: this.parseDirectives(!1), | ||
| selectionSet: this.parseSelectionSet() | ||
| }); | ||
| } | ||
| parseOperationType() { | ||
| let t = this.expectToken(o.NAME); | ||
| switch (t.value) { | ||
| case "query": return C.QUERY; | ||
| case "mutation": return C.MUTATION; | ||
| case "subscription": return C.SUBSCRIPTION; | ||
| } | ||
| throw this.unexpected(t); | ||
| } | ||
| parseVariableDefinitions() { | ||
| return this.optionalMany(o.PAREN_L, this.parseVariableDefinition, o.PAREN_R); | ||
| } | ||
| parseVariableDefinition() { | ||
| return this.node(this._lexer.token, { | ||
| kind: c.VARIABLE_DEFINITION, | ||
| description: this.parseDescription(), | ||
| variable: this.parseVariable(), | ||
| type: (this.expectToken(o.COLON), this.parseTypeReference()), | ||
| defaultValue: this.expectOptionalToken(o.EQUALS) ? this.parseConstValueLiteral() : void 0, | ||
| directives: this.parseConstDirectives() | ||
| }); | ||
| } | ||
| parseVariable() { | ||
| let t = this._lexer.token; | ||
| return this.expectToken(o.DOLLAR), this.node(t, { | ||
| kind: c.VARIABLE, | ||
| name: this.parseName() | ||
| }); | ||
| } | ||
| parseSelectionSet() { | ||
| return this.node(this._lexer.token, { | ||
| kind: c.SELECTION_SET, | ||
| selections: this.many(o.BRACE_L, this.parseSelection, o.BRACE_R) | ||
| }); | ||
| } | ||
| parseSelection() { | ||
| return this.peek(o.SPREAD) ? this.parseFragment() : this.parseField(); | ||
| } | ||
| parseField() { | ||
| let t = this._lexer.token, n = this.parseName(), i, r; | ||
| return this.expectOptionalToken(o.COLON) ? (i = n, r = this.parseName()) : r = n, this.node(t, { | ||
| kind: c.FIELD, | ||
| alias: i, | ||
| name: r, | ||
| arguments: this.parseArguments(!1), | ||
| directives: this.parseDirectives(!1), | ||
| selectionSet: this.peek(o.BRACE_L) ? this.parseSelectionSet() : void 0 | ||
| }); | ||
| } | ||
| parseArguments(t) { | ||
| let n = t ? this.parseConstArgument : this.parseArgument; | ||
| return this.optionalMany(o.PAREN_L, n, o.PAREN_R); | ||
| } | ||
| parseArgument(t = !1) { | ||
| let n = this._lexer.token, i = this.parseName(); | ||
| return this.expectToken(o.COLON), this.node(n, { | ||
| kind: c.ARGUMENT, | ||
| name: i, | ||
| value: this.parseValueLiteral(t) | ||
| }); | ||
| } | ||
| parseConstArgument() { | ||
| return this.parseArgument(!0); | ||
| } | ||
| parseFragment() { | ||
| let t = this._lexer.token; | ||
| this.expectToken(o.SPREAD); | ||
| let n = this.expectOptionalKeyword("on"); | ||
| return !n && this.peek(o.NAME) ? this.node(t, { | ||
| kind: c.FRAGMENT_SPREAD, | ||
| name: this.parseFragmentName(), | ||
| directives: this.parseDirectives(!1) | ||
| }) : this.node(t, { | ||
| kind: c.INLINE_FRAGMENT, | ||
| typeCondition: n ? this.parseNamedType() : void 0, | ||
| directives: this.parseDirectives(!1), | ||
| selectionSet: this.parseSelectionSet() | ||
| }); | ||
| } | ||
| parseFragmentDefinition() { | ||
| let t = this._lexer.token, n = this.parseDescription(); | ||
| return this.expectKeyword("fragment"), this._options.allowLegacyFragmentVariables === !0 ? this.node(t, { | ||
| kind: c.FRAGMENT_DEFINITION, | ||
| description: n, | ||
| name: this.parseFragmentName(), | ||
| variableDefinitions: this.parseVariableDefinitions(), | ||
| typeCondition: (this.expectKeyword("on"), this.parseNamedType()), | ||
| directives: this.parseDirectives(!1), | ||
| selectionSet: this.parseSelectionSet() | ||
| }) : this.node(t, { | ||
| kind: c.FRAGMENT_DEFINITION, | ||
| description: n, | ||
| name: this.parseFragmentName(), | ||
| typeCondition: (this.expectKeyword("on"), this.parseNamedType()), | ||
| directives: this.parseDirectives(!1), | ||
| selectionSet: this.parseSelectionSet() | ||
| }); | ||
| } | ||
| parseFragmentName() { | ||
| if (this._lexer.token.value === "on") throw this.unexpected(); | ||
| return this.parseName(); | ||
| } | ||
| parseValueLiteral(t) { | ||
| let n = this._lexer.token; | ||
| switch (n.kind) { | ||
| case o.BRACKET_L: return this.parseList(t); | ||
| case o.BRACE_L: return this.parseObject(t); | ||
| case o.INT: return this.advanceLexer(), this.node(n, { | ||
| kind: c.INT, | ||
| value: n.value | ||
| }); | ||
| case o.FLOAT: return this.advanceLexer(), this.node(n, { | ||
| kind: c.FLOAT, | ||
| value: n.value | ||
| }); | ||
| case o.STRING: | ||
| case o.BLOCK_STRING: return this.parseStringLiteral(); | ||
| case o.NAME: switch (this.advanceLexer(), n.value) { | ||
| case "true": return this.node(n, { | ||
| kind: c.BOOLEAN, | ||
| value: !0 | ||
| }); | ||
| case "false": return this.node(n, { | ||
| kind: c.BOOLEAN, | ||
| value: !1 | ||
| }); | ||
| case "null": return this.node(n, { kind: c.NULL }); | ||
| default: return this.node(n, { | ||
| kind: c.ENUM, | ||
| value: n.value | ||
| }); | ||
| } | ||
| case o.DOLLAR: | ||
| if (t) if (this.expectToken(o.DOLLAR), this._lexer.token.kind === o.NAME) { | ||
| let i = this._lexer.token.value; | ||
| throw h(this._lexer.source, n.start, `Unexpected variable "$${i}" in constant value.`); | ||
| } else throw this.unexpected(n); | ||
| return this.parseVariable(); | ||
| default: throw this.unexpected(); | ||
| } | ||
| } | ||
| parseConstValueLiteral() { | ||
| return this.parseValueLiteral(!0); | ||
| } | ||
| parseStringLiteral() { | ||
| let t = this._lexer.token; | ||
| return this.advanceLexer(), this.node(t, { | ||
| kind: c.STRING, | ||
| value: t.value, | ||
| block: t.kind === o.BLOCK_STRING | ||
| }); | ||
| } | ||
| parseList(t) { | ||
| let n = () => this.parseValueLiteral(t); | ||
| return this.node(this._lexer.token, { | ||
| kind: c.LIST, | ||
| values: this.any(o.BRACKET_L, n, o.BRACKET_R) | ||
| }); | ||
| } | ||
| parseObject(t) { | ||
| let n = () => this.parseObjectField(t); | ||
| return this.node(this._lexer.token, { | ||
| kind: c.OBJECT, | ||
| fields: this.any(o.BRACE_L, n, o.BRACE_R) | ||
| }); | ||
| } | ||
| parseObjectField(t) { | ||
| let n = this._lexer.token, i = this.parseName(); | ||
| return this.expectToken(o.COLON), this.node(n, { | ||
| kind: c.OBJECT_FIELD, | ||
| name: i, | ||
| value: this.parseValueLiteral(t) | ||
| }); | ||
| } | ||
| parseDirectives(t) { | ||
| let n = []; | ||
| for (; this.peek(o.AT);) n.push(this.parseDirective(t)); | ||
| return n; | ||
| } | ||
| parseConstDirectives() { | ||
| return this.parseDirectives(!0); | ||
| } | ||
| parseDirective(t) { | ||
| let n = this._lexer.token; | ||
| return this.expectToken(o.AT), this.node(n, { | ||
| kind: c.DIRECTIVE, | ||
| name: this.parseName(), | ||
| arguments: this.parseArguments(t) | ||
| }); | ||
| } | ||
| parseTypeReference() { | ||
| let t = this._lexer.token, n; | ||
| if (this.expectOptionalToken(o.BRACKET_L)) { | ||
| let i = this.parseTypeReference(); | ||
| this.expectToken(o.BRACKET_R), n = this.node(t, { | ||
| kind: c.LIST_TYPE, | ||
| type: i | ||
| }); | ||
| } else n = this.parseNamedType(); | ||
| return this.expectOptionalToken(o.BANG) ? this.node(t, { | ||
| kind: c.NON_NULL_TYPE, | ||
| type: n | ||
| }) : n; | ||
| } | ||
| parseNamedType() { | ||
| return this.node(this._lexer.token, { | ||
| kind: c.NAMED_TYPE, | ||
| name: this.parseName() | ||
| }); | ||
| } | ||
| peekDescription() { | ||
| return this.peek(o.STRING) || this.peek(o.BLOCK_STRING); | ||
| } | ||
| parseDescription() { | ||
| if (this.peekDescription()) return this.parseStringLiteral(); | ||
| } | ||
| parseSchemaDefinition() { | ||
| let t = this._lexer.token, n = this.parseDescription(); | ||
| this.expectKeyword("schema"); | ||
| let i = this.parseConstDirectives(), r = this.many(o.BRACE_L, this.parseOperationTypeDefinition, o.BRACE_R); | ||
| return this.node(t, { | ||
| kind: c.SCHEMA_DEFINITION, | ||
| description: n, | ||
| directives: i, | ||
| operationTypes: r | ||
| }); | ||
| } | ||
| parseOperationTypeDefinition() { | ||
| let t = this._lexer.token, n = this.parseOperationType(); | ||
| this.expectToken(o.COLON); | ||
| let i = this.parseNamedType(); | ||
| return this.node(t, { | ||
| kind: c.OPERATION_TYPE_DEFINITION, | ||
| operation: n, | ||
| type: i | ||
| }); | ||
| } | ||
| parseScalarTypeDefinition() { | ||
| let t = this._lexer.token, n = this.parseDescription(); | ||
| this.expectKeyword("scalar"); | ||
| let i = this.parseName(), r = this.parseConstDirectives(); | ||
| return this.node(t, { | ||
| kind: c.SCALAR_TYPE_DEFINITION, | ||
| description: n, | ||
| name: i, | ||
| directives: r | ||
| }); | ||
| } | ||
| parseObjectTypeDefinition() { | ||
| let t = this._lexer.token, n = this.parseDescription(); | ||
| this.expectKeyword("type"); | ||
| let i = this.parseName(), r = this.parseImplementsInterfaces(), s = this.parseConstDirectives(), a = this.parseFieldsDefinition(); | ||
| return this.node(t, { | ||
| kind: c.OBJECT_TYPE_DEFINITION, | ||
| description: n, | ||
| name: i, | ||
| interfaces: r, | ||
| directives: s, | ||
| fields: a | ||
| }); | ||
| } | ||
| parseImplementsInterfaces() { | ||
| return this.expectOptionalKeyword("implements") ? this.delimitedMany(o.AMP, this.parseNamedType) : []; | ||
| } | ||
| parseFieldsDefinition() { | ||
| return this.optionalMany(o.BRACE_L, this.parseFieldDefinition, o.BRACE_R); | ||
| } | ||
| parseFieldDefinition() { | ||
| let t = this._lexer.token, n = this.parseDescription(), i = this.parseName(), r = this.parseArgumentDefs(); | ||
| this.expectToken(o.COLON); | ||
| let s = this.parseTypeReference(), a = this.parseConstDirectives(); | ||
| return this.node(t, { | ||
| kind: c.FIELD_DEFINITION, | ||
| description: n, | ||
| name: i, | ||
| arguments: r, | ||
| type: s, | ||
| directives: a | ||
| }); | ||
| } | ||
| parseArgumentDefs() { | ||
| return this.optionalMany(o.PAREN_L, this.parseInputValueDef, o.PAREN_R); | ||
| } | ||
| parseInputValueDef() { | ||
| let t = this._lexer.token, n = this.parseDescription(), i = this.parseName(); | ||
| this.expectToken(o.COLON); | ||
| let r = this.parseTypeReference(), s; | ||
| this.expectOptionalToken(o.EQUALS) && (s = this.parseConstValueLiteral()); | ||
| let a = this.parseConstDirectives(); | ||
| return this.node(t, { | ||
| kind: c.INPUT_VALUE_DEFINITION, | ||
| description: n, | ||
| name: i, | ||
| type: r, | ||
| defaultValue: s, | ||
| directives: a | ||
| }); | ||
| } | ||
| parseInterfaceTypeDefinition() { | ||
| let t = this._lexer.token, n = this.parseDescription(); | ||
| this.expectKeyword("interface"); | ||
| let i = this.parseName(), r = this.parseImplementsInterfaces(), s = this.parseConstDirectives(), a = this.parseFieldsDefinition(); | ||
| return this.node(t, { | ||
| kind: c.INTERFACE_TYPE_DEFINITION, | ||
| description: n, | ||
| name: i, | ||
| interfaces: r, | ||
| directives: s, | ||
| fields: a | ||
| }); | ||
| } | ||
| parseUnionTypeDefinition() { | ||
| let t = this._lexer.token, n = this.parseDescription(); | ||
| this.expectKeyword("union"); | ||
| let i = this.parseName(), r = this.parseConstDirectives(), s = this.parseUnionMemberTypes(); | ||
| return this.node(t, { | ||
| kind: c.UNION_TYPE_DEFINITION, | ||
| description: n, | ||
| name: i, | ||
| directives: r, | ||
| types: s | ||
| }); | ||
| } | ||
| parseUnionMemberTypes() { | ||
| return this.expectOptionalToken(o.EQUALS) ? this.delimitedMany(o.PIPE, this.parseNamedType) : []; | ||
| } | ||
| parseEnumTypeDefinition() { | ||
| let t = this._lexer.token, n = this.parseDescription(); | ||
| this.expectKeyword("enum"); | ||
| let i = this.parseName(), r = this.parseConstDirectives(), s = this.parseEnumValuesDefinition(); | ||
| return this.node(t, { | ||
| kind: c.ENUM_TYPE_DEFINITION, | ||
| description: n, | ||
| name: i, | ||
| directives: r, | ||
| values: s | ||
| }); | ||
| } | ||
| parseEnumValuesDefinition() { | ||
| return this.optionalMany(o.BRACE_L, this.parseEnumValueDefinition, o.BRACE_R); | ||
| } | ||
| parseEnumValueDefinition() { | ||
| let t = this._lexer.token, n = this.parseDescription(), i = this.parseEnumValueName(), r = this.parseConstDirectives(); | ||
| return this.node(t, { | ||
| kind: c.ENUM_VALUE_DEFINITION, | ||
| description: n, | ||
| name: i, | ||
| directives: r | ||
| }); | ||
| } | ||
| parseEnumValueName() { | ||
| if (this._lexer.token.value === "true" || this._lexer.token.value === "false" || this._lexer.token.value === "null") throw h(this._lexer.source, this._lexer.token.start, `${ne(this._lexer.token)} is reserved and cannot be used for an enum value.`); | ||
| return this.parseName(); | ||
| } | ||
| parseInputObjectTypeDefinition() { | ||
| let t = this._lexer.token, n = this.parseDescription(); | ||
| this.expectKeyword("input"); | ||
| let i = this.parseName(), r = this.parseConstDirectives(), s = this.parseInputFieldsDefinition(); | ||
| return this.node(t, { | ||
| kind: c.INPUT_OBJECT_TYPE_DEFINITION, | ||
| description: n, | ||
| name: i, | ||
| directives: r, | ||
| fields: s | ||
| }); | ||
| } | ||
| parseInputFieldsDefinition() { | ||
| return this.optionalMany(o.BRACE_L, this.parseInputValueDef, o.BRACE_R); | ||
| } | ||
| parseTypeSystemExtension() { | ||
| let t = this._lexer.lookahead(); | ||
| if (t.kind === o.NAME) switch (t.value) { | ||
| case "schema": return this.parseSchemaExtension(); | ||
| case "scalar": return this.parseScalarTypeExtension(); | ||
| case "type": return this.parseObjectTypeExtension(); | ||
| case "interface": return this.parseInterfaceTypeExtension(); | ||
| case "union": return this.parseUnionTypeExtension(); | ||
| case "enum": return this.parseEnumTypeExtension(); | ||
| case "input": return this.parseInputObjectTypeExtension(); | ||
| } | ||
| throw this.unexpected(t); | ||
| } | ||
| parseSchemaExtension() { | ||
| let t = this._lexer.token; | ||
| this.expectKeyword("extend"), this.expectKeyword("schema"); | ||
| let n = this.parseConstDirectives(), i = this.optionalMany(o.BRACE_L, this.parseOperationTypeDefinition, o.BRACE_R); | ||
| if (n.length === 0 && i.length === 0) throw this.unexpected(); | ||
| return this.node(t, { | ||
| kind: c.SCHEMA_EXTENSION, | ||
| directives: n, | ||
| operationTypes: i | ||
| }); | ||
| } | ||
| parseScalarTypeExtension() { | ||
| let t = this._lexer.token; | ||
| this.expectKeyword("extend"), this.expectKeyword("scalar"); | ||
| let n = this.parseName(), i = this.parseConstDirectives(); | ||
| if (i.length === 0) throw this.unexpected(); | ||
| return this.node(t, { | ||
| kind: c.SCALAR_TYPE_EXTENSION, | ||
| name: n, | ||
| directives: i | ||
| }); | ||
| } | ||
| parseObjectTypeExtension() { | ||
| let t = this._lexer.token; | ||
| this.expectKeyword("extend"), this.expectKeyword("type"); | ||
| let n = this.parseName(), i = this.parseImplementsInterfaces(), r = this.parseConstDirectives(), s = this.parseFieldsDefinition(); | ||
| if (i.length === 0 && r.length === 0 && s.length === 0) throw this.unexpected(); | ||
| return this.node(t, { | ||
| kind: c.OBJECT_TYPE_EXTENSION, | ||
| name: n, | ||
| interfaces: i, | ||
| directives: r, | ||
| fields: s | ||
| }); | ||
| } | ||
| parseInterfaceTypeExtension() { | ||
| let t = this._lexer.token; | ||
| this.expectKeyword("extend"), this.expectKeyword("interface"); | ||
| let n = this.parseName(), i = this.parseImplementsInterfaces(), r = this.parseConstDirectives(), s = this.parseFieldsDefinition(); | ||
| if (i.length === 0 && r.length === 0 && s.length === 0) throw this.unexpected(); | ||
| return this.node(t, { | ||
| kind: c.INTERFACE_TYPE_EXTENSION, | ||
| name: n, | ||
| interfaces: i, | ||
| directives: r, | ||
| fields: s | ||
| }); | ||
| } | ||
| parseUnionTypeExtension() { | ||
| let t = this._lexer.token; | ||
| this.expectKeyword("extend"), this.expectKeyword("union"); | ||
| let n = this.parseName(), i = this.parseConstDirectives(), r = this.parseUnionMemberTypes(); | ||
| if (i.length === 0 && r.length === 0) throw this.unexpected(); | ||
| return this.node(t, { | ||
| kind: c.UNION_TYPE_EXTENSION, | ||
| name: n, | ||
| directives: i, | ||
| types: r | ||
| }); | ||
| } | ||
| parseEnumTypeExtension() { | ||
| let t = this._lexer.token; | ||
| this.expectKeyword("extend"), this.expectKeyword("enum"); | ||
| let n = this.parseName(), i = this.parseConstDirectives(), r = this.parseEnumValuesDefinition(); | ||
| if (i.length === 0 && r.length === 0) throw this.unexpected(); | ||
| return this.node(t, { | ||
| kind: c.ENUM_TYPE_EXTENSION, | ||
| name: n, | ||
| directives: i, | ||
| values: r | ||
| }); | ||
| } | ||
| parseInputObjectTypeExtension() { | ||
| let t = this._lexer.token; | ||
| this.expectKeyword("extend"), this.expectKeyword("input"); | ||
| let n = this.parseName(), i = this.parseConstDirectives(), r = this.parseInputFieldsDefinition(); | ||
| if (i.length === 0 && r.length === 0) throw this.unexpected(); | ||
| return this.node(t, { | ||
| kind: c.INPUT_OBJECT_TYPE_EXTENSION, | ||
| name: n, | ||
| directives: i, | ||
| fields: r | ||
| }); | ||
| } | ||
| parseDirectiveDefinition() { | ||
| let t = this._lexer.token, n = this.parseDescription(); | ||
| this.expectKeyword("directive"), this.expectToken(o.AT); | ||
| let i = this.parseName(), r = this.parseArgumentDefs(), s = this.expectOptionalKeyword("repeatable"); | ||
| this.expectKeyword("on"); | ||
| let a = this.parseDirectiveLocations(); | ||
| return this.node(t, { | ||
| kind: c.DIRECTIVE_DEFINITION, | ||
| description: n, | ||
| name: i, | ||
| arguments: r, | ||
| repeatable: s, | ||
| locations: a | ||
| }); | ||
| } | ||
| parseDirectiveLocations() { | ||
| return this.delimitedMany(o.PIPE, this.parseDirectiveLocation); | ||
| } | ||
| parseDirectiveLocation() { | ||
| let t = this._lexer.token, n = this.parseName(); | ||
| if (Object.prototype.hasOwnProperty.call(W, n.value)) return n; | ||
| throw this.unexpected(t); | ||
| } | ||
| parseSchemaCoordinate() { | ||
| let t = this._lexer.token, n = this.expectOptionalToken(o.AT), i = this.parseName(), r; | ||
| !n && this.expectOptionalToken(o.DOT) && (r = this.parseName()); | ||
| let s; | ||
| return (n || r) && this.expectOptionalToken(o.PAREN_L) && (s = this.parseName(), this.expectToken(o.COLON), this.expectToken(o.PAREN_R)), n ? s ? this.node(t, { | ||
| kind: c.DIRECTIVE_ARGUMENT_COORDINATE, | ||
| name: i, | ||
| argumentName: s | ||
| }) : this.node(t, { | ||
| kind: c.DIRECTIVE_COORDINATE, | ||
| name: i | ||
| }) : r ? s ? this.node(t, { | ||
| kind: c.ARGUMENT_COORDINATE, | ||
| name: i, | ||
| fieldName: r, | ||
| argumentName: s | ||
| }) : this.node(t, { | ||
| kind: c.MEMBER_COORDINATE, | ||
| name: i, | ||
| memberName: r | ||
| }) : this.node(t, { | ||
| kind: c.TYPE_COORDINATE, | ||
| name: i | ||
| }); | ||
| } | ||
| node(t, n) { | ||
| return this._options.noLocation !== !0 && (n.loc = new H(t, this._lexer.lastToken, this._lexer.source)), n; | ||
| } | ||
| peek(t) { | ||
| return this._lexer.token.kind === t; | ||
| } | ||
| expectToken(t) { | ||
| let n = this._lexer.token; | ||
| if (n.kind === t) return this.advanceLexer(), n; | ||
| throw h(this._lexer.source, n.start, `Expected ${at(t)}, found ${ne(n)}.`); | ||
| } | ||
| expectOptionalToken(t) { | ||
| return this._lexer.token.kind === t ? (this.advanceLexer(), !0) : !1; | ||
| } | ||
| expectKeyword(t) { | ||
| let n = this._lexer.token; | ||
| if (n.kind === o.NAME && n.value === t) this.advanceLexer(); | ||
| else throw h(this._lexer.source, n.start, `Expected "${t}", found ${ne(n)}.`); | ||
| } | ||
| expectOptionalKeyword(t) { | ||
| let n = this._lexer.token; | ||
| return n.kind === o.NAME && n.value === t ? (this.advanceLexer(), !0) : !1; | ||
| } | ||
| unexpected(t) { | ||
| let n = t ?? this._lexer.token; | ||
| return h(this._lexer.source, n.start, `Unexpected ${ne(n)}.`); | ||
| } | ||
| any(t, n, i) { | ||
| this.expectToken(t); | ||
| let r = []; | ||
| for (; !this.expectOptionalToken(i);) r.push(n.call(this)); | ||
| return r; | ||
| } | ||
| optionalMany(t, n, i) { | ||
| if (this.expectOptionalToken(t)) { | ||
| let r = []; | ||
| do | ||
| r.push(n.call(this)); | ||
| while (!this.expectOptionalToken(i)); | ||
| return r; | ||
| } | ||
| return []; | ||
| } | ||
| many(t, n, i) { | ||
| this.expectToken(t); | ||
| let r = []; | ||
| do | ||
| r.push(n.call(this)); | ||
| while (!this.expectOptionalToken(i)); | ||
| return r; | ||
| } | ||
| delimitedMany(t, n) { | ||
| this.expectOptionalToken(t); | ||
| let i = []; | ||
| do | ||
| i.push(n.call(this)); | ||
| while (this.expectOptionalToken(t)); | ||
| return i; | ||
| } | ||
| advanceLexer() { | ||
| let { maxTokens: t } = this._options, n = this._lexer.advance(); | ||
| if (n.kind !== o.EOF && (++this._tokenCounter, t !== void 0 && this._tokenCounter > t)) throw h(this._lexer.source, n.start, `Document contains more that ${t} tokens. Parsing aborted.`); | ||
| } | ||
| }; | ||
| ct = Wt; | ||
| Kt = { allowLegacyFragmentVariables: !0 }; | ||
| tn = { | ||
| parse: en, | ||
| astFormat: "graphql", | ||
| hasPragma: Fe, | ||
| hasIgnorePragma: Me, | ||
| locStart: J, | ||
| locEnd: q | ||
| }; | ||
| nn = { graphql: Ge }; | ||
| }))(); | ||
| export { ut as default, Ye as languages, $e as options, he as parsers, nn as printers }; |
Sorry, the diff of this file is too big to display
| import { i as saveOxfmtrcFile, n as exitWithError, r as hasOxfmtrcFile, t as createBlankOxfmtrcFile } from "./shared-BTEY2VsW.js"; | ||
| //#region src-js/cli/migration/init.ts | ||
| /** | ||
| * Run the `--init` command to scaffold a default `.oxfmtrc.json` file. | ||
| */ | ||
| async function runInit() { | ||
| const cwd = process.cwd(); | ||
| if (await hasOxfmtrcFile(cwd)) return exitWithError("Oxfmt configuration file already exists."); | ||
| const oxfmtrc = await createBlankOxfmtrcFile(cwd); | ||
| const jsonStr = JSON.stringify(oxfmtrc, null, 2); | ||
| try { | ||
| await saveOxfmtrcFile(cwd, jsonStr); | ||
| console.log("Created `.oxfmtrc.json`."); | ||
| } catch { | ||
| return exitWithError("Failed to create `.oxfmtrc.json`."); | ||
| } | ||
| } | ||
| //#endregion | ||
| export { runInit }; |
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 { i as saveOxfmtrcFile, n as exitWithError, r as hasOxfmtrcFile, t as createBlankOxfmtrcFile } from "./shared-BTEY2VsW.js"; | ||
| import { join } from "node:path"; | ||
| import { readFile } from "node:fs/promises"; | ||
| //#region src-js/cli/migration/migrate-biome.ts | ||
| const BIOME_DEFAULTS = { | ||
| lineWidth: 80, | ||
| indentStyle: "tab", | ||
| indentWidth: 2, | ||
| lineEnding: "lf", | ||
| attributePosition: "auto", | ||
| bracketSpacing: true, | ||
| quoteStyle: "double", | ||
| jsxQuoteStyle: "double", | ||
| quoteProperties: "asNeeded", | ||
| trailingCommas: "all", | ||
| semicolons: "always", | ||
| arrowParentheses: "always", | ||
| bracketSameLine: false | ||
| }; | ||
| /** | ||
| * Run the `--migrate biome` command to migrate Biome's config to `.oxfmtrc.json` file. | ||
| * https://biomejs.dev/reference/configuration/ | ||
| */ | ||
| async function runMigrateBiome() { | ||
| const cwd = process.cwd(); | ||
| if (await hasOxfmtrcFile(cwd)) return exitWithError("Oxfmt configuration file already exists."); | ||
| const biomeConfigPath = await resolveBiomeConfigFile(cwd); | ||
| if (!biomeConfigPath) { | ||
| console.log("No Biome configuration file found."); | ||
| const oxfmtrc = await createBlankOxfmtrcFile(cwd); | ||
| const jsonStr = JSON.stringify(oxfmtrc, null, 2); | ||
| try { | ||
| await saveOxfmtrcFile(cwd, jsonStr); | ||
| console.log("Created `.oxfmtrc.json` instead."); | ||
| } catch { | ||
| exitWithError("Failed to create `.oxfmtrc.json`."); | ||
| } | ||
| return; | ||
| } | ||
| let biomeConfig; | ||
| try { | ||
| biomeConfig = parseJSONC(await readFile(biomeConfigPath, "utf8")); | ||
| console.log("Found Biome configuration at:", biomeConfigPath); | ||
| } catch { | ||
| return exitWithError(`Failed to parse: ${biomeConfigPath}`); | ||
| } | ||
| const oxfmtrc = await createBlankOxfmtrcFile(cwd); | ||
| const formatterConfig = biomeConfig.formatter ?? {}; | ||
| const jsFormatterConfig = biomeConfig.javascript?.formatter ?? {}; | ||
| migrateIndentStyle(formatterConfig, jsFormatterConfig, oxfmtrc); | ||
| migrateIndentWidth(formatterConfig, jsFormatterConfig, oxfmtrc); | ||
| migrateLineWidth(formatterConfig, jsFormatterConfig, oxfmtrc); | ||
| migrateQuoteStyle(jsFormatterConfig, oxfmtrc); | ||
| migrateJsxQuoteStyle(jsFormatterConfig, oxfmtrc); | ||
| migrateQuoteProperties(jsFormatterConfig, oxfmtrc); | ||
| migrateTrailingCommas(jsFormatterConfig, oxfmtrc); | ||
| migrateSemicolons(jsFormatterConfig, oxfmtrc); | ||
| migrateArrowParentheses(jsFormatterConfig, oxfmtrc); | ||
| migrateBracketSameLine(formatterConfig, jsFormatterConfig, oxfmtrc); | ||
| migrateBracketSpacing(formatterConfig, jsFormatterConfig, oxfmtrc); | ||
| migrateAttributePosition(formatterConfig, jsFormatterConfig, oxfmtrc); | ||
| const ignores = extractIgnorePatterns(biomeConfig); | ||
| if (ignores.length > 0) console.log("Migrated ignore patterns from Biome config"); | ||
| delete oxfmtrc.ignorePatterns; | ||
| oxfmtrc.ignorePatterns = ignores; | ||
| if (biomeConfig.overrides && biomeConfig.overrides.length > 0) console.warn(` - "overrides" cannot be migrated automatically yet`); | ||
| const jsonStr = JSON.stringify(oxfmtrc, null, 2); | ||
| try { | ||
| await saveOxfmtrcFile(cwd, jsonStr); | ||
| console.log("Created `.oxfmtrc.json`."); | ||
| } catch { | ||
| return exitWithError("Failed to create `.oxfmtrc.json`."); | ||
| } | ||
| } | ||
| async function resolveBiomeConfigFile(cwd) { | ||
| for (const filename of ["biome.json", "biome.jsonc"]) { | ||
| const filepath = join(cwd, filename); | ||
| try { | ||
| await readFile(filepath, "utf8"); | ||
| return filepath; | ||
| } catch {} | ||
| } | ||
| return null; | ||
| } | ||
| const stringOrCommentRe = /("(?:\\?[^])*?")|(\/\/.*)|(\/\*[^]*?\*\/)/g; | ||
| const stringOrTrailingCommaRe = /("(?:\\?[^])*?")|(,\s*)(?=]|})/g; | ||
| function parseJSONC(text) { | ||
| text = String(text); | ||
| try { | ||
| return JSON.parse(text); | ||
| } catch { | ||
| return JSON.parse(text.replace(stringOrCommentRe, "$1").replace(stringOrTrailingCommaRe, "$1")); | ||
| } | ||
| } | ||
| function migrateIndentStyle(formatterConfig, jsFormatterConfig, oxfmtrc) { | ||
| const value = jsFormatterConfig.indentStyle ?? formatterConfig.indentStyle; | ||
| if (value !== void 0) oxfmtrc.useTabs = value === "tab"; | ||
| else oxfmtrc.useTabs = BIOME_DEFAULTS.indentStyle === "tab"; | ||
| } | ||
| function migrateIndentWidth(formatterConfig, jsFormatterConfig, oxfmtrc) { | ||
| const value = jsFormatterConfig.indentWidth ?? formatterConfig.indentWidth; | ||
| if (value !== void 0) oxfmtrc.tabWidth = value; | ||
| else oxfmtrc.tabWidth = BIOME_DEFAULTS.indentWidth; | ||
| } | ||
| function migrateLineWidth(formatterConfig, jsFormatterConfig, oxfmtrc) { | ||
| const value = jsFormatterConfig.lineWidth ?? formatterConfig.lineWidth; | ||
| if (value !== void 0) oxfmtrc.printWidth = value; | ||
| else oxfmtrc.printWidth = BIOME_DEFAULTS.lineWidth; | ||
| } | ||
| function migrateQuoteStyle(jsFormatterConfig, oxfmtrc) { | ||
| const value = jsFormatterConfig.quoteStyle; | ||
| if (value !== void 0) oxfmtrc.singleQuote = value === "single"; | ||
| else oxfmtrc.singleQuote = false; | ||
| } | ||
| function migrateJsxQuoteStyle(jsFormatterConfig, oxfmtrc) { | ||
| const value = jsFormatterConfig.jsxQuoteStyle; | ||
| if (value !== void 0) oxfmtrc.jsxSingleQuote = value === "single"; | ||
| else oxfmtrc.jsxSingleQuote = false; | ||
| } | ||
| function migrateQuoteProperties(jsFormatterConfig, oxfmtrc) { | ||
| const value = jsFormatterConfig.quoteProperties; | ||
| if (value !== void 0) { | ||
| if (value === "asNeeded") oxfmtrc.quoteProps = "as-needed"; | ||
| else if (value === "preserve") oxfmtrc.quoteProps = "preserve"; | ||
| } else oxfmtrc.quoteProps = "as-needed"; | ||
| } | ||
| function migrateTrailingCommas(jsFormatterConfig, oxfmtrc) { | ||
| const value = jsFormatterConfig.trailingCommas; | ||
| if (value !== void 0) oxfmtrc.trailingComma = value; | ||
| else oxfmtrc.trailingComma = BIOME_DEFAULTS.trailingCommas; | ||
| } | ||
| function migrateSemicolons(jsFormatterConfig, oxfmtrc) { | ||
| const value = jsFormatterConfig.semicolons; | ||
| if (value !== void 0) oxfmtrc.semi = value === "always"; | ||
| else oxfmtrc.semi = BIOME_DEFAULTS.semicolons === "always"; | ||
| } | ||
| function migrateArrowParentheses(jsFormatterConfig, oxfmtrc) { | ||
| const value = jsFormatterConfig.arrowParentheses; | ||
| if (value !== void 0) { | ||
| if (value === "always") oxfmtrc.arrowParens = "always"; | ||
| else if (value === "asNeeded") oxfmtrc.arrowParens = "avoid"; | ||
| } else oxfmtrc.arrowParens = BIOME_DEFAULTS.arrowParentheses === "always" ? "always" : "avoid"; | ||
| } | ||
| function migrateBracketSameLine(_formatterConfig, jsFormatterConfig, oxfmtrc) { | ||
| const value = jsFormatterConfig.bracketSameLine; | ||
| if (value !== void 0) oxfmtrc.bracketSameLine = value; | ||
| else oxfmtrc.bracketSameLine = BIOME_DEFAULTS.bracketSameLine; | ||
| } | ||
| function migrateBracketSpacing(formatterConfig, jsFormatterConfig, oxfmtrc) { | ||
| const value = jsFormatterConfig.bracketSpacing ?? formatterConfig.bracketSpacing; | ||
| if (value !== void 0) oxfmtrc.bracketSpacing = value; | ||
| else oxfmtrc.bracketSpacing = BIOME_DEFAULTS.bracketSpacing; | ||
| } | ||
| function migrateAttributePosition(formatterConfig, jsFormatterConfig, oxfmtrc) { | ||
| const value = jsFormatterConfig.attributePosition ?? formatterConfig.attributePosition; | ||
| if (value !== void 0) if (value === "multiline") oxfmtrc.singleAttributePerLine = true; | ||
| else oxfmtrc.singleAttributePerLine = false; | ||
| } | ||
| function extractIgnorePatterns(biomeConfig) { | ||
| const ignores = []; | ||
| if (biomeConfig.files?.includes) { | ||
| for (const pattern of biomeConfig.files.includes) if (pattern.startsWith("!") && !pattern.startsWith("!!")) ignores.push(pattern.slice(1)); | ||
| } | ||
| return ignores; | ||
| } | ||
| //#endregion | ||
| export { runMigrateBiome }; |
| import { i as saveOxfmtrcFile, n as exitWithError, r as hasOxfmtrcFile, t as createBlankOxfmtrcFile } from "./shared-BTEY2VsW.js"; | ||
| import { join } from "node:path"; | ||
| import { readFile } from "node:fs/promises"; | ||
| //#region src-js/cli/migration/migrate-prettier.ts | ||
| /** | ||
| * Run the `--migrate prettier` command to migrate various Prettier's config to `.oxfmtrc.json` file. | ||
| * https://prettier.io/docs/configuration | ||
| */ | ||
| async function runMigratePrettier() { | ||
| const cwd = process.cwd(); | ||
| if (await hasOxfmtrcFile(cwd)) return exitWithError("Oxfmt configuration file already exists."); | ||
| const { resolveConfigFile, resolveConfig } = await import("./prettier-s1WPCGVk.js"); | ||
| const prettierConfigPath = await resolveConfigFile(join(cwd, "dummy.js")); | ||
| if (!prettierConfigPath) { | ||
| console.log("No Prettier configuration file found."); | ||
| const oxfmtrc = await createBlankOxfmtrcFile(cwd); | ||
| const jsonStr = JSON.stringify(oxfmtrc, null, 2); | ||
| try { | ||
| await saveOxfmtrcFile(cwd, jsonStr); | ||
| console.log("Created `.oxfmtrc.json` instead."); | ||
| } catch { | ||
| exitWithError("Failed to create `.oxfmtrc.json`."); | ||
| } | ||
| return; | ||
| } | ||
| let prettierConfig; | ||
| try { | ||
| prettierConfig = await resolveConfig(prettierConfigPath, { editorconfig: false }); | ||
| console.log("Found Prettier configuration at:", prettierConfigPath); | ||
| } catch { | ||
| return exitWithError(`Failed to parse: ${prettierConfigPath}`); | ||
| } | ||
| const oxfmtrc = await createBlankOxfmtrcFile(cwd); | ||
| let hasSortPackageJsonPlugin = false; | ||
| for (const [key, value] of Object.entries(prettierConfig ?? {})) { | ||
| if (key === "plugins" && Array.isArray(value)) { | ||
| for (const plugin of value) if (plugin === "prettier-plugin-tailwindcss") migrateTailwindOptions(prettierConfig, oxfmtrc); | ||
| else if (plugin === "prettier-plugin-packagejson") hasSortPackageJsonPlugin = true; | ||
| else if (typeof plugin === "string") console.error(` - plugins: "${plugin}" is not supported, skipping...`); | ||
| else console.error(` - plugins: custom plugin module is not supported, skipping...`); | ||
| continue; | ||
| } | ||
| if (key === "endOfLine" && value === "auto") { | ||
| console.error(` - "endOfLine: auto" is not supported, skipping...`); | ||
| continue; | ||
| } | ||
| if (key === "experimentalTernaries" || key === "experimentalOperatorPosition") { | ||
| console.error(` - "${key}" is not supported in JS/TS files yet`); | ||
| continue; | ||
| } | ||
| if (key.startsWith("tailwind")) continue; | ||
| oxfmtrc[key] = value; | ||
| } | ||
| if (typeof oxfmtrc.printWidth !== "number") { | ||
| console.error(` - "printWidth" is not set in Prettier config, defaulting to 80 (Oxfmt default: 100)`); | ||
| oxfmtrc.printWidth = 80; | ||
| } | ||
| if (hasSortPackageJsonPlugin) { | ||
| oxfmtrc.sortPackageJson = {}; | ||
| console.error(` - Migrated "prettier-plugin-packagejson" to "sortPackageJson"`); | ||
| } else oxfmtrc.sortPackageJson = false; | ||
| if (oxfmtrc.embeddedLanguageFormatting !== "off") console.error(` - "embeddedLanguageFormatting" in JS/TS files is not fully supported yet`); | ||
| const ignores = await resolvePrettierIgnore(cwd); | ||
| if (ignores.length > 0) console.log("Migrated ignore patterns from `.prettierignore`"); | ||
| delete oxfmtrc.ignorePatterns; | ||
| oxfmtrc.ignorePatterns = ignores; | ||
| if ("overrides" in oxfmtrc) console.warn(` - "overrides" cannot be migrated automatically. See: https://github.com/oxc-project/oxc/issues/18215`); | ||
| const jsonStr = JSON.stringify(oxfmtrc, null, 2); | ||
| try { | ||
| await saveOxfmtrcFile(cwd, jsonStr); | ||
| console.log("Created `.oxfmtrc.json`."); | ||
| } catch { | ||
| return exitWithError("Failed to create `.oxfmtrc.json`."); | ||
| } | ||
| } | ||
| async function resolvePrettierIgnore(cwd) { | ||
| const ignores = []; | ||
| try { | ||
| const lines = (await readFile(join(cwd, ".prettierignore"), "utf8")).split("\n"); | ||
| for (let line of lines) { | ||
| line = line.trim(); | ||
| if (line === "" || line.startsWith("#")) continue; | ||
| ignores.push(line); | ||
| } | ||
| } catch {} | ||
| return ignores; | ||
| } | ||
| const TAILWIND_OPTION_MAPPING = { | ||
| config: "tailwindConfig", | ||
| stylesheet: "tailwindStylesheet", | ||
| functions: "tailwindFunctions", | ||
| attributes: "tailwindAttributes", | ||
| preserveWhitespace: "tailwindPreserveWhitespace", | ||
| preserveDuplicates: "tailwindPreserveDuplicates" | ||
| }; | ||
| /** | ||
| * Migrate prettier-plugin-tailwindcss options to Oxfmt's sortTailwindcss format. | ||
| * | ||
| * Prettier format: | ||
| * ```json | ||
| * { | ||
| * "plugins": ["prettier-plugin-tailwindcss"], | ||
| * "tailwindConfig": "./tailwind.config.js", | ||
| * "tailwindFunctions": ["clsx", "cn"] | ||
| * } | ||
| * ``` | ||
| * | ||
| * Oxfmt format: | ||
| * ```json | ||
| * { | ||
| * "sortTailwindcss": { | ||
| * "config": "./tailwind.config.js", | ||
| * "functions": ["clsx", "cn"] | ||
| * } | ||
| * } | ||
| * ``` | ||
| */ | ||
| function migrateTailwindOptions(prettierConfig, oxfmtrc) { | ||
| const tailwindOptions = {}; | ||
| for (const [oxfmtKey, prettierKey] of Object.entries(TAILWIND_OPTION_MAPPING)) { | ||
| const value = prettierConfig[prettierKey]; | ||
| if (value !== void 0) { | ||
| if ((prettierKey == "tailwindFunctions" || prettierKey == "tailwindAttributes") && Array.isArray(value)) { | ||
| for (const item of value) if (typeof item === "string" && item.startsWith("/") && item.endsWith("/")) { | ||
| console.warn(` - Do not support regex in "${prettierKey}" option yet, skipping: ${item}`); | ||
| continue; | ||
| } | ||
| } | ||
| tailwindOptions[oxfmtKey] = value; | ||
| } | ||
| } | ||
| oxfmtrc.sortTailwindcss = tailwindOptions; | ||
| console.log("Migrated prettier-plugin-tailwindcss options to sortTailwindcss"); | ||
| } | ||
| //#endregion | ||
| export { runMigratePrettier }; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| import { jsTextToDoc } from "./index.js"; | ||
| //#region src-js/libs/prettier-plugin-oxfmt/text-to-doc.ts | ||
| const textToDoc = async (embeddedSourceText, textToDocOptions) => { | ||
| const { parser, parentParser, filepath, _oxfmtPluginOptionsJson } = textToDocOptions; | ||
| const doc = await jsTextToDoc(parser === "typescript" || parser === "babel-ts" ? filepath?.endsWith(".tsx") ? "tsx" : "ts" : "jsx", embeddedSourceText, _oxfmtPluginOptionsJson, detectParentContext(parentParser, textToDocOptions)); | ||
| if (doc === null) throw new Error("`oxfmt::textToDoc()` failed. Use `OXC_LOG` env var to see Rust-side logs."); | ||
| return JSON.parse(doc); | ||
| }; | ||
| /** | ||
| * Detects Vue fragment mode from Prettier's internal flags. | ||
| * | ||
| * When Prettier formats Vue SFC templates, it calls textToDoc with special flags: | ||
| * - `__isVueForBindingLeft`: v-for left-hand side (e.g., `(item, index)` in `v-for="(item, index) in items"`) | ||
| * - `__isVueBindings`: v-slot bindings (e.g., `{ item }` in `#default="{ item }"`) | ||
| * - `__isEmbeddedTypescriptGenericParameters`: `<script generic="...">` type parameters | ||
| */ | ||
| function detectParentContext(parentParser, options) { | ||
| if (parentParser === "vue") { | ||
| if ("__isVueForBindingLeft" in options) return "vue-for-binding-left"; | ||
| if ("__isVueBindings" in options) return "vue-bindings"; | ||
| if ("__isEmbeddedTypescriptGenericParameters" in options) return "vue-script-generic"; | ||
| return "vue-script"; | ||
| } | ||
| if (parentParser === "svelte") return "svelte-script"; | ||
| return parentParser; | ||
| } | ||
| //#endregion | ||
| //#region src-js/libs/prettier-plugin-oxfmt/index.ts | ||
| /** | ||
| * Prettier plugin that uses `oxc_formatter` for (j|t)s-in-xxx part. | ||
| * | ||
| * When Prettier formats Vue/HTML (which can embed JS/TS code inside) files, | ||
| * it calls the `embed()` function for each block. | ||
| * | ||
| * By default, it uses the `babel` or `typescript` parser and `estree` printer. | ||
| * Therefore, by overriding these internally, we can use `oxc_formatter` instead. | ||
| * e.g. Now it's possible to apply our builtin sort-imports for JS/TS code inside Vue `<script>`. | ||
| */ | ||
| const options = { _oxfmtPluginOptionsJson: { | ||
| category: "JavaScript", | ||
| type: "string", | ||
| default: "{}", | ||
| description: "Bundled JSON string for oxfmt-plugin options" | ||
| } }; | ||
| const oxfmtParser = { | ||
| parse: textToDoc, | ||
| astFormat: "OXFMT", | ||
| locStart: () => -1, | ||
| locEnd: () => -1 | ||
| }; | ||
| const parsers = { | ||
| babel: oxfmtParser, | ||
| "babel-ts": oxfmtParser, | ||
| typescript: oxfmtParser | ||
| }; | ||
| const printers = { OXFMT: { print: ({ node }) => node } }; | ||
| //#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
| import { join } from "node:path"; | ||
| import { stat, writeFile } from "node:fs/promises"; | ||
| //#region src-js/cli/migration/shared.ts | ||
| async function hasOxfmtrcFile(cwd) { | ||
| return await isFile(join(cwd, ".oxfmtrc.json")) || await isFile(join(cwd, ".oxfmtrc.jsonc")); | ||
| } | ||
| const SCHEMA_RELATIVE_PATH = "./node_modules/oxfmt/configuration_schema.json"; | ||
| async function hasSchemaFile(cwd) { | ||
| return await isFile(join(cwd, "node_modules/oxfmt/configuration_schema.json")) ? SCHEMA_RELATIVE_PATH : null; | ||
| } | ||
| async function createBlankOxfmtrcFile(cwd) { | ||
| const config = { | ||
| $schema: await hasSchemaFile(cwd), | ||
| ignorePatterns: [] | ||
| }; | ||
| if (config.$schema === null) delete config.$schema; | ||
| return config; | ||
| } | ||
| async function saveOxfmtrcFile(cwd, jsonStr) { | ||
| await writeFile(join(cwd, ".oxfmtrc.json"), jsonStr + "\n", "utf8"); | ||
| } | ||
| function exitWithError(message) { | ||
| console.error(message); | ||
| process.exitCode = 1; | ||
| } | ||
| async function isFile(path) { | ||
| try { | ||
| return (await stat(path)).isFile(); | ||
| } catch { | ||
| return false; | ||
| } | ||
| } | ||
| //#endregion | ||
| export { saveOxfmtrcFile as i, exitWithError as n, hasOxfmtrcFile as r, createBlankOxfmtrcFile as t }; |
| import { a as resolveJsFrom, t as expiringMap } from "./resolve-pWjAK-4f-BnquIxPb.js"; | ||
| import { n as cacheForDirs, t as bigSign } from "./utils-D8dQkKEd-Dgy5UIHl.js"; | ||
| import { pathToFileURL } from "node:url"; | ||
| import * as path from "node:path"; | ||
| import { dirname, resolve } from "path"; | ||
| import { readdirSync, statSync } from "fs"; | ||
| //#region ../../node_modules/.pnpm/prettier-plugin-tailwindcss@0.0.0-insiders.3997fbd_prettier-plugin-svelte@3.5.1_prettie_57f1f908c644a91a29f5821c3681dd20/node_modules/prettier-plugin-tailwindcss/dist/sorter-BZkvDMjt.mjs | ||
| let seen = /* @__PURE__ */ new Set(); | ||
| function warn(key, arg, ...args) { | ||
| if (seen.has(key)) return; | ||
| seen.add(key); | ||
| console.warn(arg, ...args); | ||
| } | ||
| function error(key, arg, ...args) { | ||
| if (seen.has(key)) return; | ||
| seen.add(key); | ||
| console.error(arg, ...args); | ||
| } | ||
| function sync_default(start, callback) { | ||
| let dir = resolve(".", start); | ||
| let tmp; | ||
| if (!statSync(dir).isDirectory()) dir = dirname(dir); | ||
| while (true) { | ||
| tmp = callback(dir, readdirSync(dir)); | ||
| if (tmp) return resolve(dir, tmp); | ||
| dir = dirname(tmp = dir); | ||
| if (tmp === dir) break; | ||
| } | ||
| } | ||
| function sortClasses(classStr, { env, ignoreFirst = false, ignoreLast = false, removeDuplicates = true, collapseWhitespace = { | ||
| start: true, | ||
| end: true | ||
| } }) { | ||
| if (typeof classStr !== "string" || classStr === "") return classStr; | ||
| if (classStr.includes("{{")) return classStr; | ||
| if (env.options.tailwindPreserveWhitespace) collapseWhitespace = false; | ||
| if (env.options.tailwindPreserveDuplicates) removeDuplicates = false; | ||
| if (collapseWhitespace && /^[\t\r\f\n ]+$/.test(classStr)) return " "; | ||
| let result = ""; | ||
| let parts = classStr.split(/([\t\r\f\n ]+)/); | ||
| let classes = parts.filter((_, i) => i % 2 === 0); | ||
| let whitespace = parts.filter((_, i) => i % 2 !== 0); | ||
| if (classes[classes.length - 1] === "") classes.pop(); | ||
| if (collapseWhitespace) whitespace = whitespace.map(() => " "); | ||
| let prefix = ""; | ||
| if (ignoreFirst) prefix = `${classes.shift() ?? ""}${whitespace.shift() ?? ""}`; | ||
| let suffix = ""; | ||
| if (ignoreLast) suffix = `${whitespace.pop() ?? ""}${classes.pop() ?? ""}`; | ||
| let { classList, removedIndices } = sortClassList({ | ||
| classList: classes, | ||
| api: env.context, | ||
| removeDuplicates | ||
| }); | ||
| whitespace = whitespace.filter((_, index) => !removedIndices.has(index + 1)); | ||
| for (let i = 0; i < classList.length; i++) result += `${classList[i]}${whitespace[i] ?? ""}`; | ||
| if (collapseWhitespace) { | ||
| prefix = prefix.replace(/\s+$/g, " "); | ||
| suffix = suffix.replace(/^\s+/g, " "); | ||
| result = result.replace(/^\s+/, collapseWhitespace.start ? "" : " ").replace(/\s+$/, collapseWhitespace.end ? "" : " "); | ||
| } | ||
| return prefix + result + suffix; | ||
| } | ||
| function sortClassList({ classList, api, removeDuplicates }) { | ||
| let orderedClasses = api.getClassOrder(classList); | ||
| orderedClasses.sort(([nameA, a], [nameZ, z]) => { | ||
| if (nameA === "..." || nameA === "…") return 1; | ||
| if (nameZ === "..." || nameZ === "…") return -1; | ||
| if (a === z) return 0; | ||
| if (a === null) return -1; | ||
| if (z === null) return 1; | ||
| return bigSign(a - z); | ||
| }); | ||
| let removedIndices = /* @__PURE__ */ new Set(); | ||
| if (removeDuplicates) { | ||
| let seenClasses = /* @__PURE__ */ new Set(); | ||
| orderedClasses = orderedClasses.filter(([cls, order], index) => { | ||
| if (seenClasses.has(cls)) { | ||
| removedIndices.add(index); | ||
| return false; | ||
| } | ||
| if (order !== null) seenClasses.add(cls); | ||
| return true; | ||
| }); | ||
| } | ||
| return { | ||
| classList: orderedClasses.map(([className]) => className), | ||
| removedIndices | ||
| }; | ||
| } | ||
| function resolveIfRelative(base, filePath) { | ||
| if (!filePath) return null; | ||
| return path.isAbsolute(filePath) ? filePath : path.resolve(base, filePath); | ||
| } | ||
| let pathToApiMap = expiringMap(1e4); | ||
| async function getTailwindConfig(options) { | ||
| let base = options.base ?? process.cwd(); | ||
| let inputDir = options.filepath ? path.dirname(options.filepath) : base; | ||
| let configPath = resolveIfRelative(base, options.configPath); | ||
| let stylesheetPath = resolveIfRelative(base, options.stylesheetPath); | ||
| let [mod, pkgDir] = await resolveTailwindPath({ packageName: options.packageName }, inputDir); | ||
| let stylesheet = resolveStylesheet(stylesheetPath, base); | ||
| let jsConfig = resolveJsConfigPath(configPath); | ||
| if (!stylesheet && !(mod === null || mod === void 0 ? void 0 : mod.__unstable__loadDesignSystem)) jsConfig = jsConfig ?? findClosestJsConfig(inputDir); | ||
| if (jsConfig) { | ||
| if (!stylesheet) return pathToApiMap.remember(`${pkgDir}:${jsConfig}`, async () => { | ||
| const { loadV3 } = await import("./v3-D-mr2VVh-Bw8A9MXh.js"); | ||
| return loadV3(pkgDir, jsConfig); | ||
| }); | ||
| error("explicit-stylesheet-and-config-together", base, `You have specified a Tailwind CSS stylesheet and a Tailwind CSS config at the same time. Use stylesheetPath unless you are using v3. Preferring the stylesheet.`); | ||
| } | ||
| if (mod && !mod.__unstable__loadDesignSystem) { | ||
| if (!stylesheet) return pathToApiMap.remember(`${pkgDir}:${jsConfig}`, async () => { | ||
| const { loadV3 } = await import("./v3-D-mr2VVh-Bw8A9MXh.js"); | ||
| return loadV3(pkgDir, jsConfig); | ||
| }); | ||
| mod = null; | ||
| error("stylesheet-unsupported", base, "You have specified a Tailwind CSS stylesheet but your installed version of Tailwind CSS does not support this feature."); | ||
| } | ||
| if (mod && mod.__unstable__loadDesignSystem && pkgDir) stylesheet ?? (stylesheet = `${pkgDir}/theme.css`); | ||
| return pathToApiMap.remember(`${pkgDir}:${stylesheet}`, async () => { | ||
| const { loadV4 } = await import("./v4-C-HWEQJm-B81QD_Ac.js"); | ||
| return loadV4(mod, stylesheet); | ||
| }); | ||
| } | ||
| let resolvedModCache = expiringMap(1e4); | ||
| async function resolveTailwindPath(options, baseDir) { | ||
| let pkgName = options.packageName ?? "tailwindcss"; | ||
| let makeKey = (dir) => `${pkgName}:${dir}`; | ||
| let cached = resolvedModCache.get(makeKey(baseDir)); | ||
| if (cached !== void 0) return cached; | ||
| let resolve = async () => { | ||
| let pkgDir = null; | ||
| let mod = null; | ||
| try { | ||
| mod = await import(pathToFileURL(resolveJsFrom(baseDir, pkgName)).toString()); | ||
| let pkgFile = resolveJsFrom(baseDir, `${pkgName}/package.json`); | ||
| pkgDir = path.dirname(pkgFile); | ||
| } catch {} | ||
| return [mod, pkgDir]; | ||
| }; | ||
| let result = await resolve(); | ||
| let [, pkgDir] = result; | ||
| if (pkgDir) cacheForDirs(resolvedModCache, baseDir, result, pkgDir, makeKey); | ||
| else resolvedModCache.set(makeKey(baseDir), result); | ||
| return result; | ||
| } | ||
| function resolveJsConfigPath(configPath) { | ||
| if (!configPath) return null; | ||
| if (configPath.endsWith(".css")) return null; | ||
| return configPath; | ||
| } | ||
| let configPathCache = /* @__PURE__ */ new Map(); | ||
| function findClosestJsConfig(inputDir) { | ||
| let cached = configPathCache.get(inputDir); | ||
| if (cached !== void 0) return cached; | ||
| let configPath = null; | ||
| try { | ||
| configPath = sync_default(inputDir, (_, names) => { | ||
| if (names.includes("tailwind.config.js")) return "tailwind.config.js"; | ||
| if (names.includes("tailwind.config.cjs")) return "tailwind.config.cjs"; | ||
| if (names.includes("tailwind.config.mjs")) return "tailwind.config.mjs"; | ||
| if (names.includes("tailwind.config.ts")) return "tailwind.config.ts"; | ||
| }) ?? null; | ||
| } catch {} | ||
| if (configPath) cacheForDirs(configPathCache, inputDir, configPath, path.dirname(configPath)); | ||
| else configPathCache.set(inputDir, null); | ||
| return configPath; | ||
| } | ||
| function resolveStylesheet(stylesheetPath, base) { | ||
| if (!stylesheetPath) return null; | ||
| if (stylesheetPath.endsWith(".js") || stylesheetPath.endsWith(".mjs") || stylesheetPath.endsWith(".cjs") || stylesheetPath.endsWith(".ts") || stylesheetPath.endsWith(".mts") || stylesheetPath.endsWith(".cts")) error("stylesheet-is-js-file", base, "Your `stylesheetPath` option points to a JS/TS config file. You must point to your project's `.css` file for v4 projects."); | ||
| else if (stylesheetPath.endsWith(".sass") || stylesheetPath.endsWith(".scss") || stylesheetPath.endsWith(".less") || stylesheetPath.endsWith(".styl")) error("stylesheet-is-preprocessor-file", base, "Your `stylesheetPath` option points to a preprocessor file. This is unsupported and you may get unexpected results."); | ||
| else if (!stylesheetPath.endsWith(".css")) error("stylesheet-is-not-css-file", base, "Your `stylesheetPath` option does not point to a CSS file. This is unsupported and you may get unexpected results."); | ||
| return stylesheetPath; | ||
| } | ||
| async function createSorter(opts) { | ||
| let preserveDuplicates = opts.preserveDuplicates ?? false; | ||
| let preserveWhitespace = opts.preserveWhitespace ?? false; | ||
| let api = await getTailwindConfig({ | ||
| base: opts.base, | ||
| filepath: opts.filepath, | ||
| configPath: opts.configPath, | ||
| stylesheetPath: opts.stylesheetPath, | ||
| packageName: opts.packageName | ||
| }); | ||
| let env = { | ||
| context: api, | ||
| changes: [], | ||
| options: { | ||
| tailwindPreserveWhitespace: preserveWhitespace, | ||
| tailwindPreserveDuplicates: preserveDuplicates, | ||
| tailwindPackageName: opts.packageName | ||
| }, | ||
| matcher: void 0 | ||
| }; | ||
| return { | ||
| sortClassLists(classes) { | ||
| return classes.map((list) => { | ||
| return sortClassList({ | ||
| api, | ||
| classList: list, | ||
| removeDuplicates: !preserveDuplicates | ||
| }).classList; | ||
| }); | ||
| }, | ||
| sortClassAttributes(classes) { | ||
| return classes.map((list) => sortClasses(list, { env })); | ||
| } | ||
| }; | ||
| } | ||
| //#endregion | ||
| export { sortClasses as a, sortClassList as i, error as n, warn as o, getTailwindConfig as r, createSorter as t }; |
| import "./resolve-pWjAK-4f-BnquIxPb.js"; | ||
| import { r as getTailwindConfig, t as createSorter } from "./sorter-BZkvDMjt-y2u_e1ZW.js"; | ||
| export { createSorter, getTailwindConfig }; |
Sorry, the diff of this file is too big to display
| import * as path from "node:path"; | ||
| //#region ../../node_modules/.pnpm/prettier-plugin-tailwindcss@0.0.0-insiders.3997fbd_prettier-plugin-svelte@3.5.1_prettie_57f1f908c644a91a29f5821c3681dd20/node_modules/prettier-plugin-tailwindcss/dist/utils-D8dQkKEd.mjs | ||
| function isNodeLike(value) { | ||
| return typeof (value === null || value === void 0 ? void 0 : value.type) === "string"; | ||
| } | ||
| function visit(ast, callbackMap) { | ||
| function _visit(node, path, meta) { | ||
| if (typeof callbackMap === "function") { | ||
| if (callbackMap(node, path, meta) === false) return; | ||
| } else if (node.type in callbackMap) { | ||
| if (callbackMap[node.type](node, path, meta) === false) return; | ||
| } | ||
| const keys = Object.keys(node); | ||
| for (let i = 0; i < keys.length; i++) { | ||
| const child = node[keys[i]]; | ||
| if (Array.isArray(child)) { | ||
| for (let j = 0; j < child.length; j++) if (isNodeLike(child[j])) { | ||
| let newMeta = { ...meta }; | ||
| let newPath = [{ | ||
| node: child[j], | ||
| parent: node, | ||
| key: keys[i], | ||
| index: j, | ||
| meta: newMeta | ||
| }, ...path]; | ||
| _visit(child[j], newPath, newMeta); | ||
| } | ||
| } else if (isNodeLike(child)) { | ||
| let newMeta = { ...meta }; | ||
| _visit(child, [{ | ||
| node: child, | ||
| parent: node, | ||
| key: keys[i], | ||
| index: i, | ||
| meta: newMeta | ||
| }, ...path], newMeta); | ||
| } | ||
| } | ||
| } | ||
| let newMeta = {}; | ||
| _visit(ast, [{ | ||
| node: ast, | ||
| parent: null, | ||
| key: null, | ||
| index: null, | ||
| meta: newMeta | ||
| }], newMeta); | ||
| } | ||
| function spliceChangesIntoString(str, changes) { | ||
| if (!changes[0]) return str; | ||
| changes.sort((a, b) => { | ||
| return a.end - b.end || a.start - b.start; | ||
| }); | ||
| let result = ""; | ||
| let previous = changes[0]; | ||
| result += str.slice(0, previous.start); | ||
| result += previous.after; | ||
| for (let i = 1; i < changes.length; ++i) { | ||
| let change = changes[i]; | ||
| result += str.slice(previous.end, change.start); | ||
| result += change.after; | ||
| previous = change; | ||
| } | ||
| result += str.slice(previous.end); | ||
| return result; | ||
| } | ||
| function bigSign(bigIntValue) { | ||
| return Number(bigIntValue > 0n) - Number(bigIntValue < 0n); | ||
| } | ||
| function cacheForDirs(cache, inputDir, value, targetDir, makeKey = (dir) => dir) { | ||
| let dir = inputDir; | ||
| while (dir !== path.dirname(dir) && dir.length >= targetDir.length) { | ||
| const key = makeKey(dir); | ||
| if (cache.get(key) !== void 0) break; | ||
| cache.set(key, value); | ||
| if (dir === targetDir) break; | ||
| dir = path.dirname(dir); | ||
| } | ||
| } | ||
| //#endregion | ||
| export { visit as i, cacheForDirs as n, spliceChangesIntoString as r, bigSign as t }; |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 4 instances
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 4 instances
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
8482986
0.04%248493
0.03%39
-9.3%