wuira 0.1.2 → 0.1.3
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/CHANGELOG.md +93 -0
- package/README.md +89 -0
- package/lib/datasources/Auras.d.ts +32 -0
- package/lib/datasources/Auras.lua +284 -0
- package/lib/datasources/GroupMembers.d.ts +18 -0
- package/lib/datasources/GroupMembers.lua +122 -0
- package/lib/datasources/Resources.d.ts +9 -8
- package/lib/datasources/Resources.lua +172 -11
- package/lib/datasources/UnitInfo.d.ts +45 -0
- package/lib/datasources/UnitInfo.lua +451 -0
- package/lib/datasources/UnitSource.d.ts +28 -0
- package/lib/datasources/UnitSource.lua +245 -0
- package/lib/datasources/index.d.ts +8 -0
- package/lib/datasources/index.lua +23 -0
- package/package.json +2 -1
|
@@ -31,11 +31,154 @@ local function __TS__ClassExtends(target, base)
|
|
|
31
31
|
target.prototype.__tostring = base.prototype.__tostring
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
|
+
|
|
35
|
+
local function __TS__CloneDescriptor(____bindingPattern0)
|
|
36
|
+
local value
|
|
37
|
+
local writable
|
|
38
|
+
local set
|
|
39
|
+
local get
|
|
40
|
+
local configurable
|
|
41
|
+
local enumerable
|
|
42
|
+
enumerable = ____bindingPattern0.enumerable
|
|
43
|
+
configurable = ____bindingPattern0.configurable
|
|
44
|
+
get = ____bindingPattern0.get
|
|
45
|
+
set = ____bindingPattern0.set
|
|
46
|
+
writable = ____bindingPattern0.writable
|
|
47
|
+
value = ____bindingPattern0.value
|
|
48
|
+
local descriptor = {enumerable = enumerable == true, configurable = configurable == true}
|
|
49
|
+
local hasGetterOrSetter = get ~= nil or set ~= nil
|
|
50
|
+
local hasValueOrWritableAttribute = writable ~= nil or value ~= nil
|
|
51
|
+
if hasGetterOrSetter and hasValueOrWritableAttribute then
|
|
52
|
+
error("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute.", 0)
|
|
53
|
+
end
|
|
54
|
+
if get or set then
|
|
55
|
+
descriptor.get = get
|
|
56
|
+
descriptor.set = set
|
|
57
|
+
else
|
|
58
|
+
descriptor.value = value
|
|
59
|
+
descriptor.writable = writable == true
|
|
60
|
+
end
|
|
61
|
+
return descriptor
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
local __TS__DescriptorGet
|
|
65
|
+
do
|
|
66
|
+
local getmetatable = _G.getmetatable
|
|
67
|
+
local ____rawget = _G.rawget
|
|
68
|
+
function __TS__DescriptorGet(self, metatable, key)
|
|
69
|
+
while metatable do
|
|
70
|
+
local rawResult = ____rawget(metatable, key)
|
|
71
|
+
if rawResult ~= nil then
|
|
72
|
+
return rawResult
|
|
73
|
+
end
|
|
74
|
+
local descriptors = ____rawget(metatable, "_descriptors")
|
|
75
|
+
if descriptors then
|
|
76
|
+
local descriptor = descriptors[key]
|
|
77
|
+
if descriptor ~= nil then
|
|
78
|
+
if descriptor.get then
|
|
79
|
+
return descriptor.get(self)
|
|
80
|
+
end
|
|
81
|
+
return descriptor.value
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
metatable = getmetatable(metatable)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
local __TS__DescriptorSet
|
|
90
|
+
do
|
|
91
|
+
local getmetatable = _G.getmetatable
|
|
92
|
+
local ____rawget = _G.rawget
|
|
93
|
+
local rawset = _G.rawset
|
|
94
|
+
function __TS__DescriptorSet(self, metatable, key, value)
|
|
95
|
+
while metatable do
|
|
96
|
+
local descriptors = ____rawget(metatable, "_descriptors")
|
|
97
|
+
if descriptors then
|
|
98
|
+
local descriptor = descriptors[key]
|
|
99
|
+
if descriptor ~= nil then
|
|
100
|
+
if descriptor.set then
|
|
101
|
+
descriptor.set(self, value)
|
|
102
|
+
else
|
|
103
|
+
if descriptor.writable == false then
|
|
104
|
+
error(
|
|
105
|
+
((("Cannot assign to read only property '" .. key) .. "' of object '") .. tostring(self)) .. "'",
|
|
106
|
+
0
|
|
107
|
+
)
|
|
108
|
+
end
|
|
109
|
+
descriptor.value = value
|
|
110
|
+
end
|
|
111
|
+
return
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
metatable = getmetatable(metatable)
|
|
115
|
+
end
|
|
116
|
+
rawset(self, key, value)
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
local __TS__SetDescriptor
|
|
121
|
+
do
|
|
122
|
+
local getmetatable = _G.getmetatable
|
|
123
|
+
local function descriptorIndex(self, key)
|
|
124
|
+
return __TS__DescriptorGet(
|
|
125
|
+
self,
|
|
126
|
+
getmetatable(self),
|
|
127
|
+
key
|
|
128
|
+
)
|
|
129
|
+
end
|
|
130
|
+
local function descriptorNewIndex(self, key, value)
|
|
131
|
+
return __TS__DescriptorSet(
|
|
132
|
+
self,
|
|
133
|
+
getmetatable(self),
|
|
134
|
+
key,
|
|
135
|
+
value
|
|
136
|
+
)
|
|
137
|
+
end
|
|
138
|
+
function __TS__SetDescriptor(target, key, desc, isPrototype)
|
|
139
|
+
if isPrototype == nil then
|
|
140
|
+
isPrototype = false
|
|
141
|
+
end
|
|
142
|
+
local ____isPrototype_0
|
|
143
|
+
if isPrototype then
|
|
144
|
+
____isPrototype_0 = target
|
|
145
|
+
else
|
|
146
|
+
____isPrototype_0 = getmetatable(target)
|
|
147
|
+
end
|
|
148
|
+
local metatable = ____isPrototype_0
|
|
149
|
+
if not metatable then
|
|
150
|
+
metatable = {}
|
|
151
|
+
setmetatable(target, metatable)
|
|
152
|
+
end
|
|
153
|
+
if not isPrototype and not rawget(metatable, "_isOwnDescriptorMetatable") then
|
|
154
|
+
local instanceMetatable = {}
|
|
155
|
+
instanceMetatable._isOwnDescriptorMetatable = true
|
|
156
|
+
setmetatable(instanceMetatable, metatable)
|
|
157
|
+
setmetatable(target, instanceMetatable)
|
|
158
|
+
metatable = instanceMetatable
|
|
159
|
+
end
|
|
160
|
+
local value = rawget(target, key)
|
|
161
|
+
if value ~= nil then
|
|
162
|
+
rawset(target, key, nil)
|
|
163
|
+
end
|
|
164
|
+
if not rawget(metatable, "_descriptors") then
|
|
165
|
+
metatable._descriptors = {}
|
|
166
|
+
end
|
|
167
|
+
metatable._descriptors[key] = __TS__CloneDescriptor(desc)
|
|
168
|
+
metatable.__index = descriptorIndex
|
|
169
|
+
metatable.__newindex = descriptorNewIndex
|
|
170
|
+
end
|
|
171
|
+
end
|
|
34
172
|
-- End of Lua Library inline imports
|
|
35
173
|
local ____exports = {}
|
|
36
174
|
local ____ProgressSource = require("datasources.ProgressSource")
|
|
37
175
|
local ProgressSource = ____ProgressSource.ProgressSource
|
|
38
|
-
|
|
176
|
+
local ____UnitSource = require("datasources.UnitSource")
|
|
177
|
+
local resolveUnit = ____UnitSource.resolveUnit
|
|
178
|
+
do
|
|
179
|
+
local ____UnitSource = require("datasources.UnitSource")
|
|
180
|
+
____exports.Unit = ____UnitSource.Unit
|
|
181
|
+
end
|
|
39
182
|
--- Direct API-to-widget binding; opaque values are never compared or calculated.
|
|
40
183
|
local Resource = __TS__Class()
|
|
41
184
|
Resource.name = "Resource"
|
|
@@ -72,31 +215,49 @@ local HP = ____exports.HP
|
|
|
72
215
|
HP.name = "HP"
|
|
73
216
|
__TS__ClassExtends(HP, Resource)
|
|
74
217
|
function HP.prototype.____constructor(self, unit)
|
|
218
|
+
local target = resolveUnit(nil, unit)
|
|
75
219
|
Resource.prototype.____constructor(
|
|
76
220
|
self,
|
|
77
|
-
function() return UnitHealth(
|
|
78
|
-
function() return UnitHealthMax(
|
|
79
|
-
function() return UnitHealthPercent(
|
|
80
|
-
|
|
221
|
+
function() return UnitHealth(target.Token) end,
|
|
222
|
+
function() return UnitHealthMax(target.Token) end,
|
|
223
|
+
function() return UnitHealthPercent(target.Token, true, CurveConstants.ScaleTo100) end,
|
|
224
|
+
target.Token,
|
|
81
225
|
{"UNIT_HEALTH", "UNIT_MAXHEALTH"}
|
|
82
226
|
)
|
|
83
|
-
self.
|
|
227
|
+
self.target = target
|
|
84
228
|
end
|
|
229
|
+
__TS__SetDescriptor(
|
|
230
|
+
HP.prototype,
|
|
231
|
+
"unit",
|
|
232
|
+
{get = function(self)
|
|
233
|
+
return self.target.Token
|
|
234
|
+
end},
|
|
235
|
+
true
|
|
236
|
+
)
|
|
85
237
|
--- Explicit mana (power type 0), even while the unit uses rage/energy.
|
|
86
238
|
____exports.Mana = __TS__Class()
|
|
87
239
|
local Mana = ____exports.Mana
|
|
88
240
|
Mana.name = "Mana"
|
|
89
241
|
__TS__ClassExtends(Mana, Resource)
|
|
90
242
|
function Mana.prototype.____constructor(self, unit)
|
|
243
|
+
local target = resolveUnit(nil, unit)
|
|
91
244
|
Resource.prototype.____constructor(
|
|
92
245
|
self,
|
|
93
|
-
function() return UnitPower(
|
|
94
|
-
function() return UnitPowerMax(
|
|
95
|
-
function() return UnitPowerPercent(
|
|
96
|
-
|
|
246
|
+
function() return UnitPower(target.Token, 0) end,
|
|
247
|
+
function() return UnitPowerMax(target.Token, 0) end,
|
|
248
|
+
function() return UnitPowerPercent(target.Token, 0, true, CurveConstants.ScaleTo100) end,
|
|
249
|
+
target.Token,
|
|
97
250
|
{"UNIT_POWER_UPDATE", "UNIT_MAXPOWER", "UNIT_DISPLAYPOWER"}
|
|
98
251
|
)
|
|
99
|
-
self.
|
|
252
|
+
self.target = target
|
|
100
253
|
end
|
|
254
|
+
__TS__SetDescriptor(
|
|
255
|
+
Mana.prototype,
|
|
256
|
+
"unit",
|
|
257
|
+
{get = function(self)
|
|
258
|
+
return self.target.Token
|
|
259
|
+
end},
|
|
260
|
+
true
|
|
261
|
+
)
|
|
101
262
|
____exports.DataSources = {Resources = {HP = ____exports.HP, Mana = ____exports.Mana}}
|
|
102
263
|
return ____exports
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { DataSource } from "./DataSource";
|
|
2
|
+
import { UnitSource } from "./UnitSource";
|
|
3
|
+
import type { UnitInput } from "./UnitSource";
|
|
4
|
+
export interface ClassInfo {
|
|
5
|
+
readonly id: number;
|
|
6
|
+
readonly token: string;
|
|
7
|
+
readonly name: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class ClassSource extends DataSource<ClassInfo | undefined> {
|
|
10
|
+
private restricted;
|
|
11
|
+
readonly target: UnitSource;
|
|
12
|
+
constructor(unit: UnitInput);
|
|
13
|
+
get unit(): string;
|
|
14
|
+
protected HasSecretFields(): boolean;
|
|
15
|
+
protected GetValue(): ClassInfo | undefined;
|
|
16
|
+
}
|
|
17
|
+
export interface SpecializationInfo {
|
|
18
|
+
readonly id: number;
|
|
19
|
+
readonly name?: string;
|
|
20
|
+
readonly icon?: number;
|
|
21
|
+
readonly role?: string;
|
|
22
|
+
/** Native value when provided by the client; never estimated. */
|
|
23
|
+
readonly pointsSpent?: number;
|
|
24
|
+
}
|
|
25
|
+
export type InspectStatus = "idle" | "pending" | "ready" | "unsupported";
|
|
26
|
+
/** Own data is read live; other units require an explicit inspect request. */
|
|
27
|
+
export declare class SpecSource extends DataSource<readonly SpecializationInfo[] | undefined> {
|
|
28
|
+
private restricted;
|
|
29
|
+
private snapshot?;
|
|
30
|
+
private snapshotGUID?;
|
|
31
|
+
private listener?;
|
|
32
|
+
private status;
|
|
33
|
+
readonly target: UnitSource;
|
|
34
|
+
constructor(unit: UnitInput);
|
|
35
|
+
get unit(): string;
|
|
36
|
+
get Status(): InspectStatus;
|
|
37
|
+
protected HasSecretFields(): boolean;
|
|
38
|
+
protected GetValue(): readonly SpecializationInfo[] | undefined;
|
|
39
|
+
private Read;
|
|
40
|
+
/** Returns false if an inspect cannot start. No request is made from a getter. */
|
|
41
|
+
RequestInspect(): boolean;
|
|
42
|
+
private StopListening;
|
|
43
|
+
Dispose(): void;
|
|
44
|
+
}
|
|
45
|
+
export { SpecSource as Specializations };
|
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
-- Lua Library inline imports
|
|
3
|
+
local function __TS__Class(self)
|
|
4
|
+
local c = {prototype = {}}
|
|
5
|
+
c.prototype.__index = c.prototype
|
|
6
|
+
c.prototype.constructor = c
|
|
7
|
+
return c
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
local function __TS__ClassExtends(target, base)
|
|
11
|
+
target.____super = base
|
|
12
|
+
local staticMetatable = setmetatable({__index = base}, base)
|
|
13
|
+
setmetatable(target, staticMetatable)
|
|
14
|
+
local baseMetatable = getmetatable(base)
|
|
15
|
+
if baseMetatable then
|
|
16
|
+
if type(baseMetatable.__index) == "function" then
|
|
17
|
+
staticMetatable.__index = baseMetatable.__index
|
|
18
|
+
end
|
|
19
|
+
if type(baseMetatable.__newindex) == "function" then
|
|
20
|
+
staticMetatable.__newindex = baseMetatable.__newindex
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
setmetatable(target.prototype, base.prototype)
|
|
24
|
+
if type(base.prototype.__index) == "function" then
|
|
25
|
+
target.prototype.__index = base.prototype.__index
|
|
26
|
+
end
|
|
27
|
+
if type(base.prototype.__newindex) == "function" then
|
|
28
|
+
target.prototype.__newindex = base.prototype.__newindex
|
|
29
|
+
end
|
|
30
|
+
if type(base.prototype.__tostring) == "function" then
|
|
31
|
+
target.prototype.__tostring = base.prototype.__tostring
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
local function __TS__CloneDescriptor(____bindingPattern0)
|
|
36
|
+
local value
|
|
37
|
+
local writable
|
|
38
|
+
local set
|
|
39
|
+
local get
|
|
40
|
+
local configurable
|
|
41
|
+
local enumerable
|
|
42
|
+
enumerable = ____bindingPattern0.enumerable
|
|
43
|
+
configurable = ____bindingPattern0.configurable
|
|
44
|
+
get = ____bindingPattern0.get
|
|
45
|
+
set = ____bindingPattern0.set
|
|
46
|
+
writable = ____bindingPattern0.writable
|
|
47
|
+
value = ____bindingPattern0.value
|
|
48
|
+
local descriptor = {enumerable = enumerable == true, configurable = configurable == true}
|
|
49
|
+
local hasGetterOrSetter = get ~= nil or set ~= nil
|
|
50
|
+
local hasValueOrWritableAttribute = writable ~= nil or value ~= nil
|
|
51
|
+
if hasGetterOrSetter and hasValueOrWritableAttribute then
|
|
52
|
+
error("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute.", 0)
|
|
53
|
+
end
|
|
54
|
+
if get or set then
|
|
55
|
+
descriptor.get = get
|
|
56
|
+
descriptor.set = set
|
|
57
|
+
else
|
|
58
|
+
descriptor.value = value
|
|
59
|
+
descriptor.writable = writable == true
|
|
60
|
+
end
|
|
61
|
+
return descriptor
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
local __TS__DescriptorGet
|
|
65
|
+
do
|
|
66
|
+
local getmetatable = _G.getmetatable
|
|
67
|
+
local ____rawget = _G.rawget
|
|
68
|
+
function __TS__DescriptorGet(self, metatable, key)
|
|
69
|
+
while metatable do
|
|
70
|
+
local rawResult = ____rawget(metatable, key)
|
|
71
|
+
if rawResult ~= nil then
|
|
72
|
+
return rawResult
|
|
73
|
+
end
|
|
74
|
+
local descriptors = ____rawget(metatable, "_descriptors")
|
|
75
|
+
if descriptors then
|
|
76
|
+
local descriptor = descriptors[key]
|
|
77
|
+
if descriptor ~= nil then
|
|
78
|
+
if descriptor.get then
|
|
79
|
+
return descriptor.get(self)
|
|
80
|
+
end
|
|
81
|
+
return descriptor.value
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
metatable = getmetatable(metatable)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
local __TS__DescriptorSet
|
|
90
|
+
do
|
|
91
|
+
local getmetatable = _G.getmetatable
|
|
92
|
+
local ____rawget = _G.rawget
|
|
93
|
+
local rawset = _G.rawset
|
|
94
|
+
function __TS__DescriptorSet(self, metatable, key, value)
|
|
95
|
+
while metatable do
|
|
96
|
+
local descriptors = ____rawget(metatable, "_descriptors")
|
|
97
|
+
if descriptors then
|
|
98
|
+
local descriptor = descriptors[key]
|
|
99
|
+
if descriptor ~= nil then
|
|
100
|
+
if descriptor.set then
|
|
101
|
+
descriptor.set(self, value)
|
|
102
|
+
else
|
|
103
|
+
if descriptor.writable == false then
|
|
104
|
+
error(
|
|
105
|
+
((("Cannot assign to read only property '" .. key) .. "' of object '") .. tostring(self)) .. "'",
|
|
106
|
+
0
|
|
107
|
+
)
|
|
108
|
+
end
|
|
109
|
+
descriptor.value = value
|
|
110
|
+
end
|
|
111
|
+
return
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
metatable = getmetatable(metatable)
|
|
115
|
+
end
|
|
116
|
+
rawset(self, key, value)
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
local __TS__SetDescriptor
|
|
121
|
+
do
|
|
122
|
+
local getmetatable = _G.getmetatable
|
|
123
|
+
local function descriptorIndex(self, key)
|
|
124
|
+
return __TS__DescriptorGet(
|
|
125
|
+
self,
|
|
126
|
+
getmetatable(self),
|
|
127
|
+
key
|
|
128
|
+
)
|
|
129
|
+
end
|
|
130
|
+
local function descriptorNewIndex(self, key, value)
|
|
131
|
+
return __TS__DescriptorSet(
|
|
132
|
+
self,
|
|
133
|
+
getmetatable(self),
|
|
134
|
+
key,
|
|
135
|
+
value
|
|
136
|
+
)
|
|
137
|
+
end
|
|
138
|
+
function __TS__SetDescriptor(target, key, desc, isPrototype)
|
|
139
|
+
if isPrototype == nil then
|
|
140
|
+
isPrototype = false
|
|
141
|
+
end
|
|
142
|
+
local ____isPrototype_0
|
|
143
|
+
if isPrototype then
|
|
144
|
+
____isPrototype_0 = target
|
|
145
|
+
else
|
|
146
|
+
____isPrototype_0 = getmetatable(target)
|
|
147
|
+
end
|
|
148
|
+
local metatable = ____isPrototype_0
|
|
149
|
+
if not metatable then
|
|
150
|
+
metatable = {}
|
|
151
|
+
setmetatable(target, metatable)
|
|
152
|
+
end
|
|
153
|
+
if not isPrototype and not rawget(metatable, "_isOwnDescriptorMetatable") then
|
|
154
|
+
local instanceMetatable = {}
|
|
155
|
+
instanceMetatable._isOwnDescriptorMetatable = true
|
|
156
|
+
setmetatable(instanceMetatable, metatable)
|
|
157
|
+
setmetatable(target, instanceMetatable)
|
|
158
|
+
metatable = instanceMetatable
|
|
159
|
+
end
|
|
160
|
+
local value = rawget(target, key)
|
|
161
|
+
if value ~= nil then
|
|
162
|
+
rawset(target, key, nil)
|
|
163
|
+
end
|
|
164
|
+
if not rawget(metatable, "_descriptors") then
|
|
165
|
+
metatable._descriptors = {}
|
|
166
|
+
end
|
|
167
|
+
metatable._descriptors[key] = __TS__CloneDescriptor(desc)
|
|
168
|
+
metatable.__index = descriptorIndex
|
|
169
|
+
metatable.__newindex = descriptorNewIndex
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
local function __TS__New(target, ...)
|
|
174
|
+
local instance = setmetatable({}, target.prototype)
|
|
175
|
+
instance:____constructor(...)
|
|
176
|
+
return instance
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
local function __TS__NumberIsFinite(value)
|
|
180
|
+
return type(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
local function __TS__NumberIsInteger(value)
|
|
184
|
+
return __TS__NumberIsFinite(value) and math.floor(value) == value
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
local function __TS__ArraySome(self, callbackfn, thisArg)
|
|
188
|
+
for i = 1, #self do
|
|
189
|
+
if callbackfn(thisArg, self[i], i - 1, self) then
|
|
190
|
+
return true
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
return false
|
|
194
|
+
end
|
|
195
|
+
-- End of Lua Library inline imports
|
|
196
|
+
local ____exports = {}
|
|
197
|
+
local ____DataSource = require("datasources.DataSource")
|
|
198
|
+
local DataSource = ____DataSource.DataSource
|
|
199
|
+
local ____UnitSource = require("datasources.UnitSource")
|
|
200
|
+
local resolveUnit = ____UnitSource.resolveUnit
|
|
201
|
+
____exports.ClassSource = __TS__Class()
|
|
202
|
+
local ClassSource = ____exports.ClassSource
|
|
203
|
+
ClassSource.name = "ClassSource"
|
|
204
|
+
__TS__ClassExtends(ClassSource, DataSource)
|
|
205
|
+
function ClassSource.prototype.____constructor(self, unit)
|
|
206
|
+
DataSource.prototype.____constructor(self, nil)
|
|
207
|
+
self.restricted = false
|
|
208
|
+
self.target = resolveUnit(nil, unit)
|
|
209
|
+
end
|
|
210
|
+
function ClassSource.prototype.HasSecretFields(self)
|
|
211
|
+
return self.restricted
|
|
212
|
+
end
|
|
213
|
+
function ClassSource.prototype.GetValue(self)
|
|
214
|
+
self.restricted = false
|
|
215
|
+
local player = UnitIsPlayer(self.unit)
|
|
216
|
+
if issecretvalue(player) then
|
|
217
|
+
self.restricted = true
|
|
218
|
+
return nil
|
|
219
|
+
end
|
|
220
|
+
if not player then
|
|
221
|
+
return nil
|
|
222
|
+
end
|
|
223
|
+
local name, token, id = UnitClass(self.unit)
|
|
224
|
+
if issecretvalue(name) or issecretvalue(token) or issecretvalue(id) then
|
|
225
|
+
self.restricted = true
|
|
226
|
+
return nil
|
|
227
|
+
end
|
|
228
|
+
if name == nil or token == nil or id == nil then
|
|
229
|
+
return nil
|
|
230
|
+
end
|
|
231
|
+
return {name = name, token = token, id = id}
|
|
232
|
+
end
|
|
233
|
+
__TS__SetDescriptor(
|
|
234
|
+
ClassSource.prototype,
|
|
235
|
+
"unit",
|
|
236
|
+
{get = function(self)
|
|
237
|
+
return self.target.Token
|
|
238
|
+
end},
|
|
239
|
+
true
|
|
240
|
+
)
|
|
241
|
+
--- Own data is read live; other units require an explicit inspect request.
|
|
242
|
+
____exports.SpecSource = __TS__Class()
|
|
243
|
+
local SpecSource = ____exports.SpecSource
|
|
244
|
+
SpecSource.name = "SpecSource"
|
|
245
|
+
__TS__ClassExtends(SpecSource, DataSource)
|
|
246
|
+
function SpecSource.prototype.____constructor(self, unit)
|
|
247
|
+
DataSource.prototype.____constructor(self, nil)
|
|
248
|
+
self.restricted = false
|
|
249
|
+
self.status = "idle"
|
|
250
|
+
self.target = resolveUnit(nil, unit)
|
|
251
|
+
end
|
|
252
|
+
function SpecSource.prototype.HasSecretFields(self)
|
|
253
|
+
return self.restricted
|
|
254
|
+
end
|
|
255
|
+
function SpecSource.prototype.GetValue(self)
|
|
256
|
+
local player = UnitIsPlayer(self.unit)
|
|
257
|
+
if issecretvalue(player) then
|
|
258
|
+
self.restricted = true
|
|
259
|
+
return nil
|
|
260
|
+
end
|
|
261
|
+
if not player then
|
|
262
|
+
self.restricted = false
|
|
263
|
+
return nil
|
|
264
|
+
end
|
|
265
|
+
local ____self = UnitIsUnit(self.unit, "player")
|
|
266
|
+
if issecretvalue(____self) then
|
|
267
|
+
self.restricted = true
|
|
268
|
+
return nil
|
|
269
|
+
end
|
|
270
|
+
if ____self then
|
|
271
|
+
return self:Read(false)
|
|
272
|
+
end
|
|
273
|
+
local guid = UnitGUID(self.unit)
|
|
274
|
+
if issecretvalue(guid) then
|
|
275
|
+
self.restricted = true
|
|
276
|
+
return nil
|
|
277
|
+
end
|
|
278
|
+
if guid == nil or guid ~= self.snapshotGUID then
|
|
279
|
+
self.restricted = false
|
|
280
|
+
return nil
|
|
281
|
+
end
|
|
282
|
+
return self.snapshot
|
|
283
|
+
end
|
|
284
|
+
function SpecSource.prototype.Read(self, inspect)
|
|
285
|
+
self.restricted = false
|
|
286
|
+
local api = C_SpecializationInfo
|
|
287
|
+
if (api and api.GetNumSpecializationsForClassID) == nil or api.GetSpecializationInfo == nil then
|
|
288
|
+
self.status = "unsupported"
|
|
289
|
+
return nil
|
|
290
|
+
end
|
|
291
|
+
local classes = __TS__New(____exports.ClassSource, self.target)
|
|
292
|
+
if classes:IsSecret() then
|
|
293
|
+
self.restricted = true
|
|
294
|
+
return nil
|
|
295
|
+
end
|
|
296
|
+
local info = classes.Value
|
|
297
|
+
if info == nil then
|
|
298
|
+
return nil
|
|
299
|
+
end
|
|
300
|
+
local count = api.GetNumSpecializationsForClassID(info.id)
|
|
301
|
+
if issecretvalue(count) then
|
|
302
|
+
self.restricted = true
|
|
303
|
+
return nil
|
|
304
|
+
end
|
|
305
|
+
if not __TS__NumberIsInteger(count) or count < 0 or count > 32 then
|
|
306
|
+
error("Specializations: invalid specialization count")
|
|
307
|
+
end
|
|
308
|
+
local result = {}
|
|
309
|
+
do
|
|
310
|
+
local index = 1
|
|
311
|
+
while index <= count do
|
|
312
|
+
local id, name, _description, icon, role, _stat, pointsSpent = api.GetSpecializationInfo(
|
|
313
|
+
index,
|
|
314
|
+
inspect,
|
|
315
|
+
false,
|
|
316
|
+
inspect and self.unit or nil,
|
|
317
|
+
nil,
|
|
318
|
+
nil,
|
|
319
|
+
info.id
|
|
320
|
+
)
|
|
321
|
+
if __TS__ArraySome(
|
|
322
|
+
{
|
|
323
|
+
id,
|
|
324
|
+
name,
|
|
325
|
+
icon,
|
|
326
|
+
role,
|
|
327
|
+
pointsSpent
|
|
328
|
+
},
|
|
329
|
+
function(____, value) return issecretvalue(value) end
|
|
330
|
+
) then
|
|
331
|
+
self.restricted = true
|
|
332
|
+
return nil
|
|
333
|
+
end
|
|
334
|
+
if id <= 0 then
|
|
335
|
+
return nil
|
|
336
|
+
end
|
|
337
|
+
result[#result + 1] = {
|
|
338
|
+
id = id,
|
|
339
|
+
name = name,
|
|
340
|
+
icon = icon,
|
|
341
|
+
role = role,
|
|
342
|
+
pointsSpent = pointsSpent
|
|
343
|
+
}
|
|
344
|
+
index = index + 1
|
|
345
|
+
end
|
|
346
|
+
end
|
|
347
|
+
self.status = "ready"
|
|
348
|
+
return result
|
|
349
|
+
end
|
|
350
|
+
function SpecSource.prototype.RequestInspect(self)
|
|
351
|
+
self:Dispose()
|
|
352
|
+
self.snapshot = nil
|
|
353
|
+
self.snapshotGUID = nil
|
|
354
|
+
self.restricted = false
|
|
355
|
+
local player = UnitIsPlayer(self.unit)
|
|
356
|
+
if issecretvalue(player) then
|
|
357
|
+
self.restricted = true
|
|
358
|
+
return false
|
|
359
|
+
end
|
|
360
|
+
if not player then
|
|
361
|
+
return false
|
|
362
|
+
end
|
|
363
|
+
if CanInspect == nil or NotifyInspect == nil or (C_SpecializationInfo and C_SpecializationInfo.GetSpecializationInfo) == nil then
|
|
364
|
+
self.status = "unsupported"
|
|
365
|
+
return false
|
|
366
|
+
end
|
|
367
|
+
if InCombatLockdown() then
|
|
368
|
+
return false
|
|
369
|
+
end
|
|
370
|
+
local guid = UnitGUID(self.unit)
|
|
371
|
+
if issecretvalue(guid) then
|
|
372
|
+
self.restricted = true
|
|
373
|
+
return false
|
|
374
|
+
end
|
|
375
|
+
local allowed = CanInspect(self.unit)
|
|
376
|
+
if issecretvalue(allowed) then
|
|
377
|
+
self.restricted = true
|
|
378
|
+
return false
|
|
379
|
+
end
|
|
380
|
+
if guid == nil or not allowed then
|
|
381
|
+
return false
|
|
382
|
+
end
|
|
383
|
+
self.snapshotGUID = guid
|
|
384
|
+
self.status = "pending"
|
|
385
|
+
local listener = CreateFrame("Frame", nil, UIParent)
|
|
386
|
+
self.listener = listener
|
|
387
|
+
listener:RegisterEvent("INSPECT_READY")
|
|
388
|
+
listener:SetScript(
|
|
389
|
+
"OnEvent",
|
|
390
|
+
function(_frame, _event, inspectedGUID)
|
|
391
|
+
if issecretvalue(inspectedGUID) or inspectedGUID ~= guid then
|
|
392
|
+
return
|
|
393
|
+
end
|
|
394
|
+
local current = UnitGUID(self.unit)
|
|
395
|
+
if issecretvalue(current) or current ~= guid then
|
|
396
|
+
self:Dispose()
|
|
397
|
+
return
|
|
398
|
+
end
|
|
399
|
+
self.snapshot = self:Read(true)
|
|
400
|
+
self:StopListening()
|
|
401
|
+
if self.status == "pending" then
|
|
402
|
+
self.status = "idle"
|
|
403
|
+
end
|
|
404
|
+
end
|
|
405
|
+
)
|
|
406
|
+
NotifyInspect(self.unit)
|
|
407
|
+
return true
|
|
408
|
+
end
|
|
409
|
+
function SpecSource.prototype.StopListening(self)
|
|
410
|
+
local ____opt_4 = self.listener
|
|
411
|
+
if ____opt_4 ~= nil then
|
|
412
|
+
____opt_4:UnregisterAllEvents()
|
|
413
|
+
end
|
|
414
|
+
local ____opt_6 = self.listener
|
|
415
|
+
if ____opt_6 ~= nil then
|
|
416
|
+
____opt_6:SetScript("OnEvent", nil)
|
|
417
|
+
end
|
|
418
|
+
local ____opt_8 = self.listener
|
|
419
|
+
if ____opt_8 ~= nil then
|
|
420
|
+
____opt_8:Hide()
|
|
421
|
+
end
|
|
422
|
+
self.listener = nil
|
|
423
|
+
end
|
|
424
|
+
function SpecSource.prototype.Dispose(self)
|
|
425
|
+
self:StopListening()
|
|
426
|
+
self.status = "idle"
|
|
427
|
+
self.snapshot = nil
|
|
428
|
+
self.snapshotGUID = nil
|
|
429
|
+
end
|
|
430
|
+
__TS__SetDescriptor(
|
|
431
|
+
SpecSource.prototype,
|
|
432
|
+
"unit",
|
|
433
|
+
{get = function(self)
|
|
434
|
+
return self.target.Token
|
|
435
|
+
end},
|
|
436
|
+
true
|
|
437
|
+
)
|
|
438
|
+
__TS__SetDescriptor(
|
|
439
|
+
SpecSource.prototype,
|
|
440
|
+
"Status",
|
|
441
|
+
{get = function(self)
|
|
442
|
+
local guid = UnitGUID(self.unit)
|
|
443
|
+
if not issecretvalue(guid) and self.snapshotGUID ~= nil and guid ~= self.snapshotGUID then
|
|
444
|
+
return "idle"
|
|
445
|
+
end
|
|
446
|
+
return self.status
|
|
447
|
+
end},
|
|
448
|
+
true
|
|
449
|
+
)
|
|
450
|
+
____exports.Specializations = ____exports.SpecSource
|
|
451
|
+
return ____exports
|