@swipt/cli 0.1.0-nightly.78 → 0.1.0-nightly.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/availability.d.ts +5 -0
  2. package/dist/availability.js +349 -0
  3. package/dist/availability.js.map +1 -0
  4. package/dist/client.d.ts +25 -0
  5. package/dist/client.js +248 -0
  6. package/dist/client.js.map +1 -0
  7. package/dist/connection.d.ts +24 -0
  8. package/dist/connection.js +293 -0
  9. package/dist/connection.js.map +1 -0
  10. package/dist/coredevice.d.ts +22 -0
  11. package/dist/coredevice.js +329 -0
  12. package/dist/coredevice.js.map +1 -0
  13. package/dist/device.d.ts +130 -0
  14. package/dist/device.js +539 -0
  15. package/dist/device.js.map +1 -0
  16. package/dist/i18n.d.ts +2 -0
  17. package/dist/i18n.js +57 -0
  18. package/dist/i18n.js.map +1 -0
  19. package/dist/ignore.d.ts +8 -0
  20. package/dist/ignore.js +112 -0
  21. package/dist/ignore.js.map +1 -0
  22. package/dist/metro.d.ts +10 -0
  23. package/dist/metro.js +349 -0
  24. package/dist/metro.js.map +1 -0
  25. package/dist/output.d.ts +20 -0
  26. package/dist/output.js +116 -0
  27. package/dist/output.js.map +1 -0
  28. package/dist/project.d.ts +18 -0
  29. package/dist/project.js +696 -0
  30. package/dist/project.js.map +1 -0
  31. package/dist/proto/common_pb.js +34 -0
  32. package/dist/proto/common_pb.js.map +1 -0
  33. package/dist/proto/logs_pb.js +15 -0
  34. package/dist/proto/logs_pb.js.map +1 -0
  35. package/dist/proto/repl_pb.js +15 -0
  36. package/dist/proto/repl_pb.js.map +1 -0
  37. package/dist/proto/swiplets_pb.js +28 -0
  38. package/dist/proto/swiplets_pb.js.map +1 -0
  39. package/dist/proto/system_pb.js +15 -0
  40. package/dist/proto/system_pb.js.map +1 -0
  41. package/dist/sideload.d.ts +17 -0
  42. package/dist/sideload.js +1098 -0
  43. package/dist/sideload.js.map +1 -0
  44. package/dist/swipt.d.ts +1 -0
  45. package/dist/swipt.js +631 -0
  46. package/dist/swipt.js.map +1 -0
  47. package/dist/version.d.ts +2 -0
  48. package/dist/version.js +15 -0
  49. package/dist/version.js.map +1 -0
  50. package/package.json +21 -7
  51. package/availability.mjs +0 -642
  52. package/client.mjs +0 -375
  53. package/connection.mjs +0 -450
  54. package/coredevice.mjs +0 -464
  55. package/device.mjs +0 -837
  56. package/i18n.mjs +0 -71
  57. package/ignore.mjs +0 -149
  58. package/metro.mjs +0 -432
  59. package/output.mjs +0 -177
  60. package/project.mjs +0 -1013
  61. package/proto/common_pb.js +0 -98
  62. package/proto/logs_pb.js +0 -34
  63. package/proto/repl_pb.js +0 -55
  64. package/proto/swiplets_pb.js +0 -179
  65. package/proto/system_pb.js +0 -27
  66. package/sideload.mjs +0 -1696
  67. package/swipt.mjs +0 -726
  68. package/version.mjs +0 -16
package/dist/swipt.js ADDED
@@ -0,0 +1,631 @@
1
+ #!/usr/bin/env node
2
+ import { Code, RpcError, UsageError } from "./client.js";
3
+ import { add, list, remove, withToken } from "./connection.js";
4
+ import { api, call, deployProject, develop, install, isProgram, list as list$1, logs, printVersion, remove as remove$1, replData, reset, run, serviceWatch, setService, show, stop, swipletData } from "./device.js";
5
+ import { tr } from "./i18n.js";
6
+ import { FalseResult } from "./output.js";
7
+ import { buildProject, createCommand, sourceCommand } from "./project.js";
8
+ import { install as install$1, setup, uninstall, update } from "./sideload.js";
9
+ import path from "node:path";
10
+ import { parseArgs } from "node:util";
11
+ // src/swipt.ts
12
+ const globalOptions = { help: {
13
+ type: "boolean",
14
+ short: "h",
15
+ help: tr("help")
16
+ } };
17
+ const deviceOption = { device: {
18
+ type: "string",
19
+ short: "d",
20
+ value: "NAME|URL",
21
+ help: tr("the device to use")
22
+ } };
23
+ const sideloadOptions = {
24
+ device: {
25
+ type: "string",
26
+ short: "d",
27
+ value: "NAME|UDID",
28
+ help: tr("the device to use")
29
+ },
30
+ team: {
31
+ type: "string",
32
+ value: "ID",
33
+ help: tr("team ID, required if more than one")
34
+ }
35
+ };
36
+ const passcodeOptions = (help) => ({
37
+ passcode: {
38
+ type: "string",
39
+ value: "CODE",
40
+ help
41
+ },
42
+ "passcode-type": {
43
+ type: "string",
44
+ value: "TYPE",
45
+ help: tr("pin (4 or 6 digits, default), numeric or alphanumeric")
46
+ }
47
+ });
48
+ const nightlyOption = { nightly: {
49
+ type: "boolean",
50
+ help: tr("use nightly build")
51
+ } };
52
+ const setupStepOptions = {
53
+ "no-setup-pair": {
54
+ type: "boolean",
55
+ help: tr("do not pair Swipt")
56
+ },
57
+ "no-setup-api": {
58
+ type: "boolean",
59
+ help: tr("do not publish the API to the local network")
60
+ }
61
+ };
62
+ const setupOptions = {
63
+ "no-setup": {
64
+ type: "boolean",
65
+ help: tr("do not pair Swipt, trust its developer or publish its API")
66
+ },
67
+ ...setupStepOptions
68
+ };
69
+ const durationUnits = {
70
+ ns: 1e-6,
71
+ us: .001,
72
+ µs: .001,
73
+ ms: 1,
74
+ s: 1e3,
75
+ m: 6e4,
76
+ h: 36e5
77
+ };
78
+ function parseDuration(text, option) {
79
+ if (text === void 0) return 0;
80
+ if (/^-?\d+$/.test(text) && Number(text) === 0) return 0;
81
+ let total = 0;
82
+ let rest = text;
83
+ while (rest !== "") {
84
+ const match = /^(\d+(?:\.\d*)?|\.\d+)(ns|us|µs|ms|s|m|h)/.exec(rest);
85
+ if (!match) throw new UsageError(tr("invalid argument {value} for {option}: it is a duration such as 30s or 1m30s", {
86
+ value: JSON.stringify(text),
87
+ option
88
+ }));
89
+ total += Number(match[1]) * durationUnits[match[2]];
90
+ rest = rest.slice(match[0].length);
91
+ }
92
+ return total;
93
+ }
94
+ function parseCount(text, option) {
95
+ if (text === void 0) return;
96
+ if (!/^\d+$/.test(text) || Number(text) > 4294967295) throw new UsageError(tr("invalid argument {value} for {option}: it is a number", {
97
+ value: JSON.stringify(text),
98
+ option
99
+ }));
100
+ return Number(text);
101
+ }
102
+ const dataCommands = (operand, files) => {
103
+ const before = operand === "" ? 0 : 1;
104
+ return {
105
+ name: "data",
106
+ short: operand === "" ? tr("Manage the files in the data directory of the REPL") : tr("Manage the files in the data directory of a swiplet"),
107
+ commands: [
108
+ {
109
+ name: "list",
110
+ use: `list ${operand}[PATH]`,
111
+ short: tr("List data files"),
112
+ args: [before, before + 1],
113
+ options: { recursive: {
114
+ type: "boolean",
115
+ help: tr("include subdirectories")
116
+ } },
117
+ run: files.list
118
+ },
119
+ {
120
+ name: "read",
121
+ use: `read ${operand}PATH`,
122
+ short: tr("Read a data file or directory"),
123
+ args: [before + 1, before + 1],
124
+ options: { output: {
125
+ type: "string",
126
+ value: "PATH",
127
+ help: tr("destination")
128
+ } },
129
+ run: files.read
130
+ },
131
+ {
132
+ name: "write",
133
+ use: `write ${operand}PATH [FILE | -]`,
134
+ short: tr("Write a data file"),
135
+ args: [before + 1, before + 2],
136
+ run: files.write
137
+ },
138
+ {
139
+ name: "remove",
140
+ use: `remove ${operand}PATH`,
141
+ short: tr("Remove a data file"),
142
+ args: [before + 1, before + 1],
143
+ options: { recursive: {
144
+ type: "boolean",
145
+ help: tr("include directory contents")
146
+ } },
147
+ run: files.remove
148
+ },
149
+ {
150
+ name: "clear",
151
+ use: `clear ${operand}`.trimEnd(),
152
+ short: tr("Remove every data file, keeping the data directory"),
153
+ args: [before, before],
154
+ run: files.clear
155
+ }
156
+ ]
157
+ };
158
+ };
159
+ const commands = [
160
+ {
161
+ name: "project",
162
+ short: tr("Make, build and deploy swiplet projects"),
163
+ commands: [
164
+ {
165
+ name: "create",
166
+ use: "create DIRECTORY",
167
+ short: tr("Make a swiplet project in a new or empty directory"),
168
+ args: [1, 1],
169
+ run: ({ args }) => createCommand(args[0])
170
+ },
171
+ {
172
+ name: "build",
173
+ use: "build [PROJECT]",
174
+ short: tr("Bundle the project into dist/<swiplet.id>.swiplet"),
175
+ args: [0, 1],
176
+ run: async ({ args }) => {
177
+ const { archive } = await buildProject(path.resolve(args[0] ?? "."));
178
+ console.log(path.relative(process.cwd(), archive));
179
+ }
180
+ },
181
+ {
182
+ name: "source",
183
+ use: "source [SWIPLET...]",
184
+ short: tr("Collect the built swiplets into dist/ with a swiplets.json"),
185
+ args: [0, Infinity],
186
+ run: ({ args }) => sourceCommand(process.cwd(), args)
187
+ },
188
+ {
189
+ name: "deploy",
190
+ use: "deploy [PROJECT]",
191
+ short: tr("Build the project and install it on the device"),
192
+ args: [0, 1],
193
+ options: deviceOption,
194
+ run: deployProject
195
+ },
196
+ {
197
+ name: "develop",
198
+ use: "develop [PROJECT]",
199
+ short: tr("Build, install and follow a swiplet project as it changes"),
200
+ args: [0, 1],
201
+ options: {
202
+ ...deviceOption,
203
+ "no-logs": {
204
+ type: "boolean",
205
+ help: tr("without logs")
206
+ }
207
+ },
208
+ run: develop
209
+ }
210
+ ]
211
+ },
212
+ {
213
+ name: "device",
214
+ short: tr("Manage the devices and read their logs"),
215
+ commands: [
216
+ {
217
+ name: "list",
218
+ short: tr("List the devices, adding the ones found on the local network"),
219
+ args: [0, 0],
220
+ run: list
221
+ },
222
+ {
223
+ name: "add",
224
+ use: "add URL",
225
+ short: tr("Add a device by its URL; needed when it is remote or requires a token"),
226
+ args: [1, 1],
227
+ run: add
228
+ },
229
+ {
230
+ name: "remove",
231
+ use: "remove NAME",
232
+ short: tr("Forget a device"),
233
+ args: [1, 1],
234
+ run: remove
235
+ },
236
+ {
237
+ name: "stop",
238
+ short: tr("Stop the Swipt server"),
239
+ args: [0, 0],
240
+ options: deviceOption,
241
+ run: stop
242
+ },
243
+ {
244
+ name: "logs",
245
+ short: tr("Print the logs"),
246
+ args: [0, 0],
247
+ options: {
248
+ ...deviceOption,
249
+ follow: {
250
+ type: "boolean",
251
+ help: tr("follow new entries")
252
+ },
253
+ tail: {
254
+ type: "string",
255
+ value: "COUNT",
256
+ help: tr("number of past entries (default 100)")
257
+ },
258
+ since: {
259
+ type: "string",
260
+ value: "DURATION",
261
+ help: tr("maximum age")
262
+ },
263
+ level: {
264
+ type: "string",
265
+ value: "LEVEL",
266
+ help: tr("minimum level (default info)")
267
+ },
268
+ swiplet: {
269
+ type: "string",
270
+ value: "ID",
271
+ help: tr("swiplet ID")
272
+ }
273
+ },
274
+ parse: (options) => ({
275
+ ...options,
276
+ tail: parseCount(options.tail, "--tail"),
277
+ since: parseDuration(options.since, "--since"),
278
+ level: options.level ?? "info"
279
+ }),
280
+ run: logs
281
+ }
282
+ ]
283
+ },
284
+ {
285
+ name: "swiplet",
286
+ short: tr("Manage the swiplets on the device"),
287
+ options: deviceOption,
288
+ commands: [
289
+ {
290
+ name: "list",
291
+ short: tr("List the swiplets"),
292
+ args: [0, 0],
293
+ run: list$1
294
+ },
295
+ {
296
+ name: "show",
297
+ use: "show ID",
298
+ short: tr("Show a swiplet"),
299
+ args: [1, 1],
300
+ run: show
301
+ },
302
+ {
303
+ name: "install",
304
+ use: "install ARCHIVE",
305
+ short: tr("Install a swiplet archive"),
306
+ args: [1, 1],
307
+ run: install
308
+ },
309
+ {
310
+ name: "remove",
311
+ use: "remove ID",
312
+ short: tr("Remove a swiplet"),
313
+ args: [1, 1],
314
+ run: remove$1
315
+ },
316
+ {
317
+ name: "call",
318
+ use: "call ID ACTION",
319
+ short: tr("Call a swiplet action"),
320
+ args: [2, 2],
321
+ options: { input: {
322
+ type: "string",
323
+ value: "JSON",
324
+ help: tr("input JSON, @FILE or -")
325
+ } },
326
+ run: call
327
+ },
328
+ {
329
+ name: "service",
330
+ short: tr("Manage swiplet services"),
331
+ commands: [
332
+ {
333
+ name: "enable",
334
+ use: "enable ID",
335
+ short: tr("Turn on a swiplet service"),
336
+ args: [1, 1],
337
+ options: { watch: {
338
+ type: "boolean",
339
+ help: tr("watch the state")
340
+ } },
341
+ run: setService(true)
342
+ },
343
+ {
344
+ name: "disable",
345
+ use: "disable ID",
346
+ short: tr("Turn off a swiplet service"),
347
+ args: [1, 1],
348
+ options: { watch: {
349
+ type: "boolean",
350
+ help: tr("watch the state")
351
+ } },
352
+ run: setService(false)
353
+ },
354
+ {
355
+ name: "watch",
356
+ use: "watch [ID]",
357
+ short: tr("Watch swiplet services"),
358
+ args: [0, 1],
359
+ run: serviceWatch
360
+ }
361
+ ]
362
+ },
363
+ dataCommands("ID ", swipletData)
364
+ ]
365
+ },
366
+ {
367
+ name: "repl",
368
+ short: tr("Run JavaScript in the REPL session on the device"),
369
+ options: deviceOption,
370
+ commands: [
371
+ {
372
+ name: "run",
373
+ use: "run [CODE | FILE [ARG...] | - [ARG...]]",
374
+ short: tr("Run a JavaScript expression or program on the device"),
375
+ description: [tr("The first argument is FILE when it names an existing file and CODE otherwise; options go before it."), tr("CODE is an expression whose value is printed. FILE, or standard input given as - or no argument, is a program, and only its console output is printed.")],
376
+ args: [0, Infinity],
377
+ passthrough: isProgram,
378
+ options: { output: {
379
+ type: "string",
380
+ value: "DIRECTORY",
381
+ help: tr("image directory (default: a new temporary directory)")
382
+ } },
383
+ run
384
+ },
385
+ {
386
+ name: "reset",
387
+ short: tr("Reset the session"),
388
+ args: [0, 0],
389
+ run: reset
390
+ },
391
+ {
392
+ name: "api",
393
+ short: tr("Print the TypeScript declarations of the globals and modules"),
394
+ args: [0, 0],
395
+ run: api
396
+ },
397
+ dataCommands("", replData)
398
+ ]
399
+ },
400
+ {
401
+ name: "sideload",
402
+ short: tr("Sideload Swipt"),
403
+ options: sideloadOptions,
404
+ commands: [
405
+ {
406
+ name: "install",
407
+ short: tr("Install Swipt"),
408
+ args: [0, 0],
409
+ options: {
410
+ ...passcodeOptions(tr("set up auto-unlock with this passcode")),
411
+ ...nightlyOption,
412
+ ...setupOptions
413
+ },
414
+ run: install$1
415
+ },
416
+ {
417
+ name: "update",
418
+ short: tr("Update or renew Swipt"),
419
+ args: [0, 0],
420
+ options: {
421
+ ...passcodeOptions(tr("unlock device with this passcode")),
422
+ ...nightlyOption,
423
+ ...setupOptions
424
+ },
425
+ run: update
426
+ },
427
+ {
428
+ name: "setup",
429
+ short: tr("Set up Swipt"),
430
+ args: [0, 0],
431
+ options: {
432
+ ...passcodeOptions(tr("set up auto-unlock with this passcode")),
433
+ ...setupStepOptions
434
+ },
435
+ run: setup
436
+ },
437
+ {
438
+ name: "uninstall",
439
+ short: tr("Remove Swipt"),
440
+ args: [0, 0],
441
+ run: uninstall
442
+ }
443
+ ]
444
+ },
445
+ {
446
+ name: "version",
447
+ short: tr("Print the version"),
448
+ args: [0, 0],
449
+ run: printVersion
450
+ }
451
+ ];
452
+ const root = {
453
+ name: "swipt",
454
+ short: tr("Swipt CLI"),
455
+ commands
456
+ };
457
+ const parseOptions = (options) => Object.fromEntries(Object.entries(options ?? {}).map(([name, option]) => [name, {
458
+ type: option.type,
459
+ ...option.short ? { short: option.short } : {}
460
+ }]));
461
+ function allOptions(command, collected = {}) {
462
+ Object.assign(collected, parseOptions(command.options));
463
+ for (const child of command.commands ?? []) allOptions(child, collected);
464
+ return collected;
465
+ }
466
+ function usage(trail) {
467
+ const command = trail.at(-1);
468
+ const name = trail.map((it) => it.name).join(" ");
469
+ const lines = [command.short, ""];
470
+ if (command.commands) {
471
+ lines.push(tr("usage: {usage}", { usage: `${name} COMMAND` }), "", tr("commands:"));
472
+ lines.push(...columns(command.commands.map((child) => [` ${child.use ?? child.name}`, child.short])).split("\n"));
473
+ } else lines.push(tr("usage: {usage}", { usage: `${trail.slice(0, -1).map((it) => it.name).join(" ")} ${command.use ?? command.name}`.replace(/ +/g, " ") }));
474
+ if (command.description) lines.push("", ...command.description);
475
+ const options = {
476
+ ...trail.reduce((found, it) => ({
477
+ ...found,
478
+ ...it.options
479
+ }), {}),
480
+ ...globalOptions
481
+ };
482
+ lines.push("", tr("options:"));
483
+ lines.push(...columns(Object.entries(options).map(([option, it]) => [` ${it.short ? `-${it.short}, ` : ""}--${option}${it.value ? ` ${it.value}` : ""}`, it.help])).split("\n"));
484
+ return lines.join("\n");
485
+ }
486
+ function columns(rows) {
487
+ const width = Math.max(...rows.map((row) => row[0].length));
488
+ return rows.map((row) => `${row[0].padEnd(width + 2)}${row[1]}`).join("\n");
489
+ }
490
+ function resolve(argv) {
491
+ const loose = parseArgs({
492
+ args: argv,
493
+ options: {
494
+ ...parseOptions(globalOptions),
495
+ ...allOptions(root)
496
+ },
497
+ allowPositionals: true,
498
+ strict: false,
499
+ tokens: true
500
+ });
501
+ const positionals = loose.tokens.filter((token) => token.kind === "positional");
502
+ const trail = [root];
503
+ let consumed = 0;
504
+ let help = positionals[0]?.value === "help";
505
+ if (help) consumed++;
506
+ while (trail.at(-1).commands) {
507
+ const current = trail.at(-1);
508
+ const word = positionals[consumed]?.value;
509
+ if (word === void 0) {
510
+ if (help || loose.values.help || current !== root || argv.length === 0) return {
511
+ trail,
512
+ help: true
513
+ };
514
+ throw new UsageError(tr("a command is missing"));
515
+ }
516
+ const found = current.commands.find((it) => it.name === word);
517
+ if (!found) throw new UsageError(tr("unknown command {name} for {parent}", {
518
+ name: JSON.stringify(word),
519
+ parent: JSON.stringify(trail.map((it) => it.name).join(" "))
520
+ }));
521
+ trail.push(found);
522
+ consumed++;
523
+ }
524
+ const command = trail.at(-1);
525
+ const options = trail.reduce((found, it) => ({
526
+ ...found,
527
+ ...it.options
528
+ }), {});
529
+ const first = positionals[consumed];
530
+ const verbatim = first !== void 0 && command.passthrough?.(first.value) ? first.index + 1 : argv.length;
531
+ let parsed;
532
+ try {
533
+ parsed = parseArgs({
534
+ args: argv.slice(0, verbatim),
535
+ options: {
536
+ ...parseOptions(globalOptions),
537
+ ...parseOptions(options)
538
+ },
539
+ allowPositionals: true,
540
+ strict: true
541
+ });
542
+ } catch (error) {
543
+ const option = error.message.match(/^Unknown option '(-[^']*)'/)?.[1];
544
+ throw new UsageError(option === void 0 ? error.message : tr("{option} is not an option of {command}", {
545
+ option,
546
+ command: JSON.stringify(trail.map((it) => it.name).join(" "))
547
+ }));
548
+ }
549
+ if (parsed.values.help) help = true;
550
+ const args = [...parsed.positionals.slice(consumed), ...argv.slice(verbatim)];
551
+ if (!help && (args.length < command.args[0] || args.length > command.args[1])) {
552
+ const [least, most] = command.args;
553
+ throw new UsageError(least === most ? tr("accepts {count} arg(s), received {received}", {
554
+ count: least,
555
+ received: args.length
556
+ }) : most === Infinity ? tr("accepts at least {count} arg(s), received {received}", {
557
+ count: least,
558
+ received: args.length
559
+ }) : tr("accepts between {least} and {count} arg(s), received {received}", {
560
+ least,
561
+ count: most,
562
+ received: args.length
563
+ }));
564
+ }
565
+ return {
566
+ trail,
567
+ help,
568
+ args,
569
+ values: parsed.values
570
+ };
571
+ }
572
+ function printError(error, target, operation) {
573
+ let exit = 1;
574
+ let message = error.message;
575
+ if (error instanceof UsageError) exit = 2;
576
+ else if (error instanceof RpcError) switch (error.code) {
577
+ case Code.Unavailable:
578
+ exit = 5;
579
+ message = tr("Swipt at {url} is unreachable: {message}", {
580
+ url: target.url,
581
+ message
582
+ });
583
+ break;
584
+ case Code.Unauthenticated:
585
+ message = tr("{message}; connect with the URL from Swipt › Developer: swipt device add {url}", {
586
+ message,
587
+ url: withToken(target.url)
588
+ });
589
+ break;
590
+ case Code.Unimplemented: message = tr("Swipt at {url} does not have this command; update Swipt", { url: target.url });
591
+ }
592
+ console.error(tr("error: {message}", { message: operation === void 0 ? message : `${operation}: ${message}` }));
593
+ if (exit === 2) console.error(tr("run \"swipt help\" for usage"));
594
+ return exit;
595
+ }
596
+ async function main() {
597
+ const interrupt = new AbortController();
598
+ const interrupted = () => interrupt.abort();
599
+ process.once("SIGINT", interrupted);
600
+ process.once("SIGTERM", interrupted);
601
+ const target = { url: "" };
602
+ try {
603
+ const resolved = resolve(process.argv.slice(2));
604
+ if (resolved.help) {
605
+ console.log(usage(resolved.trail));
606
+ return;
607
+ }
608
+ const command = resolved.trail.at(-1);
609
+ const values = command.parse ? command.parse(resolved.values) : resolved.values;
610
+ await command.run({
611
+ args: resolved.args,
612
+ options: values,
613
+ target,
614
+ signal: interrupt.signal,
615
+ printError: (error, operation) => printError(error, target, operation)
616
+ });
617
+ } catch (error) {
618
+ if (error instanceof FalseResult) process.exitCode = 1;
619
+ else if (interrupt.signal.aborted || error.name === "ExitPromptError") process.exitCode = 130;
620
+ else process.exitCode = printError(error, target);
621
+ } finally {
622
+ process.off("SIGINT", interrupted);
623
+ process.off("SIGTERM", interrupted);
624
+ }
625
+ }
626
+ await main();
627
+ await Promise.all([process.stdout, process.stderr].map((stream) => new Promise((resolve) => stream.write("", resolve))));
628
+ process.exit();
629
+ export {};
630
+
631
+ //# sourceMappingURL=swipt.js.map