xray16 1.3.0 → 1.3.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/package.json +1 -1
- package/plugins/built_at_info.d.ts +3 -0
- package/plugins/constants.d.ts +2 -0
- package/plugins/constants.js +5 -0
- package/plugins/from_cast_utils.d.ts +7 -0
- package/plugins/global_declarations_transform.d.ts +6 -0
- package/plugins/inject_file_meta.d.ts +6 -0
- package/plugins/inject_tracy_zones.d.ts +6 -0
- package/plugins/inject_tracy_zones.js +4 -4
- package/plugins/strip_lua_logger.d.ts +6 -0
- package/plugins/strip_lua_logger.js +2 -2
- package/plugins/transform_luabind_class/plugin.d.ts +6 -0
- package/plugins/transform_luabind_class/transformation/class_declaration.d.ts +18 -0
- package/plugins/transform_luabind_class/transformation/constants.d.ts +4 -0
- package/plugins/transform_luabind_class/transformation/decorators.d.ts +6 -0
- package/plugins/transform_luabind_class/transformation/errors.d.ts +18 -0
- package/plugins/transform_luabind_class/transformation/index.d.ts +5 -0
- package/plugins/transform_luabind_class/transformation/members/accessors.d.ts +3 -0
- package/plugins/transform_luabind_class/transformation/members/constructor.d.ts +5 -0
- package/plugins/transform_luabind_class/transformation/members/fields.d.ts +8 -0
- package/plugins/transform_luabind_class/transformation/members/method.d.ts +10 -0
- package/plugins/transform_luabind_class/transformation/new.d.ts +7 -0
- package/plugins/transform_luabind_class/transformation/setup.d.ts +8 -0
- package/plugins/transform_luabind_class/transformation/super.d.ts +20 -0
- package/plugins/transform_luabind_class/transformation/utils.d.ts +30 -0
- package/plugins/utils/ast.d.ts +2 -0
- package/plugins/utils/diagnostics.d.ts +12 -0
- package/plugins/utils/environment.d.ts +2 -0
- package/plugins/utils/environment.js +9 -3
- package/plugins/utils/tracy.d.ts +13 -0
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const typescript_1 = require("typescript");
|
|
4
|
-
const environment_1 = require("./utils/environment");
|
|
5
4
|
const tracy_1 = require("./utils/tracy");
|
|
6
5
|
const ast_1 = require("./utils/ast");
|
|
6
|
+
const environment_1 = require("./utils/environment");
|
|
7
7
|
/**
|
|
8
8
|
* Plugin that injects FILE_NAME in compile-time.
|
|
9
9
|
*/
|
|
10
10
|
const plugin = {
|
|
11
11
|
visitors: {
|
|
12
12
|
[typescript_1.SyntaxKind.FunctionDeclaration]: (node, context) => {
|
|
13
|
-
return context.superTransformStatements(environment_1.
|
|
13
|
+
return context.superTransformStatements((0, environment_1.isTracyZonesInjectionEnabled)() ? (0, tracy_1.transformWithInjectedZones)(node) : node);
|
|
14
14
|
},
|
|
15
15
|
[typescript_1.SyntaxKind.ClassDeclaration]: (node, context) => {
|
|
16
|
-
if (environment_1.
|
|
16
|
+
if ((0, environment_1.isTracyZonesInjectionEnabled)()) {
|
|
17
17
|
const name = node.name ? node.name.getText() : null;
|
|
18
18
|
return context.superTransformStatements(typescript_1.factory.updateClassDeclaration(node, node.modifiers, node.name, node.typeParameters, node.heritageClauses, node.members.map((it) => {
|
|
19
19
|
if ((0, typescript_1.isMethodDeclaration)(it)) {
|
|
@@ -25,7 +25,7 @@ const plugin = {
|
|
|
25
25
|
return context.superTransformStatements(node);
|
|
26
26
|
},
|
|
27
27
|
[typescript_1.SyntaxKind.ExpressionStatement]: (statement, context) => {
|
|
28
|
-
if (environment_1.
|
|
28
|
+
if ((0, environment_1.isTracyZonesInjectionEnabled)()) {
|
|
29
29
|
const expression = statement.expression;
|
|
30
30
|
if ((0, typescript_1.isCallExpression)(expression) &&
|
|
31
31
|
expression.expression?.kind === typescript_1.SyntaxKind.Identifier &&
|
|
@@ -9,7 +9,7 @@ const LUA_LOGGER_STRIP_TARGET = "LuaLogger";
|
|
|
9
9
|
const plugin = {
|
|
10
10
|
visitors: {
|
|
11
11
|
[typescript_1.SyntaxKind.VariableStatement]: (statement, context) => {
|
|
12
|
-
if (environment_1.
|
|
12
|
+
if (!(0, environment_1.isLuaLoggerEnabled)()) {
|
|
13
13
|
let elementsCount = 0;
|
|
14
14
|
const list = statement.declarationList;
|
|
15
15
|
const nodes = [];
|
|
@@ -34,7 +34,7 @@ const plugin = {
|
|
|
34
34
|
return context.superTransformStatements(statement);
|
|
35
35
|
},
|
|
36
36
|
[typescript_1.SyntaxKind.ExpressionStatement]: (statement, context) => {
|
|
37
|
-
if (environment_1.
|
|
37
|
+
if (!(0, environment_1.isLuaLoggerEnabled)() && statement.expression?.kind === typescript_1.SyntaxKind.CallExpression) {
|
|
38
38
|
const expression = statement.expression;
|
|
39
39
|
const propertyAccess = expression.expression;
|
|
40
40
|
if (propertyAccess.expression?.kind === typescript_1.SyntaxKind.Identifier) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ClassLikeDeclaration, ExpressionWithTypeArguments } from "typescript";
|
|
2
|
+
import * as tstl from "typescript-to-lua";
|
|
3
|
+
import { TransformationContext } from "typescript-to-lua";
|
|
4
|
+
export interface ITransformationContext extends TransformationContext {
|
|
5
|
+
classSuperInfos: Array<ClassSuperInfo>;
|
|
6
|
+
}
|
|
7
|
+
export declare const transformLuabindClassDeclaration: (declaration: any, context: TransformationContext) => tstl.Statement[];
|
|
8
|
+
export declare function transformClassAsExpression(expression: ClassLikeDeclaration, context: ITransformationContext): tstl.Expression;
|
|
9
|
+
/** @internal */
|
|
10
|
+
export interface ClassSuperInfo {
|
|
11
|
+
className: tstl.Identifier;
|
|
12
|
+
classDeclaration: ClassLikeDeclaration;
|
|
13
|
+
extendedTypeNode?: ExpressionWithTypeArguments;
|
|
14
|
+
}
|
|
15
|
+
export declare function transformClassLikeDeclaration(classDeclaration: ClassLikeDeclaration, context: ITransformationContext, nameOverride?: tstl.Identifier): {
|
|
16
|
+
statements: tstl.Statement[];
|
|
17
|
+
name: tstl.Identifier;
|
|
18
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Decorator } from "typescript";
|
|
2
|
+
import { TransformationContext } from "typescript-to-lua";
|
|
3
|
+
/**
|
|
4
|
+
* Transform decorator call expressions for luabind class.
|
|
5
|
+
*/
|
|
6
|
+
export declare function checkLuabindClassDecoratorExpression(context: TransformationContext, decorator: Decorator): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const unsupportedStaticMethod: ((node: import("typescript").Node, name?: string) => import("typescript").Diagnostic) & {
|
|
2
|
+
code: number;
|
|
3
|
+
};
|
|
4
|
+
export declare const unsupportedClassDecorator: ((node: import("typescript").Node, name?: string) => import("typescript").Diagnostic) & {
|
|
5
|
+
code: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const unsupportedPropertyDecorator: ((node: import("typescript").Node, name?: string) => import("typescript").Diagnostic) & {
|
|
8
|
+
code: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const unsupportedParameterDecorator: ((node: import("typescript").Node, name?: string) => import("typescript").Diagnostic) & {
|
|
11
|
+
code: number;
|
|
12
|
+
};
|
|
13
|
+
export declare const unsupportedMethodDecorator: ((node: import("typescript").Node, name?: string) => import("typescript").Diagnostic) & {
|
|
14
|
+
code: number;
|
|
15
|
+
};
|
|
16
|
+
export declare const unsupportedStaticAccessor: ((node: import("typescript").Node, name?: string) => import("typescript").Diagnostic) & {
|
|
17
|
+
code: number;
|
|
18
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { AllAccessorDeclarations, TransformationContext } from "typescript-to-lua";
|
|
2
|
+
import * as lua from "typescript-to-lua";
|
|
3
|
+
export declare function transformAccessorDeclarations(context: TransformationContext, { firstAccessor, getAccessor, setAccessor }: AllAccessorDeclarations, className: lua.Identifier): lua.Statement | undefined;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ClassLikeDeclaration, ConstructorDeclaration, PropertyDeclaration } from "typescript";
|
|
2
|
+
import { TransformationContext } from "typescript-to-lua";
|
|
3
|
+
import * as lua from "typescript-to-lua";
|
|
4
|
+
export declare function createConstructorName(className: lua.Identifier): lua.TableIndexExpression;
|
|
5
|
+
export declare function transformConstructorDeclaration(context: TransformationContext, statement: ConstructorDeclaration, className: lua.Identifier, instanceFields: Array<PropertyDeclaration>, classDeclaration: ClassLikeDeclaration): lua.Statement | undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AccessorDeclaration, PropertyDeclaration } from "typescript";
|
|
2
|
+
import { TransformationContext } from "typescript-to-lua";
|
|
3
|
+
import * as tstl from "typescript-to-lua";
|
|
4
|
+
/**
|
|
5
|
+
* Verify whether decorators provided for luabind class.
|
|
6
|
+
*/
|
|
7
|
+
export declare function verifyPropertyDecoratingExpression(context: TransformationContext, node: PropertyDeclaration | AccessorDeclaration): void;
|
|
8
|
+
export declare function transformClassInstanceFields(context: TransformationContext, instanceFields: Array<PropertyDeclaration>): Array<tstl.Statement>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AccessorDeclaration, MethodDeclaration, PropertyDeclaration } from "typescript";
|
|
2
|
+
import { TransformationContext } from "typescript-to-lua";
|
|
3
|
+
import * as lua from "typescript-to-lua";
|
|
4
|
+
export declare function transformMemberExpressionOwnerName(node: PropertyDeclaration | MethodDeclaration | AccessorDeclaration, className: lua.Identifier): lua.Expression;
|
|
5
|
+
export declare function transformMethodName(context: TransformationContext, node: MethodDeclaration): lua.Expression;
|
|
6
|
+
export declare function transformMethodDeclaration(context: TransformationContext, node: MethodDeclaration, className: lua.Identifier): lua.Statement | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Verify that method statement is not using decorators for methods/parameters.
|
|
9
|
+
*/
|
|
10
|
+
export declare function verifyMethodDecoratingExpression(context: TransformationContext, node: MethodDeclaration): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { NewExpression } from "typescript";
|
|
2
|
+
import * as tstl from "typescript-to-lua";
|
|
3
|
+
import { ITransformationContext } from "./index";
|
|
4
|
+
/**
|
|
5
|
+
* Transform new call for luabind class as ClassConstructor() instead of TS_NEW from tstl.
|
|
6
|
+
*/
|
|
7
|
+
export declare function transformNewCallExpression(expression: NewExpression, context: ITransformationContext): tstl.CallExpression;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ClassLikeDeclarationBase } from "typescript";
|
|
2
|
+
import * as tstl from "typescript-to-lua";
|
|
3
|
+
import { TransformationContext } from "typescript-to-lua";
|
|
4
|
+
/**
|
|
5
|
+
* Create full class setup statement with name/super calls/methods/declaration/fields etc.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createClassSetup(context: TransformationContext, statement: ClassLikeDeclarationBase, className: tstl.Identifier, localClassName: tstl.Identifier): tstl.Statement[];
|
|
8
|
+
export declare function getReflectionClassName(declaration: ClassLikeDeclarationBase, className: tstl.Identifier): tstl.Expression;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CallExpression, Expression, SuperExpression } from "typescript";
|
|
2
|
+
import * as tstl from "typescript-to-lua";
|
|
3
|
+
import { ITransformationContext } from "./class_declaration";
|
|
4
|
+
/**
|
|
5
|
+
* Transform generic methods super calls.
|
|
6
|
+
* Example: super.parentMethod(first, second).
|
|
7
|
+
*/
|
|
8
|
+
export declare function transformClassSuperMethodExpression(expression: Expression, context: ITransformationContext): tstl.Expression;
|
|
9
|
+
/**
|
|
10
|
+
* Check if super() call is in luabind class target.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isLuabindClassSuperCall(expression: CallExpression | SuperExpression, context: ITransformationContext): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Check if super.method() call is in luabind class target.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isLuabindClassSuperMethodCall(expression: CallExpression | SuperExpression, context: ITransformationContext): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Transform super() call in luabind classes to base_class.__init(self, param).
|
|
19
|
+
*/
|
|
20
|
+
export declare function transformLuabindConstructorSuperCall(expression: CallExpression, context: ITransformationContext): tstl.CallExpression;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ClassLikeDeclaration, ClassLikeDeclarationBase, Expression, ExpressionWithTypeArguments, HasModifiers, HeritageClause, Type } from "typescript";
|
|
2
|
+
import { TransformationContext } from "typescript-to-lua";
|
|
3
|
+
/**
|
|
4
|
+
* Whether method / field is static.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isStaticNode(node: HasModifiers): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Get class extends node.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getExtendsClause(node: ClassLikeDeclarationBase): HeritageClause | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Get class extended node.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getExtendedNode(node: ClassLikeDeclarationBase): ExpressionWithTypeArguments | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Get class extended node.
|
|
17
|
+
*/
|
|
18
|
+
export declare function getExtendedType(context: TransformationContext, node: ClassLikeDeclarationBase): Type | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Check if class is decorated with provided decorator name.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isLuabindDecoratedClass(declaration: ClassLikeDeclaration): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Mark provided class as Luabind target.
|
|
25
|
+
*/
|
|
26
|
+
export declare function markTypeAsLuabind(declaration: ClassLikeDeclaration, context: TransformationContext): void;
|
|
27
|
+
/**
|
|
28
|
+
* Check if provided class is specified as LuaBind.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isLuabindClassType(declaration: Expression | ClassLikeDeclaration, context: TransformationContext): boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DiagnosticCategory, Node } from "typescript";
|
|
2
|
+
type MessageProvider<TArgs extends any[]> = string | ((...args: TArgs) => string);
|
|
3
|
+
/**
|
|
4
|
+
* Create diagnostics factory to push errors when transpile lua to typescript.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createDiagnosticFactory<TArgs extends any[]>(category: DiagnosticCategory, message: MessageProvider<TArgs>): ((node: Node, ...args: TArgs) => import("typescript").Diagnostic) & {
|
|
7
|
+
code: number;
|
|
8
|
+
};
|
|
9
|
+
export declare function createErrorDiagnosticFactory<TArgs extends any[]>(message: MessageProvider<TArgs>): ((node: Node, ...args: TArgs) => import("typescript").Diagnostic) & {
|
|
10
|
+
code: number;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
|
|
3
|
+
exports.isLuaLoggerEnabled = isLuaLoggerEnabled;
|
|
4
|
+
exports.isTracyZonesInjectionEnabled = isTracyZonesInjectionEnabled;
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
function isLuaLoggerEnabled() {
|
|
7
|
+
return !process.argv.includes("--no-lua-logs") && process.env[constants_1.ENV_XR_NO_LUA_LOGS] !== "true";
|
|
8
|
+
}
|
|
9
|
+
function isTracyZonesInjectionEnabled() {
|
|
10
|
+
return process.argv.includes("--inject-tracy-zones") || process.env[constants_1.ENV_XR_INJECT_TRACY_ZONES] === "true";
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ArrowFunction, ConstructorDeclaration, ExpressionStatement, FunctionDeclaration, MethodDeclaration, Node, NodeArray, Statement } from "typescript";
|
|
2
|
+
export declare function isTraceBeginExpression(node: Node): boolean;
|
|
3
|
+
export declare function isTraceEndExpression(node: Node): boolean;
|
|
4
|
+
export declare function createTraceZoneBeginExpression(): ExpressionStatement;
|
|
5
|
+
export declare function createTraceZoneBeginNExpression(name: string): ExpressionStatement;
|
|
6
|
+
export declare function createTraceZoneBeginSExpression(name: string): ExpressionStatement;
|
|
7
|
+
export declare function createTraceZoneEndExpression(): ExpressionStatement;
|
|
8
|
+
export declare function remapStatementsWithZoneEnd<T extends {
|
|
9
|
+
statements: NodeArray<Statement>;
|
|
10
|
+
}>(target: T): Array<Statement>;
|
|
11
|
+
export declare function transformNestedStatementsToInjectEndZones(statement?: Statement): Statement;
|
|
12
|
+
export declare function transformWithInjectedZones<T extends FunctionDeclaration | MethodDeclaration | ConstructorDeclaration>(node: T, parentName?: string): T;
|
|
13
|
+
export declare function transformArrowFunctionWithInjectedZones<T extends ArrowFunction>(node: T, name: string): T;
|