wuira 0.1.3 → 0.1.5

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 (44) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +181 -0
  3. package/lib/Spells.d.ts +10 -0
  4. package/lib/Spells.lua +19 -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/ProgressSource.d.ts +6 -2
  12. package/lib/datasources/ProgressSource.lua +20 -2
  13. package/lib/datasources/Resources.d.ts +21 -2
  14. package/lib/datasources/Resources.lua +473 -0
  15. package/lib/datasources/SpellCooldown.d.ts +10 -0
  16. package/lib/datasources/SpellCooldown.lua +207 -0
  17. package/lib/datasources/SwingTimer.d.ts +31 -0
  18. package/lib/datasources/SwingTimer.lua +641 -0
  19. package/lib/datasources/TextureSource.d.ts +10 -0
  20. package/lib/datasources/TextureSource.lua +83 -0
  21. package/lib/datasources/TimerSource.d.ts +18 -0
  22. package/lib/datasources/TimerSource.lua +284 -0
  23. package/lib/datasources/index.d.ts +9 -1
  24. package/lib/datasources/index.lua +27 -0
  25. package/lib/index.d.ts +5 -0
  26. package/lib/index.lua +13 -0
  27. package/lib/platform/BlizzardUI.d.ts +12 -0
  28. package/lib/platform/BlizzardUI.lua +352 -0
  29. package/lib/platform/forever.d.ts +40 -2
  30. package/lib/store/index.d.ts +37 -0
  31. package/lib/store/index.lua +921 -0
  32. package/lib/ui/Cell.d.ts +3 -1
  33. package/lib/ui/Icon.d.ts +8 -0
  34. package/lib/ui/Icon.lua +8 -0
  35. package/lib/ui/Label.d.ts +10 -0
  36. package/lib/ui/Label.lua +8 -0
  37. package/lib/ui/ProgressBar.d.ts +5 -1
  38. package/lib/ui/index.d.ts +4 -0
  39. package/lib/ui/index.lua +8 -0
  40. package/lib/ui/layout/measureLayout.lua +8 -1
  41. package/lib/ui/mount.lua +267 -45
  42. package/lib/ui/primitives/jsx.d.ts +7 -2
  43. package/package.json +8 -1
  44. 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,18 @@
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
+ BindTo(frame: wuiraNativeStatusBar, options?: ProgressOverrides): () => void;
18
+ }
@@ -0,0 +1,284 @@
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.BindTo(self, frame, options)
199
+ if options == nil then
200
+ options = {}
201
+ end
202
+ if options.min ~= nil or options.max ~= nil or options.current ~= nil then
203
+ error("TimerSource: min/max/current overrides are not supported")
204
+ end
205
+ local bar = frame
206
+ local ____opt_0 = Enum and Enum.StatusBarInterpolation
207
+ local immediate = ____opt_0 and ____opt_0.Immediate
208
+ local ____opt_4 = Enum and Enum.StatusBarTimerDirection
209
+ local remaining = ____opt_4 and ____opt_4.RemainingTime
210
+ if bar.SetTimerDuration == nil or C_DurationUtil == nil or immediate == nil or remaining == nil then
211
+ error("TimerSource: native timer support is unavailable")
212
+ end
213
+ local empty = C_DurationUtil.CreateDuration()
214
+ bar:SetMinMaxValues(0, 1)
215
+ local function refresh()
216
+ local duration = self:read()
217
+ self.boundDuration = duration
218
+ local active = self:CanEmit(duration)
219
+ local ____this_9
220
+ ____this_9 = options
221
+ local ____opt_8 = ____this_9.onActiveChange
222
+ if ____opt_8 ~= nil then
223
+ ____opt_8(____this_9, active)
224
+ end
225
+ if not active then
226
+ return
227
+ end
228
+ if issecretvalue(duration) then
229
+ bar:SetTimerDuration(duration, immediate, remaining)
230
+ return
231
+ end
232
+ bar:SetTimerDuration(duration or empty, immediate, remaining)
233
+ if duration == nil then
234
+ bar:SetValue(0)
235
+ end
236
+ end
237
+ frame:SetScript(
238
+ "OnEvent",
239
+ function(_frame, event, unit)
240
+ if not __TS__StringStartsWith(event, "UNIT_") or self.unit == nil or unit == self.unit then
241
+ refresh(nil)
242
+ end
243
+ end
244
+ )
245
+ for ____, event in ipairs(self.events) do
246
+ frame:RegisterEvent(event)
247
+ end
248
+ self.bindingCount = self.bindingCount + 1
249
+ refresh(nil)
250
+ local disposed = false
251
+ return function()
252
+ if disposed then
253
+ return
254
+ end
255
+ disposed = true
256
+ self.bindingCount = self.bindingCount - 1
257
+ end
258
+ end
259
+ __TS__SetDescriptor(
260
+ TimerSource.prototype,
261
+ "IsActive",
262
+ {get = function(self)
263
+ local ____temp_10
264
+ if self.bindingCount > 0 then
265
+ ____temp_10 = self.boundDuration
266
+ else
267
+ ____temp_10 = self:read()
268
+ end
269
+ local duration = ____temp_10
270
+ if issecretvalue(duration) then
271
+ return true
272
+ end
273
+ if duration == nil then
274
+ return false
275
+ end
276
+ local ____this_12
277
+ ____this_12 = duration
278
+ local ____opt_11 = ____this_12.GetRemainingDuration
279
+ local remaining = ____opt_11 and ____opt_11(____this_12)
280
+ return issecretvalue(remaining) or remaining == nil or remaining > 0
281
+ end},
282
+ true
283
+ )
284
+ return ____exports
@@ -1,7 +1,7 @@
1
1
  /// <reference path="../platform/forever.d.ts" />
2
2
  export { DataSource } from "./DataSource";
3
3
  export { ProgressSource } from "./ProgressSource";
4
- export { HP, Mana, Unit, DataSources } from "./Resources";
4
+ export { HP, Mana, Unit, DataSources, HealthPrediction } from "./Resources";
5
5
  export { Aura, AuraSource, Buffs, Debuffs } from "./Auras";
6
6
  export type { AuraSourceStatus } from "./Auras";
7
7
  export { GroupMembers, PartyMembers, RaidMembers } from "./GroupMembers";
@@ -10,3 +10,11 @@ export { ClassSource, SpecSource, Specializations } from "./UnitInfo";
10
10
  export type { ClassInfo, SpecializationInfo, InspectStatus } from "./UnitInfo";
11
11
  export { UnitSource } from "./UnitSource";
12
12
  export type { UnitInput, UnitIdentity } from "./UnitSource";
13
+ export { SwingTimer, SwingHand } from "./SwingTimer";
14
+ export { TimerSource } from "./TimerSource";
15
+ export type { NativeDuration } from "./TimerSource";
16
+ export { TextureSource } from "./TextureSource";
17
+ export { CastTimer } from "./CastTimer";
18
+ export { AuraTimer } from "./AuraTimer";
19
+ export type { AuraTimerOptions, AuraTimerStatus } from "./AuraTimer";
20
+ export { SpellCooldown, GlobalCooldown } from "./SpellCooldown";
@@ -14,6 +14,7 @@ do
14
14
  ____exports.Mana = ____Resources.Mana
15
15
  ____exports.Unit = ____Resources.Unit
16
16
  ____exports.DataSources = ____Resources.DataSources
17
+ ____exports.HealthPrediction = ____Resources.HealthPrediction
17
18
  end
18
19
  do
19
20
  local ____Auras = require("datasources.Auras")
@@ -38,4 +39,30 @@ do
38
39
  local ____UnitSource = require("datasources.UnitSource")
39
40
  ____exports.UnitSource = ____UnitSource.UnitSource
40
41
  end
42
+ do
43
+ local ____SwingTimer = require("datasources.SwingTimer")
44
+ ____exports.SwingTimer = ____SwingTimer.SwingTimer
45
+ ____exports.SwingHand = ____SwingTimer.SwingHand
46
+ end
47
+ do
48
+ local ____TimerSource = require("datasources.TimerSource")
49
+ ____exports.TimerSource = ____TimerSource.TimerSource
50
+ end
51
+ do
52
+ local ____TextureSource = require("datasources.TextureSource")
53
+ ____exports.TextureSource = ____TextureSource.TextureSource
54
+ end
55
+ do
56
+ local ____CastTimer = require("datasources.CastTimer")
57
+ ____exports.CastTimer = ____CastTimer.CastTimer
58
+ end
59
+ do
60
+ local ____AuraTimer = require("datasources.AuraTimer")
61
+ ____exports.AuraTimer = ____AuraTimer.AuraTimer
62
+ end
63
+ do
64
+ local ____SpellCooldown = require("datasources.SpellCooldown")
65
+ ____exports.SpellCooldown = ____SpellCooldown.SpellCooldown
66
+ ____exports.GlobalCooldown = ____SpellCooldown.GlobalCooldown
67
+ end
41
68
  return ____exports
package/lib/index.d.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  /// <reference path="./platform/forever.d.ts" />
2
2
  import "./console-polyfill";
3
3
  export { wuira } from "./wuira";
4
+ export { Spells } from "./Spells";
5
+ export { BlizzardUI } from "./platform/BlizzardUI";
6
+ export type { BlizzardUIOptions } from "./platform/BlizzardUI";
4
7
  export { UI } from "./ui/primitives/jsx";
5
8
  export type { Element, Component } from "./ui/primitives/jsx";
6
9
  export type { Cell } from "./ui/Cell";
10
+ export { Store, StoreRegistry } from "./store";
11
+ export type { StoreClass, ReadonlyData, SavedStoreOptions } from "./store";
package/lib/index.lua CHANGED
@@ -5,8 +5,21 @@ do
5
5
  local ____wuira = require("wuira")
6
6
  ____exports.wuira = ____wuira.wuira
7
7
  end
8
+ do
9
+ local ____Spells = require("Spells")
10
+ ____exports.Spells = ____Spells.Spells
11
+ end
12
+ do
13
+ local ____BlizzardUI = require("platform.BlizzardUI")
14
+ ____exports.BlizzardUI = ____BlizzardUI.BlizzardUI
15
+ end
8
16
  do
9
17
  local ____jsx = require("ui.primitives.jsx")
10
18
  ____exports.UI = ____jsx.UI
11
19
  end
20
+ do
21
+ local ____store = require("store.index")
22
+ ____exports.Store = ____store.Store
23
+ ____exports.StoreRegistry = ____store.StoreRegistry
24
+ end
12
25
  return ____exports
@@ -0,0 +1,12 @@
1
+ export interface BlizzardUIOptions {
2
+ actionBars?: boolean;
3
+ player?: boolean;
4
+ target?: boolean;
5
+ focus?: boolean;
6
+ }
7
+ /** Opt-in stock UI visibility. Native buttons, bindings and event handlers remain intact. */
8
+ export declare class BlizzardUI {
9
+ private constructor();
10
+ /** Returns a restore function; protected changes wait until combat ends. */
11
+ static Hide(options: BlizzardUIOptions): () => void;
12
+ }