@flamework-experimental/transformer 2.0.0-alpha.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/README.md +66 -0
- package/flamework-schema.json +76 -0
- package/flamework.config.schema.json +197 -0
- package/out/classes/buildInfo.js +467 -0
- package/out/classes/diagnostics.js +110 -0
- package/out/classes/logger.js +201 -0
- package/out/classes/nodeMetadata.js +232 -0
- package/out/classes/transformState.js +623 -0
- package/out/index.js +75 -0
- package/out/transformations/expressions/transformAccessExpression.js +35 -0
- package/out/transformations/expressions/transformBinaryExpression.js +57 -0
- package/out/transformations/expressions/transformCallExpression.js +33 -0
- package/out/transformations/expressions/transformDeleteExpression.js +22 -0
- package/out/transformations/expressions/transformNewExpression.js +17 -0
- package/out/transformations/expressions/transformUnaryExpression.js +63 -0
- package/out/transformations/macros/intrinsics/components.js +64 -0
- package/out/transformations/macros/intrinsics/env.js +31 -0
- package/out/transformations/macros/intrinsics/guards.js +43 -0
- package/out/transformations/macros/intrinsics/inlining.js +22 -0
- package/out/transformations/macros/intrinsics/networking.js +131 -0
- package/out/transformations/macros/intrinsics/parameters.js +81 -0
- package/out/transformations/macros/intrinsics/paths.js +42 -0
- package/out/transformations/macros/updateComponentConfig.js +409 -0
- package/out/transformations/plugins/nodeFactory.js +159 -0
- package/out/transformations/plugins/pluginHost.js +235 -0
- package/out/transformations/plugins/typeFacade.js +242 -0
- package/out/transformations/statements/transformClassDeclaration.js +282 -0
- package/out/transformations/transformExpression.js +34 -0
- package/out/transformations/transformFile.js +78 -0
- package/out/transformations/transformNetworkingCall.js +566 -0
- package/out/transformations/transformNode.js +27 -0
- package/out/transformations/transformStatement.js +57 -0
- package/out/transformations/transformStatementList.js +64 -0
- package/out/transformations/transformUserMacro.js +698 -0
- package/out/transformer.js +52 -0
- package/out/util/cache.js +10 -0
- package/out/util/constants.js +5 -0
- package/out/util/diagnosticsUtils.js +112 -0
- package/out/util/env.js +267 -0
- package/out/util/factory.js +583 -0
- package/out/util/functions/addLeadingComment.js +13 -0
- package/out/util/functions/arePathsEqual.js +14 -0
- package/out/util/functions/assert.js +17 -0
- package/out/util/functions/buildGuardFromType.js +713 -0
- package/out/util/functions/buildInstanceShape.js +156 -0
- package/out/util/functions/buildSerializerFromType.js +2309 -0
- package/out/util/functions/createPathTranslator.js +54 -0
- package/out/util/functions/emitTypescriptMismatch.js +80 -0
- package/out/util/functions/getDeclarationName.js +23 -0
- package/out/util/functions/getDeclarationOfType.js +7 -0
- package/out/util/functions/getIndexExpression.js +16 -0
- package/out/util/functions/getInstanceTypeFromType.js +75 -0
- package/out/util/functions/getNodeList.js +6 -0
- package/out/util/functions/getPackageJson.js +44 -0
- package/out/util/functions/getSuperClasses.js +51 -0
- package/out/util/functions/isAttributesAccess.js +23 -0
- package/out/util/functions/isCleanBuildDirectory.js +13 -0
- package/out/util/functions/isDefinedType.js +16 -0
- package/out/util/functions/isPathDescendantOf.js +25 -0
- package/out/util/functions/isTupleType.js +10 -0
- package/out/util/functions/parseCommandLine.js +31 -0
- package/out/util/functions/shuffle.js +39 -0
- package/out/util/functions/tryResolve.js +15 -0
- package/out/util/functions/validateConstraintMetadata.js +60 -0
- package/out/util/packages.js +12 -0
- package/out/util/projectConfig.js +221 -0
- package/out/util/schema.js +80 -0
- package/out/util/tsInternals.js +16 -0
- package/out/util/uid.js +227 -0
- package/package.json +45 -0
- package/rojo-schema.json +34 -0
- package/types.d.ts +4 -0
|
@@ -0,0 +1,583 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __values = (this && this.__values) || function(o) {
|
|
3
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
|
+
if (m) return m.call(o);
|
|
5
|
+
if (o && typeof o.length === "number") return {
|
|
6
|
+
next: function () {
|
|
7
|
+
if (o && i >= o.length) o = void 0;
|
|
8
|
+
return { value: o && o[i++], done: !o };
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.f = void 0;
|
|
18
|
+
var typescript_1 = __importDefault(require("typescript"));
|
|
19
|
+
/**
|
|
20
|
+
* Shorthand factory methods.
|
|
21
|
+
*
|
|
22
|
+
* Naming scheme:
|
|
23
|
+
*
|
|
24
|
+
* f.expressionType
|
|
25
|
+
* f.declarationTypeDeclaration
|
|
26
|
+
* f.statementTypeStatement
|
|
27
|
+
* f.typeNodeType
|
|
28
|
+
*
|
|
29
|
+
* f.is.*
|
|
30
|
+
* f.update.*
|
|
31
|
+
*
|
|
32
|
+
* Examples:
|
|
33
|
+
*
|
|
34
|
+
* f.string()
|
|
35
|
+
* f.classDeclaration()
|
|
36
|
+
* f.ifStatement()
|
|
37
|
+
*/
|
|
38
|
+
var f;
|
|
39
|
+
(function (f) {
|
|
40
|
+
var factory = typescript_1.default.factory;
|
|
41
|
+
function toExpression(expression, stringFn) {
|
|
42
|
+
if (stringFn === void 0) { stringFn = string; }
|
|
43
|
+
if (typeof expression === "string") {
|
|
44
|
+
return stringFn(expression);
|
|
45
|
+
}
|
|
46
|
+
else if (typeof expression === "number") {
|
|
47
|
+
return number(expression);
|
|
48
|
+
}
|
|
49
|
+
else if (typeof expression === "boolean") {
|
|
50
|
+
return bool(expression);
|
|
51
|
+
}
|
|
52
|
+
else if (Array.isArray(expression)) {
|
|
53
|
+
return array(expression.map(function (x) { return toExpression(x); }));
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
return expression;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
f.toExpression = toExpression;
|
|
60
|
+
/// Expressions
|
|
61
|
+
function string(str) {
|
|
62
|
+
return factory.createStringLiteral(str);
|
|
63
|
+
}
|
|
64
|
+
f.string = string;
|
|
65
|
+
function bool(value) {
|
|
66
|
+
return value ? factory.createTrue() : factory.createFalse();
|
|
67
|
+
}
|
|
68
|
+
f.bool = bool;
|
|
69
|
+
function array(values, multiLine) {
|
|
70
|
+
if (multiLine === void 0) { multiLine = true; }
|
|
71
|
+
return factory.createArrayLiteralExpression(values, multiLine);
|
|
72
|
+
}
|
|
73
|
+
f.array = array;
|
|
74
|
+
function number(value, flags) {
|
|
75
|
+
return +value < 0
|
|
76
|
+
? factory.createPrefixUnaryExpression(typescript_1.default.SyntaxKind.MinusToken, factory.createNumericLiteral(-value, flags))
|
|
77
|
+
: factory.createNumericLiteral(value, flags);
|
|
78
|
+
}
|
|
79
|
+
f.number = number;
|
|
80
|
+
function identifier(name, unique) {
|
|
81
|
+
if (unique === void 0) { unique = false; }
|
|
82
|
+
return unique
|
|
83
|
+
? factory.createUniqueName(name, typescript_1.default.GeneratedIdentifierFlags.Optimistic)
|
|
84
|
+
: factory.createIdentifier(name);
|
|
85
|
+
}
|
|
86
|
+
f.identifier = identifier;
|
|
87
|
+
function nil() {
|
|
88
|
+
return identifier("undefined");
|
|
89
|
+
}
|
|
90
|
+
f.nil = nil;
|
|
91
|
+
function field(name, property, expression) {
|
|
92
|
+
if (expression === void 0) { expression = false; }
|
|
93
|
+
if (typeof property === "string") {
|
|
94
|
+
return factory.createElementAccessExpression(toExpression(name, identifier), string(property));
|
|
95
|
+
}
|
|
96
|
+
if (typescript_1.default.isComputedPropertyName(property)) {
|
|
97
|
+
return field(name, property.expression);
|
|
98
|
+
}
|
|
99
|
+
if (typescript_1.default.isMemberName(property) && !expression) {
|
|
100
|
+
return factory.createPropertyAccessExpression(toExpression(name, identifier), property);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
return factory.createElementAccessExpression(toExpression(name, identifier), toExpression(property));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
f.field = field;
|
|
107
|
+
function statement(expression) {
|
|
108
|
+
if (expression !== undefined) {
|
|
109
|
+
return factory.createExpressionStatement(toExpression(expression));
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
return factory.createExpressionStatement(identifier("undefined"));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
f.statement = statement;
|
|
116
|
+
function call(expression, args, typeArguments) {
|
|
117
|
+
return factory.createCallExpression(toExpression(expression, identifier), typeArguments, args === null || args === void 0 ? void 0 : args.map(function (x) { return toExpression(x); }));
|
|
118
|
+
}
|
|
119
|
+
f.call = call;
|
|
120
|
+
function object(properties, multiLine) {
|
|
121
|
+
var e_1, _a;
|
|
122
|
+
if (multiLine === void 0) { multiLine = true; }
|
|
123
|
+
if (properties instanceof Array) {
|
|
124
|
+
return factory.createObjectLiteralExpression(properties, multiLine);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
var realProperties = [];
|
|
128
|
+
try {
|
|
129
|
+
for (var _b = __values(Object.keys(properties)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
130
|
+
var key = _c.value;
|
|
131
|
+
realProperties.push(propertyAssignmentDeclaration(key, properties[key]));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
135
|
+
finally {
|
|
136
|
+
try {
|
|
137
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
138
|
+
}
|
|
139
|
+
finally { if (e_1) throw e_1.error; }
|
|
140
|
+
}
|
|
141
|
+
return factory.createObjectLiteralExpression(realProperties, multiLine);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
f.object = object;
|
|
145
|
+
function as(expression, node, explicit) {
|
|
146
|
+
if (explicit === void 0) { explicit = false; }
|
|
147
|
+
return explicit
|
|
148
|
+
? factory.createAsExpression(factory.createAsExpression(expression, keywordType(typescript_1.default.SyntaxKind.UnknownKeyword)), node)
|
|
149
|
+
: factory.createAsExpression(expression, node);
|
|
150
|
+
}
|
|
151
|
+
f.as = as;
|
|
152
|
+
function asNever(expression) {
|
|
153
|
+
return f.as(expression, keywordType(typescript_1.default.SyntaxKind.NeverKeyword));
|
|
154
|
+
}
|
|
155
|
+
f.asNever = asNever;
|
|
156
|
+
function binary(left, op, right) {
|
|
157
|
+
return factory.createBinaryExpression(toExpression(left), op, toExpression(right));
|
|
158
|
+
}
|
|
159
|
+
f.binary = binary;
|
|
160
|
+
function elementAccessExpression(expression, index, questionToken) {
|
|
161
|
+
return questionToken
|
|
162
|
+
? factory.createElementAccessChain(toExpression(expression), questionToken, toExpression(index))
|
|
163
|
+
: factory.createElementAccessExpression(toExpression(expression), toExpression(index));
|
|
164
|
+
}
|
|
165
|
+
f.elementAccessExpression = elementAccessExpression;
|
|
166
|
+
function propertyAccessExpression(expression, name) {
|
|
167
|
+
return factory.createPropertyAccessExpression(toExpression(expression), name);
|
|
168
|
+
}
|
|
169
|
+
f.propertyAccessExpression = propertyAccessExpression;
|
|
170
|
+
function arrowFunction(body, parameters, typeParameters, type) {
|
|
171
|
+
return factory.createArrowFunction(undefined, typeParameters, parameters !== null && parameters !== void 0 ? parameters : [], type, factory.createToken(typescript_1.default.SyntaxKind.EqualsGreaterThanToken), body);
|
|
172
|
+
}
|
|
173
|
+
f.arrowFunction = arrowFunction;
|
|
174
|
+
function bang(expression) {
|
|
175
|
+
return factory.createNonNullExpression(toExpression(expression, identifier));
|
|
176
|
+
}
|
|
177
|
+
f.bang = bang;
|
|
178
|
+
function self() {
|
|
179
|
+
return typescript_1.default.factory.createThis();
|
|
180
|
+
}
|
|
181
|
+
f.self = self;
|
|
182
|
+
function superExpression() {
|
|
183
|
+
return typescript_1.default.factory.createSuper();
|
|
184
|
+
}
|
|
185
|
+
f.superExpression = superExpression;
|
|
186
|
+
/// Statements
|
|
187
|
+
function block(statements, multiLine) {
|
|
188
|
+
if (multiLine === void 0) { multiLine = true; }
|
|
189
|
+
return factory.createBlock(statements, multiLine);
|
|
190
|
+
}
|
|
191
|
+
f.block = block;
|
|
192
|
+
function returnStatement(expression) {
|
|
193
|
+
return factory.createReturnStatement(expression ? toExpression(expression) : undefined);
|
|
194
|
+
}
|
|
195
|
+
f.returnStatement = returnStatement;
|
|
196
|
+
function variableStatement(name, initializer, type, isMutable) {
|
|
197
|
+
if (isMutable === void 0) { isMutable = false; }
|
|
198
|
+
return factory.createVariableStatement(undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(name, undefined, type, initializer)], isMutable ? typescript_1.default.NodeFlags.Let : typescript_1.default.NodeFlags.Const));
|
|
199
|
+
}
|
|
200
|
+
f.variableStatement = variableStatement;
|
|
201
|
+
/// Declarations
|
|
202
|
+
function methodDeclaration(name, body, parameters, type, isOptional, typeParameters) {
|
|
203
|
+
if (isOptional === void 0) { isOptional = false; }
|
|
204
|
+
return factory.createMethodDeclaration(undefined, undefined, name, isOptional ? token(typescript_1.default.SyntaxKind.QuestionToken) : undefined, typeParameters, parameters !== null && parameters !== void 0 ? parameters : [], type, body);
|
|
205
|
+
}
|
|
206
|
+
f.methodDeclaration = methodDeclaration;
|
|
207
|
+
function arrayBindingDeclaration(elements) {
|
|
208
|
+
return factory.createArrayBindingPattern(elements.map(function (x) { return factory.createBindingElement(undefined, undefined, x, undefined); }));
|
|
209
|
+
}
|
|
210
|
+
f.arrayBindingDeclaration = arrayBindingDeclaration;
|
|
211
|
+
function parameterDeclaration(name, type, value, isOptional, isSpread) {
|
|
212
|
+
return factory.createParameterDeclaration(undefined, isSpread ? factory.createToken(typescript_1.default.SyntaxKind.DotDotDotToken) : undefined, name, isOptional ? factory.createToken(typescript_1.default.SyntaxKind.QuestionToken) : undefined, type, value);
|
|
213
|
+
}
|
|
214
|
+
f.parameterDeclaration = parameterDeclaration;
|
|
215
|
+
function typeParameterDeclaration(name, constraint, defaultType) {
|
|
216
|
+
return factory.createTypeParameterDeclaration(undefined, name, constraint, defaultType);
|
|
217
|
+
}
|
|
218
|
+
f.typeParameterDeclaration = typeParameterDeclaration;
|
|
219
|
+
function propertyAssignmentDeclaration(name, value) {
|
|
220
|
+
return factory.createPropertyAssignment(typeof name === "string" ? string(name) : name, toExpression(value));
|
|
221
|
+
}
|
|
222
|
+
f.propertyAssignmentDeclaration = propertyAssignmentDeclaration;
|
|
223
|
+
function propertyDeclaration(name, initializer, type, tokenType) {
|
|
224
|
+
return factory.createPropertyDeclaration(undefined, name, tokenType, type, initializer);
|
|
225
|
+
}
|
|
226
|
+
f.propertyDeclaration = propertyDeclaration;
|
|
227
|
+
function importDeclaration(path, imports, defaultImport, typeOnly) {
|
|
228
|
+
if (typeOnly === void 0) { typeOnly = false; }
|
|
229
|
+
return factory.createImportDeclaration(undefined, factory.createImportClause(typeOnly, defaultImport, imports
|
|
230
|
+
? factory.createNamedImports(imports.map(function (x) {
|
|
231
|
+
if (Array.isArray(x)) {
|
|
232
|
+
return factory.createImportSpecifier(false, typeof x[0] === "string" ? f.identifier(x[0]) : x[0], x[1]);
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
return factory.createImportSpecifier(false, undefined, x);
|
|
236
|
+
}
|
|
237
|
+
}))
|
|
238
|
+
: undefined), toExpression(path));
|
|
239
|
+
}
|
|
240
|
+
f.importDeclaration = importDeclaration;
|
|
241
|
+
function functionDeclaration(name, body, parameters, type, typeParams) {
|
|
242
|
+
if (parameters === void 0) { parameters = []; }
|
|
243
|
+
return factory.createFunctionDeclaration(undefined, undefined, name, typeParams, parameters, type, body);
|
|
244
|
+
}
|
|
245
|
+
f.functionDeclaration = functionDeclaration;
|
|
246
|
+
function typeAliasDeclaration(name, type, typeParameters) {
|
|
247
|
+
return factory.createTypeAliasDeclaration(undefined, name, typeParameters, type);
|
|
248
|
+
}
|
|
249
|
+
f.typeAliasDeclaration = typeAliasDeclaration;
|
|
250
|
+
function computedPropertyName(expression) {
|
|
251
|
+
return factory.createComputedPropertyName(expression);
|
|
252
|
+
}
|
|
253
|
+
f.computedPropertyName = computedPropertyName;
|
|
254
|
+
function staticBlockDeclaration(statements) {
|
|
255
|
+
return factory.createClassStaticBlockDeclaration(block(statements));
|
|
256
|
+
}
|
|
257
|
+
f.staticBlockDeclaration = staticBlockDeclaration;
|
|
258
|
+
/// Type Nodes
|
|
259
|
+
function functionType(parameters, returnType, typeParameters) {
|
|
260
|
+
return factory.createFunctionTypeNode(typeParameters !== null && typeParameters !== void 0 ? typeParameters : [], parameters, returnType);
|
|
261
|
+
}
|
|
262
|
+
f.functionType = functionType;
|
|
263
|
+
function unionType(types) {
|
|
264
|
+
return factory.createUnionTypeNode(types);
|
|
265
|
+
}
|
|
266
|
+
f.unionType = unionType;
|
|
267
|
+
function intersectionType(types) {
|
|
268
|
+
return factory.createIntersectionTypeNode(types);
|
|
269
|
+
}
|
|
270
|
+
f.intersectionType = intersectionType;
|
|
271
|
+
function importType(argument, qualifier, isTypeOf, typeArguments) {
|
|
272
|
+
return factory.createImportTypeNode(typeof argument === "string" ? literalType(string(argument)) : argument, undefined, qualifier, typeArguments, isTypeOf);
|
|
273
|
+
}
|
|
274
|
+
f.importType = importType;
|
|
275
|
+
function referenceType(typeName, typeArguments) {
|
|
276
|
+
return factory.createTypeReferenceNode(typeName, typeArguments);
|
|
277
|
+
}
|
|
278
|
+
f.referenceType = referenceType;
|
|
279
|
+
function keywordType(kind) {
|
|
280
|
+
return factory.createKeywordTypeNode(kind);
|
|
281
|
+
}
|
|
282
|
+
f.keywordType = keywordType;
|
|
283
|
+
function qualifiedNameType(left, right) {
|
|
284
|
+
return factory.createQualifiedName(left, right);
|
|
285
|
+
}
|
|
286
|
+
f.qualifiedNameType = qualifiedNameType;
|
|
287
|
+
function typeLiteralType(members) {
|
|
288
|
+
return factory.createTypeLiteralNode(members);
|
|
289
|
+
}
|
|
290
|
+
f.typeLiteralType = typeLiteralType;
|
|
291
|
+
function indexSignatureType(indexType, valueType) {
|
|
292
|
+
return factory.createIndexSignature(undefined, [parameterDeclaration("key", indexType)], valueType);
|
|
293
|
+
}
|
|
294
|
+
f.indexSignatureType = indexSignatureType;
|
|
295
|
+
function callSignatureType(parameters, returnType, typeParameters) {
|
|
296
|
+
return factory.createCallSignature(typeParameters, parameters, returnType);
|
|
297
|
+
}
|
|
298
|
+
f.callSignatureType = callSignatureType;
|
|
299
|
+
function tupleType(elements) {
|
|
300
|
+
return factory.createTupleTypeNode(elements);
|
|
301
|
+
}
|
|
302
|
+
f.tupleType = tupleType;
|
|
303
|
+
function literalType(expr) {
|
|
304
|
+
return factory.createLiteralTypeNode(expr);
|
|
305
|
+
}
|
|
306
|
+
f.literalType = literalType;
|
|
307
|
+
function propertySignatureType(name, type, isOptional) {
|
|
308
|
+
return factory.createPropertySignature(undefined, name, isOptional ? token(typescript_1.default.SyntaxKind.QuestionToken) : undefined, type);
|
|
309
|
+
}
|
|
310
|
+
f.propertySignatureType = propertySignatureType;
|
|
311
|
+
function indexedAccessType(left, right) {
|
|
312
|
+
return factory.createIndexedAccessTypeNode(left, right);
|
|
313
|
+
}
|
|
314
|
+
f.indexedAccessType = indexedAccessType;
|
|
315
|
+
function queryType(expression) {
|
|
316
|
+
return factory.createTypeQueryNode(expression);
|
|
317
|
+
}
|
|
318
|
+
f.queryType = queryType;
|
|
319
|
+
function selfType() {
|
|
320
|
+
return factory.createThisTypeNode();
|
|
321
|
+
}
|
|
322
|
+
f.selfType = selfType;
|
|
323
|
+
// Other
|
|
324
|
+
/**
|
|
325
|
+
* `ts.factory.createToken` is a large overload set whose first matching overload wins when the
|
|
326
|
+
* kind is generic, so it has to be called through a narrowed signature to return `Token<T>`.
|
|
327
|
+
*/
|
|
328
|
+
function token(kind) {
|
|
329
|
+
return factory.createToken(kind);
|
|
330
|
+
}
|
|
331
|
+
f.token = token;
|
|
332
|
+
function modifier(kind) {
|
|
333
|
+
return factory.createModifier(kind);
|
|
334
|
+
}
|
|
335
|
+
f.modifier = modifier;
|
|
336
|
+
var is;
|
|
337
|
+
(function (is) {
|
|
338
|
+
/// Expressions
|
|
339
|
+
function statement(node) {
|
|
340
|
+
return node !== undefined && typescript_1.default.isExpressionStatement(node);
|
|
341
|
+
}
|
|
342
|
+
is.statement = statement;
|
|
343
|
+
function string(node) {
|
|
344
|
+
return node !== undefined && typescript_1.default.isStringLiteral(node);
|
|
345
|
+
}
|
|
346
|
+
is.string = string;
|
|
347
|
+
function bool(node) {
|
|
348
|
+
return node !== undefined && (node === f.bool(true) || node === f.bool(false));
|
|
349
|
+
}
|
|
350
|
+
is.bool = bool;
|
|
351
|
+
function array(node) {
|
|
352
|
+
return node !== undefined && typescript_1.default.isArrayLiteralExpression(node);
|
|
353
|
+
}
|
|
354
|
+
is.array = array;
|
|
355
|
+
function number(node) {
|
|
356
|
+
return node !== undefined && typescript_1.default.isNumericLiteral(node);
|
|
357
|
+
}
|
|
358
|
+
is.number = number;
|
|
359
|
+
function identifier(node) {
|
|
360
|
+
return node !== undefined && typescript_1.default.isIdentifier(node);
|
|
361
|
+
}
|
|
362
|
+
is.identifier = identifier;
|
|
363
|
+
function nil(node) {
|
|
364
|
+
return node !== undefined && identifier(node) && node.text === "undefined";
|
|
365
|
+
}
|
|
366
|
+
is.nil = nil;
|
|
367
|
+
function call(node) {
|
|
368
|
+
return node !== undefined && typescript_1.default.isCallExpression(node);
|
|
369
|
+
}
|
|
370
|
+
is.call = call;
|
|
371
|
+
function object(node) {
|
|
372
|
+
return node !== undefined && typescript_1.default.isObjectLiteralExpression(node);
|
|
373
|
+
}
|
|
374
|
+
is.object = object;
|
|
375
|
+
function functionExpression(node) {
|
|
376
|
+
return node !== undefined && (typescript_1.default.isArrowFunction(node) || typescript_1.default.isFunctionExpression(node));
|
|
377
|
+
}
|
|
378
|
+
is.functionExpression = functionExpression;
|
|
379
|
+
function omitted(node) {
|
|
380
|
+
return node !== undefined && typescript_1.default.isOmittedExpression(node);
|
|
381
|
+
}
|
|
382
|
+
is.omitted = omitted;
|
|
383
|
+
function accessExpression(node) {
|
|
384
|
+
return node !== undefined && typescript_1.default.isAccessExpression(node);
|
|
385
|
+
}
|
|
386
|
+
is.accessExpression = accessExpression;
|
|
387
|
+
function propertyAccessExpression(node) {
|
|
388
|
+
return node !== undefined && typescript_1.default.isPropertyAccessExpression(node);
|
|
389
|
+
}
|
|
390
|
+
is.propertyAccessExpression = propertyAccessExpression;
|
|
391
|
+
function elementAccessExpression(node) {
|
|
392
|
+
return node !== undefined && typescript_1.default.isElementAccessExpression(node);
|
|
393
|
+
}
|
|
394
|
+
is.elementAccessExpression = elementAccessExpression;
|
|
395
|
+
function postfixUnary(node) {
|
|
396
|
+
return node !== undefined && typescript_1.default.isPostfixUnaryExpression(node);
|
|
397
|
+
}
|
|
398
|
+
is.postfixUnary = postfixUnary;
|
|
399
|
+
function superExpression(node) {
|
|
400
|
+
return node !== undefined && typescript_1.default.isSuperKeyword(node);
|
|
401
|
+
}
|
|
402
|
+
is.superExpression = superExpression;
|
|
403
|
+
function asExpression(node) {
|
|
404
|
+
return node !== undefined && typescript_1.default.isAsExpression(node);
|
|
405
|
+
}
|
|
406
|
+
is.asExpression = asExpression;
|
|
407
|
+
/// Statements
|
|
408
|
+
/// Declarations
|
|
409
|
+
function enumDeclaration(node) {
|
|
410
|
+
return node !== undefined && typescript_1.default.isEnumDeclaration(node);
|
|
411
|
+
}
|
|
412
|
+
is.enumDeclaration = enumDeclaration;
|
|
413
|
+
function constructor(node) {
|
|
414
|
+
return node !== undefined && typescript_1.default.isConstructorDeclaration(node);
|
|
415
|
+
}
|
|
416
|
+
is.constructor = constructor;
|
|
417
|
+
function propertyDeclaration(node) {
|
|
418
|
+
return node !== undefined && typescript_1.default.isPropertyDeclaration(node);
|
|
419
|
+
}
|
|
420
|
+
is.propertyDeclaration = propertyDeclaration;
|
|
421
|
+
function propertyAssignmentDeclaration(node) {
|
|
422
|
+
return node !== undefined && typescript_1.default.isPropertyAssignment(node);
|
|
423
|
+
}
|
|
424
|
+
is.propertyAssignmentDeclaration = propertyAssignmentDeclaration;
|
|
425
|
+
function importDeclaration(node) {
|
|
426
|
+
return node !== undefined && typescript_1.default.isImportDeclaration(node);
|
|
427
|
+
}
|
|
428
|
+
is.importDeclaration = importDeclaration;
|
|
429
|
+
function classDeclaration(node) {
|
|
430
|
+
return node !== undefined && typescript_1.default.isClassDeclaration(node);
|
|
431
|
+
}
|
|
432
|
+
is.classDeclaration = classDeclaration;
|
|
433
|
+
function methodDeclaration(node) {
|
|
434
|
+
return node !== undefined && typescript_1.default.isMethodDeclaration(node);
|
|
435
|
+
}
|
|
436
|
+
is.methodDeclaration = methodDeclaration;
|
|
437
|
+
function namespaceDeclaration(node) {
|
|
438
|
+
return ((node !== undefined &&
|
|
439
|
+
typescript_1.default.isModuleDeclaration(node) &&
|
|
440
|
+
identifier(node.name) &&
|
|
441
|
+
node.body &&
|
|
442
|
+
typescript_1.default.isNamespaceBody(node.body)) ||
|
|
443
|
+
false);
|
|
444
|
+
}
|
|
445
|
+
is.namespaceDeclaration = namespaceDeclaration;
|
|
446
|
+
function moduleBlockDeclaration(node) {
|
|
447
|
+
return node !== undefined && typescript_1.default.isModuleBlock(node);
|
|
448
|
+
}
|
|
449
|
+
is.moduleBlockDeclaration = moduleBlockDeclaration;
|
|
450
|
+
function importClauseDeclaration(node) {
|
|
451
|
+
return node !== undefined && typescript_1.default.isImportClause(node);
|
|
452
|
+
}
|
|
453
|
+
is.importClauseDeclaration = importClauseDeclaration;
|
|
454
|
+
function namedDeclaration(node) {
|
|
455
|
+
return node !== undefined && typescript_1.default.isNamedDeclaration(node);
|
|
456
|
+
}
|
|
457
|
+
is.namedDeclaration = namedDeclaration;
|
|
458
|
+
function interfaceDeclaration(node) {
|
|
459
|
+
return node !== undefined && typescript_1.default.isInterfaceDeclaration(node);
|
|
460
|
+
}
|
|
461
|
+
is.interfaceDeclaration = interfaceDeclaration;
|
|
462
|
+
function typeAliasDeclaration(node) {
|
|
463
|
+
return node !== undefined && typescript_1.default.isTypeAliasDeclaration(node);
|
|
464
|
+
}
|
|
465
|
+
is.typeAliasDeclaration = typeAliasDeclaration;
|
|
466
|
+
/// Type Nodes
|
|
467
|
+
function referenceType(node) {
|
|
468
|
+
return node !== undefined && typescript_1.default.isTypeReferenceNode(node);
|
|
469
|
+
}
|
|
470
|
+
is.referenceType = referenceType;
|
|
471
|
+
function queryType(node) {
|
|
472
|
+
return node !== undefined && typescript_1.default.isTypeQueryNode(node);
|
|
473
|
+
}
|
|
474
|
+
is.queryType = queryType;
|
|
475
|
+
function importType(node) {
|
|
476
|
+
return node !== undefined && typescript_1.default.isImportTypeNode(node);
|
|
477
|
+
}
|
|
478
|
+
is.importType = importType;
|
|
479
|
+
/// OTHERS
|
|
480
|
+
function namedImports(node) {
|
|
481
|
+
return node !== undefined && typescript_1.default.isNamedImports(node);
|
|
482
|
+
}
|
|
483
|
+
is.namedImports = namedImports;
|
|
484
|
+
function file(node) {
|
|
485
|
+
return node !== undefined && typescript_1.default.isSourceFile(node);
|
|
486
|
+
}
|
|
487
|
+
is.file = file;
|
|
488
|
+
})(is = f.is || (f.is = {}));
|
|
489
|
+
var update;
|
|
490
|
+
(function (update) {
|
|
491
|
+
/// Expressions
|
|
492
|
+
function call(node, expression, args, typeArguments) {
|
|
493
|
+
var _a;
|
|
494
|
+
if (expression === void 0) { expression = node.expression; }
|
|
495
|
+
return factory.updateCallExpression(node, expression, typeArguments !== null && typeArguments !== void 0 ? typeArguments : node.typeArguments, (_a = args === null || args === void 0 ? void 0 : args.map(function (x) { return toExpression(x); })) !== null && _a !== void 0 ? _a : node.arguments);
|
|
496
|
+
}
|
|
497
|
+
update.call = call;
|
|
498
|
+
function object(node, properties) {
|
|
499
|
+
return factory.updateObjectLiteralExpression(node, properties !== null && properties !== void 0 ? properties : node.properties);
|
|
500
|
+
}
|
|
501
|
+
update.object = object;
|
|
502
|
+
function propertyAccessExpression(node, expression, name) {
|
|
503
|
+
return factory.updatePropertyAccessExpression(node, toExpression(expression), typeof name === "string" ? f.identifier(name) : name);
|
|
504
|
+
}
|
|
505
|
+
update.propertyAccessExpression = propertyAccessExpression;
|
|
506
|
+
function elementAccessExpression(node, expression, name) {
|
|
507
|
+
return factory.updateElementAccessExpression(node, toExpression(expression), toExpression(name));
|
|
508
|
+
}
|
|
509
|
+
update.elementAccessExpression = elementAccessExpression;
|
|
510
|
+
/// Statements
|
|
511
|
+
/// Declarations
|
|
512
|
+
function classDeclaration(node, name, members, heritageClauses, typeParameters, modifiers) {
|
|
513
|
+
if (name === void 0) { name = node.name; }
|
|
514
|
+
if (members === void 0) { members = node.members; }
|
|
515
|
+
if (heritageClauses === void 0) { heritageClauses = node.heritageClauses; }
|
|
516
|
+
if (typeParameters === void 0) { typeParameters = node.typeParameters; }
|
|
517
|
+
if (modifiers === void 0) { modifiers = node.modifiers; }
|
|
518
|
+
return factory.updateClassDeclaration(node, modifiers, name, typeParameters, heritageClauses, members);
|
|
519
|
+
}
|
|
520
|
+
update.classDeclaration = classDeclaration;
|
|
521
|
+
function constructor(node, parameters, body) {
|
|
522
|
+
return factory.updateConstructorDeclaration(node, node.modifiers, parameters, body);
|
|
523
|
+
}
|
|
524
|
+
update.constructor = constructor;
|
|
525
|
+
function parameterDeclaration(node, name, type, initializer, modifiers, isRest, isOptional) {
|
|
526
|
+
if (name === void 0) { name = node.name; }
|
|
527
|
+
if (type === void 0) { type = node.type; }
|
|
528
|
+
if (initializer === void 0) { initializer = node.initializer; }
|
|
529
|
+
if (modifiers === void 0) { modifiers = node.modifiers; }
|
|
530
|
+
if (isRest === void 0) { isRest = node.dotDotDotToken !== undefined; }
|
|
531
|
+
if (isOptional === void 0) { isOptional = node.questionToken !== undefined; }
|
|
532
|
+
return factory.updateParameterDeclaration(node, (modifiers === null || modifiers === void 0 ? void 0 : modifiers.length) ? modifiers : undefined, isRest ? token(typescript_1.default.SyntaxKind.DotDotDotToken) : undefined, name, isOptional ? token(typescript_1.default.SyntaxKind.QuestionToken) : undefined, type, initializer);
|
|
533
|
+
}
|
|
534
|
+
update.parameterDeclaration = parameterDeclaration;
|
|
535
|
+
function methodDeclaration(node, name, body, parameters, typeParameters, modifiers, isOptional, type) {
|
|
536
|
+
if (name === void 0) { name = node.name; }
|
|
537
|
+
if (body === void 0) { body = node.body; }
|
|
538
|
+
if (parameters === void 0) { parameters = node.parameters; }
|
|
539
|
+
if (typeParameters === void 0) { typeParameters = node.typeParameters; }
|
|
540
|
+
if (modifiers === void 0) { modifiers = node.modifiers; }
|
|
541
|
+
if (isOptional === void 0) { isOptional = node.questionToken !== undefined; }
|
|
542
|
+
if (type === void 0) { type = node.type; }
|
|
543
|
+
return factory.updateMethodDeclaration(node, (modifiers === null || modifiers === void 0 ? void 0 : modifiers.length) === 0 ? undefined : modifiers, node.asteriskToken, typeof name === "string" ? identifier(name) : name, isOptional ? factory.createToken(typescript_1.default.SyntaxKind.QuestionToken) : undefined, (typeParameters === null || typeParameters === void 0 ? void 0 : typeParameters.length) === 0 ? undefined : typeParameters, parameters, type, Array.isArray(body) ? f.block(body) : body);
|
|
544
|
+
}
|
|
545
|
+
update.methodDeclaration = methodDeclaration;
|
|
546
|
+
function propertyDeclaration(node, initializer, name, modifiers, tokenType, type) {
|
|
547
|
+
if (initializer === void 0) { initializer = node.initializer; }
|
|
548
|
+
if (name === void 0) { name = node.name; }
|
|
549
|
+
if (modifiers === void 0) { modifiers = node.modifiers; }
|
|
550
|
+
if (tokenType === void 0) { tokenType = node.questionToken ? "?" : node.exclamationToken ? "!" : undefined; }
|
|
551
|
+
if (type === void 0) { type = node.type; }
|
|
552
|
+
var syntaxToken = tokenType === "!"
|
|
553
|
+
? token(typescript_1.default.SyntaxKind.ExclamationToken)
|
|
554
|
+
: tokenType === "?"
|
|
555
|
+
? token(typescript_1.default.SyntaxKind.QuestionToken)
|
|
556
|
+
: undefined;
|
|
557
|
+
return factory.updatePropertyDeclaration(node, (modifiers === null || modifiers === void 0 ? void 0 : modifiers.length) === 0 ? undefined : modifiers, name, syntaxToken, type, !initializer ? undefined : toExpression(initializer));
|
|
558
|
+
}
|
|
559
|
+
update.propertyDeclaration = propertyDeclaration;
|
|
560
|
+
function propertyAssignmentDeclaration(node, initializer, name) {
|
|
561
|
+
if (initializer === void 0) { initializer = node.initializer; }
|
|
562
|
+
if (name === void 0) { name = node.name; }
|
|
563
|
+
return factory.updatePropertyAssignment(node, typeof name === "string" ? f.identifier(name) : name, toExpression(initializer));
|
|
564
|
+
}
|
|
565
|
+
update.propertyAssignmentDeclaration = propertyAssignmentDeclaration;
|
|
566
|
+
/// Type Nodes
|
|
567
|
+
/// Other
|
|
568
|
+
function sourceFile(sourceFile, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) {
|
|
569
|
+
if (statements === void 0) { statements = sourceFile.statements; }
|
|
570
|
+
if (isDeclarationFile === void 0) { isDeclarationFile = sourceFile.isDeclarationFile; }
|
|
571
|
+
if (referencedFiles === void 0) { referencedFiles = sourceFile.referencedFiles; }
|
|
572
|
+
if (typeReferences === void 0) { typeReferences = sourceFile.typeReferenceDirectives; }
|
|
573
|
+
if (hasNoDefaultLib === void 0) { hasNoDefaultLib = sourceFile.hasNoDefaultLib; }
|
|
574
|
+
if (libReferences === void 0) { libReferences = sourceFile.libReferenceDirectives; }
|
|
575
|
+
return factory.updateSourceFile(sourceFile, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences);
|
|
576
|
+
}
|
|
577
|
+
update.sourceFile = sourceFile;
|
|
578
|
+
})(update = f.update || (f.update = {}));
|
|
579
|
+
function setFactory(newFactory) {
|
|
580
|
+
factory = newFactory;
|
|
581
|
+
}
|
|
582
|
+
f.setFactory = setFactory;
|
|
583
|
+
})(f || (exports.f = f = {}));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.addLeadingComment = addLeadingComment;
|
|
7
|
+
var typescript_1 = __importDefault(require("typescript"));
|
|
8
|
+
function addLeadingComment(node, text, multiline) {
|
|
9
|
+
if (multiline === void 0) { multiline = false; }
|
|
10
|
+
if (node === undefined)
|
|
11
|
+
return node;
|
|
12
|
+
return typescript_1.default.addSyntheticLeadingComment(node, multiline ? typescript_1.default.SyntaxKind.MultiLineCommentTrivia : typescript_1.default.SyntaxKind.SingleLineCommentTrivia, text, true);
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.arePathsEqual = arePathsEqual;
|
|
7
|
+
var path_1 = __importDefault(require("path"));
|
|
8
|
+
function arePathsEqual(path1, path2) {
|
|
9
|
+
if (process.platform === "win32") {
|
|
10
|
+
path1 = path1.toLowerCase();
|
|
11
|
+
path2 = path2.toLowerCase();
|
|
12
|
+
}
|
|
13
|
+
return path_1.default.normalize(path1) === path_1.default.normalize(path2);
|
|
14
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assert = assert;
|
|
4
|
+
/**
|
|
5
|
+
* Asserts the truthiness of `value`, stops the debugger on failure.
|
|
6
|
+
* @param value The value to check the truthiness of
|
|
7
|
+
* @param message Optional. The message of the error
|
|
8
|
+
*/
|
|
9
|
+
function assert(value, message) {
|
|
10
|
+
/* istanbul ignore if */
|
|
11
|
+
if (!value) {
|
|
12
|
+
debugger;
|
|
13
|
+
throw new Error("Assertion Failed! ".concat(message !== null && message !== void 0 ? message : "") +
|
|
14
|
+
"\nPlease submit a bug report here:" +
|
|
15
|
+
"\nhttps://github.com/rbxts-flamework/core/issues");
|
|
16
|
+
}
|
|
17
|
+
}
|