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,650 +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 __TS__Unpack = table.unpack or unpack
314
-
315
- local function __TS__NumberIsFinite(value)
316
- return type(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge
317
- end
318
-
319
- local function __TS__CloneDescriptor(____bindingPattern0)
320
- local value
321
- local writable
322
- local set
323
- local get
324
- local configurable
325
- local enumerable
326
- enumerable = ____bindingPattern0.enumerable
327
- configurable = ____bindingPattern0.configurable
328
- get = ____bindingPattern0.get
329
- set = ____bindingPattern0.set
330
- writable = ____bindingPattern0.writable
331
- value = ____bindingPattern0.value
332
- local descriptor = {enumerable = enumerable == true, configurable = configurable == true}
333
- local hasGetterOrSetter = get ~= nil or set ~= nil
334
- local hasValueOrWritableAttribute = writable ~= nil or value ~= nil
335
- if hasGetterOrSetter and hasValueOrWritableAttribute then
336
- error("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute.", 0)
337
- end
338
- if get or set then
339
- descriptor.get = get
340
- descriptor.set = set
341
- else
342
- descriptor.value = value
343
- descriptor.writable = writable == true
344
- end
345
- return descriptor
346
- end
347
-
348
- local __TS__DescriptorGet
349
- do
350
- local getmetatable = _G.getmetatable
351
- local ____rawget = _G.rawget
352
- function __TS__DescriptorGet(self, metatable, key)
353
- while metatable do
354
- local rawResult = ____rawget(metatable, key)
355
- if rawResult ~= nil then
356
- return rawResult
357
- end
358
- local descriptors = ____rawget(metatable, "_descriptors")
359
- if descriptors then
360
- local descriptor = descriptors[key]
361
- if descriptor ~= nil then
362
- if descriptor.get then
363
- return descriptor.get(self)
364
- end
365
- return descriptor.value
366
- end
367
- end
368
- metatable = getmetatable(metatable)
369
- end
370
- end
371
- end
372
-
373
- local __TS__DescriptorSet
374
- do
375
- local getmetatable = _G.getmetatable
376
- local ____rawget = _G.rawget
377
- local rawset = _G.rawset
378
- function __TS__DescriptorSet(self, metatable, key, value)
379
- while metatable do
380
- local descriptors = ____rawget(metatable, "_descriptors")
381
- if descriptors then
382
- local descriptor = descriptors[key]
383
- if descriptor ~= nil then
384
- if descriptor.set then
385
- descriptor.set(self, value)
386
- else
387
- if descriptor.writable == false then
388
- error(
389
- ((("Cannot assign to read only property '" .. key) .. "' of object '") .. tostring(self)) .. "'",
390
- 0
391
- )
392
- end
393
- descriptor.value = value
394
- end
395
- return
396
- end
397
- end
398
- metatable = getmetatable(metatable)
399
- end
400
- rawset(self, key, value)
401
- end
402
- end
403
-
404
- local __TS__SetDescriptor
405
- do
406
- local getmetatable = _G.getmetatable
407
- local function descriptorIndex(self, key)
408
- return __TS__DescriptorGet(
409
- self,
410
- getmetatable(self),
411
- key
412
- )
413
- end
414
- local function descriptorNewIndex(self, key, value)
415
- return __TS__DescriptorSet(
416
- self,
417
- getmetatable(self),
418
- key,
419
- value
420
- )
421
- end
422
- function __TS__SetDescriptor(target, key, desc, isPrototype)
423
- if isPrototype == nil then
424
- isPrototype = false
425
- end
426
- local ____isPrototype_0
427
- if isPrototype then
428
- ____isPrototype_0 = target
429
- else
430
- ____isPrototype_0 = getmetatable(target)
431
- end
432
- local metatable = ____isPrototype_0
433
- if not metatable then
434
- metatable = {}
435
- setmetatable(target, metatable)
436
- end
437
- if not isPrototype and not rawget(metatable, "_isOwnDescriptorMetatable") then
438
- local instanceMetatable = {}
439
- instanceMetatable._isOwnDescriptorMetatable = true
440
- setmetatable(instanceMetatable, metatable)
441
- setmetatable(target, instanceMetatable)
442
- metatable = instanceMetatable
443
- end
444
- local value = rawget(target, key)
445
- if value ~= nil then
446
- rawset(target, key, nil)
447
- end
448
- if not rawget(metatable, "_descriptors") then
449
- metatable._descriptors = {}
450
- end
451
- metatable._descriptors[key] = __TS__CloneDescriptor(desc)
452
- metatable.__index = descriptorIndex
453
- metatable.__newindex = descriptorNewIndex
454
- end
455
- end
456
- -- End of Lua Library inline imports
457
- local ____exports = {}
458
- local ____ProgressSource = require("datasources.ProgressSource")
459
- local ProgressSource = ____ProgressSource.ProgressSource
460
- local ____Source = require("datasources.Source")
461
- local registerSource = ____Source.registerSource
462
- ____exports.SwingHand = {MainHand = "MainHand", OffHand = "OffHand", Ranged = "Ranged"}
463
- --- Player-only countdown driven by Forever's native PLAYER_SWING event.
464
- ____exports.SwingTimer = __TS__Class()
465
- local SwingTimer = ____exports.SwingTimer
466
- SwingTimer.name = "SwingTimer"
467
- __TS__ClassExtends(SwingTimer, ProgressSource)
468
- function SwingTimer.prototype.____constructor(self, hand)
469
- if hand == nil then
470
- hand = ____exports.SwingHand.MainHand
471
- end
472
- ProgressSource.prototype.____constructor(
473
- self,
474
- {
475
- current = function() return self:Remaining() end,
476
- min = function() return 0 end,
477
- max = function() return self.duration end,
478
- percent = function() return self.duration > 0 and self:Remaining() / self.duration * 100 or 0 end
479
- }
480
- )
481
- self.hand = hand
482
- self.duration = 0
483
- self.endTime = 0
484
- self.known = false
485
- self.restricted = false
486
- self.bindings = __TS__New(Set)
487
- self:Start()
488
- end
489
- function SwingTimer.prototype.HasSecretFields(self)
490
- return self.restricted
491
- end
492
- function SwingTimer.prototype.Remaining(self)
493
- return self.known and math.max(
494
- 0,
495
- self.endTime - GetTime()
496
- ) or 0
497
- end
498
- function SwingTimer.prototype.Start(self)
499
- if self.events ~= nil then
500
- return
501
- end
502
- if C_SwingTimer == nil or (Enum and Enum.PlayerSwingType) == nil then
503
- error("SwingTimer: this client does not expose the Forever swing API")
504
- end
505
- local swingType = Enum.PlayerSwingType[self.hand]
506
- if swingType == nil then
507
- error("SwingTimer: unsupported swing hand")
508
- end
509
- local events = CreateFrame("Frame", nil, UIParent)
510
- self.events = events
511
- events:RegisterEvent("PLAYER_SWING")
512
- events:RegisterEvent("PLAYER_ENTERING_WORLD")
513
- events:RegisterEvent("WEAPON_SLOT_CHANGED")
514
- events:SetScript(
515
- "OnEvent",
516
- function(_frame, event, ...)
517
- local payload = {...}
518
- if event ~= "PLAYER_SWING" then
519
- self:Reset()
520
- return
521
- end
522
- local duration, hand = __TS__Unpack(payload)
523
- if issecretvalue(hand) then
524
- self:Reset(true)
525
- return
526
- end
527
- if hand ~= swingType then
528
- return
529
- end
530
- if issecretvalue(duration) then
531
- self:Reset(true)
532
- return
533
- end
534
- if type(duration) ~= "number" or not __TS__NumberIsFinite(duration) or duration <= 0 then
535
- self:Reset()
536
- return
537
- end
538
- self.duration = duration
539
- self.endTime = GetTime() + duration
540
- self.known = true
541
- self.restricted = false
542
- self:Notify()
543
- end
544
- )
545
- end
546
- function SwingTimer.prototype.Reset(self, restricted)
547
- if restricted == nil then
548
- restricted = false
549
- end
550
- self.duration = 0
551
- self.endTime = 0
552
- self.known = false
553
- self.restricted = restricted
554
- self:Notify()
555
- end
556
- function SwingTimer.prototype.Notify(self)
557
- for ____, refresh in __TS__Iterator(self.bindings) do
558
- refresh(nil)
559
- end
560
- end
561
- function SwingTimer.prototype.BindTo(self, frame, options)
562
- if options == nil then
563
- options = {}
564
- end
565
- if options.min ~= nil or options.max ~= nil or options.current ~= nil then
566
- error("SwingTimer: native timer binding does not support min/max/current overrides")
567
- end
568
- local bar = frame
569
- local ____opt_2 = Enum and Enum.StatusBarInterpolation
570
- local interpolation = ____opt_2 and ____opt_2.Immediate
571
- local ____opt_6 = Enum and Enum.StatusBarTimerDirection
572
- local direction = ____opt_6 and ____opt_6.RemainingTime
573
- if bar.SetTimerDuration == nil or C_DurationUtil == nil or interpolation == nil or direction == nil then
574
- error("SwingTimer: native StatusBar timer support is unavailable")
575
- end
576
- self:Start()
577
- local timer = C_DurationUtil.CreateDuration()
578
- bar:SetMinMaxValues(0, 1)
579
- local function refresh()
580
- local active = self:CanEmit(self:Remaining())
581
- local ____this_11
582
- ____this_11 = options
583
- local ____opt_10 = ____this_11.onActiveChange
584
- if ____opt_10 ~= nil then
585
- ____opt_10(____this_11, active)
586
- end
587
- if not active then
588
- return
589
- end
590
- if self.HasTiming and self:Remaining() > 0 then
591
- timer:SetTimeFromStart(self.endTime - self.duration, self.duration)
592
- bar:SetTimerDuration(timer, interpolation, direction)
593
- else
594
- timer:SetTimeFromStart(
595
- GetTime() - 1,
596
- 1
597
- )
598
- bar:SetTimerDuration(timer, interpolation, direction)
599
- bar:SetValue(0)
600
- end
601
- end
602
- self.bindings:add(refresh)
603
- refresh(nil)
604
- return function()
605
- self.bindings:delete(refresh)
606
- end
607
- end
608
- function SwingTimer.prototype.Listen(self)
609
- end
610
- function SwingTimer.prototype.Dispose(self)
611
- self:Reset()
612
- self.bindings:clear()
613
- local ____opt_12 = self.events
614
- if ____opt_12 ~= nil then
615
- ____opt_12:UnregisterAllEvents()
616
- end
617
- local ____opt_14 = self.events
618
- if ____opt_14 ~= nil then
619
- ____opt_14:SetScript("OnEvent", nil)
620
- end
621
- local ____opt_16 = self.events
622
- if ____opt_16 ~= nil then
623
- ____opt_16:Hide()
624
- end
625
- self.events = nil
626
- end;
627
- (function(self)
628
- registerSource(
629
- nil,
630
- ____exports.SwingTimer,
631
- function(____, props) return __TS__New(____exports.SwingTimer, props[1]) end
632
- )
633
- end)(SwingTimer)
634
- __TS__SetDescriptor(
635
- SwingTimer.prototype,
636
- "HasTiming",
637
- {get = function(self)
638
- return self.known and not self.restricted
639
- end},
640
- true
641
- )
642
- __TS__SetDescriptor(
643
- SwingTimer.prototype,
644
- "IsActive",
645
- {get = function(self)
646
- return self.HasTiming and self:Remaining() > 0
647
- end},
648
- true
649
- )
650
- return ____exports
@@ -1,10 +0,0 @@
1
- import { TimerSource } from "./TimerSource";
2
- export type TotemTimerStatus = "active" | "inactive" | "restricted" | "unavailable";
3
- /** Player-owned ground effects exposed by the game's totem API, across spell ranks. */
4
- export declare class TotemTimer extends TimerSource {
5
- readonly spell: number | string;
6
- private status;
7
- protected constructor(spell: number | string);
8
- get Status(): TotemTimerStatus;
9
- private ReadDuration;
10
- }