@luna-park/plugin 1.8.0 → 2.0.1
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-BBW6rNSm.mjs +85 -0
- package/dist/dist-Dyisk4Ug.mjs +827 -0
- package/dist/eslint.d.mts +1 -2
- package/dist/eslint.mjs +11 -4
- package/dist/extractor.d.mts +3 -13
- package/dist/extractor.mjs +32 -40
- package/dist/{index-76yMHag4.d.mts → index-w5zIwwtu.d.mts} +164 -145
- package/dist/index.d.mts +538 -459
- package/dist/index.mjs +1350 -212
- package/dist/preview.d.mts +1 -3
- package/dist/preview.mjs +5 -6
- package/package.json +30 -23
- package/dist/dist-BoFOku7q.mjs +0 -608
package/dist/eslint.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
//#region src/eslint/index.d.ts
|
|
2
1
|
export declare const objectKeysOptions: {
|
|
3
2
|
orderedKeys: string[];
|
|
4
3
|
selectors: {
|
|
5
4
|
target: {
|
|
6
5
|
name: string;
|
|
7
6
|
type: "function" | "property";
|
|
7
|
+
argument?: number | undefined;
|
|
8
8
|
};
|
|
9
9
|
mode: "direct" | "recursive";
|
|
10
10
|
orderedKeys?: Array<string>;
|
|
@@ -17,5 +17,4 @@ declare const _default: {
|
|
|
17
17
|
"sort-keys-custom-order/object-keys": ["error", typeof objectKeysOptions];
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
-
//#endregion
|
|
21
20
|
export { _default as default };
|
package/dist/eslint.mjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
// src/eslint/index.ts
|
|
2
2
|
function selector(name, type, options) {
|
|
3
|
+
const { argument, ...sorting } = options;
|
|
3
4
|
return {
|
|
4
5
|
mode: "direct",
|
|
5
|
-
...
|
|
6
|
+
...sorting,
|
|
6
7
|
target: {
|
|
8
|
+
...argument !== void 0 && { argument },
|
|
7
9
|
name,
|
|
8
10
|
type
|
|
9
11
|
}
|
|
@@ -62,12 +64,17 @@ const objectKeysOptions = {
|
|
|
62
64
|
] }),
|
|
63
65
|
selector("inputs", "property", { sorting: "none" }),
|
|
64
66
|
selector("outputs", "property", { sorting: "none" }),
|
|
65
|
-
selector("
|
|
67
|
+
selector("config", "property", { sorting: "none" }),
|
|
68
|
+
selector("methods", "property", { sorting: "none" }),
|
|
69
|
+
selector("LogicType.object", "function", {
|
|
70
|
+
argument: 0,
|
|
71
|
+
sorting: "none"
|
|
72
|
+
}),
|
|
73
|
+
selector("enum", "property", { sorting: "none" })
|
|
66
74
|
]
|
|
67
75
|
};
|
|
68
76
|
var eslint_default = {
|
|
69
77
|
name: "@luna-park/plugin/eslint",
|
|
70
78
|
rules: { "sort-keys-custom-order/object-keys": ["error", objectKeysOptions] }
|
|
71
79
|
};
|
|
72
|
-
//#endregion
|
|
73
80
|
export { eslint_default as default, objectKeysOptions };
|
package/dist/extractor.d.mts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { d as TSchema } from "./index-
|
|
1
|
+
import { d as TSchema } from "./index-w5zIwwtu.mjs";
|
|
2
2
|
import * as ts$1 from "typescript";
|
|
3
3
|
import ts from "typescript";
|
|
4
|
-
//#region src/extractor/export/type.d.ts
|
|
5
4
|
type TExportResult = {
|
|
6
5
|
components: Record<string, TExportComponent>;
|
|
7
6
|
functions: Record<string, TExportFunction>;
|
|
8
7
|
types: Record<string, TExportType>;
|
|
9
8
|
};
|
|
10
9
|
type TExportComponent = {
|
|
11
|
-
emits?: Record<string,
|
|
10
|
+
emits?: Record<string, TExportType>;
|
|
12
11
|
models?: Record<string, TExportType>;
|
|
13
12
|
properties?: Record<string, TExportType>;
|
|
14
13
|
slots?: Record<string, TExportType>;
|
|
@@ -26,7 +25,6 @@ type TExportFunction = {
|
|
|
26
25
|
description?: string;
|
|
27
26
|
type: string;
|
|
28
27
|
};
|
|
29
|
-
type: string;
|
|
30
28
|
};
|
|
31
29
|
type TExportType = {
|
|
32
30
|
default?: string;
|
|
@@ -35,8 +33,6 @@ type TExportType = {
|
|
|
35
33
|
properties?: Record<string, TExportType>;
|
|
36
34
|
type: string | Record<string, TExportType>;
|
|
37
35
|
};
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/extractor/export/index.d.ts
|
|
40
36
|
export declare class CTypeExport {
|
|
41
37
|
program: ts.Program;
|
|
42
38
|
checker: ts.TypeChecker;
|
|
@@ -51,8 +47,6 @@ export declare class CTypeExport {
|
|
|
51
47
|
extractType(type: ts.Type, ctxNode?: ts.Node): void;
|
|
52
48
|
typeToString(type: ts.Type, flags?: number): string;
|
|
53
49
|
}
|
|
54
|
-
//#endregion
|
|
55
|
-
//#region src/extractor/generator.d.ts
|
|
56
50
|
type TExportNodeFunction = {
|
|
57
51
|
description?: string;
|
|
58
52
|
name?: string;
|
|
@@ -71,13 +65,9 @@ type TExportLogicResult = {
|
|
|
71
65
|
types: Record<string, TSchema>;
|
|
72
66
|
};
|
|
73
67
|
export declare function generateNodes(exportResult: TExportResult, packageName?: string): TExportLogicResult;
|
|
74
|
-
//#endregion
|
|
75
|
-
//#region src/extractor/source.d.ts
|
|
76
68
|
export declare function getSourceFile(moduleName: string): {
|
|
77
69
|
program: ts$1.Program;
|
|
78
70
|
sourceFile: ts$1.SourceFile;
|
|
79
71
|
};
|
|
80
|
-
//#endregion
|
|
81
|
-
//#region src/extractor/index.d.ts
|
|
82
72
|
export declare function extractFile(filePath: string, target: string): Promise<void>;
|
|
83
|
-
|
|
73
|
+
export {};
|
package/dist/extractor.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { l as objectMap, n as cleanObject, t as assertType } from "./dist-BBW6rNSm.mjs";
|
|
2
|
+
import { i as LogicType, l as schemaLoop, r as EVarType, u as typeToSchema } from "./dist-Dyisk4Ug.mjs";
|
|
2
3
|
import fs from "node:fs";
|
|
3
|
-
import * as ts$1 from "typescript";
|
|
4
|
-
import ts from "typescript";
|
|
4
|
+
import ts, * as ts$1 from "typescript";
|
|
5
5
|
import * as path from "path";
|
|
6
6
|
import * as fs$1 from "fs";
|
|
7
|
-
|
|
7
|
+
// src/extractor/code/lib.ts
|
|
8
8
|
function generateCode(schema, options = {}) {
|
|
9
9
|
if (typeof schema !== "object" || schema === null) return JSON.stringify(schema);
|
|
10
10
|
const properties = {};
|
|
11
|
+
const values = { ...schema };
|
|
11
12
|
for (const props of [
|
|
12
13
|
"default",
|
|
13
14
|
"description",
|
|
@@ -17,10 +18,13 @@ function generateCode(schema, options = {}) {
|
|
|
17
18
|
"optional",
|
|
18
19
|
"example",
|
|
19
20
|
"enum"
|
|
20
|
-
]) if (
|
|
21
|
+
]) if (values[props]) properties[props] = values[props];
|
|
21
22
|
if (schema.type === EVarType.array) return buildFunctionCall(`LogicType.${schema.type}`, [generateCode(schema.items, options), getCodeFromObject(properties)]);
|
|
22
23
|
if (schema.type === EVarType.interface) return buildFunctionCall(`LogicType.${schema.type}`, [JSON.stringify(schema.className), getCodeFromObject(properties)]);
|
|
23
|
-
if (
|
|
24
|
+
if ([EVarType.union, EVarType.intersection].includes(schema.type)) {
|
|
25
|
+
assertType(schema);
|
|
26
|
+
return buildFunctionCall(`LogicType.${schema.type}`, [`[${schema.elements.map((element) => generateCode(element, options)).join(", ")}]`, getCodeFromObject(properties)]);
|
|
27
|
+
}
|
|
24
28
|
if (schema.type === EVarType.function) return buildFunctionCall(`LogicType.${schema.type}`, [
|
|
25
29
|
generateCode(schema.inputs, options),
|
|
26
30
|
generateCode(schema.output, options),
|
|
@@ -45,8 +49,7 @@ function getCodeFromObject(object, raw) {
|
|
|
45
49
|
function getSafeKey(key) {
|
|
46
50
|
return /^[a-zA-Z]+$/.test(key) ? key : JSON.stringify(key);
|
|
47
51
|
}
|
|
48
|
-
|
|
49
|
-
//#region src/extractor/code/component.ts
|
|
52
|
+
// src/extractor/code/component.ts
|
|
50
53
|
function getComponentCode(logicResult, file) {
|
|
51
54
|
const content = [];
|
|
52
55
|
const component = logicResult.components["default"];
|
|
@@ -72,8 +75,7 @@ export const ${file.name.toLocaleLowerCase()}: TComponent = {
|
|
|
72
75
|
${content.map(({ key, value }) => `${key}: {\n ${value}\n }`).join(",\n ")}
|
|
73
76
|
}`;
|
|
74
77
|
}
|
|
75
|
-
|
|
76
|
-
//#region src/extractor/documentation.ts
|
|
78
|
+
// src/extractor/documentation.ts
|
|
77
79
|
function getDocumentationFromSymbol(symbol, checker) {
|
|
78
80
|
const documentation = { description: mergeSymbolDisplayParts(symbol.getDocumentationComment(checker)) || void 0 };
|
|
79
81
|
for (const tag of symbol.getJsDocTags()) {
|
|
@@ -81,8 +83,8 @@ function getDocumentationFromSymbol(symbol, checker) {
|
|
|
81
83
|
if (!documentation.params) documentation.params = {};
|
|
82
84
|
let paramDescription = mergeSymbolDisplayParts(tag.text?.slice(1)).trim();
|
|
83
85
|
if (paramDescription.startsWith("- ")) paramDescription = paramDescription.slice(2);
|
|
84
|
-
const paramName = tag.text[0]?.text;
|
|
85
|
-
documentation.params[paramName] = paramDescription;
|
|
86
|
+
const paramName = tag.text?.[0]?.text;
|
|
87
|
+
if (paramName) documentation.params[paramName] = paramDescription;
|
|
86
88
|
continue;
|
|
87
89
|
}
|
|
88
90
|
documentation[tag.name] = mergeSymbolDisplayParts(tag.text);
|
|
@@ -92,8 +94,7 @@ function getDocumentationFromSymbol(symbol, checker) {
|
|
|
92
94
|
function mergeSymbolDisplayParts(symbolDisplayParts = []) {
|
|
93
95
|
return symbolDisplayParts.map((part) => part.text).join("");
|
|
94
96
|
}
|
|
95
|
-
|
|
96
|
-
//#region src/extractor/export/component.ts
|
|
97
|
+
// src/extractor/export/component.ts
|
|
97
98
|
function getSlots(type, typeExport) {
|
|
98
99
|
const properties = typeExport.checker.getPropertiesOfType(type);
|
|
99
100
|
const slots = {};
|
|
@@ -168,8 +169,7 @@ function emitName(name) {
|
|
|
168
169
|
name = name.slice(2);
|
|
169
170
|
return name.charAt(0).toLowerCase() + name.slice(1);
|
|
170
171
|
}
|
|
171
|
-
|
|
172
|
-
//#region src/extractor/export/template.ts
|
|
172
|
+
// src/extractor/export/template.ts
|
|
173
173
|
function getTemplateTypeParameters(signature, typeExport) {
|
|
174
174
|
return Object.fromEntries((signature.getTypeParameters() ?? []).map((typeParameter) => {
|
|
175
175
|
let type = "unknown";
|
|
@@ -180,8 +180,7 @@ function getTemplateTypeParameters(signature, typeExport) {
|
|
|
180
180
|
return [typeParameter.symbol.name, type];
|
|
181
181
|
}));
|
|
182
182
|
}
|
|
183
|
-
|
|
184
|
-
//#region src/extractor/export/utils.ts
|
|
183
|
+
// src/extractor/export/utils.ts
|
|
185
184
|
function getResolvedExports(checker, module) {
|
|
186
185
|
const resolvedExports = /* @__PURE__ */ new Map();
|
|
187
186
|
const exports = checker.getExportsOfModule(module);
|
|
@@ -216,8 +215,7 @@ function extractEnumDefinition(enumDeclaration) {
|
|
|
216
215
|
});
|
|
217
216
|
return `{ ${members.join(", ")} }`;
|
|
218
217
|
}
|
|
219
|
-
|
|
220
|
-
//#region src/extractor/lib.ts
|
|
218
|
+
// src/extractor/lib.ts
|
|
221
219
|
function isUserType(type) {
|
|
222
220
|
if (type.getFlags() & (ts.TypeFlags.StringLike | ts.TypeFlags.NumberLike | ts.TypeFlags.BooleanLike | ts.TypeFlags.ESSymbolLike | ts.TypeFlags.Void | ts.TypeFlags.Undefined | ts.TypeFlags.Null | ts.TypeFlags.Any | ts.TypeFlags.Unknown | ts.TypeFlags.Never)) return false;
|
|
223
221
|
const symbol = type.getSymbol();
|
|
@@ -229,8 +227,7 @@ function isUserType(type) {
|
|
|
229
227
|
if (srcFile.fileName.startsWith("/@vue/")) return false;
|
|
230
228
|
return true;
|
|
231
229
|
}
|
|
232
|
-
|
|
233
|
-
//#region src/extractor/export/index.ts
|
|
230
|
+
// src/extractor/export/index.ts
|
|
234
231
|
const FLAGS = ts.TypeFormatFlags.WriteArrowStyleSignature | ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope | ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.UseFullyQualifiedType;
|
|
235
232
|
var CTypeExport = class {
|
|
236
233
|
program;
|
|
@@ -303,15 +300,15 @@ var CTypeExport = class {
|
|
|
303
300
|
const documentation = getDocumentationFromSymbol(signature, this.checker);
|
|
304
301
|
const typeParameters = getTemplateTypeParameters(signature, this);
|
|
305
302
|
const parameters = signature.getParameters().map((symbol) => {
|
|
306
|
-
const
|
|
303
|
+
const parameterDeclaration = symbol.valueDeclaration;
|
|
307
304
|
const pType = this.checker.getTypeOfSymbol(symbol);
|
|
308
|
-
this.extractType(pType,
|
|
309
|
-
const defaultValue =
|
|
305
|
+
this.extractType(pType, parameterDeclaration ?? this.index);
|
|
306
|
+
const defaultValue = parameterDeclaration?.initializer?.getText();
|
|
310
307
|
return cleanObject({
|
|
311
308
|
default: defaultValue,
|
|
312
309
|
description: documentation.params?.[symbol.name],
|
|
313
310
|
name: symbol.name,
|
|
314
|
-
optional: !!
|
|
311
|
+
optional: !!parameterDeclaration?.questionToken || defaultValue !== void 0 || void 0,
|
|
315
312
|
type: swapType(this.typeToString(pType), typeParameters)
|
|
316
313
|
});
|
|
317
314
|
});
|
|
@@ -324,7 +321,7 @@ var CTypeExport = class {
|
|
|
324
321
|
component.properties = props.props;
|
|
325
322
|
component.emits = props.emits;
|
|
326
323
|
Object.values(component.properties).forEach((prop) => {
|
|
327
|
-
prop.type = swapType(prop.type, typeParameters);
|
|
324
|
+
if (typeof prop.type === "string") prop.type = swapType(prop.type, typeParameters);
|
|
328
325
|
});
|
|
329
326
|
}
|
|
330
327
|
const slotsIndex = parameters.findIndex((parameter) => parameter.name === "__VLS_slots");
|
|
@@ -332,7 +329,7 @@ var CTypeExport = class {
|
|
|
332
329
|
if (slotsSymbol) {
|
|
333
330
|
component.slots = getSlots(this.checker.getTypeOfSymbol(slotsSymbol), this);
|
|
334
331
|
Object.values(component.slots).forEach((slot) => {
|
|
335
|
-
slot.type = swapType(slot.type, typeParameters);
|
|
332
|
+
if (typeof slot.type === "string") slot.type = swapType(slot.type, typeParameters);
|
|
336
333
|
});
|
|
337
334
|
}
|
|
338
335
|
this.result.components[name] = computeModels(component);
|
|
@@ -389,7 +386,7 @@ var CTypeExport = class {
|
|
|
389
386
|
const constraintTypeObj = this.checker.getTypeFromTypeNode(constraintType);
|
|
390
387
|
type = this.typeToString(constraintTypeObj);
|
|
391
388
|
}
|
|
392
|
-
return [typeParameter.
|
|
389
|
+
return [typeParameter.name.text, type];
|
|
393
390
|
}));
|
|
394
391
|
this.result.types[fullName] = {
|
|
395
392
|
...getDocumentationFromSymbol(symbol, this.checker),
|
|
@@ -397,7 +394,7 @@ var CTypeExport = class {
|
|
|
397
394
|
};
|
|
398
395
|
}
|
|
399
396
|
if (symbol.flags & ts.SymbolFlags.Interface && isUserType(type)) {
|
|
400
|
-
const declaration = symbol.getDeclarations()[0];
|
|
397
|
+
const declaration = symbol.getDeclarations()?.[0];
|
|
401
398
|
if (declaration) {
|
|
402
399
|
const properties = this.checker.getPropertiesOfType(type);
|
|
403
400
|
const exportProperties = {};
|
|
@@ -428,7 +425,7 @@ var CTypeExport = class {
|
|
|
428
425
|
"Required"
|
|
429
426
|
].includes(fullName)) {
|
|
430
427
|
this.cache.delete(type);
|
|
431
|
-
this.extractType(type.aliasTypeArguments[0]);
|
|
428
|
+
if (type.aliasTypeArguments?.[0]) this.extractType(type.aliasTypeArguments[0]);
|
|
432
429
|
return;
|
|
433
430
|
}
|
|
434
431
|
if (type.aliasTypeArguments?.some((typeArgument) => !isUserType(typeArgument))) return;
|
|
@@ -464,8 +461,7 @@ var CTypeExport = class {
|
|
|
464
461
|
return this.checker.typeToString(type, void 0, flags);
|
|
465
462
|
}
|
|
466
463
|
};
|
|
467
|
-
|
|
468
|
-
//#region src/extractor/generator.ts
|
|
464
|
+
// src/extractor/generator.ts
|
|
469
465
|
function generateNodes(exportResult, packageName = "unknown") {
|
|
470
466
|
const nodeResult = {
|
|
471
467
|
components: {},
|
|
@@ -547,8 +543,7 @@ function generateNodes(exportResult, packageName = "unknown") {
|
|
|
547
543
|
}
|
|
548
544
|
}
|
|
549
545
|
}
|
|
550
|
-
|
|
551
|
-
//#region src/extractor/config.ts
|
|
546
|
+
// src/extractor/config.ts
|
|
552
547
|
function findNearestTsConfig(configPath) {
|
|
553
548
|
while (true) {
|
|
554
549
|
const tsconfigPath = path.join(configPath, "tsconfig.json");
|
|
@@ -563,8 +558,7 @@ function getTsConfig(configPath) {
|
|
|
563
558
|
if (configFile.error) throw new Error(`Failed to read tsconfig.json: ${configFile.error.messageText}`);
|
|
564
559
|
return ts$1.parseJsonConfigFileContent(configFile.config, ts$1.sys, path.dirname(configPath));
|
|
565
560
|
}
|
|
566
|
-
|
|
567
|
-
//#region src/extractor/source.ts
|
|
561
|
+
// src/extractor/source.ts
|
|
568
562
|
function resolveModulePath(moduleName, compilerOptions) {
|
|
569
563
|
const tempFileName = path.join(process.cwd(), "__temp__.ts");
|
|
570
564
|
const tempHost = ts$1.createCompilerHost(compilerOptions);
|
|
@@ -590,8 +584,7 @@ function getSourceFile(moduleName) {
|
|
|
590
584
|
sourceFile
|
|
591
585
|
};
|
|
592
586
|
}
|
|
593
|
-
|
|
594
|
-
//#region src/extractor/index.ts
|
|
587
|
+
// src/extractor/index.ts
|
|
595
588
|
const fsp = fs.promises;
|
|
596
589
|
async function extractFile(filePath, target) {
|
|
597
590
|
const fileName = filePath.split("/").pop().split(".")[0];
|
|
@@ -606,5 +599,4 @@ async function extractFile(filePath, target) {
|
|
|
606
599
|
await fsp.writeFile(target, content);
|
|
607
600
|
}
|
|
608
601
|
}
|
|
609
|
-
//#endregion
|
|
610
602
|
export { CTypeExport, extractFile, generateNodes, getSourceFile };
|