@unified-latex/unified-latex-cli 1.8.2 → 1.8.4

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/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { unified } from "unified";
2
- import { unifiedLatexFromString, parse } from "@unified-latex/unified-latex-util-parse";
2
+ import { parse, unifiedLatexFromString } from "@unified-latex/unified-latex-util-parse";
3
3
  import { unifiedLatexStringCompiler } from "@unified-latex/unified-latex-util-to-string";
4
4
  import process from "node:process";
5
5
  import stream from "node:stream";
@@ -15,7 +15,7 @@ import minimist from "minimist";
15
15
  import json5 from "json5";
16
16
  import { fault } from "fault";
17
17
  import { lints } from "@unified-latex/unified-latex-lint";
18
- import { newcommandMacroToName, newcommandMacroToSpec, newcommandMacroToSubstitutionAst, listNewcommands, expandMacros, expandMacrosExcludingDefinitions } from "@unified-latex/unified-latex-util-macros";
18
+ import { expandMacros, expandMacrosExcludingDefinitions, listNewcommands, newcommandMacroToName, newcommandMacroToSpec, newcommandMacroToSubstitutionAst } from "@unified-latex/unified-latex-util-macros";
19
19
  import { listPackages } from "@unified-latex/unified-latex-util-packages";
20
20
  import { printRaw } from "@unified-latex/unified-latex-util-print-raw";
21
21
  import { attachMacroArgs } from "@unified-latex/unified-latex-util-arguments";
@@ -23,776 +23,815 @@ import rehypeStringify from "rehype-stringify";
23
23
  import Prettier from "prettier";
24
24
  import remarkStringify from "remark-stringify";
25
25
  import fs from "node:fs";
26
- const processLatexViaUnified = (options2) => {
27
- return unified().use(
28
- unifiedLatexFromString,
29
- Object.assign({ environments: {}, macros: {} }, options2)
30
- ).use(
31
- unifiedLatexStringCompiler,
32
- Object.assign({ pretty: true, forceNewlineEnding: true }, options2)
33
- );
26
+ //#region libs/unified-latex.ts
27
+ /**
28
+ * Use `unified()` to a string to an `Ast.Ast` and then pretty-print it.
29
+ */
30
+ var processLatexViaUnified = (options) => {
31
+ return unified().use(unifiedLatexFromString, Object.assign({
32
+ environments: {},
33
+ macros: {}
34
+ }, options)).use(unifiedLatexStringCompiler, Object.assign({
35
+ pretty: true,
36
+ forceNewlineEnding: true
37
+ }, options));
34
38
  };
35
- const availableLints = Object.fromEntries(
36
- Object.values(lints).map((lint) => [
37
- lint.name.replace(/^unified-latex-lint:/, ""),
38
- lint
39
- ])
40
- );
41
- const schema = [
42
- {
43
- long: "help",
44
- description: "Output usage information",
45
- short: "h",
46
- type: "boolean",
47
- default: false
48
- },
49
- {
50
- long: "version",
51
- description: "Output version number",
52
- short: "v",
53
- type: "boolean",
54
- default: false
55
- },
56
- {
57
- long: "output",
58
- description: "Specify output location",
59
- short: "o",
60
- value: "[path]"
61
- },
62
- {
63
- long: "rc-path",
64
- description: "Specify configuration file",
65
- short: "r",
66
- type: "string",
67
- value: "<path>"
68
- },
69
- {
70
- long: "ignore-path",
71
- description: "Specify ignore file",
72
- short: "i",
73
- type: "string",
74
- value: "<path>"
75
- },
76
- {
77
- long: "ext",
78
- description: "Specify extensions",
79
- type: "string",
80
- value: "<extensions>"
81
- },
82
- {
83
- long: "lint",
84
- description: `Lint rules to apply. Use multiple times to specify multiple lints. Available rules: ${Object.keys(
85
- availableLints
86
- ).join(", ")}`,
87
- short: "l",
88
- type: "string",
89
- value: "<rule>"
90
- },
91
- {
92
- long: "lint-all",
93
- description: `Apply all available lint rules`,
94
- type: "boolean",
95
- default: false
96
- },
97
- {
98
- long: "fix-all",
99
- description: "Apply fixes for all applied lints",
100
- type: "boolean",
101
- default: false
102
- },
103
- {
104
- long: "watch",
105
- description: "Watch for changes and reprocess",
106
- short: "w",
107
- type: "boolean",
108
- default: false
109
- },
110
- {
111
- long: "macro",
112
- description: "Attach arguments of the specified macro (by default, unrecognized macros are parsed as having no arguments). Accepts a string of the form `\\newcommand{<name>}[<num args>]{<body>}` or a JSON string `{name: <name>, signature: <xparse argument signature>, body: <macro body>}`",
113
- short: "m",
114
- type: "string",
115
- value: "<rule>"
116
- },
117
- {
118
- long: "expand-macro",
119
- description: "Expand the specified macro. Accepts a string of the form `\\newcommand{<name>}[<num args>]{<body>}` or a JSON string `{name: <name>, signature: <xparse argument signature>, body: <macro body>}`",
120
- short: "e",
121
- type: "string",
122
- value: "<rule>"
123
- },
124
- {
125
- long: "expand-document-macro",
126
- description: "Expand the specified macro which is defined in the document. You can use --stats to list all macros defined in the document.",
127
- short: "d",
128
- type: "string",
129
- value: "<name>"
130
- },
131
- {
132
- long: "frail",
133
- description: "Exit with 1 on warnings",
134
- type: "boolean",
135
- default: false
136
- },
137
- {
138
- long: "tree",
139
- description: "Specify input and output as syntax tree",
140
- type: "boolean",
141
- default: false
142
- },
143
- {
144
- long: "report",
145
- description: "Specify reporter",
146
- type: "string",
147
- value: "<reporter>"
148
- },
149
- {
150
- long: "file-path",
151
- description: "Specify path to process as",
152
- type: "string",
153
- value: "<path>"
154
- },
155
- {
156
- long: "ignore-path-resolve-from",
157
- description: "Resolve patterns in `ignore-path` from its directory or cwd",
158
- type: "string",
159
- value: "dir|cwd",
160
- default: "dir"
161
- },
162
- {
163
- long: "ignore-pattern",
164
- description: "Specify ignore patterns",
165
- type: "string",
166
- value: "<globs>"
167
- },
168
- {
169
- long: "silently-ignore",
170
- description: "Do not fail when given ignored files",
171
- type: "boolean"
172
- },
173
- {
174
- long: "tree-in",
175
- description: "Specify input as syntax tree",
176
- type: "boolean"
177
- },
178
- {
179
- long: "tree-out",
180
- description: "Output syntax tree",
181
- type: "boolean"
182
- },
183
- {
184
- long: "inspect",
185
- description: "Output formatted syntax tree",
186
- type: "boolean"
187
- },
188
- {
189
- long: "stats",
190
- description: "Show information about the processed file",
191
- type: "boolean",
192
- default: false
193
- },
194
- {
195
- long: "stats-json",
196
- description: "Show information about the processed file and output the information as JSON",
197
- type: "boolean",
198
- default: false
199
- },
200
- {
201
- long: "html",
202
- description: "Convert the output to HTML. Note, for math to render properly, you will need to add a library like MathJax or KaTeX to your HTMl source; you should also expand/replace any macros not recognized by the converter",
203
- type: "boolean",
204
- default: false
205
- },
206
- {
207
- long: "markdown",
208
- description: "Convert the output to Markdown. Markdown output uses Github-flavored Markdown to support math",
209
- type: "boolean",
210
- default: false
211
- },
212
- {
213
- long: "pretext",
214
- description: "Convert the output to PreTeXt. Note, you should expand/replace any macros not recognized by the converter",
215
- type: "boolean",
216
- default: false
217
- },
218
- {
219
- long: "stdout",
220
- description: "[Don't] write the processed file's contents to stdout",
221
- type: "boolean",
222
- truelike: true
223
- },
224
- {
225
- long: "color",
226
- description: "Specify color in report",
227
- type: "boolean",
228
- default: true
229
- },
230
- {
231
- long: "config",
232
- description: "Search for configuration files",
233
- type: "boolean",
234
- default: true
235
- },
236
- {
237
- long: "ignore",
238
- description: "Search for ignore files",
239
- type: "boolean",
240
- default: true
241
- }
39
+ //#endregion
40
+ //#region libs/lints/index.ts
41
+ var availableLints = Object.fromEntries(Object.values(lints).map((lint) => [lint.name.replace(/^unified-latex-lint:/, ""), lint]));
42
+ //#endregion
43
+ //#region libs/unified-args/schema.ts
44
+ var schema = [
45
+ {
46
+ long: "help",
47
+ description: "Output usage information",
48
+ short: "h",
49
+ type: "boolean",
50
+ default: false
51
+ },
52
+ {
53
+ long: "version",
54
+ description: "Output version number",
55
+ short: "v",
56
+ type: "boolean",
57
+ default: false
58
+ },
59
+ {
60
+ long: "output",
61
+ description: "Specify output location",
62
+ short: "o",
63
+ value: "[path]"
64
+ },
65
+ {
66
+ long: "rc-path",
67
+ description: "Specify configuration file",
68
+ short: "r",
69
+ type: "string",
70
+ value: "<path>"
71
+ },
72
+ {
73
+ long: "ignore-path",
74
+ description: "Specify ignore file",
75
+ short: "i",
76
+ type: "string",
77
+ value: "<path>"
78
+ },
79
+ {
80
+ long: "ext",
81
+ description: "Specify extensions",
82
+ type: "string",
83
+ value: "<extensions>"
84
+ },
85
+ {
86
+ long: "lint",
87
+ description: `Lint rules to apply. Use multiple times to specify multiple lints. Available rules: ${Object.keys(availableLints).join(", ")}`,
88
+ short: "l",
89
+ type: "string",
90
+ value: "<rule>"
91
+ },
92
+ {
93
+ long: "lint-all",
94
+ description: `Apply all available lint rules`,
95
+ type: "boolean",
96
+ default: false
97
+ },
98
+ {
99
+ long: "fix-all",
100
+ description: "Apply fixes for all applied lints",
101
+ type: "boolean",
102
+ default: false
103
+ },
104
+ {
105
+ long: "watch",
106
+ description: "Watch for changes and reprocess",
107
+ short: "w",
108
+ type: "boolean",
109
+ default: false
110
+ },
111
+ {
112
+ long: "macro",
113
+ description: "Attach arguments of the specified macro (by default, unrecognized macros are parsed as having no arguments). Accepts a string of the form `\\newcommand{<name>}[<num args>]{<body>}` or a JSON string `{name: <name>, signature: <xparse argument signature>, body: <macro body>}`",
114
+ short: "m",
115
+ type: "string",
116
+ value: "<rule>"
117
+ },
118
+ {
119
+ long: "expand-macro",
120
+ description: "Expand the specified macro. Accepts a string of the form `\\newcommand{<name>}[<num args>]{<body>}` or a JSON string `{name: <name>, signature: <xparse argument signature>, body: <macro body>}`",
121
+ short: "e",
122
+ type: "string",
123
+ value: "<rule>"
124
+ },
125
+ {
126
+ long: "expand-document-macro",
127
+ description: "Expand the specified macro which is defined in the document. You can use --stats to list all macros defined in the document.",
128
+ short: "d",
129
+ type: "string",
130
+ value: "<name>"
131
+ },
132
+ {
133
+ long: "frail",
134
+ description: "Exit with 1 on warnings",
135
+ type: "boolean",
136
+ default: false
137
+ },
138
+ {
139
+ long: "tree",
140
+ description: "Specify input and output as syntax tree",
141
+ type: "boolean",
142
+ default: false
143
+ },
144
+ {
145
+ long: "report",
146
+ description: "Specify reporter",
147
+ type: "string",
148
+ value: "<reporter>"
149
+ },
150
+ {
151
+ long: "file-path",
152
+ description: "Specify path to process as",
153
+ type: "string",
154
+ value: "<path>"
155
+ },
156
+ {
157
+ long: "ignore-path-resolve-from",
158
+ description: "Resolve patterns in `ignore-path` from its directory or cwd",
159
+ type: "string",
160
+ value: "dir|cwd",
161
+ default: "dir"
162
+ },
163
+ {
164
+ long: "ignore-pattern",
165
+ description: "Specify ignore patterns",
166
+ type: "string",
167
+ value: "<globs>"
168
+ },
169
+ {
170
+ long: "silently-ignore",
171
+ description: "Do not fail when given ignored files",
172
+ type: "boolean"
173
+ },
174
+ {
175
+ long: "tree-in",
176
+ description: "Specify input as syntax tree",
177
+ type: "boolean"
178
+ },
179
+ {
180
+ long: "tree-out",
181
+ description: "Output syntax tree",
182
+ type: "boolean"
183
+ },
184
+ {
185
+ long: "inspect",
186
+ description: "Output formatted syntax tree",
187
+ type: "boolean"
188
+ },
189
+ {
190
+ long: "stats",
191
+ description: "Show information about the processed file",
192
+ type: "boolean",
193
+ default: false
194
+ },
195
+ {
196
+ long: "stats-json",
197
+ description: "Show information about the processed file and output the information as JSON",
198
+ type: "boolean",
199
+ default: false
200
+ },
201
+ {
202
+ long: "html",
203
+ description: "Convert the output to HTML. Note, for math to render properly, you will need to add a library like MathJax or KaTeX to your HTMl source; you should also expand/replace any macros not recognized by the converter",
204
+ type: "boolean",
205
+ default: false
206
+ },
207
+ {
208
+ long: "markdown",
209
+ description: "Convert the output to Markdown. Markdown output uses Github-flavored Markdown to support math",
210
+ type: "boolean",
211
+ default: false
212
+ },
213
+ {
214
+ long: "pretext",
215
+ description: "Convert the output to PreTeXt. Note, you should expand/replace any macros not recognized by the converter",
216
+ type: "boolean",
217
+ default: false
218
+ },
219
+ {
220
+ long: "stdout",
221
+ description: "[Don't] write the processed file's contents to stdout",
222
+ type: "boolean",
223
+ truelike: true
224
+ },
225
+ {
226
+ long: "color",
227
+ description: "Specify color in report",
228
+ type: "boolean",
229
+ default: true
230
+ },
231
+ {
232
+ long: "config",
233
+ description: "Search for configuration files",
234
+ type: "boolean",
235
+ default: true
236
+ },
237
+ {
238
+ long: "ignore",
239
+ description: "Search for ignore files",
240
+ type: "boolean",
241
+ default: true
242
+ }
242
243
  ];
244
+ //#endregion
245
+ //#region libs/macros/parse-macro-expansion.ts
246
+ /**
247
+ * Parse a macro specification given on the command line as either a "\newcommand" string
248
+ * or a JSON object specifying `name`, `signature`, and `body`.
249
+ */
243
250
  function parseMacroExpansion(def) {
244
- if (def.startsWith("\\")) {
245
- const macro = parse(def).content[0];
246
- const name = newcommandMacroToName(macro);
247
- if (!name) {
248
- throw new Error(
249
- `Could extract macro definition from "${def}"; expected the macro to be defined via \\newcommand or similar syntax`
250
- );
251
- }
252
- const signature = newcommandMacroToSpec(macro);
253
- const body = newcommandMacroToSubstitutionAst(macro);
254
- return { name, signature, body };
255
- }
256
- const parsedSpec = json5.parse(def);
257
- if (parsedSpec.name == null || parsedSpec.body == null) {
258
- throw new Error(
259
- `Expected a "name" field and a "body" field to be defined on ${def}`
260
- );
261
- }
262
- parsedSpec.signature = parsedSpec.signature || "";
263
- return {
264
- name: parsedSpec.name,
265
- signature: parsedSpec.signature,
266
- body: parse(parsedSpec.body).content
267
- };
251
+ if (def.startsWith("\\")) {
252
+ const macro = parse(def).content[0];
253
+ const name = newcommandMacroToName(macro);
254
+ if (!name) throw new Error(`Could extract macro definition from "${def}"; expected the macro to be defined via \\newcommand or similar syntax`);
255
+ return {
256
+ name,
257
+ signature: newcommandMacroToSpec(macro),
258
+ body: newcommandMacroToSubstitutionAst(macro)
259
+ };
260
+ }
261
+ const parsedSpec = json5.parse(def);
262
+ if (parsedSpec.name == null || parsedSpec.body == null) throw new Error(`Expected a "name" field and a "body" field to be defined on ${def}`);
263
+ parsedSpec.signature = parsedSpec.signature || "";
264
+ return {
265
+ name: parsedSpec.name,
266
+ signature: parsedSpec.signature,
267
+ body: parse(parsedSpec.body).content
268
+ };
268
269
  }
269
- const own = {}.hasOwnProperty;
270
- const minischema = {
271
- unknown: handleUnknownArgument,
272
- default: {},
273
- alias: {},
274
- string: [],
275
- boolean: []
270
+ //#endregion
271
+ //#region libs/unified-args/options.ts
272
+ var own = {}.hasOwnProperty;
273
+ /**
274
+ * Schema for `minimist`.
275
+ */
276
+ var minischema = {
277
+ unknown: handleUnknownArgument,
278
+ default: {},
279
+ alias: {},
280
+ string: [],
281
+ boolean: []
276
282
  };
277
- let index = -1;
278
- while (++index < schema.length) {
279
- addEach(schema[index]);
280
- }
283
+ var index = -1;
284
+ while (++index < schema.length) addEach(schema[index]);
285
+ /**
286
+ * Parse CLI options.
287
+ */
281
288
  function options(flags, configuration) {
282
- const extension = configuration.extensions[0];
283
- const name = configuration.name;
284
- const config = toCamelCase(minimist(flags, minischema));
285
- let index2 = -1;
286
- while (++index2 < schema.length) {
287
- const option = schema[index2];
288
- if (option.type === "string" && config[option.long] === "") {
289
- throw fault("Missing value:%s", inspect(option).join(" "));
290
- }
291
- }
292
- const ext = commaSeparated(config.ext);
293
- const report = reporter(config.report);
294
- const help = [
295
- inspectAll(schema),
296
- "",
297
- "Examples:",
298
- "",
299
- " # Process `input." + extension + "`",
300
- " $ " + name + " input." + extension + " -o output." + extension,
301
- "",
302
- " # Pipe",
303
- " $ " + name + " < input." + extension + " > output." + extension,
304
- "",
305
- " # Rewrite all applicable files",
306
- " $ " + name + " . -o",
307
- "",
308
- " # Lint files and display the lint output (but not the processed file)",
309
- " $ " + name + " . --lint-all --no-stdout"
310
- ].join("\n");
311
- const settings = parseSettings(config.setting);
312
- if (config.html && config.statsJson) {
313
- throw new Error(
314
- "Both --html and --stats-json were specified; only one may be used at a time."
315
- );
316
- }
317
- return {
318
- helpMessage: help,
319
- cwd: configuration.cwd,
320
- processor: configuration.processor,
321
- help: config.help,
322
- version: config.version,
323
- // XXX I have no idea why `minimist` is not assigning unknown arguments to "_"
324
- // but it appears unknown arguments are being assigned to "" instead...
325
- files: config._ || config[""],
326
- filePath: config.filePath,
327
- watch: config.watch,
328
- extensions: ext.length === 0 ? configuration.extensions : ext,
329
- output: config.output,
330
- out: config.stdout,
331
- tree: config.tree,
332
- treeIn: config.treeIn,
333
- treeOut: config.treeOut,
334
- inspect: config.inspect,
335
- rcName: configuration.rcName,
336
- packageField: configuration.packageField,
337
- rcPath: config.rcPath,
338
- detectConfig: config.config,
339
- settings,
340
- ignoreName: configuration.ignoreName,
341
- ignorePath: config.ignorePath,
342
- ignorePathResolveFrom: config.ignorePathResolveFrom,
343
- ignorePatterns: commaSeparated(config.ignorePattern),
344
- silentlyIgnore: config.silentlyIgnore,
345
- detectIgnore: config.ignore,
346
- pluginPrefix: configuration.pluginPrefix,
347
- plugins: [],
348
- lints: normalizeLints(config.lint, config),
349
- reporter: report[0],
350
- reporterOptions: report[1],
351
- color: config.color,
352
- silent: config.silent,
353
- quiet: config.quiet,
354
- frail: config.frail,
355
- stats: config.stats,
356
- statsJson: config.statsJson,
357
- expandMacro: normalizeToArray(config.expandMacro).map(
358
- parseMacroExpansion
359
- ),
360
- expandDocumentMacro: normalizeToArray(
361
- config.expandDocumentMacro
362
- ),
363
- macro: normalizeToArray(config.macro).map(
364
- parseMacroExpansion
365
- ),
366
- html: config.html,
367
- markdown: config.markdown,
368
- pretext: config.pretext
369
- };
289
+ const extension = configuration.extensions[0];
290
+ const name = configuration.name;
291
+ const config = toCamelCase(minimist(flags, minischema));
292
+ let index = -1;
293
+ while (++index < schema.length) {
294
+ const option = schema[index];
295
+ if (option.type === "string" && config[option.long] === "") throw fault("Missing value:%s", inspect(option).join(" "));
296
+ }
297
+ const ext = commaSeparated(config.ext);
298
+ const report = reporter(config.report);
299
+ const help = [
300
+ inspectAll(schema),
301
+ "",
302
+ "Examples:",
303
+ "",
304
+ " # Process `input." + extension + "`",
305
+ " $ " + name + " input." + extension + " -o output." + extension,
306
+ "",
307
+ " # Pipe",
308
+ " $ " + name + " < input." + extension + " > output." + extension,
309
+ "",
310
+ " # Rewrite all applicable files",
311
+ " $ " + name + " . -o",
312
+ "",
313
+ " # Lint files and display the lint output (but not the processed file)",
314
+ " $ " + name + " . --lint-all --no-stdout"
315
+ ].join("\n");
316
+ const settings = parseSettings(config.setting);
317
+ if (config.html && config.statsJson) throw new Error("Both --html and --stats-json were specified; only one may be used at a time.");
318
+ return {
319
+ helpMessage: help,
320
+ cwd: configuration.cwd,
321
+ processor: configuration.processor,
322
+ help: config.help,
323
+ version: config.version,
324
+ files: config._ || config[""],
325
+ filePath: config.filePath,
326
+ watch: config.watch,
327
+ extensions: ext.length === 0 ? configuration.extensions : ext,
328
+ output: config.output,
329
+ out: config.stdout,
330
+ tree: config.tree,
331
+ treeIn: config.treeIn,
332
+ treeOut: config.treeOut,
333
+ inspect: config.inspect,
334
+ rcName: configuration.rcName,
335
+ packageField: configuration.packageField,
336
+ rcPath: config.rcPath,
337
+ detectConfig: config.config,
338
+ settings,
339
+ ignoreName: configuration.ignoreName,
340
+ ignorePath: config.ignorePath,
341
+ ignorePathResolveFrom: config.ignorePathResolveFrom,
342
+ ignorePatterns: commaSeparated(config.ignorePattern),
343
+ silentlyIgnore: config.silentlyIgnore,
344
+ detectIgnore: config.ignore,
345
+ pluginPrefix: configuration.pluginPrefix,
346
+ plugins: [],
347
+ lints: normalizeLints(config.lint, config),
348
+ reporter: report[0],
349
+ reporterOptions: report[1],
350
+ color: config.color,
351
+ silent: config.silent,
352
+ quiet: config.quiet,
353
+ frail: config.frail,
354
+ stats: config.stats,
355
+ statsJson: config.statsJson,
356
+ expandMacro: normalizeToArray(config.expandMacro).map(parseMacroExpansion),
357
+ expandDocumentMacro: normalizeToArray(config.expandDocumentMacro),
358
+ macro: normalizeToArray(config.macro).map(parseMacroExpansion),
359
+ html: config.html,
360
+ markdown: config.markdown,
361
+ pretext: config.pretext
362
+ };
370
363
  }
371
364
  function addEach(option) {
372
- const value = option.default;
373
- minischema.default[option.long] = value === void 0 ? null : value;
374
- if (option.type && option.type in minischema) {
375
- minischema[option.type].push(option.long);
376
- }
377
- if (option.short) {
378
- minischema.alias[option.short] = option.long;
379
- }
365
+ const value = option.default;
366
+ minischema.default[option.long] = value === void 0 ? null : value;
367
+ if (option.type && option.type in minischema) minischema[option.type].push(option.long);
368
+ if (option.short) minischema.alias[option.short] = option.long;
380
369
  }
370
+ /**
371
+ * Parse `extensions`.
372
+ */
381
373
  function commaSeparated(value) {
382
- return normalizeToArray(value).flatMap((d) => splitOnComma(d));
374
+ return normalizeToArray(value).flatMap((d) => splitOnComma(d));
383
375
  }
376
+ /**
377
+ * Normalize the specified lints
378
+ */
384
379
  function normalizeLints(value, config) {
385
- const normalized = normalizeToArray(value).map(splitOnEquals);
386
- validateLintNames(normalized);
387
- if (config.lintAll) {
388
- normalized.push(...Object.keys(availableLints).map((v) => [v]));
389
- }
390
- const result = Object.fromEntries(
391
- normalized.map((value2) => {
392
- let params = value2[1] ? parseConfig(value2[1], {}) : void 0;
393
- if (config.fixAll) {
394
- if (params) {
395
- Object.assign(params, { fix: true });
396
- } else {
397
- params = { fix: true };
398
- }
399
- }
400
- return [value2[0], params];
401
- })
402
- );
403
- return result;
380
+ const normalized = normalizeToArray(value).map(splitOnEquals);
381
+ validateLintNames(normalized);
382
+ if (config.lintAll) normalized.push(...Object.keys(availableLints).map((v) => [v]));
383
+ return Object.fromEntries(normalized.map((value) => {
384
+ let params = value[1] ? parseConfig(value[1], {}) : void 0;
385
+ if (config.fixAll) if (params) Object.assign(params, { fix: true });
386
+ else params = { fix: true };
387
+ return [value[0], params];
388
+ }));
404
389
  }
390
+ /**
391
+ * Parse `reporter`: only one is accepted.
392
+ */
405
393
  function reporter(value) {
406
- const all = normalizeToArray(value).map(splitOnEquals).map((value2) => [
407
- value2[0],
408
- value2[1] ? parseConfig(value2[1], {}) : void 0
409
- ]);
410
- return all[all.length - 1] || [];
394
+ const all = normalizeToArray(value).map(splitOnEquals).map((value) => [value[0], value[1] ? parseConfig(value[1], {}) : void 0]);
395
+ return all[all.length - 1] || [];
411
396
  }
397
+ /**
398
+ * Parse `settings`.
399
+ */
412
400
  function parseSettings(value) {
413
- const normalized = normalizeToArray(value);
414
- const cache = {};
415
- for (const value2 of normalized) {
416
- parseConfig(value2, cache);
417
- }
418
- return cache;
401
+ const normalized = normalizeToArray(value);
402
+ const cache = {};
403
+ for (const value of normalized) parseConfig(value, cache);
404
+ return cache;
419
405
  }
406
+ /**
407
+ * Parse configuration.
408
+ */
420
409
  function parseConfig(value, cache) {
421
- let flags;
422
- let flag;
423
- try {
424
- flags = toCamelCase(parseJSON(value));
425
- } catch (error) {
426
- const exception = error;
427
- throw fault(
428
- "Cannot parse `%s` as JSON: %s",
429
- value,
430
- // Fix position
431
- exception.message.replace(/at(?= position)/, "around")
432
- );
433
- }
434
- for (flag in flags) {
435
- if (own.call(flags, flag)) {
436
- cache[flag] = flags[flag];
437
- }
438
- }
439
- return cache;
410
+ let flags;
411
+ let flag;
412
+ try {
413
+ flags = toCamelCase(parseJSON(value));
414
+ } catch (error) {
415
+ throw fault("Cannot parse `%s` as JSON: %s", value, error.message.replace(/at(?= position)/, "around"));
416
+ }
417
+ for (flag in flags) if (own.call(flags, flag)) cache[flag] = flags[flag];
418
+ return cache;
440
419
  }
441
- function validateLintNames(lints2) {
442
- for (const lint of lints2) {
443
- const name = lint[0];
444
- if (!availableLints[name]) {
445
- const known = Object.keys(availableLints);
446
- throw fault(
447
- "Unknown lint rule `%s`, available rules are:\n%s",
448
- name,
449
- " " + known.join("\n ")
450
- );
451
- }
452
- }
453
- return true;
420
+ /**
421
+ * Handle an unknown flag.
422
+ */
423
+ function validateLintNames(lints) {
424
+ for (const lint of lints) {
425
+ const name = lint[0];
426
+ if (!availableLints[name]) throw fault("Unknown lint rule `%s`, available rules are:\n%s", name, " " + Object.keys(availableLints).join("\n "));
427
+ }
428
+ return true;
454
429
  }
430
+ /**
431
+ * Handle an unknown flag.
432
+ */
455
433
  function handleUnknownArgument(flag) {
456
- if (flag.charAt(0) === "-") {
457
- if (flag.charAt(1) === "-") {
458
- throw fault(
459
- "Unknown option `%s`, expected:\n%s",
460
- flag,
461
- inspectAll(schema)
462
- );
463
- }
464
- const found = flag.slice(1).split("");
465
- const known = schema.filter((d) => d.short);
466
- const knownKeys = new Set(known.map((d) => d.short));
467
- let index2 = -1;
468
- while (++index2 < found.length) {
469
- const key = found[index2];
470
- if (!knownKeys.has(key)) {
471
- throw fault(
472
- "Unknown short option `-%s`, expected:\n%s",
473
- key,
474
- inspectAll(known)
475
- );
476
- }
477
- }
478
- }
479
- return true;
434
+ if (flag.charAt(0) === "-") {
435
+ if (flag.charAt(1) === "-") throw fault("Unknown option `%s`, expected:\n%s", flag, inspectAll(schema));
436
+ const found = flag.slice(1).split("");
437
+ const known = schema.filter((d) => d.short);
438
+ const knownKeys = new Set(known.map((d) => d.short));
439
+ let index = -1;
440
+ while (++index < found.length) {
441
+ const key = found[index];
442
+ if (!knownKeys.has(key)) throw fault("Unknown short option `-%s`, expected:\n%s", key, inspectAll(known));
443
+ }
444
+ }
445
+ return true;
480
446
  }
481
- function inspectAll(options2) {
482
- return table(options2.map((d) => inspect(d)));
447
+ /**
448
+ * Inspect all `options`.
449
+ */
450
+ function inspectAll(options) {
451
+ return table(options.map((d) => inspect(d)));
483
452
  }
453
+ /**
454
+ * Inspect one `option`.
455
+ */
484
456
  function inspect(option) {
485
- let description = option.description;
486
- let long = option.long;
487
- if (option.default === true || option.truelike) {
488
- description += " (on by default)";
489
- long = "[no-]" + long;
490
- }
491
- return [
492
- "",
493
- option.short ? "-" + option.short : "",
494
- "--" + long + (option.value ? " " + option.value : ""),
495
- description
496
- ];
457
+ let description = option.description;
458
+ let long = option.long;
459
+ if (option.default === true || option.truelike) {
460
+ description += " (on by default)";
461
+ long = "[no-]" + long;
462
+ }
463
+ return [
464
+ "",
465
+ option.short ? "-" + option.short : "",
466
+ "--" + long + (option.value ? " " + option.value : ""),
467
+ description
468
+ ];
497
469
  }
470
+ /**
471
+ * Normalize `value`.
472
+ */
498
473
  function normalizeToArray(value) {
499
- if (!value) {
500
- return [];
501
- }
502
- if (typeof value === "string") {
503
- return [value];
504
- }
505
- return value;
474
+ if (!value) return [];
475
+ if (typeof value === "string") return [value];
476
+ return value;
506
477
  }
507
478
  function splitOnEquals(value) {
508
- return value.split("=");
479
+ return value.split("=");
509
480
  }
510
481
  function splitOnComma(value) {
511
- return value.split(",");
482
+ return value.split(",");
512
483
  }
484
+ /**
485
+ * Transform the keys on an object to camel-case, recursively.
486
+ */
513
487
  function toCamelCase(object) {
514
- const result = {};
515
- let key;
516
- for (key in object) {
517
- if (own.call(object, key)) {
518
- let value = object[key];
519
- if (value && typeof value === "object" && !Array.isArray(value)) {
520
- value = toCamelCase(value);
521
- }
522
- result[camelcase(key)] = value;
523
- }
524
- }
525
- return result;
488
+ const result = {};
489
+ let key;
490
+ for (key in object) if (own.call(object, key)) {
491
+ let value = object[key];
492
+ if (value && typeof value === "object" && !Array.isArray(value)) value = toCamelCase(value);
493
+ result[camelcase(key)] = value;
494
+ }
495
+ return result;
526
496
  }
497
+ /**
498
+ * Parse a (lazy?) JSON config.
499
+ */
527
500
  function parseJSON(value) {
528
- return json5.parse("{" + value + "}");
501
+ return json5.parse("{" + value + "}");
529
502
  }
503
+ //#endregion
504
+ //#region libs/stats/enclosing-position.ts
505
+ /**
506
+ * Find the smallest `position` object that contains all `nodes`.
507
+ */
530
508
  function enclosingPosition(nodes) {
531
- var _a, _b, _c, _d;
532
- let start = { line: 1, column: 1, offset: 0 };
533
- let end = { line: 1, column: 1, offset: 0 };
534
- for (const node of nodes) {
535
- if (Number((_a = node.position) == null ? void 0 : _a.start.offset) < Number(start.offset)) {
536
- start = (_b = node.position) == null ? void 0 : _b.start;
537
- }
538
- if (Number((_c = node.position) == null ? void 0 : _c.end.offset) > Number(end.offset)) {
539
- end = (_d = node.position) == null ? void 0 : _d.end;
540
- }
541
- }
542
- return { start, end };
509
+ let start = {
510
+ line: 1,
511
+ column: 1,
512
+ offset: 0
513
+ };
514
+ let end = {
515
+ line: 1,
516
+ column: 1,
517
+ offset: 0
518
+ };
519
+ for (const node of nodes) {
520
+ var _node$position, _node$position3;
521
+ if (Number((_node$position = node.position) === null || _node$position === void 0 ? void 0 : _node$position.start.offset) < Number(start.offset)) {
522
+ var _node$position2;
523
+ start = (_node$position2 = node.position) === null || _node$position2 === void 0 ? void 0 : _node$position2.start;
524
+ }
525
+ if (Number((_node$position3 = node.position) === null || _node$position3 === void 0 ? void 0 : _node$position3.end.offset) > Number(end.offset)) {
526
+ var _node$position4;
527
+ end = (_node$position4 = node.position) === null || _node$position4 === void 0 ? void 0 : _node$position4.end;
528
+ }
529
+ }
530
+ return {
531
+ start,
532
+ end
533
+ };
543
534
  }
544
- const statsPlugin = function() {
545
- return (tree, file) => {
546
- const packages = listPackages(tree);
547
- const packageNames = packages.map((s) => printRaw(s));
548
- if (packages.length > 0) {
549
- file.info(
550
- `Found ${packages.length} imported packages: ${packageNames.join(", ")}`
551
- );
552
- }
553
- const newcommands = listNewcommands(tree);
554
- if (newcommands.length > 0) {
555
- file.info(
556
- `Found ${newcommands.length} defined commands: ${newcommands.map((c) => `\\${c.name}`).join(", ")}`,
557
- enclosingPosition(newcommands.map((c) => c.definition))
558
- );
559
- }
560
- };
535
+ //#endregion
536
+ //#region libs/stats/index.ts
537
+ /**
538
+ * Plugin that reports statistics on the contents of LaTeX files.
539
+ */
540
+ var statsPlugin = function() {
541
+ return (tree, file) => {
542
+ const packages = listPackages(tree);
543
+ const packageNames = packages.map((s) => printRaw(s));
544
+ if (packages.length > 0) file.info(`Found ${packages.length} imported packages: ${packageNames.join(", ")}`);
545
+ const newcommands = listNewcommands(tree);
546
+ if (newcommands.length > 0) file.info(`Found ${newcommands.length} defined commands: ${newcommands.map((c) => `\\${c.name}`).join(", ")}`, enclosingPosition(newcommands.map((c) => c.definition)));
547
+ };
561
548
  };
562
- const statsJsonPlugin = function() {
563
- this.Compiler = (tree, file) => {
564
- file.extname = ".json";
565
- file.basename += "-stats";
566
- const packages = listPackages(tree).map((s) => printRaw(s));
567
- const newcommands = listNewcommands(tree).map((c) => ({
568
- name: c.name,
569
- signature: c.signature,
570
- body: printRaw(c.body),
571
- definition: printRaw(c.definition)
572
- }));
573
- return JSON.stringify({ packages, newcommands }, null, 4) + "\n";
574
- };
549
+ /**
550
+ * Plugin that reports statistics on the contents of LaTeX files and replaces the file output with a JSON
551
+ * representation of the statistics.
552
+ */
553
+ var statsJsonPlugin = function() {
554
+ this.Compiler = (tree, file) => {
555
+ file.extname = ".json";
556
+ file.basename += "-stats";
557
+ const packages = listPackages(tree).map((s) => printRaw(s));
558
+ const newcommands = listNewcommands(tree).map((c) => ({
559
+ name: c.name,
560
+ signature: c.signature,
561
+ body: printRaw(c.body),
562
+ definition: printRaw(c.definition)
563
+ }));
564
+ return JSON.stringify({
565
+ packages,
566
+ newcommands
567
+ }, null, 4) + "\n";
568
+ };
575
569
  };
576
- const expandMacrosPlugin = function(options2) {
577
- const { macros = [] } = options2 || {};
578
- const macroInfo = Object.fromEntries(
579
- macros.map((m) => [m.name, { signature: m.signature }])
580
- );
581
- return (tree) => {
582
- attachMacroArgs(tree, macroInfo);
583
- expandMacros(tree, macros);
584
- };
570
+ //#endregion
571
+ //#region libs/macros/expand-macros-plugin.ts
572
+ /**
573
+ * Plugin that expands the specified macros.
574
+ */
575
+ var expandMacrosPlugin = function(options) {
576
+ const { macros = [] } = options || {};
577
+ const macroInfo = Object.fromEntries(macros.map((m) => [m.name, { signature: m.signature }]));
578
+ return (tree) => {
579
+ attachMacroArgs(tree, macroInfo);
580
+ expandMacros(tree, macros);
581
+ };
585
582
  };
586
- const attachMacroArgsPlugin = function(options2) {
587
- const { macros = [] } = options2 || {};
588
- const macroInfo = Object.fromEntries(
589
- macros.map((m) => [m.name, { signature: m.signature }])
590
- );
591
- return (tree) => {
592
- attachMacroArgs(tree, macroInfo);
593
- };
583
+ //#endregion
584
+ //#region libs/macros/attach-macro-args-plugin.ts
585
+ /**
586
+ * Plugin that attaches the arguments of the specified macros.
587
+ */
588
+ var attachMacroArgsPlugin = function(options) {
589
+ const { macros = [] } = options || {};
590
+ const macroInfo = Object.fromEntries(macros.map((m) => [m.name, { signature: m.signature }]));
591
+ return (tree) => {
592
+ attachMacroArgs(tree, macroInfo);
593
+ };
594
594
  };
595
- const prettyPrintHtmlPlugin = function() {
596
- const processor = unified().use(rehypeStringify);
597
- this.Compiler = (tree, file) => {
598
- file.extname = ".html";
599
- const html = processor.stringify(tree, file);
600
- try {
601
- return Prettier.format(html, { parser: "html", useTabs: true });
602
- } catch {
603
- }
604
- return html;
605
- };
595
+ //#endregion
596
+ //#region libs/html/format.ts
597
+ /**
598
+ * Plugin that pretty-prints HTML.
599
+ */
600
+ var prettyPrintHtmlPlugin = function() {
601
+ const processor = unified().use(rehypeStringify);
602
+ this.Compiler = (tree, file) => {
603
+ file.extname = ".html";
604
+ const html = processor.stringify(tree, file);
605
+ try {
606
+ return Prettier.format(html, {
607
+ parser: "html",
608
+ useTabs: true
609
+ });
610
+ } catch {}
611
+ return html;
612
+ };
606
613
  };
607
- const expandDocumentMacrosPlugin = function(options2) {
608
- const { macros = [] } = options2 || {};
609
- const macrosSet = new Set(macros);
610
- return (tree) => {
611
- const newcommands = listNewcommands(tree);
612
- const macros2 = newcommands.filter((s) => macrosSet.has(s.name));
613
- const macroInfo = Object.fromEntries(
614
- macros2.map((m) => [m.name, { signature: m.signature }])
615
- );
616
- attachMacroArgs(tree, macroInfo);
617
- expandMacrosExcludingDefinitions(tree, macros2);
618
- };
614
+ //#endregion
615
+ //#region libs/macros/expand-document-macros-plugin.ts
616
+ /**
617
+ * Plugin that expands the specified macros by name. These macros must be defined in the document via
618
+ * `\newcommand...` or equivalent.
619
+ */
620
+ var expandDocumentMacrosPlugin = function(options) {
621
+ const { macros = [] } = options || {};
622
+ const macrosSet = new Set(macros);
623
+ return (tree) => {
624
+ const macros = listNewcommands(tree).filter((s) => macrosSet.has(s.name));
625
+ attachMacroArgs(tree, Object.fromEntries(macros.map((m) => [m.name, { signature: m.signature }])));
626
+ expandMacrosExcludingDefinitions(tree, macros);
627
+ };
619
628
  };
620
- const ttyStream = Object.assign(new stream.Readable(), { isTTY: true });
621
- let exitStatus = 0;
629
+ //#endregion
630
+ //#region libs/unified-args/index.ts
631
+ var ttyStream = Object.assign(new stream.Readable(), { isTTY: true });
632
+ var exitStatus = 0;
622
633
  process.on("exit", onexit);
623
634
  process.on("uncaughtException", fail);
635
+ /**
636
+ * Start the CLI.
637
+ *
638
+ * @param {Options} cliConfig
639
+ */
624
640
  function unifiedArgs(cliConfig) {
625
- let config;
626
- let watcher;
627
- let output;
628
- try {
629
- config = options(process.argv.slice(2), cliConfig);
630
- } catch (error) {
631
- const exception = error;
632
- return fail(exception, true);
633
- }
634
- const processorOptions = { macros: {}, environments: {} };
635
- const originalProcessor = config.processor;
636
- config.processor = () => originalProcessor(processorOptions);
637
- if (config.help) {
638
- process.stdout.write(
639
- [
640
- "Usage: " + cliConfig.name + " [options] [path | glob ...]",
641
- "",
642
- " " + cliConfig.description,
643
- "",
644
- "Options:",
645
- "",
646
- config.helpMessage,
647
- ""
648
- ].join("\n"),
649
- noop
650
- );
651
- return;
652
- }
653
- if (config.version) {
654
- process.stdout.write(cliConfig.version + "\n", noop);
655
- return;
656
- }
657
- if (config.watch) {
658
- output = config.output;
659
- config.streamIn = ttyStream;
660
- config.out = false;
661
- process.stderr.write(
662
- chalk.bold("Watching...") + " (press CTRL+C to exit)\n",
663
- noop
664
- );
665
- if (output === true) {
666
- config.output = false;
667
- process.stderr.write(
668
- chalk.yellow("Note") + ": Ignoring `--output` until exit.\n",
669
- noop
670
- );
671
- }
672
- }
673
- if (config.lints) {
674
- for (const [lintName, lintArgs] of Object.entries(config.lints)) {
675
- const lint = availableLints[lintName];
676
- if (!lint) {
677
- throw new Error(
678
- `Could not find lint named "${lintName}"; available lints are ${Object.keys(
679
- availableLints
680
- ).join(", ")}`
681
- );
682
- }
683
- config.plugins.push([lint, lintArgs]);
684
- }
685
- }
686
- if (config.stats) {
687
- config.plugins.push([statsPlugin]);
688
- }
689
- if (config.macro.length > 0) {
690
- config.plugins.push([attachMacroArgsPlugin, { macros: config.macro }]);
691
- }
692
- if (config.expandMacro.length > 0) {
693
- processorOptions.macros = Object.assign(
694
- processorOptions.macros || {},
695
- Object.fromEntries(
696
- config.expandMacro.map((m) => [
697
- m.name,
698
- { signature: m.signature }
699
- ])
700
- )
701
- );
702
- config.plugins.push([
703
- expandMacrosPlugin,
704
- { macros: config.expandMacro }
705
- ]);
706
- }
707
- if (config.expandDocumentMacro.length > 0) {
708
- config.plugins.push([
709
- expandDocumentMacrosPlugin,
710
- { macros: config.expandDocumentMacro }
711
- ]);
712
- }
713
- if (config.statsJson) {
714
- config.plugins.push([statsJsonPlugin]);
715
- }
716
- if (config.html) {
717
- config.plugins.push([unifiedLatexToHast]);
718
- config.plugins.push([prettyPrintHtmlPlugin]);
719
- }
720
- if (config.markdown) {
721
- config.plugins.push([unifiedLatexToMdast]);
722
- config.plugins.push([remarkStringify]);
723
- }
724
- if (config.pretext) {
725
- config.plugins.push([unifiedLatexToPretext]);
726
- config.plugins.push([prettyPrintHtmlPlugin]);
727
- }
728
- const done = function done2(error, code, context) {
729
- if (error) {
730
- clean();
731
- fail(error);
732
- } else {
733
- exitStatus = code || 0;
734
- if (config.watch && !watcher && context) {
735
- subscribe(context);
736
- }
737
- }
738
- };
739
- function clean() {
740
- if (watcher) {
741
- watcher.close();
742
- watcher = void 0;
743
- }
744
- }
745
- function subscribe(context) {
746
- var _a;
747
- watcher = chokidar.watch(((_a = context.fileSet) == null ? void 0 : _a.origins) || [], {
748
- cwd: config.cwd != null ? "" + config.cwd : config.cwd,
749
- ignoreInitial: true
750
- }).on("error", done).on("change", (filePath) => {
751
- config.files = [filePath];
752
- engine(config, done);
753
- });
754
- process.on("SIGINT", onsigint);
755
- function onsigint() {
756
- process.stderr.write("\n", noop);
757
- clean();
758
- if (output === true) {
759
- config.output = output;
760
- config.watch = false;
761
- engine(config, done);
762
- }
763
- }
764
- }
765
- engine(config, done);
641
+ let config;
642
+ let watcher;
643
+ let output;
644
+ try {
645
+ config = options(process.argv.slice(2), cliConfig);
646
+ } catch (error) {
647
+ return fail(error, true);
648
+ }
649
+ const processorOptions = {
650
+ macros: {},
651
+ environments: {}
652
+ };
653
+ const originalProcessor = config.processor;
654
+ config.processor = () => originalProcessor(processorOptions);
655
+ if (config.help) {
656
+ process.stdout.write([
657
+ "Usage: " + cliConfig.name + " [options] [path | glob ...]",
658
+ "",
659
+ " " + cliConfig.description,
660
+ "",
661
+ "Options:",
662
+ "",
663
+ config.helpMessage,
664
+ ""
665
+ ].join("\n"), noop);
666
+ return;
667
+ }
668
+ if (config.version) {
669
+ process.stdout.write(cliConfig.version + "\n", noop);
670
+ return;
671
+ }
672
+ if (config.watch) {
673
+ output = config.output;
674
+ config.streamIn = ttyStream;
675
+ config.out = false;
676
+ process.stderr.write(chalk.bold("Watching...") + " (press CTRL+C to exit)\n", noop);
677
+ if (output === true) {
678
+ config.output = false;
679
+ process.stderr.write(chalk.yellow("Note") + ": Ignoring `--output` until exit.\n", noop);
680
+ }
681
+ }
682
+ if (config.lints) for (const [lintName, lintArgs] of Object.entries(config.lints)) {
683
+ const lint = availableLints[lintName];
684
+ if (!lint) throw new Error(`Could not find lint named "${lintName}"; available lints are ${Object.keys(availableLints).join(", ")}`);
685
+ config.plugins.push([lint, lintArgs]);
686
+ }
687
+ if (config.stats) config.plugins.push([statsPlugin]);
688
+ if (config.macro.length > 0) config.plugins.push([attachMacroArgsPlugin, { macros: config.macro }]);
689
+ if (config.expandMacro.length > 0) {
690
+ processorOptions.macros = Object.assign(processorOptions.macros || {}, Object.fromEntries(config.expandMacro.map((m) => [m.name, { signature: m.signature }])));
691
+ config.plugins.push([expandMacrosPlugin, { macros: config.expandMacro }]);
692
+ }
693
+ if (config.expandDocumentMacro.length > 0) config.plugins.push([expandDocumentMacrosPlugin, { macros: config.expandDocumentMacro }]);
694
+ if (config.statsJson) config.plugins.push([statsJsonPlugin]);
695
+ if (config.html) {
696
+ config.plugins.push([unifiedLatexToHast]);
697
+ config.plugins.push([prettyPrintHtmlPlugin]);
698
+ }
699
+ if (config.markdown) {
700
+ config.plugins.push([unifiedLatexToMdast]);
701
+ config.plugins.push([remarkStringify]);
702
+ }
703
+ if (config.pretext) {
704
+ config.plugins.push([unifiedLatexToPretext]);
705
+ config.plugins.push([prettyPrintHtmlPlugin]);
706
+ }
707
+ /**
708
+ * Handle complete run.
709
+ *
710
+ * @type {EngineCallback}
711
+ */
712
+ const done = function done(error, code, context) {
713
+ if (error) {
714
+ clean();
715
+ fail(error);
716
+ } else {
717
+ exitStatus = code || 0;
718
+ if (config.watch && !watcher && context) subscribe(context);
719
+ }
720
+ };
721
+ function clean() {
722
+ if (watcher) {
723
+ watcher.close();
724
+ watcher = void 0;
725
+ }
726
+ }
727
+ /**
728
+ * Subscribe a chokidar watcher to all processed files.
729
+ */
730
+ function subscribe(context) {
731
+ var _context$fileSet;
732
+ watcher = chokidar.watch(((_context$fileSet = context.fileSet) === null || _context$fileSet === void 0 ? void 0 : _context$fileSet.origins) || [], {
733
+ cwd: config.cwd != null ? "" + config.cwd : config.cwd,
734
+ ignoreInitial: true
735
+ }).on("error", done).on("change", (filePath) => {
736
+ config.files = [filePath];
737
+ engine(config, done);
738
+ });
739
+ process.on("SIGINT", onsigint);
740
+ /**
741
+ * Handle a SIGINT.
742
+ */
743
+ function onsigint() {
744
+ process.stderr.write("\n", noop);
745
+ clean();
746
+ if (output === true) {
747
+ config.output = output;
748
+ config.watch = false;
749
+ engine(config, done);
750
+ }
751
+ }
752
+ }
753
+ engine(config, done);
766
754
  }
755
+ /**
756
+ * Print an error, optionally with stack.
757
+ *
758
+ * @param {Error} error
759
+ * @param {boolean} [pretty=false]
760
+ */
767
761
  function fail(error, pretty) {
768
- const message = String((pretty ? error : error.stack) || error);
769
- exitStatus = 1;
770
- process.stderr.write(message.trim() + "\n", noop);
762
+ const message = String((pretty ? error : error.stack) || error);
763
+ exitStatus = 1;
764
+ process.stderr.write(message.trim() + "\n", noop);
771
765
  }
772
766
  function onexit() {
773
- process.exit(exitStatus);
774
- }
775
- function noop() {
767
+ process.exit(exitStatus);
776
768
  }
777
- let version = "unknown (could not read version from package.json)";
769
+ function noop() {}
770
+ //#endregion
771
+ //#region index.ts
772
+ var version = "unknown (could not read version from package.json)";
778
773
  try {
779
- const packageJson = JSON.parse(
780
- fs.readFileSync(new URL("data:application/json;base64,ewogICAgIm5hbWUiOiAiQHVuaWZpZWQtbGF0ZXgvdW5pZmllZC1sYXRleC1jbGkiLAogICAgInZlcnNpb24iOiAiMS44LjIiLAogICAgImRlc2NyaXB0aW9uIjogIkNvbW1hbmQgbGluZSBpbnRlcmZhY2UgdG8gY29tbW9uIHVuaWZpZWQtbGF0ZXggb3B0aW9ucyIsCiAgICAibWFpbiI6ICJkaXN0L2luZGV4LmpzIiwKICAgICJ0eXBlIjogIm1vZHVsZSIsCiAgICAiYmluIjogewogICAgICAgICJ1bmlmaWVkLWxhdGV4IjogIi4vdW5pZmllZC1sYXRleC1jbGkubWpzIgogICAgfSwKICAgICJkZXBlbmRlbmNpZXMiOiB7CiAgICAgICAgIkB0eXBlcy9oYXN0IjogIl4yLjMuOSIsCiAgICAgICAgIkB1bmlmaWVkLWxhdGV4L3VuaWZpZWQtbGF0ZXgtbGludCI6ICJeMS44LjIiLAogICAgICAgICJAdW5pZmllZC1sYXRleC91bmlmaWVkLWxhdGV4LXRvLWhhc3QiOiAiXjEuOC4yIiwKICAgICAgICAiQHVuaWZpZWQtbGF0ZXgvdW5pZmllZC1sYXRleC10by1tZGFzdCI6ICJeMS44LjIiLAogICAgICAgICJAdW5pZmllZC1sYXRleC91bmlmaWVkLWxhdGV4LXRvLXByZXRleHQiOiAiXjEuOC4yIiwKICAgICAgICAiQHVuaWZpZWQtbGF0ZXgvdW5pZmllZC1sYXRleC10eXBlcyI6ICJeMS44LjAiLAogICAgICAgICJAdW5pZmllZC1sYXRleC91bmlmaWVkLWxhdGV4LXV0aWwtYXJndW1lbnRzIjogIl4xLjguMiIsCiAgICAgICAgIkB1bmlmaWVkLWxhdGV4L3VuaWZpZWQtbGF0ZXgtdXRpbC1tYWNyb3MiOiAiXjEuOC4yIiwKICAgICAgICAiQHVuaWZpZWQtbGF0ZXgvdW5pZmllZC1sYXRleC11dGlsLXBhY2thZ2VzIjogIl4xLjguMiIsCiAgICAgICAgIkB1bmlmaWVkLWxhdGV4L3VuaWZpZWQtbGF0ZXgtdXRpbC1wYXJzZSI6ICJeMS44LjIiLAogICAgICAgICJAdW5pZmllZC1sYXRleC91bmlmaWVkLWxhdGV4LXV0aWwtcHJpbnQtcmF3IjogIl4xLjguMCIsCiAgICAgICAgIkB1bmlmaWVkLWxhdGV4L3VuaWZpZWQtbGF0ZXgtdXRpbC10by1zdHJpbmciOiAiXjEuOC4yIiwKICAgICAgICAiY2FtZWxjYXNlIjogIl43LjAuMSIsCiAgICAgICAgImNoYWxrIjogIl41LjIuMCIsCiAgICAgICAgImNob2tpZGFyIjogIl4zLjUuMyIsCiAgICAgICAgImZhdWx0IjogIl4yLjAuMSIsCiAgICAgICAgImhhc3RzY3JpcHQiOiAiXjcuMi4wIiwKICAgICAgICAianNvbjUiOiAiXjIuMi4zIiwKICAgICAgICAibWluaW1pc3QiOiAiXjEuMi43IiwKICAgICAgICAicHJldHRpZXIiOiAiXjIuOC44IiwKICAgICAgICAicmVoeXBlLXN0cmluZ2lmeSI6ICJeOS4wLjQiLAogICAgICAgICJyZW1hcmstc3RyaW5naWZ5IjogIl4xMC4wLjMiLAogICAgICAgICJ0ZXh0LXRhYmxlIjogIl4wLjIuMCIsCiAgICAgICAgInVuaWZpZWQiOiAiXjEwLjEuMiIsCiAgICAgICAgInVuaWZpZWQtZW5naW5lIjogIl4xMC4xLjAiCiAgICB9LAogICAgImZpbGVzIjogWwogICAgICAgICJkaXN0LyoqLyoudHMiLAogICAgICAgICJkaXN0LyoqLyouanMiLAogICAgICAgICJkaXN0LyoqLyoubWFwIiwKICAgICAgICAiZGlzdC8qKi8qLmpzb24iCiAgICBdLAogICAgImV4cG9ydHMiOiB7CiAgICAgICAgIi4iOiB7CiAgICAgICAgICAgICJwcmVidWlsdCI6ICIuL2Rpc3QvaW5kZXguanMiLAogICAgICAgICAgICAiaW1wb3J0IjogIi4vaW5kZXgudHMiLAogICAgICAgICAgICAicmVxdWlyZSI6ICIuL2Rpc3QvaW5kZXguY2pzIgogICAgICAgIH0sCiAgICAgICAgIi4vKmpzIjogIi4vZGlzdC8qanMiLAogICAgICAgICIuLyoiOiB7CiAgICAgICAgICAgICJwcmVidWlsdCI6ICIuL2Rpc3QvKi5qcyIsCiAgICAgICAgICAgICJpbXBvcnQiOiAiLi8qLnRzIiwKICAgICAgICAgICAgInJlcXVpcmUiOiAiLi9kaXN0LyouY2pzIgogICAgICAgIH0KICAgIH0sCiAgICAic2NyaXB0cyI6IHsKICAgICAgICAiYnVpbGQiOiAibnBtIHJ1biBjbGVhbiAmJiBta2RpcnAgLi9kaXN0ICYmIG5wbSBydW4gY29tcGlsZSIsCiAgICAgICAgImNsZWFuIjogInJpbXJhZiAuL2Rpc3QiLAogICAgICAgICJjb21waWxlIjogIndpcmVpdCIsCiAgICAgICAgImNvbXBpbGU6Y2pzIjogIndpcmVpdCIsCiAgICAgICAgImNvbXBpbGU6ZXNtIjogIndpcmVpdCIsCiAgICAgICAgImNvbXBpbGU6ZXhlY3V0YWJsZSI6ICJlY2hvICcjIS91c3IvYmluL2VudiBub2RlJyA+IGRpc3QvdW5pZmllZC1sYXRleC1jbGkubWpzICYmIGNhdCBkaXN0L2luZGV4LmpzID4+IGRpc3QvdW5pZmllZC1sYXRleC1jbGkubWpzIiwKICAgICAgICAicGFja2FnZSI6ICJub2RlIC4uLy4uL3NjcmlwdHMvbWFrZS1wYWNrYWdlLm1qcyIsCiAgICAgICAgInB1Ymxpc2giOiAiY2QgZGlzdCAmJiBucG0gcHVibGlzaCIsCiAgICAgICAgInRlc3QiOiAidml0ZXN0IgogICAgfSwKICAgICJ3aXJlaXQiOiB7CiAgICAgICAgImNvbXBpbGUiOiB7CiAgICAgICAgICAgICJjb21tYW5kIjogIm5wbSBydW4gY29tcGlsZTpleGVjdXRhYmxlIiwKICAgICAgICAgICAgImRlcGVuZGVuY2llcyI6IFsKICAgICAgICAgICAgICAgICJjb21waWxlOmNqcyIsCiAgICAgICAgICAgICAgICAiY29tcGlsZTplc20iCiAgICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgICJjb21waWxlOmNqcyI6IHsKICAgICAgICAgICAgImNvbW1hbmQiOiAidml0ZSBidWlsZCAtLW1vZGUgY29tbW9uanMiLAogICAgICAgICAgICAiZmlsZXMiOiBbCiAgICAgICAgICAgICAgICAiaW5kZXgudHMiLAogICAgICAgICAgICAgICAgImxpYnMvKiovKi50cyIsCiAgICAgICAgICAgICAgICAibGlicy8qKi8qLmpzb24iLAogICAgICAgICAgICAgICAgInRzY29uZmlnLmpzb24iLAogICAgICAgICAgICAgICAgInZpdGUuY29uZmlnLnRzIgogICAgICAgICAgICBdLAogICAgICAgICAgICAib3V0cHV0IjogWwogICAgICAgICAgICAgICAgImRpc3QvKiovKi5janMqIgogICAgICAgICAgICBdLAogICAgICAgICAgICAiZGVwZW5kZW5jaWVzIjogWwogICAgICAgICAgICAgICAgImRlcHMiCiAgICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgICJjb21waWxlOmVzbSI6IHsKICAgICAgICAgICAgImNvbW1hbmQiOiAidml0ZSBidWlsZCIsCiAgICAgICAgICAgICJmaWxlcyI6IFsKICAgICAgICAgICAgICAgICJpbmRleC50cyIsCiAgICAgICAgICAgICAgICAibGlicy8qKi8qLnRzIiwKICAgICAgICAgICAgICAgICJsaWJzLyoqLyouanNvbiIsCiAgICAgICAgICAgICAgICAidHNjb25maWcuanNvbiIsCiAgICAgICAgICAgICAgICAidml0ZS5jb25maWcudHMiCiAgICAgICAgICAgIF0sCiAgICAgICAgICAgICJvdXRwdXQiOiBbCiAgICAgICAgICAgICAgICAiZGlzdC8qKi8qLmpzKiIsCiAgICAgICAgICAgICAgICAiZGlzdC8qKi8qLmpzb24iLAogICAgICAgICAgICAgICAgImRpc3QvKiovKi5kLnRzIiwKICAgICAgICAgICAgICAgICJkaXN0LyoqLyoubWQiCiAgICAgICAgICAgIF0sCiAgICAgICAgICAgICJkZXBlbmRlbmNpZXMiOiBbCiAgICAgICAgICAgICAgICAiZGVwcyIKICAgICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgImRlcHMiOiB7CiAgICAgICAgICAgICJkZXBlbmRlbmNpZXMiOiBbCiAgICAgICAgICAgICAgICAiLi4vdW5pZmllZC1sYXRleC1saW50OmNvbXBpbGUiLAogICAgICAgICAgICAgICAgIi4uL3VuaWZpZWQtbGF0ZXgtdG8taGFzdDpjb21waWxlIiwKICAgICAgICAgICAgICAgICIuLi91bmlmaWVkLWxhdGV4LXRvLW1kYXN0OmNvbXBpbGUiLAogICAgICAgICAgICAgICAgIi4uL3VuaWZpZWQtbGF0ZXgtdHlwZXM6Y29tcGlsZSIsCiAgICAgICAgICAgICAgICAiLi4vdW5pZmllZC1sYXRleC11dGlsLWFyZ3VtZW50czpjb21waWxlIiwKICAgICAgICAgICAgICAgICIuLi91bmlmaWVkLWxhdGV4LXV0aWwtbWFjcm9zOmNvbXBpbGUiLAogICAgICAgICAgICAgICAgIi4uL3VuaWZpZWQtbGF0ZXgtdXRpbC1wYWNrYWdlczpjb21waWxlIiwKICAgICAgICAgICAgICAgICIuLi91bmlmaWVkLWxhdGV4LXV0aWwtcGFyc2U6Y29tcGlsZSIsCiAgICAgICAgICAgICAgICAiLi4vdW5pZmllZC1sYXRleC11dGlsLXByaW50LXJhdzpjb21waWxlIiwKICAgICAgICAgICAgICAgICIuLi91bmlmaWVkLWxhdGV4LXV0aWwtdG8tc3RyaW5nOmNvbXBpbGUiCiAgICAgICAgICAgIF0KICAgICAgICB9CiAgICB9LAogICAgInJlcG9zaXRvcnkiOiB7CiAgICAgICAgInR5cGUiOiAiZ2l0IiwKICAgICAgICAidXJsIjogImdpdCtodHRwczovL2dpdGh1Yi5jb20vc2llZmtlbmovdW5pZmllZC1sYXRleC5naXQiCiAgICB9LAogICAgImtleXdvcmRzIjogWwogICAgICAgICJwZWdqcyIsCiAgICAgICAgImxhdGV4IiwKICAgICAgICAicGFyc2VyIiwKICAgICAgICAicHJldHRpZXIiLAogICAgICAgICJ1bmlmaWVkLWxhdGV4IiwKICAgICAgICAidW5pZmllZCIKICAgIF0sCiAgICAiYXV0aG9yIjogIkphc29uIFNpZWZrZW4iLAogICAgImxpY2Vuc2UiOiAiTUlUIiwKICAgICJidWdzIjogewogICAgICAgICJ1cmwiOiAiaHR0cHM6Ly9naXRodWIuY29tL3NpZWZrZW5qL3VuaWZpZWQtbGF0ZXgvaXNzdWVzIgogICAgfSwKICAgICJob21lcGFnZSI6ICJodHRwczovL2dpdGh1Yi5jb20vc2llZmtlbmovdW5pZmllZC1sYXRleCNyZWFkbWUiLAogICAgInByaXZhdGUiOiB0cnVlLAogICAgImRldkRlcGVuZGVuY2llcyI6IHsKICAgICAgICAiQHR5cGVzL2Nyb3NzLXNwYXduIjogIl42LjAuNiIsCiAgICAgICAgImNyb3NzLXNwYXduIjogIl43LjAuMyIsCiAgICAgICAgInNvdXJjZS1tYXAtc3VwcG9ydCI6ICJeMC41LjIxIgogICAgfQp9Cg==", import.meta.url), {
781
- encoding: "utf8"
782
- })
783
- );
784
- version = packageJson.version;
785
- } catch {
786
- }
774
+ version = JSON.parse(fs.readFileSync(new URL("data:application/json;base64,ewogICAgIm5hbWUiOiAiQHVuaWZpZWQtbGF0ZXgvdW5pZmllZC1sYXRleC1jbGkiLAogICAgInZlcnNpb24iOiAiMS44LjQiLAogICAgImRlc2NyaXB0aW9uIjogIkNvbW1hbmQgbGluZSBpbnRlcmZhY2UgdG8gY29tbW9uIHVuaWZpZWQtbGF0ZXggb3B0aW9ucyIsCiAgICAibWFpbiI6ICJkaXN0L2luZGV4LmpzIiwKICAgICJ0eXBlIjogIm1vZHVsZSIsCiAgICAiYmluIjogewogICAgICAgICJ1bmlmaWVkLWxhdGV4IjogIi4vdW5pZmllZC1sYXRleC1jbGkubWpzIgogICAgfSwKICAgICJkZXBlbmRlbmNpZXMiOiB7CiAgICAgICAgIkB0eXBlcy9oYXN0IjogIl4yLjMuOSIsCiAgICAgICAgIkB1bmlmaWVkLWxhdGV4L3VuaWZpZWQtbGF0ZXgtbGludCI6ICJeMS44LjQiLAogICAgICAgICJAdW5pZmllZC1sYXRleC91bmlmaWVkLWxhdGV4LXRvLWhhc3QiOiAiXjEuOC40IiwKICAgICAgICAiQHVuaWZpZWQtbGF0ZXgvdW5pZmllZC1sYXRleC10by1tZGFzdCI6ICJeMS44LjQiLAogICAgICAgICJAdW5pZmllZC1sYXRleC91bmlmaWVkLWxhdGV4LXRvLXByZXRleHQiOiAiXjEuOC40IiwKICAgICAgICAiQHVuaWZpZWQtbGF0ZXgvdW5pZmllZC1sYXRleC10eXBlcyI6ICJeMS44LjQiLAogICAgICAgICJAdW5pZmllZC1sYXRleC91bmlmaWVkLWxhdGV4LXV0aWwtYXJndW1lbnRzIjogIl4xLjguNCIsCiAgICAgICAgIkB1bmlmaWVkLWxhdGV4L3VuaWZpZWQtbGF0ZXgtdXRpbC1tYWNyb3MiOiAiXjEuOC40IiwKICAgICAgICAiQHVuaWZpZWQtbGF0ZXgvdW5pZmllZC1sYXRleC11dGlsLXBhY2thZ2VzIjogIl4xLjguNCIsCiAgICAgICAgIkB1bmlmaWVkLWxhdGV4L3VuaWZpZWQtbGF0ZXgtdXRpbC1wYXJzZSI6ICJeMS44LjQiLAogICAgICAgICJAdW5pZmllZC1sYXRleC91bmlmaWVkLWxhdGV4LXV0aWwtcHJpbnQtcmF3IjogIl4xLjguNCIsCiAgICAgICAgIkB1bmlmaWVkLWxhdGV4L3VuaWZpZWQtbGF0ZXgtdXRpbC10by1zdHJpbmciOiAiXjEuOC40IiwKICAgICAgICAiY2FtZWxjYXNlIjogIl43LjAuMSIsCiAgICAgICAgImNoYWxrIjogIl41LjIuMCIsCiAgICAgICAgImNob2tpZGFyIjogIl4zLjUuMyIsCiAgICAgICAgImZhdWx0IjogIl4yLjAuMSIsCiAgICAgICAgImhhc3RzY3JpcHQiOiAiXjcuMi4wIiwKICAgICAgICAianNvbjUiOiAiXjIuMi4zIiwKICAgICAgICAibWluaW1pc3QiOiAiXjEuMi43IiwKICAgICAgICAicHJldHRpZXIiOiAiXjIuOC44IiwKICAgICAgICAicmVoeXBlLXN0cmluZ2lmeSI6ICJeOS4wLjQiLAogICAgICAgICJyZW1hcmstc3RyaW5naWZ5IjogIl4xMC4wLjMiLAogICAgICAgICJ0ZXh0LXRhYmxlIjogIl4wLjIuMCIsCiAgICAgICAgInVuaWZpZWQiOiAiXjEwLjEuMiIsCiAgICAgICAgInVuaWZpZWQtZW5naW5lIjogIl4xMC4xLjAiCiAgICB9LAogICAgImZpbGVzIjogWwogICAgICAgICJkaXN0LyoqLyoudHMiLAogICAgICAgICJkaXN0LyoqLyouanMiLAogICAgICAgICJkaXN0LyoqLyoubWFwIiwKICAgICAgICAiZGlzdC8qKi8qLmpzb24iCiAgICBdLAogICAgImV4cG9ydHMiOiB7CiAgICAgICAgIi4iOiB7CiAgICAgICAgICAgICJwcmVidWlsdCI6ICIuL2Rpc3QvaW5kZXguanMiLAogICAgICAgICAgICAiaW1wb3J0IjogIi4vaW5kZXgudHMiLAogICAgICAgICAgICAicmVxdWlyZSI6ICIuL2Rpc3QvaW5kZXguY2pzIgogICAgICAgIH0sCiAgICAgICAgIi4vKmpzIjogIi4vZGlzdC8qanMiLAogICAgICAgICIuLyoiOiB7CiAgICAgICAgICAgICJwcmVidWlsdCI6ICIuL2Rpc3QvKi5qcyIsCiAgICAgICAgICAgICJpbXBvcnQiOiAiLi8qLnRzIiwKICAgICAgICAgICAgInJlcXVpcmUiOiAiLi9kaXN0LyouY2pzIgogICAgICAgIH0KICAgIH0sCiAgICAic2NyaXB0cyI6IHsKICAgICAgICAiYnVpbGQiOiAibnBtIHJ1biBjbGVhbiAmJiBta2RpcnAgLi9kaXN0ICYmIG5wbSBydW4gY29tcGlsZSIsCiAgICAgICAgImNsZWFuIjogInJpbXJhZiAuL2Rpc3QiLAogICAgICAgICJjb21waWxlIjogIndpcmVpdCIsCiAgICAgICAgImNvbXBpbGU6Y2pzIjogIndpcmVpdCIsCiAgICAgICAgImNvbXBpbGU6ZXNtIjogIndpcmVpdCIsCiAgICAgICAgImNvbXBpbGU6ZXhlY3V0YWJsZSI6ICJlY2hvICcjIS91c3IvYmluL2VudiBub2RlJyA+IGRpc3QvdW5pZmllZC1sYXRleC1jbGkubWpzICYmIGNhdCBkaXN0L2luZGV4LmpzID4+IGRpc3QvdW5pZmllZC1sYXRleC1jbGkubWpzIiwKICAgICAgICAicGFja2FnZSI6ICJub2RlIC4uLy4uL3NjcmlwdHMvbWFrZS1wYWNrYWdlLm1qcyIsCiAgICAgICAgInB1Ymxpc2giOiAiY2QgZGlzdCAmJiBucG0gcHVibGlzaCIsCiAgICAgICAgInRlc3QiOiAidml0ZXN0IgogICAgfSwKICAgICJ3aXJlaXQiOiB7CiAgICAgICAgImNvbXBpbGUiOiB7CiAgICAgICAgICAgICJjb21tYW5kIjogIm5wbSBydW4gY29tcGlsZTpleGVjdXRhYmxlIiwKICAgICAgICAgICAgImRlcGVuZGVuY2llcyI6IFsKICAgICAgICAgICAgICAgICJjb21waWxlOmNqcyIsCiAgICAgICAgICAgICAgICAiY29tcGlsZTplc20iCiAgICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgICJjb21waWxlOmNqcyI6IHsKICAgICAgICAgICAgImNvbW1hbmQiOiAidml0ZSBidWlsZCAtLW1vZGUgY29tbW9uanMiLAogICAgICAgICAgICAiZmlsZXMiOiBbCiAgICAgICAgICAgICAgICAiaW5kZXgudHMiLAogICAgICAgICAgICAgICAgImxpYnMvKiovKi50cyIsCiAgICAgICAgICAgICAgICAibGlicy8qKi8qLmpzb24iLAogICAgICAgICAgICAgICAgInRzY29uZmlnLmpzb24iLAogICAgICAgICAgICAgICAgInZpdGUuY29uZmlnLnRzIgogICAgICAgICAgICBdLAogICAgICAgICAgICAib3V0cHV0IjogWwogICAgICAgICAgICAgICAgImRpc3QvKiovKi5janMqIgogICAgICAgICAgICBdLAogICAgICAgICAgICAiZGVwZW5kZW5jaWVzIjogWwogICAgICAgICAgICAgICAgImRlcHMiCiAgICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgICJjb21waWxlOmVzbSI6IHsKICAgICAgICAgICAgImNvbW1hbmQiOiAidml0ZSBidWlsZCIsCiAgICAgICAgICAgICJmaWxlcyI6IFsKICAgICAgICAgICAgICAgICJpbmRleC50cyIsCiAgICAgICAgICAgICAgICAibGlicy8qKi8qLnRzIiwKICAgICAgICAgICAgICAgICJsaWJzLyoqLyouanNvbiIsCiAgICAgICAgICAgICAgICAidHNjb25maWcuanNvbiIsCiAgICAgICAgICAgICAgICAidml0ZS5jb25maWcudHMiCiAgICAgICAgICAgIF0sCiAgICAgICAgICAgICJvdXRwdXQiOiBbCiAgICAgICAgICAgICAgICAiZGlzdC8qKi8qLmpzKiIsCiAgICAgICAgICAgICAgICAiZGlzdC8qKi8qLmpzb24iLAogICAgICAgICAgICAgICAgImRpc3QvKiovKi5kLnRzIiwKICAgICAgICAgICAgICAgICJkaXN0LyoqLyoubWQiCiAgICAgICAgICAgIF0sCiAgICAgICAgICAgICJkZXBlbmRlbmNpZXMiOiBbCiAgICAgICAgICAgICAgICAiZGVwcyIKICAgICAgICAgICAgXQogICAgICAgIH0sCiAgICAgICAgImRlcHMiOiB7CiAgICAgICAgICAgICJkZXBlbmRlbmNpZXMiOiBbCiAgICAgICAgICAgICAgICAiLi4vdW5pZmllZC1sYXRleC1saW50OmNvbXBpbGUiLAogICAgICAgICAgICAgICAgIi4uL3VuaWZpZWQtbGF0ZXgtdG8taGFzdDpjb21waWxlIiwKICAgICAgICAgICAgICAgICIuLi91bmlmaWVkLWxhdGV4LXRvLW1kYXN0OmNvbXBpbGUiLAogICAgICAgICAgICAgICAgIi4uL3VuaWZpZWQtbGF0ZXgtdHlwZXM6Y29tcGlsZSIsCiAgICAgICAgICAgICAgICAiLi4vdW5pZmllZC1sYXRleC11dGlsLWFyZ3VtZW50czpjb21waWxlIiwKICAgICAgICAgICAgICAgICIuLi91bmlmaWVkLWxhdGV4LXV0aWwtbWFjcm9zOmNvbXBpbGUiLAogICAgICAgICAgICAgICAgIi4uL3VuaWZpZWQtbGF0ZXgtdXRpbC1wYWNrYWdlczpjb21waWxlIiwKICAgICAgICAgICAgICAgICIuLi91bmlmaWVkLWxhdGV4LXV0aWwtcGFyc2U6Y29tcGlsZSIsCiAgICAgICAgICAgICAgICAiLi4vdW5pZmllZC1sYXRleC11dGlsLXByaW50LXJhdzpjb21waWxlIiwKICAgICAgICAgICAgICAgICIuLi91bmlmaWVkLWxhdGV4LXV0aWwtdG8tc3RyaW5nOmNvbXBpbGUiCiAgICAgICAgICAgIF0KICAgICAgICB9CiAgICB9LAogICAgInJlcG9zaXRvcnkiOiB7CiAgICAgICAgInR5cGUiOiAiZ2l0IiwKICAgICAgICAidXJsIjogImdpdCtodHRwczovL2dpdGh1Yi5jb20vc2llZmtlbmovdW5pZmllZC1sYXRleC5naXQiCiAgICB9LAogICAgImtleXdvcmRzIjogWwogICAgICAgICJwZWdqcyIsCiAgICAgICAgImxhdGV4IiwKICAgICAgICAicGFyc2VyIiwKICAgICAgICAicHJldHRpZXIiLAogICAgICAgICJ1bmlmaWVkLWxhdGV4IiwKICAgICAgICAidW5pZmllZCIKICAgIF0sCiAgICAiYXV0aG9yIjogIkphc29uIFNpZWZrZW4iLAogICAgImxpY2Vuc2UiOiAiTUlUIiwKICAgICJidWdzIjogewogICAgICAgICJ1cmwiOiAiaHR0cHM6Ly9naXRodWIuY29tL3NpZWZrZW5qL3VuaWZpZWQtbGF0ZXgvaXNzdWVzIgogICAgfSwKICAgICJob21lcGFnZSI6ICJodHRwczovL2dpdGh1Yi5jb20vc2llZmtlbmovdW5pZmllZC1sYXRleCNyZWFkbWUiLAogICAgInByaXZhdGUiOiB0cnVlLAogICAgImRldkRlcGVuZGVuY2llcyI6IHsKICAgICAgICAiQHR5cGVzL2Nyb3NzLXNwYXduIjogIl42LjAuNiIsCiAgICAgICAgImNyb3NzLXNwYXduIjogIl43LjAuMyIsCiAgICAgICAgInNvdXJjZS1tYXAtc3VwcG9ydCI6ICJeMC41LjIxIgogICAgfQp9Cg==", "" + import.meta.url), { encoding: "utf8" })).version;
775
+ } catch {}
787
776
  unifiedArgs({
788
- processor: processLatexViaUnified,
789
- name: "unified-latex",
790
- description: "LaTeX processor powered by unified-latex",
791
- version,
792
- extensions: ["tex"],
793
- ignoreName: ".unifiedlatexignore",
794
- packageField: "unifiedLatexConfig",
795
- rcName: ".unifiedlatexrc",
796
- pluginPrefix: "@unified-latex/"
777
+ processor: processLatexViaUnified,
778
+ name: "unified-latex",
779
+ description: "LaTeX processor powered by unified-latex",
780
+ version,
781
+ extensions: ["tex"],
782
+ ignoreName: ".unifiedlatexignore",
783
+ packageField: "unifiedLatexConfig",
784
+ rcName: ".unifiedlatexrc",
785
+ pluginPrefix: "@unified-latex/"
797
786
  });
798
- //# sourceMappingURL=index.js.map
787
+ /**
788
+ * ## What is this?
789
+ *
790
+ * Command line interface to common `unified-latex` functions.
791
+ *
792
+ * ## When should I use this?
793
+ *
794
+ * If you want to reformat, process, or gather statistic on LaTeX files from the command line.
795
+ *
796
+ * ## Examples
797
+ *
798
+ * Reformat and pretty-print a file
799
+ *
800
+ * ```bash
801
+ * unified-latex input.tex -o output.tex
802
+ * ```
803
+ *
804
+ * List all commands defined via `\newcommand` and friends (and hide the file output).
805
+ *
806
+ * ```bash
807
+ * unified-latex input.tex --no-stdout --stats
808
+ * ```
809
+ *
810
+ * Expand the definition of the macro `\foo{...}`, which takes one argument.
811
+ *
812
+ * ```bash
813
+ * unified-latex input.tex -e "\\newcommand{foo}[1]{FOO(#1)}"
814
+ * ```
815
+ *
816
+ * View the parsed AST.
817
+ *
818
+ * ```bash
819
+ * unified-latex input.tex --inspect
820
+ * ```
821
+ *
822
+ * Convert the file to HTML. (Note, you will need to include and configure a library like _MathJax_ or _KaTeX_ to render
823
+ * any math in the resulting HTML. Warnings are provided for macros that aren't recognized by the converter.)
824
+ *
825
+ * ```bash
826
+ * unified-latex input.tex -o output.html --html
827
+ * ```
828
+ *
829
+ * Lint all tex files in the current directory and watch for changes.
830
+ *
831
+ * ```bash
832
+ * unified-latex . --no-stdout --lint-all --watch
833
+ * ```
834
+ */
835
+ //#endregion
836
+
837
+ //# sourceMappingURL=index.js.map