shell-dsl 0.0.39 → 0.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +183 -3
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/src/commands/exit/exit.cjs +84 -0
- package/dist/cjs/src/commands/exit/exit.cjs.map +10 -0
- package/dist/cjs/src/commands/index.cjs +18 -2
- package/dist/cjs/src/commands/index.cjs.map +3 -3
- package/dist/cjs/src/commands/sh/sh.cjs +134 -0
- package/dist/cjs/src/commands/sh/sh.cjs.map +10 -0
- package/dist/cjs/src/index.cjs +9 -1
- package/dist/cjs/src/index.cjs.map +3 -3
- package/dist/cjs/src/input-analysis.cjs +154 -0
- package/dist/cjs/src/input-analysis.cjs.map +10 -0
- package/dist/cjs/src/interpreter/context.cjs +6 -1
- package/dist/cjs/src/interpreter/context.cjs.map +3 -3
- package/dist/cjs/src/interpreter/index.cjs +2 -1
- package/dist/cjs/src/interpreter/index.cjs.map +3 -3
- package/dist/cjs/src/interpreter/interpreter.cjs +434 -82
- package/dist/cjs/src/interpreter/interpreter.cjs.map +3 -3
- package/dist/cjs/src/io/async-queue.cjs +105 -0
- package/dist/cjs/src/io/async-queue.cjs.map +10 -0
- package/dist/cjs/src/io/index.cjs +4 -1
- package/dist/cjs/src/io/index.cjs.map +3 -3
- package/dist/cjs/src/io/input-controller.cjs +113 -0
- package/dist/cjs/src/io/input-controller.cjs.map +10 -0
- package/dist/cjs/src/io/stdout.cjs +9 -6
- package/dist/cjs/src/io/stdout.cjs.map +3 -3
- package/dist/cjs/src/lexer/lexer.cjs +13 -1
- package/dist/cjs/src/lexer/lexer.cjs.map +3 -3
- package/dist/cjs/src/parser/parser.cjs +11 -1
- package/dist/cjs/src/parser/parser.cjs.map +3 -3
- package/dist/cjs/src/shell-dsl.cjs +13 -5
- package/dist/cjs/src/shell-dsl.cjs.map +3 -3
- package/dist/cjs/src/shell-session.cjs +128 -0
- package/dist/cjs/src/shell-session.cjs.map +10 -0
- package/dist/cjs/src/types.cjs.map +2 -2
- package/dist/mjs/package.json +1 -1
- package/dist/mjs/src/commands/exit/exit.mjs +44 -0
- package/dist/mjs/src/commands/exit/exit.mjs.map +10 -0
- package/dist/mjs/src/commands/index.mjs +18 -2
- package/dist/mjs/src/commands/index.mjs.map +3 -3
- package/dist/mjs/src/commands/sh/sh.mjs +94 -0
- package/dist/mjs/src/commands/sh/sh.mjs.map +10 -0
- package/dist/mjs/src/index.mjs +19 -3
- package/dist/mjs/src/index.mjs.map +3 -3
- package/dist/mjs/src/input-analysis.mjs +114 -0
- package/dist/mjs/src/input-analysis.mjs.map +10 -0
- package/dist/mjs/src/interpreter/context.mjs +6 -1
- package/dist/mjs/src/interpreter/context.mjs.map +3 -3
- package/dist/mjs/src/interpreter/index.mjs +3 -2
- package/dist/mjs/src/interpreter/index.mjs.map +2 -2
- package/dist/mjs/src/interpreter/interpreter.mjs +434 -82
- package/dist/mjs/src/interpreter/interpreter.mjs.map +3 -3
- package/dist/mjs/src/io/async-queue.mjs +64 -0
- package/dist/mjs/src/io/async-queue.mjs.map +10 -0
- package/dist/mjs/src/io/index.mjs +4 -1
- package/dist/mjs/src/io/index.mjs.map +3 -3
- package/dist/mjs/src/io/input-controller.mjs +72 -0
- package/dist/mjs/src/io/input-controller.mjs.map +10 -0
- package/dist/mjs/src/io/stdout.mjs +9 -6
- package/dist/mjs/src/io/stdout.mjs.map +3 -3
- package/dist/mjs/src/lexer/lexer.mjs +13 -1
- package/dist/mjs/src/lexer/lexer.mjs.map +3 -3
- package/dist/mjs/src/parser/parser.mjs +11 -1
- package/dist/mjs/src/parser/parser.mjs.map +3 -3
- package/dist/mjs/src/shell-dsl.mjs +13 -5
- package/dist/mjs/src/shell-dsl.mjs.map +3 -3
- package/dist/mjs/src/shell-session.mjs +88 -0
- package/dist/mjs/src/shell-session.mjs.map +10 -0
- package/dist/mjs/src/types.mjs.map +2 -2
- package/dist/types/src/commands/exit/exit.d.ts +2 -0
- package/dist/types/src/commands/index.d.ts +2 -0
- package/dist/types/src/commands/sh/sh.d.ts +5 -0
- package/dist/types/src/index.d.ts +6 -3
- package/dist/types/src/input-analysis.d.ts +14 -0
- package/dist/types/src/interpreter/context.d.ts +4 -1
- package/dist/types/src/interpreter/index.d.ts +1 -1
- package/dist/types/src/interpreter/interpreter.d.ts +36 -1
- package/dist/types/src/io/async-queue.d.ts +12 -0
- package/dist/types/src/io/index.d.ts +1 -0
- package/dist/types/src/io/input-controller.d.ts +15 -0
- package/dist/types/src/io/stdout.d.ts +4 -3
- package/dist/types/src/shell-dsl.d.ts +2 -0
- package/dist/types/src/shell-session.d.ts +23 -0
- package/dist/types/src/types.d.ts +52 -0
- package/package.json +1 -1
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
8
|
+
var __toCommonJS = (from) => {
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
10
|
+
if (entry)
|
|
11
|
+
return entry;
|
|
12
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
__moduleCache.set(from, entry);
|
|
22
|
+
return entry;
|
|
23
|
+
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
29
|
+
var __export = (target, all) => {
|
|
30
|
+
for (var name in all)
|
|
31
|
+
__defProp(target, name, {
|
|
32
|
+
get: all[name],
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// src/input-analysis.ts
|
|
40
|
+
var exports_input_analysis = {};
|
|
41
|
+
__export(exports_input_analysis, {
|
|
42
|
+
analyzeInput: () => analyzeInput
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(exports_input_analysis);
|
|
45
|
+
var import_lexer = require("./lexer/lexer.cjs");
|
|
46
|
+
var import_parser = require("./parser/parser.cjs");
|
|
47
|
+
var import_errors = require("./errors.cjs");
|
|
48
|
+
function analyzeInput(source) {
|
|
49
|
+
const heredoc = findIncompleteHeredoc(source);
|
|
50
|
+
if (heredoc) {
|
|
51
|
+
return { kind: "incomplete", reason: "heredoc" };
|
|
52
|
+
}
|
|
53
|
+
let tokens;
|
|
54
|
+
try {
|
|
55
|
+
tokens = new import_lexer.Lexer(source, { preserveNewlines: true }).tokenize();
|
|
56
|
+
} catch (err) {
|
|
57
|
+
if (err instanceof import_errors.LexError && err.message.toLowerCase().includes("unterminated")) {
|
|
58
|
+
return { kind: "incomplete", reason: "quote" };
|
|
59
|
+
}
|
|
60
|
+
return { kind: "invalid", error: err instanceof Error ? err : new Error(String(err)) };
|
|
61
|
+
}
|
|
62
|
+
if (tokens.every((token) => token.type === "newline" || token.type === "eof")) {
|
|
63
|
+
return { kind: "complete", ast: emptyCommandAst() };
|
|
64
|
+
}
|
|
65
|
+
if (hasTrailingPipeline(tokens)) {
|
|
66
|
+
return { kind: "incomplete", reason: "pipeline" };
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
const ast = new import_parser.Parser(tokens).parse();
|
|
70
|
+
return { kind: "complete", ast };
|
|
71
|
+
} catch (err) {
|
|
72
|
+
if (hasOpenCompound(tokens)) {
|
|
73
|
+
return { kind: "incomplete", reason: "compound" };
|
|
74
|
+
}
|
|
75
|
+
if (err instanceof import_errors.ParseError && isIncompleteParseMessage(err.message)) {
|
|
76
|
+
return { kind: "incomplete", reason: "compound" };
|
|
77
|
+
}
|
|
78
|
+
return { kind: "invalid", error: err instanceof Error ? err : new Error(String(err)) };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function emptyCommandAst() {
|
|
82
|
+
return {
|
|
83
|
+
type: "command",
|
|
84
|
+
name: { type: "word", parts: [] },
|
|
85
|
+
args: [],
|
|
86
|
+
redirects: [],
|
|
87
|
+
assignments: []
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function hasTrailingPipeline(tokens) {
|
|
91
|
+
let i = tokens.length - 1;
|
|
92
|
+
while (i >= 0 && (tokens[i].type === "eof" || tokens[i].type === "newline")) {
|
|
93
|
+
i--;
|
|
94
|
+
}
|
|
95
|
+
return i >= 0 && tokens[i].type === "pipe";
|
|
96
|
+
}
|
|
97
|
+
function hasOpenCompound(tokens) {
|
|
98
|
+
const stack = [];
|
|
99
|
+
for (const token of tokens) {
|
|
100
|
+
if (token.type !== "keyword") {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
switch (token.value) {
|
|
104
|
+
case "if":
|
|
105
|
+
stack.push("fi");
|
|
106
|
+
break;
|
|
107
|
+
case "for":
|
|
108
|
+
case "while":
|
|
109
|
+
case "until":
|
|
110
|
+
stack.push("done");
|
|
111
|
+
break;
|
|
112
|
+
case "case":
|
|
113
|
+
stack.push("esac");
|
|
114
|
+
break;
|
|
115
|
+
case "fi":
|
|
116
|
+
case "done":
|
|
117
|
+
case "esac":
|
|
118
|
+
if (stack[stack.length - 1] === token.value) {
|
|
119
|
+
stack.pop();
|
|
120
|
+
}
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return stack.length > 0;
|
|
125
|
+
}
|
|
126
|
+
function isIncompleteParseMessage(message) {
|
|
127
|
+
return message.includes("Expected 'fi'") || message.includes("Expected 'done'") || message.includes("Expected 'esac'") || message.includes("Expected 'then'") || message.includes("Expected 'do'");
|
|
128
|
+
}
|
|
129
|
+
function findIncompleteHeredoc(source) {
|
|
130
|
+
const lines = source.split(/\n/);
|
|
131
|
+
for (let i = 0;i < lines.length; i++) {
|
|
132
|
+
const match = lines[i].match(/<<-?\s*(?:"([^"]+)"|'([^']+)'|([A-Za-z_][A-Za-z0-9_]*|\S+))/);
|
|
133
|
+
if (!match) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
const delimiter = match[1] ?? match[2] ?? match[3];
|
|
137
|
+
if (!delimiter) {
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
let found = false;
|
|
141
|
+
for (let j = i + 1;j < lines.length; j++) {
|
|
142
|
+
if (lines[j] === delimiter || lines[j].replace(/^\t+/, "") === delimiter) {
|
|
143
|
+
found = true;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (!found) {
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
//# debugId=32A2D9A6396B91EF64756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/input-analysis.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type { ASTNode } from \"./parser/ast.cjs\";\nimport type { Token, KeywordValue } from \"./lexer/tokens.cjs\";\nimport { Lexer } from \"./lexer/lexer.cjs\";\nimport { Parser } from \"./parser/parser.cjs\";\nimport { LexError, ParseError } from \"./errors.cjs\";\n\nexport type InputIncompleteReason = \"quote\" | \"heredoc\" | \"compound\" | \"pipeline\";\n\nexport type InputAnalysis =\n | { kind: \"complete\"; ast: ASTNode }\n | { kind: \"incomplete\"; reason: InputIncompleteReason }\n | { kind: \"invalid\"; error: LexError | ParseError | Error };\n\nexport function analyzeInput(source: string): InputAnalysis {\n const heredoc = findIncompleteHeredoc(source);\n if (heredoc) {\n return { kind: \"incomplete\", reason: \"heredoc\" };\n }\n\n let tokens: Token[];\n try {\n tokens = new Lexer(source, { preserveNewlines: true }).tokenize();\n } catch (err) {\n if (err instanceof LexError && err.message.toLowerCase().includes(\"unterminated\")) {\n return { kind: \"incomplete\", reason: \"quote\" };\n }\n return { kind: \"invalid\", error: err instanceof Error ? err : new Error(String(err)) };\n }\n\n if (tokens.every((token) => token.type === \"newline\" || token.type === \"eof\")) {\n return { kind: \"complete\", ast: emptyCommandAst() };\n }\n\n if (hasTrailingPipeline(tokens)) {\n return { kind: \"incomplete\", reason: \"pipeline\" };\n }\n\n try {\n const ast = new Parser(tokens).parse();\n return { kind: \"complete\", ast };\n } catch (err) {\n if (hasOpenCompound(tokens)) {\n return { kind: \"incomplete\", reason: \"compound\" };\n }\n if (err instanceof ParseError && isIncompleteParseMessage(err.message)) {\n return { kind: \"incomplete\", reason: \"compound\" };\n }\n return { kind: \"invalid\", error: err instanceof Error ? err : new Error(String(err)) };\n }\n}\n\nfunction emptyCommandAst(): ASTNode {\n return {\n type: \"command\",\n name: { type: \"word\", parts: [] },\n args: [],\n redirects: [],\n assignments: [],\n };\n}\n\nfunction hasTrailingPipeline(tokens: Token[]): boolean {\n let i = tokens.length - 1;\n while (i >= 0 && (tokens[i]!.type === \"eof\" || tokens[i]!.type === \"newline\")) {\n i--;\n }\n return i >= 0 && tokens[i]!.type === \"pipe\";\n}\n\nfunction hasOpenCompound(tokens: Token[]): boolean {\n const stack: KeywordValue[] = [];\n\n for (const token of tokens) {\n if (token.type !== \"keyword\") {\n continue;\n }\n\n switch (token.value) {\n case \"if\":\n stack.push(\"fi\");\n break;\n case \"for\":\n case \"while\":\n case \"until\":\n stack.push(\"done\");\n break;\n case \"case\":\n stack.push(\"esac\");\n break;\n case \"fi\":\n case \"done\":\n case \"esac\":\n if (stack[stack.length - 1] === token.value) {\n stack.pop();\n }\n break;\n }\n }\n\n return stack.length > 0;\n}\n\nfunction isIncompleteParseMessage(message: string): boolean {\n return (\n message.includes(\"Expected 'fi'\") ||\n message.includes(\"Expected 'done'\") ||\n message.includes(\"Expected 'esac'\") ||\n message.includes(\"Expected 'then'\") ||\n message.includes(\"Expected 'do'\")\n );\n}\n\nfunction findIncompleteHeredoc(source: string): boolean {\n const lines = source.split(/\\n/);\n\n for (let i = 0; i < lines.length; i++) {\n const match = lines[i]!.match(/<<-?\\s*(?:\"([^\"]+)\"|'([^']+)'|([A-Za-z_][A-Za-z0-9_]*|\\S+))/);\n if (!match) {\n continue;\n }\n\n const delimiter = match[1] ?? match[2] ?? match[3];\n if (!delimiter) {\n continue;\n }\n\n let found = false;\n for (let j = i + 1; j < lines.length; j++) {\n if (lines[j] === delimiter || lines[j]!.replace(/^\\t+/, \"\") === delimiter) {\n found = true;\n break;\n }\n }\n if (!found) {\n return true;\n }\n }\n\n return false;\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEsB,IAAtB;AACuB,IAAvB;AACqC,IAArC;AASO,SAAS,YAAY,CAAC,QAA+B;AAAA,EAC1D,MAAM,UAAU,sBAAsB,MAAM;AAAA,EAC5C,IAAI,SAAS;AAAA,IACX,OAAO,EAAE,MAAM,cAAc,QAAQ,UAAU;AAAA,EACjD;AAAA,EAEA,IAAI;AAAA,EACJ,IAAI;AAAA,IACF,SAAS,IAAI,mBAAM,QAAQ,EAAE,kBAAkB,KAAK,CAAC,EAAE,SAAS;AAAA,IAChE,OAAO,KAAK;AAAA,IACZ,IAAI,eAAe,0BAAY,IAAI,QAAQ,YAAY,EAAE,SAAS,cAAc,GAAG;AAAA,MACjF,OAAO,EAAE,MAAM,cAAc,QAAQ,Q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AO,aAAa,MAAM,GAAI,QAAQ,QAAQ,EAAE,MAAM,WAAW;AAAA,QACzE,QAAQ;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,IACA,IAAI,CAAC,OAAO;AAAA,MACV,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEA,OAAO;AAAA;",
|
|
8
|
+
"debugId": "32A2D9A6396B91EF64756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -51,12 +51,17 @@ function createCommandContext(options) {
|
|
|
51
51
|
fs: options.fs,
|
|
52
52
|
cwd: options.cwd,
|
|
53
53
|
env: options.env,
|
|
54
|
+
terminal: options.terminal,
|
|
55
|
+
signal: options.signal,
|
|
54
56
|
setCwd: options.setCwd
|
|
55
57
|
};
|
|
56
58
|
if (options.exec) {
|
|
57
59
|
ctx.exec = options.exec;
|
|
58
60
|
}
|
|
61
|
+
if (options.shell) {
|
|
62
|
+
ctx.shell = options.shell;
|
|
63
|
+
}
|
|
59
64
|
return ctx;
|
|
60
65
|
}
|
|
61
66
|
|
|
62
|
-
//# debugId=
|
|
67
|
+
//# debugId=EF2EDEF001ADFBB864756E2164756E21
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/interpreter/context.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import type {
|
|
5
|
+
"import type {\n CommandContext,\n VirtualFS,\n Stdin,\n Stdout,\n Stderr,\n ExecResult,\n ShellCommandApi,\n TerminalInfo,\n} from \"../types.cjs\";\n\nexport interface ContextOptions {\n args: string[];\n stdin: Stdin;\n stdout: Stdout;\n stderr: Stderr;\n fs: VirtualFS;\n cwd: string;\n env: Record<string, string>;\n terminal: TerminalInfo;\n signal: AbortSignal;\n setCwd: (path: string) => void;\n exec?: (name: string, args: string[]) => Promise<ExecResult>;\n shell?: ShellCommandApi;\n}\n\nexport function createCommandContext(options: ContextOptions): CommandContext {\n const ctx: CommandContext = {\n args: options.args,\n stdin: options.stdin,\n stdout: options.stdout,\n stderr: options.stderr,\n fs: options.fs,\n cwd: options.cwd,\n env: options.env,\n terminal: options.terminal,\n signal: options.signal,\n setCwd: options.setCwd,\n };\n if (options.exec) {\n ctx.exec = options.exec;\n }\n if (options.shell) {\n ctx.shell = options.shell;\n }\n return ctx;\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BO,SAAS,oBAAoB,CAAC,SAAyC;AAAA,EAC5E,MAAM,MAAsB;AAAA,IAC1B,MAAM,QAAQ;AAAA,IACd,OAAO,QAAQ;AAAA,IACf,QAAQ,QAAQ;AAAA,IAChB,QAAQ,QAAQ;AAAA,IAChB,IAAI,QAAQ;AAAA,IACZ,KAAK,QAAQ;AAAA,IACb,KAAK,QAAQ;AAAA,IACb,UAAU,QAAQ;AAAA,IAClB,QAAQ,QAAQ;AAAA,IAChB,QAAQ,QAAQ;AAAA,EAClB;AAAA,EACA,IAAI,QAAQ,MAAM;AAAA,IAChB,IAAI,OAAO,QAAQ;AAAA,EACrB;AAAA,EACA,IAAI,QAAQ,OAAO;AAAA,IACjB,IAAI,QAAQ,QAAQ;AAAA,EACtB;AAAA,EACA,OAAO;AAAA;",
|
|
8
|
+
"debugId": "EF2EDEF001ADFBB864756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -41,6 +41,7 @@ var exports_interpreter = {};
|
|
|
41
41
|
__export(exports_interpreter, {
|
|
42
42
|
createCommandContext: () => import_context.createCommandContext,
|
|
43
43
|
Interpreter: () => import_interpreter.Interpreter,
|
|
44
|
+
ExitException: () => import_interpreter.ExitException,
|
|
44
45
|
ContinueException: () => import_interpreter.ContinueException,
|
|
45
46
|
BreakException: () => import_interpreter.BreakException
|
|
46
47
|
});
|
|
@@ -48,4 +49,4 @@ module.exports = __toCommonJS(exports_interpreter);
|
|
|
48
49
|
var import_interpreter = require("./interpreter.cjs");
|
|
49
50
|
var import_context = require("./context.cjs");
|
|
50
51
|
|
|
51
|
-
//# debugId=
|
|
52
|
+
//# debugId=478C5E50B11BB65664756E2164756E21
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/interpreter/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"export { Interpreter, type InterpreterOptions, BreakException, ContinueException } from \"./interpreter.cjs\";\nexport { createCommandContext, type ContextOptions } from \"./context.cjs\";\n"
|
|
5
|
+
"export { Interpreter, type InterpreterOptions, BreakException, ContinueException, ExitException } from \"./interpreter.cjs\";\nexport { createCommandContext, type ContextOptions } from \"./context.cjs\";\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAuG,IAAvG;AAC0D,IAA1D;",
|
|
8
|
+
"debugId": "478C5E50B11BB65664756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|