chore: upgrade ts2lua-unreal to v0.3.1 with lowercase lib/module.lua & lib/class.lua and commit framework refactor

This commit is contained in:
szy73711 committed 2026-11-30 03:43:42 +08:00
1 parent 783dccf53d
commit 3572f2da43
206 files changed
+14442 -13186

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
-- 热更友好的纯 TS 类定义运行时(扁平全局函数,零表查询开销,完全兼容 TSTL lualib_bundle)
local pairs = pairs
local type = type
local allClassTbl = {}
local function __TS__DefineClass(name, mod)
local modname = mod and mod.name or ""
local fullName = modname .. ":" .. name
local cls = allClassTbl[fullName]
if cls then
-- 热更重载时清理原型上已删除的旧方法,保持既有实例与子类继承链的原型表引用不变
local modSys = _G.__MODULE__
if modSys and modSys.IsReimporting and modSys.IsReimporting(mod) then
local proto = cls.prototype
if proto then
for k, v in pairs(proto) do
if k ~= "__index" and k ~= "constructor" and type(v) == "function" then
proto[k] = nil
end
end
end
end
cls.name = name
return cls
end
cls = {
__classdefine__ = true,
__fullname__ = fullName,
name = name,
prototype = {},
}
cls.prototype.__index = cls.prototype
cls.prototype.constructor = cls
allClassTbl[fullName] = cls
return cls
end
_G.__TS__DefineClass = __TS__DefineClass
return {
DefineClass = __TS__DefineClass,
allClassTbl = allClassTbl,
GetClass = function(fullName)
return allClassTbl[fullName]
end,
AllClasses = function()
return allClassTbl
end,
}