wuira 0.1.4 → 0.1.6

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 (79) hide show
  1. package/CHANGELOG.md +102 -1
  2. package/README.md +347 -0
  3. package/lib/Spells.d.ts +21 -0
  4. package/lib/Spells.lua +41 -0
  5. package/lib/datasources/AuraTimer.d.ts +21 -0
  6. package/lib/datasources/AuraTimer.lua +322 -0
  7. package/lib/datasources/CastTimer.d.ts +9 -0
  8. package/lib/datasources/CastTimer.lua +240 -0
  9. package/lib/datasources/DataSource.d.ts +4 -0
  10. package/lib/datasources/DataSource.lua +24 -0
  11. package/lib/datasources/KnownSpells.d.ts +21 -0
  12. package/lib/datasources/KnownSpells.lua +794 -0
  13. package/lib/datasources/ManaRegenTimer.d.ts +29 -0
  14. package/lib/datasources/ManaRegenTimer.lua +674 -0
  15. package/lib/datasources/ProgressSource.d.ts +6 -2
  16. package/lib/datasources/ProgressSource.lua +34 -3
  17. package/lib/datasources/Resources.d.ts +33 -2
  18. package/lib/datasources/Resources.lua +562 -10
  19. package/lib/datasources/SpellCooldown.d.ts +12 -0
  20. package/lib/datasources/SpellCooldown.lua +218 -0
  21. package/lib/datasources/SpellSource.d.ts +14 -0
  22. package/lib/datasources/SpellSource.lua +224 -0
  23. package/lib/datasources/SwingTimer.d.ts +31 -0
  24. package/lib/datasources/SwingTimer.lua +641 -0
  25. package/lib/datasources/TextureSource.d.ts +10 -0
  26. package/lib/datasources/TextureSource.lua +83 -0
  27. package/lib/datasources/TimerSource.d.ts +20 -0
  28. package/lib/datasources/TimerSource.lua +338 -0
  29. package/lib/datasources/TotemTimer.d.ts +10 -0
  30. package/lib/datasources/TotemTimer.lua +260 -0
  31. package/lib/datasources/index.d.ts +16 -1
  32. package/lib/datasources/index.lua +43 -0
  33. package/lib/index.d.ts +11 -0
  34. package/lib/index.lua +24 -0
  35. package/lib/platform/ActionBars.d.ts +27 -0
  36. package/lib/platform/ActionBars.lua +726 -0
  37. package/lib/platform/AddonSettings.d.ts +9 -0
  38. package/lib/platform/AddonSettings.lua +36 -0
  39. package/lib/platform/BlizzardUI.d.ts +17 -0
  40. package/lib/platform/BlizzardUI.lua +689 -0
  41. package/lib/platform/MicroMenu.d.ts +15 -0
  42. package/lib/platform/MicroMenu.lua +219 -0
  43. package/lib/platform/SecureButton.d.ts +5 -0
  44. package/lib/platform/SecureButton.lua +196 -0
  45. package/lib/platform/SlashCommands.d.ts +3 -0
  46. package/lib/platform/SlashCommands.lua +309 -0
  47. package/lib/platform/forever.d.ts +115 -2
  48. package/lib/skins/MicroBar.d.ts +8 -0
  49. package/lib/skins/MicroBar.lua +65 -0
  50. package/lib/skins/NativeSkin.d.ts +26 -0
  51. package/lib/skins/NativeSkin.lua +601 -0
  52. package/lib/skins/index.d.ts +3 -0
  53. package/lib/skins/index.lua +11 -0
  54. package/lib/store/index.lua +13 -0
  55. package/lib/ui/Button.d.ts +10 -0
  56. package/lib/ui/Button.lua +9 -0
  57. package/lib/ui/Cell.d.ts +7 -1
  58. package/lib/ui/FrameMover.d.ts +21 -0
  59. package/lib/ui/FrameMover.lua +123 -0
  60. package/lib/ui/HoverTracker.d.ts +20 -0
  61. package/lib/ui/HoverTracker.lua +88 -0
  62. package/lib/ui/Icon.d.ts +8 -0
  63. package/lib/ui/Icon.lua +8 -0
  64. package/lib/ui/KeybindCapture.d.ts +20 -0
  65. package/lib/ui/KeybindCapture.lua +488 -0
  66. package/lib/ui/Label.d.ts +10 -0
  67. package/lib/ui/Label.lua +8 -0
  68. package/lib/ui/ProgressBar.d.ts +5 -1
  69. package/lib/ui/SecureButton.d.ts +44 -0
  70. package/lib/ui/SecureButton.lua +9 -0
  71. package/lib/ui/index.d.ts +13 -0
  72. package/lib/ui/index.lua +28 -0
  73. package/lib/ui/layout/measureLayout.lua +11 -2
  74. package/lib/ui/mount.lua +679 -74
  75. package/lib/ui/primitives/jsx.d.ts +15 -2
  76. package/lib/wuira.d.ts +3 -0
  77. package/lib/wuira.lua +5 -0
  78. package/package.json +8 -1
  79. package/tools/build-library.mjs +1 -1
@@ -0,0 +1,83 @@
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__StringStartsWith(self, searchString, position)
36
+ if position == nil or position < 0 then
37
+ position = 0
38
+ end
39
+ return string.sub(self, position + 1, #searchString + position) == searchString
40
+ end
41
+ -- End of Lua Library inline imports
42
+ local ____exports = {}
43
+ local ____DataSource = require("datasources.DataSource")
44
+ local DataSource = ____DataSource.DataSource
45
+ --- A native texture reader with event-driven updates; no per-frame polling.
46
+ ____exports.TextureSource = __TS__Class()
47
+ local TextureSource = ____exports.TextureSource
48
+ TextureSource.name = "TextureSource"
49
+ __TS__ClassExtends(TextureSource, DataSource)
50
+ function TextureSource.prototype.____constructor(self, read, events, unit)
51
+ DataSource.prototype.____constructor(self, nil)
52
+ self.read = read
53
+ self.events = events
54
+ self.unit = unit
55
+ end
56
+ function TextureSource.prototype.GetValue(self)
57
+ return self:read()
58
+ end
59
+ function TextureSource.prototype.BindTo(self, frame, texture, onActiveChange)
60
+ local function refresh()
61
+ local value = self:read()
62
+ local active = self:CanEmit(value)
63
+ if onActiveChange ~= nil then
64
+ onActiveChange(nil, active)
65
+ end
66
+ if active then
67
+ texture:SetTexture(value)
68
+ end
69
+ end
70
+ frame:SetScript(
71
+ "OnEvent",
72
+ function(_frame, event, unit)
73
+ if not __TS__StringStartsWith(event, "UNIT_") or self.unit == nil or unit == self.unit then
74
+ refresh(nil)
75
+ end
76
+ end
77
+ )
78
+ for ____, event in ipairs(self.events) do
79
+ frame:RegisterEvent(event)
80
+ end
81
+ refresh(nil)
82
+ end
83
+ return ____exports
@@ -0,0 +1,20 @@
1
+ import { DataSource } from "./DataSource";
2
+ import type { ProgressOverrides } from "./ProgressSource";
3
+ /** Opaque native object: pass it to the renderer instead of doing Lua arithmetic. */
4
+ export interface NativeDuration {
5
+ readonly __wuiraDuration: unique symbol;
6
+ }
7
+ /** Duration reader whose animation is performed entirely by the native widget. */
8
+ export declare class TimerSource extends DataSource<NativeDuration | undefined> {
9
+ private readonly read;
10
+ private readonly events;
11
+ private readonly unit?;
12
+ private boundDuration?;
13
+ private bindingCount;
14
+ constructor(read: () => NativeDuration | undefined, events: readonly string[], unit?: string | undefined);
15
+ protected GetValue(): NativeDuration | undefined;
16
+ get IsActive(): boolean;
17
+ /** A native radial cooldown owns timing, countdown text and completion effects. */
18
+ BindCooldown(frame: wuiraNativeCooldown): () => void;
19
+ BindTo(frame: wuiraNativeStatusBar, options?: ProgressOverrides): () => void;
20
+ }
@@ -0,0 +1,338 @@
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__StringStartsWith(self, searchString, position)
36
+ if position == nil or position < 0 then
37
+ position = 0
38
+ end
39
+ return string.sub(self, position + 1, #searchString + position) == searchString
40
+ end
41
+
42
+ local function __TS__CloneDescriptor(____bindingPattern0)
43
+ local value
44
+ local writable
45
+ local set
46
+ local get
47
+ local configurable
48
+ local enumerable
49
+ enumerable = ____bindingPattern0.enumerable
50
+ configurable = ____bindingPattern0.configurable
51
+ get = ____bindingPattern0.get
52
+ set = ____bindingPattern0.set
53
+ writable = ____bindingPattern0.writable
54
+ value = ____bindingPattern0.value
55
+ local descriptor = {enumerable = enumerable == true, configurable = configurable == true}
56
+ local hasGetterOrSetter = get ~= nil or set ~= nil
57
+ local hasValueOrWritableAttribute = writable ~= nil or value ~= nil
58
+ if hasGetterOrSetter and hasValueOrWritableAttribute then
59
+ error("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute.", 0)
60
+ end
61
+ if get or set then
62
+ descriptor.get = get
63
+ descriptor.set = set
64
+ else
65
+ descriptor.value = value
66
+ descriptor.writable = writable == true
67
+ end
68
+ return descriptor
69
+ end
70
+
71
+ local __TS__DescriptorGet
72
+ do
73
+ local getmetatable = _G.getmetatable
74
+ local ____rawget = _G.rawget
75
+ function __TS__DescriptorGet(self, metatable, key)
76
+ while metatable do
77
+ local rawResult = ____rawget(metatable, key)
78
+ if rawResult ~= nil then
79
+ return rawResult
80
+ end
81
+ local descriptors = ____rawget(metatable, "_descriptors")
82
+ if descriptors then
83
+ local descriptor = descriptors[key]
84
+ if descriptor ~= nil then
85
+ if descriptor.get then
86
+ return descriptor.get(self)
87
+ end
88
+ return descriptor.value
89
+ end
90
+ end
91
+ metatable = getmetatable(metatable)
92
+ end
93
+ end
94
+ end
95
+
96
+ local __TS__DescriptorSet
97
+ do
98
+ local getmetatable = _G.getmetatable
99
+ local ____rawget = _G.rawget
100
+ local rawset = _G.rawset
101
+ function __TS__DescriptorSet(self, metatable, key, value)
102
+ while metatable do
103
+ local descriptors = ____rawget(metatable, "_descriptors")
104
+ if descriptors then
105
+ local descriptor = descriptors[key]
106
+ if descriptor ~= nil then
107
+ if descriptor.set then
108
+ descriptor.set(self, value)
109
+ else
110
+ if descriptor.writable == false then
111
+ error(
112
+ ((("Cannot assign to read only property '" .. key) .. "' of object '") .. tostring(self)) .. "'",
113
+ 0
114
+ )
115
+ end
116
+ descriptor.value = value
117
+ end
118
+ return
119
+ end
120
+ end
121
+ metatable = getmetatable(metatable)
122
+ end
123
+ rawset(self, key, value)
124
+ end
125
+ end
126
+
127
+ local __TS__SetDescriptor
128
+ do
129
+ local getmetatable = _G.getmetatable
130
+ local function descriptorIndex(self, key)
131
+ return __TS__DescriptorGet(
132
+ self,
133
+ getmetatable(self),
134
+ key
135
+ )
136
+ end
137
+ local function descriptorNewIndex(self, key, value)
138
+ return __TS__DescriptorSet(
139
+ self,
140
+ getmetatable(self),
141
+ key,
142
+ value
143
+ )
144
+ end
145
+ function __TS__SetDescriptor(target, key, desc, isPrototype)
146
+ if isPrototype == nil then
147
+ isPrototype = false
148
+ end
149
+ local ____isPrototype_0
150
+ if isPrototype then
151
+ ____isPrototype_0 = target
152
+ else
153
+ ____isPrototype_0 = getmetatable(target)
154
+ end
155
+ local metatable = ____isPrototype_0
156
+ if not metatable then
157
+ metatable = {}
158
+ setmetatable(target, metatable)
159
+ end
160
+ if not isPrototype and not rawget(metatable, "_isOwnDescriptorMetatable") then
161
+ local instanceMetatable = {}
162
+ instanceMetatable._isOwnDescriptorMetatable = true
163
+ setmetatable(instanceMetatable, metatable)
164
+ setmetatable(target, instanceMetatable)
165
+ metatable = instanceMetatable
166
+ end
167
+ local value = rawget(target, key)
168
+ if value ~= nil then
169
+ rawset(target, key, nil)
170
+ end
171
+ if not rawget(metatable, "_descriptors") then
172
+ metatable._descriptors = {}
173
+ end
174
+ metatable._descriptors[key] = __TS__CloneDescriptor(desc)
175
+ metatable.__index = descriptorIndex
176
+ metatable.__newindex = descriptorNewIndex
177
+ end
178
+ end
179
+ -- End of Lua Library inline imports
180
+ local ____exports = {}
181
+ local ____DataSource = require("datasources.DataSource")
182
+ local DataSource = ____DataSource.DataSource
183
+ --- Duration reader whose animation is performed entirely by the native widget.
184
+ ____exports.TimerSource = __TS__Class()
185
+ local TimerSource = ____exports.TimerSource
186
+ TimerSource.name = "TimerSource"
187
+ __TS__ClassExtends(TimerSource, DataSource)
188
+ function TimerSource.prototype.____constructor(self, read, events, unit)
189
+ DataSource.prototype.____constructor(self, nil)
190
+ self.read = read
191
+ self.events = events
192
+ self.unit = unit
193
+ self.bindingCount = 0
194
+ end
195
+ function TimerSource.prototype.GetValue(self)
196
+ return self:read()
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
252
+ function TimerSource.prototype.BindTo(self, frame, options)
253
+ if options == nil then
254
+ options = {}
255
+ end
256
+ if options.min ~= nil or options.max ~= nil or options.current ~= nil then
257
+ error("TimerSource: min/max/current overrides are not supported")
258
+ end
259
+ local bar = frame
260
+ local ____opt_0 = Enum and Enum.StatusBarInterpolation
261
+ local immediate = ____opt_0 and ____opt_0.Immediate
262
+ local ____opt_4 = Enum and Enum.StatusBarTimerDirection
263
+ local remaining = ____opt_4 and ____opt_4.RemainingTime
264
+ if bar.SetTimerDuration == nil or C_DurationUtil == nil or immediate == nil or remaining == nil then
265
+ error("TimerSource: native timer support is unavailable")
266
+ end
267
+ local empty = C_DurationUtil.CreateDuration()
268
+ bar:SetMinMaxValues(0, 1)
269
+ local function refresh()
270
+ local duration = self:read()
271
+ self.boundDuration = duration
272
+ local active = self:CanEmit(duration)
273
+ local ____this_9
274
+ ____this_9 = options
275
+ local ____opt_8 = ____this_9.onActiveChange
276
+ if ____opt_8 ~= nil then
277
+ ____opt_8(____this_9, active)
278
+ end
279
+ if not active then
280
+ return
281
+ end
282
+ if issecretvalue(duration) then
283
+ bar:SetTimerDuration(duration, immediate, remaining)
284
+ return
285
+ end
286
+ bar:SetTimerDuration(duration or empty, immediate, remaining)
287
+ if duration == nil then
288
+ bar:SetValue(0)
289
+ end
290
+ end
291
+ frame:SetScript(
292
+ "OnEvent",
293
+ function(_frame, event, unit)
294
+ if not __TS__StringStartsWith(event, "UNIT_") or self.unit == nil or unit == self.unit then
295
+ refresh(nil)
296
+ end
297
+ end
298
+ )
299
+ for ____, event in ipairs(self.events) do
300
+ frame:RegisterEvent(event)
301
+ end
302
+ self.bindingCount = self.bindingCount + 1
303
+ refresh(nil)
304
+ local disposed = false
305
+ return function()
306
+ if disposed then
307
+ return
308
+ end
309
+ disposed = true
310
+ self.bindingCount = self.bindingCount - 1
311
+ end
312
+ end
313
+ __TS__SetDescriptor(
314
+ TimerSource.prototype,
315
+ "IsActive",
316
+ {get = function(self)
317
+ local ____temp_10
318
+ if self.bindingCount > 0 then
319
+ ____temp_10 = self.boundDuration
320
+ else
321
+ ____temp_10 = self:read()
322
+ end
323
+ local duration = ____temp_10
324
+ if issecretvalue(duration) then
325
+ return true
326
+ end
327
+ if duration == nil then
328
+ return false
329
+ end
330
+ local ____this_12
331
+ ____this_12 = duration
332
+ local ____opt_11 = ____this_12.GetRemainingDuration
333
+ local remaining = ____opt_11 and ____opt_11(____this_12)
334
+ return issecretvalue(remaining) or remaining == nil or remaining > 0
335
+ end},
336
+ true
337
+ )
338
+ return ____exports
@@ -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
+ }