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,240 @@
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__Unpack = table.unpack or unpack
36
+
37
+ local function __TS__CloneDescriptor(____bindingPattern0)
38
+ local value
39
+ local writable
40
+ local set
41
+ local get
42
+ local configurable
43
+ local enumerable
44
+ enumerable = ____bindingPattern0.enumerable
45
+ configurable = ____bindingPattern0.configurable
46
+ get = ____bindingPattern0.get
47
+ set = ____bindingPattern0.set
48
+ writable = ____bindingPattern0.writable
49
+ value = ____bindingPattern0.value
50
+ local descriptor = {enumerable = enumerable == true, configurable = configurable == true}
51
+ local hasGetterOrSetter = get ~= nil or set ~= nil
52
+ local hasValueOrWritableAttribute = writable ~= nil or value ~= nil
53
+ if hasGetterOrSetter and hasValueOrWritableAttribute then
54
+ error("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute.", 0)
55
+ end
56
+ if get or set then
57
+ descriptor.get = get
58
+ descriptor.set = set
59
+ else
60
+ descriptor.value = value
61
+ descriptor.writable = writable == true
62
+ end
63
+ return descriptor
64
+ end
65
+
66
+ local __TS__DescriptorGet
67
+ do
68
+ local getmetatable = _G.getmetatable
69
+ local ____rawget = _G.rawget
70
+ function __TS__DescriptorGet(self, metatable, key)
71
+ while metatable do
72
+ local rawResult = ____rawget(metatable, key)
73
+ if rawResult ~= nil then
74
+ return rawResult
75
+ end
76
+ local descriptors = ____rawget(metatable, "_descriptors")
77
+ if descriptors then
78
+ local descriptor = descriptors[key]
79
+ if descriptor ~= nil then
80
+ if descriptor.get then
81
+ return descriptor.get(self)
82
+ end
83
+ return descriptor.value
84
+ end
85
+ end
86
+ metatable = getmetatable(metatable)
87
+ end
88
+ end
89
+ end
90
+
91
+ local __TS__DescriptorSet
92
+ do
93
+ local getmetatable = _G.getmetatable
94
+ local ____rawget = _G.rawget
95
+ local rawset = _G.rawset
96
+ function __TS__DescriptorSet(self, metatable, key, value)
97
+ while metatable do
98
+ local descriptors = ____rawget(metatable, "_descriptors")
99
+ if descriptors then
100
+ local descriptor = descriptors[key]
101
+ if descriptor ~= nil then
102
+ if descriptor.set then
103
+ descriptor.set(self, value)
104
+ else
105
+ if descriptor.writable == false then
106
+ error(
107
+ ((("Cannot assign to read only property '" .. key) .. "' of object '") .. tostring(self)) .. "'",
108
+ 0
109
+ )
110
+ end
111
+ descriptor.value = value
112
+ end
113
+ return
114
+ end
115
+ end
116
+ metatable = getmetatable(metatable)
117
+ end
118
+ rawset(self, key, value)
119
+ end
120
+ end
121
+
122
+ local __TS__SetDescriptor
123
+ do
124
+ local getmetatable = _G.getmetatable
125
+ local function descriptorIndex(self, key)
126
+ return __TS__DescriptorGet(
127
+ self,
128
+ getmetatable(self),
129
+ key
130
+ )
131
+ end
132
+ local function descriptorNewIndex(self, key, value)
133
+ return __TS__DescriptorSet(
134
+ self,
135
+ getmetatable(self),
136
+ key,
137
+ value
138
+ )
139
+ end
140
+ function __TS__SetDescriptor(target, key, desc, isPrototype)
141
+ if isPrototype == nil then
142
+ isPrototype = false
143
+ end
144
+ local ____isPrototype_0
145
+ if isPrototype then
146
+ ____isPrototype_0 = target
147
+ else
148
+ ____isPrototype_0 = getmetatable(target)
149
+ end
150
+ local metatable = ____isPrototype_0
151
+ if not metatable then
152
+ metatable = {}
153
+ setmetatable(target, metatable)
154
+ end
155
+ if not isPrototype and not rawget(metatable, "_isOwnDescriptorMetatable") then
156
+ local instanceMetatable = {}
157
+ instanceMetatable._isOwnDescriptorMetatable = true
158
+ setmetatable(instanceMetatable, metatable)
159
+ setmetatable(target, instanceMetatable)
160
+ metatable = instanceMetatable
161
+ end
162
+ local value = rawget(target, key)
163
+ if value ~= nil then
164
+ rawset(target, key, nil)
165
+ end
166
+ if not rawget(metatable, "_descriptors") then
167
+ metatable._descriptors = {}
168
+ end
169
+ metatable._descriptors[key] = __TS__CloneDescriptor(desc)
170
+ metatable.__index = descriptorIndex
171
+ metatable.__newindex = descriptorNewIndex
172
+ end
173
+ end
174
+ -- End of Lua Library inline imports
175
+ local ____exports = {}
176
+ local ____TimerSource = require("datasources.TimerSource")
177
+ local TimerSource = ____TimerSource.TimerSource
178
+ local ____UnitSource = require("datasources.UnitSource")
179
+ local Unit = ____UnitSource.Unit
180
+ local resolveUnit = ____UnitSource.resolveUnit
181
+ --- Remaining cast/channel time using the native duration object.
182
+ ____exports.CastTimer = __TS__Class()
183
+ local CastTimer = ____exports.CastTimer
184
+ CastTimer.name = "CastTimer"
185
+ __TS__ClassExtends(CastTimer, TimerSource)
186
+ function CastTimer.prototype.____constructor(self, unit)
187
+ if unit == nil then
188
+ unit = Unit.Player
189
+ end
190
+ local target = resolveUnit(nil, unit)
191
+ if UnitCastingDuration == nil or UnitChannelDuration == nil then
192
+ error("CastTimer: native cast/channel durations are unavailable")
193
+ end
194
+ TimerSource.prototype.____constructor(
195
+ self,
196
+ function()
197
+ local casting = UnitCastingDuration(target.Token)
198
+ if issecretvalue(casting) or casting ~= nil then
199
+ return casting
200
+ end
201
+ return UnitChannelDuration(target.Token)
202
+ end,
203
+ {
204
+ "UNIT_SPELLCAST_START",
205
+ "UNIT_SPELLCAST_STOP",
206
+ "UNIT_SPELLCAST_DELAYED",
207
+ "UNIT_SPELLCAST_INTERRUPTED",
208
+ "UNIT_SPELLCAST_FAILED",
209
+ "UNIT_SPELLCAST_SUCCEEDED",
210
+ "UNIT_SPELLCAST_CHANNEL_START",
211
+ "UNIT_SPELLCAST_CHANNEL_UPDATE",
212
+ "UNIT_SPELLCAST_CHANNEL_STOP",
213
+ "PLAYER_ENTERING_WORLD",
214
+ "PLAYER_TARGET_CHANGED",
215
+ "PLAYER_FOCUS_CHANGED"
216
+ },
217
+ target.Token
218
+ )
219
+ self.target = target
220
+ end
221
+ __TS__SetDescriptor(
222
+ CastTimer.prototype,
223
+ "SpellName",
224
+ {get = function(self)
225
+ local casting = __TS__Unpack(UnitCastingInfo ~= nil and ({UnitCastingInfo(self.target.Token)}) or ({nil}))
226
+ if issecretvalue(casting) then
227
+ return casting
228
+ end
229
+ if casting ~= nil then
230
+ return casting
231
+ end
232
+ local channel = __TS__Unpack(UnitChannelInfo ~= nil and ({UnitChannelInfo(self.target.Token)}) or ({nil}))
233
+ if issecretvalue(channel) then
234
+ return channel
235
+ end
236
+ return channel or ""
237
+ end},
238
+ true
239
+ )
240
+ return ____exports
@@ -2,12 +2,16 @@
2
2
  export declare abstract class DataSource<T> {
3
3
  private value;
4
4
  private secret;
5
+ private conditions?;
5
6
  protected constructor(value: T, secret?: boolean);
6
7
  /** Checked when consumed, rather than inferred from combat state. */
7
8
  IsSecret(): boolean;
8
9
  get Value(): T;
9
10
  Compute<TResult>(compute: (value: T) => TResult): TResult;
10
11
  protected GetValue(): T;
12
+ /** Filters native binding emissions; Value remains a checked, fresh snapshot. */
13
+ When(condition: (value: T) => boolean): this;
14
+ protected CanEmit(value: T): boolean;
11
15
  private IsValueSecret;
12
16
  /** Replace the value and its explicit restriction together, clearing stale flags. */
13
17
  protected SetValue(value: T, secret?: boolean): void;
@@ -168,6 +168,30 @@ end
168
168
  function DataSource.prototype.GetValue(self)
169
169
  return self.value
170
170
  end
171
+ function DataSource.prototype.When(self, condition)
172
+ local ____self_0, ____conditions_1 = self, "conditions"
173
+ if ____self_0[____conditions_1] == nil then
174
+ ____self_0[____conditions_1] = {}
175
+ end
176
+ local ____self_conditions_3 = self.conditions
177
+ ____self_conditions_3[#____self_conditions_3 + 1] = condition
178
+ return self
179
+ end
180
+ function DataSource.prototype.CanEmit(self, value)
181
+ if self.conditions == nil then
182
+ return true
183
+ end
184
+ if self:IsValueSecret(value) then
185
+ return false
186
+ end
187
+ for ____, condition in ipairs(self.conditions) do
188
+ local result = condition(nil, value)
189
+ if issecretvalue(result) or not result then
190
+ return false
191
+ end
192
+ end
193
+ return true
194
+ end
171
195
  function DataSource.prototype.IsValueSecret(self, value)
172
196
  return issecretvalue(value) or self.secret or self:HasSecretFields(value)
173
197
  end
@@ -3,6 +3,10 @@ export interface ProgressOverrides {
3
3
  min?: number;
4
4
  max?: number;
5
5
  current?: number;
6
+ onActiveChange?: (active: boolean) => void;
7
+ onRefresh?: () => void;
8
+ healPredictionBar?: wuiraNativeStatusBar;
9
+ absorbPredictionBar?: wuiraNativeStatusBar;
6
10
  }
7
11
  /** Shared contract for health, power, cooldowns, and other progress values. */
8
12
  export declare abstract class ProgressSource extends DataSource<number> {
@@ -18,6 +22,6 @@ export declare abstract class ProgressSource extends DataSource<number> {
18
22
  });
19
23
  protected GetValue(): number;
20
24
  IsSecret(): boolean;
21
- BindTo(frame: wuiraNativeStatusBar, options?: ProgressOverrides): void;
22
- protected abstract Listen(frame: wuiraNativeFrame, refresh: () => void): void;
25
+ BindTo(frame: wuiraNativeStatusBar, options?: ProgressOverrides): void | (() => void);
26
+ protected abstract Listen(frame: wuiraNativeFrame, refresh: () => void): void | (() => void);
23
27
  }
@@ -66,14 +66,32 @@ function ProgressSource.prototype.BindTo(self, frame, options)
66
66
  options = {}
67
67
  end
68
68
  local function refresh()
69
- local current = options.current ~= nil and options.current or self.readers:current()
69
+ local sourceValue = self.readers:current()
70
+ local active = self:CanEmit(sourceValue)
71
+ local ____this_1
72
+ ____this_1 = options
73
+ local ____opt_0 = ____this_1.onActiveChange
74
+ if ____opt_0 ~= nil then
75
+ ____opt_0(____this_1, active)
76
+ end
77
+ if not active then
78
+ return
79
+ end
80
+ local current = options.current ~= nil and options.current or sourceValue
70
81
  frame:SetMinMaxValues(
71
82
  options.min ~= nil and options.min or self.readers:min(),
72
83
  options.max ~= nil and options.max or self.readers:max()
73
84
  )
74
85
  frame:SetValue(current)
86
+ local ____this_3
87
+ ____this_3 = options
88
+ local ____opt_2 = ____this_3.onRefresh
89
+ if ____opt_2 ~= nil then
90
+ ____opt_2(____this_3)
91
+ end
75
92
  end
76
- self:Listen(frame, refresh)
93
+ local dispose = self:Listen(frame, refresh)
77
94
  refresh(nil)
95
+ return dispose
78
96
  end
79
97
  return ____exports
@@ -1,18 +1,37 @@
1
1
  import { ProgressSource } from "./ProgressSource";
2
2
  import { UnitSource } from "./UnitSource";
3
3
  import type { UnitInput } from "./UnitSource";
4
+ import { DataSource } from "./DataSource";
5
+ import type { ProgressOverrides } from "./ProgressSource";
4
6
  export { Unit } from "./UnitSource";
5
7
  /** Direct API-to-widget binding; opaque values are never compared or calculated. */
6
8
  declare abstract class Resource extends ProgressSource {
7
9
  private readonly unitToken;
8
10
  private readonly events;
11
+ private readonly listeners;
9
12
  protected constructor(current: () => number, maximum: () => number, percent: () => number, unitToken: string, events: string[]);
10
- protected Listen(frame: wuiraNativeFrame, refresh: () => void): void;
13
+ protected AddEvents(...events: string[]): void;
14
+ protected Listen(frame: wuiraNativeFrame, refresh: () => void): () => void;
15
+ }
16
+ /** Live optional prediction channel. Secret amounts only travel to native sinks. */
17
+ export declare class HealthPrediction extends DataSource<number> {
18
+ private readonly read;
19
+ constructor(read: (() => number | undefined) | undefined);
20
+ get IsAvailable(): boolean;
21
+ protected GetValue(): number;
22
+ ApplyTo(frame: wuiraNativeStatusBar, maximum: number): void;
11
23
  }
12
24
  export declare class HP extends Resource {
25
+ private healPrediction?;
26
+ private absorbPrediction?;
27
+ get HealPrediction(): HealthPrediction | undefined;
28
+ get AbsorbPrediction(): HealthPrediction | undefined;
29
+ UseHealPrediction(): this;
30
+ UseAbsorbPrediction(): this;
31
+ BindTo(frame: wuiraNativeStatusBar, options?: ProgressOverrides): () => void;
13
32
  readonly target: UnitSource;
14
33
  get unit(): string;
15
- constructor(unit: UnitInput);
34
+ constructor(unit?: UnitInput);
16
35
  }
17
36
  /** Explicit mana (power type 0), even while the unit uses rage/energy. */
18
37
  export declare class Mana extends Resource {