wuira 0.1.1 → 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.
@@ -1,7 +1,7 @@
1
1
  import { ProgressSource } from "./ProgressSource";
2
- export declare const Unit: {
3
- readonly Player: "player";
4
- };
2
+ import { UnitSource } from "./UnitSource";
3
+ import type { UnitInput } from "./UnitSource";
4
+ export { Unit } from "./UnitSource";
5
5
  /** Direct API-to-widget binding; opaque values are never compared or calculated. */
6
6
  declare abstract class Resource extends ProgressSource {
7
7
  private readonly unitToken;
@@ -10,13 +10,15 @@ declare abstract class Resource extends ProgressSource {
10
10
  protected Listen(frame: wuiraNativeFrame, refresh: () => void): void;
11
11
  }
12
12
  export declare class HP extends Resource {
13
- readonly unit: string;
14
- constructor(unit: string);
13
+ readonly target: UnitSource;
14
+ get unit(): string;
15
+ constructor(unit: UnitInput);
15
16
  }
16
17
  /** Explicit mana (power type 0), even while the unit uses rage/energy. */
17
18
  export declare class Mana extends Resource {
18
- readonly unit: string;
19
- constructor(unit: string);
19
+ readonly target: UnitSource;
20
+ get unit(): string;
21
+ constructor(unit: UnitInput);
20
22
  }
21
23
  export declare const DataSources: {
22
24
  Resources: {
@@ -24,4 +26,3 @@ export declare const DataSources: {
24
26
  Mana: typeof Mana;
25
27
  };
26
28
  };
27
- export {};
@@ -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
- ____exports.Unit = {Player = "player"}
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(unit) end,
78
- function() return UnitHealthMax(unit) end,
79
- function() return UnitHealthPercent(unit, true, CurveConstants.ScaleTo100) end,
80
- unit,
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.unit = unit
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(unit, 0) end,
94
- function() return UnitPowerMax(unit, 0) end,
95
- function() return UnitPowerPercent(unit, 0, true, CurveConstants.ScaleTo100) end,
96
- unit,
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.unit = unit
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 };