greybel-interpreter 1.6.6 → 1.6.8
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/cps.js +4 -10
- package/dist/handler/output.d.ts +9 -8
- package/dist/handler/output.js +16 -6
- package/package.json +2 -1
package/dist/cps.js
CHANGED
|
@@ -21,6 +21,7 @@ const call_1 = __importDefault(require("./operations/call"));
|
|
|
21
21
|
const chunk_1 = __importDefault(require("./operations/chunk"));
|
|
22
22
|
const continue_1 = __importDefault(require("./operations/continue"));
|
|
23
23
|
const debugger_statement_1 = __importDefault(require("./operations/debugger-statement"));
|
|
24
|
+
const envar_1 = __importDefault(require("./operations/envar"));
|
|
24
25
|
const evaluate_1 = __importDefault(require("./operations/evaluate"));
|
|
25
26
|
const for_1 = __importDefault(require("./operations/for"));
|
|
26
27
|
const function_1 = __importDefault(require("./operations/function"));
|
|
@@ -38,7 +39,6 @@ const not_1 = __importDefault(require("./operations/not"));
|
|
|
38
39
|
const resolve_1 = __importDefault(require("./operations/resolve"));
|
|
39
40
|
const return_1 = __importDefault(require("./operations/return"));
|
|
40
41
|
const while_1 = __importDefault(require("./operations/while"));
|
|
41
|
-
const envar_1 = __importDefault(require("./operations/envar"));
|
|
42
42
|
class CPSContext {
|
|
43
43
|
constructor(target, handler) {
|
|
44
44
|
this.target = target;
|
|
@@ -88,14 +88,12 @@ const visit = (context, stack, item) => __awaiter(void 0, void 0, void 0, functi
|
|
|
88
88
|
console.warn('Found circluar dependency. Using noop operation.');
|
|
89
89
|
return new noop_1.default(item, target);
|
|
90
90
|
}
|
|
91
|
-
stack.push(target);
|
|
92
91
|
const code = yield context.handler.resourceHandler.get(target);
|
|
93
92
|
if (code == null) {
|
|
94
93
|
throw new Error(`Cannot find import ${currentTarget}.`);
|
|
95
94
|
}
|
|
96
|
-
const subVisit = visit.bind(null, context, stack);
|
|
95
|
+
const subVisit = visit.bind(null, context, [...stack, target]);
|
|
97
96
|
const importStatement = yield new import_1.default(importExpr, target, code).build(subVisit);
|
|
98
|
-
stack.pop();
|
|
99
97
|
return importStatement;
|
|
100
98
|
}
|
|
101
99
|
case greybel_core_1.ASTType.FeatureIncludeExpression: {
|
|
@@ -105,14 +103,12 @@ const visit = (context, stack, item) => __awaiter(void 0, void 0, void 0, functi
|
|
|
105
103
|
console.warn('Found circluar dependency. Using noop operation.');
|
|
106
104
|
return new noop_1.default(item, target);
|
|
107
105
|
}
|
|
108
|
-
stack.push(target);
|
|
109
106
|
const code = yield context.handler.resourceHandler.get(target);
|
|
110
107
|
if (code == null) {
|
|
111
108
|
throw new Error(`Cannot find include ${currentTarget}.`);
|
|
112
109
|
}
|
|
113
|
-
const subVisit = visit.bind(null, context, stack);
|
|
110
|
+
const subVisit = visit.bind(null, context, [...stack, target]);
|
|
114
111
|
const importStatement = yield new include_1.default(includeExpr, target, code).build(subVisit);
|
|
115
|
-
stack.pop();
|
|
116
112
|
return importStatement;
|
|
117
113
|
}
|
|
118
114
|
case greyscript_core_1.ASTType.ImportCodeExpression: {
|
|
@@ -122,14 +118,12 @@ const visit = (context, stack, item) => __awaiter(void 0, void 0, void 0, functi
|
|
|
122
118
|
console.warn('Found circluar dependency. Using noop operation.');
|
|
123
119
|
return new noop_1.default(item, target);
|
|
124
120
|
}
|
|
125
|
-
stack.push(target);
|
|
126
121
|
const code = yield context.handler.resourceHandler.get(target);
|
|
127
122
|
if (code == null) {
|
|
128
123
|
throw new Error(`Cannot find native import ${currentTarget}.`);
|
|
129
124
|
}
|
|
130
|
-
const subVisit = visit.bind(null, context, stack);
|
|
125
|
+
const subVisit = visit.bind(null, context, [...stack, target]);
|
|
131
126
|
const importStatement = yield new include_1.default(importExpr, target, code).build(subVisit);
|
|
132
|
-
stack.pop();
|
|
133
127
|
return importStatement;
|
|
134
128
|
}
|
|
135
129
|
case greybel_core_1.ASTType.FeatureDebuggerExpression:
|
package/dist/handler/output.d.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
+
import { CancelablePromise } from 'cancelable-promise';
|
|
1
2
|
export interface KeyEvent {
|
|
2
3
|
keyCode: number;
|
|
3
4
|
code: string;
|
|
4
5
|
}
|
|
5
6
|
export declare abstract class OutputHandler {
|
|
6
|
-
abstract print(message: string): void;
|
|
7
|
-
abstract progress(timeout: number):
|
|
8
|
-
abstract waitForInput(isPassword: boolean):
|
|
9
|
-
abstract waitForKeyPress():
|
|
7
|
+
abstract print(message: string, appendNewLine: boolean): void;
|
|
8
|
+
abstract progress(timeout: number): CancelablePromise<void>;
|
|
9
|
+
abstract waitForInput(isPassword: boolean): CancelablePromise<string>;
|
|
10
|
+
abstract waitForKeyPress(): CancelablePromise<KeyEvent>;
|
|
10
11
|
abstract clear(): void;
|
|
11
12
|
}
|
|
12
13
|
export declare class DefaultOutputHandler extends OutputHandler {
|
|
13
|
-
print(message: string): void;
|
|
14
|
-
progress(timeout: number):
|
|
15
|
-
waitForInput(_isPassword: boolean):
|
|
16
|
-
waitForKeyPress():
|
|
14
|
+
print(message: string, appendNewLine?: boolean): void;
|
|
15
|
+
progress(timeout: number): CancelablePromise<void>;
|
|
16
|
+
waitForInput(_isPassword: boolean): CancelablePromise<string>;
|
|
17
|
+
waitForKeyPress(): CancelablePromise<KeyEvent>;
|
|
17
18
|
clear(): void;
|
|
18
19
|
}
|
package/dist/handler/output.js
CHANGED
|
@@ -1,23 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DefaultOutputHandler = exports.OutputHandler = void 0;
|
|
4
|
+
const cancelable_promise_1 = require("cancelable-promise");
|
|
4
5
|
class OutputHandler {
|
|
5
6
|
}
|
|
6
7
|
exports.OutputHandler = OutputHandler;
|
|
7
8
|
class DefaultOutputHandler extends OutputHandler {
|
|
8
|
-
print(message) {
|
|
9
|
-
|
|
9
|
+
print(message, appendNewLine = true) {
|
|
10
|
+
if (appendNewLine) {
|
|
11
|
+
process.stdout.write(message + '\n');
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
process.stdout.write(message);
|
|
15
|
+
}
|
|
10
16
|
}
|
|
11
17
|
progress(timeout) {
|
|
12
|
-
return new
|
|
13
|
-
setTimeout(resolve, timeout);
|
|
18
|
+
return new cancelable_promise_1.CancelablePromise((resolve, _reject, onCancel) => {
|
|
19
|
+
const timer = setTimeout(resolve, timeout);
|
|
20
|
+
onCancel(() => {
|
|
21
|
+
clearTimeout(timer);
|
|
22
|
+
resolve();
|
|
23
|
+
});
|
|
14
24
|
});
|
|
15
25
|
}
|
|
16
26
|
waitForInput(_isPassword) {
|
|
17
|
-
return
|
|
27
|
+
return cancelable_promise_1.CancelablePromise.resolve('test');
|
|
18
28
|
}
|
|
19
29
|
waitForKeyPress() {
|
|
20
|
-
return
|
|
30
|
+
return cancelable_promise_1.CancelablePromise.resolve({
|
|
21
31
|
keyCode: 13,
|
|
22
32
|
code: 'Enter'
|
|
23
33
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "greybel-interpreter",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.8",
|
|
4
4
|
"description": "Interpreter",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"typescript": "^4.5.4"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
+
"cancelable-promise": "^4.3.1",
|
|
51
52
|
"greybel-core": "^0.6.7",
|
|
52
53
|
"greyscript-core": "^0.6.2"
|
|
53
54
|
},
|