@routier/core 0.0.5 → 0.0.7
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/capabilities/Capability.d.ts +11 -0
- package/dist/capabilities/PerformanceCapability.d.ts +13 -0
- package/dist/capabilities/TracingCapability.d.ts +11 -0
- package/dist/capabilities/index.d.ts +4 -0
- package/dist/capabilities/index.js +763 -0
- package/dist/capabilities/index.js.map +1 -0
- package/dist/capabilities/performance/PerformanceTracker.d.ts +11 -0
- package/dist/capabilities/tracing/CallTraceManager.d.ts +12 -0
- package/dist/capabilities/types.d.ts +17 -0
- package/dist/codegen/blocks.d.ts +8 -0
- package/dist/codegen/handlers/CompareIdsHandlerBuilder.d.ts +4 -0
- package/dist/codegen/handlers/compare/CompareArrayHandler.d.ts +6 -0
- package/dist/codegen/handlers/compare/CompareDateHandler.d.ts +6 -0
- package/dist/codegen/handlers/compareIds/CompareIdsKeyHandler.d.ts +6 -0
- package/dist/codegen/handlers/index.d.ts +1 -0
- package/dist/codegen/handlers/serialize/SerializeDateHandler.d.ts +2 -1
- package/dist/codegen/handlers/serialize/SerializeFunctionHandler.d.ts +6 -0
- package/dist/codegen/index.js +660 -0
- package/dist/codegen/index.js.map +1 -0
- package/dist/collections/index.js.map +1 -1
- package/dist/expressions/index.js +108 -19
- package/dist/expressions/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1406 -602
- package/dist/index.js.map +1 -1
- package/dist/pipeline/WorkPipeline.test.d.ts +1 -0
- package/dist/pipeline/index.js.map +1 -1
- package/dist/plugins/EphemeralDataPlugin.d.ts +2 -2
- package/dist/plugins/EphemeralDataPlugin.test.d.ts +1 -0
- package/dist/plugins/index.d.ts +0 -1
- package/dist/plugins/index.js +244 -483
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/query/types.d.ts +5 -0
- package/dist/plugins/replication/OptimisticReplicationDbPlugin.d.ts +2 -1
- package/dist/plugins/replication/ReplicationDbPlugin.d.ts +2 -1
- package/dist/plugins/translators/DataTranslator.d.ts +3 -1
- package/dist/plugins/translators/JsonTranslator.d.ts +1 -0
- package/dist/plugins/translators/SqlTranslator.d.ts +1 -0
- package/dist/plugins/translators/TranslatedArrayValue.d.ts +6 -0
- package/dist/plugins/translators/TranslatedGroupValue.d.ts +6 -0
- package/dist/plugins/translators/TranslatedSingleValue.d.ts +6 -0
- package/dist/plugins/translators/index.d.ts +4 -0
- package/dist/plugins/translators/types.d.ts +10 -0
- package/dist/plugins/types.d.ts +2 -1
- package/dist/schema/PropertyInfo.d.ts +6 -1
- package/dist/schema/SchemaDefinition.d.ts +1 -1
- package/dist/schema/communication/broadcast.d.ts +3 -3
- package/dist/schema/index.js +508 -76
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/property/modifiers/SchemaTracked.d.ts +3 -1
- package/dist/schema/table/SchemaComputed.d.ts +1 -1
- package/dist/schema/testSchemas.test.d.ts +60 -36
- package/dist/schema/types.d.ts +16 -1
- package/dist/utilities/index.js +145 -2
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/strings.d.ts +34 -0
- package/dist/utilities/strings.test.d.ts +1 -0
- package/package.json +5 -1
- package/readme.md +1 -1
- package/dist/plugins/capabilities/DbPluginCapability.d.ts +0 -23
- package/dist/plugins/capabilities/index.d.ts +0 -2
- package/dist/plugins/capabilities/logging/DbPluginLoggingCapability.d.ts +0 -28
- package/dist/plugins/capabilities/logging/index.d.ts +0 -1
|
@@ -0,0 +1,660 @@
|
|
|
1
|
+
var __webpack_modules__ = ({
|
|
2
|
+
"./src/codegen/blocks.ts":
|
|
3
|
+
/*!*******************************!*\
|
|
4
|
+
!*** ./src/codegen/blocks.ts ***!
|
|
5
|
+
\*******************************/
|
|
6
|
+
(function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
7
|
+
__webpack_require__.r(__webpack_exports__);
|
|
8
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
9
|
+
AndBuilder: () => (AndBuilder),
|
|
10
|
+
ArrayBuilder: () => (ArrayBuilder),
|
|
11
|
+
AssignmentBuilder: () => (AssignmentBuilder),
|
|
12
|
+
Block: () => (Block),
|
|
13
|
+
CodeBuilder: () => (CodeBuilder),
|
|
14
|
+
ContainerBlock: () => (ContainerBlock),
|
|
15
|
+
FunctionBuilder: () => (FunctionBuilder),
|
|
16
|
+
FunctionFactoryBuilder: () => (FunctionFactoryBuilder),
|
|
17
|
+
IfBuilder: () => (IfBuilder),
|
|
18
|
+
ObjectBuilder: () => (ObjectBuilder),
|
|
19
|
+
RawBuilder: () => (RawBuilder),
|
|
20
|
+
SlotBlock: () => (SlotBlock),
|
|
21
|
+
StringBuilder: () => (StringBuilder),
|
|
22
|
+
VariableBuilder: () => (VariableBuilder)
|
|
23
|
+
});
|
|
24
|
+
/* ESM import */var _utilities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utilities */ "./src/utilities/uuid.ts");
|
|
25
|
+
|
|
26
|
+
class Block {
|
|
27
|
+
name;
|
|
28
|
+
_lines = [];
|
|
29
|
+
_indent = "";
|
|
30
|
+
_parent;
|
|
31
|
+
constructor(name, parentIndent = "", parent) {
|
|
32
|
+
this.name = name != null ? name : (0,_utilities__WEBPACK_IMPORTED_MODULE_0__.uuid)();
|
|
33
|
+
this._indent = parentIndent;
|
|
34
|
+
this._parent = parent;
|
|
35
|
+
}
|
|
36
|
+
indexOf(name) {
|
|
37
|
+
return this._lines.findIndex(w => typeof w !== "string" && w.name === name);
|
|
38
|
+
}
|
|
39
|
+
getLines() {
|
|
40
|
+
return this._lines;
|
|
41
|
+
}
|
|
42
|
+
getParent() {
|
|
43
|
+
return this._parent;
|
|
44
|
+
}
|
|
45
|
+
getIndent() {
|
|
46
|
+
return this._indent;
|
|
47
|
+
}
|
|
48
|
+
setLines(lines) {
|
|
49
|
+
this._lines = lines;
|
|
50
|
+
}
|
|
51
|
+
setParent(block) {
|
|
52
|
+
this._parent = block;
|
|
53
|
+
}
|
|
54
|
+
setIndent(indent) {
|
|
55
|
+
this._indent = indent;
|
|
56
|
+
}
|
|
57
|
+
getOrDefault(name) {
|
|
58
|
+
if (name.includes('.') === false) {
|
|
59
|
+
return this._lines.find(w => typeof w !== "string" && w.name === name);
|
|
60
|
+
}
|
|
61
|
+
const split = name.match(/(\[[^\]]+\]|[^.]+)/g);
|
|
62
|
+
let result = this;
|
|
63
|
+
for (const item of split) {
|
|
64
|
+
const found = result._lines.find(w => typeof w !== "string" && w.name === item);
|
|
65
|
+
if (found == null) {
|
|
66
|
+
if ("getValue" in result && result.getValue instanceof Block && result.getValue.name === item) {
|
|
67
|
+
result = result.getValue;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
result = found;
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
get(name) {
|
|
77
|
+
const found = this.getOrDefault(name);
|
|
78
|
+
if (found == null) {
|
|
79
|
+
throw new Error(`Error finding code block for given path. Path: ${name}`);
|
|
80
|
+
}
|
|
81
|
+
return found;
|
|
82
|
+
}
|
|
83
|
+
has(name) {
|
|
84
|
+
return this._lines.some(w => typeof w !== "string" && w.name === name);
|
|
85
|
+
}
|
|
86
|
+
remove(name) {
|
|
87
|
+
this._lines = this._lines.filter(x => typeof x === "object" && typeof x.name === "string" && x.name !== name);
|
|
88
|
+
}
|
|
89
|
+
replace(name, line) {
|
|
90
|
+
const foundIndex = this._lines.findIndex(x => typeof x !== "string" && x.name === name);
|
|
91
|
+
if (foundIndex === -1) {
|
|
92
|
+
throw new Error(`Cannot find line by name. Name: ${name}`);
|
|
93
|
+
}
|
|
94
|
+
const found = this._lines[foundIndex];
|
|
95
|
+
if (typeof found === "string") {
|
|
96
|
+
// Replace the line
|
|
97
|
+
this._lines.splice(foundIndex, 1, line);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
line.setLines(found.getLines());
|
|
101
|
+
line.setIndent(found.getIndent());
|
|
102
|
+
line.setParent(found.getParent());
|
|
103
|
+
// Replace the line
|
|
104
|
+
this._lines.splice(foundIndex, 1, line);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
push(line) {
|
|
108
|
+
this._lines.push(line);
|
|
109
|
+
}
|
|
110
|
+
unshift(line) {
|
|
111
|
+
this._lines.unshift(line);
|
|
112
|
+
}
|
|
113
|
+
indent(text) {
|
|
114
|
+
return this._indent + text;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
class ContainerBlock extends Block {
|
|
118
|
+
if(condition, options) {
|
|
119
|
+
const builder = new IfBuilder(condition, options?.name, this._indent + " ", this);
|
|
120
|
+
if (options?.unshift === true) {
|
|
121
|
+
this.unshift(builder);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
this.push(builder);
|
|
125
|
+
}
|
|
126
|
+
return builder;
|
|
127
|
+
}
|
|
128
|
+
raw(raw, options) {
|
|
129
|
+
const builder = new RawBuilder(raw, options?.name, this._indent + " ", this);
|
|
130
|
+
this.push(builder);
|
|
131
|
+
return builder;
|
|
132
|
+
}
|
|
133
|
+
function(name, options) {
|
|
134
|
+
const builder = new FunctionBuilder(name, options?.name, this._indent + " ", this);
|
|
135
|
+
this.push(builder);
|
|
136
|
+
return builder;
|
|
137
|
+
}
|
|
138
|
+
factory(name, options) {
|
|
139
|
+
const builder = new FunctionFactoryBuilder(name, options?.name, this._indent + " ", this);
|
|
140
|
+
this.push(builder);
|
|
141
|
+
return builder;
|
|
142
|
+
}
|
|
143
|
+
variable(declaration, options) {
|
|
144
|
+
const builder = new VariableBuilder(declaration, options?.name, this._indent + " ", this);
|
|
145
|
+
this.push(builder);
|
|
146
|
+
return builder;
|
|
147
|
+
}
|
|
148
|
+
assign(variableName, options) {
|
|
149
|
+
const builder = new AssignmentBuilder(variableName, options?.name, this._indent + " ", this);
|
|
150
|
+
this.push(builder);
|
|
151
|
+
return builder;
|
|
152
|
+
}
|
|
153
|
+
object(options) {
|
|
154
|
+
const builder = new ObjectBuilder(options?.name, this._indent + " ", this);
|
|
155
|
+
this.push(builder);
|
|
156
|
+
return builder;
|
|
157
|
+
}
|
|
158
|
+
slot(name) {
|
|
159
|
+
const builder = new SlotBlock(name, this._indent + " ", this);
|
|
160
|
+
this.push(builder);
|
|
161
|
+
return builder;
|
|
162
|
+
}
|
|
163
|
+
array(accessor, options) {
|
|
164
|
+
const builder = new ArrayBuilder(accessor, options?.name, this._indent + " ", this);
|
|
165
|
+
this.push(builder);
|
|
166
|
+
return builder;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
class StringBuilder extends Block {
|
|
170
|
+
_type;
|
|
171
|
+
constructor(type, name, parentIndent = "", parent) {
|
|
172
|
+
super(name, parentIndent, parent);
|
|
173
|
+
this._type = type;
|
|
174
|
+
}
|
|
175
|
+
append(value) {
|
|
176
|
+
this._lines.push(value);
|
|
177
|
+
return this;
|
|
178
|
+
}
|
|
179
|
+
toString() {
|
|
180
|
+
if (this._type === "template") {
|
|
181
|
+
return "`" + this._lines.join("") + "`";
|
|
182
|
+
}
|
|
183
|
+
return `"${this._lines.join("")}"`;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
class SlotBlock extends ContainerBlock {
|
|
187
|
+
constructor(name, parentIndent = "", parent) {
|
|
188
|
+
super(name, parentIndent, parent);
|
|
189
|
+
}
|
|
190
|
+
insert(line) {
|
|
191
|
+
this.push(line);
|
|
192
|
+
}
|
|
193
|
+
toString() {
|
|
194
|
+
return this._lines.map(line => typeof line === 'string'
|
|
195
|
+
? this.indent(line)
|
|
196
|
+
: line.toString()).join('\n\n');
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
class AssignmentBuilder extends ContainerBlock {
|
|
200
|
+
_variableName;
|
|
201
|
+
_value;
|
|
202
|
+
_functionName;
|
|
203
|
+
get getValue() {
|
|
204
|
+
return this._value;
|
|
205
|
+
}
|
|
206
|
+
constructor(variableName, name, parentIndent = "", parent) {
|
|
207
|
+
super(name, parentIndent, parent);
|
|
208
|
+
this._variableName = variableName;
|
|
209
|
+
}
|
|
210
|
+
value(value) {
|
|
211
|
+
this._value = value;
|
|
212
|
+
return this;
|
|
213
|
+
}
|
|
214
|
+
and(and, options) {
|
|
215
|
+
this._value = new AndBuilder(and, options?.name, this._indent, this);
|
|
216
|
+
return this;
|
|
217
|
+
}
|
|
218
|
+
object(options) {
|
|
219
|
+
const objectBuilder = new ObjectBuilder(options?.name, this._indent, this);
|
|
220
|
+
this._value = objectBuilder;
|
|
221
|
+
return objectBuilder;
|
|
222
|
+
}
|
|
223
|
+
call(functionName, options) {
|
|
224
|
+
this._functionName = functionName;
|
|
225
|
+
const objectBuilder = new ObjectBuilder(options?.name, this._indent, this);
|
|
226
|
+
this._value = objectBuilder;
|
|
227
|
+
return objectBuilder;
|
|
228
|
+
}
|
|
229
|
+
string(type, options) {
|
|
230
|
+
const stringBuilder = new StringBuilder(type, options?.name, this._indent, this);
|
|
231
|
+
this._value = stringBuilder;
|
|
232
|
+
return stringBuilder;
|
|
233
|
+
}
|
|
234
|
+
toString() {
|
|
235
|
+
if (this._value == null) {
|
|
236
|
+
throw new Error("Value cannot be null for AssignmentBuilder Builder");
|
|
237
|
+
}
|
|
238
|
+
if (this._functionName != null) {
|
|
239
|
+
return this.indent(`${this._variableName} = ${this._functionName}(${this._value.toString()});`);
|
|
240
|
+
}
|
|
241
|
+
return this.indent(`${this._variableName} = ${this._value.toString()};`);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
class AndBuilder extends ContainerBlock {
|
|
245
|
+
constructor(and, name, parentIndent = "", parent) {
|
|
246
|
+
super(name, parentIndent, parent);
|
|
247
|
+
this._lines.push(and);
|
|
248
|
+
}
|
|
249
|
+
and(and) {
|
|
250
|
+
this._lines.push(and);
|
|
251
|
+
}
|
|
252
|
+
toString() {
|
|
253
|
+
return this._lines.join(" && ");
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
class VariableBuilder extends Block {
|
|
257
|
+
_declaration;
|
|
258
|
+
_value;
|
|
259
|
+
get getValue() {
|
|
260
|
+
return this._value;
|
|
261
|
+
}
|
|
262
|
+
constructor(declaration, name, parentIndent = "", parent) {
|
|
263
|
+
super(name, parentIndent, parent);
|
|
264
|
+
this._declaration = declaration;
|
|
265
|
+
}
|
|
266
|
+
value(value) {
|
|
267
|
+
this._value = value;
|
|
268
|
+
return this;
|
|
269
|
+
}
|
|
270
|
+
object(options) {
|
|
271
|
+
const objectBuilder = new ObjectBuilder(options?.name, this._indent, this);
|
|
272
|
+
this._value = objectBuilder;
|
|
273
|
+
return objectBuilder;
|
|
274
|
+
}
|
|
275
|
+
array(accessor, options) {
|
|
276
|
+
const arrayBuilder = new ArrayBuilder(accessor, options?.name, this._indent, this);
|
|
277
|
+
this._value = arrayBuilder;
|
|
278
|
+
return arrayBuilder;
|
|
279
|
+
}
|
|
280
|
+
toString() {
|
|
281
|
+
if (this._value == null) {
|
|
282
|
+
throw new Error("Value cannot be null for Variable Builder");
|
|
283
|
+
}
|
|
284
|
+
return this.indent(`const ${this._declaration} = ${this._value.toString()};`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
class RawBuilder extends ContainerBlock {
|
|
288
|
+
_raw;
|
|
289
|
+
constructor(raw, name, parentIndent = "", parent) {
|
|
290
|
+
super(name, parentIndent, parent);
|
|
291
|
+
this._raw = raw;
|
|
292
|
+
}
|
|
293
|
+
toString() {
|
|
294
|
+
return `${this._raw}\n`;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
class ObjectBuilder extends Block {
|
|
298
|
+
property(line) {
|
|
299
|
+
// Add comma to previous line if it exists and isn't a brace
|
|
300
|
+
if (this._lines.length > 0) {
|
|
301
|
+
const lastLine = this._lines[this._lines.length - 1];
|
|
302
|
+
if (typeof lastLine === 'string' && !lastLine.endsWith("{")) {
|
|
303
|
+
this._lines[this._lines.length - 1] = lastLine + ",";
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
this.push(line);
|
|
307
|
+
return this;
|
|
308
|
+
}
|
|
309
|
+
nested(propertyName, name) {
|
|
310
|
+
const builder = new ObjectBuilder(name, this._indent + " ", this);
|
|
311
|
+
// Add comma to previous line if it exists and isn't a brace
|
|
312
|
+
if (this._lines.length > 0) {
|
|
313
|
+
const lastLine = this._lines[this._lines.length - 1];
|
|
314
|
+
if (typeof lastLine === 'string' && !lastLine.endsWith("{")) {
|
|
315
|
+
this._lines[this._lines.length - 1] = lastLine + ",";
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
// Add the property name and opening brace
|
|
319
|
+
this.push(`${propertyName}: {`);
|
|
320
|
+
// Add the nested builder
|
|
321
|
+
this.push(builder);
|
|
322
|
+
// Add the closing brace
|
|
323
|
+
this.push("}");
|
|
324
|
+
return builder;
|
|
325
|
+
}
|
|
326
|
+
toString() {
|
|
327
|
+
// Check if this is a nested object's content
|
|
328
|
+
const isNestedContent = this._parent instanceof ObjectBuilder;
|
|
329
|
+
if (isNestedContent) {
|
|
330
|
+
// For nested object contents, just return the lines
|
|
331
|
+
return this._lines.map(line => typeof line === 'string'
|
|
332
|
+
? this.indent(" " + line)
|
|
333
|
+
: line.toString()).join('\n');
|
|
334
|
+
}
|
|
335
|
+
// For root objects, include the braces
|
|
336
|
+
const lines = [
|
|
337
|
+
"{",
|
|
338
|
+
...this._lines.map(line => typeof line === 'string'
|
|
339
|
+
? this.indent(" " + line)
|
|
340
|
+
: line.toString()),
|
|
341
|
+
this.indent("}")
|
|
342
|
+
];
|
|
343
|
+
return lines.join('\n');
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
class FunctionFactoryBuilder extends ContainerBlock {
|
|
347
|
+
_functionName;
|
|
348
|
+
_params = [];
|
|
349
|
+
_return = false;
|
|
350
|
+
constructor(functionName, sectionName, parentIndent = "", parent) {
|
|
351
|
+
super(sectionName, parentIndent, parent);
|
|
352
|
+
this._functionName = functionName;
|
|
353
|
+
}
|
|
354
|
+
getParameters() {
|
|
355
|
+
return [...this._params];
|
|
356
|
+
}
|
|
357
|
+
createParameter(value) {
|
|
358
|
+
const name = `injection${this._params.length}`;
|
|
359
|
+
return {
|
|
360
|
+
name,
|
|
361
|
+
value
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
parameters(...params) {
|
|
365
|
+
this._params.push(...params);
|
|
366
|
+
return this;
|
|
367
|
+
}
|
|
368
|
+
return() {
|
|
369
|
+
this._return = true;
|
|
370
|
+
return this;
|
|
371
|
+
}
|
|
372
|
+
appendBody(line) {
|
|
373
|
+
this.push(line);
|
|
374
|
+
return this;
|
|
375
|
+
}
|
|
376
|
+
invoke() {
|
|
377
|
+
const body = this.toString();
|
|
378
|
+
const parameterNames = this._getParameterNames();
|
|
379
|
+
const parameterValues = this._getParameterValues();
|
|
380
|
+
return Function(...parameterNames, body)(...parameterValues);
|
|
381
|
+
}
|
|
382
|
+
_getParameterNames() {
|
|
383
|
+
return this._params.map(w => w.name).join(", ");
|
|
384
|
+
}
|
|
385
|
+
_getParameterValues() {
|
|
386
|
+
return this._params.map(w => w.value);
|
|
387
|
+
}
|
|
388
|
+
toString() {
|
|
389
|
+
const r = this._return === true ? "return " : "";
|
|
390
|
+
const signature = this._functionName
|
|
391
|
+
? `${r}function ${this._functionName}(${this._getParameterNames()})`
|
|
392
|
+
: `${r}function(${this._getParameterNames()})`;
|
|
393
|
+
const lines = [
|
|
394
|
+
this.indent(signature + " {"),
|
|
395
|
+
...this._lines.map(line => typeof line === 'string'
|
|
396
|
+
? this.indent(" " + line)
|
|
397
|
+
: line.toString()),
|
|
398
|
+
this.indent("}")
|
|
399
|
+
];
|
|
400
|
+
return lines.join('\n');
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
class FunctionBuilder extends ContainerBlock {
|
|
404
|
+
_functionName;
|
|
405
|
+
_params = [];
|
|
406
|
+
_return = false;
|
|
407
|
+
constructor(functionName, sectionName, parentIndent = "", parent) {
|
|
408
|
+
super(sectionName, parentIndent, parent);
|
|
409
|
+
this._functionName = functionName;
|
|
410
|
+
}
|
|
411
|
+
parameters(...params) {
|
|
412
|
+
this._params.push(...params);
|
|
413
|
+
return this;
|
|
414
|
+
}
|
|
415
|
+
return() {
|
|
416
|
+
this._return = true;
|
|
417
|
+
return this;
|
|
418
|
+
}
|
|
419
|
+
appendBody(line) {
|
|
420
|
+
this.push(line);
|
|
421
|
+
return this;
|
|
422
|
+
}
|
|
423
|
+
_getParameterKeys() {
|
|
424
|
+
return this._params.map(w => typeof w === "object" ? w.name : w).join(", ");
|
|
425
|
+
}
|
|
426
|
+
toCallable() {
|
|
427
|
+
return `${this._functionName}(${this._params.map(w => typeof w === "object" ? w.callName : w).join(", ")})`;
|
|
428
|
+
}
|
|
429
|
+
toString() {
|
|
430
|
+
const r = this._return === true ? "return " : "";
|
|
431
|
+
const signature = this._functionName
|
|
432
|
+
? `${r}function ${this._functionName}(${this._getParameterKeys()})`
|
|
433
|
+
: `${r}function(${this._getParameterKeys()})`;
|
|
434
|
+
const lines = [
|
|
435
|
+
this.indent(signature + " {"),
|
|
436
|
+
...this._lines.map(line => typeof line === 'string'
|
|
437
|
+
? this.indent(" " + line)
|
|
438
|
+
: line.toString()),
|
|
439
|
+
this.indent("}")
|
|
440
|
+
];
|
|
441
|
+
return lines.join('\n');
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
class ArrayBuilder extends Block {
|
|
445
|
+
constructor(accessor, name, parentIndent = "", parent) {
|
|
446
|
+
super(name, parentIndent, parent);
|
|
447
|
+
this._lines.push(accessor);
|
|
448
|
+
}
|
|
449
|
+
append(accessor) {
|
|
450
|
+
this._lines.push(accessor);
|
|
451
|
+
return this;
|
|
452
|
+
}
|
|
453
|
+
toString() {
|
|
454
|
+
return `[${this._lines.join(",")}]`;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
class IfBuilder extends ContainerBlock {
|
|
458
|
+
_condition;
|
|
459
|
+
constructor(condition, name, parentIndent = "", parent) {
|
|
460
|
+
super(name, parentIndent, parent);
|
|
461
|
+
this._condition = condition;
|
|
462
|
+
}
|
|
463
|
+
appendBody(line) {
|
|
464
|
+
this.push(line);
|
|
465
|
+
return this;
|
|
466
|
+
}
|
|
467
|
+
unshiftBody(line) {
|
|
468
|
+
this.unshift(line);
|
|
469
|
+
return this;
|
|
470
|
+
}
|
|
471
|
+
stringifyLine(line) {
|
|
472
|
+
if (typeof line === 'string') {
|
|
473
|
+
return this.indent(" " + line);
|
|
474
|
+
}
|
|
475
|
+
if (Array.isArray(line)) {
|
|
476
|
+
return line.join("\r\n");
|
|
477
|
+
}
|
|
478
|
+
return line.toString();
|
|
479
|
+
}
|
|
480
|
+
toString() {
|
|
481
|
+
// need to join with \r\n because we are not an object
|
|
482
|
+
const lines = [
|
|
483
|
+
this.indent(`if (${this._condition}) {`),
|
|
484
|
+
this._lines.map(x => this.stringifyLine(x)).join("\r\n"),
|
|
485
|
+
this.indent("}")
|
|
486
|
+
];
|
|
487
|
+
return lines.join("\n\n");
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
class CodeBuilder extends ContainerBlock {
|
|
491
|
+
toString() {
|
|
492
|
+
return this._lines.map(line => typeof line === 'string'
|
|
493
|
+
? this.indent(line)
|
|
494
|
+
: line.toString()).join('\n\n');
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
}),
|
|
500
|
+
"./src/utilities/uuid.ts":
|
|
501
|
+
/*!*******************************!*\
|
|
502
|
+
!*** ./src/utilities/uuid.ts ***!
|
|
503
|
+
\*******************************/
|
|
504
|
+
(function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
505
|
+
__webpack_require__.r(__webpack_exports__);
|
|
506
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
507
|
+
uuid: () => (uuid),
|
|
508
|
+
uuidv4: () => (uuidv4)
|
|
509
|
+
});
|
|
510
|
+
const uuid = (length = 16) => {
|
|
511
|
+
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
512
|
+
const charLength = chars.length;
|
|
513
|
+
let result = '';
|
|
514
|
+
for (let i = 0; i < length; i++) {
|
|
515
|
+
result += chars[Math.random() * charLength | 0];
|
|
516
|
+
}
|
|
517
|
+
return result;
|
|
518
|
+
};
|
|
519
|
+
const HEX_CHARS = '0123456789abcdef';
|
|
520
|
+
const UUID_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
|
|
521
|
+
const hasCrypto = typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function';
|
|
522
|
+
const uuidv4 = () => {
|
|
523
|
+
let randomBytes = null;
|
|
524
|
+
if (hasCrypto) {
|
|
525
|
+
randomBytes = crypto.getRandomValues(new Uint8Array(16));
|
|
526
|
+
}
|
|
527
|
+
let byteIndex = 0;
|
|
528
|
+
let uuid = '';
|
|
529
|
+
for (let i = 0; i < UUID_TEMPLATE.length; i++) {
|
|
530
|
+
const c = UUID_TEMPLATE[i];
|
|
531
|
+
if (c === '-') {
|
|
532
|
+
uuid += '-';
|
|
533
|
+
continue;
|
|
534
|
+
}
|
|
535
|
+
let r;
|
|
536
|
+
if (hasCrypto && randomBytes) {
|
|
537
|
+
// Each byte gives two hex digits (nibbles)
|
|
538
|
+
r =
|
|
539
|
+
(i % 2 === 0
|
|
540
|
+
? randomBytes[byteIndex] >> 4
|
|
541
|
+
: randomBytes[byteIndex++] & 0x0f);
|
|
542
|
+
}
|
|
543
|
+
else {
|
|
544
|
+
r = Math.floor(Math.random() * 16);
|
|
545
|
+
}
|
|
546
|
+
if (c === 'x') {
|
|
547
|
+
uuid += HEX_CHARS[r];
|
|
548
|
+
}
|
|
549
|
+
else if (c === 'y') {
|
|
550
|
+
// Variant bits: 8, 9, A, or B
|
|
551
|
+
uuid += HEX_CHARS[(r & 0x3) | 0x8];
|
|
552
|
+
}
|
|
553
|
+
else if (c === '4') {
|
|
554
|
+
uuid += '4';
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
return uuid;
|
|
558
|
+
};
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
}),
|
|
562
|
+
|
|
563
|
+
});
|
|
564
|
+
/************************************************************************/
|
|
565
|
+
// The module cache
|
|
566
|
+
var __webpack_module_cache__ = {};
|
|
567
|
+
|
|
568
|
+
// The require function
|
|
569
|
+
function __webpack_require__(moduleId) {
|
|
570
|
+
|
|
571
|
+
// Check if module is in cache
|
|
572
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
573
|
+
if (cachedModule !== undefined) {
|
|
574
|
+
return cachedModule.exports;
|
|
575
|
+
}
|
|
576
|
+
// Create a new module (and put it into the cache)
|
|
577
|
+
var module = (__webpack_module_cache__[moduleId] = {
|
|
578
|
+
exports: {}
|
|
579
|
+
});
|
|
580
|
+
// Execute the module function
|
|
581
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
582
|
+
|
|
583
|
+
// Return the exports of the module
|
|
584
|
+
return module.exports;
|
|
585
|
+
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/************************************************************************/
|
|
589
|
+
// webpack/runtime/define_property_getters
|
|
590
|
+
(() => {
|
|
591
|
+
__webpack_require__.d = (exports, definition) => {
|
|
592
|
+
for(var key in definition) {
|
|
593
|
+
if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
594
|
+
Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
};
|
|
598
|
+
})();
|
|
599
|
+
// webpack/runtime/has_own_property
|
|
600
|
+
(() => {
|
|
601
|
+
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
602
|
+
})();
|
|
603
|
+
// webpack/runtime/make_namespace_object
|
|
604
|
+
(() => {
|
|
605
|
+
// define __esModule on exports
|
|
606
|
+
__webpack_require__.r = (exports) => {
|
|
607
|
+
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
608
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
609
|
+
}
|
|
610
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
611
|
+
};
|
|
612
|
+
})();
|
|
613
|
+
/************************************************************************/
|
|
614
|
+
var __webpack_exports__ = {};
|
|
615
|
+
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
|
|
616
|
+
(() => {
|
|
617
|
+
|
|
618
|
+
/*!******************************!*\
|
|
619
|
+
!*** ./src/codegen/index.ts ***!
|
|
620
|
+
\******************************/
|
|
621
|
+
__webpack_require__.r(__webpack_exports__);
|
|
622
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
623
|
+
AndBuilder: () => (/* reexport safe */ _blocks__WEBPACK_IMPORTED_MODULE_0__.AndBuilder),
|
|
624
|
+
ArrayBuilder: () => (/* reexport safe */ _blocks__WEBPACK_IMPORTED_MODULE_0__.ArrayBuilder),
|
|
625
|
+
AssignmentBuilder: () => (/* reexport safe */ _blocks__WEBPACK_IMPORTED_MODULE_0__.AssignmentBuilder),
|
|
626
|
+
Block: () => (/* reexport safe */ _blocks__WEBPACK_IMPORTED_MODULE_0__.Block),
|
|
627
|
+
CodeBuilder: () => (/* reexport safe */ _blocks__WEBPACK_IMPORTED_MODULE_0__.CodeBuilder),
|
|
628
|
+
ContainerBlock: () => (/* reexport safe */ _blocks__WEBPACK_IMPORTED_MODULE_0__.ContainerBlock),
|
|
629
|
+
FunctionBuilder: () => (/* reexport safe */ _blocks__WEBPACK_IMPORTED_MODULE_0__.FunctionBuilder),
|
|
630
|
+
FunctionFactoryBuilder: () => (/* reexport safe */ _blocks__WEBPACK_IMPORTED_MODULE_0__.FunctionFactoryBuilder),
|
|
631
|
+
IfBuilder: () => (/* reexport safe */ _blocks__WEBPACK_IMPORTED_MODULE_0__.IfBuilder),
|
|
632
|
+
ObjectBuilder: () => (/* reexport safe */ _blocks__WEBPACK_IMPORTED_MODULE_0__.ObjectBuilder),
|
|
633
|
+
RawBuilder: () => (/* reexport safe */ _blocks__WEBPACK_IMPORTED_MODULE_0__.RawBuilder),
|
|
634
|
+
SlotBlock: () => (/* reexport safe */ _blocks__WEBPACK_IMPORTED_MODULE_0__.SlotBlock),
|
|
635
|
+
StringBuilder: () => (/* reexport safe */ _blocks__WEBPACK_IMPORTED_MODULE_0__.StringBuilder),
|
|
636
|
+
VariableBuilder: () => (/* reexport safe */ _blocks__WEBPACK_IMPORTED_MODULE_0__.VariableBuilder)
|
|
637
|
+
});
|
|
638
|
+
/* ESM import */var _blocks__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./blocks */ "./src/codegen/blocks.ts");
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
})();
|
|
643
|
+
|
|
644
|
+
var __webpack_exports__AndBuilder = __webpack_exports__.AndBuilder;
|
|
645
|
+
var __webpack_exports__ArrayBuilder = __webpack_exports__.ArrayBuilder;
|
|
646
|
+
var __webpack_exports__AssignmentBuilder = __webpack_exports__.AssignmentBuilder;
|
|
647
|
+
var __webpack_exports__Block = __webpack_exports__.Block;
|
|
648
|
+
var __webpack_exports__CodeBuilder = __webpack_exports__.CodeBuilder;
|
|
649
|
+
var __webpack_exports__ContainerBlock = __webpack_exports__.ContainerBlock;
|
|
650
|
+
var __webpack_exports__FunctionBuilder = __webpack_exports__.FunctionBuilder;
|
|
651
|
+
var __webpack_exports__FunctionFactoryBuilder = __webpack_exports__.FunctionFactoryBuilder;
|
|
652
|
+
var __webpack_exports__IfBuilder = __webpack_exports__.IfBuilder;
|
|
653
|
+
var __webpack_exports__ObjectBuilder = __webpack_exports__.ObjectBuilder;
|
|
654
|
+
var __webpack_exports__RawBuilder = __webpack_exports__.RawBuilder;
|
|
655
|
+
var __webpack_exports__SlotBlock = __webpack_exports__.SlotBlock;
|
|
656
|
+
var __webpack_exports__StringBuilder = __webpack_exports__.StringBuilder;
|
|
657
|
+
var __webpack_exports__VariableBuilder = __webpack_exports__.VariableBuilder;
|
|
658
|
+
export { __webpack_exports__AndBuilder as AndBuilder, __webpack_exports__ArrayBuilder as ArrayBuilder, __webpack_exports__AssignmentBuilder as AssignmentBuilder, __webpack_exports__Block as Block, __webpack_exports__CodeBuilder as CodeBuilder, __webpack_exports__ContainerBlock as ContainerBlock, __webpack_exports__FunctionBuilder as FunctionBuilder, __webpack_exports__FunctionFactoryBuilder as FunctionFactoryBuilder, __webpack_exports__IfBuilder as IfBuilder, __webpack_exports__ObjectBuilder as ObjectBuilder, __webpack_exports__RawBuilder as RawBuilder, __webpack_exports__SlotBlock as SlotBlock, __webpack_exports__StringBuilder as StringBuilder, __webpack_exports__VariableBuilder as VariableBuilder };
|
|
659
|
+
|
|
660
|
+
//# sourceMappingURL=index.js.map
|