oxfmt 0.8.0 → 0.10.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.
@@ -29,6 +29,17 @@
29
29
  "null"
30
30
  ]
31
31
  },
32
+ "embeddedLanguageFormatting": {
33
+ "description": "Control whether formats quoted code embedded in the file. (Default: \"auto\")",
34
+ "anyOf": [
35
+ {
36
+ "$ref": "#/definitions/EmbeddedLanguageFormattingConfig"
37
+ },
38
+ {
39
+ "type": "null"
40
+ }
41
+ ]
42
+ },
32
43
  "endOfLine": {
33
44
  "description": "Which end of line characters to apply. (Default: \"lf\")",
34
45
  "anyOf": [
@@ -167,6 +178,13 @@
167
178
  "avoid"
168
179
  ]
169
180
  },
181
+ "EmbeddedLanguageFormattingConfig": {
182
+ "type": "string",
183
+ "enum": [
184
+ "auto",
185
+ "off"
186
+ ]
187
+ },
170
188
  "EndOfLineConfig": {
171
189
  "type": "string",
172
190
  "enum": [
@@ -244,4 +262,4 @@
244
262
  ]
245
263
  }
246
264
  }
247
- }
265
+ }
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { };
package/dist/cli.js ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ import { n as format, t as formatEmbeddedCode } from "./embedded-CSusLtBX.js";
3
+
4
+ //#region src-js/cli.ts
5
+ const success = await format(process.argv.slice(2), formatEmbeddedCode);
6
+ process.exit(success ? 0 : 1);
7
+
8
+ //#endregion
9
+ export { };
@@ -0,0 +1,500 @@
1
+ import { createRequire } from "node:module";
2
+ import prettier from "@prettier/sync";
3
+
4
+ //#region src-js/bindings.js
5
+ const require = createRequire(import.meta.url);
6
+ new URL(".", import.meta.url).pathname;
7
+ const { readFileSync } = require("node:fs");
8
+ let nativeBinding = null;
9
+ const loadErrors = [];
10
+ const isMusl = () => {
11
+ let musl = false;
12
+ if (process.platform === "linux") {
13
+ musl = isMuslFromFilesystem();
14
+ if (musl === null) musl = isMuslFromReport();
15
+ if (musl === null) musl = isMuslFromChildProcess();
16
+ }
17
+ return musl;
18
+ };
19
+ const isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
20
+ const isMuslFromFilesystem = () => {
21
+ try {
22
+ return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
23
+ } catch {
24
+ return null;
25
+ }
26
+ };
27
+ const isMuslFromReport = () => {
28
+ let report = null;
29
+ if (typeof process.report?.getReport === "function") {
30
+ process.report.excludeNetwork = true;
31
+ report = process.report.getReport();
32
+ }
33
+ if (!report) return null;
34
+ if (report.header && report.header.glibcVersionRuntime) return false;
35
+ if (Array.isArray(report.sharedObjects)) {
36
+ if (report.sharedObjects.some(isFileMusl)) return true;
37
+ }
38
+ return false;
39
+ };
40
+ const isMuslFromChildProcess = () => {
41
+ try {
42
+ return require("child_process").execSync("ldd --version", { encoding: "utf8" }).includes("musl");
43
+ } catch (e) {
44
+ return false;
45
+ }
46
+ };
47
+ function requireNative() {
48
+ if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) try {
49
+ return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
50
+ } catch (err) {
51
+ loadErrors.push(err);
52
+ }
53
+ else if (process.platform === "android") if (process.arch === "arm64") {
54
+ try {
55
+ return require("./oxfmt.android-arm64.node");
56
+ } catch (e) {
57
+ loadErrors.push(e);
58
+ }
59
+ try {
60
+ const binding = require("@oxfmt/android-arm64");
61
+ const bindingPackageVersion = require("@oxfmt/android-arm64/package.json").version;
62
+ if (bindingPackageVersion !== "0.9.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.9.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
63
+ return binding;
64
+ } catch (e) {
65
+ loadErrors.push(e);
66
+ }
67
+ } else if (process.arch === "arm") {
68
+ try {
69
+ return require("./oxfmt.android-arm-eabi.node");
70
+ } catch (e) {
71
+ loadErrors.push(e);
72
+ }
73
+ try {
74
+ const binding = require("@oxfmt/android-arm-eabi");
75
+ const bindingPackageVersion = require("@oxfmt/android-arm-eabi/package.json").version;
76
+ if (bindingPackageVersion !== "0.9.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.9.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
77
+ return binding;
78
+ } catch (e) {
79
+ loadErrors.push(e);
80
+ }
81
+ } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Android ${process.arch}`));
82
+ 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") {
83
+ try {
84
+ return require("./oxfmt.win32-x64-gnu.node");
85
+ } catch (e) {
86
+ loadErrors.push(e);
87
+ }
88
+ try {
89
+ const binding = require("@oxfmt/win32-x64-gnu");
90
+ const bindingPackageVersion = require("@oxfmt/win32-x64-gnu/package.json").version;
91
+ if (bindingPackageVersion !== "0.9.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.9.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
92
+ return binding;
93
+ } catch (e) {
94
+ loadErrors.push(e);
95
+ }
96
+ } else {
97
+ try {
98
+ return require("./oxfmt.win32-x64-msvc.node");
99
+ } catch (e) {
100
+ loadErrors.push(e);
101
+ }
102
+ try {
103
+ const binding = require("@oxfmt/win32-x64");
104
+ const bindingPackageVersion = require("@oxfmt/win32-x64/package.json").version;
105
+ if (bindingPackageVersion !== "0.9.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.9.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
106
+ return binding;
107
+ } catch (e) {
108
+ loadErrors.push(e);
109
+ }
110
+ }
111
+ else if (process.arch === "ia32") {
112
+ try {
113
+ return require("./oxfmt.win32-ia32-msvc.node");
114
+ } catch (e) {
115
+ loadErrors.push(e);
116
+ }
117
+ try {
118
+ const binding = require("@oxfmt/win32-ia32");
119
+ const bindingPackageVersion = require("@oxfmt/win32-ia32/package.json").version;
120
+ if (bindingPackageVersion !== "0.9.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.9.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
121
+ return binding;
122
+ } catch (e) {
123
+ loadErrors.push(e);
124
+ }
125
+ } else if (process.arch === "arm64") {
126
+ try {
127
+ return require("./oxfmt.win32-arm64-msvc.node");
128
+ } catch (e) {
129
+ loadErrors.push(e);
130
+ }
131
+ try {
132
+ const binding = require("@oxfmt/win32-arm64");
133
+ const bindingPackageVersion = require("@oxfmt/win32-arm64/package.json").version;
134
+ if (bindingPackageVersion !== "0.9.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.9.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
135
+ return binding;
136
+ } catch (e) {
137
+ loadErrors.push(e);
138
+ }
139
+ } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Windows: ${process.arch}`));
140
+ else if (process.platform === "darwin") {
141
+ try {
142
+ return require("./oxfmt.darwin-universal.node");
143
+ } catch (e) {
144
+ loadErrors.push(e);
145
+ }
146
+ try {
147
+ const binding = require("@oxfmt/darwin-universal");
148
+ const bindingPackageVersion = require("@oxfmt/darwin-universal/package.json").version;
149
+ if (bindingPackageVersion !== "0.9.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.9.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
150
+ return binding;
151
+ } catch (e) {
152
+ loadErrors.push(e);
153
+ }
154
+ if (process.arch === "x64") {
155
+ try {
156
+ return require("./oxfmt.darwin-x64.node");
157
+ } catch (e) {
158
+ loadErrors.push(e);
159
+ }
160
+ try {
161
+ const binding = require("@oxfmt/darwin-x64");
162
+ const bindingPackageVersion = require("@oxfmt/darwin-x64/package.json").version;
163
+ if (bindingPackageVersion !== "0.9.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.9.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
164
+ return binding;
165
+ } catch (e) {
166
+ loadErrors.push(e);
167
+ }
168
+ } else if (process.arch === "arm64") {
169
+ try {
170
+ return require("./oxfmt.darwin-arm64.node");
171
+ } catch (e) {
172
+ loadErrors.push(e);
173
+ }
174
+ try {
175
+ const binding = require("@oxfmt/darwin-arm64");
176
+ const bindingPackageVersion = require("@oxfmt/darwin-arm64/package.json").version;
177
+ if (bindingPackageVersion !== "0.9.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.9.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
178
+ return binding;
179
+ } catch (e) {
180
+ loadErrors.push(e);
181
+ }
182
+ } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on macOS: ${process.arch}`));
183
+ } else if (process.platform === "freebsd") if (process.arch === "x64") {
184
+ try {
185
+ return require("./oxfmt.freebsd-x64.node");
186
+ } catch (e) {
187
+ loadErrors.push(e);
188
+ }
189
+ try {
190
+ const binding = require("@oxfmt/freebsd-x64");
191
+ const bindingPackageVersion = require("@oxfmt/freebsd-x64/package.json").version;
192
+ if (bindingPackageVersion !== "0.9.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.9.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
193
+ return binding;
194
+ } catch (e) {
195
+ loadErrors.push(e);
196
+ }
197
+ } else if (process.arch === "arm64") {
198
+ try {
199
+ return require("./oxfmt.freebsd-arm64.node");
200
+ } catch (e) {
201
+ loadErrors.push(e);
202
+ }
203
+ try {
204
+ const binding = require("@oxfmt/freebsd-arm64");
205
+ const bindingPackageVersion = require("@oxfmt/freebsd-arm64/package.json").version;
206
+ if (bindingPackageVersion !== "0.9.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.9.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
207
+ return binding;
208
+ } catch (e) {
209
+ loadErrors.push(e);
210
+ }
211
+ } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on FreeBSD: ${process.arch}`));
212
+ else if (process.platform === "linux") if (process.arch === "x64") if (isMusl()) {
213
+ try {
214
+ return require("./oxfmt.linux-x64-musl.node");
215
+ } catch (e) {
216
+ loadErrors.push(e);
217
+ }
218
+ try {
219
+ const binding = require("@oxfmt/linux-x64-musl");
220
+ const bindingPackageVersion = require("@oxfmt/linux-x64-musl/package.json").version;
221
+ if (bindingPackageVersion !== "0.9.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.9.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
222
+ return binding;
223
+ } catch (e) {
224
+ loadErrors.push(e);
225
+ }
226
+ } else {
227
+ try {
228
+ return require("./oxfmt.linux-x64-gnu.node");
229
+ } catch (e) {
230
+ loadErrors.push(e);
231
+ }
232
+ try {
233
+ const binding = require("@oxfmt/linux-x64-gnu");
234
+ const bindingPackageVersion = require("@oxfmt/linux-x64-gnu/package.json").version;
235
+ if (bindingPackageVersion !== "0.9.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.9.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
236
+ return binding;
237
+ } catch (e) {
238
+ loadErrors.push(e);
239
+ }
240
+ }
241
+ else if (process.arch === "arm64") if (isMusl()) {
242
+ try {
243
+ return require("./oxfmt.linux-arm64-musl.node");
244
+ } catch (e) {
245
+ loadErrors.push(e);
246
+ }
247
+ try {
248
+ const binding = require("@oxfmt/linux-arm64-musl");
249
+ const bindingPackageVersion = require("@oxfmt/linux-arm64-musl/package.json").version;
250
+ if (bindingPackageVersion !== "0.9.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.9.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
251
+ return binding;
252
+ } catch (e) {
253
+ loadErrors.push(e);
254
+ }
255
+ } else {
256
+ try {
257
+ return require("./oxfmt.linux-arm64-gnu.node");
258
+ } catch (e) {
259
+ loadErrors.push(e);
260
+ }
261
+ try {
262
+ const binding = require("@oxfmt/linux-arm64-gnu");
263
+ const bindingPackageVersion = require("@oxfmt/linux-arm64-gnu/package.json").version;
264
+ if (bindingPackageVersion !== "0.9.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.9.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
265
+ return binding;
266
+ } catch (e) {
267
+ loadErrors.push(e);
268
+ }
269
+ }
270
+ else if (process.arch === "arm") if (isMusl()) {
271
+ try {
272
+ return require("./oxfmt.linux-arm-musleabihf.node");
273
+ } catch (e) {
274
+ loadErrors.push(e);
275
+ }
276
+ try {
277
+ const binding = require("@oxfmt/linux-arm-musleabihf");
278
+ const bindingPackageVersion = require("@oxfmt/linux-arm-musleabihf/package.json").version;
279
+ if (bindingPackageVersion !== "0.9.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.9.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
280
+ return binding;
281
+ } catch (e) {
282
+ loadErrors.push(e);
283
+ }
284
+ } else {
285
+ try {
286
+ return require("./oxfmt.linux-arm-gnueabihf.node");
287
+ } catch (e) {
288
+ loadErrors.push(e);
289
+ }
290
+ try {
291
+ const binding = require("@oxfmt/linux-arm-gnueabihf");
292
+ const bindingPackageVersion = require("@oxfmt/linux-arm-gnueabihf/package.json").version;
293
+ if (bindingPackageVersion !== "0.9.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.9.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
294
+ return binding;
295
+ } catch (e) {
296
+ loadErrors.push(e);
297
+ }
298
+ }
299
+ else if (process.arch === "loong64") if (isMusl()) {
300
+ try {
301
+ return require("./oxfmt.linux-loong64-musl.node");
302
+ } catch (e) {
303
+ loadErrors.push(e);
304
+ }
305
+ try {
306
+ const binding = require("@oxfmt/linux-loong64-musl");
307
+ const bindingPackageVersion = require("@oxfmt/linux-loong64-musl/package.json").version;
308
+ if (bindingPackageVersion !== "0.9.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.9.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
309
+ return binding;
310
+ } catch (e) {
311
+ loadErrors.push(e);
312
+ }
313
+ } else {
314
+ try {
315
+ return require("./oxfmt.linux-loong64-gnu.node");
316
+ } catch (e) {
317
+ loadErrors.push(e);
318
+ }
319
+ try {
320
+ const binding = require("@oxfmt/linux-loong64-gnu");
321
+ const bindingPackageVersion = require("@oxfmt/linux-loong64-gnu/package.json").version;
322
+ if (bindingPackageVersion !== "0.9.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.9.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
323
+ return binding;
324
+ } catch (e) {
325
+ loadErrors.push(e);
326
+ }
327
+ }
328
+ else if (process.arch === "riscv64") if (isMusl()) {
329
+ try {
330
+ return require("./oxfmt.linux-riscv64-musl.node");
331
+ } catch (e) {
332
+ loadErrors.push(e);
333
+ }
334
+ try {
335
+ const binding = require("@oxfmt/linux-riscv64-musl");
336
+ const bindingPackageVersion = require("@oxfmt/linux-riscv64-musl/package.json").version;
337
+ if (bindingPackageVersion !== "0.9.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.9.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
338
+ return binding;
339
+ } catch (e) {
340
+ loadErrors.push(e);
341
+ }
342
+ } else {
343
+ try {
344
+ return require("./oxfmt.linux-riscv64-gnu.node");
345
+ } catch (e) {
346
+ loadErrors.push(e);
347
+ }
348
+ try {
349
+ const binding = require("@oxfmt/linux-riscv64-gnu");
350
+ const bindingPackageVersion = require("@oxfmt/linux-riscv64-gnu/package.json").version;
351
+ if (bindingPackageVersion !== "0.9.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.9.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
352
+ return binding;
353
+ } catch (e) {
354
+ loadErrors.push(e);
355
+ }
356
+ }
357
+ else if (process.arch === "ppc64") {
358
+ try {
359
+ return require("./oxfmt.linux-ppc64-gnu.node");
360
+ } catch (e) {
361
+ loadErrors.push(e);
362
+ }
363
+ try {
364
+ const binding = require("@oxfmt/linux-ppc64-gnu");
365
+ const bindingPackageVersion = require("@oxfmt/linux-ppc64-gnu/package.json").version;
366
+ if (bindingPackageVersion !== "0.9.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.9.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
367
+ return binding;
368
+ } catch (e) {
369
+ loadErrors.push(e);
370
+ }
371
+ } else if (process.arch === "s390x") {
372
+ try {
373
+ return require("./oxfmt.linux-s390x-gnu.node");
374
+ } catch (e) {
375
+ loadErrors.push(e);
376
+ }
377
+ try {
378
+ const binding = require("@oxfmt/linux-s390x-gnu");
379
+ const bindingPackageVersion = require("@oxfmt/linux-s390x-gnu/package.json").version;
380
+ if (bindingPackageVersion !== "0.9.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.9.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
381
+ return binding;
382
+ } catch (e) {
383
+ loadErrors.push(e);
384
+ }
385
+ } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Linux: ${process.arch}`));
386
+ else if (process.platform === "openharmony") if (process.arch === "arm64") {
387
+ try {
388
+ return require("./oxfmt.openharmony-arm64.node");
389
+ } catch (e) {
390
+ loadErrors.push(e);
391
+ }
392
+ try {
393
+ const binding = require("@oxfmt/openharmony-arm64");
394
+ const bindingPackageVersion = require("@oxfmt/openharmony-arm64/package.json").version;
395
+ if (bindingPackageVersion !== "0.9.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.9.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
396
+ return binding;
397
+ } catch (e) {
398
+ loadErrors.push(e);
399
+ }
400
+ } else if (process.arch === "x64") {
401
+ try {
402
+ return require("./oxfmt.openharmony-x64.node");
403
+ } catch (e) {
404
+ loadErrors.push(e);
405
+ }
406
+ try {
407
+ const binding = require("@oxfmt/openharmony-x64");
408
+ const bindingPackageVersion = require("@oxfmt/openharmony-x64/package.json").version;
409
+ if (bindingPackageVersion !== "0.9.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.9.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
410
+ return binding;
411
+ } catch (e) {
412
+ loadErrors.push(e);
413
+ }
414
+ } else if (process.arch === "arm") {
415
+ try {
416
+ return require("./oxfmt.openharmony-arm.node");
417
+ } catch (e) {
418
+ loadErrors.push(e);
419
+ }
420
+ try {
421
+ const binding = require("@oxfmt/openharmony-arm");
422
+ const bindingPackageVersion = require("@oxfmt/openharmony-arm/package.json").version;
423
+ if (bindingPackageVersion !== "0.9.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.9.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
424
+ return binding;
425
+ } catch (e) {
426
+ loadErrors.push(e);
427
+ }
428
+ } else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`));
429
+ else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`));
430
+ }
431
+ nativeBinding = requireNative();
432
+ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
433
+ let wasiBinding = null;
434
+ let wasiBindingError = null;
435
+ try {
436
+ wasiBinding = require("./oxfmt.wasi.cjs");
437
+ nativeBinding = wasiBinding;
438
+ } catch (err) {
439
+ if (process.env.NAPI_RS_FORCE_WASI) wasiBindingError = err;
440
+ }
441
+ if (!nativeBinding) try {
442
+ wasiBinding = require("@oxfmt/wasm32-wasi");
443
+ nativeBinding = wasiBinding;
444
+ } catch (err) {
445
+ if (process.env.NAPI_RS_FORCE_WASI) {
446
+ wasiBindingError.cause = err;
447
+ loadErrors.push(err);
448
+ }
449
+ }
450
+ if (process.env.NAPI_RS_FORCE_WASI === "error" && !wasiBinding) {
451
+ const error = /* @__PURE__ */ new Error("WASI binding not found and NAPI_RS_FORCE_WASI is set to error");
452
+ error.cause = wasiBindingError;
453
+ throw error;
454
+ }
455
+ }
456
+ if (!nativeBinding) {
457
+ 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) => {
458
+ cur.cause = err;
459
+ return cur;
460
+ }) });
461
+ throw new Error(`Failed to load native binding`);
462
+ }
463
+ const { format } = nativeBinding;
464
+
465
+ //#endregion
466
+ //#region src-js/embedded.ts
467
+ const TAG_TO_PARSER = {
468
+ css: "css",
469
+ styled: "css",
470
+ gql: "graphql",
471
+ graphql: "graphql",
472
+ html: "html",
473
+ md: "markdown",
474
+ markdown: "markdown"
475
+ };
476
+ /**
477
+ * Format embedded code using Prettier (synchronous).
478
+ * Note: Called from Rust via NAPI ThreadsafeFunction with FnArgs
479
+ * @param tagName - The template tag name (e.g., "css", "gql", "html")
480
+ * @param code - The code to format
481
+ * @returns Formatted code
482
+ */
483
+ function formatEmbeddedCode(tagName, code) {
484
+ const parser = TAG_TO_PARSER[tagName];
485
+ if (!parser) return code;
486
+ try {
487
+ return prettier.format(code, {
488
+ parser,
489
+ printWidth: 80,
490
+ tabWidth: 2,
491
+ semi: true,
492
+ singleQuote: false
493
+ }).trimEnd();
494
+ } catch {
495
+ return code;
496
+ }
497
+ }
498
+
499
+ //#endregion
500
+ export { format as n, formatEmbeddedCode as t };
@@ -0,0 +1,25 @@
1
+ //#region src-js/bindings.d.ts
2
+ /* auto-generated by NAPI-RS */
3
+ /* eslint-disable */
4
+ /**
5
+ * NAPI entry point.
6
+ *
7
+ * JS side passes in:
8
+ * 1. `args`: Command line arguments (process.argv.slice(2))
9
+ * 2. `format_embedded_cb`: Callback to format embedded code in templates
10
+ *
11
+ * Returns `true` if formatting succeeded without errors, `false` otherwise.
12
+ */
13
+ declare function format(args: Array<string>, formatEmbeddedCb: JsFormatEmbeddedCb): Promise<boolean>;
14
+ //#endregion
15
+ //#region src-js/embedded.d.ts
16
+ /**
17
+ * Format embedded code using Prettier (synchronous).
18
+ * Note: Called from Rust via NAPI ThreadsafeFunction with FnArgs
19
+ * @param tagName - The template tag name (e.g., "css", "gql", "html")
20
+ * @param code - The code to format
21
+ * @returns Formatted code
22
+ */
23
+ declare function formatEmbeddedCode(tagName: string, code: string): string;
24
+ //#endregion
25
+ export { format, formatEmbeddedCode };
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ import { n as format, t as formatEmbeddedCode } from "./embedded-CSusLtBX.js";
2
+
3
+ export { format, formatEmbeddedCode };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oxfmt",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "type": "module",
5
5
  "description": "Formatter for the JavaScript Oxidation Compiler",
6
6
  "keywords": [],
@@ -13,28 +13,35 @@
13
13
  "url": "git+https://github.com/oxc-project/oxc",
14
14
  "directory": "npm/oxfmt"
15
15
  },
16
+ "main": "dist/index.js",
16
17
  "bin": {
17
18
  "oxfmt": "bin/oxfmt"
18
19
  },
20
+ "types": "dist/index.d.ts",
19
21
  "funding": {
20
22
  "url": "https://github.com/sponsors/Boshen"
21
23
  },
22
24
  "engines": {
23
25
  "node": "^20.19.0 || >=22.12.0"
24
26
  },
27
+ "dependencies": {
28
+ "prettier": "3.6.2",
29
+ "@prettier/sync": "0.6.1"
30
+ },
25
31
  "files": [
26
32
  "bin/oxfmt",
27
33
  "configuration_schema.json",
34
+ "dist",
28
35
  "README.md"
29
36
  ],
30
37
  "optionalDependencies": {
31
- "@oxfmt/win32-x64": "0.8.0",
32
- "@oxfmt/win32-arm64": "0.8.0",
33
- "@oxfmt/linux-x64-gnu": "0.8.0",
34
- "@oxfmt/linux-arm64-gnu": "0.8.0",
35
- "@oxfmt/linux-x64-musl": "0.8.0",
36
- "@oxfmt/linux-arm64-musl": "0.8.0",
37
- "@oxfmt/darwin-x64": "0.8.0",
38
- "@oxfmt/darwin-arm64": "0.8.0"
38
+ "@oxfmt/win32-x64": "0.10.0",
39
+ "@oxfmt/win32-arm64": "0.10.0",
40
+ "@oxfmt/linux-x64-gnu": "0.10.0",
41
+ "@oxfmt/linux-arm64-gnu": "0.10.0",
42
+ "@oxfmt/linux-x64-musl": "0.10.0",
43
+ "@oxfmt/linux-arm64-musl": "0.10.0",
44
+ "@oxfmt/darwin-x64": "0.10.0",
45
+ "@oxfmt/darwin-arm64": "0.10.0"
39
46
  }
40
47
  }