@kubb/parser-ts 3.16.2 → 3.16.4
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/chunk-Cl8Af3a2.js +11 -0
- package/dist/factory-CTKjALU5.js +254 -0
- package/dist/factory-CTKjALU5.js.map +1 -0
- package/dist/factory-CUjjpSgy.d.ts +230 -0
- package/dist/factory-DeJMlphM.cjs +497 -0
- package/dist/factory-DeJMlphM.cjs.map +1 -0
- package/dist/factory-_F-JTqnG.d.cts +230 -0
- package/dist/factory.cjs +35 -143
- package/dist/factory.d.cts +2 -2
- package/dist/factory.d.ts +2 -2
- package/dist/factory.js +3 -3
- package/dist/index.cjs +55 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -9
- package/dist/index.d.ts +19 -9
- package/dist/index.js +51 -32
- package/dist/index.js.map +1 -1
- package/package.json +11 -15
- package/src/factory.ts +3 -3
- package/dist/chunk-BEHWCDCH.js +0 -461
- package/dist/chunk-BEHWCDCH.js.map +0 -1
- package/dist/chunk-FIHRQE7D.cjs +0 -501
- package/dist/chunk-FIHRQE7D.cjs.map +0 -1
- package/dist/factory-Cn6Avpxk.d.cts +0 -193
- package/dist/factory-Cn6Avpxk.d.ts +0 -193
- package/dist/factory.cjs.map +0 -1
- package/dist/factory.js.map +0 -1
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
declare namespace factory_d_exports {
|
|
5
|
+
export { appendJSDocToNode, createArrayDeclaration, createArrayTypeNode, createEnumDeclaration, createExportDeclaration, createFalse, createIdentifier, createImportDeclaration, createIndexSignature, createInterfaceDeclaration, createIntersectionDeclaration, createJSDoc, createLiteralTypeNode, createNamespaceDeclaration, createNull, createNumericLiteral, createOmitDeclaration, createOptionalTypeNode, createParameterSignature, createPropertySignature, createQuestionToken, createRestTypeNode, createStringLiteral, createTrue, createTupleDeclaration, createTupleTypeNode, createTypeAliasDeclaration, createTypeDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionDeclaration, keywordTypeNodes, modifiers, syntaxKind };
|
|
6
|
+
}
|
|
7
|
+
declare const modifiers: {
|
|
8
|
+
readonly async: ts.ModifierToken<ts.SyntaxKind.AsyncKeyword>;
|
|
9
|
+
readonly export: ts.ModifierToken<ts.SyntaxKind.ExportKeyword>;
|
|
10
|
+
readonly const: ts.ModifierToken<ts.SyntaxKind.ConstKeyword>;
|
|
11
|
+
readonly static: ts.ModifierToken<ts.SyntaxKind.StaticKeyword>;
|
|
12
|
+
};
|
|
13
|
+
declare const syntaxKind: {
|
|
14
|
+
readonly union: 192;
|
|
15
|
+
};
|
|
16
|
+
declare function createQuestionToken(token?: boolean | ts.QuestionToken): ts.PunctuationToken<ts.SyntaxKind.QuestionToken> | undefined;
|
|
17
|
+
declare function createIntersectionDeclaration({
|
|
18
|
+
nodes,
|
|
19
|
+
withParentheses
|
|
20
|
+
}: {
|
|
21
|
+
nodes: Array<ts.TypeNode>;
|
|
22
|
+
withParentheses?: boolean;
|
|
23
|
+
}): ts.TypeNode | null;
|
|
24
|
+
/**
|
|
25
|
+
* Minimum nodes length of 2
|
|
26
|
+
* @example `string & number`
|
|
27
|
+
*/
|
|
28
|
+
declare function createTupleDeclaration({
|
|
29
|
+
nodes,
|
|
30
|
+
withParentheses
|
|
31
|
+
}: {
|
|
32
|
+
nodes: Array<ts.TypeNode>;
|
|
33
|
+
withParentheses?: boolean;
|
|
34
|
+
}): ts.TypeNode | null;
|
|
35
|
+
declare function createArrayDeclaration({
|
|
36
|
+
nodes
|
|
37
|
+
}: {
|
|
38
|
+
nodes: Array<ts.TypeNode>;
|
|
39
|
+
}): ts.TypeNode | null;
|
|
40
|
+
/**
|
|
41
|
+
* Minimum nodes length of 2
|
|
42
|
+
* @example `string | number`
|
|
43
|
+
*/
|
|
44
|
+
declare function createUnionDeclaration({
|
|
45
|
+
nodes,
|
|
46
|
+
withParentheses
|
|
47
|
+
}: {
|
|
48
|
+
nodes: Array<ts.TypeNode>;
|
|
49
|
+
withParentheses?: boolean;
|
|
50
|
+
}): ts.TypeNode;
|
|
51
|
+
declare function createPropertySignature({
|
|
52
|
+
readOnly,
|
|
53
|
+
modifiers,
|
|
54
|
+
name,
|
|
55
|
+
questionToken,
|
|
56
|
+
type
|
|
57
|
+
}: {
|
|
58
|
+
readOnly?: boolean;
|
|
59
|
+
modifiers?: Array<ts.Modifier>;
|
|
60
|
+
name: ts.PropertyName | string;
|
|
61
|
+
questionToken?: ts.QuestionToken | boolean;
|
|
62
|
+
type?: ts.TypeNode;
|
|
63
|
+
}): ts.PropertySignature;
|
|
64
|
+
declare function createParameterSignature(name: string | ts.BindingName, {
|
|
65
|
+
modifiers,
|
|
66
|
+
dotDotDotToken,
|
|
67
|
+
questionToken,
|
|
68
|
+
type,
|
|
69
|
+
initializer
|
|
70
|
+
}: {
|
|
71
|
+
decorators?: Array<ts.Decorator>;
|
|
72
|
+
modifiers?: Array<ts.Modifier>;
|
|
73
|
+
dotDotDotToken?: ts.DotDotDotToken;
|
|
74
|
+
questionToken?: ts.QuestionToken | boolean;
|
|
75
|
+
type?: ts.TypeNode;
|
|
76
|
+
initializer?: ts.Expression;
|
|
77
|
+
}): ts.ParameterDeclaration;
|
|
78
|
+
declare function createJSDoc({
|
|
79
|
+
comments
|
|
80
|
+
}: {
|
|
81
|
+
comments: string[];
|
|
82
|
+
}): ts.JSDoc | null;
|
|
83
|
+
/**
|
|
84
|
+
* @link https://github.com/microsoft/TypeScript/issues/44151
|
|
85
|
+
*/
|
|
86
|
+
declare function appendJSDocToNode<TNode extends ts.Node>({
|
|
87
|
+
node,
|
|
88
|
+
comments
|
|
89
|
+
}: {
|
|
90
|
+
node: TNode;
|
|
91
|
+
comments: Array<string | undefined>;
|
|
92
|
+
}): TNode;
|
|
93
|
+
declare function createIndexSignature(type: ts.TypeNode, {
|
|
94
|
+
modifiers,
|
|
95
|
+
indexName,
|
|
96
|
+
indexType
|
|
97
|
+
}?: {
|
|
98
|
+
indexName?: string;
|
|
99
|
+
indexType?: ts.TypeNode;
|
|
100
|
+
decorators?: Array<ts.Decorator>;
|
|
101
|
+
modifiers?: Array<ts.Modifier>;
|
|
102
|
+
}): ts.IndexSignatureDeclaration;
|
|
103
|
+
declare function createTypeAliasDeclaration({
|
|
104
|
+
modifiers,
|
|
105
|
+
name,
|
|
106
|
+
typeParameters,
|
|
107
|
+
type
|
|
108
|
+
}: {
|
|
109
|
+
modifiers?: Array<ts.Modifier>;
|
|
110
|
+
name: string | ts.Identifier;
|
|
111
|
+
typeParameters?: Array<ts.TypeParameterDeclaration>;
|
|
112
|
+
type: ts.TypeNode;
|
|
113
|
+
}): ts.TypeAliasDeclaration;
|
|
114
|
+
declare function createInterfaceDeclaration({
|
|
115
|
+
modifiers,
|
|
116
|
+
name,
|
|
117
|
+
typeParameters,
|
|
118
|
+
members
|
|
119
|
+
}: {
|
|
120
|
+
modifiers?: Array<ts.Modifier>;
|
|
121
|
+
name: string | ts.Identifier;
|
|
122
|
+
typeParameters?: Array<ts.TypeParameterDeclaration>;
|
|
123
|
+
members: Array<ts.TypeElement>;
|
|
124
|
+
}): ts.InterfaceDeclaration;
|
|
125
|
+
declare function createTypeDeclaration({
|
|
126
|
+
syntax,
|
|
127
|
+
isExportable,
|
|
128
|
+
comments,
|
|
129
|
+
name,
|
|
130
|
+
type
|
|
131
|
+
}: {
|
|
132
|
+
syntax: 'type' | 'interface';
|
|
133
|
+
comments: Array<string | undefined>;
|
|
134
|
+
isExportable?: boolean;
|
|
135
|
+
name: string | ts.Identifier;
|
|
136
|
+
type: ts.TypeNode;
|
|
137
|
+
}): ts.TypeAliasDeclaration | ts.InterfaceDeclaration;
|
|
138
|
+
declare function createNamespaceDeclaration({
|
|
139
|
+
statements,
|
|
140
|
+
name
|
|
141
|
+
}: {
|
|
142
|
+
name: string;
|
|
143
|
+
statements: ts.Statement[];
|
|
144
|
+
}): ts.ModuleDeclaration;
|
|
145
|
+
/**
|
|
146
|
+
* In { propertyName: string; name?: string } is `name` being used to make the type more unique when multiple same names are used.
|
|
147
|
+
* @example `import { Pet as Cat } from './Pet'`
|
|
148
|
+
*/
|
|
149
|
+
declare function createImportDeclaration({
|
|
150
|
+
name,
|
|
151
|
+
path,
|
|
152
|
+
isTypeOnly,
|
|
153
|
+
isNameSpace
|
|
154
|
+
}: {
|
|
155
|
+
name: string | Array<string | {
|
|
156
|
+
propertyName: string;
|
|
157
|
+
name?: string;
|
|
158
|
+
}>;
|
|
159
|
+
path: string;
|
|
160
|
+
isTypeOnly?: boolean;
|
|
161
|
+
isNameSpace?: boolean;
|
|
162
|
+
}): ts.ImportDeclaration;
|
|
163
|
+
declare function createExportDeclaration({
|
|
164
|
+
path,
|
|
165
|
+
asAlias,
|
|
166
|
+
isTypeOnly,
|
|
167
|
+
name
|
|
168
|
+
}: {
|
|
169
|
+
path: string;
|
|
170
|
+
asAlias?: boolean;
|
|
171
|
+
isTypeOnly?: boolean;
|
|
172
|
+
name?: string | Array<ts.Identifier | string>;
|
|
173
|
+
}): ts.ExportDeclaration;
|
|
174
|
+
declare function createEnumDeclaration({
|
|
175
|
+
type,
|
|
176
|
+
name,
|
|
177
|
+
typeName,
|
|
178
|
+
enums
|
|
179
|
+
}: {
|
|
180
|
+
/**
|
|
181
|
+
* @default `'enum'`
|
|
182
|
+
*/
|
|
183
|
+
type?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal';
|
|
184
|
+
/**
|
|
185
|
+
* Enum name in camelCase.
|
|
186
|
+
*/
|
|
187
|
+
name: string;
|
|
188
|
+
/**
|
|
189
|
+
* Enum name in PascalCase.
|
|
190
|
+
*/
|
|
191
|
+
typeName: string;
|
|
192
|
+
enums: [key: string | number, value: string | number | boolean][];
|
|
193
|
+
}): [name: ts.Node | undefined, type: ts.Node];
|
|
194
|
+
declare function createOmitDeclaration({
|
|
195
|
+
keys,
|
|
196
|
+
type,
|
|
197
|
+
nonNullable
|
|
198
|
+
}: {
|
|
199
|
+
keys: Array<string> | string;
|
|
200
|
+
type: ts.TypeNode;
|
|
201
|
+
nonNullable?: boolean;
|
|
202
|
+
}): ts.TypeReferenceNode;
|
|
203
|
+
declare const keywordTypeNodes: {
|
|
204
|
+
readonly any: ts.KeywordTypeNode<ts.SyntaxKind.AnyKeyword>;
|
|
205
|
+
readonly unknown: ts.KeywordTypeNode<ts.SyntaxKind.UnknownKeyword>;
|
|
206
|
+
readonly void: ts.KeywordTypeNode<ts.SyntaxKind.VoidKeyword>;
|
|
207
|
+
readonly number: ts.KeywordTypeNode<ts.SyntaxKind.NumberKeyword>;
|
|
208
|
+
readonly integer: ts.KeywordTypeNode<ts.SyntaxKind.NumberKeyword>;
|
|
209
|
+
readonly object: ts.KeywordTypeNode<ts.SyntaxKind.ObjectKeyword>;
|
|
210
|
+
readonly string: ts.KeywordTypeNode<ts.SyntaxKind.StringKeyword>;
|
|
211
|
+
readonly boolean: ts.KeywordTypeNode<ts.SyntaxKind.BooleanKeyword>;
|
|
212
|
+
readonly undefined: ts.KeywordTypeNode<ts.SyntaxKind.UndefinedKeyword>;
|
|
213
|
+
readonly null: ts.LiteralTypeNode;
|
|
214
|
+
};
|
|
215
|
+
declare const createTypeLiteralNode: (members: readonly ts.TypeElement[] | undefined) => ts.TypeLiteralNode;
|
|
216
|
+
declare const createTypeReferenceNode: (typeName: string | ts.EntityName, typeArguments?: readonly ts.TypeNode[]) => ts.TypeReferenceNode;
|
|
217
|
+
declare const createNumericLiteral: (value: string | number, numericLiteralFlags?: ts.TokenFlags) => ts.NumericLiteral;
|
|
218
|
+
declare const createStringLiteral: (text: string, isSingleQuote?: boolean) => ts.StringLiteral;
|
|
219
|
+
declare const createArrayTypeNode: (elementType: ts.TypeNode) => ts.ArrayTypeNode;
|
|
220
|
+
declare const createLiteralTypeNode: (literal: ts.LiteralTypeNode["literal"]) => ts.LiteralTypeNode;
|
|
221
|
+
declare const createNull: () => ts.NullLiteral;
|
|
222
|
+
declare const createIdentifier: (text: string) => ts.Identifier;
|
|
223
|
+
declare const createOptionalTypeNode: (type: ts.TypeNode) => ts.OptionalTypeNode;
|
|
224
|
+
declare const createTupleTypeNode: (elements: readonly (ts.TypeNode | ts.NamedTupleMember)[]) => ts.TupleTypeNode;
|
|
225
|
+
declare const createRestTypeNode: (type: ts.TypeNode) => ts.RestTypeNode;
|
|
226
|
+
declare const createTrue: () => ts.TrueLiteral;
|
|
227
|
+
declare const createFalse: () => ts.FalseLiteral;
|
|
228
|
+
//#endregion
|
|
229
|
+
export { appendJSDocToNode, createArrayDeclaration, createArrayTypeNode, createEnumDeclaration, createExportDeclaration, createFalse, createIdentifier, createImportDeclaration, createIndexSignature, createInterfaceDeclaration, createIntersectionDeclaration, createJSDoc, createLiteralTypeNode, createNamespaceDeclaration, createNull, createNumericLiteral, createOmitDeclaration, createOptionalTypeNode, createParameterSignature, createPropertySignature, createQuestionToken, createRestTypeNode, createStringLiteral, createTrue, createTupleDeclaration, createTupleTypeNode, createTypeAliasDeclaration, createTypeDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionDeclaration, factory_d_exports, keywordTypeNodes, modifiers, syntaxKind };
|
|
230
|
+
//# sourceMappingURL=factory-_F-JTqnG.d.cts.map
|
package/dist/factory.cjs
CHANGED
|
@@ -1,144 +1,36 @@
|
|
|
1
|
-
|
|
1
|
+
const require_factory = require('./factory-DeJMlphM.cjs');
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
get: function () { return chunkFIHRQE7D_cjs.createImportDeclaration; }
|
|
38
|
-
});
|
|
39
|
-
Object.defineProperty(exports, "createIndexSignature", {
|
|
40
|
-
enumerable: true,
|
|
41
|
-
get: function () { return chunkFIHRQE7D_cjs.createIndexSignature; }
|
|
42
|
-
});
|
|
43
|
-
Object.defineProperty(exports, "createInterfaceDeclaration", {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () { return chunkFIHRQE7D_cjs.createInterfaceDeclaration; }
|
|
46
|
-
});
|
|
47
|
-
Object.defineProperty(exports, "createIntersectionDeclaration", {
|
|
48
|
-
enumerable: true,
|
|
49
|
-
get: function () { return chunkFIHRQE7D_cjs.createIntersectionDeclaration; }
|
|
50
|
-
});
|
|
51
|
-
Object.defineProperty(exports, "createJSDoc", {
|
|
52
|
-
enumerable: true,
|
|
53
|
-
get: function () { return chunkFIHRQE7D_cjs.createJSDoc; }
|
|
54
|
-
});
|
|
55
|
-
Object.defineProperty(exports, "createLiteralTypeNode", {
|
|
56
|
-
enumerable: true,
|
|
57
|
-
get: function () { return chunkFIHRQE7D_cjs.createLiteralTypeNode; }
|
|
58
|
-
});
|
|
59
|
-
Object.defineProperty(exports, "createNamespaceDeclaration", {
|
|
60
|
-
enumerable: true,
|
|
61
|
-
get: function () { return chunkFIHRQE7D_cjs.createNamespaceDeclaration; }
|
|
62
|
-
});
|
|
63
|
-
Object.defineProperty(exports, "createNull", {
|
|
64
|
-
enumerable: true,
|
|
65
|
-
get: function () { return chunkFIHRQE7D_cjs.createNull; }
|
|
66
|
-
});
|
|
67
|
-
Object.defineProperty(exports, "createNumericLiteral", {
|
|
68
|
-
enumerable: true,
|
|
69
|
-
get: function () { return chunkFIHRQE7D_cjs.createNumericLiteral; }
|
|
70
|
-
});
|
|
71
|
-
Object.defineProperty(exports, "createOmitDeclaration", {
|
|
72
|
-
enumerable: true,
|
|
73
|
-
get: function () { return chunkFIHRQE7D_cjs.createOmitDeclaration; }
|
|
74
|
-
});
|
|
75
|
-
Object.defineProperty(exports, "createOptionalTypeNode", {
|
|
76
|
-
enumerable: true,
|
|
77
|
-
get: function () { return chunkFIHRQE7D_cjs.createOptionalTypeNode; }
|
|
78
|
-
});
|
|
79
|
-
Object.defineProperty(exports, "createParameterSignature", {
|
|
80
|
-
enumerable: true,
|
|
81
|
-
get: function () { return chunkFIHRQE7D_cjs.createParameterSignature; }
|
|
82
|
-
});
|
|
83
|
-
Object.defineProperty(exports, "createPropertySignature", {
|
|
84
|
-
enumerable: true,
|
|
85
|
-
get: function () { return chunkFIHRQE7D_cjs.createPropertySignature; }
|
|
86
|
-
});
|
|
87
|
-
Object.defineProperty(exports, "createQuestionToken", {
|
|
88
|
-
enumerable: true,
|
|
89
|
-
get: function () { return chunkFIHRQE7D_cjs.createQuestionToken; }
|
|
90
|
-
});
|
|
91
|
-
Object.defineProperty(exports, "createRestTypeNode", {
|
|
92
|
-
enumerable: true,
|
|
93
|
-
get: function () { return chunkFIHRQE7D_cjs.createRestTypeNode; }
|
|
94
|
-
});
|
|
95
|
-
Object.defineProperty(exports, "createStringLiteral", {
|
|
96
|
-
enumerable: true,
|
|
97
|
-
get: function () { return chunkFIHRQE7D_cjs.createStringLiteral; }
|
|
98
|
-
});
|
|
99
|
-
Object.defineProperty(exports, "createTrue", {
|
|
100
|
-
enumerable: true,
|
|
101
|
-
get: function () { return chunkFIHRQE7D_cjs.createTrue; }
|
|
102
|
-
});
|
|
103
|
-
Object.defineProperty(exports, "createTupleDeclaration", {
|
|
104
|
-
enumerable: true,
|
|
105
|
-
get: function () { return chunkFIHRQE7D_cjs.createTupleDeclaration; }
|
|
106
|
-
});
|
|
107
|
-
Object.defineProperty(exports, "createTupleTypeNode", {
|
|
108
|
-
enumerable: true,
|
|
109
|
-
get: function () { return chunkFIHRQE7D_cjs.createTupleTypeNode; }
|
|
110
|
-
});
|
|
111
|
-
Object.defineProperty(exports, "createTypeAliasDeclaration", {
|
|
112
|
-
enumerable: true,
|
|
113
|
-
get: function () { return chunkFIHRQE7D_cjs.createTypeAliasDeclaration; }
|
|
114
|
-
});
|
|
115
|
-
Object.defineProperty(exports, "createTypeDeclaration", {
|
|
116
|
-
enumerable: true,
|
|
117
|
-
get: function () { return chunkFIHRQE7D_cjs.createTypeDeclaration; }
|
|
118
|
-
});
|
|
119
|
-
Object.defineProperty(exports, "createTypeLiteralNode", {
|
|
120
|
-
enumerable: true,
|
|
121
|
-
get: function () { return chunkFIHRQE7D_cjs.createTypeLiteralNode; }
|
|
122
|
-
});
|
|
123
|
-
Object.defineProperty(exports, "createTypeReferenceNode", {
|
|
124
|
-
enumerable: true,
|
|
125
|
-
get: function () { return chunkFIHRQE7D_cjs.createTypeReferenceNode; }
|
|
126
|
-
});
|
|
127
|
-
Object.defineProperty(exports, "createUnionDeclaration", {
|
|
128
|
-
enumerable: true,
|
|
129
|
-
get: function () { return chunkFIHRQE7D_cjs.createUnionDeclaration; }
|
|
130
|
-
});
|
|
131
|
-
Object.defineProperty(exports, "keywordTypeNodes", {
|
|
132
|
-
enumerable: true,
|
|
133
|
-
get: function () { return chunkFIHRQE7D_cjs.keywordTypeNodes; }
|
|
134
|
-
});
|
|
135
|
-
Object.defineProperty(exports, "modifiers", {
|
|
136
|
-
enumerable: true,
|
|
137
|
-
get: function () { return chunkFIHRQE7D_cjs.modifiers; }
|
|
138
|
-
});
|
|
139
|
-
Object.defineProperty(exports, "syntaxKind", {
|
|
140
|
-
enumerable: true,
|
|
141
|
-
get: function () { return chunkFIHRQE7D_cjs.syntaxKind; }
|
|
142
|
-
});
|
|
143
|
-
//# sourceMappingURL=factory.cjs.map
|
|
144
|
-
//# sourceMappingURL=factory.cjs.map
|
|
3
|
+
exports.appendJSDocToNode = require_factory.appendJSDocToNode;
|
|
4
|
+
exports.createArrayDeclaration = require_factory.createArrayDeclaration;
|
|
5
|
+
exports.createArrayTypeNode = require_factory.createArrayTypeNode;
|
|
6
|
+
exports.createEnumDeclaration = require_factory.createEnumDeclaration;
|
|
7
|
+
exports.createExportDeclaration = require_factory.createExportDeclaration;
|
|
8
|
+
exports.createFalse = require_factory.createFalse;
|
|
9
|
+
exports.createIdentifier = require_factory.createIdentifier;
|
|
10
|
+
exports.createImportDeclaration = require_factory.createImportDeclaration;
|
|
11
|
+
exports.createIndexSignature = require_factory.createIndexSignature;
|
|
12
|
+
exports.createInterfaceDeclaration = require_factory.createInterfaceDeclaration;
|
|
13
|
+
exports.createIntersectionDeclaration = require_factory.createIntersectionDeclaration;
|
|
14
|
+
exports.createJSDoc = require_factory.createJSDoc;
|
|
15
|
+
exports.createLiteralTypeNode = require_factory.createLiteralTypeNode;
|
|
16
|
+
exports.createNamespaceDeclaration = require_factory.createNamespaceDeclaration;
|
|
17
|
+
exports.createNull = require_factory.createNull;
|
|
18
|
+
exports.createNumericLiteral = require_factory.createNumericLiteral;
|
|
19
|
+
exports.createOmitDeclaration = require_factory.createOmitDeclaration;
|
|
20
|
+
exports.createOptionalTypeNode = require_factory.createOptionalTypeNode;
|
|
21
|
+
exports.createParameterSignature = require_factory.createParameterSignature;
|
|
22
|
+
exports.createPropertySignature = require_factory.createPropertySignature;
|
|
23
|
+
exports.createQuestionToken = require_factory.createQuestionToken;
|
|
24
|
+
exports.createRestTypeNode = require_factory.createRestTypeNode;
|
|
25
|
+
exports.createStringLiteral = require_factory.createStringLiteral;
|
|
26
|
+
exports.createTrue = require_factory.createTrue;
|
|
27
|
+
exports.createTupleDeclaration = require_factory.createTupleDeclaration;
|
|
28
|
+
exports.createTupleTypeNode = require_factory.createTupleTypeNode;
|
|
29
|
+
exports.createTypeAliasDeclaration = require_factory.createTypeAliasDeclaration;
|
|
30
|
+
exports.createTypeDeclaration = require_factory.createTypeDeclaration;
|
|
31
|
+
exports.createTypeLiteralNode = require_factory.createTypeLiteralNode;
|
|
32
|
+
exports.createTypeReferenceNode = require_factory.createTypeReferenceNode;
|
|
33
|
+
exports.createUnionDeclaration = require_factory.createUnionDeclaration;
|
|
34
|
+
exports.keywordTypeNodes = require_factory.keywordTypeNodes;
|
|
35
|
+
exports.modifiers = require_factory.modifiers;
|
|
36
|
+
exports.syntaxKind = require_factory.syntaxKind;
|
package/dist/factory.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export {
|
|
1
|
+
import { appendJSDocToNode, createArrayDeclaration, createArrayTypeNode, createEnumDeclaration, createExportDeclaration, createFalse, createIdentifier, createImportDeclaration, createIndexSignature, createInterfaceDeclaration, createIntersectionDeclaration, createJSDoc, createLiteralTypeNode, createNamespaceDeclaration, createNull, createNumericLiteral, createOmitDeclaration, createOptionalTypeNode, createParameterSignature, createPropertySignature, createQuestionToken, createRestTypeNode, createStringLiteral, createTrue, createTupleDeclaration, createTupleTypeNode, createTypeAliasDeclaration, createTypeDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionDeclaration, keywordTypeNodes, modifiers, syntaxKind } from "./factory-_F-JTqnG.cjs";
|
|
2
|
+
export { appendJSDocToNode, createArrayDeclaration, createArrayTypeNode, createEnumDeclaration, createExportDeclaration, createFalse, createIdentifier, createImportDeclaration, createIndexSignature, createInterfaceDeclaration, createIntersectionDeclaration, createJSDoc, createLiteralTypeNode, createNamespaceDeclaration, createNull, createNumericLiteral, createOmitDeclaration, createOptionalTypeNode, createParameterSignature, createPropertySignature, createQuestionToken, createRestTypeNode, createStringLiteral, createTrue, createTupleDeclaration, createTupleTypeNode, createTypeAliasDeclaration, createTypeDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionDeclaration, keywordTypeNodes, modifiers, syntaxKind };
|
package/dist/factory.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export {
|
|
1
|
+
import { appendJSDocToNode, createArrayDeclaration, createArrayTypeNode, createEnumDeclaration, createExportDeclaration, createFalse, createIdentifier, createImportDeclaration, createIndexSignature, createInterfaceDeclaration, createIntersectionDeclaration, createJSDoc, createLiteralTypeNode, createNamespaceDeclaration, createNull, createNumericLiteral, createOmitDeclaration, createOptionalTypeNode, createParameterSignature, createPropertySignature, createQuestionToken, createRestTypeNode, createStringLiteral, createTrue, createTupleDeclaration, createTupleTypeNode, createTypeAliasDeclaration, createTypeDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionDeclaration, keywordTypeNodes, modifiers, syntaxKind } from "./factory-CUjjpSgy.js";
|
|
2
|
+
export { appendJSDocToNode, createArrayDeclaration, createArrayTypeNode, createEnumDeclaration, createExportDeclaration, createFalse, createIdentifier, createImportDeclaration, createIndexSignature, createInterfaceDeclaration, createIntersectionDeclaration, createJSDoc, createLiteralTypeNode, createNamespaceDeclaration, createNull, createNumericLiteral, createOmitDeclaration, createOptionalTypeNode, createParameterSignature, createPropertySignature, createQuestionToken, createRestTypeNode, createStringLiteral, createTrue, createTupleDeclaration, createTupleTypeNode, createTypeAliasDeclaration, createTypeDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionDeclaration, keywordTypeNodes, modifiers, syntaxKind };
|
package/dist/factory.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { appendJSDocToNode, createArrayDeclaration, createArrayTypeNode, createEnumDeclaration, createExportDeclaration, createFalse, createIdentifier, createImportDeclaration, createIndexSignature, createInterfaceDeclaration, createIntersectionDeclaration, createJSDoc, createLiteralTypeNode, createNamespaceDeclaration, createNull, createNumericLiteral, createOmitDeclaration, createOptionalTypeNode, createParameterSignature, createPropertySignature, createQuestionToken, createRestTypeNode, createStringLiteral, createTrue, createTupleDeclaration, createTupleTypeNode, createTypeAliasDeclaration, createTypeDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionDeclaration, keywordTypeNodes, modifiers, syntaxKind } from "./factory-CTKjALU5.js";
|
|
2
|
+
|
|
3
|
+
export { appendJSDocToNode, createArrayDeclaration, createArrayTypeNode, createEnumDeclaration, createExportDeclaration, createFalse, createIdentifier, createImportDeclaration, createIndexSignature, createInterfaceDeclaration, createIntersectionDeclaration, createJSDoc, createLiteralTypeNode, createNamespaceDeclaration, createNull, createNumericLiteral, createOmitDeclaration, createOptionalTypeNode, createParameterSignature, createPropertySignature, createQuestionToken, createRestTypeNode, createStringLiteral, createTrue, createTupleDeclaration, createTupleTypeNode, createTypeAliasDeclaration, createTypeDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionDeclaration, keywordTypeNodes, modifiers, syntaxKind };
|
package/dist/index.cjs
CHANGED
|
@@ -1,52 +1,66 @@
|
|
|
1
|
-
|
|
1
|
+
const require_factory = require('./factory-DeJMlphM.cjs');
|
|
2
|
+
const typescript = require_factory.__toESM(require("typescript"));
|
|
3
|
+
const prettier = require_factory.__toESM(require("prettier"));
|
|
4
|
+
const prettier_plugins_typescript = require_factory.__toESM(require("prettier/plugins/typescript"));
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
6
|
+
//#region src/print.ts
|
|
7
|
+
const { factory } = typescript.default;
|
|
8
|
+
/**
|
|
9
|
+
* Escaped new lines in code with block comments so they can be restored by {@link restoreNewLines}
|
|
10
|
+
* @param code The code to escape new lines in
|
|
11
|
+
* @returns The same code but with new lines escaped using block comments
|
|
12
|
+
*/
|
|
13
|
+
const escapeNewLines = (code) => code.replace(/\n\n/g, "\n/* :newline: */");
|
|
14
|
+
/**
|
|
15
|
+
* Reverses {@link escapeNewLines} and restores new lines
|
|
16
|
+
* @param code The code with escaped new lines
|
|
17
|
+
* @returns The same code with new lines restored
|
|
18
|
+
*/
|
|
19
|
+
const restoreNewLines = (code) => code.replace(/\/\* :newline: \*\//g, "\n");
|
|
20
|
+
/**
|
|
21
|
+
* Convert AST TypeScript nodes to a string based on the TypeScript printer.
|
|
22
|
+
* Ensures consistent output across environments.
|
|
23
|
+
*/
|
|
24
|
+
function print(elements, { source = "", baseName = "print.ts", removeComments, noEmitHelpers, newLine = typescript.default.NewLineKind.LineFeed, scriptKind = typescript.default.ScriptKind.TS } = {}) {
|
|
25
|
+
const sourceFile = typescript.default.createSourceFile(baseName, escapeNewLines(source), typescript.default.ScriptTarget.ES2022, false, scriptKind);
|
|
26
|
+
const printer = typescript.default.createPrinter({
|
|
27
|
+
omitTrailingSemicolon: true,
|
|
28
|
+
newLine,
|
|
29
|
+
removeComments,
|
|
30
|
+
noEmitHelpers
|
|
31
|
+
});
|
|
32
|
+
const nodes = (Array.isArray(elements) ? elements : [elements]).filter(Boolean).sort((a, b) => (a.pos ?? 0) - (b.pos ?? 0));
|
|
33
|
+
const output = printer.printList(typescript.default.ListFormat.MultiLine, factory.createNodeArray(nodes), sourceFile);
|
|
34
|
+
return restoreNewLines(output).replace(/\r\n/g, "\n");
|
|
27
35
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/format.ts
|
|
39
|
+
const formatOptions = {
|
|
40
|
+
tabWidth: 2,
|
|
41
|
+
printWidth: 160,
|
|
42
|
+
parser: "typescript",
|
|
43
|
+
singleQuote: true,
|
|
44
|
+
semi: false,
|
|
45
|
+
bracketSameLine: false,
|
|
46
|
+
endOfLine: "auto",
|
|
47
|
+
plugins: [prettier_plugins_typescript.default]
|
|
37
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* Format the generated code based on Prettier
|
|
51
|
+
*/
|
|
38
52
|
async function format(source) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
return prettier.format(source, formatOptions);
|
|
53
|
+
if (!source) return "";
|
|
54
|
+
return (0, prettier.format)(source, formatOptions);
|
|
43
55
|
}
|
|
44
56
|
|
|
45
|
-
|
|
57
|
+
//#endregion
|
|
58
|
+
Object.defineProperty(exports, 'factory', {
|
|
46
59
|
enumerable: true,
|
|
47
|
-
get: function () {
|
|
60
|
+
get: function () {
|
|
61
|
+
return require_factory.factory_exports;
|
|
62
|
+
}
|
|
48
63
|
});
|
|
49
64
|
exports.format = format;
|
|
50
65
|
exports.print = print;
|
|
51
|
-
//# sourceMappingURL=index.cjs.map
|
|
52
66
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["ts","code: string","elements: Array<ts.Node>","formatOptions: Options","pluginTypescript","source: string"],"sources":["../src/print.ts","../src/format.ts"],"sourcesContent":["import ts from 'typescript'\n\nimport type { PrinterOptions } from 'typescript'\n\nconst { factory } = ts\n\nexport type PrintOptions = {\n source?: string\n baseName?: string\n scriptKind?: ts.ScriptKind\n} & PrinterOptions\n\n/**\n * Escaped new lines in code with block comments so they can be restored by {@link restoreNewLines}\n * @param code The code to escape new lines in\n * @returns The same code but with new lines escaped using block comments\n */\nconst escapeNewLines = (code: string) => code.replace(/\\n\\n/g, '\\n/* :newline: */')\n\n/**\n * Reverses {@link escapeNewLines} and restores new lines\n * @param code The code with escaped new lines\n * @returns The same code with new lines restored\n */\nconst restoreNewLines = (code: string) => code.replace(/\\/\\* :newline: \\*\\//g, '\\n')\n\n/**\n * Convert AST TypeScript nodes to a string based on the TypeScript printer.\n * Ensures consistent output across environments.\n */\nexport function print(\n elements: Array<ts.Node>,\n { source = '', baseName = 'print.ts', removeComments, noEmitHelpers, newLine = ts.NewLineKind.LineFeed, scriptKind = ts.ScriptKind.TS }: PrintOptions = {},\n): string {\n const sourceFile = ts.createSourceFile(baseName, escapeNewLines(source), ts.ScriptTarget.ES2022, false, scriptKind)\n\n const printer = ts.createPrinter({\n omitTrailingSemicolon: true,\n newLine,\n removeComments,\n noEmitHelpers,\n })\n // make sure that the nodes have the same order on every machine\n const nodes = (Array.isArray(elements) ? elements : [elements]).filter(Boolean).sort((a, b) => (a.pos ?? 0) - (b.pos ?? 0))\n\n const output = printer.printList(ts.ListFormat.MultiLine, factory.createNodeArray(nodes), sourceFile)\n\n return restoreNewLines(output).replace(/\\r\\n/g, '\\n')\n}\n","import { format as prettierFormat } from 'prettier'\nimport pluginTypescript from 'prettier/plugins/typescript'\n\nimport type { Options } from 'prettier'\n\nconst formatOptions: Options = {\n tabWidth: 2,\n printWidth: 160,\n parser: 'typescript',\n singleQuote: true,\n semi: false,\n bracketSameLine: false,\n endOfLine: 'auto',\n plugins: [pluginTypescript],\n}\n\n/**\n * Format the generated code based on Prettier\n */\nexport async function format(source: string) {\n // do some basic linting with the ts compiler\n if (!source) {\n return ''\n }\n\n return prettierFormat(source, formatOptions)\n}\n"],"mappings":";;;;;;AAIA,MAAM,EAAE,SAAS,GAAGA;;;;;;AAapB,MAAM,iBAAiB,CAACC,SAAiB,KAAK,QAAQ,SAAS,oBAAoB;;;;;;AAOnF,MAAM,kBAAkB,CAACA,SAAiB,KAAK,QAAQ,wBAAwB,KAAK;;;;;AAMpF,SAAgB,MACdC,UACA,EAAE,SAAS,IAAI,WAAW,YAAY,gBAAgB,eAAe,UAAUF,mBAAG,YAAY,UAAU,aAAaA,mBAAG,WAAW,IAAkB,GAAG,CAAE,GAClJ;CACR,MAAM,aAAaA,mBAAG,iBAAiB,UAAU,eAAe,OAAO,EAAEA,mBAAG,aAAa,QAAQ,OAAO,WAAW;CAEnH,MAAM,UAAUA,mBAAG,cAAc;EAC/B,uBAAuB;EACvB;EACA;EACA;CACD,EAAC;CAEF,MAAM,SAAS,MAAM,QAAQ,SAAS,GAAG,WAAW,CAAC,QAAS,GAAE,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,OAAO,EAAE,OAAO,MAAM,EAAE,OAAO,GAAG;CAE3H,MAAM,SAAS,QAAQ,UAAUA,mBAAG,WAAW,WAAW,QAAQ,gBAAgB,MAAM,EAAE,WAAW;AAErG,QAAO,gBAAgB,OAAO,CAAC,QAAQ,SAAS,KAAK;AACtD;;;;AC3CD,MAAMG,gBAAyB;CAC7B,UAAU;CACV,YAAY;CACZ,QAAQ;CACR,aAAa;CACb,MAAM;CACN,iBAAiB;CACjB,WAAW;CACX,SAAS,CAACC,mCAAiB;AAC5B;;;;AAKD,eAAsB,OAAOC,QAAgB;AAE3C,KAAI,CAAC,OACH,QAAO;AAGT,6BAAsB,QAAQ,cAAc;AAC7C"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,20 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { factory_d_exports } from "./factory-_F-JTqnG.cjs";
|
|
2
|
+
import ts, { PrinterOptions } from "typescript";
|
|
3
3
|
|
|
4
|
+
//#region src/print.d.ts
|
|
4
5
|
type PrintOptions = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
source?: string;
|
|
7
|
+
baseName?: string;
|
|
8
|
+
scriptKind?: ts.ScriptKind;
|
|
8
9
|
} & PrinterOptions;
|
|
9
10
|
/**
|
|
10
11
|
* Convert AST TypeScript nodes to a string based on the TypeScript printer.
|
|
11
12
|
* Ensures consistent output across environments.
|
|
12
13
|
*/
|
|
13
|
-
declare function print(elements: Array<ts.Node>, {
|
|
14
|
-
|
|
14
|
+
declare function print(elements: Array<ts.Node>, {
|
|
15
|
+
source,
|
|
16
|
+
baseName,
|
|
17
|
+
removeComments,
|
|
18
|
+
noEmitHelpers,
|
|
19
|
+
newLine,
|
|
20
|
+
scriptKind
|
|
21
|
+
}?: PrintOptions): string;
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/format.d.ts
|
|
15
24
|
/**
|
|
16
25
|
* Format the generated code based on Prettier
|
|
17
26
|
*/
|
|
18
27
|
declare function format(source: string): Promise<string>;
|
|
19
|
-
|
|
20
|
-
export { format, print };
|
|
28
|
+
//#endregion
|
|
29
|
+
export { factory_d_exports as factory, format, print };
|
|
30
|
+
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { factory_d_exports } from "./factory-CUjjpSgy.js";
|
|
2
|
+
import ts, { PrinterOptions } from "typescript";
|
|
3
3
|
|
|
4
|
+
//#region src/print.d.ts
|
|
4
5
|
type PrintOptions = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
source?: string;
|
|
7
|
+
baseName?: string;
|
|
8
|
+
scriptKind?: ts.ScriptKind;
|
|
8
9
|
} & PrinterOptions;
|
|
9
10
|
/**
|
|
10
11
|
* Convert AST TypeScript nodes to a string based on the TypeScript printer.
|
|
11
12
|
* Ensures consistent output across environments.
|
|
12
13
|
*/
|
|
13
|
-
declare function print(elements: Array<ts.Node>, {
|
|
14
|
-
|
|
14
|
+
declare function print(elements: Array<ts.Node>, {
|
|
15
|
+
source,
|
|
16
|
+
baseName,
|
|
17
|
+
removeComments,
|
|
18
|
+
noEmitHelpers,
|
|
19
|
+
newLine,
|
|
20
|
+
scriptKind
|
|
21
|
+
}?: PrintOptions): string;
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/format.d.ts
|
|
15
24
|
/**
|
|
16
25
|
* Format the generated code based on Prettier
|
|
17
26
|
*/
|
|
18
27
|
declare function format(source: string): Promise<string>;
|
|
19
|
-
|
|
20
|
-
export { format, print };
|
|
28
|
+
//#endregion
|
|
29
|
+
export { factory_d_exports as factory, format, print };
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|