wuira 0.1.5 → 0.1.7

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 (63) hide show
  1. package/CHANGELOG.md +70 -1
  2. package/README.md +242 -0
  3. package/lib/Spells.d.ts +11 -0
  4. package/lib/Spells.lua +22 -0
  5. package/lib/datasources/KnownSpells.d.ts +21 -0
  6. package/lib/datasources/KnownSpells.lua +794 -0
  7. package/lib/datasources/ManaRegenTimer.d.ts +29 -0
  8. package/lib/datasources/ManaRegenTimer.lua +674 -0
  9. package/lib/datasources/ProgressSource.lua +15 -2
  10. package/lib/datasources/Resources.d.ts +13 -1
  11. package/lib/datasources/Resources.lua +118 -39
  12. package/lib/datasources/SpellCooldown.d.ts +4 -2
  13. package/lib/datasources/SpellCooldown.lua +13 -2
  14. package/lib/datasources/SpellSource.d.ts +14 -0
  15. package/lib/datasources/SpellSource.lua +224 -0
  16. package/lib/datasources/TimerSource.d.ts +2 -0
  17. package/lib/datasources/TimerSource.lua +54 -0
  18. package/lib/datasources/TotemTimer.d.ts +10 -0
  19. package/lib/datasources/TotemTimer.lua +260 -0
  20. package/lib/datasources/index.d.ts +7 -0
  21. package/lib/datasources/index.lua +16 -0
  22. package/lib/index.d.ts +8 -0
  23. package/lib/index.lua +16 -0
  24. package/lib/platform/ActionBars.d.ts +27 -0
  25. package/lib/platform/ActionBars.lua +726 -0
  26. package/lib/platform/AddonSettings.d.ts +9 -0
  27. package/lib/platform/AddonSettings.lua +36 -0
  28. package/lib/platform/BlizzardUI.d.ts +5 -0
  29. package/lib/platform/BlizzardUI.lua +357 -20
  30. package/lib/platform/MicroMenu.d.ts +15 -0
  31. package/lib/platform/MicroMenu.lua +219 -0
  32. package/lib/platform/SecureButton.d.ts +5 -0
  33. package/lib/platform/SecureButton.lua +196 -0
  34. package/lib/platform/SlashCommands.d.ts +3 -0
  35. package/lib/platform/SlashCommands.lua +309 -0
  36. package/lib/platform/forever.d.ts +78 -3
  37. package/lib/skins/MicroBar.d.ts +8 -0
  38. package/lib/skins/MicroBar.lua +65 -0
  39. package/lib/skins/NativeSkin.d.ts +26 -0
  40. package/lib/skins/NativeSkin.lua +601 -0
  41. package/lib/skins/index.d.ts +3 -0
  42. package/lib/skins/index.lua +11 -0
  43. package/lib/store/index.lua +13 -0
  44. package/lib/ui/Button.d.ts +10 -0
  45. package/lib/ui/Button.lua +9 -0
  46. package/lib/ui/Cell.d.ts +5 -1
  47. package/lib/ui/FrameMover.d.ts +21 -0
  48. package/lib/ui/FrameMover.lua +123 -0
  49. package/lib/ui/HoverTracker.d.ts +20 -0
  50. package/lib/ui/HoverTracker.lua +88 -0
  51. package/lib/ui/KeybindCapture.d.ts +20 -0
  52. package/lib/ui/KeybindCapture.lua +488 -0
  53. package/lib/ui/SecureButton.d.ts +44 -0
  54. package/lib/ui/SecureButton.lua +9 -0
  55. package/lib/ui/index.d.ts +9 -0
  56. package/lib/ui/index.lua +20 -0
  57. package/lib/ui/layout/measureLayout.lua +4 -2
  58. package/lib/ui/mount.lua +500 -117
  59. package/lib/ui/primitives/jsx.d.ts +9 -1
  60. package/lib/wuira.d.ts +3 -0
  61. package/lib/wuira.lua +5 -0
  62. package/package.json +8 -1
  63. package/tools/build-library.mjs +1 -1
@@ -66,7 +66,7 @@ function ProgressSource.prototype.BindTo(self, frame, options)
66
66
  options = {}
67
67
  end
68
68
  local function refresh()
69
- local sourceValue = self.readers:current()
69
+ local sourceValue = self:GetValue()
70
70
  local active = self:CanEmit(sourceValue)
71
71
  local ____this_1
72
72
  ____this_1 = options
@@ -91,7 +91,20 @@ function ProgressSource.prototype.BindTo(self, frame, options)
91
91
  end
92
92
  end
93
93
  local dispose = self:Listen(frame, refresh)
94
- refresh(nil)
94
+ do
95
+ local function ____catch(failure)
96
+ if dispose ~= nil then
97
+ dispose(nil)
98
+ end
99
+ error(failure, 0)
100
+ end
101
+ local ____try, ____hasReturned = pcall(function()
102
+ refresh(nil)
103
+ end)
104
+ if not ____try then
105
+ ____catch(____hasReturned)
106
+ end
107
+ end
95
108
  return dispose
96
109
  end
97
110
  return ____exports
@@ -3,15 +3,24 @@ import { UnitSource } from "./UnitSource";
3
3
  import type { UnitInput } from "./UnitSource";
4
4
  import { DataSource } from "./DataSource";
5
5
  import type { ProgressOverrides } from "./ProgressSource";
6
+ import { ManaRegenTimer } from "./ManaRegenTimer";
6
7
  export { Unit } from "./UnitSource";
7
8
  /** Direct API-to-widget binding; opaque values are never compared or calculated. */
8
9
  declare abstract class Resource extends ProgressSource {
9
10
  private readonly unitToken;
10
11
  private readonly events;
11
12
  private readonly listeners;
13
+ private eventFrame?;
14
+ private dispatching;
15
+ private eventValue;
12
16
  protected constructor(current: () => number, maximum: () => number, percent: () => number, unitToken: string, events: string[]);
13
17
  protected AddEvents(...events: string[]): void;
14
- protected Listen(frame: wuiraNativeFrame, refresh: () => void): () => void;
18
+ protected GetValue(): number;
19
+ /** Future readable value changes only. Unsubscribe when the consumer is removed. */
20
+ onChange(listener: (value: number) => void): () => void;
21
+ /** One native event frame is shared by widgets, observers, and accessories. */
22
+ protected Observe(listener: (event: string, payload: unknown[], value: number) => void): () => void;
23
+ protected Listen(_frame: wuiraNativeFrame, refresh: () => void): () => void;
15
24
  }
16
25
  /** Live optional prediction channel. Secret amounts only travel to native sinks. */
17
26
  export declare class HealthPrediction extends DataSource<number> {
@@ -35,6 +44,9 @@ export declare class HP extends Resource {
35
44
  }
36
45
  /** Explicit mana (power type 0), even while the unit uses rage/energy. */
37
46
  export declare class Mana extends Resource {
47
+ private regenTimer?;
48
+ get RegenTimer(): ManaRegenTimer | undefined;
49
+ UseRegenTimer(): this;
38
50
  readonly target: UnitSource;
39
51
  get unit(): string;
40
52
  constructor(unit: UnitInput);
@@ -489,6 +489,8 @@ local Unit = ____UnitSource.Unit
489
489
  local resolveUnit = ____UnitSource.resolveUnit
490
490
  local ____DataSource = require("datasources.DataSource")
491
491
  local DataSource = ____DataSource.DataSource
492
+ local ____ManaRegenTimer = require("datasources.ManaRegenTimer")
493
+ local ManaRegenTimer = ____ManaRegenTimer.ManaRegenTimer
492
494
  do
493
495
  local ____UnitSource = require("datasources.UnitSource")
494
496
  ____exports.Unit = ____UnitSource.Unit
@@ -510,6 +512,8 @@ function Resource.prototype.____constructor(self, current, maximum, percent, uni
510
512
  self.unitToken = unitToken
511
513
  self.events = events
512
514
  self.listeners = __TS__New(Set)
515
+ self.dispatching = false
516
+ self.eventValue = 0
513
517
  end
514
518
  function Resource.prototype.AddEvents(self, ...)
515
519
  local events = {...}
@@ -523,8 +527,11 @@ function Resource.prototype.AddEvents(self, ...)
523
527
  end
524
528
  local ____self_events_0 = self.events
525
529
  ____self_events_0[#____self_events_0 + 1] = event
526
- for ____, frame in __TS__Iterator(self.listeners) do
527
- frame:RegisterEvent(event)
530
+ if self.listeners.size > 0 then
531
+ local ____opt_1 = self.eventFrame
532
+ if ____opt_1 ~= nil then
533
+ ____opt_1:RegisterEvent(event)
534
+ end
528
535
  end
529
536
  __continue5 = true
530
537
  until true
@@ -534,26 +541,77 @@ function Resource.prototype.AddEvents(self, ...)
534
541
  end
535
542
  end
536
543
  end
537
- function Resource.prototype.Listen(self, frame, refresh)
538
- self.listeners:add(frame)
539
- frame:SetScript(
540
- "OnEvent",
541
- function(_frame, event, unit)
542
- if event == "PLAYER_ENTERING_WORLD" or unit == self.unitToken then
543
- refresh(nil)
544
+ function Resource.prototype.GetValue(self)
545
+ return self.dispatching and self.eventValue or ProgressSource.prototype.GetValue(self)
546
+ end
547
+ function Resource.prototype.onChange(self, listener)
548
+ local previous = self:GetValue()
549
+ local readable = not issecretvalue(previous)
550
+ return self:Observe(function(____, _, _payload, value)
551
+ if issecretvalue(value) or not self:CanEmit(value) then
552
+ return
553
+ end
554
+ if readable and value == previous then
555
+ return
556
+ end
557
+ previous = value
558
+ readable = true
559
+ listener(nil, value)
560
+ end)
561
+ end
562
+ function Resource.prototype.Observe(self, listener)
563
+ self.listeners:add(listener)
564
+ if self.listeners.size == 1 then
565
+ if self.eventFrame == nil then
566
+ self.eventFrame = CreateFrame("Frame", nil, UIParent)
567
+ end
568
+ local frame = self.eventFrame
569
+ frame:SetScript(
570
+ "OnEvent",
571
+ function(_frame, event, ...)
572
+ local payload = {...}
573
+ if event ~= "PLAYER_ENTERING_WORLD" and (issecretvalue(payload[1]) or payload[1] ~= self.unitToken) then
574
+ return
575
+ end
576
+ self.eventValue = ProgressSource.prototype.GetValue(self)
577
+ self.dispatching = true
578
+ do
579
+ local ____try, ____error = pcall(function()
580
+ for ____, callback in __TS__Iterator(self.listeners) do
581
+ callback(nil, event, payload, self.eventValue)
582
+ end
583
+ end)
584
+ do
585
+ self.dispatching = false
586
+ end
587
+ if not ____try then
588
+ error(____error, 0)
589
+ end
590
+ end
544
591
  end
592
+ )
593
+ frame:RegisterEvent("PLAYER_ENTERING_WORLD")
594
+ for ____, event in ipairs(self.events) do
595
+ frame:RegisterEvent(event)
545
596
  end
546
- )
547
- frame:RegisterEvent("PLAYER_ENTERING_WORLD")
548
- for ____, event in ipairs(self.events) do
549
- frame:RegisterEvent(event)
550
597
  end
551
598
  return function()
552
- self.listeners:delete(frame)
553
- frame:UnregisterAllEvents()
554
- frame:SetScript("OnEvent", nil)
599
+ self.listeners:delete(listener)
600
+ if self.listeners.size == 0 then
601
+ local ____opt_3 = self.eventFrame
602
+ if ____opt_3 ~= nil then
603
+ ____opt_3:UnregisterAllEvents()
604
+ end
605
+ local ____opt_5 = self.eventFrame
606
+ if ____opt_5 ~= nil then
607
+ ____opt_5:SetScript("OnEvent", nil)
608
+ end
609
+ end
555
610
  end
556
611
  end
612
+ function Resource.prototype.Listen(self, _frame, refresh)
613
+ return self:Observe(function() return refresh(nil) end)
614
+ end
557
615
  --- Live optional prediction channel. Secret amounts only travel to native sinks.
558
616
  ____exports.HealthPrediction = __TS__Class()
559
617
  local HealthPrediction = ____exports.HealthPrediction
@@ -564,8 +622,8 @@ function HealthPrediction.prototype.____constructor(self, read)
564
622
  self.read = read
565
623
  end
566
624
  function HealthPrediction.prototype.GetValue(self)
567
- local ____opt_1 = self.read
568
- local value = ____opt_1 and ____opt_1(self)
625
+ local ____opt_7 = self.read
626
+ local value = ____opt_7 and ____opt_7(self)
569
627
  if issecretvalue(value) then
570
628
  return value
571
629
  end
@@ -614,14 +672,14 @@ function HP.prototype.____constructor(self, unit)
614
672
  end
615
673
  function HP.prototype.UseHealPrediction(self)
616
674
  if self.healPrediction == nil then
617
- local ____exports_HealthPrediction_4 = ____exports.HealthPrediction
618
- local ____temp_3
675
+ local ____exports_HealthPrediction_10 = ____exports.HealthPrediction
676
+ local ____temp_9
619
677
  if UnitGetIncomingHeals == nil then
620
- ____temp_3 = nil
678
+ ____temp_9 = nil
621
679
  else
622
- ____temp_3 = function() return UnitGetIncomingHeals(self.unit) end
680
+ ____temp_9 = function() return UnitGetIncomingHeals(self.unit) end
623
681
  end
624
- self.healPrediction = __TS__New(____exports_HealthPrediction_4, ____temp_3)
682
+ self.healPrediction = __TS__New(____exports_HealthPrediction_10, ____temp_9)
625
683
  if self.healPrediction.IsAvailable then
626
684
  self:AddEvents("UNIT_HEAL_PREDICTION")
627
685
  end
@@ -630,14 +688,14 @@ function HP.prototype.UseHealPrediction(self)
630
688
  end
631
689
  function HP.prototype.UseAbsorbPrediction(self)
632
690
  if self.absorbPrediction == nil then
633
- local ____exports_HealthPrediction_6 = ____exports.HealthPrediction
634
- local ____temp_5
691
+ local ____exports_HealthPrediction_12 = ____exports.HealthPrediction
692
+ local ____temp_11
635
693
  if UnitGetTotalAbsorbs == nil then
636
- ____temp_5 = nil
694
+ ____temp_11 = nil
637
695
  else
638
- ____temp_5 = function() return UnitGetTotalAbsorbs(self.unit) end
696
+ ____temp_11 = function() return UnitGetTotalAbsorbs(self.unit) end
639
697
  end
640
- self.absorbPrediction = __TS__New(____exports_HealthPrediction_6, ____temp_5)
698
+ self.absorbPrediction = __TS__New(____exports_HealthPrediction_12, ____temp_11)
641
699
  if self.absorbPrediction.IsAvailable then
642
700
  self:AddEvents("UNIT_ABSORB_AMOUNT_CHANGED")
643
701
  end
@@ -661,23 +719,23 @@ function HP.prototype.BindTo(self, frame, options)
661
719
  if options.healPredictionBar ~= nil or options.absorbPredictionBar ~= nil then
662
720
  local maximum = UnitHealthMax(self.unit)
663
721
  if options.healPredictionBar ~= nil then
664
- local ____opt_7 = self.healPrediction
665
- if ____opt_7 ~= nil then
666
- ____opt_7:ApplyTo(options.healPredictionBar, maximum)
722
+ local ____opt_13 = self.healPrediction
723
+ if ____opt_13 ~= nil then
724
+ ____opt_13:ApplyTo(options.healPredictionBar, maximum)
667
725
  end
668
726
  end
669
727
  if options.absorbPredictionBar ~= nil then
670
- local ____opt_9 = self.absorbPrediction
671
- if ____opt_9 ~= nil then
672
- ____opt_9:ApplyTo(options.absorbPredictionBar, maximum)
728
+ local ____opt_15 = self.absorbPrediction
729
+ if ____opt_15 ~= nil then
730
+ ____opt_15:ApplyTo(options.absorbPredictionBar, maximum)
673
731
  end
674
732
  end
675
733
  end
676
- local ____this_12
677
- ____this_12 = options
678
- local ____opt_11 = ____this_12.onRefresh
679
- if ____opt_11 ~= nil then
680
- ____opt_11(____this_12)
734
+ local ____this_18
735
+ ____this_18 = options
736
+ local ____opt_17 = ____this_18.onRefresh
737
+ if ____opt_17 ~= nil then
738
+ ____opt_17(____this_18)
681
739
  end
682
740
  end}
683
741
  )
@@ -724,6 +782,27 @@ function Mana.prototype.____constructor(self, unit)
724
782
  )
725
783
  self.target = target
726
784
  end
785
+ function Mana.prototype.UseRegenTimer(self)
786
+ if self.unit ~= "player" then
787
+ error("Mana.UseRegenTimer: only the player is supported")
788
+ end
789
+ if self.regenTimer == nil then
790
+ self:AddEvents("UNIT_SPELLCAST_SUCCEEDED")
791
+ self.regenTimer = __TS__New(
792
+ ManaRegenTimer,
793
+ function(____, listener) return self:Observe(listener) end
794
+ )
795
+ end
796
+ return self
797
+ end
798
+ __TS__SetDescriptor(
799
+ Mana.prototype,
800
+ "RegenTimer",
801
+ {get = function(self)
802
+ return self.regenTimer
803
+ end},
804
+ true
805
+ )
727
806
  __TS__SetDescriptor(
728
807
  Mana.prototype,
729
808
  "unit",
@@ -1,8 +1,10 @@
1
1
  import { TimerSource } from "./TimerSource";
2
2
  /** Native cooldown duration, including opaque timings during combat. */
3
3
  export declare class SpellCooldown extends TimerSource {
4
- readonly spellId: number;
5
- constructor(spellId: number);
4
+ readonly spellId: number | string;
5
+ constructor(spellId: number | string, options?: {
6
+ ignoreGCD?: boolean;
7
+ });
6
8
  get IsAvailable(): boolean;
7
9
  }
8
10
  export declare class GlobalCooldown extends SpellCooldown {
@@ -178,12 +178,23 @@ ____exports.SpellCooldown = __TS__Class()
178
178
  local SpellCooldown = ____exports.SpellCooldown
179
179
  SpellCooldown.name = "SpellCooldown"
180
180
  __TS__ClassExtends(SpellCooldown, TimerSource)
181
- function SpellCooldown.prototype.____constructor(self, spellId)
181
+ function SpellCooldown.prototype.____constructor(self, spellId, options)
182
+ if options == nil then
183
+ options = {}
184
+ end
182
185
  TimerSource.prototype.____constructor(
183
186
  self,
184
187
  function()
185
188
  local ____opt_0 = C_Spell and C_Spell.GetSpellCooldownDuration
186
- return ____opt_0 and ____opt_0(spellId)
189
+ if ____opt_0 ~= nil then
190
+ local ____spellId_2 = spellId
191
+ local ____options_ignoreGCD_1 = options.ignoreGCD
192
+ if ____options_ignoreGCD_1 == nil then
193
+ ____options_ignoreGCD_1 = false
194
+ end
195
+ ____opt_0 = ____opt_0(____spellId_2, ____options_ignoreGCD_1)
196
+ end
197
+ return ____opt_0
187
198
  end,
188
199
  {"SPELL_UPDATE_COOLDOWN", "PLAYER_ENTERING_WORLD", "SPELLS_CHANGED"}
189
200
  )
@@ -0,0 +1,14 @@
1
+ import { DataSource } from "./DataSource";
2
+ import { TextureSource } from "./TextureSource";
3
+ import { SpellCooldown } from "./SpellCooldown";
4
+ import type { SecureAction } from "../ui/SecureButton";
5
+ /** Localized spell identity, texture and native cooldown, independent of action slots. */
6
+ export declare class SpellSource extends DataSource<string | undefined> {
7
+ readonly spellId: number;
8
+ readonly Texture: TextureSource;
9
+ readonly Cooldown: SpellCooldown;
10
+ constructor(spellId: number);
11
+ protected GetValue(): string | undefined;
12
+ get Identifier(): number | string;
13
+ get Action(): SecureAction;
14
+ }
@@ -0,0 +1,224 @@
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__New(target, ...)
36
+ local instance = setmetatable({}, target.prototype)
37
+ instance:____constructor(...)
38
+ return instance
39
+ end
40
+
41
+ local function __TS__CloneDescriptor(____bindingPattern0)
42
+ local value
43
+ local writable
44
+ local set
45
+ local get
46
+ local configurable
47
+ local enumerable
48
+ enumerable = ____bindingPattern0.enumerable
49
+ configurable = ____bindingPattern0.configurable
50
+ get = ____bindingPattern0.get
51
+ set = ____bindingPattern0.set
52
+ writable = ____bindingPattern0.writable
53
+ value = ____bindingPattern0.value
54
+ local descriptor = {enumerable = enumerable == true, configurable = configurable == true}
55
+ local hasGetterOrSetter = get ~= nil or set ~= nil
56
+ local hasValueOrWritableAttribute = writable ~= nil or value ~= nil
57
+ if hasGetterOrSetter and hasValueOrWritableAttribute then
58
+ error("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute.", 0)
59
+ end
60
+ if get or set then
61
+ descriptor.get = get
62
+ descriptor.set = set
63
+ else
64
+ descriptor.value = value
65
+ descriptor.writable = writable == true
66
+ end
67
+ return descriptor
68
+ end
69
+
70
+ local __TS__DescriptorGet
71
+ do
72
+ local getmetatable = _G.getmetatable
73
+ local ____rawget = _G.rawget
74
+ function __TS__DescriptorGet(self, metatable, key)
75
+ while metatable do
76
+ local rawResult = ____rawget(metatable, key)
77
+ if rawResult ~= nil then
78
+ return rawResult
79
+ end
80
+ local descriptors = ____rawget(metatable, "_descriptors")
81
+ if descriptors then
82
+ local descriptor = descriptors[key]
83
+ if descriptor ~= nil then
84
+ if descriptor.get then
85
+ return descriptor.get(self)
86
+ end
87
+ return descriptor.value
88
+ end
89
+ end
90
+ metatable = getmetatable(metatable)
91
+ end
92
+ end
93
+ end
94
+
95
+ local __TS__DescriptorSet
96
+ do
97
+ local getmetatable = _G.getmetatable
98
+ local ____rawget = _G.rawget
99
+ local rawset = _G.rawset
100
+ function __TS__DescriptorSet(self, metatable, key, value)
101
+ while metatable do
102
+ local descriptors = ____rawget(metatable, "_descriptors")
103
+ if descriptors then
104
+ local descriptor = descriptors[key]
105
+ if descriptor ~= nil then
106
+ if descriptor.set then
107
+ descriptor.set(self, value)
108
+ else
109
+ if descriptor.writable == false then
110
+ error(
111
+ ((("Cannot assign to read only property '" .. key) .. "' of object '") .. tostring(self)) .. "'",
112
+ 0
113
+ )
114
+ end
115
+ descriptor.value = value
116
+ end
117
+ return
118
+ end
119
+ end
120
+ metatable = getmetatable(metatable)
121
+ end
122
+ rawset(self, key, value)
123
+ end
124
+ end
125
+
126
+ local __TS__SetDescriptor
127
+ do
128
+ local getmetatable = _G.getmetatable
129
+ local function descriptorIndex(self, key)
130
+ return __TS__DescriptorGet(
131
+ self,
132
+ getmetatable(self),
133
+ key
134
+ )
135
+ end
136
+ local function descriptorNewIndex(self, key, value)
137
+ return __TS__DescriptorSet(
138
+ self,
139
+ getmetatable(self),
140
+ key,
141
+ value
142
+ )
143
+ end
144
+ function __TS__SetDescriptor(target, key, desc, isPrototype)
145
+ if isPrototype == nil then
146
+ isPrototype = false
147
+ end
148
+ local ____isPrototype_0
149
+ if isPrototype then
150
+ ____isPrototype_0 = target
151
+ else
152
+ ____isPrototype_0 = getmetatable(target)
153
+ end
154
+ local metatable = ____isPrototype_0
155
+ if not metatable then
156
+ metatable = {}
157
+ setmetatable(target, metatable)
158
+ end
159
+ if not isPrototype and not rawget(metatable, "_isOwnDescriptorMetatable") then
160
+ local instanceMetatable = {}
161
+ instanceMetatable._isOwnDescriptorMetatable = true
162
+ setmetatable(instanceMetatable, metatable)
163
+ setmetatable(target, instanceMetatable)
164
+ metatable = instanceMetatable
165
+ end
166
+ local value = rawget(target, key)
167
+ if value ~= nil then
168
+ rawset(target, key, nil)
169
+ end
170
+ if not rawget(metatable, "_descriptors") then
171
+ metatable._descriptors = {}
172
+ end
173
+ metatable._descriptors[key] = __TS__CloneDescriptor(desc)
174
+ metatable.__index = descriptorIndex
175
+ metatable.__newindex = descriptorNewIndex
176
+ end
177
+ end
178
+ -- End of Lua Library inline imports
179
+ local ____exports = {}
180
+ local ____DataSource = require("datasources.DataSource")
181
+ local DataSource = ____DataSource.DataSource
182
+ local ____TextureSource = require("datasources.TextureSource")
183
+ local TextureSource = ____TextureSource.TextureSource
184
+ local ____SpellCooldown = require("datasources.SpellCooldown")
185
+ local SpellCooldown = ____SpellCooldown.SpellCooldown
186
+ --- Localized spell identity, texture and native cooldown, independent of action slots.
187
+ ____exports.SpellSource = __TS__Class()
188
+ local SpellSource = ____exports.SpellSource
189
+ SpellSource.name = "SpellSource"
190
+ __TS__ClassExtends(SpellSource, DataSource)
191
+ function SpellSource.prototype.____constructor(self, spellId)
192
+ DataSource.prototype.____constructor(self, nil)
193
+ self.spellId = spellId
194
+ self.Texture = __TS__New(
195
+ TextureSource,
196
+ function()
197
+ local ____opt_0 = C_Spell and C_Spell.GetSpellTexture
198
+ return ____opt_0 and ____opt_0(spellId)
199
+ end,
200
+ {"SPELLS_CHANGED", "PLAYER_ENTERING_WORLD"}
201
+ )
202
+ self.Cooldown = __TS__New(SpellCooldown, self.Identifier, {ignoreGCD = true})
203
+ end
204
+ function SpellSource.prototype.GetValue(self)
205
+ local ____opt_4 = C_Spell and C_Spell.GetSpellName
206
+ return ____opt_4 and ____opt_4(self.spellId)
207
+ end
208
+ __TS__SetDescriptor(
209
+ SpellSource.prototype,
210
+ "Identifier",
211
+ {get = function(self)
212
+ return self.Value or self.spellId
213
+ end},
214
+ true
215
+ )
216
+ __TS__SetDescriptor(
217
+ SpellSource.prototype,
218
+ "Action",
219
+ {get = function(self)
220
+ return {type = "spell", spell = self.Identifier}
221
+ end},
222
+ true
223
+ )
224
+ return ____exports
@@ -14,5 +14,7 @@ export declare class TimerSource extends DataSource<NativeDuration | undefined>
14
14
  constructor(read: () => NativeDuration | undefined, events: readonly string[], unit?: string | undefined);
15
15
  protected GetValue(): NativeDuration | undefined;
16
16
  get IsActive(): boolean;
17
+ /** A native radial cooldown owns timing, countdown text and completion effects. */
18
+ BindCooldown(frame: wuiraNativeCooldown): () => void;
17
19
  BindTo(frame: wuiraNativeStatusBar, options?: ProgressOverrides): () => void;
18
20
  }
@@ -195,6 +195,60 @@ end
195
195
  function TimerSource.prototype.GetValue(self)
196
196
  return self:read()
197
197
  end
198
+ function TimerSource.prototype.BindCooldown(self, frame)
199
+ if C_DurationUtil == nil then
200
+ error("TimerSource: native duration support is unavailable")
201
+ end
202
+ local empty = C_DurationUtil.CreateDuration()
203
+ local listener = CreateFrame("Frame", nil, UIParent)
204
+ local function refresh()
205
+ local duration = self:read()
206
+ self.boundDuration = duration
207
+ frame:SetCooldownFromDurationObject(
208
+ self:CanEmit(duration) and (duration or empty) or empty,
209
+ true
210
+ )
211
+ end
212
+ listener:SetScript(
213
+ "OnEvent",
214
+ function(_frame, event, unit)
215
+ if not __TS__StringStartsWith(event, "UNIT_") or self.unit == nil or unit == self.unit then
216
+ refresh(nil)
217
+ end
218
+ end
219
+ )
220
+ for ____, event in ipairs(self.events) do
221
+ listener:RegisterEvent(event)
222
+ end
223
+ self.bindingCount = self.bindingCount + 1
224
+ do
225
+ local function ____catch(failure)
226
+ self.bindingCount = self.bindingCount - 1
227
+ listener:UnregisterAllEvents()
228
+ listener:SetScript("OnEvent", nil)
229
+ error(failure, 0)
230
+ end
231
+ local ____try, ____hasReturned = pcall(function()
232
+ refresh(nil)
233
+ end)
234
+ if not ____try then
235
+ ____catch(____hasReturned)
236
+ end
237
+ end
238
+ local disposed = false
239
+ return function()
240
+ if disposed then
241
+ return
242
+ end
243
+ disposed = true
244
+ self.bindingCount = self.bindingCount - 1
245
+ listener:UnregisterAllEvents()
246
+ listener:SetScript("OnEvent", nil)
247
+ listener:Hide()
248
+ frame:SetDrawBling(false)
249
+ frame:Clear()
250
+ end
251
+ end
198
252
  function TimerSource.prototype.BindTo(self, frame, options)
199
253
  if options == nil then
200
254
  options = {}
@@ -0,0 +1,10 @@
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
+ constructor(spell: number | string);
8
+ get Status(): TotemTimerStatus;
9
+ private ReadDuration;
10
+ }