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,726 @@
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__NumberIsFinite(value)
36
+ return type(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge
37
+ end
38
+
39
+ local function __TS__NumberIsInteger(value)
40
+ return __TS__NumberIsFinite(value) and math.floor(value) == value
41
+ end
42
+
43
+ local __TS__Symbol, Symbol
44
+ do
45
+ local symbolMetatable = {__tostring = function(self)
46
+ return ("Symbol(" .. (self.description or "")) .. ")"
47
+ end}
48
+ function __TS__Symbol(description)
49
+ return setmetatable({description = description}, symbolMetatable)
50
+ end
51
+ Symbol = {
52
+ asyncDispose = __TS__Symbol("Symbol.asyncDispose"),
53
+ dispose = __TS__Symbol("Symbol.dispose"),
54
+ iterator = __TS__Symbol("Symbol.iterator"),
55
+ hasInstance = __TS__Symbol("Symbol.hasInstance"),
56
+ species = __TS__Symbol("Symbol.species"),
57
+ toStringTag = __TS__Symbol("Symbol.toStringTag")
58
+ }
59
+ end
60
+
61
+ local __TS__Iterator
62
+ do
63
+ local function iteratorGeneratorStep(self)
64
+ local co = self.____coroutine
65
+ local status, value = coroutine.resume(co)
66
+ if not status then
67
+ error(value, 0)
68
+ end
69
+ if coroutine.status(co) == "dead" then
70
+ return
71
+ end
72
+ return true, value
73
+ end
74
+ local function iteratorIteratorStep(self)
75
+ local result = self:next()
76
+ if result.done then
77
+ return
78
+ end
79
+ return true, result.value
80
+ end
81
+ local function iteratorStringStep(self, index)
82
+ index = index + 1
83
+ if index > #self then
84
+ return
85
+ end
86
+ return index, string.sub(self, index, index)
87
+ end
88
+ function __TS__Iterator(iterable)
89
+ if type(iterable) == "string" then
90
+ return iteratorStringStep, iterable, 0
91
+ elseif iterable.____coroutine ~= nil then
92
+ return iteratorGeneratorStep, iterable
93
+ elseif iterable[Symbol.iterator] then
94
+ local iterator = iterable[Symbol.iterator](iterable)
95
+ return iteratorIteratorStep, iterator
96
+ else
97
+ return ipairs(iterable)
98
+ end
99
+ end
100
+ end
101
+
102
+ local Map
103
+ do
104
+ Map = __TS__Class()
105
+ Map.name = "Map"
106
+ function Map.prototype.____constructor(self, entries)
107
+ self[Symbol.toStringTag] = "Map"
108
+ self.items = {}
109
+ self.size = 0
110
+ self.nextKey = {}
111
+ self.previousKey = {}
112
+ if entries == nil then
113
+ return
114
+ end
115
+ local iterable = entries
116
+ if iterable[Symbol.iterator] then
117
+ local iterator = iterable[Symbol.iterator](iterable)
118
+ while true do
119
+ local result = iterator:next()
120
+ if result.done then
121
+ break
122
+ end
123
+ local value = result.value
124
+ self:set(value[1], value[2])
125
+ end
126
+ else
127
+ local array = entries
128
+ for ____, kvp in ipairs(array) do
129
+ self:set(kvp[1], kvp[2])
130
+ end
131
+ end
132
+ end
133
+ function Map.prototype.clear(self)
134
+ self.items = {}
135
+ self.nextKey = {}
136
+ self.previousKey = {}
137
+ self.firstKey = nil
138
+ self.lastKey = nil
139
+ self.size = 0
140
+ end
141
+ function Map.prototype.delete(self, key)
142
+ local contains = self:has(key)
143
+ if contains then
144
+ self.size = self.size - 1
145
+ local next = self.nextKey[key]
146
+ local previous = self.previousKey[key]
147
+ if next ~= nil and previous ~= nil then
148
+ self.nextKey[previous] = next
149
+ self.previousKey[next] = previous
150
+ elseif next ~= nil then
151
+ self.firstKey = next
152
+ self.previousKey[next] = nil
153
+ elseif previous ~= nil then
154
+ self.lastKey = previous
155
+ self.nextKey[previous] = nil
156
+ else
157
+ self.firstKey = nil
158
+ self.lastKey = nil
159
+ end
160
+ self.nextKey[key] = nil
161
+ self.previousKey[key] = nil
162
+ end
163
+ self.items[key] = nil
164
+ return contains
165
+ end
166
+ function Map.prototype.forEach(self, callback)
167
+ for ____, key in __TS__Iterator(self:keys()) do
168
+ callback(nil, self.items[key], key, self)
169
+ end
170
+ end
171
+ function Map.prototype.get(self, key)
172
+ return self.items[key]
173
+ end
174
+ function Map.prototype.has(self, key)
175
+ return self.nextKey[key] ~= nil or self.lastKey == key
176
+ end
177
+ function Map.prototype.set(self, key, value)
178
+ local isNewValue = not self:has(key)
179
+ if isNewValue then
180
+ self.size = self.size + 1
181
+ end
182
+ self.items[key] = value
183
+ if self.firstKey == nil then
184
+ self.firstKey = key
185
+ self.lastKey = key
186
+ elseif isNewValue then
187
+ self.nextKey[self.lastKey] = key
188
+ self.previousKey[key] = self.lastKey
189
+ self.lastKey = key
190
+ end
191
+ return self
192
+ end
193
+ Map.prototype[Symbol.iterator] = function(self)
194
+ return self:entries()
195
+ end
196
+ function Map.prototype.entries(self)
197
+ local function getFirstKey()
198
+ return self.firstKey
199
+ end
200
+ local items = self.items
201
+ local nextKey = self.nextKey
202
+ local key
203
+ local started = false
204
+ return {
205
+ [Symbol.iterator] = function(self)
206
+ return self
207
+ end,
208
+ next = function(self)
209
+ if not started then
210
+ started = true
211
+ key = getFirstKey(nil)
212
+ else
213
+ key = nextKey[key]
214
+ end
215
+ return {done = not key, value = {key, items[key]}}
216
+ end
217
+ }
218
+ end
219
+ function Map.prototype.keys(self)
220
+ local function getFirstKey()
221
+ return self.firstKey
222
+ end
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 = key}
238
+ end
239
+ }
240
+ end
241
+ function Map.prototype.values(self)
242
+ local function getFirstKey()
243
+ return self.firstKey
244
+ end
245
+ local items = self.items
246
+ local nextKey = self.nextKey
247
+ local key
248
+ local started = false
249
+ return {
250
+ [Symbol.iterator] = function(self)
251
+ return self
252
+ end,
253
+ next = function(self)
254
+ if not started then
255
+ started = true
256
+ key = getFirstKey(nil)
257
+ else
258
+ key = nextKey[key]
259
+ end
260
+ return {done = not key, value = items[key]}
261
+ end
262
+ }
263
+ end
264
+ Map[Symbol.species] = Map
265
+ end
266
+
267
+ local function __TS__New(target, ...)
268
+ local instance = setmetatable({}, target.prototype)
269
+ instance:____constructor(...)
270
+ return instance
271
+ end
272
+
273
+ local function __TS__StringIncludes(self, searchString, position)
274
+ if not position then
275
+ position = 1
276
+ else
277
+ position = position + 1
278
+ end
279
+ local index = string.find(self, searchString, position, true)
280
+ return index ~= nil
281
+ end
282
+
283
+ local Error, RangeError, ReferenceError, SyntaxError, TypeError, URIError
284
+ do
285
+ local function getErrorStack(self, constructor)
286
+ if debug == nil then
287
+ return nil
288
+ end
289
+ local level = 1
290
+ while true do
291
+ local info = debug.getinfo(level, "f")
292
+ level = level + 1
293
+ if not info then
294
+ level = 1
295
+ break
296
+ elseif info.func == constructor then
297
+ break
298
+ end
299
+ end
300
+ if __TS__StringIncludes(_VERSION, "Lua 5.0") then
301
+ return debug.traceback(("[Level " .. tostring(level)) .. "]")
302
+ elseif _VERSION == "Lua 5.1" then
303
+ return string.sub(
304
+ debug.traceback("", level),
305
+ 2
306
+ )
307
+ else
308
+ return debug.traceback(nil, level)
309
+ end
310
+ end
311
+ local function wrapErrorToString(self, getDescription)
312
+ return function(self)
313
+ local description = getDescription(self)
314
+ local caller = debug.getinfo(3, "f")
315
+ local isClassicLua = __TS__StringIncludes(_VERSION, "Lua 5.0")
316
+ if isClassicLua or caller and caller.func ~= error then
317
+ return description
318
+ else
319
+ return (description .. "\n") .. tostring(self.stack)
320
+ end
321
+ end
322
+ end
323
+ local function initErrorClass(self, Type, name)
324
+ Type.name = name
325
+ return setmetatable(
326
+ Type,
327
+ {__call = function(____, _self, message) return __TS__New(Type, message) end}
328
+ )
329
+ end
330
+ local ____initErrorClass_1 = initErrorClass
331
+ local ____class_0 = __TS__Class()
332
+ ____class_0.name = ""
333
+ function ____class_0.prototype.____constructor(self, message)
334
+ if message == nil then
335
+ message = ""
336
+ end
337
+ self.message = message
338
+ self.name = "Error"
339
+ self.stack = getErrorStack(nil, __TS__New)
340
+ local metatable = getmetatable(self)
341
+ if metatable and not metatable.__errorToStringPatched then
342
+ metatable.__errorToStringPatched = true
343
+ metatable.__tostring = wrapErrorToString(nil, metatable.__tostring)
344
+ end
345
+ end
346
+ function ____class_0.prototype.__tostring(self)
347
+ return self.message ~= "" and (self.name .. ": ") .. self.message or self.name
348
+ end
349
+ Error = ____initErrorClass_1(nil, ____class_0, "Error")
350
+ local function createErrorClass(self, name)
351
+ local ____initErrorClass_3 = initErrorClass
352
+ local ____class_2 = __TS__Class()
353
+ ____class_2.name = ____class_2.name
354
+ __TS__ClassExtends(____class_2, Error)
355
+ function ____class_2.prototype.____constructor(self, ...)
356
+ ____class_2.____super.prototype.____constructor(self, ...)
357
+ self.name = name
358
+ end
359
+ return ____initErrorClass_3(nil, ____class_2, name)
360
+ end
361
+ RangeError = createErrorClass(nil, "RangeError")
362
+ ReferenceError = createErrorClass(nil, "ReferenceError")
363
+ SyntaxError = createErrorClass(nil, "SyntaxError")
364
+ TypeError = createErrorClass(nil, "TypeError")
365
+ URIError = createErrorClass(nil, "URIError")
366
+ end
367
+
368
+ local function __TS__ObjectGetOwnPropertyDescriptors(object)
369
+ local metatable = getmetatable(object)
370
+ if not metatable then
371
+ return {}
372
+ end
373
+ return rawget(metatable, "_descriptors") or ({})
374
+ end
375
+
376
+ local function __TS__Delete(target, key)
377
+ local descriptors = __TS__ObjectGetOwnPropertyDescriptors(target)
378
+ local descriptor = descriptors[key]
379
+ if descriptor then
380
+ if not descriptor.configurable then
381
+ error(
382
+ __TS__New(
383
+ TypeError,
384
+ ((("Cannot delete property " .. tostring(key)) .. " of ") .. tostring(target)) .. "."
385
+ ),
386
+ 0
387
+ )
388
+ end
389
+ descriptors[key] = nil
390
+ return true
391
+ end
392
+ target[key] = nil
393
+ return true
394
+ end
395
+ -- End of Lua Library inline imports
396
+ local ____exports = {}
397
+ local ____store = require("store.index")
398
+ local Store = ____store.Store
399
+ local StoreRegistry = ____store.StoreRegistry
400
+ local ____BlizzardUI = require("platform.BlizzardUI")
401
+ local BlizzardUI = ____BlizzardUI.BlizzardUI
402
+ local ActionBarBackup = __TS__Class()
403
+ ActionBarBackup.name = "ActionBarBackup"
404
+ __TS__ClassExtends(ActionBarBackup, Store)
405
+ function ActionBarBackup.prototype.____constructor(self, ...)
406
+ Store.prototype.____constructor(self, ...)
407
+ self.phase = "capture"
408
+ self.slots = {}
409
+ end
410
+ ActionBarBackup.Token = "wuira.native-action-bars"
411
+ --- Explicit destructive action-slot operations. Persist Capture() before Clear().
412
+ ____exports.ActionBars = __TS__Class()
413
+ local ActionBars = ____exports.ActionBars
414
+ ActionBars.name = "ActionBars"
415
+ function ActionBars.prototype.____constructor(self)
416
+ end
417
+ function ActionBars.AssertReady(self)
418
+ if InCombatLockdown() then
419
+ error("ActionBars: changes must wait until combat ends")
420
+ end
421
+ local cursor = GetCursorInfo()
422
+ if issecretvalue(cursor) or cursor ~= nil then
423
+ error("ActionBars: clear the cursor before changing action slots")
424
+ end
425
+ end
426
+ function ActionBars.Pickup(self, entry)
427
+ local spell = C_Spell and C_Spell.PickupSpell or PickupSpell
428
+ local item = C_Item and C_Item.PickupItem or PickupItem
429
+ if entry.type == "spell" and spell ~= nil then
430
+ spell(entry.id)
431
+ elseif entry.type == "item" and item ~= nil then
432
+ item(entry.id)
433
+ elseif entry.type == "macro" and PickupMacro ~= nil then
434
+ PickupMacro(entry.id)
435
+ else
436
+ error("ActionBars: unsupported restore API for " .. entry.type)
437
+ end
438
+ end
439
+ function ActionBars.Validate(self, entry)
440
+ if not __TS__NumberIsInteger(entry.slot) or entry.slot < 1 or entry.slot > self.SlotCount or not __TS__NumberIsInteger(entry.id) or entry.id <= 0 then
441
+ error("ActionBars: invalid backup entry")
442
+ end
443
+ if entry.type == "spell" and (C_Spell and C_Spell.PickupSpell or PickupSpell) ~= nil or entry.type == "item" and (C_Item and C_Item.PickupItem or PickupItem) ~= nil or entry.type == "macro" and PickupMacro ~= nil then
444
+ return
445
+ end
446
+ error("ActionBars: cannot safely restore action type " .. entry.type)
447
+ end
448
+ function ActionBars.Capture(self)
449
+ self:AssertReady()
450
+ local entries = {}
451
+ do
452
+ local slot = 1
453
+ while slot <= self.SlotCount do
454
+ do
455
+ local __continue16
456
+ repeat
457
+ local ____type, id, subtype = GetActionInfo(slot)
458
+ if issecretvalue(____type) or issecretvalue(id) or issecretvalue(subtype) then
459
+ error("ActionBars: secret slot data cannot be backed up")
460
+ end
461
+ if ____type == nil then
462
+ __continue16 = true
463
+ break
464
+ end
465
+ if ____type ~= "spell" and ____type ~= "item" and ____type ~= "macro" then
466
+ error(("ActionBars: unsupported action type " .. ____type) .. "; no slots were cleared")
467
+ end
468
+ local entry = {slot = slot, type = ____type, id = id, subtype = subtype}
469
+ self:Validate(entry)
470
+ entries[#entries + 1] = entry
471
+ __continue16 = true
472
+ until true
473
+ if not __continue16 then
474
+ break
475
+ end
476
+ end
477
+ slot = slot + 1
478
+ end
479
+ end
480
+ return entries
481
+ end
482
+ function ActionBars.Clear(self, backup)
483
+ self:AssertReady()
484
+ local current = self:Capture()
485
+ local covered = __TS__New(Map)
486
+ for ____, entry in ipairs(backup) do
487
+ self:Validate(entry)
488
+ covered:set(entry.slot, entry)
489
+ end
490
+ for ____, entry in ipairs(current) do
491
+ local saved = covered:get(entry.slot)
492
+ if saved == nil or saved.type ~= entry.type or saved.id ~= entry.id then
493
+ error("ActionBars: backup does not cover the current slot contents")
494
+ end
495
+ end
496
+ for ____, entry in ipairs(current) do
497
+ PickupAction(entry.slot)
498
+ local remaining = GetActionInfo(entry.slot)
499
+ if issecretvalue(remaining) or remaining ~= nil then
500
+ error("ActionBars: client refused to clear slot " .. tostring(entry.slot))
501
+ end
502
+ ClearCursor()
503
+ end
504
+ end
505
+ function ActionBars.Restore(self, backup)
506
+ self:AssertReady()
507
+ for ____, entry in ipairs(backup) do
508
+ self:Validate(entry)
509
+ local ____type, id = GetActionInfo(entry.slot)
510
+ if issecretvalue(____type) or issecretvalue(id) then
511
+ error("ActionBars: restricted slot cannot be restored")
512
+ end
513
+ if ____type ~= nil and (____type ~= entry.type or id ~= entry.id) then
514
+ error("ActionBars: restore would overwrite slot " .. tostring(entry.slot))
515
+ end
516
+ end
517
+ for ____, entry in ipairs(backup) do
518
+ do
519
+ local __continue34
520
+ repeat
521
+ local ____type = GetActionInfo(entry.slot)
522
+ if ____type ~= nil then
523
+ __continue34 = true
524
+ break
525
+ end
526
+ self:Pickup(entry)
527
+ local cursor = GetCursorInfo()
528
+ if issecretvalue(cursor) or cursor == nil then
529
+ error("ActionBars: client refused to pick up action " .. tostring(entry.id))
530
+ end
531
+ PlaceAction(entry.slot)
532
+ local placedType, placedId = GetActionInfo(entry.slot)
533
+ if issecretvalue(placedType) or issecretvalue(placedId) or placedType ~= entry.type or placedId ~= entry.id then
534
+ error("ActionBars: client refused to restore slot " .. tostring(entry.slot))
535
+ end
536
+ ClearCursor()
537
+ __continue34 = true
538
+ until true
539
+ if not __continue34 then
540
+ break
541
+ end
542
+ end
543
+ end
544
+ end
545
+ function ActionBars.InstallEmptyMode(self, options)
546
+ local store = __TS__New(StoreRegistry, options)
547
+ local listener = CreateFrame("Frame", nil, UIParent)
548
+ local worldReady = false
549
+ local busy = false
550
+ local initialized = false
551
+ local backupPersisted = false
552
+ local disposed = false
553
+ local stopSuppressing
554
+ local stage = "initialization"
555
+ local diagnostics = CreateFrame("Frame", nil, UIParent)
556
+ diagnostics:RegisterEvent("ADDON_ACTION_BLOCKED")
557
+ diagnostics:RegisterEvent("ADDON_ACTION_FORBIDDEN")
558
+ diagnostics:SetScript(
559
+ "OnEvent",
560
+ function(_frame, event, addon, api)
561
+ if busy or addon == options.addon then
562
+ console.error(
563
+ "Action bars:",
564
+ stage,
565
+ event,
566
+ addon,
567
+ api
568
+ )
569
+ end
570
+ end
571
+ )
572
+ local function attempt()
573
+ if disposed or initialized or busy or not worldReady or not store.IsReady or InCombatLockdown() then
574
+ return
575
+ end
576
+ busy = true
577
+ do
578
+ local function ____catch(failure)
579
+ console.error("Action bars:", stage, failure)
580
+ end
581
+ local ____try, ____hasReturned = pcall(function()
582
+ local settings = store:get(ActionBarBackup)
583
+ backupPersisted = settings.phase ~= "capture"
584
+ if settings.phase ~= "restored" and settings.phase ~= "restore" then
585
+ stage = "disable native bars"
586
+ do
587
+ local function ____catch(failure)
588
+ console.error("Native action bar suppression stopped:", failure)
589
+ end
590
+ local ____try, ____hasReturned = pcall(function()
591
+ stopSuppressing = BlizzardUI:DisableActionBars()
592
+ end)
593
+ if not ____try then
594
+ ____catch(____hasReturned)
595
+ end
596
+ end
597
+ end
598
+ stage = "capture backup"
599
+ if settings.phase == "capture" then
600
+ local slots = self:Capture()
601
+ store:set(
602
+ ActionBarBackup,
603
+ function(____, draft)
604
+ draft.slots = slots
605
+ draft.phase = "ready"
606
+ return draft
607
+ end
608
+ )
609
+ console.log(("Action bars backed up. Use /reload to save the backup, then " .. options.clearCommand) .. " outside combat to clear slots.")
610
+ elseif settings.phase == "restore" then
611
+ console.log(("Use " .. options.restoreCommand) .. " outside combat to restore action slots.")
612
+ elseif settings.phase ~= "restored" then
613
+ console.log(("Native action bars disabled. Use " .. options.clearCommand) .. " outside combat to clear their slots.")
614
+ end
615
+ end)
616
+ local ____rethrow
617
+ if not ____try then
618
+ ____try, ____rethrow = pcall(function()
619
+ ____catch(____hasReturned)
620
+ end)
621
+ end
622
+ do
623
+ initialized = true
624
+ listener:UnregisterAllEvents()
625
+ busy = false
626
+ end
627
+ if not ____try then
628
+ error(____rethrow, 0)
629
+ end
630
+ end
631
+ end
632
+ listener:RegisterEvent("PLAYER_ENTERING_WORLD")
633
+ listener:RegisterEvent("PLAYER_REGEN_ENABLED")
634
+ listener:SetScript(
635
+ "OnEvent",
636
+ function(_frame, event)
637
+ if event == "PLAYER_ENTERING_WORLD" then
638
+ worldReady = true
639
+ end
640
+ attempt(nil)
641
+ end
642
+ )
643
+ store:onReady(attempt)
644
+ local clearCommand = "WUIRA_CLEAR_" .. string.upper(options.addon)
645
+ local restoreCommand = "WUIRA_RESTORE_" .. string.upper(options.addon)
646
+ if SlashCmdList[clearCommand] ~= nil or SlashCmdList[restoreCommand] ~= nil then
647
+ error("ActionBars: command already registered")
648
+ end
649
+ local function run(____, restore)
650
+ if disposed or busy then
651
+ return
652
+ end
653
+ if InCombatLockdown() then
654
+ console.warn("Change action bars after combat ends.")
655
+ return
656
+ end
657
+ if not initialized or not store.IsReady or not backupPersisted then
658
+ console.warn("Use /reload to persist the action bar backup first.")
659
+ return
660
+ end
661
+ busy = true
662
+ stage = restore and "restore slots" or "clear slots"
663
+ do
664
+ local function ____catch(failure)
665
+ console.error("Action bars:", stage, failure)
666
+ end
667
+ local ____try, ____hasReturned = pcall(function()
668
+ local settings = store:get(ActionBarBackup)
669
+ if restore then
670
+ self:Restore(settings.slots)
671
+ store:set(
672
+ ActionBarBackup,
673
+ function(____, draft)
674
+ draft.phase = "restored"
675
+ return draft
676
+ end
677
+ )
678
+ console.log("Action slots restored. Use /reload to restore native bar handlers and visibility.")
679
+ else
680
+ self:Clear(settings.slots)
681
+ store:set(
682
+ ActionBarBackup,
683
+ function(____, draft)
684
+ draft.phase = "disabled"
685
+ return draft
686
+ end
687
+ )
688
+ console.log("Native action slots cleared.")
689
+ end
690
+ end)
691
+ local ____rethrow
692
+ if not ____try then
693
+ ____try, ____rethrow = pcall(function()
694
+ ____catch(____hasReturned)
695
+ end)
696
+ end
697
+ do
698
+ busy = false
699
+ end
700
+ if not ____try then
701
+ error(____rethrow, 0)
702
+ end
703
+ end
704
+ end
705
+ _G[("SLASH_" .. clearCommand) .. "1"] = options.clearCommand
706
+ _G[("SLASH_" .. restoreCommand) .. "1"] = options.restoreCommand
707
+ SlashCmdList[clearCommand] = function() return run(nil, false) end
708
+ SlashCmdList[restoreCommand] = function() return run(nil, true) end
709
+ return function()
710
+ disposed = true
711
+ if stopSuppressing ~= nil then
712
+ stopSuppressing(nil)
713
+ end
714
+ store:Dispose()
715
+ listener:UnregisterAllEvents()
716
+ listener:SetScript("OnEvent", nil)
717
+ diagnostics:UnregisterAllEvents()
718
+ diagnostics:SetScript("OnEvent", nil)
719
+ _G[("SLASH_" .. clearCommand) .. "1"] = nil
720
+ _G[("SLASH_" .. restoreCommand) .. "1"] = nil
721
+ __TS__Delete(SlashCmdList, clearCommand)
722
+ __TS__Delete(SlashCmdList, restoreCommand)
723
+ end
724
+ end
725
+ ActionBars.SlotCount = 180
726
+ return ____exports