oxfmt 0.35.0 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/{angular-DdA9f8ZK.js → angular-BYaMjeNY.js} +1 -1
- package/dist/{apis-KSwODFyo.js → apis-C04w0rkO.js} +42 -13
- package/dist/babel-CsJ8KocL.js +3 -0
- package/dist/{bindings-Bg9JnrLc.js → bindings-BY08Skk2.js} +26 -26
- package/dist/cli-worker.d.ts +31 -11
- package/dist/cli-worker.js +2 -2
- package/dist/cli.js +17 -11
- package/dist/{dist-DQgkZSFc.js → dist-BIcAktiQ.js} +6 -6
- package/dist/index.d.ts +1 -7
- package/dist/index.js +13 -7
- package/dist/{jiti-Bb1dT6Cw-CP1_dUF7.js → jiti-Bb1dT6Cw-D7Kk0pkW.js} +1 -1
- package/dist/{migrate-prettier-CMmmGHbr.js → migrate-prettier-BrvLf3WK.js} +1 -1
- package/dist/{postcss-D79LfgjO.js → postcss-o-3qwTQO.js} +1 -1
- package/dist/{prettier-DIVejRqd.js → prettier-CK6Vmyxp.js} +7 -7
- package/dist/prettier-plugin-oxfmt-DQXypUIM.js +62 -0
- package/dist/{resolve-pWjAK-4f-YzJRPmwZ.js → resolve-pWjAK-4f-DMrPXOR5.js} +1 -1
- package/dist/{sorter-BZkvDMjt-CiG199np.js → sorter-BZkvDMjt-CZzzihz1.js} +6 -6
- package/dist/sorter-DmFkUshw.js +5 -0
- package/dist/{v3-D-mr2VVh-DAVD4LOh.js → v3-D-mr2VVh-Bj3_v5Qp.js} +3 -3
- package/dist/{v4-C-HWEQJm-DOWhMvfI.js → v4-C-HWEQJm-D29N-mp3.js} +3 -3
- package/package.json +21 -20
- package/dist/babel-CmMxKXKi.js +0 -3
- package/dist/prettier-plugin-oxfmt-B4H9aKXO.js +0 -47
- package/dist/sorter-CjGwXe5x.js +0 -5
- /package/dist/{chunk-DSjvVL_1-K7gBHu1i.js → chunk-DSjvVL_1-B9nK_dIv.js} +0 -0
- /package/dist/{utils-D8dQkKEd-bSmL59ud.js → utils-D8dQkKEd-w107AldM.js} +0 -0
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
[ci-badge]: https://github.com/oxc-project/oxc/actions/workflows/ci.yml/badge.svg?event=push&branch=main
|
|
31
31
|
[ci-url]: https://github.com/oxc-project/oxc/actions/workflows/ci.yml?query=event%3Apush+branch%3Amain
|
|
32
32
|
[npm-badge]: https://img.shields.io/npm/v/oxfmt/latest?color=brightgreen
|
|
33
|
-
[npm-url]: https://
|
|
33
|
+
[npm-url]: https://npmx.dev/package/oxfmt/v/latest
|
|
34
34
|
[code-size-badge]: https://img.shields.io/github/languages/code-size/oxc-project/oxc
|
|
35
35
|
[code-size-url]: https://github.com/oxc-project/oxc
|
|
36
36
|
[code-coverage-badge]: https://codecov.io/github/oxc-project/oxc/branch/main/graph/badge.svg
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
[sponsors-badge]: https://img.shields.io/github/sponsors/Boshen
|
|
39
39
|
[sponsors-url]: https://github.com/sponsors/Boshen
|
|
40
40
|
[playground-badge]: https://img.shields.io/badge/Playground-blue?color=9BE4E0
|
|
41
|
-
[playground-url]: https://
|
|
41
|
+
[playground-url]: https://playground.oxc.rs/
|
|
42
42
|
|
|
43
43
|
</div>
|
|
44
44
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-DpReBE2K.js";
|
|
2
|
-
import { i as sn, r as Ei } from "./dist-
|
|
2
|
+
import { i as sn, r as Ei } from "./dist-BIcAktiQ.js";
|
|
3
3
|
|
|
4
4
|
//#region ../../node_modules/.pnpm/prettier@3.8.1/node_modules/prettier/plugins/postcss.mjs
|
|
5
5
|
var postcss_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
let prettierCache;
|
|
3
3
|
async function loadPrettier() {
|
|
4
4
|
if (prettierCache) return prettierCache;
|
|
5
|
-
prettierCache = await import("./prettier-
|
|
5
|
+
prettierCache = await import("./prettier-CK6Vmyxp.js").then((n) => n.n);
|
|
6
6
|
return prettierCache;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
@@ -17,11 +17,23 @@ async function resolvePlugins() {
|
|
|
17
17
|
return [];
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* Format
|
|
20
|
+
* Format non-js file
|
|
21
|
+
*
|
|
22
|
+
* @returns Formatted code
|
|
23
|
+
*/
|
|
24
|
+
async function formatFile({ code, options }) {
|
|
25
|
+
const prettier = await loadPrettier();
|
|
26
|
+
await setupTailwindPlugin(options);
|
|
27
|
+
await setupOxfmtPlugin(options);
|
|
28
|
+
return prettier.format(code, options);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Format xxx-in-js code snippets into formatted string.
|
|
32
|
+
*
|
|
33
|
+
* This will be gradually replaced by `formatEmbeddedDoc` which returns `Doc`.
|
|
34
|
+
* For now, html|css|md-in-js are using this.
|
|
21
35
|
*
|
|
22
36
|
* @returns Formatted code snippet
|
|
23
|
-
* TODO: In the future, this should return `Doc` instead of string,
|
|
24
|
-
* otherwise, we cannot calculate `printWidth` correctly.
|
|
25
37
|
*/
|
|
26
38
|
async function formatEmbeddedCode({ code, options }) {
|
|
27
39
|
const prettier = await loadPrettier();
|
|
@@ -29,20 +41,37 @@ async function formatEmbeddedCode({ code, options }) {
|
|
|
29
41
|
return prettier.format(code, options);
|
|
30
42
|
}
|
|
31
43
|
/**
|
|
32
|
-
* Format
|
|
44
|
+
* Format xxx-in-js code snippets into Prettier `Doc` JSON strings.
|
|
33
45
|
*
|
|
34
|
-
*
|
|
46
|
+
* This makes `oxc_formatter` correctly handle `printWidth` even for embedded code.
|
|
47
|
+
* - For gql-in-js, `texts` contains multiple parts split by `${}` in a template literal
|
|
48
|
+
* - For others, `texts` always contains a single string with `${}` parts replaced by placeholders
|
|
49
|
+
* However, this function does not need to be aware of that,
|
|
50
|
+
* as it simply formats each text part independently and returns an array of formatted parts.
|
|
51
|
+
*
|
|
52
|
+
* @returns Doc JSON strings (one per input text)
|
|
35
53
|
*/
|
|
36
|
-
async function
|
|
54
|
+
async function formatEmbeddedDoc({ texts, options }) {
|
|
37
55
|
const prettier = await loadPrettier();
|
|
38
56
|
await setupTailwindPlugin(options);
|
|
39
|
-
|
|
40
|
-
|
|
57
|
+
return Promise.all(texts.map(async (text) => {
|
|
58
|
+
const doc = await prettier.__debug.printToDoc(text, options);
|
|
59
|
+
const symbolToNumber = /* @__PURE__ */ new Map();
|
|
60
|
+
let nextId = 1;
|
|
61
|
+
return JSON.stringify(doc, (_key, value) => {
|
|
62
|
+
if (typeof value === "symbol") {
|
|
63
|
+
if (!symbolToNumber.has(value)) symbolToNumber.set(value, nextId++);
|
|
64
|
+
return symbolToNumber.get(value);
|
|
65
|
+
}
|
|
66
|
+
if (value === -Infinity) return "__NEGATIVE_INFINITY__";
|
|
67
|
+
return value;
|
|
68
|
+
});
|
|
69
|
+
}));
|
|
41
70
|
}
|
|
42
71
|
let tailwindPluginCache;
|
|
43
72
|
async function loadTailwindPlugin() {
|
|
44
73
|
if (tailwindPluginCache) return tailwindPluginCache;
|
|
45
|
-
tailwindPluginCache = await import("./dist-
|
|
74
|
+
tailwindPluginCache = await import("./dist-BIcAktiQ.js");
|
|
46
75
|
return tailwindPluginCache;
|
|
47
76
|
}
|
|
48
77
|
/**
|
|
@@ -63,7 +92,7 @@ async function setupTailwindPlugin(options) {
|
|
|
63
92
|
* @returns Array of sorted class strings (same order/length as input)
|
|
64
93
|
*/
|
|
65
94
|
async function sortTailwindClasses({ classes, options }) {
|
|
66
|
-
const { createSorter } = await import("./sorter-
|
|
95
|
+
const { createSorter } = await import("./sorter-DmFkUshw.js");
|
|
67
96
|
return (await createSorter({
|
|
68
97
|
filepath: options.filepath,
|
|
69
98
|
stylesheetPath: options.tailwindStylesheet,
|
|
@@ -75,7 +104,7 @@ async function sortTailwindClasses({ classes, options }) {
|
|
|
75
104
|
let oxfmtPluginCache;
|
|
76
105
|
async function loadOxfmtPlugin() {
|
|
77
106
|
if (oxfmtPluginCache) return oxfmtPluginCache;
|
|
78
|
-
oxfmtPluginCache = await import("./prettier-plugin-oxfmt-
|
|
107
|
+
oxfmtPluginCache = await import("./prettier-plugin-oxfmt-DQXypUIM.js");
|
|
79
108
|
return oxfmtPluginCache;
|
|
80
109
|
}
|
|
81
110
|
/**
|
|
@@ -90,4 +119,4 @@ async function setupOxfmtPlugin(options) {
|
|
|
90
119
|
}
|
|
91
120
|
|
|
92
121
|
//#endregion
|
|
93
|
-
export { sortTailwindClasses as i,
|
|
122
|
+
export { sortTailwindClasses as a, resolvePlugins as i, formatEmbeddedDoc as n, formatFile as r, formatEmbeddedCode as t };
|
|
@@ -58,7 +58,7 @@ function requireNative() {
|
|
|
58
58
|
try {
|
|
59
59
|
const binding = require("@oxfmt/binding-android-arm64");
|
|
60
60
|
const bindingPackageVersion = require("@oxfmt/binding-android-arm64/package.json").version;
|
|
61
|
-
if (bindingPackageVersion !== "0.
|
|
61
|
+
if (bindingPackageVersion !== "0.36.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.36.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
62
62
|
return binding;
|
|
63
63
|
} catch (e) {
|
|
64
64
|
loadErrors.push(e);
|
|
@@ -72,7 +72,7 @@ function requireNative() {
|
|
|
72
72
|
try {
|
|
73
73
|
const binding = require("@oxfmt/binding-android-arm-eabi");
|
|
74
74
|
const bindingPackageVersion = require("@oxfmt/binding-android-arm-eabi/package.json").version;
|
|
75
|
-
if (bindingPackageVersion !== "0.
|
|
75
|
+
if (bindingPackageVersion !== "0.36.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.36.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
76
76
|
return binding;
|
|
77
77
|
} catch (e) {
|
|
78
78
|
loadErrors.push(e);
|
|
@@ -87,7 +87,7 @@ function requireNative() {
|
|
|
87
87
|
try {
|
|
88
88
|
const binding = require("@oxfmt/binding-win32-x64-gnu");
|
|
89
89
|
const bindingPackageVersion = require("@oxfmt/binding-win32-x64-gnu/package.json").version;
|
|
90
|
-
if (bindingPackageVersion !== "0.
|
|
90
|
+
if (bindingPackageVersion !== "0.36.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.36.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
91
91
|
return binding;
|
|
92
92
|
} catch (e) {
|
|
93
93
|
loadErrors.push(e);
|
|
@@ -101,7 +101,7 @@ function requireNative() {
|
|
|
101
101
|
try {
|
|
102
102
|
const binding = require("@oxfmt/binding-win32-x64-msvc");
|
|
103
103
|
const bindingPackageVersion = require("@oxfmt/binding-win32-x64-msvc/package.json").version;
|
|
104
|
-
if (bindingPackageVersion !== "0.
|
|
104
|
+
if (bindingPackageVersion !== "0.36.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.36.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
105
105
|
return binding;
|
|
106
106
|
} catch (e) {
|
|
107
107
|
loadErrors.push(e);
|
|
@@ -116,7 +116,7 @@ function requireNative() {
|
|
|
116
116
|
try {
|
|
117
117
|
const binding = require("@oxfmt/binding-win32-ia32-msvc");
|
|
118
118
|
const bindingPackageVersion = require("@oxfmt/binding-win32-ia32-msvc/package.json").version;
|
|
119
|
-
if (bindingPackageVersion !== "0.
|
|
119
|
+
if (bindingPackageVersion !== "0.36.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.36.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
120
120
|
return binding;
|
|
121
121
|
} catch (e) {
|
|
122
122
|
loadErrors.push(e);
|
|
@@ -130,7 +130,7 @@ function requireNative() {
|
|
|
130
130
|
try {
|
|
131
131
|
const binding = require("@oxfmt/binding-win32-arm64-msvc");
|
|
132
132
|
const bindingPackageVersion = require("@oxfmt/binding-win32-arm64-msvc/package.json").version;
|
|
133
|
-
if (bindingPackageVersion !== "0.
|
|
133
|
+
if (bindingPackageVersion !== "0.36.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.36.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
134
134
|
return binding;
|
|
135
135
|
} catch (e) {
|
|
136
136
|
loadErrors.push(e);
|
|
@@ -145,7 +145,7 @@ function requireNative() {
|
|
|
145
145
|
try {
|
|
146
146
|
const binding = require("@oxfmt/binding-darwin-universal");
|
|
147
147
|
const bindingPackageVersion = require("@oxfmt/binding-darwin-universal/package.json").version;
|
|
148
|
-
if (bindingPackageVersion !== "0.
|
|
148
|
+
if (bindingPackageVersion !== "0.36.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.36.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
149
149
|
return binding;
|
|
150
150
|
} catch (e) {
|
|
151
151
|
loadErrors.push(e);
|
|
@@ -159,7 +159,7 @@ function requireNative() {
|
|
|
159
159
|
try {
|
|
160
160
|
const binding = require("@oxfmt/binding-darwin-x64");
|
|
161
161
|
const bindingPackageVersion = require("@oxfmt/binding-darwin-x64/package.json").version;
|
|
162
|
-
if (bindingPackageVersion !== "0.
|
|
162
|
+
if (bindingPackageVersion !== "0.36.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.36.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
163
163
|
return binding;
|
|
164
164
|
} catch (e) {
|
|
165
165
|
loadErrors.push(e);
|
|
@@ -173,7 +173,7 @@ function requireNative() {
|
|
|
173
173
|
try {
|
|
174
174
|
const binding = require("@oxfmt/binding-darwin-arm64");
|
|
175
175
|
const bindingPackageVersion = require("@oxfmt/binding-darwin-arm64/package.json").version;
|
|
176
|
-
if (bindingPackageVersion !== "0.
|
|
176
|
+
if (bindingPackageVersion !== "0.36.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.36.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
177
177
|
return binding;
|
|
178
178
|
} catch (e) {
|
|
179
179
|
loadErrors.push(e);
|
|
@@ -188,7 +188,7 @@ function requireNative() {
|
|
|
188
188
|
try {
|
|
189
189
|
const binding = require("@oxfmt/binding-freebsd-x64");
|
|
190
190
|
const bindingPackageVersion = require("@oxfmt/binding-freebsd-x64/package.json").version;
|
|
191
|
-
if (bindingPackageVersion !== "0.
|
|
191
|
+
if (bindingPackageVersion !== "0.36.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.36.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
192
192
|
return binding;
|
|
193
193
|
} catch (e) {
|
|
194
194
|
loadErrors.push(e);
|
|
@@ -202,7 +202,7 @@ function requireNative() {
|
|
|
202
202
|
try {
|
|
203
203
|
const binding = require("@oxfmt/binding-freebsd-arm64");
|
|
204
204
|
const bindingPackageVersion = require("@oxfmt/binding-freebsd-arm64/package.json").version;
|
|
205
|
-
if (bindingPackageVersion !== "0.
|
|
205
|
+
if (bindingPackageVersion !== "0.36.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.36.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
206
206
|
return binding;
|
|
207
207
|
} catch (e) {
|
|
208
208
|
loadErrors.push(e);
|
|
@@ -217,7 +217,7 @@ function requireNative() {
|
|
|
217
217
|
try {
|
|
218
218
|
const binding = require("@oxfmt/binding-linux-x64-musl");
|
|
219
219
|
const bindingPackageVersion = require("@oxfmt/binding-linux-x64-musl/package.json").version;
|
|
220
|
-
if (bindingPackageVersion !== "0.
|
|
220
|
+
if (bindingPackageVersion !== "0.36.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.36.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
221
221
|
return binding;
|
|
222
222
|
} catch (e) {
|
|
223
223
|
loadErrors.push(e);
|
|
@@ -231,7 +231,7 @@ function requireNative() {
|
|
|
231
231
|
try {
|
|
232
232
|
const binding = require("@oxfmt/binding-linux-x64-gnu");
|
|
233
233
|
const bindingPackageVersion = require("@oxfmt/binding-linux-x64-gnu/package.json").version;
|
|
234
|
-
if (bindingPackageVersion !== "0.
|
|
234
|
+
if (bindingPackageVersion !== "0.36.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.36.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
235
235
|
return binding;
|
|
236
236
|
} catch (e) {
|
|
237
237
|
loadErrors.push(e);
|
|
@@ -246,7 +246,7 @@ function requireNative() {
|
|
|
246
246
|
try {
|
|
247
247
|
const binding = require("@oxfmt/binding-linux-arm64-musl");
|
|
248
248
|
const bindingPackageVersion = require("@oxfmt/binding-linux-arm64-musl/package.json").version;
|
|
249
|
-
if (bindingPackageVersion !== "0.
|
|
249
|
+
if (bindingPackageVersion !== "0.36.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.36.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
250
250
|
return binding;
|
|
251
251
|
} catch (e) {
|
|
252
252
|
loadErrors.push(e);
|
|
@@ -260,7 +260,7 @@ function requireNative() {
|
|
|
260
260
|
try {
|
|
261
261
|
const binding = require("@oxfmt/binding-linux-arm64-gnu");
|
|
262
262
|
const bindingPackageVersion = require("@oxfmt/binding-linux-arm64-gnu/package.json").version;
|
|
263
|
-
if (bindingPackageVersion !== "0.
|
|
263
|
+
if (bindingPackageVersion !== "0.36.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.36.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
264
264
|
return binding;
|
|
265
265
|
} catch (e) {
|
|
266
266
|
loadErrors.push(e);
|
|
@@ -275,7 +275,7 @@ function requireNative() {
|
|
|
275
275
|
try {
|
|
276
276
|
const binding = require("@oxfmt/binding-linux-arm-musleabihf");
|
|
277
277
|
const bindingPackageVersion = require("@oxfmt/binding-linux-arm-musleabihf/package.json").version;
|
|
278
|
-
if (bindingPackageVersion !== "0.
|
|
278
|
+
if (bindingPackageVersion !== "0.36.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.36.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
279
279
|
return binding;
|
|
280
280
|
} catch (e) {
|
|
281
281
|
loadErrors.push(e);
|
|
@@ -289,7 +289,7 @@ function requireNative() {
|
|
|
289
289
|
try {
|
|
290
290
|
const binding = require("@oxfmt/binding-linux-arm-gnueabihf");
|
|
291
291
|
const bindingPackageVersion = require("@oxfmt/binding-linux-arm-gnueabihf/package.json").version;
|
|
292
|
-
if (bindingPackageVersion !== "0.
|
|
292
|
+
if (bindingPackageVersion !== "0.36.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.36.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
293
293
|
return binding;
|
|
294
294
|
} catch (e) {
|
|
295
295
|
loadErrors.push(e);
|
|
@@ -304,7 +304,7 @@ function requireNative() {
|
|
|
304
304
|
try {
|
|
305
305
|
const binding = require("@oxfmt/binding-linux-loong64-musl");
|
|
306
306
|
const bindingPackageVersion = require("@oxfmt/binding-linux-loong64-musl/package.json").version;
|
|
307
|
-
if (bindingPackageVersion !== "0.
|
|
307
|
+
if (bindingPackageVersion !== "0.36.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.36.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
308
308
|
return binding;
|
|
309
309
|
} catch (e) {
|
|
310
310
|
loadErrors.push(e);
|
|
@@ -318,7 +318,7 @@ function requireNative() {
|
|
|
318
318
|
try {
|
|
319
319
|
const binding = require("@oxfmt/binding-linux-loong64-gnu");
|
|
320
320
|
const bindingPackageVersion = require("@oxfmt/binding-linux-loong64-gnu/package.json").version;
|
|
321
|
-
if (bindingPackageVersion !== "0.
|
|
321
|
+
if (bindingPackageVersion !== "0.36.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.36.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
322
322
|
return binding;
|
|
323
323
|
} catch (e) {
|
|
324
324
|
loadErrors.push(e);
|
|
@@ -333,7 +333,7 @@ function requireNative() {
|
|
|
333
333
|
try {
|
|
334
334
|
const binding = require("@oxfmt/binding-linux-riscv64-musl");
|
|
335
335
|
const bindingPackageVersion = require("@oxfmt/binding-linux-riscv64-musl/package.json").version;
|
|
336
|
-
if (bindingPackageVersion !== "0.
|
|
336
|
+
if (bindingPackageVersion !== "0.36.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.36.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
337
337
|
return binding;
|
|
338
338
|
} catch (e) {
|
|
339
339
|
loadErrors.push(e);
|
|
@@ -347,7 +347,7 @@ function requireNative() {
|
|
|
347
347
|
try {
|
|
348
348
|
const binding = require("@oxfmt/binding-linux-riscv64-gnu");
|
|
349
349
|
const bindingPackageVersion = require("@oxfmt/binding-linux-riscv64-gnu/package.json").version;
|
|
350
|
-
if (bindingPackageVersion !== "0.
|
|
350
|
+
if (bindingPackageVersion !== "0.36.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.36.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
351
351
|
return binding;
|
|
352
352
|
} catch (e) {
|
|
353
353
|
loadErrors.push(e);
|
|
@@ -362,7 +362,7 @@ function requireNative() {
|
|
|
362
362
|
try {
|
|
363
363
|
const binding = require("@oxfmt/binding-linux-ppc64-gnu");
|
|
364
364
|
const bindingPackageVersion = require("@oxfmt/binding-linux-ppc64-gnu/package.json").version;
|
|
365
|
-
if (bindingPackageVersion !== "0.
|
|
365
|
+
if (bindingPackageVersion !== "0.36.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.36.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
366
366
|
return binding;
|
|
367
367
|
} catch (e) {
|
|
368
368
|
loadErrors.push(e);
|
|
@@ -376,7 +376,7 @@ function requireNative() {
|
|
|
376
376
|
try {
|
|
377
377
|
const binding = require("@oxfmt/binding-linux-s390x-gnu");
|
|
378
378
|
const bindingPackageVersion = require("@oxfmt/binding-linux-s390x-gnu/package.json").version;
|
|
379
|
-
if (bindingPackageVersion !== "0.
|
|
379
|
+
if (bindingPackageVersion !== "0.36.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.36.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
380
380
|
return binding;
|
|
381
381
|
} catch (e) {
|
|
382
382
|
loadErrors.push(e);
|
|
@@ -391,7 +391,7 @@ function requireNative() {
|
|
|
391
391
|
try {
|
|
392
392
|
const binding = require("@oxfmt/binding-openharmony-arm64");
|
|
393
393
|
const bindingPackageVersion = require("@oxfmt/binding-openharmony-arm64/package.json").version;
|
|
394
|
-
if (bindingPackageVersion !== "0.
|
|
394
|
+
if (bindingPackageVersion !== "0.36.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.36.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
395
395
|
return binding;
|
|
396
396
|
} catch (e) {
|
|
397
397
|
loadErrors.push(e);
|
|
@@ -405,7 +405,7 @@ function requireNative() {
|
|
|
405
405
|
try {
|
|
406
406
|
const binding = require("@oxfmt/binding-openharmony-x64");
|
|
407
407
|
const bindingPackageVersion = require("@oxfmt/binding-openharmony-x64/package.json").version;
|
|
408
|
-
if (bindingPackageVersion !== "0.
|
|
408
|
+
if (bindingPackageVersion !== "0.36.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.36.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
409
409
|
return binding;
|
|
410
410
|
} catch (e) {
|
|
411
411
|
loadErrors.push(e);
|
|
@@ -419,7 +419,7 @@ function requireNative() {
|
|
|
419
419
|
try {
|
|
420
420
|
const binding = require("@oxfmt/binding-openharmony-arm");
|
|
421
421
|
const bindingPackageVersion = require("@oxfmt/binding-openharmony-arm/package.json").version;
|
|
422
|
-
if (bindingPackageVersion !== "0.
|
|
422
|
+
if (bindingPackageVersion !== "0.36.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.36.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
423
423
|
return binding;
|
|
424
424
|
} catch (e) {
|
|
425
425
|
loadErrors.push(e);
|
package/dist/cli-worker.d.ts
CHANGED
|
@@ -1,34 +1,54 @@
|
|
|
1
1
|
import { t as Options } from "./index-BNhsnuYk.js";
|
|
2
2
|
|
|
3
3
|
//#region src-js/libs/apis.d.ts
|
|
4
|
+
type FormatFileParam = {
|
|
5
|
+
code: string;
|
|
6
|
+
options: Options;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Format non-js file
|
|
10
|
+
*
|
|
11
|
+
* @returns Formatted code
|
|
12
|
+
*/
|
|
13
|
+
declare function formatFile({
|
|
14
|
+
code,
|
|
15
|
+
options
|
|
16
|
+
}: FormatFileParam): Promise<string>;
|
|
4
17
|
type FormatEmbeddedCodeParam = {
|
|
5
18
|
code: string;
|
|
6
19
|
options: Options;
|
|
7
20
|
};
|
|
8
21
|
/**
|
|
9
|
-
* Format xxx-in-js code snippets
|
|
22
|
+
* Format xxx-in-js code snippets into formatted string.
|
|
23
|
+
*
|
|
24
|
+
* This will be gradually replaced by `formatEmbeddedDoc` which returns `Doc`.
|
|
25
|
+
* For now, html|css|md-in-js are using this.
|
|
10
26
|
*
|
|
11
27
|
* @returns Formatted code snippet
|
|
12
|
-
* TODO: In the future, this should return `Doc` instead of string,
|
|
13
|
-
* otherwise, we cannot calculate `printWidth` correctly.
|
|
14
28
|
*/
|
|
15
29
|
declare function formatEmbeddedCode({
|
|
16
30
|
code,
|
|
17
31
|
options
|
|
18
32
|
}: FormatEmbeddedCodeParam): Promise<string>;
|
|
19
|
-
type
|
|
20
|
-
|
|
33
|
+
type FormatEmbeddedDocParam = {
|
|
34
|
+
texts: string[];
|
|
21
35
|
options: Options;
|
|
22
36
|
};
|
|
23
37
|
/**
|
|
24
|
-
* Format
|
|
38
|
+
* Format xxx-in-js code snippets into Prettier `Doc` JSON strings.
|
|
25
39
|
*
|
|
26
|
-
*
|
|
40
|
+
* This makes `oxc_formatter` correctly handle `printWidth` even for embedded code.
|
|
41
|
+
* - For gql-in-js, `texts` contains multiple parts split by `${}` in a template literal
|
|
42
|
+
* - For others, `texts` always contains a single string with `${}` parts replaced by placeholders
|
|
43
|
+
* However, this function does not need to be aware of that,
|
|
44
|
+
* as it simply formats each text part independently and returns an array of formatted parts.
|
|
45
|
+
*
|
|
46
|
+
* @returns Doc JSON strings (one per input text)
|
|
27
47
|
*/
|
|
28
|
-
declare function
|
|
29
|
-
|
|
48
|
+
declare function formatEmbeddedDoc({
|
|
49
|
+
texts,
|
|
30
50
|
options
|
|
31
|
-
}:
|
|
51
|
+
}: FormatEmbeddedDocParam): Promise<string[]>;
|
|
32
52
|
interface SortTailwindClassesArgs {
|
|
33
53
|
classes: string[];
|
|
34
54
|
options: {
|
|
@@ -49,4 +69,4 @@ declare function sortTailwindClasses({
|
|
|
49
69
|
options
|
|
50
70
|
}: SortTailwindClassesArgs): Promise<string[]>;
|
|
51
71
|
//#endregion
|
|
52
|
-
export { formatEmbeddedCode, formatFile, sortTailwindClasses };
|
|
72
|
+
export { formatEmbeddedCode, formatEmbeddedDoc, formatFile, sortTailwindClasses };
|
package/dist/cli-worker.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as sortTailwindClasses, n as formatEmbeddedDoc, r as formatFile, t as formatEmbeddedCode } from "./apis-C04w0rkO.js";
|
|
2
2
|
|
|
3
|
-
export { formatEmbeddedCode, formatFile, sortTailwindClasses };
|
|
3
|
+
export { formatEmbeddedCode, formatEmbeddedDoc, formatFile, sortTailwindClasses };
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as runCli } from "./bindings-
|
|
2
|
-
import {
|
|
1
|
+
import { r as runCli } from "./bindings-BY08Skk2.js";
|
|
2
|
+
import { i as resolvePlugins } from "./apis-C04w0rkO.js";
|
|
3
3
|
import Tinypool from "tinypool";
|
|
4
4
|
|
|
5
5
|
//#region src-js/cli/worker-proxy.ts
|
|
@@ -18,12 +18,6 @@ async function disposeExternalFormatter() {
|
|
|
18
18
|
await pool?.destroy();
|
|
19
19
|
pool = null;
|
|
20
20
|
}
|
|
21
|
-
async function formatEmbeddedCode(options, code) {
|
|
22
|
-
return pool.run({
|
|
23
|
-
options,
|
|
24
|
-
code
|
|
25
|
-
}, { name: "formatEmbeddedCode" });
|
|
26
|
-
}
|
|
27
21
|
async function formatFile(options, code) {
|
|
28
22
|
return pool.run({
|
|
29
23
|
options,
|
|
@@ -39,11 +33,23 @@ async function formatFile(options, code) {
|
|
|
39
33
|
throw new Error(String(err));
|
|
40
34
|
});
|
|
41
35
|
}
|
|
36
|
+
async function formatEmbeddedCode(options, code) {
|
|
37
|
+
return pool.run({
|
|
38
|
+
options,
|
|
39
|
+
code
|
|
40
|
+
}, { name: "formatEmbeddedCode" }).catch(() => null);
|
|
41
|
+
}
|
|
42
|
+
async function formatEmbeddedDoc(options, texts) {
|
|
43
|
+
return pool.run({
|
|
44
|
+
options,
|
|
45
|
+
texts
|
|
46
|
+
}, { name: "formatEmbeddedDoc" }).catch(() => null);
|
|
47
|
+
}
|
|
42
48
|
async function sortTailwindClasses(options, classes) {
|
|
43
49
|
return pool.run({
|
|
44
50
|
classes,
|
|
45
51
|
options
|
|
46
|
-
}, { name: "sortTailwindClasses" });
|
|
52
|
+
}, { name: "sortTailwindClasses" }).catch(() => null);
|
|
47
53
|
}
|
|
48
54
|
|
|
49
55
|
//#endregion
|
|
@@ -51,13 +57,13 @@ async function sortTailwindClasses(options, classes) {
|
|
|
51
57
|
(async () => {
|
|
52
58
|
const args = process.argv.slice(2);
|
|
53
59
|
if (!process.stdout.isTTY) process.stdout._handle?.setBlocking?.(true);
|
|
54
|
-
const [mode, exitCode] = await runCli(args, initExternalFormatter, formatEmbeddedCode,
|
|
60
|
+
const [mode, exitCode] = await runCli(args, initExternalFormatter, formatFile, formatEmbeddedCode, formatEmbeddedDoc, sortTailwindClasses);
|
|
55
61
|
if (mode === "init") {
|
|
56
62
|
await import("./init-BlnymtNS.js").then((m) => m.runInit());
|
|
57
63
|
return;
|
|
58
64
|
}
|
|
59
65
|
if (mode === "migrate:prettier") {
|
|
60
|
-
await import("./migrate-prettier-
|
|
66
|
+
await import("./migrate-prettier-BrvLf3WK.js").then((m) => m.runMigratePrettier());
|
|
61
67
|
return;
|
|
62
68
|
}
|
|
63
69
|
if (mode === "migrate:biome") {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-DpReBE2K.js";
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { i as
|
|
6
|
-
import { a as
|
|
7
|
-
import {
|
|
2
|
+
import { a as __toESM, t as __commonJSMin } from "./chunk-DSjvVL_1-B9nK_dIv.js";
|
|
3
|
+
import { n as loadIfExists, r as maybeResolve, t as expiringMap } from "./resolve-pWjAK-4f-DMrPXOR5.js";
|
|
4
|
+
import { i as visit, n as cacheForDirs, r as spliceChangesIntoString } from "./utils-D8dQkKEd-w107AldM.js";
|
|
5
|
+
import { a as sortClasses, i as sortClassList, n as error, o as warn, r as getTailwindConfig$1 } from "./sorter-BZkvDMjt-CZzzihz1.js";
|
|
6
|
+
import { a as en$1, o as postcss_exports } from "./angular-BYaMjeNY.js";
|
|
7
|
+
import { t as index_exports } from "./prettier-CK6Vmyxp.js";
|
|
8
8
|
import * as path from "node:path";
|
|
9
9
|
import { isAbsolute } from "path";
|
|
10
10
|
|
package/dist/index.d.ts
CHANGED
|
@@ -24,12 +24,6 @@ interface FormatResult {
|
|
|
24
24
|
/** Parse and format errors. */
|
|
25
25
|
errors: Array<OxcError>;
|
|
26
26
|
}
|
|
27
|
-
interface TextToDocResult {
|
|
28
|
-
/** The formatted code. */
|
|
29
|
-
doc: string;
|
|
30
|
-
/** Parse and format errors. */
|
|
31
|
-
errors: Array<OxcError>;
|
|
32
|
-
}
|
|
33
27
|
//#endregion
|
|
34
28
|
//#region src-js/index.d.ts
|
|
35
29
|
/**
|
|
@@ -39,7 +33,7 @@ declare function format(fileName: string, sourceText: string, options?: FormatOp
|
|
|
39
33
|
/**
|
|
40
34
|
* Format a JS/TS snippet for Prettier `textToDoc()` plugin flow.
|
|
41
35
|
*/
|
|
42
|
-
declare function jsTextToDoc(
|
|
36
|
+
declare function jsTextToDoc(sourceExt: string, sourceText: string, oxfmtPluginOptionsJson: string, parentContext: string): Promise<string | null>;
|
|
43
37
|
/**
|
|
44
38
|
* Configuration options for the `format()` API.
|
|
45
39
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as jsTextToDoc$1, t as format$1 } from "./bindings-
|
|
2
|
-
import {
|
|
1
|
+
import { n as jsTextToDoc$1, t as format$1 } from "./bindings-BY08Skk2.js";
|
|
2
|
+
import { a as sortTailwindClasses, i as resolvePlugins, n as formatEmbeddedDoc, r as formatFile, t as formatEmbeddedCode } from "./apis-C04w0rkO.js";
|
|
3
3
|
|
|
4
4
|
//#region src-js/index.ts
|
|
5
5
|
/**
|
|
@@ -8,12 +8,15 @@ import { i as sortTailwindClasses, n as formatFile, r as resolvePlugins, t as fo
|
|
|
8
8
|
async function format(fileName, sourceText, options) {
|
|
9
9
|
if (typeof fileName !== "string") throw new TypeError("`fileName` must be a string");
|
|
10
10
|
if (typeof sourceText !== "string") throw new TypeError("`sourceText` must be a string");
|
|
11
|
-
return format$1(fileName, sourceText, options ?? {}, resolvePlugins, (options, code) =>
|
|
11
|
+
return format$1(fileName, sourceText, options ?? {}, resolvePlugins, (options, code) => formatFile({
|
|
12
12
|
options,
|
|
13
13
|
code
|
|
14
|
-
}), (options, code) =>
|
|
14
|
+
}), (options, code) => formatEmbeddedCode({
|
|
15
15
|
options,
|
|
16
16
|
code
|
|
17
|
+
}), (options, texts) => formatEmbeddedDoc({
|
|
18
|
+
options,
|
|
19
|
+
texts
|
|
17
20
|
}), (options, classes) => sortTailwindClasses({
|
|
18
21
|
options,
|
|
19
22
|
classes
|
|
@@ -22,11 +25,14 @@ async function format(fileName, sourceText, options) {
|
|
|
22
25
|
/**
|
|
23
26
|
* Format a JS/TS snippet for Prettier `textToDoc()` plugin flow.
|
|
24
27
|
*/
|
|
25
|
-
async function jsTextToDoc(
|
|
26
|
-
return jsTextToDoc$1(
|
|
28
|
+
async function jsTextToDoc(sourceExt, sourceText, oxfmtPluginOptionsJson, parentContext) {
|
|
29
|
+
return jsTextToDoc$1(sourceExt, sourceText, oxfmtPluginOptionsJson, parentContext, resolvePlugins, (_options, _code) => Promise.reject(), (options, code) => formatEmbeddedCode({
|
|
27
30
|
options,
|
|
28
31
|
code
|
|
29
|
-
}), (
|
|
32
|
+
}), (options, texts) => formatEmbeddedDoc({
|
|
33
|
+
options,
|
|
34
|
+
texts
|
|
35
|
+
}), (options, classes) => sortTailwindClasses({
|
|
30
36
|
options,
|
|
31
37
|
classes
|
|
32
38
|
}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as __toESM, i as __require, t as __commonJSMin } from "./chunk-DSjvVL_1-
|
|
1
|
+
import { a as __toESM, i as __require, t as __commonJSMin } from "./chunk-DSjvVL_1-B9nK_dIv.js";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
|
|
4
4
|
//#region ../../node_modules/.pnpm/prettier-plugin-tailwindcss@0.0.0-insiders.3997fbd_prettier@3.8.1/node_modules/prettier-plugin-tailwindcss/dist/jiti-Bb1dT6Cw.mjs
|
|
@@ -10,7 +10,7 @@ import { readFile } from "node:fs/promises";
|
|
|
10
10
|
async function runMigratePrettier() {
|
|
11
11
|
const cwd = process.cwd();
|
|
12
12
|
if (await hasOxfmtrcFile(cwd)) return exitWithError("Oxfmt configuration file already exists.");
|
|
13
|
-
const { resolveConfigFile, resolveConfig } = await import("./prettier-
|
|
13
|
+
const { resolveConfigFile, resolveConfig } = await import("./prettier-CK6Vmyxp.js").then((n) => n.n);
|
|
14
14
|
const prettierConfigPath = await resolveConfigFile(join(cwd, "dummy.js"));
|
|
15
15
|
if (!prettierConfigPath) {
|
|
16
16
|
console.log("No Prettier configuration file found.");
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-DpReBE2K.js";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import path10, { dirname } from "path";
|
|
4
|
+
import fs3, { realpathSync, statSync } from "fs";
|
|
2
5
|
import { builtinModules, createRequire } from "module";
|
|
3
6
|
import * as url from "url";
|
|
4
7
|
import url2, { fileURLToPath, pathToFileURL } from "url";
|
|
5
|
-
import * as path from "path";
|
|
6
|
-
import path10, { dirname } from "path";
|
|
7
8
|
import * as fs from "fs/promises";
|
|
8
9
|
import fs2 from "fs/promises";
|
|
9
10
|
import process2 from "process";
|
|
10
11
|
import assert3, { ok, strictEqual } from "assert";
|
|
11
|
-
import fs3, { realpathSync, statSync } from "fs";
|
|
12
12
|
import v8 from "v8";
|
|
13
13
|
import { format, inspect } from "util";
|
|
14
14
|
|
|
@@ -15201,7 +15201,7 @@ var { parsers, printers } = createParsersAndPrinters([
|
|
|
15201
15201
|
parsers: ["acorn", "espree"]
|
|
15202
15202
|
},
|
|
15203
15203
|
{
|
|
15204
|
-
importPlugin: () => import("./angular-
|
|
15204
|
+
importPlugin: () => import("./angular-BYaMjeNY.js"),
|
|
15205
15205
|
parsers: [
|
|
15206
15206
|
"__ng_action",
|
|
15207
15207
|
"__ng_binding",
|
|
@@ -15210,7 +15210,7 @@ var { parsers, printers } = createParsersAndPrinters([
|
|
|
15210
15210
|
]
|
|
15211
15211
|
},
|
|
15212
15212
|
{
|
|
15213
|
-
importPlugin: () => import("./babel-
|
|
15213
|
+
importPlugin: () => import("./babel-CsJ8KocL.js"),
|
|
15214
15214
|
parsers: [
|
|
15215
15215
|
"babel",
|
|
15216
15216
|
"babel-flow",
|
|
@@ -15267,7 +15267,7 @@ var { parsers, printers } = createParsersAndPrinters([
|
|
|
15267
15267
|
parsers: ["meriyah"]
|
|
15268
15268
|
},
|
|
15269
15269
|
{
|
|
15270
|
-
importPlugin: () => import("./postcss-
|
|
15270
|
+
importPlugin: () => import("./postcss-o-3qwTQO.js"),
|
|
15271
15271
|
parsers: [
|
|
15272
15272
|
"css",
|
|
15273
15273
|
"less",
|
|
@@ -15605,4 +15605,4 @@ var debugApis = {
|
|
|
15605
15605
|
};
|
|
15606
15606
|
|
|
15607
15607
|
//#endregion
|
|
15608
|
-
export { prettier_exports as n,
|
|
15608
|
+
export { prettier_exports as n, index_exports as t };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import "./bindings-BY08Skk2.js";
|
|
2
|
+
import "./apis-C04w0rkO.js";
|
|
3
|
+
import { jsTextToDoc } from "./index.js";
|
|
4
|
+
|
|
5
|
+
//#region src-js/libs/prettier-plugin-oxfmt/text-to-doc.ts
|
|
6
|
+
const textToDoc = async (embeddedSourceText, textToDocOptions) => {
|
|
7
|
+
const { parser, parentParser, filepath, _oxfmtPluginOptionsJson } = textToDocOptions;
|
|
8
|
+
const doc = await jsTextToDoc(parser === "typescript" || parser === "babel-ts" ? filepath?.endsWith(".tsx") ? "tsx" : "ts" : "jsx", embeddedSourceText, _oxfmtPluginOptionsJson, detectParentContext(parentParser, textToDocOptions));
|
|
9
|
+
if (doc === null) throw new Error("`oxfmt::textToDoc()` failed. Use `OXC_LOG` env var to see Rust-side logs.");
|
|
10
|
+
return JSON.parse(doc);
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Detects Vue fragment mode from Prettier's internal flags.
|
|
14
|
+
*
|
|
15
|
+
* When Prettier formats Vue SFC templates, it calls textToDoc with special flags:
|
|
16
|
+
* - `__isVueForBindingLeft`: v-for left-hand side (e.g., `(item, index)` in `v-for="(item, index) in items"`)
|
|
17
|
+
* - `__isVueBindings`: v-slot bindings (e.g., `{ item }` in `#default="{ item }"`)
|
|
18
|
+
* - `__isEmbeddedTypescriptGenericParameters`: `<script generic="...">` type parameters
|
|
19
|
+
*/
|
|
20
|
+
function detectParentContext(parentParser, options) {
|
|
21
|
+
if (parentParser === "vue") {
|
|
22
|
+
if ("__isVueForBindingLeft" in options) return "vue-for-binding-left";
|
|
23
|
+
if ("__isVueBindings" in options) return "vue-bindings";
|
|
24
|
+
if ("__isEmbeddedTypescriptGenericParameters" in options) return "vue-script-generic";
|
|
25
|
+
return "vue-script";
|
|
26
|
+
}
|
|
27
|
+
return parentParser;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src-js/libs/prettier-plugin-oxfmt/index.ts
|
|
32
|
+
/**
|
|
33
|
+
* Prettier plugin that uses `oxc_formatter` for (j|t)s-in-xxx part.
|
|
34
|
+
*
|
|
35
|
+
* When Prettier formats Vue/HTML (which can embed JS/TS code inside) files,
|
|
36
|
+
* it calls the `embed()` function for each block.
|
|
37
|
+
*
|
|
38
|
+
* By default, it uses the `babel` or `typescript` parser and `estree` printer.
|
|
39
|
+
* Therefore, by overriding these internally, we can use `oxc_formatter` instead.
|
|
40
|
+
* e.g. Now it's possible to apply our builtin sort-imports for JS/TS code inside Vue `<script>`.
|
|
41
|
+
*/
|
|
42
|
+
const options = { _oxfmtPluginOptionsJson: {
|
|
43
|
+
category: "JavaScript",
|
|
44
|
+
type: "string",
|
|
45
|
+
default: "{}",
|
|
46
|
+
description: "Bundled JSON string for oxfmt-plugin options"
|
|
47
|
+
} };
|
|
48
|
+
const oxfmtParser = {
|
|
49
|
+
parse: textToDoc,
|
|
50
|
+
astFormat: "OXFMT",
|
|
51
|
+
locStart: () => -1,
|
|
52
|
+
locEnd: () => -1
|
|
53
|
+
};
|
|
54
|
+
const parsers = {
|
|
55
|
+
babel: oxfmtParser,
|
|
56
|
+
"babel-ts": oxfmtParser,
|
|
57
|
+
typescript: oxfmtParser
|
|
58
|
+
};
|
|
59
|
+
const printers = { OXFMT: { print: ({ node }) => node } };
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
62
|
+
export { options, parsers, printers };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { a as resolveJsFrom, t as expiringMap } from "./resolve-pWjAK-4f-
|
|
2
|
-
import { n as cacheForDirs, t as bigSign } from "./utils-D8dQkKEd-
|
|
1
|
+
import { a as resolveJsFrom, t as expiringMap } from "./resolve-pWjAK-4f-DMrPXOR5.js";
|
|
2
|
+
import { n as cacheForDirs, t as bigSign } from "./utils-D8dQkKEd-w107AldM.js";
|
|
3
3
|
import * as path from "node:path";
|
|
4
|
+
import { pathToFileURL } from "node:url";
|
|
4
5
|
import { dirname, resolve } from "path";
|
|
5
6
|
import { readdirSync, statSync } from "fs";
|
|
6
|
-
import { pathToFileURL } from "node:url";
|
|
7
7
|
|
|
8
8
|
//#region ../../node_modules/.pnpm/prettier-plugin-tailwindcss@0.0.0-insiders.3997fbd_prettier@3.8.1/node_modules/prettier-plugin-tailwindcss/dist/sorter-BZkvDMjt.mjs
|
|
9
9
|
let seen = /* @__PURE__ */ new Set();
|
|
@@ -104,14 +104,14 @@ async function getTailwindConfig(options) {
|
|
|
104
104
|
if (!stylesheet && !(mod === null || mod === void 0 ? void 0 : mod.__unstable__loadDesignSystem)) jsConfig = jsConfig ?? findClosestJsConfig(inputDir);
|
|
105
105
|
if (jsConfig) {
|
|
106
106
|
if (!stylesheet) return pathToApiMap.remember(`${pkgDir}:${jsConfig}`, async () => {
|
|
107
|
-
const { loadV3 } = await import("./v3-D-mr2VVh-
|
|
107
|
+
const { loadV3 } = await import("./v3-D-mr2VVh-Bj3_v5Qp.js");
|
|
108
108
|
return loadV3(pkgDir, jsConfig);
|
|
109
109
|
});
|
|
110
110
|
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.`);
|
|
111
111
|
}
|
|
112
112
|
if (mod && !mod.__unstable__loadDesignSystem) {
|
|
113
113
|
if (!stylesheet) return pathToApiMap.remember(`${pkgDir}:${jsConfig}`, async () => {
|
|
114
|
-
const { loadV3 } = await import("./v3-D-mr2VVh-
|
|
114
|
+
const { loadV3 } = await import("./v3-D-mr2VVh-Bj3_v5Qp.js");
|
|
115
115
|
return loadV3(pkgDir, jsConfig);
|
|
116
116
|
});
|
|
117
117
|
mod = null;
|
|
@@ -119,7 +119,7 @@ async function getTailwindConfig(options) {
|
|
|
119
119
|
}
|
|
120
120
|
if (mod && mod.__unstable__loadDesignSystem && pkgDir) stylesheet ?? (stylesheet = `${pkgDir}/theme.css`);
|
|
121
121
|
return pathToApiMap.remember(`${pkgDir}:${stylesheet}`, async () => {
|
|
122
|
-
const { loadV4 } = await import("./v4-C-HWEQJm-
|
|
122
|
+
const { loadV4 } = await import("./v4-C-HWEQJm-D29N-mp3.js");
|
|
123
123
|
return loadV4(mod, stylesheet);
|
|
124
124
|
});
|
|
125
125
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as __toESM, i as __require, n as __esmMin, t as __commonJSMin } from "./chunk-DSjvVL_1-
|
|
2
|
-
import { t as bigSign } from "./utils-D8dQkKEd-
|
|
3
|
-
import { t as createJiti } from "./jiti-Bb1dT6Cw-
|
|
1
|
+
import { a as __toESM, i as __require, n as __esmMin, t as __commonJSMin } from "./chunk-DSjvVL_1-B9nK_dIv.js";
|
|
2
|
+
import { t as bigSign } from "./utils-D8dQkKEd-w107AldM.js";
|
|
3
|
+
import { t as createJiti } from "./jiti-Bb1dT6Cw-D7Kk0pkW.js";
|
|
4
4
|
import * as path from "node:path";
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { r as __exportAll } from "./chunk-DSjvVL_1-
|
|
2
|
-
import { a as resolveJsFrom, i as resolveCssFrom } from "./resolve-pWjAK-4f-
|
|
3
|
-
import { t as createJiti } from "./jiti-Bb1dT6Cw-
|
|
1
|
+
import { r as __exportAll } from "./chunk-DSjvVL_1-B9nK_dIv.js";
|
|
2
|
+
import { a as resolveJsFrom, i as resolveCssFrom } from "./resolve-pWjAK-4f-DMrPXOR5.js";
|
|
3
|
+
import { t as createJiti } from "./jiti-Bb1dT6Cw-D7Kk0pkW.js";
|
|
4
4
|
import * as path from "node:path";
|
|
5
5
|
import * as fs from "node:fs/promises";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oxfmt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0",
|
|
4
4
|
"description": "Formatter for the JavaScript Oxidation Compiler",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"formatter",
|
|
@@ -65,25 +65,26 @@
|
|
|
65
65
|
"engines": {
|
|
66
66
|
"node": "^20.19.0 || >=22.12.0"
|
|
67
67
|
},
|
|
68
|
+
"preferUnplugged": true,
|
|
68
69
|
"optionalDependencies": {
|
|
69
|
-
"@oxfmt/binding-darwin-arm64": "0.
|
|
70
|
-
"@oxfmt/binding-android-arm64": "0.
|
|
71
|
-
"@oxfmt/binding-win32-arm64-msvc": "0.
|
|
72
|
-
"@oxfmt/binding-linux-arm64-gnu": "0.
|
|
73
|
-
"@oxfmt/binding-linux-arm64-musl": "0.
|
|
74
|
-
"@oxfmt/binding-openharmony-arm64": "0.
|
|
75
|
-
"@oxfmt/binding-android-arm-eabi": "0.
|
|
76
|
-
"@oxfmt/binding-linux-arm-gnueabihf": "0.
|
|
77
|
-
"@oxfmt/binding-linux-arm-musleabihf": "0.
|
|
78
|
-
"@oxfmt/binding-win32-ia32-msvc": "0.
|
|
79
|
-
"@oxfmt/binding-linux-ppc64-gnu": "0.
|
|
80
|
-
"@oxfmt/binding-linux-riscv64-gnu": "0.
|
|
81
|
-
"@oxfmt/binding-linux-riscv64-musl": "0.
|
|
82
|
-
"@oxfmt/binding-linux-s390x-gnu": "0.
|
|
83
|
-
"@oxfmt/binding-darwin-x64": "0.
|
|
84
|
-
"@oxfmt/binding-win32-x64-msvc": "0.
|
|
85
|
-
"@oxfmt/binding-freebsd-x64": "0.
|
|
86
|
-
"@oxfmt/binding-linux-x64-gnu": "0.
|
|
87
|
-
"@oxfmt/binding-linux-x64-musl": "0.
|
|
70
|
+
"@oxfmt/binding-darwin-arm64": "0.36.0",
|
|
71
|
+
"@oxfmt/binding-android-arm64": "0.36.0",
|
|
72
|
+
"@oxfmt/binding-win32-arm64-msvc": "0.36.0",
|
|
73
|
+
"@oxfmt/binding-linux-arm64-gnu": "0.36.0",
|
|
74
|
+
"@oxfmt/binding-linux-arm64-musl": "0.36.0",
|
|
75
|
+
"@oxfmt/binding-openharmony-arm64": "0.36.0",
|
|
76
|
+
"@oxfmt/binding-android-arm-eabi": "0.36.0",
|
|
77
|
+
"@oxfmt/binding-linux-arm-gnueabihf": "0.36.0",
|
|
78
|
+
"@oxfmt/binding-linux-arm-musleabihf": "0.36.0",
|
|
79
|
+
"@oxfmt/binding-win32-ia32-msvc": "0.36.0",
|
|
80
|
+
"@oxfmt/binding-linux-ppc64-gnu": "0.36.0",
|
|
81
|
+
"@oxfmt/binding-linux-riscv64-gnu": "0.36.0",
|
|
82
|
+
"@oxfmt/binding-linux-riscv64-musl": "0.36.0",
|
|
83
|
+
"@oxfmt/binding-linux-s390x-gnu": "0.36.0",
|
|
84
|
+
"@oxfmt/binding-darwin-x64": "0.36.0",
|
|
85
|
+
"@oxfmt/binding-win32-x64-msvc": "0.36.0",
|
|
86
|
+
"@oxfmt/binding-freebsd-x64": "0.36.0",
|
|
87
|
+
"@oxfmt/binding-linux-x64-gnu": "0.36.0",
|
|
88
|
+
"@oxfmt/binding-linux-x64-musl": "0.36.0"
|
|
88
89
|
}
|
|
89
90
|
}
|
package/dist/babel-CmMxKXKi.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import "./bindings-Bg9JnrLc.js";
|
|
2
|
-
import "./apis-KSwODFyo.js";
|
|
3
|
-
import { jsTextToDoc } from "./index.js";
|
|
4
|
-
import { r as builders } from "./prettier-DIVejRqd.js";
|
|
5
|
-
|
|
6
|
-
//#region src-js/libs/prettier-plugin-oxfmt/text-to-doc.ts
|
|
7
|
-
const { hardline, join } = builders;
|
|
8
|
-
const LINE_BREAK_RE = /\r?\n/;
|
|
9
|
-
const textToDoc = async (embeddedSourceText, textToDocOptions) => {
|
|
10
|
-
const { parser, parentParser, filepath, _oxfmtPluginOptionsJson } = textToDocOptions;
|
|
11
|
-
const { doc: formattedText, errors } = await jsTextToDoc(parser === "typescript" ? filepath.endsWith(".tsx") ? "dummy.tsx" : "dummy.ts" : "dummy.jsx", embeddedSourceText, _oxfmtPluginOptionsJson, [parentParser].join(":"));
|
|
12
|
-
if (0 < errors.length) throw new Error(errors[0].message);
|
|
13
|
-
return join(hardline, formattedText.split(LINE_BREAK_RE));
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region src-js/libs/prettier-plugin-oxfmt/index.ts
|
|
18
|
-
/**
|
|
19
|
-
* Prettier plugin that uses `oxc_formatter` for (j|t)s-in-xxx part.
|
|
20
|
-
*
|
|
21
|
-
* When Prettier formats Vue/HTML (which can embed JS/TS code inside) files,
|
|
22
|
-
* it calls the `embed()` function for each block.
|
|
23
|
-
*
|
|
24
|
-
* By default, it uses the `babel` or `typescript` parser and `estree` printer.
|
|
25
|
-
* Therefore, by overriding these internally, we can use `oxc_formatter` instead.
|
|
26
|
-
* e.g. Now it's possible to apply our builtin sort-imports for JS/TS code inside Vue `<script>`.
|
|
27
|
-
*/
|
|
28
|
-
const options = { _oxfmtPluginOptionsJson: {
|
|
29
|
-
category: "JavaScript",
|
|
30
|
-
type: "string",
|
|
31
|
-
default: "{}",
|
|
32
|
-
description: "Bundled JSON string for oxfmt-plugin options"
|
|
33
|
-
} };
|
|
34
|
-
const oxfmtParser = {
|
|
35
|
-
parse: textToDoc,
|
|
36
|
-
astFormat: "OXFMT",
|
|
37
|
-
locStart: () => -1,
|
|
38
|
-
locEnd: () => -1
|
|
39
|
-
};
|
|
40
|
-
const parsers = {
|
|
41
|
-
babel: oxfmtParser,
|
|
42
|
-
typescript: oxfmtParser
|
|
43
|
-
};
|
|
44
|
-
const printers = { OXFMT: { print: ({ node }) => node } };
|
|
45
|
-
|
|
46
|
-
//#endregion
|
|
47
|
-
export { options, parsers, printers };
|
package/dist/sorter-CjGwXe5x.js
DELETED
|
File without changes
|
|
File without changes
|