greybel-interpreter 1.2.7 → 1.2.9
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/dist/handler/output.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
export interface KeyEvent {
|
|
2
|
+
keyCode: number;
|
|
3
|
+
code: string;
|
|
4
|
+
}
|
|
1
5
|
export declare abstract class OutputHandler {
|
|
2
6
|
abstract print(message: string): void;
|
|
3
7
|
abstract progress(timeout: number): Promise<void>;
|
|
4
8
|
abstract waitForInput(isPassword: boolean): Promise<string>;
|
|
5
|
-
abstract waitForKeyPress(): Promise<
|
|
9
|
+
abstract waitForKeyPress(): Promise<KeyEvent>;
|
|
6
10
|
abstract clear(): void;
|
|
7
11
|
}
|
|
8
12
|
export declare class DefaultOutputHandler extends OutputHandler {
|
|
9
13
|
print(message: string): void;
|
|
10
14
|
progress(timeout: number): Promise<void>;
|
|
11
15
|
waitForInput(_isPassword: boolean): Promise<string>;
|
|
12
|
-
waitForKeyPress(): Promise<
|
|
16
|
+
waitForKeyPress(): Promise<KeyEvent>;
|
|
13
17
|
clear(): void;
|
|
14
18
|
}
|
package/dist/handler/output.js
CHANGED
|
@@ -39,7 +39,10 @@ var DefaultOutputHandler = /** @class */ (function (_super) {
|
|
|
39
39
|
return Promise.resolve('test');
|
|
40
40
|
};
|
|
41
41
|
DefaultOutputHandler.prototype.waitForKeyPress = function () {
|
|
42
|
-
return Promise.resolve(
|
|
42
|
+
return Promise.resolve({
|
|
43
|
+
keyCode: 13,
|
|
44
|
+
code: 'Enter'
|
|
45
|
+
});
|
|
43
46
|
};
|
|
44
47
|
DefaultOutputHandler.prototype.clear = function () {
|
|
45
48
|
console.clear();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { ContextForkOptions, ContextOptions, ContextState, ContextType, Debugger, FunctionState, LoopState, default as OperationContext, ProcessState, Scope } from './context';
|
|
2
2
|
export { default as CPS, CPSContext } from './cps';
|
|
3
3
|
export { DefaultErrorHandler, ErrorHandler } from './handler/error';
|
|
4
|
-
export { DefaultOutputHandler, OutputHandler } from './handler/output';
|
|
4
|
+
export { DefaultOutputHandler, OutputHandler, KeyEvent } from './handler/output';
|
|
5
5
|
export { DefaultResourceHandler, ResourceHandler } from './handler/resource';
|
|
6
6
|
export { default as HandlerContainer } from './handler-container';
|
|
7
7
|
export { default as Interpreter, InterpreterOptions } from './interpreter';
|
|
@@ -230,7 +230,7 @@ var Resolve = /** @class */ (function (_super) {
|
|
|
230
230
|
handle = ctx.get(traversedPath);
|
|
231
231
|
}
|
|
232
232
|
if (!(handle instanceof function_1.default)) return [3 /*break*/, 5];
|
|
233
|
-
return [4 /*yield*/, handle.run(previous || default_1.default.Void, [])];
|
|
233
|
+
return [4 /*yield*/, handle.run(previous || default_1.default.Void, [], ctx)];
|
|
234
234
|
case 4:
|
|
235
235
|
handle = _a.sent();
|
|
236
236
|
_a.label = 5;
|
|
@@ -302,7 +302,7 @@ var Resolve = /** @class */ (function (_super) {
|
|
|
302
302
|
if (result.handle !== default_1.default.Void) {
|
|
303
303
|
if (result.path.count() === 0) {
|
|
304
304
|
if (autoCall && result.handle instanceof function_1.default) {
|
|
305
|
-
return [2 /*return*/, result.handle.run(default_1.default.Void, [])];
|
|
305
|
+
return [2 /*return*/, result.handle.run(default_1.default.Void, [], ctx)];
|
|
306
306
|
}
|
|
307
307
|
return [2 /*return*/, result.handle];
|
|
308
308
|
}
|
|
@@ -312,13 +312,13 @@ var Resolve = /** @class */ (function (_super) {
|
|
|
312
312
|
child instanceof function_1.default &&
|
|
313
313
|
// support index bug in greyscript
|
|
314
314
|
!(this.last instanceof IndexSegment)) {
|
|
315
|
-
return [2 /*return*/, child.run(customValueCtx, [])];
|
|
315
|
+
return [2 /*return*/, child.run(customValueCtx, [], ctx)];
|
|
316
316
|
}
|
|
317
317
|
return [2 /*return*/, child];
|
|
318
318
|
}
|
|
319
319
|
handle = ctx.get(result.path);
|
|
320
320
|
if (autoCall && handle instanceof function_1.default) {
|
|
321
|
-
return [2 /*return*/, handle.run(default_1.default.Void, [])];
|
|
321
|
+
return [2 /*return*/, handle.run(default_1.default.Void, [], ctx)];
|
|
322
322
|
}
|
|
323
323
|
return [2 /*return*/, handle];
|
|
324
324
|
}
|
package/dist/types/function.d.ts
CHANGED
|
@@ -28,5 +28,5 @@ export default class CustomFunction extends CustomValue {
|
|
|
28
28
|
toInt(): number;
|
|
29
29
|
toString(): string;
|
|
30
30
|
toTruthy(): boolean;
|
|
31
|
-
run(self: CustomValue, args: Array<CustomValue>, callContext
|
|
31
|
+
run(self: CustomValue, args: Array<CustomValue>, callContext: OperationContext): Promise<CustomValue>;
|
|
32
32
|
}
|