@luna-park/plugin 1.4.2 → 1.5.0
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/{dist-hc-SHkAg.mjs → dist-JzydDdZn.mjs} +97 -95
- package/dist/extractor.d.mts +6 -8
- package/dist/extractor.mjs +3 -4
- package/dist/{index-X3hhfmWd.d.mts → index-DwEOlEBY.d.mts} +75 -44
- package/dist/index.d.mts +616 -524
- package/dist/index.mjs +124 -70
- package/dist/preview.d.mts +2 -3
- package/package.json +25 -25
|
@@ -92,99 +92,99 @@ const LogicType = {
|
|
|
92
92
|
return {
|
|
93
93
|
...args,
|
|
94
94
|
items,
|
|
95
|
-
type:
|
|
95
|
+
type: "array"
|
|
96
96
|
};
|
|
97
97
|
},
|
|
98
98
|
boolean: (args = {}) => {
|
|
99
99
|
return {
|
|
100
100
|
...args,
|
|
101
|
-
type:
|
|
101
|
+
type: "boolean"
|
|
102
102
|
};
|
|
103
103
|
},
|
|
104
104
|
exec: (args = {}) => {
|
|
105
105
|
return {
|
|
106
106
|
...args,
|
|
107
|
-
type:
|
|
108
|
-
};
|
|
109
|
-
},
|
|
110
|
-
function: (inputs = {
|
|
111
|
-
properties: {},
|
|
112
|
-
type: EVarType.object
|
|
113
|
-
}, output = { type: EVarType.void }, args = {}) => {
|
|
114
|
-
return {
|
|
115
|
-
...args,
|
|
116
|
-
inputs,
|
|
117
|
-
output,
|
|
118
|
-
type: EVarType.function
|
|
107
|
+
type: "exec"
|
|
119
108
|
};
|
|
120
109
|
},
|
|
110
|
+
function: createFunction,
|
|
121
111
|
interface: (interfaceClass, args = {}) => {
|
|
122
112
|
return {
|
|
123
113
|
...args,
|
|
124
114
|
className: typeof interfaceClass === "string" ? interfaceClass : interfaceClass.name,
|
|
125
|
-
type:
|
|
115
|
+
type: "interface"
|
|
126
116
|
};
|
|
127
117
|
},
|
|
128
118
|
number: (args = {}) => {
|
|
129
119
|
return {
|
|
130
120
|
...args,
|
|
131
|
-
type:
|
|
121
|
+
type: "number"
|
|
132
122
|
};
|
|
133
123
|
},
|
|
134
124
|
object: (properties = {}, args = {}) => {
|
|
135
125
|
return {
|
|
136
126
|
...args,
|
|
137
127
|
properties,
|
|
138
|
-
type:
|
|
128
|
+
type: "object"
|
|
139
129
|
};
|
|
140
130
|
},
|
|
141
131
|
record: (key, value, args = {}) => {
|
|
142
132
|
return {
|
|
143
133
|
...args,
|
|
144
134
|
key,
|
|
145
|
-
type:
|
|
135
|
+
type: "record",
|
|
146
136
|
value
|
|
147
137
|
};
|
|
148
138
|
},
|
|
149
139
|
string: (args = {}) => {
|
|
150
140
|
return {
|
|
151
141
|
...args,
|
|
152
|
-
type:
|
|
153
|
-
};
|
|
154
|
-
},
|
|
155
|
-
type: (target, args = {}) => {
|
|
156
|
-
return {
|
|
157
|
-
...args,
|
|
158
|
-
target,
|
|
159
|
-
type: EVarType.type
|
|
142
|
+
type: "string"
|
|
160
143
|
};
|
|
161
144
|
},
|
|
145
|
+
type: createType,
|
|
162
146
|
undefined: (args = {}) => {
|
|
163
147
|
return {
|
|
164
148
|
...args,
|
|
165
|
-
type:
|
|
149
|
+
type: "undefined"
|
|
166
150
|
};
|
|
167
151
|
},
|
|
168
152
|
union: (elements, args = {}) => {
|
|
169
153
|
return {
|
|
170
154
|
...args,
|
|
171
155
|
elements,
|
|
172
|
-
type:
|
|
156
|
+
type: "union"
|
|
173
157
|
};
|
|
174
158
|
},
|
|
175
159
|
unknown: (args = {}) => {
|
|
176
160
|
return {
|
|
177
161
|
...args,
|
|
178
|
-
type:
|
|
162
|
+
type: "unknown"
|
|
179
163
|
};
|
|
180
164
|
},
|
|
181
165
|
void: (args = {}) => {
|
|
182
166
|
return {
|
|
183
167
|
...args,
|
|
184
|
-
type:
|
|
168
|
+
type: "void"
|
|
185
169
|
};
|
|
186
170
|
}
|
|
187
171
|
};
|
|
172
|
+
function createFunction(inputs = [], output = LogicType.void(), args = {}) {
|
|
173
|
+
if (Array.isArray(inputs)) return createFunction(LogicType.object(Object.fromEntries(inputs)), output, args);
|
|
174
|
+
return {
|
|
175
|
+
...args,
|
|
176
|
+
inputs,
|
|
177
|
+
output,
|
|
178
|
+
type: "function"
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
function createType(target, args = {}) {
|
|
182
|
+
return {
|
|
183
|
+
...args,
|
|
184
|
+
target,
|
|
185
|
+
type: "type"
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
188
|
const LogicUtil = {
|
|
189
189
|
omit(target, keys) {
|
|
190
190
|
return {
|
|
@@ -239,44 +239,6 @@ let ELogicScope = /* @__PURE__ */ function(ELogicScope) {
|
|
|
239
239
|
function makeLogicNode(node) {
|
|
240
240
|
return node;
|
|
241
241
|
}
|
|
242
|
-
function scanner(input) {
|
|
243
|
-
const elements = [];
|
|
244
|
-
input = input.replaceAll(/ +/g, " ");
|
|
245
|
-
input = input.replaceAll(/\s*\n\s*/g, "\n");
|
|
246
|
-
while (input.length) {
|
|
247
|
-
if ([" ", "\n"].includes(input[0])) {
|
|
248
|
-
input = input.slice(1);
|
|
249
|
-
continue;
|
|
250
|
-
}
|
|
251
|
-
if (input.startsWith("/*")) {
|
|
252
|
-
const commentEnd = input.indexOf("*/");
|
|
253
|
-
elements.push(input.slice(0, commentEnd + 2));
|
|
254
|
-
input = input.slice(commentEnd + 2);
|
|
255
|
-
continue;
|
|
256
|
-
}
|
|
257
|
-
const startingWord = input.match(/^([a-zA-Z_][a-zA-Z0-9_.]*)/)?.[0];
|
|
258
|
-
if (startingWord) {
|
|
259
|
-
input = input.slice(startingWord.length);
|
|
260
|
-
elements.push(startingWord);
|
|
261
|
-
continue;
|
|
262
|
-
}
|
|
263
|
-
const startingNumber = input.match(/^([0-9]+)/)?.[0];
|
|
264
|
-
if (startingNumber) {
|
|
265
|
-
input = input.slice(startingNumber.length);
|
|
266
|
-
elements.push(startingNumber);
|
|
267
|
-
continue;
|
|
268
|
-
}
|
|
269
|
-
if (input[0] === ">" && elements.at(-1) === "=") {
|
|
270
|
-
elements.pop();
|
|
271
|
-
elements.push("=>");
|
|
272
|
-
input = input.slice(1);
|
|
273
|
-
continue;
|
|
274
|
-
}
|
|
275
|
-
elements.push(input[0]);
|
|
276
|
-
input = input.slice(1);
|
|
277
|
-
}
|
|
278
|
-
return elements;
|
|
279
|
-
}
|
|
280
242
|
const wrappers = [
|
|
281
243
|
["(", ")"],
|
|
282
244
|
["[", "]"],
|
|
@@ -332,8 +294,8 @@ function getFirstElement(scan) {
|
|
|
332
294
|
exportFlag = true;
|
|
333
295
|
element = scan.shift();
|
|
334
296
|
if (element === "=") return {
|
|
335
|
-
|
|
336
|
-
|
|
297
|
+
content: scan.shift(),
|
|
298
|
+
type: "export"
|
|
337
299
|
};
|
|
338
300
|
if (element === "as") {
|
|
339
301
|
eraseUntil(scan, ";");
|
|
@@ -347,10 +309,10 @@ function getFirstElement(scan) {
|
|
|
347
309
|
const content = splitUntil(getUntil(scan, "}", 0), ";");
|
|
348
310
|
scan.unshift(";");
|
|
349
311
|
return {
|
|
350
|
-
name,
|
|
351
|
-
type: element,
|
|
352
312
|
content,
|
|
353
|
-
export: exportFlag
|
|
313
|
+
export: exportFlag,
|
|
314
|
+
name,
|
|
315
|
+
type: element
|
|
354
316
|
};
|
|
355
317
|
}
|
|
356
318
|
if (element === "function") {
|
|
@@ -380,9 +342,9 @@ function getFirstElement(scan) {
|
|
|
380
342
|
const content = splitUntil(getUntil(scan, "}", 0), ";");
|
|
381
343
|
scan.unshift(";");
|
|
382
344
|
return {
|
|
345
|
+
content,
|
|
383
346
|
name,
|
|
384
|
-
type: "interface"
|
|
385
|
-
content
|
|
347
|
+
type: "interface"
|
|
386
348
|
};
|
|
387
349
|
}
|
|
388
350
|
if (element === "type" && /^[A-Za-z0-9]*$/.test(scan[0])) {
|
|
@@ -407,24 +369,24 @@ function getFirstElement(scan) {
|
|
|
407
369
|
scan.unshift(";");
|
|
408
370
|
return {
|
|
409
371
|
name,
|
|
410
|
-
type: "enum",
|
|
411
372
|
options: Object.fromEntries(content.join("").split(",").filter((item) => item.trim()).map((item) => {
|
|
412
373
|
if (item.includes("=")) {
|
|
413
374
|
const [name, value] = item.split("=");
|
|
414
375
|
return [JSON.parse(value), name];
|
|
415
376
|
}
|
|
416
377
|
return [name, name];
|
|
417
|
-
}))
|
|
378
|
+
})),
|
|
379
|
+
type: "enum"
|
|
418
380
|
};
|
|
419
381
|
}
|
|
420
382
|
if (typeof element === "string" && element.startsWith("/*")) return {
|
|
421
|
-
|
|
422
|
-
|
|
383
|
+
content: cleanComment(element),
|
|
384
|
+
type: "comment"
|
|
423
385
|
};
|
|
424
386
|
for (const wrapper of wrappers) if (element === wrapper[0]) return {
|
|
425
|
-
type: "wrap",
|
|
426
387
|
content: splitUntil(getUntil(scan, wrapper[1]), ";").map((item) => splitUntil(item, ",")).map((item) => splitUntil(item, "|")),
|
|
427
|
-
style: wrapper.join("")
|
|
388
|
+
style: wrapper.join(""),
|
|
389
|
+
type: "wrap"
|
|
428
390
|
};
|
|
429
391
|
return element;
|
|
430
392
|
}
|
|
@@ -447,32 +409,32 @@ function cleanComment(comment) {
|
|
|
447
409
|
return comment.trim();
|
|
448
410
|
}
|
|
449
411
|
function cleanUnion(schema) {
|
|
450
|
-
if (schema.elements.find((element) => [
|
|
412
|
+
if (schema.elements.find((element) => ["undefined", "void"].includes(element.type))) {
|
|
451
413
|
schema.optional = true;
|
|
452
|
-
schema.elements = schema.elements.filter((element) => ![
|
|
414
|
+
schema.elements = schema.elements.filter((element) => !["undefined", "void"].includes(element.type));
|
|
453
415
|
}
|
|
454
|
-
const childUnions = schema.elements.filter((element) => element.type ===
|
|
416
|
+
const childUnions = schema.elements.filter((element) => element.type === "union");
|
|
455
417
|
if (childUnions.length > 0) {
|
|
456
|
-
schema.elements = schema.elements.filter((element) => element.type !==
|
|
418
|
+
schema.elements = schema.elements.filter((element) => element.type !== "union");
|
|
457
419
|
for (const childUnion of childUnions) schema.elements.push(...childUnion.elements);
|
|
458
420
|
}
|
|
459
|
-
const stringElements = schema.elements.filter((element) => element.type ===
|
|
421
|
+
const stringElements = schema.elements.filter((element) => element.type === "string");
|
|
460
422
|
if (stringElements.length > 1) {
|
|
461
423
|
const enumValues = [];
|
|
462
424
|
let anyFlag = false;
|
|
463
425
|
for (const element of stringElements) if (element.enum) enumValues.push(...element.enum);
|
|
464
426
|
else anyFlag = true;
|
|
465
|
-
schema.elements = schema.elements.filter((element) => element.type !==
|
|
427
|
+
schema.elements = schema.elements.filter((element) => element.type !== "string");
|
|
466
428
|
if (anyFlag) schema.elements.push(LogicType.string());
|
|
467
429
|
else schema.elements.push(LogicType.string({ enum: enumValues }));
|
|
468
430
|
}
|
|
469
|
-
const numberElements = schema.elements.filter((element) => element.type ===
|
|
431
|
+
const numberElements = schema.elements.filter((element) => element.type === "number");
|
|
470
432
|
if (numberElements.length > 1) {
|
|
471
433
|
const enumValues = [];
|
|
472
434
|
let anyFlag = false;
|
|
473
435
|
for (const element of numberElements) if (element.enum) enumValues.push(...element.enum);
|
|
474
436
|
else anyFlag = true;
|
|
475
|
-
schema.elements = schema.elements.filter((element) => element.type !==
|
|
437
|
+
schema.elements = schema.elements.filter((element) => element.type !== "number");
|
|
476
438
|
if (anyFlag) schema.elements.push(LogicType.number());
|
|
477
439
|
else schema.elements.push(LogicType.number({ enum: enumValues }));
|
|
478
440
|
}
|
|
@@ -497,6 +459,44 @@ function cleanInterface(schema) {
|
|
|
497
459
|
if (["Omit", "Pick"].includes(schema.className)) return LogicUtil[schema.className.toLocaleLowerCase()](schema.options.template[0], schema.options.template[1]?.enum);
|
|
498
460
|
return schema;
|
|
499
461
|
}
|
|
462
|
+
function scanner(input) {
|
|
463
|
+
const elements = [];
|
|
464
|
+
input = input.replaceAll(/ +/g, " ");
|
|
465
|
+
input = input.replaceAll(/\s*\n\s*/g, "\n");
|
|
466
|
+
while (input.length) {
|
|
467
|
+
if ([" ", "\n"].includes(input[0])) {
|
|
468
|
+
input = input.slice(1);
|
|
469
|
+
continue;
|
|
470
|
+
}
|
|
471
|
+
if (input.startsWith("/*")) {
|
|
472
|
+
const commentEnd = input.indexOf("*/");
|
|
473
|
+
elements.push(input.slice(0, commentEnd + 2));
|
|
474
|
+
input = input.slice(commentEnd + 2);
|
|
475
|
+
continue;
|
|
476
|
+
}
|
|
477
|
+
const startingWord = input.match(/^([a-zA-Z_][a-zA-Z0-9_.]*)/)?.[0];
|
|
478
|
+
if (startingWord) {
|
|
479
|
+
input = input.slice(startingWord.length);
|
|
480
|
+
elements.push(startingWord);
|
|
481
|
+
continue;
|
|
482
|
+
}
|
|
483
|
+
const startingNumber = input.match(/^([0-9]+)/)?.[0];
|
|
484
|
+
if (startingNumber) {
|
|
485
|
+
input = input.slice(startingNumber.length);
|
|
486
|
+
elements.push(startingNumber);
|
|
487
|
+
continue;
|
|
488
|
+
}
|
|
489
|
+
if (input[0] === ">" && elements.at(-1) === "=") {
|
|
490
|
+
elements.pop();
|
|
491
|
+
elements.push("=>");
|
|
492
|
+
input = input.slice(1);
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
elements.push(input[0]);
|
|
496
|
+
input = input.slice(1);
|
|
497
|
+
}
|
|
498
|
+
return elements;
|
|
499
|
+
}
|
|
500
500
|
function parser(element, options = {}) {
|
|
501
501
|
if (typeof element === "string") {
|
|
502
502
|
if (element === "string") return LogicType.string(options);
|
|
@@ -519,8 +519,10 @@ function parser(element, options = {}) {
|
|
|
519
519
|
if (element[1].style === "<>") {
|
|
520
520
|
let template = element[1].content;
|
|
521
521
|
if (!Array.isArray(template)) template = [template];
|
|
522
|
-
if (!Array.isArray(template[0]))
|
|
523
|
-
|
|
522
|
+
if (!Array.isArray(template[0])) {
|
|
523
|
+
if (template.some((element) => element.type === "wrap" && element.style === "[]") || template.some((element) => element.type === "wrap" && element.style === "<>") || template.includes("&") || template.includes("|")) template = [template];
|
|
524
|
+
else template = template.map((element) => [element]);
|
|
525
|
+
}
|
|
524
526
|
template = template.map((element) => parser(element));
|
|
525
527
|
return cleanInterface(LogicType.interface(element[0], {
|
|
526
528
|
...options,
|
|
@@ -587,13 +589,13 @@ function schemaLoop(schema, func, key) {
|
|
|
587
589
|
key,
|
|
588
590
|
schema
|
|
589
591
|
}) || schema;
|
|
590
|
-
if (schema.type ===
|
|
591
|
-
if (schema.type ===
|
|
592
|
-
if (schema.type ===
|
|
592
|
+
if (schema.type === "object") for (const key in schema.properties) schema.properties[key] = schemaLoop(schema.properties[key], func, key);
|
|
593
|
+
if (schema.type === "array") schema.items = schemaLoop(schema.items, func);
|
|
594
|
+
if (schema.type === "function") {
|
|
593
595
|
schema.inputs = schemaLoop(schema.inputs, func);
|
|
594
596
|
schema.output = schemaLoop(schema.output, func);
|
|
595
597
|
}
|
|
596
|
-
if (schema.type ===
|
|
598
|
+
if (schema.type === "union") for (const key in schema.elements) schema.elements[key] = schemaLoop(schema.elements[key], func);
|
|
597
599
|
return schema;
|
|
598
600
|
}
|
|
599
601
|
//#endregion
|
package/dist/extractor.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { l as TSchema } from "./index-
|
|
1
|
+
import { l as TSchema } from "./index-DwEOlEBY.mjs";
|
|
2
2
|
import * as ts$1 from "typescript";
|
|
3
3
|
import ts from "typescript";
|
|
4
|
-
|
|
5
4
|
//#region src/extractor/export/type.d.ts
|
|
6
5
|
type TExportResult = {
|
|
7
6
|
components: Record<string, TExportComponent>;
|
|
@@ -38,7 +37,7 @@ type TExportType = {
|
|
|
38
37
|
};
|
|
39
38
|
//#endregion
|
|
40
39
|
//#region src/extractor/export/index.d.ts
|
|
41
|
-
declare class CTypeExport {
|
|
40
|
+
export declare class CTypeExport {
|
|
42
41
|
program: ts.Program;
|
|
43
42
|
checker: ts.TypeChecker;
|
|
44
43
|
index?: ts.SourceFile;
|
|
@@ -71,15 +70,14 @@ type TExportLogicResult = {
|
|
|
71
70
|
functions: Record<string, TExportNodeFunction>;
|
|
72
71
|
types: Record<string, TSchema>;
|
|
73
72
|
};
|
|
74
|
-
declare function generateNodes(exportResult: TExportResult, packageName?: string): TExportLogicResult;
|
|
73
|
+
export declare function generateNodes(exportResult: TExportResult, packageName?: string): TExportLogicResult;
|
|
75
74
|
//#endregion
|
|
76
75
|
//#region src/extractor/source.d.ts
|
|
77
|
-
declare function getSourceFile(moduleName: string): {
|
|
76
|
+
export declare function getSourceFile(moduleName: string): {
|
|
78
77
|
program: ts$1.Program;
|
|
79
78
|
sourceFile: ts$1.SourceFile;
|
|
80
79
|
};
|
|
81
80
|
//#endregion
|
|
82
81
|
//#region src/extractor/index.d.ts
|
|
83
|
-
declare function extractFile(filePath: string, target: string): Promise<void>;
|
|
84
|
-
//#endregion
|
|
85
|
-
export { CTypeExport, extractFile, generateNodes, getSourceFile };
|
|
82
|
+
export declare function extractFile(filePath: string, target: string): Promise<void>;
|
|
83
|
+
//#endregion
|
package/dist/extractor.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as typeToSchema, d as objectMap, i as LogicType, l as cleanObject, r as EVarType, s as schemaLoop } from "./dist-
|
|
1
|
+
import { c as typeToSchema, d as objectMap, i as LogicType, l as cleanObject, r as EVarType, s as schemaLoop } from "./dist-JzydDdZn.mjs";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import * as ts$1 from "typescript";
|
|
4
4
|
import ts from "typescript";
|
|
@@ -233,6 +233,7 @@ function isUserType(type) {
|
|
|
233
233
|
//#region src/extractor/export/index.ts
|
|
234
234
|
const FLAGS = ts.TypeFormatFlags.WriteArrowStyleSignature | ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope | ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.UseFullyQualifiedType;
|
|
235
235
|
var CTypeExport = class {
|
|
236
|
+
program;
|
|
236
237
|
checker;
|
|
237
238
|
index;
|
|
238
239
|
cache = /* @__PURE__ */ new Set();
|
|
@@ -493,9 +494,7 @@ function generateNodes(exportResult, packageName = "unknown") {
|
|
|
493
494
|
case EVarType.number:
|
|
494
495
|
schema.default = Number(type.default);
|
|
495
496
|
break;
|
|
496
|
-
case EVarType.string:
|
|
497
|
-
schema.default = type.default;
|
|
498
|
-
break;
|
|
497
|
+
case EVarType.string: schema.default = type.default;
|
|
499
498
|
}
|
|
500
499
|
if (schema.type === EVarType.object && !Object.keys(schema.properties).length) schema.customizable = true;
|
|
501
500
|
return schema;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { IconDefinition } from "@fortawesome/fontawesome-svg-core";
|
|
2
|
-
|
|
3
2
|
//#region ../utils/dist/index.d.mts
|
|
4
|
-
type DeepPartial<T> = { [K in keyof T]?: T[K] extends Array<unknown> ? Array<DeepPartial<T[K][number]>> : T[K] extends Record<string, unknown> ? DeepPartial<T[K]> : T[K] };
|
|
3
|
+
type DeepPartial<T> = { [K in keyof T]?: T[K] extends Array<unknown> ? Array<DeepPartial<T[K][number]>> : T[K] extends Record<string, unknown> ? DeepPartial<T[K]> : T[K]; };
|
|
5
4
|
type MaybePromise<T> = T | Promise<T>;
|
|
6
5
|
//#endregion
|
|
7
6
|
//#region src/vector.d.ts
|
|
@@ -27,7 +26,8 @@ declare class CVector {
|
|
|
27
26
|
isNearlyEqual(vector: TVector): boolean;
|
|
28
27
|
getPointString(): string;
|
|
29
28
|
getMagnitude(): number;
|
|
30
|
-
}
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
31
|
//#endregion
|
|
32
32
|
//#region ../logicnodes/dist/index.d.mts
|
|
33
33
|
//#region src/logic/type.d.ts
|
|
@@ -67,7 +67,6 @@ interface TArguments<TType = unknown> {
|
|
|
67
67
|
optional?: boolean;
|
|
68
68
|
options?: {
|
|
69
69
|
access?: TSchema<TObject>;
|
|
70
|
-
format?: (arg: TType) => TType;
|
|
71
70
|
freeze?: boolean;
|
|
72
71
|
readonly?: boolean;
|
|
73
72
|
} & Record<string, unknown>;
|
|
@@ -124,14 +123,14 @@ interface TInterface<T = unknown> {
|
|
|
124
123
|
static: T;
|
|
125
124
|
type: EVarType.interface;
|
|
126
125
|
}
|
|
127
|
-
interface TType<T
|
|
126
|
+
interface TType<T = unknown> {
|
|
128
127
|
static: T;
|
|
129
128
|
target: Array<string>;
|
|
130
129
|
type: EVarType.type;
|
|
131
130
|
}
|
|
132
131
|
interface TArray<T extends TSchema = TSchema> {
|
|
133
132
|
items: T;
|
|
134
|
-
static: Array<
|
|
133
|
+
static: Array<StaticSchema<T>>;
|
|
135
134
|
type: EVarType.array;
|
|
136
135
|
}
|
|
137
136
|
interface TUnion<T extends ReadonlyArray<TSchema> = ReadonlyArray<TSchema>> {
|
|
@@ -139,50 +138,80 @@ interface TUnion<T extends ReadonlyArray<TSchema> = ReadonlyArray<TSchema>> {
|
|
|
139
138
|
static: StaticUnion<T>;
|
|
140
139
|
type: EVarType.union;
|
|
141
140
|
}
|
|
142
|
-
|
|
141
|
+
type TFunction<TInputs extends TObject = TObject, TOutput extends TSchema = TSchema, TPromise extends boolean = false, TParameters extends ReadonlyArray<TSchema> = ReadonlyArray<TSchema>> = {
|
|
143
142
|
inputs: TInputs;
|
|
144
143
|
output: TOutput;
|
|
145
|
-
static: StaticFunction<
|
|
144
|
+
static: StaticFunction<TParameters, TOutput, TPromise>;
|
|
146
145
|
type: EVarType.function;
|
|
147
|
-
}
|
|
148
|
-
type TAnyLogic = TExec | TObject | TRecord | TInterface | TType | TArray | TString | TNumber | TBoolean | TUnknown | TUndefined | TUnion | TFunction | TVoid;
|
|
149
|
-
type TSchema<TLogic extends TAnyLogic = TAnyLogic> = TLogic & TArguments
|
|
146
|
+
};
|
|
147
|
+
type TAnyLogic = TExec | TObject | TRecord<TString | TNumber> | TInterface | TType | TArray | TString | TNumber | TBoolean | TUnknown | TUndefined | TUnion | TFunction<TObject, TSchema, boolean, ReadonlyArray<never>> | TVoid;
|
|
148
|
+
type TSchema<TLogic extends TAnyLogic = TAnyLogic> = TLogic & TArguments;
|
|
150
149
|
declare const LogicType: {
|
|
151
|
-
array: <T extends TSchema, TArgs extends TArguments<Array<T
|
|
150
|
+
array: <T extends TSchema, TArgs extends TArguments<Array<StaticSchema<T>>>>(items: T, args?: TArgs) => TArray<T> & TArgs;
|
|
152
151
|
boolean: <TArgs extends TArguments<boolean>>(args?: TArgs) => TBoolean & TArgs;
|
|
153
|
-
exec: (args?:
|
|
154
|
-
function:
|
|
155
|
-
promise?: TPromise;
|
|
156
|
-
}) => TFunction<TInputs, TOutput, TPromise>;
|
|
152
|
+
exec: <const TArgs extends TArguments = {}>(args?: TArgs) => TExec & TArgs;
|
|
153
|
+
function: typeof createFunction;
|
|
157
154
|
interface: <T = unknown, TArgs extends TArguments<T> = TArguments<T>>(interfaceClass: (new (...args: Array<unknown>) => T) | string, args?: TArgs) => TInterface<T> & TArgs;
|
|
158
155
|
number: <TArgs extends TArguments<number>>(args?: TArgs) => TNumber & TArgs;
|
|
159
156
|
object: <T extends TProperties, TArgs extends TArguments<object>>(properties?: T, args?: TArgs) => TObject<T> & TArgs;
|
|
160
|
-
record: <TKey extends TString | TNumber, TValue extends TSchema
|
|
157
|
+
record: <TKey extends TString | TNumber, TValue extends TSchema, const TArgs extends TArguments<StaticRecord<TKey, TValue>> = {}>(key: TKey, value: TValue, args?: TArgs) => TRecord<TKey, TValue> & TArgs;
|
|
161
158
|
string: <TArgs extends TArguments<string>>(args?: TArgs) => TString & TArgs;
|
|
162
|
-
type:
|
|
163
|
-
undefined: (args?:
|
|
164
|
-
union: <T extends
|
|
159
|
+
type: typeof createType;
|
|
160
|
+
undefined: <const TArgs extends TArguments<undefined> = {}>(args?: TArgs) => TUndefined & TArgs;
|
|
161
|
+
union: <const T extends ReadonlyArray<TSchema>, const TArgs extends TArguments<StaticUnion<T>> = {}>(elements: T, args?: TArgs) => TUnion<T> & TArgs;
|
|
165
162
|
unknown: <TArgs extends TArguments>(args?: TArgs) => TUnknown & TArgs;
|
|
166
|
-
void: (args?:
|
|
163
|
+
void: <const TArgs extends TArguments<void> = {}>(args?: TArgs) => TVoid & TArgs;
|
|
167
164
|
};
|
|
168
165
|
type OptionalKeys<T extends TProperties> = { [K in keyof T]: T[K] extends {
|
|
169
166
|
optional: true;
|
|
170
|
-
} ? K : never }[keyof T];
|
|
167
|
+
} ? K : never; }[keyof T];
|
|
171
168
|
type RequiredKeys<T extends TProperties> = Exclude<keyof T, OptionalKeys<T>>;
|
|
172
|
-
type
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
type
|
|
176
|
-
type
|
|
169
|
+
type StaticSchema<T extends TSchema> = [TSchema] extends [T] ? unknown : T extends {
|
|
170
|
+
static: unknown;
|
|
171
|
+
} ? Static<T> : unknown;
|
|
172
|
+
type StaticObject<T extends TProperties> = string extends keyof T ? Record<string, unknown> : { [K in RequiredKeys<T>]: StaticSchema<T[K]>; } & { [K in OptionalKeys<T>]?: StaticSchema<T[K]>; };
|
|
173
|
+
type StaticRecord<TKey extends TSchema<TString> | TSchema<TNumber>, TValue extends TSchema> = Record<StaticSchema<TKey> & (string | number), StaticSchema<TValue>>;
|
|
174
|
+
type StaticUnion<T extends ReadonlyArray<TSchema>> = StaticSchema<T[number]>;
|
|
175
|
+
type TStaticParameters<T extends ReadonlyArray<TSchema>> = number extends T["length"] ? Array<StaticSchema<T[number]>> : T extends readonly [...infer TRest extends ReadonlyArray<TSchema>, infer TLast extends TSchema] ? TLast extends {
|
|
176
|
+
optional: true;
|
|
177
|
+
} ? [...TStaticParameters<TRest>, StaticSchema<TLast>?] : [...TStaticParameters<TRest>, StaticSchema<TLast>] : [];
|
|
178
|
+
type StaticFunction<TParameters extends ReadonlyArray<TSchema>, TOutput extends TSchema, TPromise extends boolean = false> = TPromise extends true ? (...args: TStaticParameters<TParameters>) => Promise<StaticSchema<TOutput>> : (...args: TStaticParameters<TParameters>) => StaticSchema<TOutput>;
|
|
179
|
+
type TFunctionEntries = ReadonlyArray<readonly [string, TSchema]>;
|
|
180
|
+
type TEntryProperties<T extends TFunctionEntries> = { [TEntry in T[number] as TEntry[0]]: TEntry[1]; };
|
|
181
|
+
type TEntryParameters<T extends TFunctionEntries> = { [K in keyof T]: T[K][1]; };
|
|
182
|
+
type TObjectParameters<T extends TObject> = keyof T["properties"] extends never ? ReadonlyArray<TSchema> : ReadonlyArray<T["properties"][keyof T["properties"]]>;
|
|
183
|
+
type TFunctionPromise<T extends TArguments> = "promise" extends keyof T ? Exclude<T["promise"], undefined> : false;
|
|
184
|
+
declare function createFunction<const TEntries extends TFunctionEntries = [], TOutput extends TSchema = TVoid, const TArgs extends TArguments = {}>(inputs?: TEntries, output?: TOutput, args?: TArgs): TFunction<TObject<TEntryProperties<TEntries>>, TOutput, TFunctionPromise<TArgs>, TEntryParameters<TEntries>> & TArgs;
|
|
185
|
+
declare function createFunction<TInputs extends TObject, TOutput extends TSchema = TVoid, const TArgs extends TArguments = {}>(inputs: TInputs, output?: TOutput, args?: TArgs): TFunction<TInputs, TOutput, TFunctionPromise<TArgs>, TObjectParameters<TInputs>> & TArgs;
|
|
186
|
+
declare function createType<T, const TArgs extends TArguments<T> & {
|
|
187
|
+
optional: true;
|
|
188
|
+
} = TArguments<T> & {
|
|
189
|
+
optional: true;
|
|
190
|
+
}>(target: Array<string>, args: TArgs): TType<T> & TArgs;
|
|
191
|
+
declare function createType<T, const TArgs extends TArguments<T> = TArguments<T>>(target: Array<string>, args?: TArgs): TType<T> & TArgs;
|
|
192
|
+
type Static<T extends {
|
|
193
|
+
optional?: boolean;
|
|
194
|
+
static: unknown;
|
|
195
|
+
}> = T extends {
|
|
177
196
|
optional: true;
|
|
178
197
|
} ? (T["static"] | undefined) : T["static"];
|
|
198
|
+
type TTransformedObject<TTarget extends TObject, T extends TProperties> = Omit<TTarget, "properties" | "static"> & TObject<T>;
|
|
199
|
+
type TWithOptional<T extends TSchema, TOptional extends boolean> = T extends TSchema ? Omit<T, "optional"> & {
|
|
200
|
+
optional: TOptional;
|
|
201
|
+
} : never;
|
|
202
|
+
type TPartialOptional<T extends TSchema> = T["required"] extends true ? false : true extends T["required"] ? boolean : true;
|
|
203
|
+
type TPartialProperties<T extends TProperties, TForce extends boolean> = TForce extends true ? { [K in keyof T]: TWithOptional<T[K], TPartialOptional<T[K]>>; } : { [K in keyof T]: TWithOptional<T[K], true>; };
|
|
204
|
+
type TRequiredProperties<T extends TProperties> = { [K in keyof T]: TWithOptional<T[K], false>; };
|
|
205
|
+
type TPickedProperties<T extends TProperties, TKeys extends ReadonlyArray<string>> = number extends TKeys["length"] ? TProperties : Pick<T, Extract<TKeys[number], keyof T>>;
|
|
206
|
+
type TOmittedProperties<T extends TProperties, TKeys extends ReadonlyArray<string>> = number extends TKeys["length"] ? TProperties : Omit<T, TKeys[number]>;
|
|
179
207
|
declare const LogicUtil: {
|
|
180
|
-
omit(target:
|
|
181
|
-
partial(target:
|
|
182
|
-
pick(target:
|
|
208
|
+
omit<TTarget extends TObject, const TKeys extends ReadonlyArray<string>>(target: TTarget, keys: TKeys): TTransformedObject<TTarget, TOmittedProperties<TTarget["properties"], TKeys>>;
|
|
209
|
+
partial<TTarget extends TObject, TForce extends boolean = false>(target: TTarget, force?: TForce): TTransformedObject<TTarget, TPartialProperties<TTarget["properties"], TForce>>;
|
|
210
|
+
pick<TTarget extends TObject, const TKeys extends ReadonlyArray<string>>(target: TTarget, keys: TKeys): TTransformedObject<TTarget, TPickedProperties<TTarget["properties"], TKeys>>;
|
|
183
211
|
promise(target: TSchema): TSchema;
|
|
184
|
-
required(target:
|
|
185
|
-
};
|
|
212
|
+
required<TTarget extends TObject>(target: TTarget): TTransformedObject<TTarget, TRequiredProperties<TTarget["properties"]>>;
|
|
213
|
+
};
|
|
214
|
+
//#endregion
|
|
186
215
|
//#region src/logic/node.d.ts
|
|
187
216
|
type Component = {
|
|
188
217
|
name: string;
|
|
@@ -234,11 +263,11 @@ type TNodeIOSchema<TInterface extends TNodeInterfaceDescriptor> = { [TKey in key
|
|
|
234
263
|
linked: boolean;
|
|
235
264
|
schema: TOnlyVarsOf<TInterface>[TKey];
|
|
236
265
|
value: Static<TOnlyVarsOf<TInterface>[TKey]>;
|
|
237
|
-
} };
|
|
238
|
-
type TNodeOptionals<TInputs extends TNodeInterfaceDescriptor, TOutputs extends TNodeInterfaceDescriptor> = { [TKey in keyof (TOnlyVarsOf<TInputs> | TOnlyVarsOf<TOutputs>)]: boolean };
|
|
266
|
+
}; };
|
|
267
|
+
type TNodeOptionals<TInputs extends TNodeInterfaceDescriptor, TOutputs extends TNodeInterfaceDescriptor> = { [TKey in keyof (TOnlyVarsOf<TInputs> | TOnlyVarsOf<TOutputs>)]: boolean; };
|
|
239
268
|
type TNodeConfigSchema<TConfig extends TNodeConfigDescriptor> = {
|
|
240
269
|
internal?: unknown;
|
|
241
|
-
} & { [TKey in keyof TConfig]: Static<TConfig[TKey]
|
|
270
|
+
} & { [TKey in keyof TConfig]: Static<TConfig[TKey]>; };
|
|
242
271
|
type TNodeDynamics<TInputs extends TNodeInterfaceDescriptor, TOutputs extends TNodeInterfaceDescriptor, TConfig extends TNodeConfigDescriptor> = {
|
|
243
272
|
inputs?: (ioSchema: {
|
|
244
273
|
config: TNodeConfigSchema<TConfig>;
|
|
@@ -270,17 +299,18 @@ type TDocumentation = {
|
|
|
270
299
|
name: string;
|
|
271
300
|
}>;
|
|
272
301
|
};
|
|
273
|
-
type TOnlyExecOf<TNodeInterfaceDescriptor> = { [TAnchor in keyof TNodeInterfaceDescriptor as TNodeInterfaceDescriptor[TAnchor] extends TExec ? TAnchor : never]: TNodeInterfaceDescriptor[TAnchor] };
|
|
274
|
-
type TOnlyVarsOf<TNodeInterfaceDescriptor> = { [TAnchor in keyof TNodeInterfaceDescriptor as TNodeInterfaceDescriptor[TAnchor] extends TExec ? never : TAnchor]: TNodeInterfaceDescriptor[TAnchor] };
|
|
302
|
+
type TOnlyExecOf<TNodeInterfaceDescriptor> = { [TAnchor in keyof TNodeInterfaceDescriptor as TNodeInterfaceDescriptor[TAnchor] extends TExec ? TAnchor : never]: TNodeInterfaceDescriptor[TAnchor]; };
|
|
303
|
+
type TOnlyVarsOf<TNodeInterfaceDescriptor> = { [TAnchor in keyof TNodeInterfaceDescriptor as TNodeInterfaceDescriptor[TAnchor] extends TExec ? never : TAnchor]: TNodeInterfaceDescriptor[TAnchor]; };
|
|
275
304
|
type MethodsFrom<TInterface extends TNodeInterfaceDescriptor> = { [TKey in keyof TInterface]: (() => MaybePromise<Static<TInterface[TKey]>>) | {
|
|
276
305
|
async: () => Promise<Static<TInterface[TKey]>>;
|
|
277
306
|
sync: () => MaybePromise<Static<TInterface[TKey]>>;
|
|
278
|
-
} };
|
|
307
|
+
}; };
|
|
279
308
|
type TMethodsOf<TInputs extends TNodeInterfaceDescriptor, TOutputs extends TNodeInterfaceDescriptor> = MethodsFrom<TOnlyExecOf<TInputs>> & MethodsFrom<TOnlyVarsOf<TOutputs>>;
|
|
280
|
-
type TNodeDescriptor<TInputs extends TNodeInterfaceDescriptor, TOutputs extends TNodeInterfaceDescriptor, TConfig extends TNodeConfigDescriptor> = TNodeGenerated<TInputs, TOutputs, TConfig> & ThisType<{ [TKey in keyof TOnlyExecOf<TOutputs>]: (stack?: unknown) => Promise<void
|
|
281
|
-
arguments:
|
|
309
|
+
type TNodeDescriptor<TInputs extends TNodeInterfaceDescriptor, TOutputs extends TNodeInterfaceDescriptor, TConfig extends TNodeConfigDescriptor> = TNodeGenerated<TInputs, TOutputs, TConfig> & ThisType<{ [TKey in keyof TOnlyExecOf<TOutputs>]: (stack?: unknown) => Promise<void>; } & { [TKey in keyof TOnlyVarsOf<TInputs>]: Static<TInputs[TKey]>; } & { [TKey in keyof TOnlyVarsOf<TOutputs>]: Static<TOutputs[TKey]>; } & Record<`internal_${string}`, unknown> & {
|
|
310
|
+
arguments: Array<unknown>;
|
|
282
311
|
cache: Record<string, unknown>;
|
|
283
|
-
config: { [TKey in keyof TConfig]: Static<TConfig[TKey]
|
|
312
|
+
config: { [TKey in keyof TConfig]: Static<TConfig[TKey]>; };
|
|
313
|
+
instance: <TValue>(deps: Array<unknown>, factory: () => TValue, key?: string) => TValue;
|
|
284
314
|
properties: Record<string, {
|
|
285
315
|
name: string;
|
|
286
316
|
value: Promise<unknown>;
|
|
@@ -299,7 +329,8 @@ type TNodeGenerated<TInputs extends TNodeInterfaceDescriptor, TOutputs extends T
|
|
|
299
329
|
}>;
|
|
300
330
|
entry?: boolean;
|
|
301
331
|
generate?: (data: {
|
|
302
|
-
config?: { [TKey in keyof TConfig]: Static<TConfig[TKey]
|
|
332
|
+
config?: { [TKey in keyof TConfig]: Static<TConfig[TKey]>; };
|
|
333
|
+
id?: string;
|
|
303
334
|
inputKeys: Array<string>;
|
|
304
335
|
key?: string;
|
|
305
336
|
}) => string;
|
|
@@ -331,6 +362,7 @@ type TLogicNode = {
|
|
|
331
362
|
entry?: boolean;
|
|
332
363
|
generate?: (options: {
|
|
333
364
|
config: Record<string, unknown>;
|
|
365
|
+
id?: string;
|
|
334
366
|
inputKeys: Array<string>;
|
|
335
367
|
key: string;
|
|
336
368
|
}) => string;
|
|
@@ -362,7 +394,6 @@ type TLogicNode = {
|
|
|
362
394
|
outputs: TNodeInterfaceDescriptor;
|
|
363
395
|
type?: ELogicType;
|
|
364
396
|
};
|
|
365
|
-
declare function makeLogicNode<TInputs extends TNodeInterfaceDescriptor, TOutputs extends TNodeInterfaceDescriptor, TConfig extends TNodeConfigDescriptor>(node: TNodeDescriptor<TInputs, TOutputs, TConfig>): TLogicNode;
|
|
366
|
-
//#region src/logic/lib.d.ts
|
|
397
|
+
declare function makeLogicNode<TInputs extends TNodeInterfaceDescriptor, TOutputs extends TNodeInterfaceDescriptor, TConfig extends TNodeConfigDescriptor>(node: TNodeDescriptor<TInputs, TOutputs, TConfig>): TLogicNode;
|
|
367
398
|
//#endregion
|
|
368
399
|
export { LogicUtil as a, TObject as c, makeLogicNode as d, CVector as f, TVector as h, LogicType as i, TSchema as l, MaybePromise as m, ELogicType as n, Static as o, DeepPartial as p, EVarType as r, TLogicNode as s, ELogicScope as t, TVoid as u };
|