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
@@ -0,0 +1,9 @@
1
+ import type { Cell } from "../ui/Cell";
2
+ /** Registers a JSX settings view in the client's native addon settings list. */
3
+ export declare class AddonSettings {
4
+ readonly Frame: wuiraNativeFrame;
5
+ private readonly category;
6
+ constructor(name: string, view: Cell | (() => Cell | void));
7
+ Open(): void;
8
+ Close(): void;
9
+ }
@@ -0,0 +1,36 @@
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
+ -- End of Lua Library inline imports
10
+ local ____exports = {}
11
+ local ____wuira = require("wuira")
12
+ local wuira = ____wuira.wuira
13
+ --- Registers a JSX settings view in the client's native addon settings list.
14
+ ____exports.AddonSettings = __TS__Class()
15
+ local AddonSettings = ____exports.AddonSettings
16
+ AddonSettings.name = "AddonSettings"
17
+ function AddonSettings.prototype.____constructor(self, name, view)
18
+ if (Settings and Settings.RegisterCanvasLayoutCategory) == nil then
19
+ error("AddonSettings: native settings API is unavailable")
20
+ end
21
+ self.Frame = CreateFrame("Frame", nil, UIParent)
22
+ self.Frame:Hide()
23
+ wuira:Mount(view, nil, self.Frame)
24
+ self.category = Settings.RegisterCanvasLayoutCategory(self.Frame, name)
25
+ Settings.RegisterAddOnCategory(self.category)
26
+ end
27
+ function AddonSettings.prototype.Open(self)
28
+ Settings.OpenToCategory(self.category:GetID())
29
+ end
30
+ function AddonSettings.prototype.Close(self)
31
+ local ____opt_2 = _G.SettingsPanel
32
+ if ____opt_2 ~= nil then
33
+ ____opt_2:Hide()
34
+ end
35
+ end
36
+ return ____exports
@@ -1,3 +1,4 @@
1
+ import type { MicroMenuSkinOptions } from "./MicroMenu";
1
2
  export interface BlizzardUIOptions {
2
3
  actionBars?: boolean;
3
4
  player?: boolean;
@@ -7,6 +8,10 @@ export interface BlizzardUIOptions {
7
8
  /** Opt-in stock UI visibility. Native buttons, bindings and event handlers remain intact. */
8
9
  export declare class BlizzardUI {
9
10
  private constructor();
11
+ /** Style native micro-menu buttons. Reload restores their original textures. */
12
+ static SkinMicroMenu(options?: MicroMenuSkinOptions): () => void;
13
+ /** Disable stock action-bar event/update paths. Restoring their scripts requires reload. */
14
+ static DisableActionBars(): () => void;
10
15
  /** Returns a restore function; protected changes wait until combat ends. */
11
16
  static Hide(options: BlizzardUIOptions): () => void;
12
17
  }
@@ -7,16 +7,6 @@ local function __TS__Class(self)
7
7
  return c
8
8
  end
9
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
10
  local __TS__Symbol, Symbol
21
11
  do
22
12
  local symbolMetatable = {__tostring = function(self)
@@ -76,6 +66,262 @@ do
76
66
  end
77
67
  end
78
68
 
69
+ local function __TS__New(target, ...)
70
+ local instance = setmetatable({}, target.prototype)
71
+ instance:____constructor(...)
72
+ return instance
73
+ end
74
+
75
+ local Set
76
+ do
77
+ Set = __TS__Class()
78
+ Set.name = "Set"
79
+ function Set.prototype.____constructor(self, values)
80
+ self[Symbol.toStringTag] = "Set"
81
+ self.size = 0
82
+ self.nextKey = {}
83
+ self.previousKey = {}
84
+ if values == nil then
85
+ return
86
+ end
87
+ local iterable = values
88
+ if iterable[Symbol.iterator] then
89
+ local iterator = iterable[Symbol.iterator](iterable)
90
+ while true do
91
+ local result = iterator:next()
92
+ if result.done then
93
+ break
94
+ end
95
+ self:add(result.value)
96
+ end
97
+ else
98
+ local array = values
99
+ for ____, value in ipairs(array) do
100
+ self:add(value)
101
+ end
102
+ end
103
+ end
104
+ function Set.prototype.add(self, value)
105
+ local isNewValue = not self:has(value)
106
+ if isNewValue then
107
+ self.size = self.size + 1
108
+ end
109
+ if self.firstKey == nil then
110
+ self.firstKey = value
111
+ self.lastKey = value
112
+ elseif isNewValue then
113
+ self.nextKey[self.lastKey] = value
114
+ self.previousKey[value] = self.lastKey
115
+ self.lastKey = value
116
+ end
117
+ return self
118
+ end
119
+ function Set.prototype.clear(self)
120
+ self.nextKey = {}
121
+ self.previousKey = {}
122
+ self.firstKey = nil
123
+ self.lastKey = nil
124
+ self.size = 0
125
+ end
126
+ function Set.prototype.delete(self, value)
127
+ local contains = self:has(value)
128
+ if contains then
129
+ self.size = self.size - 1
130
+ local next = self.nextKey[value]
131
+ local previous = self.previousKey[value]
132
+ if next ~= nil and previous ~= nil then
133
+ self.nextKey[previous] = next
134
+ self.previousKey[next] = previous
135
+ elseif next ~= nil then
136
+ self.firstKey = next
137
+ self.previousKey[next] = nil
138
+ elseif previous ~= nil then
139
+ self.lastKey = previous
140
+ self.nextKey[previous] = nil
141
+ else
142
+ self.firstKey = nil
143
+ self.lastKey = nil
144
+ end
145
+ self.nextKey[value] = nil
146
+ self.previousKey[value] = nil
147
+ end
148
+ return contains
149
+ end
150
+ function Set.prototype.forEach(self, callback)
151
+ for ____, key in __TS__Iterator(self:keys()) do
152
+ callback(nil, key, key, self)
153
+ end
154
+ end
155
+ function Set.prototype.has(self, value)
156
+ return self.nextKey[value] ~= nil or self.lastKey == value
157
+ end
158
+ Set.prototype[Symbol.iterator] = function(self)
159
+ return self:values()
160
+ end
161
+ function Set.prototype.entries(self)
162
+ local function getFirstKey()
163
+ return self.firstKey
164
+ end
165
+ local nextKey = self.nextKey
166
+ local key
167
+ local started = false
168
+ return {
169
+ [Symbol.iterator] = function(self)
170
+ return self
171
+ end,
172
+ next = function(self)
173
+ if not started then
174
+ started = true
175
+ key = getFirstKey(nil)
176
+ else
177
+ key = nextKey[key]
178
+ end
179
+ return {done = not key, value = {key, key}}
180
+ end
181
+ }
182
+ end
183
+ function Set.prototype.keys(self)
184
+ local function getFirstKey()
185
+ return self.firstKey
186
+ end
187
+ local nextKey = self.nextKey
188
+ local key
189
+ local started = false
190
+ return {
191
+ [Symbol.iterator] = function(self)
192
+ return self
193
+ end,
194
+ next = function(self)
195
+ if not started then
196
+ started = true
197
+ key = getFirstKey(nil)
198
+ else
199
+ key = nextKey[key]
200
+ end
201
+ return {done = not key, value = key}
202
+ end
203
+ }
204
+ end
205
+ function Set.prototype.values(self)
206
+ local function getFirstKey()
207
+ return self.firstKey
208
+ end
209
+ local nextKey = self.nextKey
210
+ local key
211
+ local started = false
212
+ return {
213
+ [Symbol.iterator] = function(self)
214
+ return self
215
+ end,
216
+ next = function(self)
217
+ if not started then
218
+ started = true
219
+ key = getFirstKey(nil)
220
+ else
221
+ key = nextKey[key]
222
+ end
223
+ return {done = not key, value = key}
224
+ end
225
+ }
226
+ end
227
+ function Set.prototype.union(self, other)
228
+ local result = __TS__New(Set, self)
229
+ for ____, item in __TS__Iterator(other) do
230
+ result:add(item)
231
+ end
232
+ return result
233
+ end
234
+ function Set.prototype.intersection(self, other)
235
+ local result = __TS__New(Set)
236
+ for ____, item in __TS__Iterator(self) do
237
+ if other:has(item) then
238
+ result:add(item)
239
+ end
240
+ end
241
+ return result
242
+ end
243
+ function Set.prototype.difference(self, other)
244
+ local result = __TS__New(Set, self)
245
+ for ____, item in __TS__Iterator(other) do
246
+ result:delete(item)
247
+ end
248
+ return result
249
+ end
250
+ function Set.prototype.symmetricDifference(self, other)
251
+ local result = __TS__New(Set, self)
252
+ for ____, item in __TS__Iterator(other) do
253
+ if self:has(item) then
254
+ result:delete(item)
255
+ else
256
+ result:add(item)
257
+ end
258
+ end
259
+ return result
260
+ end
261
+ function Set.prototype.isSubsetOf(self, other)
262
+ for ____, item in __TS__Iterator(self) do
263
+ if not other:has(item) then
264
+ return false
265
+ end
266
+ end
267
+ return true
268
+ end
269
+ function Set.prototype.isSupersetOf(self, other)
270
+ for ____, item in __TS__Iterator(other) do
271
+ if not self:has(item) then
272
+ return false
273
+ end
274
+ end
275
+ return true
276
+ end
277
+ function Set.prototype.isDisjointFrom(self, other)
278
+ for ____, item in __TS__Iterator(self) do
279
+ if other:has(item) then
280
+ return false
281
+ end
282
+ end
283
+ return true
284
+ end
285
+ Set[Symbol.species] = Set
286
+ end
287
+
288
+ local __TS__Unpack = table.unpack or unpack
289
+
290
+ local function __TS__CountVarargs(...)
291
+ return select("#", ...)
292
+ end
293
+
294
+ local function __TS__SparseArrayNew(...)
295
+ local sparseArray = {...}
296
+ sparseArray.sparseLength = __TS__CountVarargs(...)
297
+ return sparseArray
298
+ end
299
+
300
+ local function __TS__SparseArrayPush(sparseArray, ...)
301
+ local args = {...}
302
+ local argsLen = __TS__CountVarargs(...)
303
+ local listLen = sparseArray.sparseLength
304
+ for i = 1, argsLen do
305
+ sparseArray[listLen + i] = args[i]
306
+ end
307
+ sparseArray.sparseLength = listLen + argsLen
308
+ end
309
+
310
+ local function __TS__SparseArraySpread(sparseArray)
311
+ local _unpack = unpack or table.unpack
312
+ return _unpack(sparseArray, 1, sparseArray.sparseLength)
313
+ end
314
+
315
+ local function __TS__ArrayPush(self, ...)
316
+ local items = {...}
317
+ local len = #self
318
+ for i = 1, #items do
319
+ len = len + 1
320
+ self[len] = items[i]
321
+ end
322
+ return len
323
+ end
324
+
79
325
  local Map
80
326
  do
81
327
  Map = __TS__Class()
@@ -240,20 +486,111 @@ do
240
486
  end
241
487
  Map[Symbol.species] = Map
242
488
  end
243
-
244
- local function __TS__New(target, ...)
245
- local instance = setmetatable({}, target.prototype)
246
- instance:____constructor(...)
247
- return instance
248
- end
249
489
  -- End of Lua Library inline imports
250
490
  local ____exports = {}
491
+ local ____MicroMenu = require("platform.MicroMenu")
492
+ local skinMicroMenu = ____MicroMenu.skinMicroMenu
251
493
  --- Opt-in stock UI visibility. Native buttons, bindings and event handlers remain intact.
252
494
  ____exports.BlizzardUI = __TS__Class()
253
495
  local BlizzardUI = ____exports.BlizzardUI
254
496
  BlizzardUI.name = "BlizzardUI"
255
497
  function BlizzardUI.prototype.____constructor(self)
256
498
  end
499
+ function BlizzardUI.SkinMicroMenu(self, options)
500
+ if options == nil then
501
+ options = {}
502
+ end
503
+ return skinMicroMenu(nil, options)
504
+ end
505
+ function BlizzardUI.DisableActionBars(self)
506
+ local unhide = self:Hide({actionBars = true})
507
+ local listener = CreateFrame("Frame", nil, UIParent)
508
+ local roots = {
509
+ "MainActionBar",
510
+ "MainMenuBar",
511
+ "MultiBarBottomLeft",
512
+ "MultiBarBottomRight",
513
+ "MultiBarRight",
514
+ "MultiBarLeft",
515
+ "MultiBar5",
516
+ "MultiBar6",
517
+ "MultiBar7",
518
+ "StanceBar",
519
+ "PetActionBar"
520
+ }
521
+ local managers = {
522
+ "ActionBarController",
523
+ "ActionBarButtonEventsFrame",
524
+ "ActionBarActionEventsFrame",
525
+ "ActionBarButtonUpdateFrame",
526
+ "ActionBarButtonRangeCheckFrame",
527
+ "ActionBarButtonUsableWatcherFrame"
528
+ }
529
+ local function apply()
530
+ if InCombatLockdown() then
531
+ return
532
+ end
533
+ local seen = __TS__New(Set)
534
+ local quiet
535
+ quiet = function(____, frame)
536
+ if frame == nil or frame.UnregisterAllEvents == nil or seen:has(frame) then
537
+ return
538
+ end
539
+ seen:add(frame)
540
+ frame:UnregisterAllEvents()
541
+ frame:SetScript("OnEvent", nil)
542
+ frame:SetScript("OnUpdate", nil)
543
+ if frame.GetChildren ~= nil then
544
+ local children = {frame:GetChildren()}
545
+ for ____, child in ipairs(children) do
546
+ quiet(nil, child)
547
+ end
548
+ end
549
+ end
550
+ local ____array_0 = __TS__SparseArrayNew(__TS__Unpack(roots))
551
+ __TS__SparseArrayPush(
552
+ ____array_0,
553
+ __TS__Unpack(managers)
554
+ )
555
+ for ____, name in ipairs({__TS__SparseArraySpread(____array_0)}) do
556
+ quiet(nil, _G[name])
557
+ end
558
+ for ____, prefix in ipairs({
559
+ "ActionButton",
560
+ "MultiBarBottomLeftButton",
561
+ "MultiBarBottomRightButton",
562
+ "MultiBarRightButton",
563
+ "MultiBarLeftButton",
564
+ "MultiBar5Button",
565
+ "MultiBar6Button",
566
+ "MultiBar7Button"
567
+ }) do
568
+ do
569
+ local index = 1
570
+ while index <= 12 do
571
+ local button = _G[prefix .. tostring(index)]
572
+ if button ~= nil then
573
+ local ____opt_1 = C_ActionBar and C_ActionBar.UnregisterActionUIButton
574
+ if ____opt_1 ~= nil then
575
+ ____opt_1(button)
576
+ end
577
+ end
578
+ index = index + 1
579
+ end
580
+ end
581
+ end
582
+ end
583
+ listener:RegisterEvent("ADDON_LOADED")
584
+ listener:RegisterEvent("PLAYER_ENTERING_WORLD")
585
+ listener:RegisterEvent("PLAYER_REGEN_ENABLED")
586
+ listener:SetScript("OnEvent", apply)
587
+ apply(nil)
588
+ return function()
589
+ listener:UnregisterAllEvents()
590
+ listener:SetScript("OnEvent", nil)
591
+ unhide(nil)
592
+ end
593
+ end
257
594
  function BlizzardUI.Hide(self, options)
258
595
  local names = {}
259
596
  if options.actionBars then
@@ -307,11 +644,11 @@ function BlizzardUI.Hide(self, options)
307
644
  end
308
645
  for ____, name in ipairs(names) do
309
646
  do
310
- local __continue14
647
+ local __continue31
311
648
  repeat
312
649
  local frame = _G[name]
313
650
  if frame == nil then
314
- __continue14 = true
651
+ __continue31 = true
315
652
  break
316
653
  end
317
654
  if not parents:has(frame) then
@@ -331,9 +668,9 @@ function BlizzardUI.Hide(self, options)
331
668
  if frame:GetParent() ~= hidden then
332
669
  frame:SetParent(hidden)
333
670
  end
334
- __continue14 = true
671
+ __continue31 = true
335
672
  until true
336
- if not __continue14 then
673
+ if not __continue31 then
337
674
  break
338
675
  end
339
676
  end
@@ -0,0 +1,15 @@
1
+ import type { Color } from "../types/Color";
2
+ export interface MicroMenuSkinOptions {
3
+ background?: Color;
4
+ border?: Color;
5
+ buttonBackground?: Color;
6
+ icon?: Color;
7
+ accent?: Color;
8
+ disabledIcon?: Color;
9
+ padding?: number;
10
+ panel?: boolean;
11
+ }
12
+ /** Style Forever's existing micro buttons without replacing their scripts or layout.
13
+ * Disposing stops maintenance; reload restores the native textures.
14
+ */
15
+ export declare function skinMicroMenu(options?: MicroMenuSkinOptions): () => void;