Files
ts2lua-unreal/CHANGELOG.md
T

59 lines
5.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Changelog
All notable changes to `ts2lua-unreal` will be documented in this file.
The format is based on [Semantic Versioning](https://semver.org/).
## [0.2.2] - 2026-11-29
### Fixed
- **修复可选链(`a?.b?.c`)触发插件崩溃**:TSTL 转译可选链时会合成无 `SourceFile` / 无 `parent` 的临时 `Identifier` 节点;为 `tryTransformUnLuaSelfClassIdentifier`、`hasAllowTryComment` 与 `arguments` 校验补齐空值保护。
- **修复 `@unlua` 类静态方法 `self` 参数不匹配 Bug**:移除 `methodHasSelfParam` 中无条件剔除 `static` 方法 `self` 的错误逻辑,使其与 TSTL 调用侧的冒号调用(`ClassName:StaticMethod(...)`)一致,并支持 `this: void`、`/** @noSelf */` 与 `/** @noSelfInFile */` 点号调用;同时在 `super.Method(...)` 调用 `@unlua` 父类方法时尊重目标方法的 `@noSelf` 声明。
- **修复 `@unlua` 类方法解构参数未展开 Bug**:完整支持对象解构、数组解构、重命名、嵌套解构、默认值与剩余元素(`...rest`)展开。
- **修复混合默认导入与纯类型命名导入(`import Base, { type BaseCfg } from "./Base"`)生成 `.default` 的 Bug**:当命名导入全为编译期擦除类型时,仍直接生成 `local Base = require("...")`。
### Added
- **编译期宏 `UnLua.Delegate(target, callback)`**:在 [types/unlua.d.ts](types/unlua.d.ts) 中声明并在插件编译期直接内联为 `{ target, callback }`,用于类型安全且零开销地调用 `K2_SetTimerDelegate` / `LoadAsset` / `BindToAnimationFinished` 等接收 `UE.FScriptDelegate` 参数的 UE API;同时在编译期拦截对 `UnLua.Delegate` 传入箭头函数或匿名函数(`90107`)。
- **补齐 UnLua 全局运行时类型声明**:新增 `UnLua.Log` / `LogWarn` / `LogError`、`UnLua.Input`(`BindKey` / `BindAction` / `BindAxis`)及 `UnLua.EnhancedInput`(`BindAction`),并让 `UE.TArray<T>` / `UE.TMap<K, V>` 继承 `LuaPairsIterable`,支持 `for (const [k, v] of container)` 直接编译为 Lua 原生 `pairs()` 遍历。
- **增强编译期约束检查**:新增拦截 `BigInt` 字面量(`123n`)、`new UE.AActor()` / `new UE.UObject()` 误实例化,以及继承独立 `@unlua` 类时漏标 `@unlua` 的防呆检查。
- **扩展插件测试套件**:[test/plugin.test.mjs](test/plugin.test.mjs) 增至 23 组测试,并结合本机 `lua5.4` 执行编译产物验证运行时语义。
## [0.2.1] - 2026-11-29
### Fixed
- 修正 [types/unlua.d.ts](types/unlua.d.ts) 中 `UE.TArray` 与 UnLua `LuaLib_Array.cpp` 不一致的两处签名:
- `RemoveItem(item: T): number`(实际返回移除元素数量 `int32`,而非 `boolean`)。
- `GetData(): unknown`(无参调用,传参会在运行时触发 `luaL_error`)。
### Added
- 在 [types/unlua.d.ts](types/unlua.d.ts) 中补充 UnLua 原生基础类型描述符 Token(`UE.int8`~`UE.uint64`、`UE.float`、`UE.double`、`UE.bool`、`UE.FName`、`UE.FString`),支持直接使用 `UE.TArray(UE.int32)` / `UE.TMap(UE.FString, UE.float)` 构造原生类型容器。
## [0.2.0] - 2026-11-29
### Changed
- **拆分精简 [types/unlua.d.ts](types/unlua.d.ts)**:移除所有 UE 引擎反射类声明(`UObject`/`AActor`/`UWorld`/`FVector`/`UKismetSystemLibrary` 等),仅保留 UE 反射无法自动生成的零冲突核心运行时层(`@unlua` 装饰器、`UnLua` 全局模块、`TArray`/`TMap`/`TSet`、智能指针模板别名、`FScriptDelegate`/`FMulticastScriptDelegate`/`FMulticastSparseDelegate` 以及 `UE.NewObject`/`LoadClass`/`LoadObject`),彻底避免与 UE 项目自动生成的反射 `.d.ts` 冲突。
### Removed
- 移除仓库内置的 `examples/` 示例工程、`examples/types/demo.d.ts` 及 `build:examples` / `watch:examples` 脚本;插件自动化测试保留在 [test/plugin.test.mjs](test/plugin.test.mjs) 中使用内存虚拟声明运行。
## [0.1.0] - 2026-11-29
### Added
- **规范与接入文档**:
- [docs/ts-unlua-spec.md](docs/ts-unlua-spec.md):面向 UE 5.8 + UnLua 2.3.6(Lua 5.4)的 TypeScript 开发与语言约束规范。
- [docs/integration-guide.md](docs/integration-guide.md):UE 项目接入、错误码速查、版本升级与本地 `npm link` 联调手册。
- [docs/ai-rules-template.md](docs/ai-rules-template.md):可直接复用的业务项目规则模板。
- **UnLua TSTL 编译器插件 (`src/plugin/`)**:
- 编译期拦截全部禁用语言特性(`90001`~`90016`)与 `@unlua` 绑定类专项约束(`90101`~`90110`,含继承 `UE.UObject` 漏标 `@unlua` 防呆)。
- `@unlua` 类原生 UnLua 代码生成:`local ClassName = UnLua.Class(...)`、`function ClassName.Method(self, ...)`、`return ClassName`,消除 `____exports` / `__TS__Class` / `__TS__Decorate` 垫片。
- 精确 `super.Method(...)` 映射(UE 原生基类 -> `self.Overridden.Method(self, ...)`;`@unlua` TS 父类 -> `BaseClass.Method(self, ...)`)。
- `@unlua` 默认导入直连优化(`import Base from "./Base"` -> `local Base = require("...")`,不生成 `.default`)。
- 面向大项目(3000~5000+ 文件)的 `WeakMap` 类型与文件名缓存优化。
- **包导出与 CLI**:
- 暴露 `ts2lua-unreal`、`ts2lua-unreal/tsconfig.base.json`、`ts2lua-unreal/types/unlua.d.ts` 及全部文档导出。
- 提供 `ts2lua-unreal build` / `watch` / `info` CLI 命令与 `prepare` 自动构建脚本,支持通过 npm Git Tag 依赖无缝接入任意 UE 项目。
- **基础类型、示例与测试**:
- [types/unlua.d.ts](types/unlua.d.ts):全局 `@unlua` 装饰器及 UnLua/UE 核心基础类型声明。
- `examples/`:还原 `UnrealLuaDemo` 的端到端 TS -> UnLua 示例工程。
- `test/plugin.test.mjs`:16 组正反用例自动化测试套件。