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