oxfmt 0.51.0 → 0.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/{acorn-Cz3eAoi8.js → acorn-C-l7ouWN.js} +1 -1
  2. package/dist/{angular-BzDc3wVg.js → angular-4Mc0TmPv.js} +3 -5
  3. package/dist/{apis-H4bwlBNm.js → apis-Cc9jzUH4.js} +6 -6
  4. package/dist/{babel-Cs312VeV.js → babel-DjR61Wf3.js} +2 -3
  5. package/dist/{bindings-qpSSlUMn.js → bindings-BJw0GhQr.js} +26 -26
  6. package/dist/cli-worker.js +1 -1
  7. package/dist/cli.js +44 -25
  8. package/dist/{dist-DieWQ1D0.js → dist-CJyFMFm2.js} +70 -50
  9. package/dist/{estree-BL2Xy2uB.js → estree-DHQPBKqf.js} +1 -1
  10. package/dist/{flow-Bj4lBR-Y.js → flow-Cz3mJAtC.js} +1 -1
  11. package/dist/{glimmer-C2ccnwyy.js → glimmer-ubhL-0tG.js} +1 -1
  12. package/dist/{graphql-D73FSqwO.js → graphql-Cl0TIiHU.js} +1 -1
  13. package/dist/{html-ENhiK7MR.js → html-Cqnv8X__.js} +1 -1
  14. package/dist/index.js +2 -2
  15. package/dist/{init-BbKOMZ57.js → init-DGfXRYLw.js} +1 -1
  16. package/dist/{jiti-Bb1dT6Cw-BtDs_aWX.js → jiti-Bb1dT6Cw-B_5IaZk7.js} +2 -2
  17. package/dist/{markdown-CDTH7TpJ.js → markdown-Eujfu-fQ.js} +1 -1
  18. package/dist/{meriyah-C-N-xeFc.js → meriyah-DESRG6oe.js} +1 -1
  19. package/dist/{migrate-biome-BMqs7-eg.js → migrate-biome-P928W9-y.js} +1 -1
  20. package/dist/{migrate-prettier-CBzqnxHw.js → migrate-prettier-CotsZUFl.js} +2 -2
  21. package/dist/{plugin-DiRKvkOT.js → plugin-C4twtOn4.js} +433 -374
  22. package/dist/{postcss-CS83Slco.js → postcss-BFLfznNY.js} +1 -1
  23. package/dist/{prettier-D7Ly-aG0.js → prettier-Cy-lZk4k.js} +15 -15
  24. package/dist/{sorter-BZkvDMjt-r7M4pM9t.js → sorter-BZkvDMjt-C3eOnP5z.js} +7 -7
  25. package/dist/{sorter-D0Nd4qpi.js → sorter-CHFUGfz-.js} +1 -1
  26. package/dist/{typescript-DkgFgfZO.js → typescript-lqJOqGcK.js} +1 -1
  27. package/dist/{v3-D-mr2VVh-DBBWnwM8.js → v3-D-mr2VVh-BXhnMySQ.js} +3 -3
  28. package/dist/{v4-C-HWEQJm-OZwT-Lc8.js → v4-C-HWEQJm-CvgekpKf.js} +3 -3
  29. package/dist/{yaml-Ddi9JTUZ.js → yaml-D3PpfZBy.js} +1 -1
  30. package/package.json +25 -21
  31. /package/dist/{chunk-HkwdBwDg.js → chunk-CNf5ZN-e.js} +0 -0
  32. /package/dist/{prettier-plugin-oxfmt-Besh6ER1.js → prettier-plugin-oxfmt-Dj6FaAil.js} +0 -0
  33. /package/dist/{shared-BTEY2VsW.js → shared-BiMl-bLP.js} +0 -0
@@ -1,12 +1,12 @@
1
- import { o as __toESM } from "./chunk-HkwdBwDg.js";
2
- import { n as init_babel, parsers as ra, t as babel_exports } from "./babel-Cs312VeV.js";
3
- import index_exports, { t as init_prettier } from "./prettier-D7Ly-aG0.js";
4
- 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-r7M4pM9t.js";
5
- import { parsers as fn, t as init_angular } from "./angular-BzDc3wVg.js";
6
- import { n as postcss_exports, parsers as en, t as init_postcss } from "./postcss-CS83Slco.js";
1
+ import { o as __toESM } from "./chunk-CNf5ZN-e.js";
2
+ import { n as init_babel, parsers as ra, t as babel_exports } from "./babel-DjR61Wf3.js";
3
+ import index_exports, { t as init_prettier } from "./prettier-Cy-lZk4k.js";
4
+ 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-C3eOnP5z.js";
5
+ import { parsers as fn, t as init_angular } from "./angular-4Mc0TmPv.js";
6
+ import { n as postcss_exports, parsers as en, t as init_postcss } from "./postcss-BFLfznNY.js";
7
7
  import * as path from "node:path";
8
8
  import { isAbsolute } from "path";
9
- //#region ../../node_modules/.pnpm/prettier-plugin-tailwindcss@0.0.0-insiders.3997fbd_prettier-plugin-svelte@3.5.2_prettie_a08864e9b63fbbe60e61e20100abcb82/node_modules/prettier-plugin-tailwindcss/dist/index.mjs
9
+ //#region ../../node_modules/.pnpm/prettier-plugin-tailwindcss@0.0.0-insiders.2b6f3c2_prettier-plugin-svelte@4.0.1_prettie_b20d8b14d002a94b1de20f5a14f79b1e/node_modules/prettier-plugin-tailwindcss/dist/index.mjs
10
10
  init_angular();
11
11
  init_babel();
12
12
  init_postcss();
@@ -417,7 +417,6 @@ function transformAst({ ast, env, opts }) {
417
417
  function defineTransform(opts) {
418
418
  return opts;
419
419
  }
420
- const ESCAPE_SEQUENCE_PATTERN = /\\(['"\\nrtbfv0-7xuU])/g;
421
420
  function tryParseAngularAttribute(value, env) {
422
421
  try {
423
422
  return fn.__ng_directive.parse(value, env.options);
@@ -678,26 +677,29 @@ function sortStringLiteral(node, { env, removeDuplicates, collapseWhitespace = {
678
677
  start: true,
679
678
  end: true
680
679
  } }) {
681
- var _node$extra3, _node$extra4;
682
- let result = sortClasses(node.value, {
680
+ var _node$extra3;
681
+ let raw = ((_node$extra3 = node.extra) === null || _node$extra3 === void 0 ? void 0 : _node$extra3.raw) ?? node.raw;
682
+ let quote = raw[0];
683
+ let rawContent = raw.slice(1, -1);
684
+ let sortedRaw = sortClasses(rawContent, {
683
685
  env,
684
686
  removeDuplicates,
685
687
  collapseWhitespace
686
688
  });
687
- if (!(result !== node.value)) return false;
688
- node.value = result;
689
- let raw = ((_node$extra3 = node.extra) === null || _node$extra3 === void 0 ? void 0 : _node$extra3.raw) ?? node.raw;
690
- let quote = raw[0];
691
- let originalRawContent = raw.slice(1, -1);
692
- let originalValue = ((_node$extra4 = node.extra) === null || _node$extra4 === void 0 ? void 0 : _node$extra4.rawValue) ?? node.value;
693
- if (node.extra) {
694
- if (originalRawContent !== originalValue && originalValue.includes("\\")) result = result.replace(ESCAPE_SEQUENCE_PATTERN, "\\\\$1");
695
- node.extra = {
696
- ...node.extra,
697
- rawValue: result,
698
- raw: quote + result + quote
699
- };
700
- } else node.raw = quote + result + quote;
689
+ if (sortedRaw === rawContent) return false;
690
+ let sortedCooked = rawContent === node.value ? sortedRaw : sortClasses(node.value, {
691
+ env,
692
+ removeDuplicates,
693
+ collapseWhitespace
694
+ });
695
+ node.value = sortedCooked;
696
+ let newRaw = quote + sortedRaw + quote;
697
+ if (node.extra) node.extra = {
698
+ ...node.extra,
699
+ rawValue: sortedCooked,
700
+ raw: newRaw
701
+ };
702
+ else node.raw = newRaw;
701
703
  return true;
702
704
  }
703
705
  function isStringLiteral(node) {
@@ -979,25 +981,26 @@ function transformSvelte(ast, env) {
979
981
  let { matcher, changes } = env;
980
982
  for (let attr of ast.attributes ?? []) {
981
983
  if (!matcher.hasStaticAttr(attr.name) || attr.type !== "Attribute") continue;
982
- for (let i = 0; i < attr.value.length; i++) {
983
- let value = attr.value[i];
984
+ let values = getSvelteAttributeValues(attr);
985
+ for (let i = 0; i < values.length; i++) {
986
+ let value = values[i];
984
987
  if (value.type === "Text") {
985
988
  let same = value.raw === value.data;
986
989
  value.raw = sortClasses(value.raw, {
987
990
  env,
988
991
  ignoreFirst: i > 0 && !/^\s/.test(value.raw),
989
- ignoreLast: i < attr.value.length - 1 && !/\s$/.test(value.raw),
992
+ ignoreLast: i < values.length - 1 && !/\s$/.test(value.raw),
990
993
  removeDuplicates: true,
991
994
  collapseWhitespace: false
992
995
  });
993
996
  value.data = same ? value.raw : sortClasses(value.data, {
994
997
  env,
995
998
  ignoreFirst: i > 0 && !/^\s/.test(value.data),
996
- ignoreLast: i < attr.value.length - 1 && !/\s$/.test(value.data),
999
+ ignoreLast: i < values.length - 1 && !/\s$/.test(value.data),
997
1000
  removeDuplicates: true,
998
1001
  collapseWhitespace: false
999
1002
  });
1000
- } else if (value.type === "MustacheTag") visit(value.expression, {
1003
+ } else if (value.type === "MustacheTag" || value.type === "ExpressionTag") visit(value.expression, {
1001
1004
  Literal(node) {
1002
1005
  if (isStringLiteral(node)) {
1003
1006
  let before = node.raw;
@@ -1029,27 +1032,44 @@ function transformSvelte(ast, env) {
1029
1032
  });
1030
1033
  }
1031
1034
  }
1032
- for (let child of ast.children ?? []) transformSvelte(child, env);
1033
- if (ast.type === "IfBlock") {
1034
- var _ast$else;
1035
- for (let child of ((_ast$else = ast.else) === null || _ast$else === void 0 ? void 0 : _ast$else.children) ?? []) transformSvelte(child, env);
1036
- }
1037
- if (ast.type === "AwaitBlock") {
1038
- let nodes = [
1039
- ast.pending,
1040
- ast.then,
1041
- ast.catch
1042
- ];
1043
- for (let child of nodes) transformSvelte(child, env);
1044
- }
1045
- if (ast.html) transformSvelte(ast.html, env);
1035
+ for (let child of getSvelteChildNodes(ast)) transformSvelte(child, env);
1036
+ }
1037
+ function getSvelteAttributeValues(attr) {
1038
+ if (Array.isArray(attr.value)) return attr.value;
1039
+ if (attr.value && typeof attr.value === "object") return [attr.value];
1040
+ return [];
1041
+ }
1042
+ function getSvelteChildNodes(node) {
1043
+ let children = [];
1044
+ for (let key of [
1045
+ "children",
1046
+ "nodes",
1047
+ "fragment",
1048
+ "html",
1049
+ "else",
1050
+ "consequent",
1051
+ "alternate",
1052
+ "body",
1053
+ "fallback",
1054
+ "pending",
1055
+ "then",
1056
+ "catch"
1057
+ ]) children.push(...getSvelteNodes(node[key]));
1058
+ return children;
1059
+ }
1060
+ function getSvelteNodes(value) {
1061
+ if (Array.isArray(value)) return value.filter((node) => node === null || node === void 0 ? void 0 : node.type);
1062
+ if (Array.isArray(value === null || value === void 0 ? void 0 : value.nodes)) return value.nodes;
1063
+ if (Array.isArray(value === null || value === void 0 ? void 0 : value.children)) return value.children;
1064
+ if (value === null || value === void 0 ? void 0 : value.type) return [value];
1065
+ return [];
1046
1066
  }
1047
1067
  const { parsers, printers } = createPlugin([
1048
1068
  defineTransform({
1049
1069
  staticAttrs: ["class"],
1050
1070
  load: [{
1051
1071
  name: "prettier/plugins/html",
1052
- importer: () => import("./html-ENhiK7MR.js")
1072
+ importer: () => import("./html-Cqnv8X__.js")
1053
1073
  }],
1054
1074
  compatible: ["prettier-plugin-organize-attributes"],
1055
1075
  parsers: {
@@ -1064,7 +1084,7 @@ const { parsers, printers } = createPlugin([
1064
1084
  staticAttrs: ["class"],
1065
1085
  load: [{
1066
1086
  name: "prettier/plugins/glimmer",
1067
- importer: () => import("./glimmer-C2ccnwyy.js")
1087
+ importer: () => import("./glimmer-ubhL-0tG.js")
1068
1088
  }],
1069
1089
  parsers: { glimmer: {} },
1070
1090
  transform: transformGlimmer
@@ -1096,19 +1116,19 @@ const { parsers, printers } = createPlugin([
1096
1116
  __js_expression: { load: [babel_exports] },
1097
1117
  typescript: { load: [{
1098
1118
  name: "prettier/plugins/typescript",
1099
- importer: () => import("./typescript-DkgFgfZO.js")
1119
+ importer: () => import("./typescript-lqJOqGcK.js")
1100
1120
  }] },
1101
1121
  meriyah: { load: [{
1102
1122
  name: "prettier/plugins/meriyah",
1103
- importer: () => import("./meriyah-C-N-xeFc.js")
1123
+ importer: () => import("./meriyah-DESRG6oe.js")
1104
1124
  }] },
1105
1125
  acorn: { load: [{
1106
1126
  name: "prettier/plugins/acorn",
1107
- importer: () => import("./acorn-Cz3eAoi8.js")
1127
+ importer: () => import("./acorn-C-l7ouWN.js")
1108
1128
  }] },
1109
1129
  flow: { load: [{
1110
1130
  name: "prettier/plugins/flow",
1111
- importer: () => import("./flow-Bj4lBR-Y.js")
1131
+ importer: () => import("./flow-Cz3mJAtC.js")
1112
1132
  }] },
1113
1133
  oxc: { load: [{
1114
1134
  name: "@prettier/plugin-oxc",
@@ -1139,7 +1159,7 @@ const { parsers, printers } = createPlugin([
1139
1159
  staticAttrs: ["class"],
1140
1160
  load: [{
1141
1161
  name: "prettier-plugin-svelte",
1142
- importer: () => import("./plugin-DiRKvkOT.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1))
1162
+ importer: () => import("./plugin-C4twtOn4.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1))
1143
1163
  }],
1144
1164
  parsers: { svelte: {} },
1145
1165
  printers: { "svelte-ast": {} },
@@ -1,4 +1,4 @@
1
- import { n as __esmMin } from "./chunk-HkwdBwDg.js";
1
+ import { n as __esmMin } from "./chunk-CNf5ZN-e.js";
2
2
  //#region ../../node_modules/.pnpm/prettier@3.8.3/node_modules/prettier/plugins/estree.mjs
3
3
  function ka(e) {
4
4
  return this[e < 0 ? this.length + e : e];
@@ -1,4 +1,4 @@
1
- import { n as __esmMin } from "./chunk-HkwdBwDg.js";
1
+ import { n as __esmMin } from "./chunk-CNf5ZN-e.js";
2
2
  //#region ../../node_modules/.pnpm/prettier@3.8.3/node_modules/prettier/plugins/flow.mjs
3
3
  function iI0(a0, ox) {
4
4
  let Yx = /* @__PURE__ */ new SyntaxError(a0 + " (" + ox.loc.start.line + ":" + ox.loc.start.column + ")");
@@ -1,4 +1,4 @@
1
- import { n as __esmMin } from "./chunk-HkwdBwDg.js";
1
+ import { n as __esmMin } from "./chunk-CNf5ZN-e.js";
2
2
  //#region ../../node_modules/.pnpm/prettier@3.8.3/node_modules/prettier/plugins/glimmer.mjs
3
3
  function Yn(e) {
4
4
  return this[e < 0 ? this.length + e : e];
@@ -1,4 +1,4 @@
1
- import { n as __esmMin } from "./chunk-HkwdBwDg.js";
1
+ import { n as __esmMin } from "./chunk-CNf5ZN-e.js";
2
2
  //#region ../../node_modules/.pnpm/prettier@3.8.3/node_modules/prettier/plugins/graphql.mjs
3
3
  function x(e) {
4
4
  return S(e), {
@@ -1,4 +1,4 @@
1
- import { n as __esmMin } from "./chunk-HkwdBwDg.js";
1
+ import { n as __esmMin } from "./chunk-CNf5ZN-e.js";
2
2
  //#region ../../node_modules/.pnpm/prettier@3.8.3/node_modules/prettier/plugins/html.mjs
3
3
  function ns(e) {
4
4
  return this[e < 0 ? this.length + e : e];
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { n as jsTextToDoc$1, t as format$1 } from "./bindings-qpSSlUMn.js";
2
- import { i as sortTailwindClasses, n as formatEmbeddedDoc, r as formatFile, t as formatEmbeddedCode } from "./apis-H4bwlBNm.js";
1
+ import { n as jsTextToDoc$1, t as format$1 } from "./bindings-BJw0GhQr.js";
2
+ import { i as sortTailwindClasses, n as formatEmbeddedDoc, r as formatFile, t as formatEmbeddedCode } from "./apis-Cc9jzUH4.js";
3
3
  //#region src-js/index.ts
4
4
  /**
5
5
  * Define an oxfmt configuration with type inference.
@@ -1,4 +1,4 @@
1
- import { i as saveOxfmtrcFile, n as exitWithError, r as hasOxfmtrcFile, t as createBlankOxfmtrcFile } from "./shared-BTEY2VsW.js";
1
+ import { i as saveOxfmtrcFile, n as exitWithError, r as hasOxfmtrcFile, t as createBlankOxfmtrcFile } from "./shared-BiMl-bLP.js";
2
2
  //#region src-js/cli/migration/init.ts
3
3
  /**
4
4
  * Run the `--init` command to scaffold a default `.oxfmtrc.json` file.
@@ -1,6 +1,6 @@
1
- import { b as __toESM, g as __commonJSMin, y as __require } from "./sorter-BZkvDMjt-r7M4pM9t.js";
1
+ import { b as __toESM, g as __commonJSMin, y as __require } from "./sorter-BZkvDMjt-C3eOnP5z.js";
2
2
  import { createRequire } from "node:module";
3
- //#region ../../node_modules/.pnpm/prettier-plugin-tailwindcss@0.0.0-insiders.3997fbd_prettier-plugin-svelte@3.5.2_prettie_a08864e9b63fbbe60e61e20100abcb82/node_modules/prettier-plugin-tailwindcss/dist/jiti-Bb1dT6Cw.mjs
3
+ //#region ../../node_modules/.pnpm/prettier-plugin-tailwindcss@0.0.0-insiders.2b6f3c2_prettier-plugin-svelte@4.0.1_prettie_b20d8b14d002a94b1de20f5a14f79b1e/node_modules/prettier-plugin-tailwindcss/dist/jiti-Bb1dT6Cw.mjs
4
4
  var require_jiti = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5
5
  (() => {
6
6
  var e = { "./node_modules/.pnpm/mlly@1.8.0/node_modules/mlly/dist lazy recursive": function(e) {
@@ -1,4 +1,4 @@
1
- import { n as __esmMin } from "./chunk-HkwdBwDg.js";
1
+ import { n as __esmMin } from "./chunk-CNf5ZN-e.js";
2
2
  //#region ../../node_modules/.pnpm/prettier@3.8.3/node_modules/prettier/plugins/markdown.mjs
3
3
  function yl(e) {
4
4
  return this[e < 0 ? this.length + e : e];
@@ -1,4 +1,4 @@
1
- import { n as __esmMin } from "./chunk-HkwdBwDg.js";
1
+ import { n as __esmMin } from "./chunk-CNf5ZN-e.js";
2
2
  //#region ../../node_modules/.pnpm/prettier@3.8.3/node_modules/prettier/plugins/meriyah.mjs
3
3
  function Se(e) {
4
4
  return e <= 127 ? _2[e] > 0 : Ct(e);
@@ -1,4 +1,4 @@
1
- import { i as saveOxfmtrcFile, n as exitWithError, r as hasOxfmtrcFile, t as createBlankOxfmtrcFile } from "./shared-BTEY2VsW.js";
1
+ import { i as saveOxfmtrcFile, n as exitWithError, r as hasOxfmtrcFile, t as createBlankOxfmtrcFile } from "./shared-BiMl-bLP.js";
2
2
  import { join } from "node:path";
3
3
  import { readFile } from "node:fs/promises";
4
4
  //#region src-js/cli/migration/migrate-biome.ts
@@ -1,4 +1,4 @@
1
- import { i as saveOxfmtrcFile, n as exitWithError, r as hasOxfmtrcFile, t as createBlankOxfmtrcFile } from "./shared-BTEY2VsW.js";
1
+ import { i as saveOxfmtrcFile, n as exitWithError, r as hasOxfmtrcFile, t as createBlankOxfmtrcFile } from "./shared-BiMl-bLP.js";
2
2
  import { join } from "node:path";
3
3
  import { readFile } from "node:fs/promises";
4
4
  //#region src-js/cli/migration/migrate-prettier.ts
@@ -9,7 +9,7 @@ import { readFile } from "node:fs/promises";
9
9
  async function runMigratePrettier() {
10
10
  const cwd = process.cwd();
11
11
  if (await hasOxfmtrcFile(cwd)) return exitWithError("Oxfmt configuration file already exists.");
12
- const { resolveConfigFile, resolveConfig } = await import("./prettier-D7Ly-aG0.js");
12
+ const { resolveConfigFile, resolveConfig } = await import("./prettier-Cy-lZk4k.js");
13
13
  const prettierConfigPath = await resolveConfigFile(join(cwd, "dummy.js"));
14
14
  if (!prettierConfigPath) {
15
15
  console.log("No Prettier configuration file found.");