xray16 1.5.4 → 1.6.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/README.md +6 -0
- package/package.json +12 -6
- package/plugins/optimize_return_ternary.d.ts +6 -0
- package/plugins/optimize_return_ternary.js +65 -0
- package/xray16.d.ts +30847 -0
- package/types/index.d.ts +0 -55
- package/types/xr_ai/xr_action.d.ts +0 -1802
- package/types/xr_ai/xr_alife.d.ts +0 -1870
- package/types/xr_ai/xr_enemy_evaluation.d.ts +0 -134
- package/types/xr_ai/xr_goap.d.ts +0 -1116
- package/types/xr_ai/xr_graph.d.ts +0 -135
- package/types/xr_ai/xr_memory.d.ts +0 -382
- package/types/xr_lib/xr_animation.d.ts +0 -252
- package/types/xr_lib/xr_bitwise.d.ts +0 -44
- package/types/xr_lib/xr_color.d.ts +0 -142
- package/types/xr_lib/xr_debug.d.ts +0 -181
- package/types/xr_lib/xr_dialog.d.ts +0 -132
- package/types/xr_lib/xr_flags.d.ts +0 -592
- package/types/xr_lib/xr_fs.d.ts +0 -615
- package/types/xr_lib/xr_game.d.ts +0 -362
- package/types/xr_lib/xr_hit.d.ts +0 -125
- package/types/xr_lib/xr_ini.d.ts +0 -473
- package/types/xr_lib/xr_level.d.ts +0 -795
- package/types/xr_lib/xr_luabind.d.ts +0 -90
- package/types/xr_lib/xr_map.d.ts +0 -192
- package/types/xr_lib/xr_math.d.ts +0 -871
- package/types/xr_lib/xr_multiplayer.d.ts +0 -1079
- package/types/xr_lib/xr_profile.d.ts +0 -272
- package/types/xr_lib/xr_properties.d.ts +0 -610
- package/types/xr_lib/xr_relation.d.ts +0 -231
- package/types/xr_lib/xr_render.d.ts +0 -167
- package/types/xr_lib/xr_save.d.ts +0 -833
- package/types/xr_lib/xr_sound.d.ts +0 -515
- package/types/xr_lib/xr_stats.ts +0 -49
- package/types/xr_lib/xr_task.d.ts +0 -388
- package/types/xr_lib/xr_time.d.ts +0 -177
- package/types/xr_lib/xr_type.d.ts +0 -75
- package/types/xr_object/client/xr_anomaly.d.ts +0 -70
- package/types/xr_object/client/xr_artefact.d.ts +0 -153
- package/types/xr_object/client/xr_client_object.d.ts +0 -207
- package/types/xr_object/client/xr_creature.d.ts +0 -243
- package/types/xr_object/client/xr_item.d.ts +0 -370
- package/types/xr_object/client/xr_level.d.ts +0 -753
- package/types/xr_object/client/xr_physic.d.ts +0 -644
- package/types/xr_object/client/xr_zone.d.ts +0 -85
- package/types/xr_object/script/xr_script_interface.d.ts +0 -819
- package/types/xr_object/script/xr_script_object.d.ts +0 -5719
- package/types/xr_object/script/xr_script_trade.d.ts +0 -51
- package/types/xr_object/server/xr_server_object.d.ts +0 -1486
- package/types/xr_ui/xr_ui_asset.d.ts +0 -364
- package/types/xr_ui/xr_ui_core.d.ts +0 -424
- package/types/xr_ui/xr_ui_event.d.ts +0 -1449
- package/types/xr_ui/xr_ui_interface.d.ts +0 -2447
- package/types/xr_ui/xr_ui_menu.d.ts +0 -385
- package/types/xrf_plugin.d.ts +0 -109
package/README.md
CHANGED
|
@@ -61,6 +61,7 @@ Plugins can be included in [tstl tsconfig](https://typescripttolua.github.io/doc
|
|
|
61
61
|
{ "name": "xray16/plugins/strip_lua_logger" },
|
|
62
62
|
{ "name": "xray16/plugins/inject_filename" },
|
|
63
63
|
{ "name": "xray16/plugins/from_cast_utils" },
|
|
64
|
+
{ "name": "xray16/plugins/optimize_return_ternary" },
|
|
64
65
|
{ "name": "xray16/plugins/inject_tracy_zones" }
|
|
65
66
|
]
|
|
66
67
|
}
|
|
@@ -106,6 +107,11 @@ Lua does not provide convenient API do get filename in runtime and static step i
|
|
|
106
107
|
Plugin to simplify casting from `LuaTable` to typescript array/map objects.\
|
|
107
108
|
All the calls are completely gets stripped and removed from runtime.
|
|
108
109
|
|
|
110
|
+
### optimize_return_ternary
|
|
111
|
+
|
|
112
|
+
Plugin rewrites returned ternary expressions into direct `if` / `else` branch returns when it is safe.\
|
|
113
|
+
This avoids temporary result locals for patterns like `return condition ? first : second` while preserving general ternary semantics.
|
|
114
|
+
|
|
109
115
|
### inject_tracy_zones
|
|
110
116
|
|
|
111
117
|
Plugin designed to work specifically with [tracy profiler](https://github.com/wolfpld/tracy).\
|
package/package.json
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xray16",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"author": "Neloreck",
|
|
5
5
|
"repository": "https://github.com/xray-forge/xray-16-types",
|
|
6
|
+
"homepage": "https://xray-forge.github.io/xray-16-types/index.html",
|
|
6
7
|
"private": false,
|
|
7
|
-
"main": "
|
|
8
|
-
"types": "
|
|
8
|
+
"main": "xray16.d.ts",
|
|
9
|
+
"types": "xray16.d.ts",
|
|
9
10
|
"scripts": {
|
|
10
|
-
"prepublish": "npm run build
|
|
11
|
+
"prepublish": "npm run build",
|
|
12
|
+
"prepack": "npm run build",
|
|
13
|
+
"build": "npm run build:plugins && npm run build:types",
|
|
11
14
|
"build:plugins": "tsc -p ./src/tsconfig.json",
|
|
12
|
-
"build:types": "
|
|
15
|
+
"build:types": "rollup -c rollup.dts.config.mjs",
|
|
16
|
+
"build:docs": "typedoc",
|
|
13
17
|
"typecheck": "tsc --noEmit",
|
|
14
18
|
"typedoc": "typedoc",
|
|
15
19
|
"format": "prettier --write \"**/*.(js|ts|tsx|md)\" && eslint . --fix",
|
|
@@ -31,6 +35,8 @@
|
|
|
31
35
|
"eslint-plugin-jsdoc": "^63.0.7",
|
|
32
36
|
"globals": "^17.7.0",
|
|
33
37
|
"prettier": "^3.4.2",
|
|
38
|
+
"rollup": "^4.62.2",
|
|
39
|
+
"rollup-plugin-dts": "^6.4.1",
|
|
34
40
|
"typedoc": "^0.27.5",
|
|
35
41
|
"typescript": "5.7.2",
|
|
36
42
|
"typescript-eslint": "^8.62.0",
|
|
@@ -38,7 +44,7 @@
|
|
|
38
44
|
},
|
|
39
45
|
"files": [
|
|
40
46
|
"plugins/**/*",
|
|
41
|
-
"
|
|
47
|
+
"xray16.d.ts",
|
|
42
48
|
"README.md",
|
|
43
49
|
"LICENSE"
|
|
44
50
|
]
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ts = require("typescript");
|
|
4
|
+
const lua = require("typescript-to-lua");
|
|
5
|
+
const assignment_validation_1 = require("typescript-to-lua/dist/transformation/utils/assignment-validation");
|
|
6
|
+
const preceding_statements_1 = require("typescript-to-lua/dist/transformation/utils/preceding-statements");
|
|
7
|
+
const conditional_1 = require("typescript-to-lua/dist/transformation/visitors/conditional");
|
|
8
|
+
const multi_1 = require("typescript-to-lua/dist/transformation/visitors/language-extensions/multi");
|
|
9
|
+
const return_1 = require("typescript-to-lua/dist/transformation/visitors/return");
|
|
10
|
+
function getConditionalExpression(expression) {
|
|
11
|
+
let current = expression;
|
|
12
|
+
while (ts.isParenthesizedExpression(current) ||
|
|
13
|
+
ts.isAsExpression(current) ||
|
|
14
|
+
ts.isTypeAssertionExpression(current) ||
|
|
15
|
+
ts.isNonNullExpression(current) ||
|
|
16
|
+
ts.isSatisfiesExpression(current)) {
|
|
17
|
+
current = current.expression;
|
|
18
|
+
}
|
|
19
|
+
return ts.isConditionalExpression(current) ? current : null;
|
|
20
|
+
}
|
|
21
|
+
function hasMultiReturnBranch(context, expression) {
|
|
22
|
+
return ((0, multi_1.isMultiReturnType)(context.checker.getTypeAtLocation(expression.whenTrue)) ||
|
|
23
|
+
(0, multi_1.isMultiReturnType)(context.checker.getTypeAtLocation(expression.whenFalse)));
|
|
24
|
+
}
|
|
25
|
+
function transformExpressionToReturnStatements(context, statement, expression) {
|
|
26
|
+
const conditionalExpression = getConditionalExpression(expression);
|
|
27
|
+
if (conditionalExpression !== null && !hasMultiReturnBranch(context, conditionalExpression)) {
|
|
28
|
+
return transformConditionalReturnStatement(context, statement, conditionalExpression);
|
|
29
|
+
}
|
|
30
|
+
const value = (0, preceding_statements_1.transformInPrecedingStatementScope)(context, () => context.transformExpression(expression));
|
|
31
|
+
return [...value.precedingStatements, (0, return_1.createReturnStatement)(context, [value.result], statement)];
|
|
32
|
+
}
|
|
33
|
+
function transformConditionalReturnStatement(context, statement, expression) {
|
|
34
|
+
(0, conditional_1.checkOnlyTruthyCondition)(expression.condition, context);
|
|
35
|
+
const condition = (0, preceding_statements_1.transformInPrecedingStatementScope)(context, () => context.transformExpression(expression.condition));
|
|
36
|
+
const whenTrue = transformExpressionToReturnStatements(context, statement, expression.whenTrue);
|
|
37
|
+
const whenFalse = transformExpressionToReturnStatements(context, statement, expression.whenFalse);
|
|
38
|
+
return [
|
|
39
|
+
...condition.precedingStatements,
|
|
40
|
+
lua.createIfStatement(condition.result, lua.createBlock(whenTrue), lua.createBlock(whenFalse), expression),
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Plugin that rewrites returned ternary expressions as direct branch returns.
|
|
45
|
+
*/
|
|
46
|
+
const plugin = {
|
|
47
|
+
visitors: {
|
|
48
|
+
[ts.SyntaxKind.ReturnStatement]: (statement, context) => {
|
|
49
|
+
if (statement.expression === undefined) {
|
|
50
|
+
return context.superTransformStatements(statement);
|
|
51
|
+
}
|
|
52
|
+
const expression = getConditionalExpression(statement.expression);
|
|
53
|
+
if (expression === null || hasMultiReturnBranch(context, expression)) {
|
|
54
|
+
return context.superTransformStatements(statement);
|
|
55
|
+
}
|
|
56
|
+
const expressionType = context.checker.getTypeAtLocation(statement.expression);
|
|
57
|
+
const returnType = context.checker.getContextualType(statement.expression);
|
|
58
|
+
if (returnType !== undefined) {
|
|
59
|
+
(0, assignment_validation_1.validateAssignment)(context, statement, expressionType, returnType);
|
|
60
|
+
}
|
|
61
|
+
return transformConditionalReturnStatement(context, statement, expression);
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
exports.default = plugin;
|