@iyio/protogen 0.0.10 → 0.0.11
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/esm/src/index.d.ts +6 -0
- package/esm/src/index.js +6 -0
- package/esm/src/index.js.map +1 -1
- package/esm/src/lib/ProtoExpressionEngine.d.ts +16 -0
- package/esm/src/lib/ProtoExpressionEngine.js +358 -0
- package/esm/src/lib/ProtoExpressionEngine.js.map +1 -0
- package/esm/src/lib/executeProtoPipelineAsync.js +22 -11
- package/esm/src/lib/executeProtoPipelineAsync.js.map +1 -1
- package/esm/src/lib/markdown.d.ts +1 -0
- package/esm/src/lib/markdown.js +36 -7
- package/esm/src/lib/markdown.js.map +1 -1
- package/esm/src/lib/protogen-expression-ctrls.d.ts +2 -0
- package/esm/src/lib/protogen-expression-ctrls.js +284 -0
- package/esm/src/lib/protogen-expression-ctrls.js.map +1 -0
- package/esm/src/lib/protogen-expression-lib.d.ts +16 -0
- package/esm/src/lib/protogen-expression-lib.js +101 -0
- package/esm/src/lib/protogen-expression-lib.js.map +1 -0
- package/esm/src/lib/protogen-expression-types.d.ts +160 -0
- package/esm/src/lib/protogen-expression-types.js +46 -0
- package/esm/src/lib/protogen-expression-types.js.map +1 -0
- package/esm/src/lib/protogen-lib.d.ts +17 -1
- package/esm/src/lib/protogen-lib.js +67 -0
- package/esm/src/lib/protogen-lib.js.map +1 -1
- package/esm/src/lib/protogen-pipeline-types.d.ts +17 -1
- package/esm/src/lib/protogen-pipeline-types.js.map +1 -1
- package/esm/src/lib/protogen-pipeline.js +0 -2
- package/esm/src/lib/protogen-pipeline.js.map +1 -1
- package/esm/src/lib/protogen-plugin-util.d.ts +4 -1
- package/esm/src/lib/protogen-plugin-util.js +65 -2
- package/esm/src/lib/protogen-plugin-util.js.map +1 -1
- package/esm/src/lib/protogen-types.d.ts +72 -0
- package/esm/src/lib/protogen-types.js +8 -1
- package/esm/src/lib/protogen-types.js.map +1 -1
- package/esm/src/lib/protogen-workflow-lib.d.ts +7 -0
- package/esm/src/lib/protogen-workflow-lib.js +53 -0
- package/esm/src/lib/protogen-workflow-lib.js.map +1 -0
- package/esm/src/lib/protogen-workflow-types.d.ts +95 -0
- package/esm/src/lib/protogen-workflow-types.js +2 -0
- package/esm/src/lib/protogen-workflow-types.js.map +1 -0
- package/esm/src/lib/typescript-utils.js +1 -1
- package/esm/src/lib/typescript-utils.js.map +1 -1
- package/package.json +16 -9
- package/src/index.d.ts +6 -0
- package/src/index.js +6 -0
- package/src/index.js.map +1 -1
- package/src/lib/ProtoExpressionEngine.d.ts +16 -0
- package/src/lib/ProtoExpressionEngine.js +363 -0
- package/src/lib/ProtoExpressionEngine.js.map +1 -0
- package/src/lib/executeProtoPipelineAsync.js +22 -11
- package/src/lib/executeProtoPipelineAsync.js.map +1 -1
- package/src/lib/markdown.d.ts +1 -0
- package/src/lib/markdown.js +38 -8
- package/src/lib/markdown.js.map +1 -1
- package/src/lib/protogen-expression-ctrls.d.ts +2 -0
- package/src/lib/protogen-expression-ctrls.js +288 -0
- package/src/lib/protogen-expression-ctrls.js.map +1 -0
- package/src/lib/protogen-expression-lib.d.ts +16 -0
- package/src/lib/protogen-expression-lib.js +114 -0
- package/src/lib/protogen-expression-lib.js.map +1 -0
- package/src/lib/protogen-expression-types.d.ts +160 -0
- package/src/lib/protogen-expression-types.js +50 -0
- package/src/lib/protogen-expression-types.js.map +1 -0
- package/src/lib/protogen-lib.d.ts +17 -1
- package/src/lib/protogen-lib.js +72 -1
- package/src/lib/protogen-lib.js.map +1 -1
- package/src/lib/protogen-pipeline-types.d.ts +17 -1
- package/src/lib/protogen-pipeline-types.js.map +1 -1
- package/src/lib/protogen-pipeline.js +0 -2
- package/src/lib/protogen-pipeline.js.map +1 -1
- package/src/lib/protogen-plugin-util.d.ts +4 -1
- package/src/lib/protogen-plugin-util.js +68 -3
- package/src/lib/protogen-plugin-util.js.map +1 -1
- package/src/lib/protogen-types.d.ts +72 -0
- package/src/lib/protogen-types.js +11 -0
- package/src/lib/protogen-types.js.map +1 -1
- package/src/lib/protogen-workflow-lib.d.ts +7 -0
- package/src/lib/protogen-workflow-lib.js +59 -0
- package/src/lib/protogen-workflow-lib.js.map +1 -0
- package/src/lib/protogen-workflow-types.d.ts +95 -0
- package/src/lib/protogen-workflow-types.js +3 -0
- package/src/lib/protogen-workflow-types.js.map +1 -0
- package/src/lib/typescript-utils.js +1 -1
- package/src/lib/typescript-utils.js.map +1 -1
package/esm/src/index.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
+
export * from './lib/ProtoExpressionEngine';
|
|
1
2
|
export * from './lib/executeProtoPipelineAsync';
|
|
2
3
|
export * from './lib/markdown';
|
|
3
4
|
export * from './lib/output-utils';
|
|
4
5
|
export * from './lib/protogen-cli';
|
|
6
|
+
export * from './lib/protogen-expression-ctrls';
|
|
7
|
+
export * from './lib/protogen-expression-lib';
|
|
8
|
+
export * from './lib/protogen-expression-types';
|
|
5
9
|
export * from './lib/protogen-lib';
|
|
6
10
|
export * from './lib/protogen-node';
|
|
7
11
|
export * from './lib/protogen-pipeline';
|
|
8
12
|
export * from './lib/protogen-pipeline-types';
|
|
9
13
|
export * from './lib/protogen-plugin-util';
|
|
10
14
|
export * from './lib/protogen-types';
|
|
15
|
+
export * from './lib/protogen-workflow-lib';
|
|
16
|
+
export * from './lib/protogen-workflow-types';
|
|
11
17
|
export * from './lib/typescript-utils';
|
package/esm/src/index.js
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
+
export * from './lib/ProtoExpressionEngine';
|
|
1
2
|
export * from './lib/executeProtoPipelineAsync';
|
|
2
3
|
export * from './lib/markdown';
|
|
3
4
|
export * from './lib/output-utils';
|
|
4
5
|
export * from './lib/protogen-cli';
|
|
6
|
+
export * from './lib/protogen-expression-ctrls';
|
|
7
|
+
export * from './lib/protogen-expression-lib';
|
|
8
|
+
export * from './lib/protogen-expression-types';
|
|
5
9
|
export * from './lib/protogen-lib';
|
|
6
10
|
export * from './lib/protogen-node';
|
|
7
11
|
export * from './lib/protogen-pipeline';
|
|
8
12
|
export * from './lib/protogen-pipeline-types';
|
|
9
13
|
export * from './lib/protogen-plugin-util';
|
|
10
14
|
export * from './lib/protogen-types';
|
|
15
|
+
export * from './lib/protogen-workflow-lib';
|
|
16
|
+
export * from './lib/protogen-workflow-types';
|
|
11
17
|
export * from './lib/typescript-utils';
|
|
12
18
|
//# sourceMappingURL=index.js.map
|
package/esm/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/protogen/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/protogen/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CancelToken, LogCallback } from "@iyio/common";
|
|
2
|
+
import { ProtoEvalContext, ProtoEvalFrame, ProtoEvalResult, ProtoExpression, ProtoExpressionEngineOptions } from "./protogen-expression-types";
|
|
3
|
+
export declare class ProtoExpressionEngine {
|
|
4
|
+
readonly context: ProtoEvalContext;
|
|
5
|
+
readonly cancelToken: CancelToken;
|
|
6
|
+
private readonly expression;
|
|
7
|
+
private readonly callableExpressions;
|
|
8
|
+
private readonly callables;
|
|
9
|
+
log: LogCallback | undefined;
|
|
10
|
+
constructor({ context, expression, callableExpressions, callables, cancel }: ProtoExpressionEngineOptions);
|
|
11
|
+
private _started;
|
|
12
|
+
get started(): boolean;
|
|
13
|
+
evalAsync(): Promise<ProtoEvalResult>;
|
|
14
|
+
private readonly evalExpression;
|
|
15
|
+
}
|
|
16
|
+
export declare const getProtoExpressionResumeFrames: (id: string, expression: ProtoExpression) => ProtoEvalFrame[];
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { CancelToken, deleteUndefined } from "@iyio/common";
|
|
3
|
+
import { getProtoExpressionCtrl } from "./protogen-expression-ctrls";
|
|
4
|
+
import { MaxProtoExpressionEvalCountError, ProtoExpressionPauseNotAllowedError, UnableToFindProtoExpressionResumeId, createProtoExpressionControlFlowResult, getProtoExpressionValueByPath } from "./protogen-expression-lib";
|
|
5
|
+
import { isProtoExpressionControlFlowResult } from "./protogen-expression-types";
|
|
6
|
+
import { invokeProtoCallable } from "./protogen-lib";
|
|
7
|
+
export class ProtoExpressionEngine {
|
|
8
|
+
constructor({ context, expression, callableExpressions = {}, callables = {}, cancel = new CancelToken() }) {
|
|
9
|
+
this._started = false;
|
|
10
|
+
this.evalExpression = (expression, context, depth) => __awaiter(this, void 0, void 0, function* () {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
const evalIndex = context.evalCount;
|
|
13
|
+
if (this.log) {
|
|
14
|
+
this.log(`eval[${evalIndex}] -`, expression);
|
|
15
|
+
}
|
|
16
|
+
if (this.cancelToken.isCanceled) {
|
|
17
|
+
if (this.log) {
|
|
18
|
+
this.log(`eval[${evalIndex}] - cancled`);
|
|
19
|
+
}
|
|
20
|
+
return createProtoExpressionControlFlowResult({
|
|
21
|
+
canceled: true
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
context.evalCount++;
|
|
25
|
+
if (context.maxEvalCount !== undefined && context.evalCount > context.maxEvalCount) {
|
|
26
|
+
const msg = `Max number of expressions evaluated. max:${context.maxEvalCount}`;
|
|
27
|
+
if (this.log) {
|
|
28
|
+
this.log(`eval[${evalIndex}] - ${msg}`);
|
|
29
|
+
}
|
|
30
|
+
throw new MaxProtoExpressionEvalCountError(msg);
|
|
31
|
+
}
|
|
32
|
+
let frame = context.frames[depth];
|
|
33
|
+
if (!frame) {
|
|
34
|
+
frame = {};
|
|
35
|
+
context.frames.push(frame);
|
|
36
|
+
}
|
|
37
|
+
const ctrl = getProtoExpressionCtrl(expression.ctrl);
|
|
38
|
+
let result = undefined;
|
|
39
|
+
const calls = (!(ctrl === null || ctrl === void 0 ? void 0 : ctrl.ignoreCall) && expression.address) ? true : false;
|
|
40
|
+
let value = undefined;
|
|
41
|
+
if (!(ctrl === null || ctrl === void 0 ? void 0 : ctrl.skipSubs) && expression.sub) {
|
|
42
|
+
if (frame.sub === undefined) {
|
|
43
|
+
frame.sub = 0;
|
|
44
|
+
}
|
|
45
|
+
if ((ctrl === null || ctrl === void 0 ? void 0 : ctrl.loop) && !frame.ctrlData) {
|
|
46
|
+
frame.ctrlData = {};
|
|
47
|
+
}
|
|
48
|
+
let _continue = true;
|
|
49
|
+
let loopCount = -1;
|
|
50
|
+
while ((ctrl === null || ctrl === void 0 ? void 0 : ctrl.loop) ?
|
|
51
|
+
ctrl.loop(_continue, ++loopCount, frame.ctrlData, expression, context) :
|
|
52
|
+
(++loopCount) === 0) {
|
|
53
|
+
_continue = true;
|
|
54
|
+
if (loopCount > 0) {
|
|
55
|
+
frame.sub = 0;
|
|
56
|
+
context.evalCount++;
|
|
57
|
+
if (context.maxEvalCount !== undefined && context.evalCount > context.maxEvalCount) {
|
|
58
|
+
const msg = `Max number of expressions evaluated. max:${context.maxEvalCount}`;
|
|
59
|
+
if (this.log) {
|
|
60
|
+
this.log(`eval[${evalIndex}] - ${msg}`);
|
|
61
|
+
}
|
|
62
|
+
throw new MaxProtoExpressionEvalCountError(msg);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
for (; frame.sub < expression.sub.length; frame.sub++) {
|
|
66
|
+
const sub = expression.sub[frame.sub];
|
|
67
|
+
if (!sub) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (ctrl === null || ctrl === void 0 ? void 0 : ctrl.beforeSub) {
|
|
71
|
+
if (!frame.ctrlData) {
|
|
72
|
+
frame.ctrlData = {};
|
|
73
|
+
}
|
|
74
|
+
const op = ctrl.beforeSub(frame.ctrlData, sub, expression, context);
|
|
75
|
+
if (this.log) {
|
|
76
|
+
this.log(`eval[${evalIndex}] - beforeSub: ${op}`);
|
|
77
|
+
}
|
|
78
|
+
if (op === 'skip') {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
else if (op === 'break') {
|
|
82
|
+
_continue = false;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
else if (op === 'reset') {
|
|
86
|
+
_continue = true;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const prevSubValue = value;
|
|
91
|
+
value = yield this.evalExpression(sub, context, depth + 1);
|
|
92
|
+
if ((ctrl === null || ctrl === void 0 ? void 0 : ctrl.mergeSubValues) &&
|
|
93
|
+
frame.sub &&
|
|
94
|
+
!isProtoExpressionControlFlowResult(value) &&
|
|
95
|
+
!isProtoExpressionControlFlowResult(prevSubValue)) {
|
|
96
|
+
if (!frame.ctrlData) {
|
|
97
|
+
frame.ctrlData = {};
|
|
98
|
+
}
|
|
99
|
+
value = ctrl.mergeSubValues(prevSubValue, value, frame.ctrlData, sub, expression, context);
|
|
100
|
+
}
|
|
101
|
+
if (isProtoExpressionControlFlowResult(value)) {
|
|
102
|
+
if (value.exit) {
|
|
103
|
+
if (this.log) {
|
|
104
|
+
this.log(`eval[${evalIndex}] - exit`, value);
|
|
105
|
+
}
|
|
106
|
+
return value;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else if (calls || expression.map) {
|
|
110
|
+
if (!frame.subResults) {
|
|
111
|
+
frame.subResults = {};
|
|
112
|
+
}
|
|
113
|
+
frame.subResults[(_a = sub.name) !== null && _a !== void 0 ? _a : ''] = value;
|
|
114
|
+
}
|
|
115
|
+
if (ctrl === null || ctrl === void 0 ? void 0 : ctrl.afterSub) {
|
|
116
|
+
if (!frame.ctrlData) {
|
|
117
|
+
frame.ctrlData = {};
|
|
118
|
+
}
|
|
119
|
+
const op = ctrl.afterSub(value, frame.ctrlData, sub, expression, context);
|
|
120
|
+
if (this.log) {
|
|
121
|
+
this.log(`eval[${evalIndex}] - afterSub: ${op}`);
|
|
122
|
+
}
|
|
123
|
+
if (op === 'break') {
|
|
124
|
+
_continue = false;
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
else if (op === 'reset') {
|
|
128
|
+
_continue = true;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (calls) {
|
|
136
|
+
if (expression.address) {
|
|
137
|
+
const callable = this.callables[expression.address];
|
|
138
|
+
if (callable !== undefined) {
|
|
139
|
+
if (!frame.subResults) {
|
|
140
|
+
frame.subResults = {};
|
|
141
|
+
}
|
|
142
|
+
if (this.log) {
|
|
143
|
+
this.log(`eval[${evalIndex}] - invoke: ${expression.address}`, 'args', frame.subResults, 'callable', { args: callable.args, returnType: callable.returnType });
|
|
144
|
+
}
|
|
145
|
+
result = yield invokeProtoCallable(callable, frame.subResults);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
const exCallable = this.callableExpressions[expression.address];
|
|
149
|
+
if (this.log) {
|
|
150
|
+
this.log(`eval[${evalIndex}] - invokeExpression: ${expression.address}`, exCallable);
|
|
151
|
+
}
|
|
152
|
+
if (exCallable) {
|
|
153
|
+
result = yield this.evalExpression(exCallable, context, depth + 1);
|
|
154
|
+
if (isProtoExpressionControlFlowResult(result) && result.resumeId) {
|
|
155
|
+
const msg = 'Callable expressions are not allowed to pause evaluation';
|
|
156
|
+
if (this.log) {
|
|
157
|
+
this.log(`eval[${evalIndex}] - invokeExpression: ${expression.address} - ${msg}`);
|
|
158
|
+
}
|
|
159
|
+
throw new ProtoExpressionPauseNotAllowedError();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
const varValue = context.vars[expression.address];
|
|
164
|
+
if (varValue !== undefined) {
|
|
165
|
+
result = varValue;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
else if (expression.path) {
|
|
172
|
+
if (!(ctrl === null || ctrl === void 0 ? void 0 : ctrl.ignorePath)) {
|
|
173
|
+
result = getProtoExpressionValueByPath(expression.path, context);
|
|
174
|
+
if (this.log) {
|
|
175
|
+
this.log(`eval[${evalIndex}] - path: ${expression.path}`, result);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
result = value;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
else if (expression.map) {
|
|
183
|
+
result = (_b = frame.subResults) !== null && _b !== void 0 ? _b : {};
|
|
184
|
+
}
|
|
185
|
+
else if (expression.value !== undefined) {
|
|
186
|
+
if (!(ctrl === null || ctrl === void 0 ? void 0 : ctrl.ignoreValue)) {
|
|
187
|
+
result = expression.value;
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
result = value;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
result = value;
|
|
195
|
+
}
|
|
196
|
+
if (ctrl === null || ctrl === void 0 ? void 0 : ctrl.result) {
|
|
197
|
+
if (!frame.ctrlData) {
|
|
198
|
+
frame.ctrlData = {};
|
|
199
|
+
}
|
|
200
|
+
result = yield ctrl.result(result, frame.ctrlData, expression, context);
|
|
201
|
+
}
|
|
202
|
+
if (context.frames.length - 1 === depth) {
|
|
203
|
+
context.frames.pop();
|
|
204
|
+
}
|
|
205
|
+
if (!isProtoExpressionControlFlowResult(result)) {
|
|
206
|
+
if (expression.invert && !(ctrl === null || ctrl === void 0 ? void 0 : ctrl.ignoreInvert)) {
|
|
207
|
+
result = !result;
|
|
208
|
+
}
|
|
209
|
+
if (expression.type && expression.name) {
|
|
210
|
+
if (this.log) {
|
|
211
|
+
this.log(`eval[${evalIndex}] - set[${expression.name}]`, result);
|
|
212
|
+
}
|
|
213
|
+
context.vars[expression.name] = result;
|
|
214
|
+
}
|
|
215
|
+
if (expression.setAs) {
|
|
216
|
+
if (this.log) {
|
|
217
|
+
this.log(`eval[${evalIndex}] - setAs[${expression.setAs}]`, result);
|
|
218
|
+
}
|
|
219
|
+
context.vars[expression.setAs] = result;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (this.log) {
|
|
223
|
+
this.log(`eval[${evalIndex}] - result:`, result);
|
|
224
|
+
}
|
|
225
|
+
if ((typeof result === 'string') && result.includes('{')) {
|
|
226
|
+
result = result.replace(/\{([\w.]+)\}/g, (_, path) => {
|
|
227
|
+
var _a;
|
|
228
|
+
const val = getProtoExpressionValueByPath(path, context);
|
|
229
|
+
if (this.log) {
|
|
230
|
+
this.log(`eval[${evalIndex}] - embed path: ${path}`, val);
|
|
231
|
+
}
|
|
232
|
+
return (_a = val === null || val === void 0 ? void 0 : val.toString()) !== null && _a !== void 0 ? _a : '';
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
return result;
|
|
236
|
+
});
|
|
237
|
+
this.context = Object.assign({ vars: {}, frames: [], evalCount: 0 }, deleteUndefined(Object.assign({}, context)));
|
|
238
|
+
this.cancelToken = cancel;
|
|
239
|
+
this.expression = expression;
|
|
240
|
+
this.callableExpressions = callableExpressions;
|
|
241
|
+
this.callables = callables;
|
|
242
|
+
}
|
|
243
|
+
get started() { return this._started; }
|
|
244
|
+
evalAsync() {
|
|
245
|
+
var _a, _b, _c;
|
|
246
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
247
|
+
if (this._started) {
|
|
248
|
+
throw new Error('ProtoExpressionEngine already started');
|
|
249
|
+
}
|
|
250
|
+
this._started = true;
|
|
251
|
+
this.context.startTime = Date.now();
|
|
252
|
+
if (this.log) {
|
|
253
|
+
this.log('_________________________________________________________________');
|
|
254
|
+
this.log(`\nStart eval - ${this.context.startTime}`);
|
|
255
|
+
}
|
|
256
|
+
try {
|
|
257
|
+
if (this.context.lastResumeId) {
|
|
258
|
+
this.context.frames = getProtoExpressionResumeFrames(this.context.lastResumeId, this.expression);
|
|
259
|
+
}
|
|
260
|
+
delete this.context.lastResumeId;
|
|
261
|
+
delete this.context.resumeAfter;
|
|
262
|
+
const result = yield this.evalExpression(this.expression, this.context, 0);
|
|
263
|
+
if (isProtoExpressionControlFlowResult(result)) {
|
|
264
|
+
const state = (result.complete ?
|
|
265
|
+
'complete'
|
|
266
|
+
: result.canceled ?
|
|
267
|
+
'canceled'
|
|
268
|
+
: result.error ?
|
|
269
|
+
'failed'
|
|
270
|
+
: result.resumeId ?
|
|
271
|
+
'paused'
|
|
272
|
+
:
|
|
273
|
+
'complete');
|
|
274
|
+
if (state === 'paused') {
|
|
275
|
+
this.context.lastResumeId = result.resumeId;
|
|
276
|
+
this.context.resumeAfter = result.resumeAfter;
|
|
277
|
+
}
|
|
278
|
+
if (this.log) {
|
|
279
|
+
this.log(`End eval - ${Date.now() - ((_a = this.context.startTime) !== null && _a !== void 0 ? _a : 0)}ms - ${state}`, result);
|
|
280
|
+
}
|
|
281
|
+
return {
|
|
282
|
+
state,
|
|
283
|
+
context: this.context,
|
|
284
|
+
value: state === 'complete' ? result.returnValue : undefined,
|
|
285
|
+
error: result.error,
|
|
286
|
+
errorMessage: result.errorMessage
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
if (this.log) {
|
|
291
|
+
this.log(`End eval - ${Date.now() - ((_b = this.context.startTime) !== null && _b !== void 0 ? _b : 0)}ms - complete`, result);
|
|
292
|
+
}
|
|
293
|
+
return {
|
|
294
|
+
state: 'complete',
|
|
295
|
+
context: this.context,
|
|
296
|
+
value: result
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
catch (ex) {
|
|
301
|
+
if (this.log) {
|
|
302
|
+
this.log(`End eval - ${Date.now() - ((_c = this.context.startTime) !== null && _c !== void 0 ? _c : 0)}ms - failed`, ex);
|
|
303
|
+
}
|
|
304
|
+
return {
|
|
305
|
+
state: 'failed',
|
|
306
|
+
context: this.context,
|
|
307
|
+
error: ex,
|
|
308
|
+
errorMessage: typeof (ex === null || ex === void 0 ? void 0 : ex.message) === 'string' ?
|
|
309
|
+
ex === null || ex === void 0 ? void 0 : ex.message : 'Expression failed'
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
finally {
|
|
313
|
+
if (this.log) {
|
|
314
|
+
this.log('eval context', this.context);
|
|
315
|
+
this.log('_________________________________________________________________');
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
export const getProtoExpressionResumeFrames = (id, expression) => {
|
|
322
|
+
const frames = [];
|
|
323
|
+
if (!_getProtoExpressionResumeFrames(id, expression, frames)) {
|
|
324
|
+
throw new UnableToFindProtoExpressionResumeId(`resumeId:${id}`);
|
|
325
|
+
}
|
|
326
|
+
return frames;
|
|
327
|
+
};
|
|
328
|
+
const _getProtoExpressionResumeFrames = (id, expression, frames, parentFrame) => {
|
|
329
|
+
var _a;
|
|
330
|
+
const frame = {};
|
|
331
|
+
frames.push(frame);
|
|
332
|
+
const ctrl = getProtoExpressionCtrl(expression.ctrl);
|
|
333
|
+
if ((_a = ctrl === null || ctrl === void 0 ? void 0 : ctrl.canResume) === null || _a === void 0 ? void 0 : _a.call(ctrl, id, expression)) {
|
|
334
|
+
if ((parentFrame === null || parentFrame === void 0 ? void 0 : parentFrame.sub) !== undefined) {
|
|
335
|
+
parentFrame.sub++;
|
|
336
|
+
}
|
|
337
|
+
frames.pop();
|
|
338
|
+
return true;
|
|
339
|
+
}
|
|
340
|
+
if (!(ctrl === null || ctrl === void 0 ? void 0 : ctrl.skipSubs) && expression.sub) {
|
|
341
|
+
if (frame.sub === undefined) {
|
|
342
|
+
frame.sub = 0;
|
|
343
|
+
}
|
|
344
|
+
for (; frame.sub < expression.sub.length; frame.sub++) {
|
|
345
|
+
const sub = expression.sub[frame.sub];
|
|
346
|
+
if (!sub) {
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
const found = _getProtoExpressionResumeFrames(id, sub, frames, frame);
|
|
350
|
+
if (found) {
|
|
351
|
+
return true;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
frames.pop();
|
|
356
|
+
return false;
|
|
357
|
+
};
|
|
358
|
+
//# sourceMappingURL=ProtoExpressionEngine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProtoExpressionEngine.js","sourceRoot":"","sources":["../../../../../../packages/protogen/src/lib/ProtoExpressionEngine.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAe,eAAe,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,gCAAgC,EAAE,mCAAmC,EAAE,mCAAmC,EAAE,sCAAsC,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAC9N,OAAO,EAAsK,kCAAkC,EA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IAAI,CAAE,QAAQ,CAAA,IAAI,UAAU,CAAC,GAAG,EAAC;QACjC,IAAG,KAAK,CAAC,GAAG,KAAG,SAAS,EAAC;YACrB,KAAK,CAAC,GAAG,GAAC,CAAC,CAAC;SACf;QACD,OAAK,KAAK,CAAC,GAAG,GAAC,UAAU,CAAC,GAAG,CAAC,MAAM,EAAC,KAAK,CAAC,GAAG,EAAE,EAAC;YAC7C,MAAM,GAAG,GAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACpC,IAAG,CAAC,GAAG,EAAC;gBACJ,SAAS;aACZ;YACD,MAAM,KAAK,GAAC,+BAA+B,CAAC,EAAE,EAAC,GAAG,EAAC,MAAM,EAAC,KAAK,CAAC,CAAC;YACjE,IAAG,KAAK,EAAC;gBACL,OAAO,IAAI,CAAC;aACf;SACJ;KACJ;IAED,MAAM,CAAC,GAAG,EAAE,CAAC;IACb,OAAO,KAAK,CAAC;AACjB,CAAC,CAAA"}
|
|
@@ -8,18 +8,21 @@ export const executeTGenPipelineAsync = ({ context, plugins, config }) => __awai
|
|
|
8
8
|
const log = context.log;
|
|
9
9
|
log(`\n--------------------------\nStart pipeline${config.dryRun ? ' ( DRY RUN )' : ''} - ${context.executionId}}`);
|
|
10
10
|
const runPluginsAsync = (stage) => __awaiter(void 0, void 0, void 0, function* () {
|
|
11
|
-
var _a;
|
|
11
|
+
var _a, _b;
|
|
12
12
|
context.stage = stage;
|
|
13
|
-
log(`\n## Stage ${stage}`);
|
|
13
|
+
log(`\n## Stage ${stage}${stage === 'generate' ? ` gen ${context.generationStage}` : ''}`);
|
|
14
14
|
for (const info of plugins) {
|
|
15
15
|
const plugin = info.plugin;
|
|
16
|
+
if (stage === 'generate' && ((_a = plugin.generationStage) !== null && _a !== void 0 ? _a : 0) !== context.generationStage) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
16
19
|
if (plugin.beforeEach) {
|
|
17
20
|
log(`beforeEach ${info.source}:${info.name}`);
|
|
18
21
|
yield plugin.beforeEach(context, getConfig(context, plugin), info);
|
|
19
22
|
}
|
|
20
23
|
if (plugin[stage]) {
|
|
21
24
|
log(`${stage} ${info.source}:${info.name}`);
|
|
22
|
-
yield ((
|
|
25
|
+
yield ((_b = plugin[stage]) === null || _b === void 0 ? void 0 : _b.call(plugin, context, getConfig(context, plugin), info));
|
|
23
26
|
}
|
|
24
27
|
if (plugin.afterEach) {
|
|
25
28
|
log(`afterEach ${info.source}:${info.name}`);
|
|
@@ -41,17 +44,25 @@ export const executeTGenPipelineAsync = ({ context, plugins, config }) => __awai
|
|
|
41
44
|
yield runPluginsAsync('input');
|
|
42
45
|
yield runPluginsAsync('preprocess');
|
|
43
46
|
yield runPluginsAsync('parse');
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
for (const plugin of plugins) {
|
|
48
|
+
if (plugin.plugin.setGenerationStage) {
|
|
49
|
+
plugin.plugin.generationStage = plugin.plugin.setGenerationStage(context, plugins);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
while (plugins.some(p => { var _a; return ((_a = p.plugin.generationStage) !== null && _a !== void 0 ? _a : 0) >= context.generationStage; })) {
|
|
53
|
+
yield runPluginsAsync('generate');
|
|
54
|
+
if (context.autoIndexPackages) {
|
|
55
|
+
for (let i = 0; i < context.outputs.length; i++) {
|
|
56
|
+
const out = context.outputs[i];
|
|
57
|
+
if (out && out.isPackageIndex && !out.isAutoPackageIndex) {
|
|
58
|
+
context.outputs.splice(i, 1);
|
|
59
|
+
i--;
|
|
60
|
+
}
|
|
51
61
|
}
|
|
52
62
|
}
|
|
63
|
+
yield runPluginsAsync('output');
|
|
64
|
+
context.generationStage++;
|
|
53
65
|
}
|
|
54
|
-
yield runPluginsAsync('output');
|
|
55
66
|
for (const info of plugins) {
|
|
56
67
|
if (info.plugin.afterAll) {
|
|
57
68
|
log(`afterAll ${info.source}:${info.name}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executeProtoPipelineAsync.js","sourceRoot":"","sources":["../../../../../../packages/protogen/src/lib/executeProtoPipelineAsync.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGvD,MAAM,SAAS,GAAC,CAAC,GAAgB,EAAC,MAA0B,EAAK,EAAE;IAC/D,MAAM,YAAY,GAAE,MAAmD,CAAC,YAAY,CAAC;IACrF,OAAO,YAAY,CAAA,CAAC,CAAA,gBAAgB,CAAC,YAAY,EAAC,GAAG,CAAC,IAAI,CAAC,CAAA,CAAC,CAAA,IAAI,CAAA;AACpE,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAC,CAAO,EACzC,OAAO,EACP,OAAO,EACP,MAAM,EACK,EAAe,EAAE;IAE5B,MAAM,GAAG,GAAC,OAAO,CAAC,GAAG,CAAC;IAEtB,GAAG,CAAC,+CAA+C,MAAM,CAAC,MAAM,CAAA,CAAC,CAAA,cAAc,CAAA,CAAC,CAAA,EAAE,MAAM,OAAO,CAAC,WAAW,GAAG,CAAC,CAAC;IAEhH,MAAM,eAAe,GAAC,CAAO,KAAgB,EAAC,EAAE;;QAC5C,OAAO,CAAC,KAAK,GAAC,KAAK,CAAC;QACpB,GAAG,CAAC,cAAc,KAAK,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"executeProtoPipelineAsync.js","sourceRoot":"","sources":["../../../../../../packages/protogen/src/lib/executeProtoPipelineAsync.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGvD,MAAM,SAAS,GAAC,CAAC,GAAgB,EAAC,MAA0B,EAAK,EAAE;IAC/D,MAAM,YAAY,GAAE,MAAmD,CAAC,YAAY,CAAC;IACrF,OAAO,YAAY,CAAA,CAAC,CAAA,gBAAgB,CAAC,YAAY,EAAC,GAAG,CAAC,IAAI,CAAC,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A,CAAC,CAAA,cAAc,CAAA,CAAC,CAAA,EAAE,MAAM,OAAO,CAAC,WAAW,gCAAgC,CAAC,CAAA;AAElH,CAAC,CAAA,CAAA"}
|
|
@@ -3,3 +3,4 @@ import { ProtoNode, ProtoNodeRenderData, ProtoParsingResult } from "./protogen-t
|
|
|
3
3
|
export declare const protoMarkdownGetIndent: (value: string) => string;
|
|
4
4
|
export declare const protoMarkdownParseNodes: (code: string, options?: ProtoNormalizeNodesOptions) => ProtoParsingResult;
|
|
5
5
|
export declare const protoMarkdownRenderer: (node: ProtoNode, renderData: ProtoNodeRenderData) => ProtoNodeRenderData;
|
|
6
|
+
export declare const removeProtoMarkdownBaseIndent: (md: string) => string;
|
package/esm/src/lib/markdown.js
CHANGED
|
@@ -91,6 +91,9 @@ export const protoMarkdownParseNodes = (code, options) => {
|
|
|
91
91
|
depth,
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
|
+
if (value.includes('=')) {
|
|
95
|
+
node.valueEq = true;
|
|
96
|
+
}
|
|
94
97
|
allNodes.push(node);
|
|
95
98
|
if (parent === null || parent === void 0 ? void 0 : parent.contentFocused) {
|
|
96
99
|
node.importantContent = true;
|
|
@@ -168,10 +171,11 @@ const getNodeValue = (content) => {
|
|
|
168
171
|
return content.substring(ei + 1).trim();
|
|
169
172
|
}
|
|
170
173
|
else {
|
|
171
|
-
return content;
|
|
174
|
+
return content.replace(/\(\w+\)/g, '').trim();
|
|
172
175
|
}
|
|
173
176
|
};
|
|
174
177
|
const parseTypesAndFlags = (rootNode, value) => {
|
|
178
|
+
var _a, _b;
|
|
175
179
|
const matches = value.matchAll(/([@>#~*?!= \t]+)?(\(?)[ \t]*([\w.\-[\]]+)(\)?)/g);
|
|
176
180
|
const flagsI = 1;
|
|
177
181
|
const tagOpenI = 2;
|
|
@@ -204,16 +208,20 @@ const parseTypesAndFlags = (rootNode, value) => {
|
|
|
204
208
|
path[0] = rootNode.name;
|
|
205
209
|
}
|
|
206
210
|
const name = path[0];
|
|
211
|
+
const flags = match[flagsI];
|
|
212
|
+
const eqType = flags === null || flags === void 0 ? void 0 : flags.includes('=');
|
|
207
213
|
const type = {
|
|
208
|
-
type: name,
|
|
209
|
-
isRefType: /[A-Z]/.test(name.charAt(0)),
|
|
214
|
+
type: eqType ? ((_b = (_a = types[0]) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : '') : name,
|
|
215
|
+
isRefType: eqType ? false : /[A-Z]/.test(name.charAt(0)),
|
|
210
216
|
path,
|
|
211
217
|
};
|
|
218
|
+
if (eqType) {
|
|
219
|
+
type.equals = true;
|
|
220
|
+
}
|
|
212
221
|
types.push(type);
|
|
213
222
|
if (isArray) {
|
|
214
223
|
type.isArray = true;
|
|
215
224
|
}
|
|
216
|
-
const flags = match[flagsI];
|
|
217
225
|
if (flags) {
|
|
218
226
|
if (flags.includes('*')) {
|
|
219
227
|
type.important = true;
|
|
@@ -236,9 +244,12 @@ const parseTypesAndFlags = (rootNode, value) => {
|
|
|
236
244
|
if (flags.includes('~')) {
|
|
237
245
|
type.less = true;
|
|
238
246
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
247
|
+
}
|
|
248
|
+
if (nameMatch.startsWith('.')) {
|
|
249
|
+
type.dot = true;
|
|
250
|
+
}
|
|
251
|
+
if (eqType) {
|
|
252
|
+
break;
|
|
242
253
|
}
|
|
243
254
|
}
|
|
244
255
|
if (!types.length) {
|
|
@@ -253,4 +264,22 @@ export const protoMarkdownRenderer = (node, renderData) => {
|
|
|
253
264
|
const input = `- ${node.name}${node.value ? ': ' + node.value : ''}`;
|
|
254
265
|
return Object.assign(Object.assign({}, renderData), { input });
|
|
255
266
|
};
|
|
267
|
+
export const removeProtoMarkdownBaseIndent = (md) => {
|
|
268
|
+
var _a, _b;
|
|
269
|
+
const lines = md.split('\n');
|
|
270
|
+
let indent = null;
|
|
271
|
+
for (let i = 0; i < lines.length; i++) {
|
|
272
|
+
const line = lines[i];
|
|
273
|
+
if (indent === null) {
|
|
274
|
+
if (!line.trim()) {
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
indent = (_b = (_a = /^(\s*)/.exec(line)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : '';
|
|
278
|
+
}
|
|
279
|
+
if (line.startsWith(indent)) {
|
|
280
|
+
lines[i] = line.substring(indent.length);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return lines.join('\n').trim();
|
|
284
|
+
};
|
|
256
285
|
//# sourceMappingURL=markdown.js.map
|