@dxos/react-ui-terminal 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/lib/chunk-cli.mjs +500 -0
  2. package/dist/lib/chunk-cli.mjs.map +1 -0
  3. package/dist/lib/cli.mjs +2 -0
  4. package/dist/lib/index.mjs +157 -0
  5. package/dist/lib/index.mjs.map +1 -0
  6. package/dist/lib/testing.mjs +41 -0
  7. package/dist/lib/testing.mjs.map +1 -0
  8. package/dist/types/src/cli/bridge.d.ts +42 -0
  9. package/dist/types/src/cli/bridge.d.ts.map +1 -0
  10. package/dist/types/src/cli/console.d.ts +16 -0
  11. package/dist/types/src/cli/console.d.ts.map +1 -0
  12. package/dist/types/src/cli/console.test.d.ts +2 -0
  13. package/dist/types/src/cli/console.test.d.ts.map +1 -0
  14. package/dist/types/src/cli/context.d.ts +17 -0
  15. package/dist/types/src/cli/context.d.ts.map +1 -0
  16. package/dist/types/src/cli/index.d.ts +9 -0
  17. package/dist/types/src/cli/index.d.ts.map +1 -0
  18. package/dist/types/src/cli/input.d.ts +14 -0
  19. package/dist/types/src/cli/input.d.ts.map +1 -0
  20. package/dist/types/src/cli/input.test.d.ts +2 -0
  21. package/dist/types/src/cli/input.test.d.ts.map +1 -0
  22. package/dist/types/src/cli/line-editor.d.ts +35 -0
  23. package/dist/types/src/cli/line-editor.d.ts.map +1 -0
  24. package/dist/types/src/cli/line-editor.test.d.ts +2 -0
  25. package/dist/types/src/cli/line-editor.test.d.ts.map +1 -0
  26. package/dist/types/src/cli/shell.d.ts +30 -0
  27. package/dist/types/src/cli/shell.d.ts.map +1 -0
  28. package/dist/types/src/cli/terminal.d.ts +12 -0
  29. package/dist/types/src/cli/terminal.d.ts.map +1 -0
  30. package/dist/types/src/cli/testing.d.ts +20 -0
  31. package/dist/types/src/cli/testing.d.ts.map +1 -0
  32. package/dist/types/src/cli/tokenize.d.ts +12 -0
  33. package/dist/types/src/cli/tokenize.d.ts.map +1 -0
  34. package/dist/types/src/components/Terminal/Terminal.d.ts +30 -0
  35. package/dist/types/src/components/Terminal/Terminal.d.ts.map +1 -0
  36. package/dist/types/src/components/Terminal/Terminal.stories.d.ts +18 -0
  37. package/dist/types/src/components/Terminal/Terminal.stories.d.ts.map +1 -0
  38. package/dist/types/src/components/Terminal/index.d.ts +2 -0
  39. package/dist/types/src/components/Terminal/index.d.ts.map +1 -0
  40. package/dist/types/src/components/Terminal/theme.d.ts +7 -0
  41. package/dist/types/src/components/Terminal/theme.d.ts.map +1 -0
  42. package/dist/types/src/components/index.d.ts +2 -0
  43. package/dist/types/src/components/index.d.ts.map +1 -0
  44. package/dist/types/src/index.d.ts +2 -0
  45. package/dist/types/src/index.d.ts.map +1 -0
  46. package/dist/types/src/testing.d.ts +23 -0
  47. package/dist/types/src/testing.d.ts.map +1 -0
  48. package/dist/types/tsconfig.tsbuildinfo +1 -0
  49. package/package.json +65 -0
  50. package/src/cli/bridge.ts +102 -0
  51. package/src/cli/console.test.ts +73 -0
  52. package/src/cli/console.ts +91 -0
  53. package/src/cli/context.ts +26 -0
  54. package/src/cli/index.ts +13 -0
  55. package/src/cli/input.test.ts +109 -0
  56. package/src/cli/input.ts +132 -0
  57. package/src/cli/line-editor.test.ts +141 -0
  58. package/src/cli/line-editor.ts +199 -0
  59. package/src/cli/shell.ts +103 -0
  60. package/src/cli/terminal.ts +43 -0
  61. package/src/cli/testing.ts +51 -0
  62. package/src/cli/tokenize.ts +35 -0
  63. package/src/components/Terminal/Terminal.stories.tsx +114 -0
  64. package/src/components/Terminal/Terminal.tsx +118 -0
  65. package/src/components/Terminal/index.ts +5 -0
  66. package/src/components/Terminal/theme.ts +87 -0
  67. package/src/components/index.ts +5 -0
  68. package/src/index.ts +5 -0
  69. package/src/testing.ts +56 -0
@@ -0,0 +1,500 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as Console from "effect/Console";
3
+ import * as FileSystem from "@effect/platform/FileSystem";
4
+ import * as Path from "@effect/platform/Path";
5
+ import * as Layer from "effect/Layer";
6
+ import * as Terminal from "@effect/platform/Terminal";
7
+ import * as Exit from "effect/Exit";
8
+ import * as Mailbox from "effect/Mailbox";
9
+ import * as Option from "effect/Option";
10
+ import * as Command from "@effect/cli/Command";
11
+ import * as ValidationError from "@effect/cli/ValidationError";
12
+ import * as Cause from "effect/Cause";
13
+ //#region \0rolldown/runtime.js
14
+ var __defProp = Object.defineProperty;
15
+ var __exportAll = (all, no_symbols) => {
16
+ let target = {};
17
+ for (var name in all) __defProp(target, name, {
18
+ get: all[name],
19
+ enumerable: true
20
+ });
21
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
22
+ return target;
23
+ };
24
+ //#endregion
25
+ //#region src/cli/console.ts
26
+ var console_exports = /* @__PURE__ */ __exportAll({
27
+ layer: () => layer$2,
28
+ make: () => make$1
29
+ });
30
+ var stringify = (value) => {
31
+ if (typeof value === "string") return value;
32
+ if (value instanceof Error) return value.stack ?? value.message;
33
+ try {
34
+ return JSON.stringify(value, null, 2) ?? String(value);
35
+ } catch {
36
+ return String(value);
37
+ }
38
+ };
39
+ var format = (args) => args.map(stringify).join(" ");
40
+ /**
41
+ * Routes Effect's `Console` to the terminal.
42
+ *
43
+ * `@effect/cli` renders help, usage errors, and wizard output as ANSI text through this service,
44
+ * which xterm interprets natively — so the browser gets the same styled output as a shell.
45
+ */
46
+ var make$1 = (bridge) => {
47
+ const write = (args) => bridge.write(format(args) + "\n");
48
+ const unsafe = {
49
+ assert: (condition, ...args) => {
50
+ if (!condition) write(["Assertion failed:", ...args]);
51
+ },
52
+ clear: () => bridge.clear(),
53
+ count: () => {},
54
+ countReset: () => {},
55
+ debug: (...args) => write(args),
56
+ dir: (item) => write([item]),
57
+ dirxml: (...args) => write(args),
58
+ error: (...args) => write(args),
59
+ group: (...args) => write(args),
60
+ groupCollapsed: (...args) => write(args),
61
+ groupEnd: () => {},
62
+ info: (...args) => write(args),
63
+ log: (...args) => write(args),
64
+ table: (tabularData) => write([tabularData]),
65
+ time: () => {},
66
+ timeEnd: () => {},
67
+ timeLog: (_label, ...args) => write(args),
68
+ trace: (...args) => write(args),
69
+ warn: (...args) => write(args)
70
+ };
71
+ return Console.Console.of({
72
+ [Console.TypeId]: Console.TypeId,
73
+ assert: (condition, ...args) => Effect.sync(() => unsafe.assert(condition, ...args)),
74
+ clear: Effect.sync(() => unsafe.clear()),
75
+ count: (label) => Effect.sync(() => unsafe.count(label)),
76
+ countReset: (label) => Effect.sync(() => unsafe.countReset(label)),
77
+ debug: (...args) => Effect.sync(() => unsafe.debug(...args)),
78
+ dir: (item, options) => Effect.sync(() => unsafe.dir(item, options)),
79
+ dirxml: (...args) => Effect.sync(() => unsafe.dirxml(...args)),
80
+ error: (...args) => Effect.sync(() => unsafe.error(...args)),
81
+ group: (options) => Effect.sync(() => unsafe.group(options?.label)),
82
+ groupEnd: Effect.sync(() => unsafe.groupEnd()),
83
+ info: (...args) => Effect.sync(() => unsafe.info(...args)),
84
+ log: (...args) => Effect.sync(() => unsafe.log(...args)),
85
+ table: (tabularData, properties) => Effect.sync(() => unsafe.table(tabularData, properties)),
86
+ time: (label) => Effect.sync(() => unsafe.time(label)),
87
+ timeEnd: (label) => Effect.sync(() => unsafe.timeEnd(label)),
88
+ timeLog: (label, ...args) => Effect.sync(() => unsafe.timeLog(label, ...args)),
89
+ trace: (...args) => Effect.sync(() => unsafe.trace(...args)),
90
+ warn: (...args) => Effect.sync(() => unsafe.warn(...args)),
91
+ unsafe
92
+ });
93
+ };
94
+ /**
95
+ * `Console.log` resolves against the `currentServices` fiber ref rather than the layer context, so
96
+ * this must go through `setConsole` — providing the tag with `Layer.succeed` is silently ignored.
97
+ */
98
+ var layer$2 = (bridge) => Console.setConsole(make$1(bridge));
99
+ //#endregion
100
+ //#region src/cli/input.ts
101
+ var makeInput = (name, { input, ctrl = false, meta = false, shift = false } = {}) => ({
102
+ input: Option.fromNullable(input),
103
+ key: {
104
+ name,
105
+ ctrl,
106
+ meta,
107
+ shift
108
+ }
109
+ });
110
+ /**
111
+ * Control characters that name a key directly rather than resolving to a ctrl-modified letter.
112
+ */
113
+ var CONTROL_KEYS = {
114
+ "\r": "return",
115
+ "\n": "return",
116
+ " ": "tab",
117
+ "\b": "backspace",
118
+ "": "backspace"
119
+ };
120
+ /**
121
+ * CSI/SS3 sequences (minus the leading escape) emitted by xterm for navigation keys.
122
+ * Ordered longest-first so `[3~` is matched before a shorter entry sharing its prefix.
123
+ */
124
+ var ESCAPE_SEQUENCES = [
125
+ ["[1~", "home"],
126
+ ["[3~", "delete"],
127
+ ["[4~", "end"],
128
+ ["[5~", "pageup"],
129
+ ["[6~", "pagedown"],
130
+ ["[A", "up"],
131
+ ["[B", "down"],
132
+ ["[C", "right"],
133
+ ["[D", "left"],
134
+ ["[F", "end"],
135
+ ["[H", "home"],
136
+ ["OA", "up"],
137
+ ["OB", "down"],
138
+ ["OC", "right"],
139
+ ["OD", "left"]
140
+ ];
141
+ var matchEscapeSequence = (data, index) => {
142
+ for (const [sequence, name] of ESCAPE_SEQUENCES) if (data.startsWith(sequence, index)) return {
143
+ name,
144
+ length: sequence.length
145
+ };
146
+ };
147
+ /**
148
+ * Decodes a chunk of xterm `onData` output into the keypress events that `@effect/platform`
149
+ * consumers (notably `@effect/cli` prompts) expect, using the same key names as Node's readline.
150
+ *
151
+ * Decoding the raw data stream rather than `onKey` DOM events is what makes paste work: a pasted
152
+ * string arrives as one chunk and expands to one event per character.
153
+ */
154
+ var decodeInput = (data) => {
155
+ const inputs = [];
156
+ let index = 0;
157
+ while (index < data.length) {
158
+ const char = data[index];
159
+ if (char === "\x1B") {
160
+ const escape = matchEscapeSequence(data, index + 1);
161
+ if (escape) {
162
+ inputs.push(makeInput(escape.name));
163
+ index += escape.length + 1;
164
+ continue;
165
+ }
166
+ const next = data[index + 1];
167
+ if (next !== void 0 && next >= " " && next !== "") {
168
+ inputs.push(makeInput(next.toLowerCase(), {
169
+ input: next,
170
+ meta: true
171
+ }));
172
+ index += 2;
173
+ continue;
174
+ }
175
+ inputs.push(makeInput("escape"));
176
+ index += 1;
177
+ continue;
178
+ }
179
+ const control = CONTROL_KEYS[char];
180
+ if (control) {
181
+ inputs.push(makeInput(control));
182
+ index += 1;
183
+ continue;
184
+ }
185
+ const code = char.charCodeAt(0);
186
+ if (code < 32) {
187
+ inputs.push(makeInput(String.fromCharCode(code + 96), { ctrl: true }));
188
+ index += 1;
189
+ continue;
190
+ }
191
+ const lower = char.toLowerCase();
192
+ inputs.push(makeInput(char === " " ? "space" : lower, {
193
+ input: char,
194
+ shift: char !== lower
195
+ }));
196
+ index += 1;
197
+ }
198
+ return inputs;
199
+ };
200
+ /**
201
+ * Ctrl-C and Ctrl-D end an input stream, matching the platform-node default.
202
+ */
203
+ var isQuitInput = (input) => input.key.ctrl && (input.key.name === "c" || input.key.name === "d");
204
+ //#endregion
205
+ //#region src/cli/line-editor.ts
206
+ /**
207
+ * Reads a single line, echoing keystrokes and supporting inline editing, history recall, and the
208
+ * common readline control chords.
209
+ *
210
+ * Distinguishes cancellation (Ctrl-C) from end-of-input (Ctrl-D on an empty buffer) so a shell can
211
+ * abandon the current line without exiting.
212
+ */
213
+ var readLineResult = (bridge, options = {}) => Effect.async((resume) => {
214
+ const { prompt = "", history = [] } = options;
215
+ let buffer = "";
216
+ let cursor = 0;
217
+ let historyIndex = history.length;
218
+ let draft = "";
219
+ const render = () => {
220
+ const trailing = buffer.length - cursor;
221
+ bridge.write(`\r\x1b[K${prompt}${buffer}${trailing > 0 ? `\x1b[${trailing}D` : ""}`);
222
+ };
223
+ const finish = (result) => {
224
+ unsubscribe();
225
+ resume(Effect.succeed(result));
226
+ };
227
+ const recall = (index) => {
228
+ if (historyIndex === history.length) draft = buffer;
229
+ historyIndex = index;
230
+ buffer = index === history.length ? draft : history[index];
231
+ cursor = buffer.length;
232
+ render();
233
+ };
234
+ const unsubscribe = bridge.subscribe((input) => {
235
+ const { key } = input;
236
+ if (key.ctrl) switch (key.name) {
237
+ case "c":
238
+ bridge.write("^C\n");
239
+ finish({ type: "cancelled" });
240
+ return;
241
+ case "d":
242
+ if (buffer.length === 0) {
243
+ bridge.write("\n");
244
+ finish({ type: "eof" });
245
+ }
246
+ return;
247
+ case "a":
248
+ cursor = 0;
249
+ render();
250
+ return;
251
+ case "e":
252
+ cursor = buffer.length;
253
+ render();
254
+ return;
255
+ case "u":
256
+ buffer = buffer.slice(cursor);
257
+ cursor = 0;
258
+ render();
259
+ return;
260
+ case "k":
261
+ buffer = buffer.slice(0, cursor);
262
+ render();
263
+ return;
264
+ case "l":
265
+ bridge.clear();
266
+ render();
267
+ return;
268
+ default: return;
269
+ }
270
+ switch (key.name) {
271
+ case "return":
272
+ bridge.write("\n");
273
+ finish({
274
+ type: "line",
275
+ value: buffer
276
+ });
277
+ return;
278
+ case "backspace":
279
+ if (cursor > 0) {
280
+ buffer = buffer.slice(0, cursor - 1) + buffer.slice(cursor);
281
+ cursor -= 1;
282
+ render();
283
+ }
284
+ return;
285
+ case "delete":
286
+ if (cursor < buffer.length) {
287
+ buffer = buffer.slice(0, cursor) + buffer.slice(cursor + 1);
288
+ render();
289
+ }
290
+ return;
291
+ case "left":
292
+ if (cursor > 0) {
293
+ cursor -= 1;
294
+ render();
295
+ }
296
+ return;
297
+ case "right":
298
+ if (cursor < buffer.length) {
299
+ cursor += 1;
300
+ render();
301
+ }
302
+ return;
303
+ case "home":
304
+ cursor = 0;
305
+ render();
306
+ return;
307
+ case "end":
308
+ cursor = buffer.length;
309
+ render();
310
+ return;
311
+ case "up":
312
+ if (historyIndex > 0) recall(historyIndex - 1);
313
+ return;
314
+ case "down":
315
+ if (historyIndex < history.length) recall(historyIndex + 1);
316
+ return;
317
+ case "escape":
318
+ case "tab": return;
319
+ }
320
+ Option.match(input.input, {
321
+ onNone: () => {},
322
+ onSome: (char) => {
323
+ buffer = buffer.slice(0, cursor) + char + buffer.slice(cursor);
324
+ cursor += char.length;
325
+ render();
326
+ }
327
+ });
328
+ });
329
+ render();
330
+ return Effect.sync(unsubscribe);
331
+ });
332
+ /**
333
+ * The `Terminal` service contract: a line, or a `QuitException` for either interrupt.
334
+ */
335
+ var readLine = (bridge, options = {}) => readLineResult(bridge, options).pipe(Effect.flatMap((result) => result.type === "line" ? Effect.succeed(result.value) : Effect.fail(new Terminal.QuitException())));
336
+ //#endregion
337
+ //#region src/cli/terminal.ts
338
+ var terminal_exports = /* @__PURE__ */ __exportAll({
339
+ layer: () => layer$1,
340
+ make: () => make
341
+ });
342
+ /**
343
+ * A `@effect/platform` `Terminal` backed by xterm.
344
+ *
345
+ * This is the only service in `CliApp.Environment` without a browser implementation upstream;
346
+ * `Path` is already pure JS and `FileSystem` can be stubbed.
347
+ */
348
+ var make = (bridge) => Terminal.Terminal.of({
349
+ columns: Effect.sync(() => bridge.columns),
350
+ rows: Effect.sync(() => bridge.rows),
351
+ isTTY: Effect.succeed(true),
352
+ readInput: Effect.gen(function* () {
353
+ const mailbox = yield* Mailbox.make();
354
+ const unsubscribe = bridge.subscribe((input) => {
355
+ mailbox.unsafeOffer(input);
356
+ if (isQuitInput(input)) mailbox.unsafeDone(Exit.void);
357
+ });
358
+ yield* Effect.addFinalizer(() => Effect.sync(unsubscribe));
359
+ return mailbox;
360
+ }),
361
+ readLine: readLine(bridge),
362
+ display: (text) => Effect.sync(() => bridge.write(text))
363
+ });
364
+ var layer$1 = (bridge) => Layer.succeed(Terminal.Terminal, make(bridge));
365
+ //#endregion
366
+ //#region src/cli/context.ts
367
+ var context_exports = /* @__PURE__ */ __exportAll({ layer: () => layer });
368
+ var layer = (bridge) => Layer.mergeAll(layer$1(bridge), layer$2(bridge), FileSystem.layerNoop({}), Path.layer);
369
+ //#endregion
370
+ //#region src/cli/bridge.ts
371
+ /**
372
+ * Adapts an xterm instance to {@link TerminalBridge}.
373
+ */
374
+ var XtermBridge = class {
375
+ #terminal;
376
+ #subscribers = [];
377
+ #subscription;
378
+ #atLineStart = true;
379
+ constructor(terminal) {
380
+ this.#terminal = terminal;
381
+ this.#subscription = terminal.onData((data) => this.#handleData(data));
382
+ }
383
+ get columns() {
384
+ return this.#terminal.cols;
385
+ }
386
+ get rows() {
387
+ return this.#terminal.rows;
388
+ }
389
+ /**
390
+ * Whether the cursor sits at the start of a row, so callers can avoid a blank line when a command
391
+ * has already terminated its output with a newline.
392
+ */
393
+ get atLineStart() {
394
+ return this.#atLineStart;
395
+ }
396
+ /**
397
+ * Writes text, translating bare newlines to CRLF since xterm does not reset the column on `\n`.
398
+ */
399
+ write(text) {
400
+ if (text.length === 0) return;
401
+ this.#terminal.write(text.replace(/\r?\n/g, "\r\n"));
402
+ this.#atLineStart = text.endsWith("\n");
403
+ }
404
+ clear() {
405
+ this.#terminal.write("\x1B[2J\x1B[H");
406
+ this.#atLineStart = true;
407
+ }
408
+ /**
409
+ * Subscribes to keypresses. The most recent subscriber wins, so a prompt opened by a running
410
+ * command takes over from the shell's line editor and hands back when its scope closes.
411
+ */
412
+ subscribe(handler) {
413
+ this.#subscribers.push(handler);
414
+ return () => {
415
+ const index = this.#subscribers.indexOf(handler);
416
+ if (index !== -1) this.#subscribers.splice(index, 1);
417
+ };
418
+ }
419
+ dispose() {
420
+ this.#subscription.dispose();
421
+ this.#subscribers.length = 0;
422
+ }
423
+ #handleData(data) {
424
+ const handler = this.#subscribers.at(-1);
425
+ if (!handler) return;
426
+ for (const input of decodeInput(data)) handler(input);
427
+ }
428
+ };
429
+ //#endregion
430
+ //#region src/cli/tokenize.ts
431
+ /**
432
+ * Splits a raw input line into argv tokens. Supports single/double-quoted segments so quoted
433
+ * strings with spaces survive. Intentionally simple — anything needing real shell semantics belongs
434
+ * in a real shell.
435
+ */
436
+ var tokenize = (input) => {
437
+ const tokens = [];
438
+ const regex = /"([^"]*)"|'([^']*)'|(\S+)/g;
439
+ let match;
440
+ while ((match = regex.exec(input)) !== null) tokens.push(match[1] ?? match[2] ?? match[3]);
441
+ return tokens;
442
+ };
443
+ /**
444
+ * Translates shell-friendly aliases to their Effect CLI equivalents. The Effect CLI uses `--help`
445
+ * rather than a `help` subcommand, but `help` and `?` are the natural things to type.
446
+ */
447
+ var rewriteHelpAliases = (tokens) => {
448
+ if (tokens.length === 0) return [...tokens];
449
+ if (tokens[0] !== "help" && tokens[0] !== "?") return [...tokens];
450
+ return tokens.length === 1 ? ["--help"] : [...tokens.slice(1), "--help"];
451
+ };
452
+ //#endregion
453
+ //#region src/cli/shell.ts
454
+ var EXIT_COMMANDS = ["exit", "quit"];
455
+ /**
456
+ * Runs a read-eval-print loop against an `@effect/cli` command tree.
457
+ *
458
+ * Each line is tokenized and dispatched through the same `Command.run` the binary uses, with a
459
+ * synthetic argv prefix standing in for the two leading entries the parser discards. The command
460
+ * tree and its layer are built once, so every command reuses the already-activated services.
461
+ */
462
+ var runShell = (bridge, options) => Effect.gen(function* () {
463
+ const { command, name = "dx", version = "0.0.0", prompt = `${name}> `, banner } = options;
464
+ const run = Command.run(command, {
465
+ name,
466
+ version
467
+ });
468
+ const history = [];
469
+ if (banner) bridge.write(`${banner}\n`);
470
+ while (true) {
471
+ if (!bridge.atLineStart) bridge.write("\n");
472
+ const result = yield* readLineResult(bridge, {
473
+ prompt,
474
+ history
475
+ });
476
+ if (result.type === "eof") break;
477
+ if (result.type === "cancelled") continue;
478
+ const line = result.value.trim();
479
+ if (line.length === 0) continue;
480
+ if (EXIT_COMMANDS.includes(line)) break;
481
+ history.push(line);
482
+ const tokens = rewriteHelpAliases(tokenize(line));
483
+ if (tokens.length === 0) continue;
484
+ yield* run([
485
+ name,
486
+ name,
487
+ ...tokens
488
+ ]).pipe(Effect.catchAllCause((cause) => {
489
+ if (Cause.isInterruptedOnly(cause)) return Effect.void;
490
+ const failure = Cause.failureOption(cause);
491
+ if (failure._tag === "Some" && ValidationError.isValidationError(failure.value)) return Effect.void;
492
+ return Console.error(Cause.pretty(cause));
493
+ }));
494
+ }
495
+ bridge.write("\n");
496
+ });
497
+ //#endregion
498
+ export { context_exports as a, readLine as c, isQuitInput as d, console_exports as f, XtermBridge as i, readLineResult as l, rewriteHelpAliases as n, layer as o, tokenize as r, terminal_exports as s, runShell as t, decodeInput as u };
499
+
500
+ //# sourceMappingURL=chunk-cli.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-cli.mjs","names":[],"sources":["../../src/cli/console.ts","../../src/cli/input.ts","../../src/cli/line-editor.ts","../../src/cli/terminal.ts","../../src/cli/context.ts","../../src/cli/bridge.ts","../../src/cli/tokenize.ts","../../src/cli/shell.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Console from 'effect/Console';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\n\nimport type { TerminalBridge } from './bridge';\n\nconst stringify = (value: unknown): string => {\n if (typeof value === 'string') {\n return value;\n }\n if (value instanceof Error) {\n return value.stack ?? value.message;\n }\n\n try {\n return JSON.stringify(value, null, 2) ?? String(value);\n } catch {\n return String(value);\n }\n};\n\nconst format = (args: ReadonlyArray<unknown>): string => args.map(stringify).join(' ');\n\n/**\n * Routes Effect's `Console` to the terminal.\n *\n * `@effect/cli` renders help, usage errors, and wizard output as ANSI text through this service,\n * which xterm interprets natively — so the browser gets the same styled output as a shell.\n */\nexport const make = (bridge: TerminalBridge): Console.Console => {\n const write = (args: ReadonlyArray<unknown>) => bridge.write(format(args) + '\\n');\n\n const unsafe: Console.UnsafeConsole = {\n assert: (condition, ...args) => {\n if (!condition) {\n write(['Assertion failed:', ...args]);\n }\n },\n clear: () => bridge.clear(),\n count: () => {},\n countReset: () => {},\n debug: (...args) => write(args),\n dir: (item) => write([item]),\n dirxml: (...args) => write(args),\n error: (...args) => write(args),\n group: (...args) => write(args),\n groupCollapsed: (...args) => write(args),\n groupEnd: () => {},\n info: (...args) => write(args),\n log: (...args) => write(args),\n table: (tabularData) => write([tabularData]),\n time: () => {},\n timeEnd: () => {},\n timeLog: (_label, ...args) => write(args),\n trace: (...args) => write(args),\n warn: (...args) => write(args),\n };\n\n return Console.Console.of({\n [Console.TypeId]: Console.TypeId,\n assert: (condition, ...args) => Effect.sync(() => unsafe.assert(condition, ...args)),\n clear: Effect.sync(() => unsafe.clear()),\n count: (label) => Effect.sync(() => unsafe.count(label)),\n countReset: (label) => Effect.sync(() => unsafe.countReset(label)),\n debug: (...args) => Effect.sync(() => unsafe.debug(...args)),\n dir: (item, options) => Effect.sync(() => unsafe.dir(item, options)),\n dirxml: (...args) => Effect.sync(() => unsafe.dirxml(...args)),\n error: (...args) => Effect.sync(() => unsafe.error(...args)),\n group: (options) => Effect.sync(() => unsafe.group(options?.label)),\n groupEnd: Effect.sync(() => unsafe.groupEnd()),\n info: (...args) => Effect.sync(() => unsafe.info(...args)),\n log: (...args) => Effect.sync(() => unsafe.log(...args)),\n table: (tabularData, properties) => Effect.sync(() => unsafe.table(tabularData, properties)),\n time: (label) => Effect.sync(() => unsafe.time(label)),\n timeEnd: (label) => Effect.sync(() => unsafe.timeEnd(label)),\n timeLog: (label, ...args) => Effect.sync(() => unsafe.timeLog(label, ...args)),\n trace: (...args) => Effect.sync(() => unsafe.trace(...args)),\n warn: (...args) => Effect.sync(() => unsafe.warn(...args)),\n unsafe,\n });\n};\n\n/**\n * `Console.log` resolves against the `currentServices` fiber ref rather than the layer context, so\n * this must go through `setConsole` — providing the tag with `Layer.succeed` is silently ignored.\n */\nexport const layer = (bridge: TerminalBridge): Layer.Layer<never> => Console.setConsole(make(bridge));\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport type * as Terminal from '@effect/platform/Terminal';\nimport * as Option from 'effect/Option';\n\ntype KeyOptions = {\n input?: string;\n ctrl?: boolean;\n meta?: boolean;\n shift?: boolean;\n};\n\nconst makeInput = (\n name: string,\n { input, ctrl = false, meta = false, shift = false }: KeyOptions = {},\n): Terminal.UserInput => ({\n input: Option.fromNullable(input),\n key: { name, ctrl, meta, shift },\n});\n\n/**\n * Control characters that name a key directly rather than resolving to a ctrl-modified letter.\n */\nconst CONTROL_KEYS: Record<string, string> = {\n '\\r': 'return',\n '\\n': 'return',\n '\\t': 'tab',\n '\\b': 'backspace',\n '\\x7f': 'backspace',\n};\n\n/**\n * CSI/SS3 sequences (minus the leading escape) emitted by xterm for navigation keys.\n * Ordered longest-first so `[3~` is matched before a shorter entry sharing its prefix.\n */\nconst ESCAPE_SEQUENCES: ReadonlyArray<readonly [string, string]> = [\n ['[1~', 'home'],\n ['[3~', 'delete'],\n ['[4~', 'end'],\n ['[5~', 'pageup'],\n ['[6~', 'pagedown'],\n ['[A', 'up'],\n ['[B', 'down'],\n ['[C', 'right'],\n ['[D', 'left'],\n ['[F', 'end'],\n ['[H', 'home'],\n ['OA', 'up'],\n ['OB', 'down'],\n ['OC', 'right'],\n ['OD', 'left'],\n];\n\nconst matchEscapeSequence = (data: string, index: number): { name: string; length: number } | undefined => {\n for (const [sequence, name] of ESCAPE_SEQUENCES) {\n if (data.startsWith(sequence, index)) {\n return { name, length: sequence.length };\n }\n }\n\n return undefined;\n};\n\n/**\n * Decodes a chunk of xterm `onData` output into the keypress events that `@effect/platform`\n * consumers (notably `@effect/cli` prompts) expect, using the same key names as Node's readline.\n *\n * Decoding the raw data stream rather than `onKey` DOM events is what makes paste work: a pasted\n * string arrives as one chunk and expands to one event per character.\n */\nexport const decodeInput = (data: string): Terminal.UserInput[] => {\n const inputs: Terminal.UserInput[] = [];\n let index = 0;\n\n while (index < data.length) {\n const char = data[index];\n\n if (char === '\\x1b') {\n const escape = matchEscapeSequence(data, index + 1);\n if (escape) {\n inputs.push(makeInput(escape.name));\n index += escape.length + 1;\n continue;\n }\n\n // A lone escape followed by a printable character is how alt-modified keys arrive.\n const next = data[index + 1];\n if (next !== undefined && next >= ' ' && next !== '\\x7f') {\n inputs.push(makeInput(next.toLowerCase(), { input: next, meta: true }));\n index += 2;\n continue;\n }\n\n inputs.push(makeInput('escape'));\n index += 1;\n continue;\n }\n\n const control = CONTROL_KEYS[char];\n if (control) {\n inputs.push(makeInput(control));\n index += 1;\n continue;\n }\n\n const code = char.charCodeAt(0);\n if (code < 0x20) {\n inputs.push(makeInput(String.fromCharCode(code + 0x60), { ctrl: true }));\n index += 1;\n continue;\n }\n\n const lower = char.toLowerCase();\n inputs.push(\n makeInput(char === ' ' ? 'space' : lower, {\n input: char,\n shift: char !== lower,\n }),\n );\n index += 1;\n }\n\n return inputs;\n};\n\n/**\n * Ctrl-C and Ctrl-D end an input stream, matching the platform-node default.\n */\nexport const isQuitInput = (input: Terminal.UserInput): boolean =>\n input.key.ctrl && (input.key.name === 'c' || input.key.name === 'd');\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Terminal from '@effect/platform/Terminal';\nimport * as Effect from 'effect/Effect';\nimport * as Option from 'effect/Option';\n\nimport type { TerminalBridge } from './bridge';\n\nexport type LineResult =\n | { readonly type: 'line'; readonly value: string }\n | { readonly type: 'cancelled' }\n | { readonly type: 'eof' };\n\nexport type ReadLineOptions = {\n /**\n * Rendered before the editable buffer and redrawn on every keystroke.\n */\n prompt?: string;\n /**\n * Previously entered lines, oldest first. Mutated by the caller between reads; the editor only\n * reads it.\n */\n history?: ReadonlyArray<string>;\n};\n\n/**\n * Reads a single line, echoing keystrokes and supporting inline editing, history recall, and the\n * common readline control chords.\n *\n * Distinguishes cancellation (Ctrl-C) from end-of-input (Ctrl-D on an empty buffer) so a shell can\n * abandon the current line without exiting.\n */\nexport const readLineResult = (bridge: TerminalBridge, options: ReadLineOptions = {}): Effect.Effect<LineResult> =>\n Effect.async<LineResult>((resume) => {\n const { prompt = '', history = [] } = options;\n\n let buffer = '';\n let cursor = 0;\n let historyIndex = history.length;\n let draft = '';\n\n // Redraws the whole row; a buffer long enough to wrap will not repaint correctly.\n const render = () => {\n const trailing = buffer.length - cursor;\n bridge.write(`\\r\\x1b[K${prompt}${buffer}${trailing > 0 ? `\\x1b[${trailing}D` : ''}`);\n };\n\n const finish = (result: LineResult) => {\n unsubscribe();\n resume(Effect.succeed(result));\n };\n\n const recall = (index: number) => {\n if (historyIndex === history.length) {\n draft = buffer;\n }\n\n historyIndex = index;\n buffer = index === history.length ? draft : history[index];\n cursor = buffer.length;\n render();\n };\n\n const unsubscribe = bridge.subscribe((input) => {\n const { key } = input;\n\n if (key.ctrl) {\n switch (key.name) {\n case 'c': {\n bridge.write('^C\\n');\n finish({ type: 'cancelled' });\n return;\n }\n case 'd': {\n if (buffer.length === 0) {\n bridge.write('\\n');\n finish({ type: 'eof' });\n }\n return;\n }\n case 'a': {\n cursor = 0;\n render();\n return;\n }\n case 'e': {\n cursor = buffer.length;\n render();\n return;\n }\n case 'u': {\n buffer = buffer.slice(cursor);\n cursor = 0;\n render();\n return;\n }\n case 'k': {\n buffer = buffer.slice(0, cursor);\n render();\n return;\n }\n case 'l': {\n bridge.clear();\n render();\n return;\n }\n default:\n return;\n }\n }\n\n switch (key.name) {\n case 'return': {\n bridge.write('\\n');\n finish({ type: 'line', value: buffer });\n return;\n }\n case 'backspace': {\n if (cursor > 0) {\n buffer = buffer.slice(0, cursor - 1) + buffer.slice(cursor);\n cursor -= 1;\n render();\n }\n return;\n }\n case 'delete': {\n if (cursor < buffer.length) {\n buffer = buffer.slice(0, cursor) + buffer.slice(cursor + 1);\n render();\n }\n return;\n }\n case 'left': {\n if (cursor > 0) {\n cursor -= 1;\n render();\n }\n return;\n }\n case 'right': {\n if (cursor < buffer.length) {\n cursor += 1;\n render();\n }\n return;\n }\n case 'home': {\n cursor = 0;\n render();\n return;\n }\n case 'end': {\n cursor = buffer.length;\n render();\n return;\n }\n case 'up': {\n if (historyIndex > 0) {\n recall(historyIndex - 1);\n }\n return;\n }\n case 'down': {\n if (historyIndex < history.length) {\n recall(historyIndex + 1);\n }\n return;\n }\n case 'escape':\n case 'tab':\n return;\n }\n\n Option.match(input.input, {\n onNone: () => {},\n onSome: (char) => {\n buffer = buffer.slice(0, cursor) + char + buffer.slice(cursor);\n cursor += char.length;\n render();\n },\n });\n });\n\n render();\n\n return Effect.sync(unsubscribe);\n });\n\n/**\n * The `Terminal` service contract: a line, or a `QuitException` for either interrupt.\n */\nexport const readLine = (bridge: TerminalBridge, options: ReadLineOptions = {}) =>\n readLineResult(bridge, options).pipe(\n Effect.flatMap((result) =>\n result.type === 'line' ? Effect.succeed(result.value) : Effect.fail(new Terminal.QuitException()),\n ),\n );\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Terminal from '@effect/platform/Terminal';\nimport * as Effect from 'effect/Effect';\nimport * as Exit from 'effect/Exit';\nimport * as Layer from 'effect/Layer';\nimport * as Mailbox from 'effect/Mailbox';\n\nimport type { TerminalBridge } from './bridge';\nimport { isQuitInput } from './input';\nimport { readLine } from './line-editor';\n\n/**\n * A `@effect/platform` `Terminal` backed by xterm.\n *\n * This is the only service in `CliApp.Environment` without a browser implementation upstream;\n * `Path` is already pure JS and `FileSystem` can be stubbed.\n */\nexport const make = (bridge: TerminalBridge): Terminal.Terminal =>\n Terminal.Terminal.of({\n columns: Effect.sync(() => bridge.columns),\n rows: Effect.sync(() => bridge.rows),\n isTTY: Effect.succeed(true),\n readInput: Effect.gen(function* () {\n const mailbox = yield* Mailbox.make<Terminal.UserInput>();\n const unsubscribe = bridge.subscribe((input) => {\n mailbox.unsafeOffer(input);\n if (isQuitInput(input)) {\n mailbox.unsafeDone(Exit.void);\n }\n });\n\n yield* Effect.addFinalizer(() => Effect.sync(unsubscribe));\n return mailbox;\n }),\n readLine: readLine(bridge),\n display: (text) => Effect.sync(() => bridge.write(text)),\n });\n\nexport const layer = (bridge: TerminalBridge): Layer.Layer<Terminal.Terminal> =>\n Layer.succeed(Terminal.Terminal, make(bridge));\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as FileSystem from '@effect/platform/FileSystem';\nimport * as Path from '@effect/platform/Path';\nimport type * as Terminal from '@effect/platform/Terminal';\nimport * as Layer from 'effect/Layer';\n\nimport type { XtermBridge } from './bridge';\nimport * as XtermConsole from './console';\nimport * as XtermTerminal from './terminal';\n\n/**\n * The browser counterpart to `BunContext.layer`.\n *\n * `CliApp.Environment` is only `FileSystem | Path | Terminal`: `Path` is already pure JS upstream\n * and the CLI's browser-safe commands never touch the filesystem, leaving `Terminal` as the sole\n * service needing a real implementation. The console override is merged in too — contributing no\n * services of its own — so command output and the CLI's ANSI help text land in the terminal\n * instead of the devtools console.\n */\nexport type Provided = Terminal.Terminal | FileSystem.FileSystem | Path.Path;\n\nexport const layer = (bridge: XtermBridge): Layer.Layer<Provided> =>\n Layer.mergeAll(XtermTerminal.layer(bridge), XtermConsole.layer(bridge), FileSystem.layerNoop({}), Path.layer);\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport type * as Terminal from '@effect/platform/Terminal';\nimport type { IDisposable, Terminal as XtermTerminal } from '@xterm/xterm';\n\nimport { decodeInput } from './input';\n\nexport type InputHandler = (input: Terminal.UserInput) => void;\n\n/**\n * The surface the shell and the Effect `Terminal` service need from a terminal: a write sink and a\n * stack of keypress subscribers. Depending on this rather than the xterm class keeps the rest of\n * this module free of any renderer.\n */\nexport interface TerminalBridge {\n readonly columns: number;\n readonly rows: number;\n readonly atLineStart: boolean;\n write(text: string): void;\n clear(): void;\n subscribe(handler: InputHandler): () => void;\n}\n\n/**\n * Adapts an xterm instance to {@link TerminalBridge}.\n */\nexport class XtermBridge implements TerminalBridge {\n #terminal: XtermTerminal;\n #subscribers: InputHandler[] = [];\n #subscription: IDisposable;\n #atLineStart = true;\n\n constructor(terminal: XtermTerminal) {\n this.#terminal = terminal;\n this.#subscription = terminal.onData((data) => this.#handleData(data));\n }\n\n get columns(): number {\n return this.#terminal.cols;\n }\n\n get rows(): number {\n return this.#terminal.rows;\n }\n\n /**\n * Whether the cursor sits at the start of a row, so callers can avoid a blank line when a command\n * has already terminated its output with a newline.\n */\n get atLineStart(): boolean {\n return this.#atLineStart;\n }\n\n /**\n * Writes text, translating bare newlines to CRLF since xterm does not reset the column on `\\n`.\n */\n write(text: string): void {\n if (text.length === 0) {\n return;\n }\n\n this.#terminal.write(text.replace(/\\r?\\n/g, '\\r\\n'));\n this.#atLineStart = text.endsWith('\\n');\n }\n\n clear(): void {\n this.#terminal.write('\\x1b[2J\\x1b[H');\n this.#atLineStart = true;\n }\n\n /**\n * Subscribes to keypresses. The most recent subscriber wins, so a prompt opened by a running\n * command takes over from the shell's line editor and hands back when its scope closes.\n */\n subscribe(handler: InputHandler): () => void {\n this.#subscribers.push(handler);\n return () => {\n const index = this.#subscribers.indexOf(handler);\n if (index !== -1) {\n this.#subscribers.splice(index, 1);\n }\n };\n }\n\n dispose(): void {\n this.#subscription.dispose();\n this.#subscribers.length = 0;\n }\n\n #handleData(data: string): void {\n const handler = this.#subscribers.at(-1);\n if (!handler) {\n return;\n }\n\n for (const input of decodeInput(data)) {\n handler(input);\n }\n }\n}\n","//\n// Copyright 2026 DXOS.org\n//\n\n/**\n * Splits a raw input line into argv tokens. Supports single/double-quoted segments so quoted\n * strings with spaces survive. Intentionally simple — anything needing real shell semantics belongs\n * in a real shell.\n */\nexport const tokenize = (input: string): string[] => {\n const tokens: string[] = [];\n const regex = /\"([^\"]*)\"|'([^']*)'|(\\S+)/g;\n let match: RegExpExecArray | null;\n while ((match = regex.exec(input)) !== null) {\n tokens.push(match[1] ?? match[2] ?? match[3]);\n }\n\n return tokens;\n};\n\n/**\n * Translates shell-friendly aliases to their Effect CLI equivalents. The Effect CLI uses `--help`\n * rather than a `help` subcommand, but `help` and `?` are the natural things to type.\n */\nexport const rewriteHelpAliases = (tokens: ReadonlyArray<string>): string[] => {\n if (tokens.length === 0) {\n return [...tokens];\n }\n\n if (tokens[0] !== 'help' && tokens[0] !== '?') {\n return [...tokens];\n }\n\n return tokens.length === 1 ? ['--help'] : [...tokens.slice(1), '--help'];\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Command from '@effect/cli/Command';\nimport * as ValidationError from '@effect/cli/ValidationError';\nimport type * as FileSystem from '@effect/platform/FileSystem';\nimport type * as Path from '@effect/platform/Path';\nimport type * as Terminal from '@effect/platform/Terminal';\nimport * as Cause from 'effect/Cause';\nimport * as Console from 'effect/Console';\nimport * as Effect from 'effect/Effect';\n\nimport type { TerminalBridge } from './bridge';\nimport { readLineResult } from './line-editor';\nimport { rewriteHelpAliases, tokenize } from './tokenize';\n\nconst EXIT_COMMANDS = ['exit', 'quit'];\n\n/**\n * The services `Command.run` itself needs, spelled out because `@effect/cli` only exposes the\n * equivalent alias inside its `CliApp` namespace.\n */\nexport type CliEnvironment = FileSystem.FileSystem | Path.Path | Terminal.Terminal;\n\nexport type ShellOptions<Name extends string, R, E, A> = {\n command: Command.Command<Name, R, E, A>;\n /**\n * Executable name, used in help output and as the argv[1] the Effect CLI parser skips.\n */\n name?: string;\n version?: string;\n prompt?: string;\n banner?: string;\n};\n\n/**\n * Runs a read-eval-print loop against an `@effect/cli` command tree.\n *\n * Each line is tokenized and dispatched through the same `Command.run` the binary uses, with a\n * synthetic argv prefix standing in for the two leading entries the parser discards. The command\n * tree and its layer are built once, so every command reuses the already-activated services.\n */\nexport const runShell = <Name extends string, R, E, A>(\n bridge: TerminalBridge,\n options: ShellOptions<Name, R, E, A>,\n): Effect.Effect<void, never, R | CliEnvironment> =>\n Effect.gen(function* () {\n const { command, name = 'dx', version = '0.0.0', prompt = `${name}> `, banner } = options;\n const run = Command.run(command, { name, version });\n const history: string[] = [];\n\n if (banner) {\n bridge.write(`${banner}\\n`);\n }\n\n while (true) {\n if (!bridge.atLineStart) {\n bridge.write('\\n');\n }\n\n const result = yield* readLineResult(bridge, { prompt, history });\n if (result.type === 'eof') {\n break;\n }\n if (result.type === 'cancelled') {\n continue;\n }\n\n const line = result.value.trim();\n if (line.length === 0) {\n continue;\n }\n if (EXIT_COMMANDS.includes(line)) {\n break;\n }\n\n history.push(line);\n const tokens = rewriteHelpAliases(tokenize(line));\n if (tokens.length === 0) {\n continue;\n }\n\n // Failures are reported rather than propagated so the shell survives to the next prompt.\n // Validation errors are skipped because the Effect CLI has already rendered them.\n yield* run([name, name, ...tokens]).pipe(\n Effect.catchAllCause((cause) => {\n if (Cause.isInterruptedOnly(cause)) {\n return Effect.void;\n }\n\n const failure = Cause.failureOption(cause);\n if (failure._tag === 'Some' && ValidationError.isValidationError(failure.value)) {\n return Effect.void;\n }\n\n return Console.error(Cause.pretty(cause));\n }),\n );\n }\n\n bridge.write('\\n');\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,IAAM,aAAa,UAA2B;CAC5C,IAAI,OAAO,UAAU,UACnB,OAAO;CAET,IAAI,iBAAiB,OACnB,OAAO,MAAM,SAAS,MAAM;CAG9B,IAAI;EACF,OAAO,KAAK,UAAU,OAAO,MAAM,CAAC,KAAK,OAAO,KAAK;CACvD,QAAQ;EACN,OAAO,OAAO,KAAK;CACrB;AACF;AAEA,IAAM,UAAU,SAAyC,KAAK,IAAI,SAAS,CAAC,CAAC,KAAK,GAAG;;;;;;;AAQrF,IAAa,UAAQ,WAA4C;CAC/D,MAAM,SAAS,SAAiC,OAAO,MAAM,OAAO,IAAI,IAAI,IAAI;CAEhF,MAAM,SAAgC;EACpC,SAAS,WAAW,GAAG,SAAS;GAC9B,IAAI,CAAC,WACH,MAAM,CAAC,qBAAqB,GAAG,IAAI,CAAC;EAExC;EACA,aAAa,OAAO,MAAM;EAC1B,aAAa,CAAC;EACd,kBAAkB,CAAC;EACnB,QAAQ,GAAG,SAAS,MAAM,IAAI;EAC9B,MAAM,SAAS,MAAM,CAAC,IAAI,CAAC;EAC3B,SAAS,GAAG,SAAS,MAAM,IAAI;EAC/B,QAAQ,GAAG,SAAS,MAAM,IAAI;EAC9B,QAAQ,GAAG,SAAS,MAAM,IAAI;EAC9B,iBAAiB,GAAG,SAAS,MAAM,IAAI;EACvC,gBAAgB,CAAC;EACjB,OAAO,GAAG,SAAS,MAAM,IAAI;EAC7B,MAAM,GAAG,SAAS,MAAM,IAAI;EAC5B,QAAQ,gBAAgB,MAAM,CAAC,WAAW,CAAC;EAC3C,YAAY,CAAC;EACb,eAAe,CAAC;EAChB,UAAU,QAAQ,GAAG,SAAS,MAAM,IAAI;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,UAAU,gBAAgB,kBAAkB,QAAQ,KAAK,GAC5E,OAAO,OAAO;GAGhB,OAAO,QAAQ,MAAM,MAAM,OAAO,KAAK,CAAC;EAC1C,CAAC,CACH;CACF;CAEA,OAAO,MAAM,IAAI;AACnB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { a as context_exports, c as readLine, d as isQuitInput, f as console_exports, i as XtermBridge, l as readLineResult, n as rewriteHelpAliases, r as tokenize, s as terminal_exports, t as runShell, u as decodeInput } from "./chunk-cli.mjs";
2
+ export { XtermBridge, console_exports as XtermConsole, context_exports as XtermContext, terminal_exports as XtermTerminal, decodeInput, isQuitInput, readLine, readLineResult, rewriteHelpAliases, runShell, tokenize };