wuira 0.1.4 → 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 (41) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +112 -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 +3 -0
  26. package/lib/index.lua +8 -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/ui/Cell.d.ts +3 -1
  31. package/lib/ui/Icon.d.ts +8 -0
  32. package/lib/ui/Icon.lua +8 -0
  33. package/lib/ui/Label.d.ts +10 -0
  34. package/lib/ui/Label.lua +8 -0
  35. package/lib/ui/ProgressBar.d.ts +5 -1
  36. package/lib/ui/index.d.ts +4 -0
  37. package/lib/ui/index.lua +8 -0
  38. package/lib/ui/layout/measureLayout.lua +8 -1
  39. package/lib/ui/mount.lua +267 -45
  40. package/lib/ui/primitives/jsx.d.ts +7 -2
  41. package/package.json +1 -1
@@ -0,0 +1,352 @@
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__ArrayPush(self, ...)
11
+ local items = {...}
12
+ local len = #self
13
+ for i = 1, #items do
14
+ len = len + 1
15
+ self[len] = items[i]
16
+ end
17
+ return len
18
+ end
19
+
20
+ local __TS__Symbol, Symbol
21
+ do
22
+ local symbolMetatable = {__tostring = function(self)
23
+ return ("Symbol(" .. (self.description or "")) .. ")"
24
+ end}
25
+ function __TS__Symbol(description)
26
+ return setmetatable({description = description}, symbolMetatable)
27
+ end
28
+ Symbol = {
29
+ asyncDispose = __TS__Symbol("Symbol.asyncDispose"),
30
+ dispose = __TS__Symbol("Symbol.dispose"),
31
+ iterator = __TS__Symbol("Symbol.iterator"),
32
+ hasInstance = __TS__Symbol("Symbol.hasInstance"),
33
+ species = __TS__Symbol("Symbol.species"),
34
+ toStringTag = __TS__Symbol("Symbol.toStringTag")
35
+ }
36
+ end
37
+
38
+ local __TS__Iterator
39
+ do
40
+ local function iteratorGeneratorStep(self)
41
+ local co = self.____coroutine
42
+ local status, value = coroutine.resume(co)
43
+ if not status then
44
+ error(value, 0)
45
+ end
46
+ if coroutine.status(co) == "dead" then
47
+ return
48
+ end
49
+ return true, value
50
+ end
51
+ local function iteratorIteratorStep(self)
52
+ local result = self:next()
53
+ if result.done then
54
+ return
55
+ end
56
+ return true, result.value
57
+ end
58
+ local function iteratorStringStep(self, index)
59
+ index = index + 1
60
+ if index > #self then
61
+ return
62
+ end
63
+ return index, string.sub(self, index, index)
64
+ end
65
+ function __TS__Iterator(iterable)
66
+ if type(iterable) == "string" then
67
+ return iteratorStringStep, iterable, 0
68
+ elseif iterable.____coroutine ~= nil then
69
+ return iteratorGeneratorStep, iterable
70
+ elseif iterable[Symbol.iterator] then
71
+ local iterator = iterable[Symbol.iterator](iterable)
72
+ return iteratorIteratorStep, iterator
73
+ else
74
+ return ipairs(iterable)
75
+ end
76
+ end
77
+ end
78
+
79
+ local Map
80
+ do
81
+ Map = __TS__Class()
82
+ Map.name = "Map"
83
+ function Map.prototype.____constructor(self, entries)
84
+ self[Symbol.toStringTag] = "Map"
85
+ self.items = {}
86
+ self.size = 0
87
+ self.nextKey = {}
88
+ self.previousKey = {}
89
+ if entries == nil then
90
+ return
91
+ end
92
+ local iterable = entries
93
+ if iterable[Symbol.iterator] then
94
+ local iterator = iterable[Symbol.iterator](iterable)
95
+ while true do
96
+ local result = iterator:next()
97
+ if result.done then
98
+ break
99
+ end
100
+ local value = result.value
101
+ self:set(value[1], value[2])
102
+ end
103
+ else
104
+ local array = entries
105
+ for ____, kvp in ipairs(array) do
106
+ self:set(kvp[1], kvp[2])
107
+ end
108
+ end
109
+ end
110
+ function Map.prototype.clear(self)
111
+ self.items = {}
112
+ self.nextKey = {}
113
+ self.previousKey = {}
114
+ self.firstKey = nil
115
+ self.lastKey = nil
116
+ self.size = 0
117
+ end
118
+ function Map.prototype.delete(self, key)
119
+ local contains = self:has(key)
120
+ if contains then
121
+ self.size = self.size - 1
122
+ local next = self.nextKey[key]
123
+ local previous = self.previousKey[key]
124
+ if next ~= nil and previous ~= nil then
125
+ self.nextKey[previous] = next
126
+ self.previousKey[next] = previous
127
+ elseif next ~= nil then
128
+ self.firstKey = next
129
+ self.previousKey[next] = nil
130
+ elseif previous ~= nil then
131
+ self.lastKey = previous
132
+ self.nextKey[previous] = nil
133
+ else
134
+ self.firstKey = nil
135
+ self.lastKey = nil
136
+ end
137
+ self.nextKey[key] = nil
138
+ self.previousKey[key] = nil
139
+ end
140
+ self.items[key] = nil
141
+ return contains
142
+ end
143
+ function Map.prototype.forEach(self, callback)
144
+ for ____, key in __TS__Iterator(self:keys()) do
145
+ callback(nil, self.items[key], key, self)
146
+ end
147
+ end
148
+ function Map.prototype.get(self, key)
149
+ return self.items[key]
150
+ end
151
+ function Map.prototype.has(self, key)
152
+ return self.nextKey[key] ~= nil or self.lastKey == key
153
+ end
154
+ function Map.prototype.set(self, key, value)
155
+ local isNewValue = not self:has(key)
156
+ if isNewValue then
157
+ self.size = self.size + 1
158
+ end
159
+ self.items[key] = value
160
+ if self.firstKey == nil then
161
+ self.firstKey = key
162
+ self.lastKey = key
163
+ elseif isNewValue then
164
+ self.nextKey[self.lastKey] = key
165
+ self.previousKey[key] = self.lastKey
166
+ self.lastKey = key
167
+ end
168
+ return self
169
+ end
170
+ Map.prototype[Symbol.iterator] = function(self)
171
+ return self:entries()
172
+ end
173
+ function Map.prototype.entries(self)
174
+ local function getFirstKey()
175
+ return self.firstKey
176
+ end
177
+ local items = self.items
178
+ local nextKey = self.nextKey
179
+ local key
180
+ local started = false
181
+ return {
182
+ [Symbol.iterator] = function(self)
183
+ return self
184
+ end,
185
+ next = function(self)
186
+ if not started then
187
+ started = true
188
+ key = getFirstKey(nil)
189
+ else
190
+ key = nextKey[key]
191
+ end
192
+ return {done = not key, value = {key, items[key]}}
193
+ end
194
+ }
195
+ end
196
+ function Map.prototype.keys(self)
197
+ local function getFirstKey()
198
+ return self.firstKey
199
+ end
200
+ local nextKey = self.nextKey
201
+ local key
202
+ local started = false
203
+ return {
204
+ [Symbol.iterator] = function(self)
205
+ return self
206
+ end,
207
+ next = function(self)
208
+ if not started then
209
+ started = true
210
+ key = getFirstKey(nil)
211
+ else
212
+ key = nextKey[key]
213
+ end
214
+ return {done = not key, value = key}
215
+ end
216
+ }
217
+ end
218
+ function Map.prototype.values(self)
219
+ local function getFirstKey()
220
+ return self.firstKey
221
+ end
222
+ local items = self.items
223
+ local nextKey = self.nextKey
224
+ local key
225
+ local started = false
226
+ return {
227
+ [Symbol.iterator] = function(self)
228
+ return self
229
+ end,
230
+ next = function(self)
231
+ if not started then
232
+ started = true
233
+ key = getFirstKey(nil)
234
+ else
235
+ key = nextKey[key]
236
+ end
237
+ return {done = not key, value = items[key]}
238
+ end
239
+ }
240
+ end
241
+ Map[Symbol.species] = Map
242
+ end
243
+
244
+ local function __TS__New(target, ...)
245
+ local instance = setmetatable({}, target.prototype)
246
+ instance:____constructor(...)
247
+ return instance
248
+ end
249
+ -- End of Lua Library inline imports
250
+ local ____exports = {}
251
+ --- Opt-in stock UI visibility. Native buttons, bindings and event handlers remain intact.
252
+ ____exports.BlizzardUI = __TS__Class()
253
+ local BlizzardUI = ____exports.BlizzardUI
254
+ BlizzardUI.name = "BlizzardUI"
255
+ function BlizzardUI.prototype.____constructor(self)
256
+ end
257
+ function BlizzardUI.Hide(self, options)
258
+ local names = {}
259
+ if options.actionBars then
260
+ __TS__ArrayPush(
261
+ names,
262
+ "MainActionBar",
263
+ "MainMenuBar",
264
+ "MultiBarBottomLeft",
265
+ "MultiBarBottomRight",
266
+ "MultiBarRight",
267
+ "MultiBarLeft",
268
+ "MultiBar5",
269
+ "MultiBar6",
270
+ "MultiBar7",
271
+ "StanceBar",
272
+ "PetActionBar"
273
+ )
274
+ end
275
+ if options.player then
276
+ names[#names + 1] = "PlayerFrame"
277
+ end
278
+ if options.target then
279
+ names[#names + 1] = "TargetFrame"
280
+ end
281
+ if options.focus then
282
+ names[#names + 1] = "FocusFrame"
283
+ end
284
+ local hidden = CreateFrame("Frame", nil, UIParent)
285
+ hidden:SetAllPoints(UIParent)
286
+ hidden:Hide()
287
+ local listener = CreateFrame("Frame", nil, UIParent)
288
+ local parents = __TS__New(Map)
289
+ local enabled = true
290
+ local function apply()
291
+ if InCombatLockdown() then
292
+ return
293
+ end
294
+ if not enabled then
295
+ for ____, ____value in __TS__Iterator(parents) do
296
+ local frame = ____value[1]
297
+ local parent = ____value[2]
298
+ if frame:GetParent() == hidden then
299
+ frame:SetParent(parent)
300
+ end
301
+ end
302
+ parents:clear()
303
+ listener:UnregisterAllEvents()
304
+ listener:SetScript("OnEvent", nil)
305
+ listener:Hide()
306
+ return
307
+ end
308
+ for ____, name in ipairs(names) do
309
+ do
310
+ local __continue14
311
+ repeat
312
+ local frame = _G[name]
313
+ if frame == nil then
314
+ __continue14 = true
315
+ break
316
+ end
317
+ if not parents:has(frame) then
318
+ parents:set(
319
+ frame,
320
+ frame:GetParent()
321
+ )
322
+ frame:HookScript(
323
+ "OnShow",
324
+ function()
325
+ if enabled and not InCombatLockdown() and frame:GetParent() ~= hidden then
326
+ frame:SetParent(hidden)
327
+ end
328
+ end
329
+ )
330
+ end
331
+ if frame:GetParent() ~= hidden then
332
+ frame:SetParent(hidden)
333
+ end
334
+ __continue14 = true
335
+ until true
336
+ if not __continue14 then
337
+ break
338
+ end
339
+ end
340
+ end
341
+ end
342
+ listener:RegisterEvent("PLAYER_REGEN_ENABLED")
343
+ listener:RegisterEvent("PLAYER_ENTERING_WORLD")
344
+ listener:RegisterEvent("ADDON_LOADED")
345
+ listener:SetScript("OnEvent", apply)
346
+ apply(nil)
347
+ return function()
348
+ enabled = false
349
+ apply(nil)
350
+ end
351
+ end
352
+ return ____exports
@@ -5,7 +5,7 @@ type wuiraDrawLayer = "BACKGROUND" | "OVERLAY";
5
5
  interface wuiraNativeTexture {
6
6
  SetAllPoints(frame: wuiraNativeFrame): void;
7
7
  SetColorTexture(red: number, green: number, blue: number, alpha: number): void;
8
- SetTexture(path: string): void;
8
+ SetTexture(path: string | number | undefined): void;
9
9
  SetVertexColor(red: number, green: number, blue: number, alpha: number): void;
10
10
  SetBlendMode(mode: import("../types/Texture").BlendMode): void;
11
11
  SetHorizTile(enabled: boolean): void;
@@ -20,14 +20,19 @@ interface wuiraNativeTexture {
20
20
  }
21
21
 
22
22
  interface wuiraNativeFrame {
23
+ SetClipsChildren(clips: boolean): void;
24
+ GetFrameLevel(): number;
25
+ SetFrameLevel(level: number): void;
26
+ CreateFontString(name: undefined, layer: "OVERLAY"): wuiraNativeFontString;
23
27
  EnableMouse(enabled: boolean): void;
24
28
  RegisterEvent(event: string): void;
25
29
  UnregisterAllEvents(): void;
26
30
  SetScript(script: "OnEvent", handler: ((this: void, frame: wuiraNativeFrame, event: string, unit?: string) => void) | undefined): void;
31
+ SetScript(script: "OnUpdate", handler: ((this: void, frame: wuiraNativeFrame, elapsed: number) => void) | undefined): void;
27
32
  GetWidth(): number;
28
33
  GetHeight(): number;
29
34
  SetSize(width: number, height: number): void;
30
- SetPoint(point: wuiraAnchor, relativeTo: wuiraNativeFrame, relativePoint: wuiraAnchor, x: number, y: number): void;
35
+ SetPoint(point: wuiraAnchor, relativeTo: wuiraNativeFrame | wuiraNativeTexture, relativePoint: wuiraAnchor, x: number, y: number): void;
31
36
  CreateTexture(name: undefined, layer: wuiraDrawLayer): wuiraNativeTexture;
32
37
  Show(): void;
33
38
  Hide(): void;
@@ -38,6 +43,15 @@ interface wuiraNativeFrame {
38
43
  SetBackdropBorderColor(red: number, green: number, blue: number, alpha: number): void;
39
44
  }
40
45
 
46
+ interface wuiraNativeFontString {
47
+ SetAllPoints(frame: wuiraNativeFrame): void;
48
+ SetFont(path: string, size: number, flags?: string): boolean;
49
+ SetText(text: string): void;
50
+ SetTextColor(r: number, g: number, b: number, a: number): void;
51
+ SetJustifyH(align: "LEFT" | "CENTER" | "RIGHT"): void;
52
+ SetJustifyV(align: "MIDDLE"): void;
53
+ }
54
+
41
55
  declare const UIParent: wuiraNativeFrame;
42
56
  interface wuiraNativeStatusBar extends wuiraNativeFrame {
43
57
  GetStatusBarTexture(): wuiraNativeTexture;
@@ -55,8 +69,32 @@ declare function error(this: void, message: string): never;
55
69
  declare function issecretvalue(this: void, value: unknown): boolean;
56
70
  declare function UnitHealth(this: void, unit: string): number;
57
71
  declare function UnitHealthMax(this: void, unit: string): number;
72
+ declare const UnitGetIncomingHeals: ((this: void, unit: string) => number | undefined) | undefined;
73
+ declare const UnitGetTotalAbsorbs: ((this: void, unit: string) => number | undefined) | undefined;
58
74
  declare function UnitPower(this: void, unit: string, powerType: number): number;
59
75
  declare function UnitPowerMax(this: void, unit: string, powerType: number): number;
60
76
  declare const CurveConstants: { readonly ScaleTo100: unknown };
61
77
  declare function UnitHealthPercent(this: void, unit: string, predicted: boolean, curve: unknown): number;
62
78
  declare function UnitPowerPercent(this: void, unit: string, powerType: number, predicted: boolean, curve: unknown): number;
79
+
80
+ interface wuiraNativeAuraData {
81
+ name?: string;
82
+ icon?: number;
83
+ auraInstanceID?: number;
84
+ duration?: number;
85
+ expirationTime?: number;
86
+ }
87
+ declare const C_UnitAuras: {
88
+ GetAuraDataBySpellName?: (this: void, unit: string, name: string, filter: string) => wuiraNativeAuraData | undefined;
89
+ GetAuraDuration?: (this: void, unit: string, id: number) => import("../datasources/TimerSource").NativeDuration | undefined;
90
+ } | undefined;
91
+ declare const C_Spell: {
92
+ GetSpellName?: (this: void, id: number) => string | undefined;
93
+ GetSpellCooldownDuration?: (this: void, id: number) => import("../datasources/TimerSource").NativeDuration | undefined;
94
+ } | undefined;
95
+ declare const C_DurationUtil: {
96
+ CreateDuration(this: void): import("../datasources/TimerSource").NativeDuration & {
97
+ SetTimeFromStart(start: number, duration: number): void;
98
+ };
99
+ } | undefined;
100
+ declare const C_Secrets: { ShouldAurasBeSecret?: (this: void) => boolean } | undefined;
package/lib/ui/Cell.d.ts CHANGED
@@ -14,9 +14,11 @@ export type CellProps = {
14
14
  /** Defaults to true: visual cells do not intercept mouse input. */
15
15
  clickThrough?: boolean;
16
16
  decorations?: Decorations;
17
+ /** Visibility does not remove the cell's reserved layout slot. */
18
+ visible?: () => boolean;
17
19
  } & Position<ICell>;
18
20
  export interface ICell extends Element {
19
- kind: "cell" | "flow" | "grid" | "progress";
21
+ kind: "cell" | "flow" | "grid" | "progress" | "label" | "icon";
20
22
  props: CellProps;
21
23
  }
22
24
  export declare function Cell(props: Partial<CellProps> & {
@@ -0,0 +1,8 @@
1
+ import type { CellProps } from "./Cell";
2
+ import type { TextureSource } from "../datasources/TextureSource";
3
+ export type IconProps = CellProps & {
4
+ texture?: string | number;
5
+ textureSource?: TextureSource;
6
+ texCoords?: readonly [number, number, number, number];
7
+ };
8
+ export declare function Icon(props: Partial<IconProps>): import("..").Element;
@@ -0,0 +1,8 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____exports = {}
3
+ local ____jsx = require("ui.primitives.jsx")
4
+ local UI = ____jsx.UI
5
+ function ____exports.Icon(self, props)
6
+ return UI:createElement("icon", props)
7
+ end
8
+ return ____exports
@@ -0,0 +1,10 @@
1
+ import type { CellProps } from "./Cell";
2
+ import type { Color } from "../types/Color";
3
+ export type LabelProps = CellProps & {
4
+ text: string | (() => string);
5
+ font?: string;
6
+ fontSize?: number;
7
+ color?: Color;
8
+ align?: "LEFT" | "CENTER" | "RIGHT";
9
+ };
10
+ export declare function Label(props: Partial<CellProps> & Omit<LabelProps, keyof CellProps>): import("..").Element;
@@ -0,0 +1,8 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____exports = {}
3
+ local ____jsx = require("ui.primitives.jsx")
4
+ local UI = ____jsx.UI
5
+ function ____exports.Label(self, props)
6
+ return UI:createElement("label", props)
7
+ end
8
+ return ____exports
@@ -1,6 +1,7 @@
1
1
  import type { CellProps, ICell } from "./Cell";
2
2
  import type { Color } from "../types/Color";
3
3
  import type { ProgressSource } from "../datasources/ProgressSource";
4
+ import type { TimerSource } from "../datasources/TimerSource";
4
5
  import { Element } from "./primitives/jsx";
5
6
  import type { TextureOptions } from "../types/Texture";
6
7
  import type { BackgroundProps } from "./decorations/Background";
@@ -8,12 +9,15 @@ import type { BorderProps } from "./decorations/Border";
8
9
  export type ProgressBarProps = CellProps & {
9
10
  value?: number;
10
11
  current?: number;
11
- source?: ProgressSource;
12
+ source?: ProgressSource | TimerSource;
12
13
  min?: number;
13
14
  max?: number;
14
15
  color?: Color;
15
16
  /** Fill settings; explicit fields take priority over color/texture aliases. */
16
17
  foreground?: TextureOptions;
18
+ /** Enabled HP channels render automatically; false suppresses their overlay. */
19
+ healPrediction?: TextureOptions | false;
20
+ absorbPrediction?: TextureOptions | false;
17
21
  /** Full-size track behind the fill. false disables a decoration background. */
18
22
  background?: BackgroundProps | false;
19
23
  /** Backdrop edge texture; track/background is configured independently. */
package/lib/ui/index.d.ts CHANGED
@@ -9,3 +9,7 @@ export { ProgressBar } from "./ProgressBar";
9
9
  export { Background } from "./decorations/Background";
10
10
  export { Border } from "./decorations/Border";
11
11
  export { Glow } from "./decorations/Glow";
12
+ export { Label } from "./Label";
13
+ export type { LabelProps } from "./Label";
14
+ export { Icon } from "./Icon";
15
+ export type { IconProps } from "./Icon";
package/lib/ui/index.lua CHANGED
@@ -32,4 +32,12 @@ do
32
32
  local ____Glow = require("ui.decorations.Glow")
33
33
  ____exports.Glow = ____Glow.Glow
34
34
  end
35
+ do
36
+ local ____Label = require("ui.Label")
37
+ ____exports.Label = ____Label.Label
38
+ end
39
+ do
40
+ local ____Icon = require("ui.Icon")
41
+ ____exports.Icon = ____Icon.Icon
42
+ end
35
43
  return ____exports
@@ -102,7 +102,14 @@ function ____exports.measureLayout(self, element, available, ancestors)
102
102
  if __TS__ArrayIncludes(ancestors, element) then
103
103
  error("Layout children contain a cycle")
104
104
  end
105
- if element.kind ~= "cell" and element.kind ~= "flow" and element.kind ~= "grid" and element.kind ~= "progress" then
105
+ if not __TS__ArrayIncludes({
106
+ "cell",
107
+ "flow",
108
+ "grid",
109
+ "progress",
110
+ "label",
111
+ "icon"
112
+ }, element.kind) then
106
113
  error("Unsupported UI element: " .. element.kind)
107
114
  end
108
115
  local cell = element