wuira 0.3.3 → 0.4.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +15 -12
  3. package/docs/source-converters.md +5 -5
  4. package/docs/spells.md +1 -1
  5. package/lib/datasources/NativeApi.d.ts +319 -0
  6. package/lib/datasources/NativeApi.lua +1114 -0
  7. package/lib/datasources/UseSource.d.ts +41 -43
  8. package/lib/datasources/index.d.ts +3 -25
  9. package/lib/datasources/index.lua +45 -74
  10. package/lib/helpers/Auras.d.ts +5 -0
  11. package/lib/helpers/Auras.lua +47 -0
  12. package/lib/helpers/Range.d.ts +2 -0
  13. package/lib/helpers/Range.lua +30 -0
  14. package/lib/helpers/index.d.ts +2 -0
  15. package/lib/helpers/index.lua +12 -0
  16. package/lib/index.d.ts +1 -0
  17. package/lib/index.lua +6 -0
  18. package/lib/platform/forever.d.ts +3 -0
  19. package/lib/rendering/progress.lua +5 -150
  20. package/lib/ui/UnitPortrait.d.ts +1 -2
  21. package/lib/ui/UnitPortrait.lua +11 -18
  22. package/package.json +8 -1
  23. package/lib/datasources/AuraTimer.d.ts +0 -21
  24. package/lib/datasources/AuraTimer.lua +0 -334
  25. package/lib/datasources/Auras.d.ts +0 -32
  26. package/lib/datasources/Auras.lua +0 -300
  27. package/lib/datasources/CastTimer.d.ts +0 -9
  28. package/lib/datasources/CastTimer.lua +0 -255
  29. package/lib/datasources/EditModeLayouts.d.ts +0 -33
  30. package/lib/datasources/EditModeLayouts.lua +0 -698
  31. package/lib/datasources/GroupMembers.d.ts +0 -24
  32. package/lib/datasources/GroupMembers.lua +0 -477
  33. package/lib/datasources/GroupRoster.d.ts +0 -28
  34. package/lib/datasources/GroupRoster.lua +0 -622
  35. package/lib/datasources/KnownSpells.d.ts +0 -33
  36. package/lib/datasources/KnownSpells.lua +0 -1077
  37. package/lib/datasources/ManaRegenTimer.d.ts +0 -29
  38. package/lib/datasources/ManaRegenTimer.lua +0 -683
  39. package/lib/datasources/Resources.d.ts +0 -81
  40. package/lib/datasources/Resources.lua +0 -907
  41. package/lib/datasources/SpellCooldown.d.ts +0 -12
  42. package/lib/datasources/SpellCooldown.lua +0 -240
  43. package/lib/datasources/SpellSource.d.ts +0 -14
  44. package/lib/datasources/SpellSource.lua +0 -236
  45. package/lib/datasources/SwingTimer.d.ts +0 -31
  46. package/lib/datasources/SwingTimer.lua +0 -650
  47. package/lib/datasources/TotemTimer.d.ts +0 -10
  48. package/lib/datasources/TotemTimer.lua +0 -275
  49. package/lib/datasources/UnitInfo.d.ts +0 -51
  50. package/lib/datasources/UnitInfo.lua +0 -801
  51. package/lib/datasources/UnitSource.d.ts +0 -38
  52. package/lib/datasources/UnitSource.lua +0 -613
@@ -1,907 +0,0 @@
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 __TS__Symbol, Symbol
36
- do
37
- local symbolMetatable = {__tostring = function(self)
38
- return ("Symbol(" .. (self.description or "")) .. ")"
39
- end}
40
- function __TS__Symbol(description)
41
- return setmetatable({description = description}, symbolMetatable)
42
- end
43
- Symbol = {
44
- asyncDispose = __TS__Symbol("Symbol.asyncDispose"),
45
- dispose = __TS__Symbol("Symbol.dispose"),
46
- iterator = __TS__Symbol("Symbol.iterator"),
47
- hasInstance = __TS__Symbol("Symbol.hasInstance"),
48
- species = __TS__Symbol("Symbol.species"),
49
- toStringTag = __TS__Symbol("Symbol.toStringTag")
50
- }
51
- end
52
-
53
- local __TS__Iterator
54
- do
55
- local function iteratorGeneratorStep(self)
56
- local co = self.____coroutine
57
- local status, value = coroutine.resume(co)
58
- if not status then
59
- error(value, 0)
60
- end
61
- if coroutine.status(co) == "dead" then
62
- return
63
- end
64
- return true, value
65
- end
66
- local function iteratorIteratorStep(self)
67
- local result = self:next()
68
- if result.done then
69
- return
70
- end
71
- return true, result.value
72
- end
73
- local function iteratorStringStep(self, index)
74
- index = index + 1
75
- if index > #self then
76
- return
77
- end
78
- return index, string.sub(self, index, index)
79
- end
80
- function __TS__Iterator(iterable)
81
- if type(iterable) == "string" then
82
- return iteratorStringStep, iterable, 0
83
- elseif iterable.____coroutine ~= nil then
84
- return iteratorGeneratorStep, iterable
85
- elseif iterable[Symbol.iterator] then
86
- local iterator = iterable[Symbol.iterator](iterable)
87
- return iteratorIteratorStep, iterator
88
- else
89
- return ipairs(iterable)
90
- end
91
- end
92
- end
93
-
94
- local function __TS__New(target, ...)
95
- local instance = setmetatable({}, target.prototype)
96
- instance:____constructor(...)
97
- return instance
98
- end
99
-
100
- local Set
101
- do
102
- Set = __TS__Class()
103
- Set.name = "Set"
104
- function Set.prototype.____constructor(self, values)
105
- self[Symbol.toStringTag] = "Set"
106
- self.size = 0
107
- self.nextKey = {}
108
- self.previousKey = {}
109
- if values == nil then
110
- return
111
- end
112
- local iterable = values
113
- if iterable[Symbol.iterator] then
114
- local iterator = iterable[Symbol.iterator](iterable)
115
- while true do
116
- local result = iterator:next()
117
- if result.done then
118
- break
119
- end
120
- self:add(result.value)
121
- end
122
- else
123
- local array = values
124
- for ____, value in ipairs(array) do
125
- self:add(value)
126
- end
127
- end
128
- end
129
- function Set.prototype.add(self, value)
130
- local isNewValue = not self:has(value)
131
- if isNewValue then
132
- self.size = self.size + 1
133
- end
134
- if self.firstKey == nil then
135
- self.firstKey = value
136
- self.lastKey = value
137
- elseif isNewValue then
138
- self.nextKey[self.lastKey] = value
139
- self.previousKey[value] = self.lastKey
140
- self.lastKey = value
141
- end
142
- return self
143
- end
144
- function Set.prototype.clear(self)
145
- self.nextKey = {}
146
- self.previousKey = {}
147
- self.firstKey = nil
148
- self.lastKey = nil
149
- self.size = 0
150
- end
151
- function Set.prototype.delete(self, value)
152
- local contains = self:has(value)
153
- if contains then
154
- self.size = self.size - 1
155
- local next = self.nextKey[value]
156
- local previous = self.previousKey[value]
157
- if next ~= nil and previous ~= nil then
158
- self.nextKey[previous] = next
159
- self.previousKey[next] = previous
160
- elseif next ~= nil then
161
- self.firstKey = next
162
- self.previousKey[next] = nil
163
- elseif previous ~= nil then
164
- self.lastKey = previous
165
- self.nextKey[previous] = nil
166
- else
167
- self.firstKey = nil
168
- self.lastKey = nil
169
- end
170
- self.nextKey[value] = nil
171
- self.previousKey[value] = nil
172
- end
173
- return contains
174
- end
175
- function Set.prototype.forEach(self, callback)
176
- for ____, key in __TS__Iterator(self:keys()) do
177
- callback(nil, key, key, self)
178
- end
179
- end
180
- function Set.prototype.has(self, value)
181
- return self.nextKey[value] ~= nil or self.lastKey == value
182
- end
183
- Set.prototype[Symbol.iterator] = function(self)
184
- return self:values()
185
- end
186
- function Set.prototype.entries(self)
187
- local function getFirstKey()
188
- return self.firstKey
189
- end
190
- local nextKey = self.nextKey
191
- local key
192
- local started = false
193
- return {
194
- [Symbol.iterator] = function(self)
195
- return self
196
- end,
197
- next = function(self)
198
- if not started then
199
- started = true
200
- key = getFirstKey(nil)
201
- else
202
- key = nextKey[key]
203
- end
204
- return {done = not key, value = {key, key}}
205
- end
206
- }
207
- end
208
- function Set.prototype.keys(self)
209
- local function getFirstKey()
210
- return self.firstKey
211
- end
212
- local nextKey = self.nextKey
213
- local key
214
- local started = false
215
- return {
216
- [Symbol.iterator] = function(self)
217
- return self
218
- end,
219
- next = function(self)
220
- if not started then
221
- started = true
222
- key = getFirstKey(nil)
223
- else
224
- key = nextKey[key]
225
- end
226
- return {done = not key, value = key}
227
- end
228
- }
229
- end
230
- function Set.prototype.values(self)
231
- local function getFirstKey()
232
- return self.firstKey
233
- end
234
- local nextKey = self.nextKey
235
- local key
236
- local started = false
237
- return {
238
- [Symbol.iterator] = function(self)
239
- return self
240
- end,
241
- next = function(self)
242
- if not started then
243
- started = true
244
- key = getFirstKey(nil)
245
- else
246
- key = nextKey[key]
247
- end
248
- return {done = not key, value = key}
249
- end
250
- }
251
- end
252
- function Set.prototype.union(self, other)
253
- local result = __TS__New(Set, self)
254
- for ____, item in __TS__Iterator(other) do
255
- result:add(item)
256
- end
257
- return result
258
- end
259
- function Set.prototype.intersection(self, other)
260
- local result = __TS__New(Set)
261
- for ____, item in __TS__Iterator(self) do
262
- if other:has(item) then
263
- result:add(item)
264
- end
265
- end
266
- return result
267
- end
268
- function Set.prototype.difference(self, other)
269
- local result = __TS__New(Set, self)
270
- for ____, item in __TS__Iterator(other) do
271
- result:delete(item)
272
- end
273
- return result
274
- end
275
- function Set.prototype.symmetricDifference(self, other)
276
- local result = __TS__New(Set, self)
277
- for ____, item in __TS__Iterator(other) do
278
- if self:has(item) then
279
- result:delete(item)
280
- else
281
- result:add(item)
282
- end
283
- end
284
- return result
285
- end
286
- function Set.prototype.isSubsetOf(self, other)
287
- for ____, item in __TS__Iterator(self) do
288
- if not other:has(item) then
289
- return false
290
- end
291
- end
292
- return true
293
- end
294
- function Set.prototype.isSupersetOf(self, other)
295
- for ____, item in __TS__Iterator(other) do
296
- if not self:has(item) then
297
- return false
298
- end
299
- end
300
- return true
301
- end
302
- function Set.prototype.isDisjointFrom(self, other)
303
- for ____, item in __TS__Iterator(self) do
304
- if other:has(item) then
305
- return false
306
- end
307
- end
308
- return true
309
- end
310
- Set[Symbol.species] = Set
311
- end
312
-
313
- local function __TS__ArrayIncludes(self, searchElement, fromIndex)
314
- if fromIndex == nil then
315
- fromIndex = 0
316
- end
317
- local len = #self
318
- local k = fromIndex
319
- if fromIndex < 0 then
320
- k = len + fromIndex
321
- end
322
- if k < 0 then
323
- k = 0
324
- end
325
- for i = k + 1, len do
326
- if self[i] == searchElement then
327
- return true
328
- end
329
- end
330
- return false
331
- end
332
-
333
- local function __TS__CloneDescriptor(____bindingPattern0)
334
- local value
335
- local writable
336
- local set
337
- local get
338
- local configurable
339
- local enumerable
340
- enumerable = ____bindingPattern0.enumerable
341
- configurable = ____bindingPattern0.configurable
342
- get = ____bindingPattern0.get
343
- set = ____bindingPattern0.set
344
- writable = ____bindingPattern0.writable
345
- value = ____bindingPattern0.value
346
- local descriptor = {enumerable = enumerable == true, configurable = configurable == true}
347
- local hasGetterOrSetter = get ~= nil or set ~= nil
348
- local hasValueOrWritableAttribute = writable ~= nil or value ~= nil
349
- if hasGetterOrSetter and hasValueOrWritableAttribute then
350
- error("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute.", 0)
351
- end
352
- if get or set then
353
- descriptor.get = get
354
- descriptor.set = set
355
- else
356
- descriptor.value = value
357
- descriptor.writable = writable == true
358
- end
359
- return descriptor
360
- end
361
-
362
- local __TS__DescriptorGet
363
- do
364
- local getmetatable = _G.getmetatable
365
- local ____rawget = _G.rawget
366
- function __TS__DescriptorGet(self, metatable, key)
367
- while metatable do
368
- local rawResult = ____rawget(metatable, key)
369
- if rawResult ~= nil then
370
- return rawResult
371
- end
372
- local descriptors = ____rawget(metatable, "_descriptors")
373
- if descriptors then
374
- local descriptor = descriptors[key]
375
- if descriptor ~= nil then
376
- if descriptor.get then
377
- return descriptor.get(self)
378
- end
379
- return descriptor.value
380
- end
381
- end
382
- metatable = getmetatable(metatable)
383
- end
384
- end
385
- end
386
-
387
- local __TS__DescriptorSet
388
- do
389
- local getmetatable = _G.getmetatable
390
- local ____rawget = _G.rawget
391
- local rawset = _G.rawset
392
- function __TS__DescriptorSet(self, metatable, key, value)
393
- while metatable do
394
- local descriptors = ____rawget(metatable, "_descriptors")
395
- if descriptors then
396
- local descriptor = descriptors[key]
397
- if descriptor ~= nil then
398
- if descriptor.set then
399
- descriptor.set(self, value)
400
- else
401
- if descriptor.writable == false then
402
- error(
403
- ((("Cannot assign to read only property '" .. key) .. "' of object '") .. tostring(self)) .. "'",
404
- 0
405
- )
406
- end
407
- descriptor.value = value
408
- end
409
- return
410
- end
411
- end
412
- metatable = getmetatable(metatable)
413
- end
414
- rawset(self, key, value)
415
- end
416
- end
417
-
418
- local __TS__SetDescriptor
419
- do
420
- local getmetatable = _G.getmetatable
421
- local function descriptorIndex(self, key)
422
- return __TS__DescriptorGet(
423
- self,
424
- getmetatable(self),
425
- key
426
- )
427
- end
428
- local function descriptorNewIndex(self, key, value)
429
- return __TS__DescriptorSet(
430
- self,
431
- getmetatable(self),
432
- key,
433
- value
434
- )
435
- end
436
- function __TS__SetDescriptor(target, key, desc, isPrototype)
437
- if isPrototype == nil then
438
- isPrototype = false
439
- end
440
- local ____isPrototype_0
441
- if isPrototype then
442
- ____isPrototype_0 = target
443
- else
444
- ____isPrototype_0 = getmetatable(target)
445
- end
446
- local metatable = ____isPrototype_0
447
- if not metatable then
448
- metatable = {}
449
- setmetatable(target, metatable)
450
- end
451
- if not isPrototype and not rawget(metatable, "_isOwnDescriptorMetatable") then
452
- local instanceMetatable = {}
453
- instanceMetatable._isOwnDescriptorMetatable = true
454
- setmetatable(instanceMetatable, metatable)
455
- setmetatable(target, instanceMetatable)
456
- metatable = instanceMetatable
457
- end
458
- local value = rawget(target, key)
459
- if value ~= nil then
460
- rawset(target, key, nil)
461
- end
462
- if not rawget(metatable, "_descriptors") then
463
- metatable._descriptors = {}
464
- end
465
- metatable._descriptors[key] = __TS__CloneDescriptor(desc)
466
- metatable.__index = descriptorIndex
467
- metatable.__newindex = descriptorNewIndex
468
- end
469
- end
470
-
471
- local function __TS__ObjectAssign(target, ...)
472
- local sources = {...}
473
- for i = 1, #sources do
474
- local source = sources[i]
475
- if type(source) == "table" then
476
- for key in pairs(source) do
477
- target[key] = source[key]
478
- end
479
- end
480
- end
481
- return target
482
- end
483
- -- End of Lua Library inline imports
484
- local ____exports = {}
485
- local ____ProgressSource = require("datasources.ProgressSource")
486
- local ProgressSource = ____ProgressSource.ProgressSource
487
- local ____UnitSource = require("datasources.UnitSource")
488
- local Unit = ____UnitSource.Unit
489
- local resolveUnit = ____UnitSource.resolveUnit
490
- local ____ManaRegenTimer = require("datasources.ManaRegenTimer")
491
- local ManaRegenTimer = ____ManaRegenTimer.ManaRegenTimer
492
- local ____Source = require("datasources.Source")
493
- local Source = ____Source.Source
494
- local registerSource = ____Source.registerSource
495
- local ____UseSource = require("datasources.UseSource")
496
- local UseSource = ____UseSource.UseSource
497
- do
498
- local ____UnitSource = require("datasources.UnitSource")
499
- ____exports.Unit = ____UnitSource.Unit
500
- end
501
- --- Direct API-to-widget binding; opaque values are never compared or calculated.
502
- local Resource = __TS__Class()
503
- Resource.name = "Resource"
504
- __TS__ClassExtends(Resource, ProgressSource)
505
- function Resource.prototype.____constructor(self, current, maximum, percent, unitReference, events)
506
- ProgressSource.prototype.____constructor(
507
- self,
508
- {
509
- current = current,
510
- min = function() return 0 end,
511
- max = maximum,
512
- percent = percent
513
- }
514
- )
515
- self.unitReference = unitReference
516
- self.events = events
517
- self.listeners = __TS__New(Set)
518
- self.dispatching = false
519
- self.eventValue = 0
520
- end
521
- function Resource.prototype.AddEvents(self, ...)
522
- local events = {...}
523
- for ____, event in ipairs(events) do
524
- do
525
- local __continue5
526
- repeat
527
- if __TS__ArrayIncludes(self.events, event) then
528
- __continue5 = true
529
- break
530
- end
531
- local ____self_events_0 = self.events
532
- ____self_events_0[#____self_events_0 + 1] = event
533
- if self.listeners.size > 0 then
534
- local ____opt_1 = self.eventFrame
535
- if ____opt_1 ~= nil then
536
- ____opt_1:RegisterEvent(event)
537
- end
538
- end
539
- __continue5 = true
540
- until true
541
- if not __continue5 then
542
- break
543
- end
544
- end
545
- end
546
- end
547
- function Resource.prototype.GetValue(self)
548
- return self.dispatching and self.eventValue or ProgressSource.prototype.GetValue(self)
549
- end
550
- function Resource.prototype.onChange(self, listener)
551
- local previous = self:GetValue()
552
- local readable = not issecretvalue(previous)
553
- return self:Observe(function(____, _, _payload, value)
554
- if issecretvalue(value) or not self:CanEmit(value) then
555
- return
556
- end
557
- if readable and value == previous then
558
- return
559
- end
560
- previous = value
561
- readable = true
562
- listener(nil, value)
563
- end)
564
- end
565
- function Resource.prototype.Observe(self, listener)
566
- self.listeners:add(listener)
567
- if self.listeners.size == 1 then
568
- if self.eventFrame == nil then
569
- self.eventFrame = CreateFrame("Frame", nil, UIParent)
570
- end
571
- local frame = self.eventFrame
572
- local function dispatch(____, event, payload)
573
- self.eventValue = ProgressSource.prototype.GetValue(self)
574
- self.dispatching = true
575
- do
576
- local ____try, ____error = pcall(function()
577
- for ____, callback in __TS__Iterator(self.listeners) do
578
- callback(nil, event, payload, self.eventValue)
579
- end
580
- end)
581
- do
582
- self.dispatching = false
583
- end
584
- if not ____try then
585
- error(____error, 0)
586
- end
587
- end
588
- end
589
- frame:SetScript(
590
- "OnEvent",
591
- function(_frame, event, ...)
592
- local payload = {...}
593
- if event ~= "PLAYER_ENTERING_WORLD" and (issecretvalue(payload[1]) or payload[1] ~= self.unitReference.Token) then
594
- return
595
- end
596
- dispatch(nil, event, payload)
597
- end
598
- )
599
- self.stopUnit = self.unitReference:onChange(function() return dispatch(nil, "UNIT_IDENTITY_CHANGED", {self.unitReference.Token}) end)
600
- frame:RegisterEvent("PLAYER_ENTERING_WORLD")
601
- for ____, event in ipairs(self.events) do
602
- frame:RegisterEvent(event)
603
- end
604
- end
605
- return function()
606
- self.listeners:delete(listener)
607
- if self.listeners.size == 0 then
608
- local ____opt_3 = self.stopUnit
609
- if ____opt_3 ~= nil then
610
- ____opt_3(self)
611
- end
612
- self.stopUnit = nil
613
- local ____opt_5 = self.eventFrame
614
- if ____opt_5 ~= nil then
615
- ____opt_5:UnregisterAllEvents()
616
- end
617
- local ____opt_7 = self.eventFrame
618
- if ____opt_7 ~= nil then
619
- ____opt_7:SetScript("OnEvent", nil)
620
- end
621
- end
622
- end
623
- end
624
- function Resource.prototype.Listen(self, _frame, refresh)
625
- return self:Observe(function() return refresh(nil) end)
626
- end
627
- local function unitToken(self, unit)
628
- return type(unit) == "string" and unit or unit.Token
629
- end
630
- local function nativeAmount(self, value)
631
- if issecretvalue(value) then
632
- return value
633
- end
634
- return value or 0
635
- end
636
- --- One optional unit amount. A missing native function stays unavailable and is never called.
637
- local UnitAmount = __TS__Class()
638
- UnitAmount.name = "UnitAmount"
639
- __TS__ClassExtends(UnitAmount, Source)
640
- function UnitAmount.prototype.____constructor(self, unit)
641
- Source.prototype.____constructor(self, 0, unit)
642
- self.target = resolveUnit(nil, unit)
643
- end
644
- function UnitAmount.prototype.ApplyTo(self, frame, maximum)
645
- if not self.IsAvailable then
646
- frame:Hide()
647
- return
648
- end
649
- local value = self:GetValue()
650
- if not self:CanEmit(value) then
651
- frame:Hide()
652
- return
653
- end
654
- frame:SetMinMaxValues(0, maximum)
655
- frame:SetValue(value)
656
- frame:Show()
657
- end
658
- __TS__SetDescriptor(
659
- UnitAmount.prototype,
660
- "IsAvailable",
661
- {get = function(self)
662
- end},
663
- true
664
- )
665
- --- Total absorbs on a unit. `UnitGetTotalAbsorbs`.
666
- ____exports.Absorb = __TS__Class()
667
- local Absorb = ____exports.Absorb
668
- Absorb.name = "Absorb"
669
- __TS__ClassExtends(Absorb, UnitAmount)
670
- function Absorb.prototype.____constructor(self, unit)
671
- UnitAmount.prototype.____constructor(self, unit)
672
- end
673
- function Absorb.prototype.read(self, props)
674
- return UnitGetTotalAbsorbs == nil and 0 or nativeAmount(
675
- nil,
676
- UnitGetTotalAbsorbs(unitToken(nil, props[1]))
677
- )
678
- end
679
- __TS__SetDescriptor(
680
- Absorb.prototype,
681
- "IsAvailable",
682
- {get = function(self)
683
- return UnitGetTotalAbsorbs ~= nil
684
- end},
685
- true
686
- );
687
- (function(self)
688
- registerSource(
689
- nil,
690
- ____exports.Absorb,
691
- function(____, props) return __TS__New(____exports.Absorb, props[1]) end
692
- )
693
- end)(Absorb)
694
- --- Incoming heals on a unit. `UnitGetIncomingHeals`.
695
- ____exports.Prediction = __TS__Class()
696
- local Prediction = ____exports.Prediction
697
- Prediction.name = "Prediction"
698
- __TS__ClassExtends(Prediction, UnitAmount)
699
- function Prediction.prototype.____constructor(self, unit)
700
- UnitAmount.prototype.____constructor(self, unit)
701
- end
702
- function Prediction.prototype.read(self, props)
703
- return UnitGetIncomingHeals == nil and 0 or nativeAmount(
704
- nil,
705
- UnitGetIncomingHeals(unitToken(nil, props[1]))
706
- )
707
- end
708
- __TS__SetDescriptor(
709
- Prediction.prototype,
710
- "IsAvailable",
711
- {get = function(self)
712
- return UnitGetIncomingHeals ~= nil
713
- end},
714
- true
715
- );
716
- (function(self)
717
- registerSource(
718
- nil,
719
- ____exports.Prediction,
720
- function(____, props) return __TS__New(____exports.Prediction, props[1]) end
721
- )
722
- end)(Prediction)
723
- ____exports.HP = __TS__Class()
724
- local HP = ____exports.HP
725
- HP.name = "HP"
726
- __TS__ClassExtends(HP, Resource)
727
- function HP.prototype.____constructor(self, unit)
728
- if unit == nil then
729
- unit = Unit.Player
730
- end
731
- local target = resolveUnit(nil, unit)
732
- Resource.prototype.____constructor(
733
- self,
734
- function() return UnitHealth(target.Token) end,
735
- function() return UnitHealthMax(target.Token) end,
736
- function() return UnitHealthPercent(target.Token, true, CurveConstants.ScaleTo100) end,
737
- target,
738
- {"UNIT_HEALTH", "UNIT_MAXHEALTH", "UNIT_CONNECTION"}
739
- )
740
- self.target = target
741
- end
742
- function HP.prototype.UseAbsorb(self)
743
- if self.absorb == nil then
744
- self.absorb = UseSource(nil, ____exports.Absorb, self.target)
745
- if self.absorb.IsAvailable then
746
- self:AddEvents("UNIT_ABSORB_AMOUNT_CHANGED")
747
- end
748
- end
749
- return self
750
- end
751
- function HP.prototype.UsePrediction(self)
752
- if self.prediction == nil then
753
- self.prediction = UseSource(nil, ____exports.Prediction, self.target)
754
- if self.prediction.IsAvailable then
755
- self:AddEvents("UNIT_HEAL_PREDICTION")
756
- end
757
- end
758
- return self
759
- end
760
- function HP.prototype.UseAbsorbPrediction(self)
761
- return self:UseAbsorb()
762
- end
763
- function HP.prototype.UseHealPrediction(self)
764
- return self:UsePrediction()
765
- end
766
- function HP.prototype.BindTo(self, frame, options)
767
- if options == nil then
768
- options = {}
769
- end
770
- if (options.healPredictionBar ~= nil or options.absorbPredictionBar ~= nil) and (options.min ~= nil or options.max ~= nil or options.current ~= nil) then
771
- error("HP: prediction overlays require the native health scale without min/max/current overrides")
772
- end
773
- return Resource.prototype.BindTo(
774
- self,
775
- frame,
776
- __TS__ObjectAssign(
777
- {},
778
- options,
779
- {onRefresh = function()
780
- if options.healPredictionBar ~= nil or options.absorbPredictionBar ~= nil then
781
- local maximum = UnitHealthMax(self.unit)
782
- if options.healPredictionBar ~= nil then
783
- local ____opt_9 = self.prediction
784
- if ____opt_9 ~= nil then
785
- ____opt_9:ApplyTo(options.healPredictionBar, maximum)
786
- end
787
- end
788
- if options.absorbPredictionBar ~= nil then
789
- local ____opt_11 = self.absorb
790
- if ____opt_11 ~= nil then
791
- ____opt_11:ApplyTo(options.absorbPredictionBar, maximum)
792
- end
793
- end
794
- end
795
- local ____this_14
796
- ____this_14 = options
797
- local ____opt_13 = ____this_14.onRefresh
798
- if ____opt_13 ~= nil then
799
- ____opt_13(____this_14)
800
- end
801
- end}
802
- )
803
- )
804
- end
805
- __TS__SetDescriptor(
806
- HP.prototype,
807
- "Absorb",
808
- {get = function(self)
809
- return self.absorb
810
- end},
811
- true
812
- )
813
- __TS__SetDescriptor(
814
- HP.prototype,
815
- "Prediction",
816
- {get = function(self)
817
- return self.prediction
818
- end},
819
- true
820
- )
821
- __TS__SetDescriptor(
822
- HP.prototype,
823
- "AbsorbPrediction",
824
- {get = function(self)
825
- return self.absorb
826
- end},
827
- true
828
- )
829
- __TS__SetDescriptor(
830
- HP.prototype,
831
- "HealPrediction",
832
- {get = function(self)
833
- return self.prediction
834
- end},
835
- true
836
- )
837
- __TS__SetDescriptor(
838
- HP.prototype,
839
- "unit",
840
- {get = function(self)
841
- return self.target.Token
842
- end},
843
- true
844
- );
845
- (function(self)
846
- registerSource(
847
- nil,
848
- ____exports.HP,
849
- function(____, props) return __TS__New(____exports.HP, props[1]) end
850
- )
851
- end)(HP)
852
- --- Explicit mana (power type 0), even while the unit uses rage/energy.
853
- ____exports.Mana = __TS__Class()
854
- local Mana = ____exports.Mana
855
- Mana.name = "Mana"
856
- __TS__ClassExtends(Mana, Resource)
857
- function Mana.prototype.____constructor(self, unit)
858
- local target = resolveUnit(nil, unit)
859
- Resource.prototype.____constructor(
860
- self,
861
- function() return UnitPower(target.Token, 0) end,
862
- function() return UnitPowerMax(target.Token, 0) end,
863
- function() return UnitPowerPercent(target.Token, 0, true, CurveConstants.ScaleTo100) end,
864
- target,
865
- {"UNIT_POWER_UPDATE", "UNIT_MAXPOWER", "UNIT_DISPLAYPOWER", "UNIT_CONNECTION"}
866
- )
867
- self.target = target
868
- end
869
- function Mana.prototype.UseRegenTimer(self)
870
- if self.unit ~= "player" then
871
- error("Mana.UseRegenTimer: only the player is supported")
872
- end
873
- if self.regenTimer == nil then
874
- self:AddEvents("UNIT_SPELLCAST_SUCCEEDED")
875
- self.regenTimer = UseSource(
876
- nil,
877
- ManaRegenTimer,
878
- function(____, listener) return self:Observe(listener) end
879
- )
880
- end
881
- return self
882
- end
883
- __TS__SetDescriptor(
884
- Mana.prototype,
885
- "RegenTimer",
886
- {get = function(self)
887
- return self.regenTimer
888
- end},
889
- true
890
- )
891
- __TS__SetDescriptor(
892
- Mana.prototype,
893
- "unit",
894
- {get = function(self)
895
- return self.target.Token
896
- end},
897
- true
898
- );
899
- (function(self)
900
- registerSource(
901
- nil,
902
- ____exports.Mana,
903
- function(____, props) return __TS__New(____exports.Mana, props[1]) end
904
- )
905
- end)(Mana)
906
- ____exports.DataSources = {Resources = {HP = ____exports.HP, Mana = ____exports.Mana}}
907
- return ____exports