xray16 1.3.4 → 1.5.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/LICENSE +21 -21
- package/README.md +112 -106
- package/package.json +45 -42
- package/plugins/built_at_info.d.ts +1 -1
- package/plugins/from_cast_utils.d.ts +1 -1
- package/plugins/global_declarations_transform.d.ts +1 -1
- package/plugins/inject_file_meta.d.ts +1 -1
- package/plugins/inject_tracy_zones.d.ts +1 -1
- package/plugins/inject_tracy_zones.js +2 -2
- package/plugins/strip_lua_logger.d.ts +1 -1
- package/plugins/strip_lua_logger.js +1 -1
- package/plugins/transform_luabind_class/plugin.d.ts +1 -1
- package/plugins/transform_luabind_class/transformation/class_declaration.d.ts +3 -3
- package/plugins/transform_luabind_class/transformation/decorators.d.ts +5 -2
- package/plugins/transform_luabind_class/transformation/decorators.js +3 -0
- package/plugins/transform_luabind_class/transformation/members/accessors.d.ts +1 -1
- package/plugins/transform_luabind_class/transformation/members/constructor.d.ts +2 -2
- package/plugins/transform_luabind_class/transformation/members/constructor.js +2 -2
- package/plugins/transform_luabind_class/transformation/members/fields.d.ts +5 -2
- package/plugins/transform_luabind_class/transformation/members/fields.js +5 -2
- package/plugins/transform_luabind_class/transformation/members/method.d.ts +6 -3
- package/plugins/transform_luabind_class/transformation/members/method.js +4 -1
- package/plugins/transform_luabind_class/transformation/new.d.ts +7 -3
- package/plugins/transform_luabind_class/transformation/new.js +5 -1
- package/plugins/transform_luabind_class/transformation/setup.d.ts +9 -3
- package/plugins/transform_luabind_class/transformation/setup.js +22 -6
- package/plugins/transform_luabind_class/transformation/super.d.ts +19 -3
- package/plugins/transform_luabind_class/transformation/super.js +17 -1
- package/plugins/transform_luabind_class/transformation/utils.d.ts +27 -4
- package/plugins/transform_luabind_class/transformation/utils.js +25 -2
- package/plugins/utils/ast.d.ts +1 -1
- package/plugins/utils/diagnostics.d.ts +9 -5
- package/plugins/utils/diagnostics.js +5 -1
- package/plugins/utils/tracy.d.ts +1 -1
- package/types/index.d.ts +55 -55
- package/types/xr_ai/xr_action.d.ts +1802 -510
- package/types/xr_ai/xr_alife.d.ts +1870 -566
- package/types/xr_ai/xr_enemy_evaluation.d.ts +134 -41
- package/types/xr_ai/xr_goap.d.ts +1116 -668
- package/types/xr_ai/xr_graph.d.ts +135 -47
- package/types/xr_ai/xr_memory.d.ts +382 -148
- package/types/xr_lib/xr_animation.d.ts +252 -81
- package/types/xr_lib/xr_bitwise.d.ts +44 -21
- package/types/xr_lib/xr_color.d.ts +142 -40
- package/types/xr_lib/xr_debug.d.ts +181 -77
- package/types/xr_lib/xr_dialog.d.ts +132 -40
- package/types/xr_lib/xr_flags.d.ts +592 -148
- package/types/xr_lib/xr_fs.d.ts +539 -148
- package/types/xr_lib/xr_game.d.ts +362 -158
- package/types/xr_lib/xr_hit.d.ts +125 -41
- package/types/xr_lib/xr_ini.d.ts +473 -188
- package/types/xr_lib/xr_level.d.ts +795 -225
- package/types/xr_lib/xr_luabind.d.ts +90 -59
- package/types/xr_lib/xr_map.d.ts +192 -61
- package/types/xr_lib/xr_math.d.ts +871 -233
- package/types/xr_lib/xr_multiplayer.d.ts +1079 -351
- package/types/xr_lib/xr_profile.d.ts +272 -160
- package/types/xr_lib/xr_properties.d.ts +610 -166
- package/types/xr_lib/xr_relation.d.ts +231 -84
- package/types/xr_lib/xr_render.d.ts +167 -69
- package/types/xr_lib/xr_save.d.ts +833 -223
- package/types/xr_lib/xr_sound.d.ts +515 -151
- package/types/xr_lib/xr_stats.ts +49 -20
- package/types/xr_lib/xr_task.d.ts +388 -111
- package/types/xr_lib/xr_time.d.ts +177 -61
- package/types/xr_lib/xr_type.d.ts +75 -75
- package/types/xr_object/client/xr_anomaly.d.ts +70 -50
- package/types/xr_object/client/xr_artefact.d.ts +153 -98
- package/types/xr_object/client/xr_client_object.d.ts +207 -76
- package/types/xr_object/client/xr_creature.d.ts +243 -164
- package/types/xr_object/client/xr_item.d.ts +370 -264
- package/types/xr_object/client/xr_level.d.ts +753 -285
- package/types/xr_object/client/xr_physic.d.ts +644 -214
- package/types/xr_object/client/xr_zone.d.ts +85 -47
- package/types/xr_object/script/xr_script_interface.d.ts +819 -584
- package/types/xr_object/script/xr_script_object.d.ts +5728 -1390
- package/types/xr_object/script/xr_script_trade.d.ts +51 -26
- package/types/xr_object/server/xr_server_object.d.ts +1486 -792
- package/types/xr_ui/xr_ui_asset.d.ts +364 -123
- package/types/xr_ui/xr_ui_core.d.ts +424 -97
- package/types/xr_ui/xr_ui_event.d.ts +1449 -381
- package/types/xr_ui/xr_ui_interface.d.ts +2447 -903
- package/types/xr_ui/xr_ui_menu.d.ts +385 -142
- package/types/xrf_plugin.d.ts +89 -51
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 stalker-xrts
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 stalker-xrts
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,106 +1,112 @@
|
|
|
1
|
-
# [📡 XRay-16 engine typescript definitions](https://github.com/xray-forge/xray-16-types)
|
|
2
|
-
|
|
3
|
-
[](https://xray-forge.github.io/xray-16-types/index.html)
|
|
4
|
-
[](https://xray-forge.github.io/stalker-xrf-book)
|
|
5
|
-
<br/>
|
|
6
|
-
[](https://github.com/xray-forge/xray-16-types/actions/workflows/build_and_test.yml)
|
|
7
|
-
|
|
8
|
-
X-Ray16 engine bindings documentation and types. <br/>
|
|
9
|
-
For usage with [TypeScriptToLua](https://typescripttolua.github.io/docs/getting-started).
|
|
10
|
-
|
|
11
|
-
<p>
|
|
12
|
-
Module contains xray engine globals typedefs for typescript. <br/>
|
|
13
|
-
By default x-ray export
|
|
14
|
-
|
|
15
|
-
To check more details / correct typing you always can reference X-Ray source code.
|
|
16
|
-
|
|
17
|
-
</p>
|
|
18
|
-
|
|
19
|
-
## 🗻 Docs
|
|
20
|
-
|
|
21
|
-
Types documentation can be checked [here](https://xray-forge.github.io/xray-16-types/modules.html).
|
|
22
|
-
|
|
23
|
-
## 🧱 Usage
|
|
24
|
-
|
|
25
|
-
Types are used with [xrf template](https://github.com/xray-forge/stalker-xrf-engine) and can be referenced as an example.
|
|
26
|
-
|
|
27
|
-
##
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
-
|
|
72
|
-
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
1
|
+
# [📡 XRay-16 engine typescript definitions](https://github.com/xray-forge/xray-16-types)
|
|
2
|
+
|
|
3
|
+
[](https://xray-forge.github.io/xray-16-types/index.html)
|
|
4
|
+
[](https://xray-forge.github.io/stalker-xrf-book)
|
|
5
|
+
<br/>
|
|
6
|
+
[](https://github.com/xray-forge/xray-16-types/actions/workflows/build_and_test.yml)
|
|
7
|
+
|
|
8
|
+
X-Ray16 engine bindings documentation and types. <br/>
|
|
9
|
+
For usage with [TypeScriptToLua](https://typescripttolua.github.io/docs/getting-started).
|
|
10
|
+
|
|
11
|
+
<p>
|
|
12
|
+
Module contains xray engine globals typedefs for typescript. <br/>
|
|
13
|
+
By default x-ray export bindings that can be accessed from lua scripts, but without any API documentation.
|
|
14
|
+
|
|
15
|
+
To check more details / correct typing you always can reference X-Ray source code.
|
|
16
|
+
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
## 🗻 Docs
|
|
20
|
+
|
|
21
|
+
Types documentation can be checked [here](https://xray-forge.github.io/xray-16-types/modules.html).
|
|
22
|
+
|
|
23
|
+
## 🧱 Usage
|
|
24
|
+
|
|
25
|
+
Types are used with [xrf template](https://github.com/xray-forge/stalker-xrf-engine) and can be referenced as an example.
|
|
26
|
+
|
|
27
|
+
## 📦Extending C++ classes and overriding virtual methods
|
|
28
|
+
|
|
29
|
+
### Lua
|
|
30
|
+
|
|
31
|
+
<p>
|
|
32
|
+
C++ classes can be extended in Lua code with 'class' keyword.
|
|
33
|
+
Class declaration registers table as userdata and adds constructor/destructor metamethods. <br/>
|
|
34
|
+
</p>
|
|
35
|
+
|
|
36
|
+
### Typescript
|
|
37
|
+
|
|
38
|
+
<p>
|
|
39
|
+
In TS codebase 'LuabindClass' decorator can be used to modify transformation and enable virtual calls. <br/>
|
|
40
|
+
Separate transformer is needed to build luabind classes instead of table-based classes.
|
|
41
|
+
</p>
|
|
42
|
+
|
|
43
|
+
## 🧱 Getting up-to-date LUA bindings
|
|
44
|
+
|
|
45
|
+
- Run game engine with `-dump_bindings` flag
|
|
46
|
+
- Check userdata folder _(where game saves are stored)_ `scriptbindings_*.txt` files
|
|
47
|
+
|
|
48
|
+
## 🧲 Plugins
|
|
49
|
+
|
|
50
|
+
Package includes plugins for typescript-to-lua for easier work with xray16 typings.\
|
|
51
|
+
Plugins can be included in [tstl tsconfig](https://typescripttolua.github.io/docs/configuration) file as following section:
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"tstl": {
|
|
56
|
+
"luaPlugins": [
|
|
57
|
+
{ "name": "xray16/plugins/transform_luabind_class/plugin" },
|
|
58
|
+
{ "name": "xray16/plugins/global_declarations_transform" },
|
|
59
|
+
{ "name": "xray16/plugins/built_at_info" },
|
|
60
|
+
{ "name": "xray16/plugins/strip_lua_logger" },
|
|
61
|
+
{ "name": "xray16/plugins/inject_filename" },
|
|
62
|
+
{ "name": "xray16/plugins/from_cast_utils" },
|
|
63
|
+
{ "name": "xray16/plugins/inject_tracy_zones" }
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Arguments for TSTL:
|
|
70
|
+
|
|
71
|
+
- `--no-lua-logs`
|
|
72
|
+
- `--inject-tracy-zones`
|
|
73
|
+
|
|
74
|
+
Env variables for custom CLI scripts:
|
|
75
|
+
|
|
76
|
+
- `XR_NO_LUA_LOGS`
|
|
77
|
+
- `XR_INJECT_TRACY_ZONES `
|
|
78
|
+
|
|
79
|
+
### transform_luabind_class
|
|
80
|
+
|
|
81
|
+
Custom plugin overriding transformation of classes marked with `@LuaClass` decorator.\
|
|
82
|
+
Instead of using prototypes and metatables use luabind API to declare such classes.\
|
|
83
|
+
|
|
84
|
+
### built_at_info
|
|
85
|
+
|
|
86
|
+
Plugin injecting time and generic metadata on top of built lua scripts.
|
|
87
|
+
|
|
88
|
+
### global_declarations_transform
|
|
89
|
+
|
|
90
|
+
Plugin stripping all the runtime imports from `xray16` package.
|
|
91
|
+
Default `tstl` behaviour does not work well with engine imports and I tried to avoid implicit globals.
|
|
92
|
+
|
|
93
|
+
### strip_lua_logger
|
|
94
|
+
|
|
95
|
+
Plugin to strip all `LuaLogger` calls from runtime if env variable is set or path param is provided.\
|
|
96
|
+
Logger can consume a lot of processing time that does not benefit player.
|
|
97
|
+
|
|
98
|
+
### inject_filename
|
|
99
|
+
|
|
100
|
+
Plugin adding `$filename` global variable replaced with actual file name on build time.\
|
|
101
|
+
Lua does not provide convenient API do get filename in runtime and static step is much simpler.
|
|
102
|
+
|
|
103
|
+
### from_cast_utils
|
|
104
|
+
|
|
105
|
+
Plugin to simplify casting from `LuaTable` to typescript array/map objects.\
|
|
106
|
+
All the calls are completely gets stripped and removed from runtime.
|
|
107
|
+
|
|
108
|
+
### from_cast_utils
|
|
109
|
+
|
|
110
|
+
Plugin designed to work specifically with [tracy profiler](https://github.com/wolfpld/tracy).\
|
|
111
|
+
Once it is enabled with env variable or path parameter, tracy zone marking calls are injected for every method.\
|
|
112
|
+
This way you will be able to build profiling bundle to understand bottlenecks and what takes CPU time.
|
package/package.json
CHANGED
|
@@ -1,42 +1,45 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "xray16",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"author": "Neloreck",
|
|
5
|
-
"repository": "https://github.com/
|
|
6
|
-
"private": false,
|
|
7
|
-
"main": "types/index.d.ts",
|
|
8
|
-
"types": "types/index.d.ts",
|
|
9
|
-
"scripts": {
|
|
10
|
-
"prepublish": "npm run build:plugins",
|
|
11
|
-
"build:plugins": "tsc -p ./src/tsconfig.json",
|
|
12
|
-
"build:types": "typedoc",
|
|
13
|
-
"typecheck": "tsc --noEmit",
|
|
14
|
-
"typedoc": "typedoc",
|
|
15
|
-
"format": "prettier --write \"**/*.(js|ts|tsx|md)\" && eslint . --
|
|
16
|
-
"lint": "eslint .
|
|
17
|
-
},
|
|
18
|
-
"peerDependencies": {
|
|
19
|
-
"typescript-to-lua": "^1.28.1"
|
|
20
|
-
},
|
|
21
|
-
"devDependencies": {
|
|
22
|
-
"@
|
|
23
|
-
"@
|
|
24
|
-
"@typescript-eslint/
|
|
25
|
-
"@typescript-
|
|
26
|
-
"
|
|
27
|
-
"eslint
|
|
28
|
-
"eslint-
|
|
29
|
-
"eslint-plugin-
|
|
30
|
-
"eslint-plugin-
|
|
31
|
-
"eslint-plugin-
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "xray16",
|
|
3
|
+
"version": "1.5.0",
|
|
4
|
+
"author": "Neloreck",
|
|
5
|
+
"repository": "https://github.com/xray-forge/xray-16-types",
|
|
6
|
+
"private": false,
|
|
7
|
+
"main": "types/index.d.ts",
|
|
8
|
+
"types": "types/index.d.ts",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"prepublish": "npm run build:plugins",
|
|
11
|
+
"build:plugins": "tsc -p ./src/tsconfig.json",
|
|
12
|
+
"build:types": "typedoc",
|
|
13
|
+
"typecheck": "tsc --noEmit",
|
|
14
|
+
"typedoc": "typedoc",
|
|
15
|
+
"format": "prettier --write \"**/*.(js|ts|tsx|md)\" && eslint . --fix",
|
|
16
|
+
"lint": "eslint ."
|
|
17
|
+
},
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"typescript-to-lua": "^1.28.1"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@eslint/js": "^9.39.4",
|
|
23
|
+
"@types/node": "22.10.2",
|
|
24
|
+
"@typescript-eslint/eslint-plugin": "^8.62.0",
|
|
25
|
+
"@typescript-eslint/parser": "^8.62.0",
|
|
26
|
+
"@typescript-to-lua/language-extensions": "1.0.0",
|
|
27
|
+
"eslint": "^9.39.4",
|
|
28
|
+
"eslint-config-prettier": "^10.1.8",
|
|
29
|
+
"eslint-plugin-import": "^2.32.0",
|
|
30
|
+
"eslint-plugin-jest": "^29.15.2",
|
|
31
|
+
"eslint-plugin-jsdoc": "^63.0.7",
|
|
32
|
+
"globals": "^17.7.0",
|
|
33
|
+
"prettier": "^3.4.2",
|
|
34
|
+
"typedoc": "^0.27.5",
|
|
35
|
+
"typescript": "5.7.2",
|
|
36
|
+
"typescript-eslint": "^8.62.0",
|
|
37
|
+
"typescript-to-lua": "1.28.1"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"plugins/**/*",
|
|
41
|
+
"types/**/*",
|
|
42
|
+
"README.md",
|
|
43
|
+
"LICENSE"
|
|
44
|
+
]
|
|
45
|
+
}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const path = require("path");
|
|
4
4
|
const typescript_1 = require("typescript");
|
|
5
|
-
const
|
|
5
|
+
const sourceFile_1 = require("typescript-to-lua/dist/transformation/visitors/sourceFile");
|
|
6
6
|
const ast_1 = require("./utils/ast");
|
|
7
7
|
const environment_1 = require("./utils/environment");
|
|
8
|
-
const
|
|
8
|
+
const tracy_1 = require("./utils/tracy");
|
|
9
9
|
/**
|
|
10
10
|
* Plugin that injects FILE_NAME in compile-time.
|
|
11
11
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ClassLikeDeclaration, ExpressionWithTypeArguments } from "typescript";
|
|
1
|
+
import { type ClassLikeDeclaration, type ExpressionWithTypeArguments } from "typescript";
|
|
2
2
|
import * as tstl from "typescript-to-lua";
|
|
3
|
-
import { TransformationContext } from "typescript-to-lua";
|
|
3
|
+
import { type TransformationContext } from "typescript-to-lua";
|
|
4
4
|
export interface ITransformationContext extends TransformationContext {
|
|
5
5
|
classSuperInfos: Array<ClassSuperInfo>;
|
|
6
6
|
}
|
|
@@ -13,6 +13,6 @@ export interface ClassSuperInfo {
|
|
|
13
13
|
extendedTypeNode?: ExpressionWithTypeArguments;
|
|
14
14
|
}
|
|
15
15
|
export declare function transformClassLikeDeclaration(classDeclaration: ClassLikeDeclaration, context: ITransformationContext, nameOverride?: tstl.Identifier): {
|
|
16
|
-
statements: tstl.Statement
|
|
16
|
+
statements: Array<tstl.Statement>;
|
|
17
17
|
name: tstl.Identifier;
|
|
18
18
|
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { Decorator } from "typescript";
|
|
2
|
-
import { TransformationContext } from "typescript-to-lua";
|
|
1
|
+
import { type Decorator } from "typescript";
|
|
2
|
+
import { type TransformationContext } from "typescript-to-lua";
|
|
3
3
|
/**
|
|
4
4
|
* Transform decorator call expressions for luabind class.
|
|
5
|
+
*
|
|
6
|
+
* @param context - Active transformation context.
|
|
7
|
+
* @param decorator - Class decorator to validate.
|
|
5
8
|
*/
|
|
6
9
|
export declare function checkLuabindClassDecoratorExpression(context: TransformationContext, decorator: Decorator): void;
|
|
@@ -5,6 +5,9 @@ const constants_1 = require("./constants");
|
|
|
5
5
|
const errors_1 = require("./errors");
|
|
6
6
|
/**
|
|
7
7
|
* Transform decorator call expressions for luabind class.
|
|
8
|
+
*
|
|
9
|
+
* @param context - Active transformation context.
|
|
10
|
+
* @param decorator - Class decorator to validate.
|
|
8
11
|
*/
|
|
9
12
|
function checkLuabindClassDecoratorExpression(context, decorator) {
|
|
10
13
|
const expression = decorator.expression;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { AllAccessorDeclarations, TransformationContext } from "typescript-to-lua";
|
|
1
|
+
import { type AllAccessorDeclarations, type TransformationContext } from "typescript-to-lua";
|
|
2
2
|
import * as lua from "typescript-to-lua";
|
|
3
3
|
export declare function transformAccessorDeclarations(context: TransformationContext, { firstAccessor, getAccessor, setAccessor }: AllAccessorDeclarations, className: lua.Identifier): lua.Statement | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ClassLikeDeclaration, ConstructorDeclaration, PropertyDeclaration } from "typescript";
|
|
2
|
-
import { TransformationContext } from "typescript-to-lua";
|
|
1
|
+
import { type ClassLikeDeclaration, type ConstructorDeclaration, type PropertyDeclaration } from "typescript";
|
|
2
|
+
import { type TransformationContext } from "typescript-to-lua";
|
|
3
3
|
import * as lua from "typescript-to-lua";
|
|
4
4
|
export declare function createConstructorName(className: lua.Identifier): lua.TableIndexExpression;
|
|
5
5
|
export declare function transformConstructorDeclaration(context: TransformationContext, statement: ConstructorDeclaration, className: lua.Identifier, instanceFields: Array<PropertyDeclaration>, classDeclaration: ClassLikeDeclaration): lua.Statement | undefined;
|
|
@@ -45,11 +45,11 @@ function transformConstructorDeclaration(context, statement, className, instance
|
|
|
45
45
|
// Add in instance field declarations
|
|
46
46
|
for (const declaration of constructorFieldsDeclarations) {
|
|
47
47
|
if ((0, typescript_1.isIdentifier)(declaration.name)) {
|
|
48
|
-
//
|
|
48
|
+
// Self.declarationName = declarationName
|
|
49
49
|
const assignment = lua.createAssignmentStatement(lua.createTableIndexExpression((0, lua_ast_1.createSelfIdentifier)(), lua.createStringLiteral(declaration.name.text)), (0, identifier_1.transformIdentifier)(context, declaration.name));
|
|
50
50
|
bodyWithFieldInitializers.push(assignment);
|
|
51
51
|
}
|
|
52
|
-
//
|
|
52
|
+
// Else { TypeScript error: A parameter property may not be declared using a binding pattern }
|
|
53
53
|
}
|
|
54
54
|
bodyWithFieldInitializers.push(...classInstanceFields);
|
|
55
55
|
bodyWithFieldInitializers.push(...body);
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { AccessorDeclaration, PropertyDeclaration } from "typescript";
|
|
2
|
-
import { TransformationContext } from "typescript-to-lua";
|
|
1
|
+
import { type AccessorDeclaration, type PropertyDeclaration } from "typescript";
|
|
2
|
+
import { type TransformationContext } from "typescript-to-lua";
|
|
3
3
|
import * as tstl from "typescript-to-lua";
|
|
4
4
|
/**
|
|
5
5
|
* Verify whether decorators provided for luabind class.
|
|
6
|
+
*
|
|
7
|
+
* @param context - Active transformation context.
|
|
8
|
+
* @param node - Class property or accessor to inspect.
|
|
6
9
|
*/
|
|
7
10
|
export declare function verifyPropertyDecoratingExpression(context: TransformationContext, node: PropertyDeclaration | AccessorDeclaration): void;
|
|
8
11
|
export declare function transformClassInstanceFields(context: TransformationContext, instanceFields: Array<PropertyDeclaration>): Array<tstl.Statement>;
|
|
@@ -10,6 +10,9 @@ const literal_1 = require("typescript-to-lua/dist/transformation/visitors/litera
|
|
|
10
10
|
const errors_1 = require("../errors");
|
|
11
11
|
/**
|
|
12
12
|
* Verify whether decorators provided for luabind class.
|
|
13
|
+
*
|
|
14
|
+
* @param context - Active transformation context.
|
|
15
|
+
* @param node - Class property or accessor to inspect.
|
|
13
16
|
*/
|
|
14
17
|
function verifyPropertyDecoratingExpression(context, node) {
|
|
15
18
|
if (!(0, typescript_1.canHaveDecorators)(node))
|
|
@@ -28,9 +31,9 @@ function transformClassInstanceFields(context, instanceFields) {
|
|
|
28
31
|
// Get identifier
|
|
29
32
|
const fieldName = (0, literal_1.transformPropertyName)(context, f.name);
|
|
30
33
|
const value = f.initializer ? context.transformExpression(f.initializer) : undefined;
|
|
31
|
-
//
|
|
34
|
+
// Self[fieldName]
|
|
32
35
|
const selfIndex = tstl.createTableIndexExpression((0, lua_ast_1.createSelfIdentifier)(), fieldName);
|
|
33
|
-
//
|
|
36
|
+
// Self[fieldName] = value
|
|
34
37
|
const assignClassField = tstl.createAssignmentStatement(selfIndex, value, f);
|
|
35
38
|
return assignClassField;
|
|
36
39
|
});
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { AccessorDeclaration, MethodDeclaration, PropertyDeclaration } from "typescript";
|
|
2
|
-
import { TransformationContext } from "typescript-to-lua";
|
|
1
|
+
import { type AccessorDeclaration, type MethodDeclaration, type PropertyDeclaration } from "typescript";
|
|
2
|
+
import { type TransformationContext } from "typescript-to-lua";
|
|
3
3
|
import * as lua from "typescript-to-lua";
|
|
4
4
|
export declare function transformMemberExpressionOwnerName(node: PropertyDeclaration | MethodDeclaration | AccessorDeclaration, className: lua.Identifier): lua.Expression;
|
|
5
5
|
export declare function transformMethodName(context: TransformationContext, node: MethodDeclaration): lua.Expression;
|
|
6
6
|
export declare function transformMethodDeclaration(context: TransformationContext, node: MethodDeclaration, className: lua.Identifier): lua.Statement | undefined;
|
|
7
7
|
/**
|
|
8
|
-
* Verify that method
|
|
8
|
+
* Verify that a method does not use method or parameter decorators.
|
|
9
|
+
*
|
|
10
|
+
* @param context - Active transformation context.
|
|
11
|
+
* @param node - Class method to inspect.
|
|
9
12
|
*/
|
|
10
13
|
export declare function verifyMethodDecoratingExpression(context: TransformationContext, node: MethodDeclaration): void;
|
|
@@ -35,7 +35,10 @@ function transformMethodDeclaration(context, node, className) {
|
|
|
35
35
|
return lua.createAssignmentStatement(lua.createTableIndexExpression(methodTable, methodName), functionExpression, node);
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
* Verify that method
|
|
38
|
+
* Verify that a method does not use method or parameter decorators.
|
|
39
|
+
*
|
|
40
|
+
* @param context - Active transformation context.
|
|
41
|
+
* @param node - Class method to inspect.
|
|
39
42
|
*/
|
|
40
43
|
function verifyMethodDecoratingExpression(context, node) {
|
|
41
44
|
node.parameters.flatMap((parameter, index) => {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { NewExpression } from "typescript";
|
|
1
|
+
import { type NewExpression } from "typescript";
|
|
2
2
|
import * as tstl from "typescript-to-lua";
|
|
3
|
-
import { ITransformationContext } from "./index";
|
|
3
|
+
import { type ITransformationContext } from "./index";
|
|
4
4
|
/**
|
|
5
|
-
* Transform new
|
|
5
|
+
* Transform a new expression into a luabind constructor call.
|
|
6
|
+
*
|
|
7
|
+
* @param expression - New expression to transform.
|
|
8
|
+
* @param context - Active transformation context.
|
|
9
|
+
* @returns Lua call expression for the class constructor.
|
|
6
10
|
*/
|
|
7
11
|
export declare function transformNewCallExpression(expression: NewExpression, context: ITransformationContext): tstl.CallExpression;
|
|
@@ -4,7 +4,11 @@ exports.transformNewCallExpression = transformNewCallExpression;
|
|
|
4
4
|
const tstl = require("typescript-to-lua");
|
|
5
5
|
const call_1 = require("typescript-to-lua/dist/transformation/visitors/call");
|
|
6
6
|
/**
|
|
7
|
-
* Transform new
|
|
7
|
+
* Transform a new expression into a luabind constructor call.
|
|
8
|
+
*
|
|
9
|
+
* @param expression - New expression to transform.
|
|
10
|
+
* @param context - Active transformation context.
|
|
11
|
+
* @returns Lua call expression for the class constructor.
|
|
8
12
|
*/
|
|
9
13
|
function transformNewCallExpression(expression, context) {
|
|
10
14
|
return tstl.createCallExpression(context.transformExpression(expression.expression), (0, call_1.transformArguments)(context, expression.arguments ?? []));
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import { ClassLikeDeclarationBase } from "typescript";
|
|
1
|
+
import { type ClassLikeDeclarationBase } from "typescript";
|
|
2
2
|
import * as tstl from "typescript-to-lua";
|
|
3
|
-
import { TransformationContext } from "typescript-to-lua";
|
|
3
|
+
import { type TransformationContext } from "typescript-to-lua";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Build the full set of statements that define a luabind class.
|
|
6
|
+
*
|
|
7
|
+
* @param context - Active transformation context.
|
|
8
|
+
* @param statement - Class declaration being transformed.
|
|
9
|
+
* @param className - Exported class identifier.
|
|
10
|
+
* @param localClassName - Local class identifier.
|
|
11
|
+
* @returns Lua statements that set up the class.
|
|
6
12
|
*/
|
|
7
13
|
export declare function createClassSetup(context: TransformationContext, statement: ClassLikeDeclarationBase, className: tstl.Identifier, localClassName: tstl.Identifier): tstl.Statement[];
|
|
8
14
|
export declare function getReflectionClassName(declaration: ClassLikeDeclarationBase, className: tstl.Identifier): tstl.Expression;
|