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,219 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ -- Lua Library inline imports
3
+ local function __TS__NumberIsFinite(value)
4
+ return type(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge
5
+ end
6
+ -- End of Lua Library inline imports
7
+ local ____exports = {}
8
+ --- Style Forever's existing micro buttons without replacing their scripts or layout.
9
+ -- Disposing stops maintenance; reload restores the native textures.
10
+ function ____exports.skinMicroMenu(self, options)
11
+ if options == nil then
12
+ options = {}
13
+ end
14
+ local background = options.background or ({r = 0.035, g = 0.045, b = 0.065, a = 0.9})
15
+ local border = options.border or ({r = 0.22, g = 0.28, b = 0.36, a = 0.8})
16
+ local buttonBackground = options.buttonBackground or ({r = 0.08, g = 0.1, b = 0.14, a = 0.75})
17
+ local icon = options.icon or ({r = 0.78, g = 0.83, b = 0.9})
18
+ local accent = options.accent or ({r = 0.4, g = 0.75, b = 1})
19
+ local disabledIcon = options.disabledIcon or ({r = 0.35, g = 0.38, b = 0.44})
20
+ local padding = options.padding or 6
21
+ if not __TS__NumberIsFinite(padding) or padding < 0 then
22
+ error("MicroMenu: padding must be a non-negative number")
23
+ end
24
+ local listener = CreateFrame("Frame", nil, UIParent)
25
+ local enabled = true
26
+ local applying = false
27
+ local hooked = false
28
+ local panel
29
+ local function tint(____, texture, color)
30
+ if texture ~= nil then
31
+ texture:SetVertexColor(color.r, color.g, color.b, color.a or 1)
32
+ end
33
+ end
34
+ local function fill(____, texture, color)
35
+ if texture ~= nil then
36
+ texture:SetColorTexture(color.r, color.g, color.b, color.a or 1)
37
+ end
38
+ end
39
+ local apply
40
+ apply = function()
41
+ if not enabled or applying or InCombatLockdown() then
42
+ return
43
+ end
44
+ local menu = _G.MicroMenu
45
+ if menu == nil then
46
+ return
47
+ end
48
+ applying = true
49
+ do
50
+ local ____try, ____error = pcall(function()
51
+ if not hooked and _G.LoadMicroButtonTextures ~= nil then
52
+ hooked = true
53
+ hooksecurefunc(
54
+ "LoadMicroButtonTextures",
55
+ function() return apply(nil) end
56
+ )
57
+ end
58
+ if panel == nil and options.panel ~= false then
59
+ panel = CreateFrame("Frame", nil, menu)
60
+ panel:EnableMouse(false)
61
+ panel:SetFrameLevel(menu:GetFrameLevel())
62
+ panel:SetPoint(
63
+ "TOPLEFT",
64
+ menu,
65
+ "TOPLEFT",
66
+ -padding,
67
+ padding
68
+ )
69
+ panel:SetPoint(
70
+ "BOTTOMRIGHT",
71
+ menu,
72
+ "BOTTOMRIGHT",
73
+ padding,
74
+ -padding
75
+ )
76
+ local bg = panel:CreateTexture(nil, "BACKGROUND")
77
+ bg:SetAllPoints(panel)
78
+ bg:SetColorTexture(background.r, background.g, background.b, background.a or 1)
79
+ for ____, edge in ipairs({"TOP", "BOTTOM", "LEFT", "RIGHT"}) do
80
+ local line = panel:CreateTexture(nil, "OVERLAY")
81
+ line:SetColorTexture(border.r, border.g, border.b, border.a or 1)
82
+ if edge == "TOP" or edge == "BOTTOM" then
83
+ local left = edge == "TOP" and "TOPLEFT" or "BOTTOMLEFT"
84
+ local right = edge == "TOP" and "TOPRIGHT" or "BOTTOMRIGHT"
85
+ line:SetPoint(
86
+ left,
87
+ panel,
88
+ left,
89
+ 0,
90
+ 0
91
+ )
92
+ line:SetPoint(
93
+ right,
94
+ panel,
95
+ right,
96
+ 0,
97
+ 0
98
+ )
99
+ line:SetSize(1, 1)
100
+ else
101
+ local top = edge == "LEFT" and "TOPLEFT" or "TOPRIGHT"
102
+ local bottom = edge == "LEFT" and "BOTTOMLEFT" or "BOTTOMRIGHT"
103
+ line:SetPoint(
104
+ top,
105
+ panel,
106
+ top,
107
+ 0,
108
+ 0
109
+ )
110
+ line:SetPoint(
111
+ bottom,
112
+ panel,
113
+ bottom,
114
+ 0,
115
+ 0
116
+ )
117
+ line:SetSize(1, 1)
118
+ end
119
+ end
120
+ end
121
+ local ____opt_4 = menu.BorderArt
122
+ if ____opt_4 ~= nil then
123
+ ____opt_4:SetAlpha(0)
124
+ end
125
+ local ____opt_6 = menu.BackgroundArt
126
+ if ____opt_6 ~= nil then
127
+ ____opt_6:SetAlpha(0)
128
+ end
129
+ for ____, name in ipairs({
130
+ "CharacterMicroButton",
131
+ "ProfessionMicroButton",
132
+ "SpellbookMicroButton",
133
+ "TalentMicroButton",
134
+ "PlayerSpellsMicroButton",
135
+ "QuestLogMicroButton",
136
+ "GuildMicroButton",
137
+ "LFDMicroButton",
138
+ "LegacyMicroButton",
139
+ "CollectionsMicroButton",
140
+ "EJMicroButton",
141
+ "AchievementMicroButton",
142
+ "HousingMicroButton",
143
+ "StoreMicroButton",
144
+ "MainMenuMicroButton",
145
+ "HelpMicroButton"
146
+ }) do
147
+ do
148
+ local __continue17
149
+ repeat
150
+ local button = _G[name]
151
+ if button == nil then
152
+ __continue17 = true
153
+ break
154
+ end
155
+ fill(nil, button.Background, buttonBackground)
156
+ fill(nil, button.PushedBackground, {r = accent.r * 0.25, g = accent.g * 0.25, b = accent.b * 0.25, a = 0.9})
157
+ local ____opt_8 = button.Shadow
158
+ if ____opt_8 ~= nil then
159
+ ____opt_8:SetAlpha(0)
160
+ end
161
+ local ____opt_10 = button.PushedShadow
162
+ if ____opt_10 ~= nil then
163
+ ____opt_10:SetAlpha(0)
164
+ end
165
+ local ____opt_12 = button.GetNormalTexture
166
+ tint(
167
+ nil,
168
+ ____opt_12 and ____opt_12(button),
169
+ icon
170
+ )
171
+ local ____opt_14 = button.GetPushedTexture
172
+ tint(
173
+ nil,
174
+ ____opt_14 and ____opt_14(button),
175
+ accent
176
+ )
177
+ local ____opt_16 = button.GetHighlightTexture
178
+ tint(
179
+ nil,
180
+ ____opt_16 and ____opt_16(button),
181
+ accent
182
+ )
183
+ local ____opt_18 = button.GetDisabledTexture
184
+ tint(
185
+ nil,
186
+ ____opt_18 and ____opt_18(button),
187
+ disabledIcon
188
+ )
189
+ __continue17 = true
190
+ until true
191
+ if not __continue17 then
192
+ break
193
+ end
194
+ end
195
+ end
196
+ end)
197
+ do
198
+ applying = false
199
+ end
200
+ if not ____try then
201
+ error(____error, 0)
202
+ end
203
+ end
204
+ end
205
+ listener:RegisterEvent("ADDON_LOADED")
206
+ listener:RegisterEvent("PLAYER_ENTERING_WORLD")
207
+ listener:RegisterEvent("PLAYER_REGEN_ENABLED")
208
+ listener:SetScript("OnEvent", apply)
209
+ apply(nil)
210
+ return function()
211
+ enabled = false
212
+ listener:UnregisterAllEvents()
213
+ listener:SetScript("OnEvent", nil)
214
+ if panel ~= nil then
215
+ panel:Hide()
216
+ end
217
+ end
218
+ end
219
+ return ____exports
@@ -0,0 +1,5 @@
1
+ import type { SecureButtonProps } from "../ui/SecureButton";
2
+ export declare function createSecureButton(parent: wuiraNativeFrame, props: SecureButtonProps): wuiraNativeSecureButton;
3
+ /** Validate the whole tree before allocating any protected widgets. */
4
+ export declare function validateSecureButton(props: SecureButtonProps): void;
5
+ export declare function configureSecureButton(frame: wuiraNativeSecureButton, props: SecureButtonProps): () => void;
@@ -0,0 +1,196 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ -- Lua Library inline imports
3
+ local function __TS__ArrayIncludes(self, searchElement, fromIndex)
4
+ if fromIndex == nil then
5
+ fromIndex = 0
6
+ end
7
+ local len = #self
8
+ local k = fromIndex
9
+ if fromIndex < 0 then
10
+ k = len + fromIndex
11
+ end
12
+ if k < 0 then
13
+ k = 0
14
+ end
15
+ for i = k + 1, len do
16
+ if self[i] == searchElement then
17
+ return true
18
+ end
19
+ end
20
+ return false
21
+ end
22
+
23
+ local function __TS__StringTrim(self)
24
+ local result = string.gsub(self, "^[%s ]*(.-)[%s ]*$", "%1")
25
+ return result
26
+ end
27
+
28
+ local function __TS__NumberIsFinite(value)
29
+ return type(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge
30
+ end
31
+
32
+ local function __TS__NumberIsInteger(value)
33
+ return __TS__NumberIsFinite(value) and math.floor(value) == value
34
+ end
35
+
36
+ local function __TS__ArrayIndexOf(self, searchElement, fromIndex)
37
+ if fromIndex == nil then
38
+ fromIndex = 0
39
+ end
40
+ local len = #self
41
+ if len == 0 then
42
+ return -1
43
+ end
44
+ if fromIndex >= len then
45
+ return -1
46
+ end
47
+ if fromIndex < 0 then
48
+ fromIndex = len + fromIndex
49
+ if fromIndex < 0 then
50
+ fromIndex = 0
51
+ end
52
+ end
53
+ for i = fromIndex + 1, len do
54
+ if self[i] == searchElement then
55
+ return i - 1
56
+ end
57
+ end
58
+ return -1
59
+ end
60
+ -- End of Lua Library inline imports
61
+ local ____exports = {}
62
+ function ____exports.createSecureButton(self, parent, props)
63
+ local name
64
+ if props.binding ~= nil then
65
+ local id = type(_G.__wuiraButtonSequence) == "number" and _G.__wuiraButtonSequence or 0
66
+ repeat
67
+ do
68
+ id = id + 1
69
+ name = "WuiraSecureButton" .. tostring(id)
70
+ end
71
+ until not (_G[name] ~= nil)
72
+ _G.__wuiraButtonSequence = id
73
+ end
74
+ return CreateFrame("Button", name, parent, "SecureActionButtonTemplate")
75
+ end
76
+ local buttons = {
77
+ "LeftButton",
78
+ "RightButton",
79
+ "MiddleButton",
80
+ "Button4",
81
+ "Button5"
82
+ }
83
+ --- Validate the whole tree before allocating any protected widgets.
84
+ function ____exports.validateSecureButton(self, props)
85
+ if props.clickThrough ~= nil and props.clickThrough ~= false then
86
+ error("SecureButton cannot be click-through")
87
+ end
88
+ if not __TS__ArrayIncludes(buttons, props.button or "LeftButton") then
89
+ error("SecureButton: unsupported mouse button")
90
+ end
91
+ if props.binding ~= nil and (issecretvalue(props.binding) or type(props.binding) ~= "string" or #__TS__StringTrim(props.binding) == 0) then
92
+ error("SecureButton: binding must be a non-empty key string")
93
+ end
94
+ local function reference(____, value)
95
+ if issecretvalue(value) then
96
+ error("SecureButton: action attributes cannot be secret")
97
+ end
98
+ if type(value) == "number" and __TS__NumberIsInteger(value) and value > 0 then
99
+ return
100
+ end
101
+ if type(value) == "string" and #__TS__StringTrim(value) > 0 then
102
+ return
103
+ end
104
+ error("SecureButton: action reference must be a positive integer or non-empty string")
105
+ end
106
+ local action = props.action
107
+ if action == nil then
108
+ return
109
+ end
110
+ if issecretvalue(action) or type(action) ~= "table" then
111
+ error("SecureButton: invalid action")
112
+ end
113
+ repeat
114
+ local ____switch15 = action.type
115
+ local ____cond15 = ____switch15 == "spell"
116
+ if ____cond15 then
117
+ reference(nil, action.spell)
118
+ break
119
+ end
120
+ ____cond15 = ____cond15 or ____switch15 == "item"
121
+ if ____cond15 then
122
+ reference(nil, action.item)
123
+ break
124
+ end
125
+ ____cond15 = ____cond15 or ____switch15 == "macro"
126
+ if ____cond15 then
127
+ reference(nil, action.macro)
128
+ break
129
+ end
130
+ ____cond15 = ____cond15 or ____switch15 == "action"
131
+ if ____cond15 then
132
+ if issecretvalue(action.slot) or not __TS__NumberIsInteger(action.slot) or action.slot <= 0 then
133
+ error("SecureButton: slot must be a positive integer")
134
+ end
135
+ break
136
+ end
137
+ ____cond15 = ____cond15 or ____switch15 == "target"
138
+ if ____cond15 then
139
+ if action.unit == nil then
140
+ error("SecureButton: target action requires a unit")
141
+ end
142
+ break
143
+ end
144
+ do
145
+ error("SecureButton: unsupported action type")
146
+ end
147
+ until true
148
+ if action.unit ~= nil and action.unit ~= nil then
149
+ if issecretvalue(action.unit) or type(action.unit) ~= "string" or #__TS__StringTrim(action.unit) == 0 then
150
+ error("SecureButton: unit must be a static unit token")
151
+ end
152
+ end
153
+ end
154
+ function ____exports.configureSecureButton(self, frame, props)
155
+ local button = props.button or "LeftButton"
156
+ local suffix = tostring(__TS__ArrayIndexOf(buttons, button) + 1)
157
+ frame:RegisterForClicks(button .. "Up")
158
+ frame:SetAttribute("useOnKeyDown", false)
159
+ frame:SetID(0)
160
+ local action = props.action
161
+ if action ~= nil then
162
+ if action.type == "spell" then
163
+ frame:SetAttribute("spell" .. suffix, action.spell)
164
+ elseif action.type == "item" then
165
+ frame:SetAttribute(
166
+ "item" .. suffix,
167
+ type(action.item) == "number" and "item:" .. tostring(action.item) or action.item
168
+ )
169
+ elseif action.type == "macro" then
170
+ frame:SetAttribute("macro" .. suffix, action.macro)
171
+ elseif action.type == "action" then
172
+ frame:SetAttribute("action" .. suffix, action.slot)
173
+ end
174
+ if action.unit ~= nil then
175
+ frame:SetAttribute("unit" .. suffix, action.unit)
176
+ end
177
+ frame:SetAttribute("type" .. suffix, action.type)
178
+ end
179
+ if props.binding ~= nil then
180
+ SetOverrideBindingClick(
181
+ frame,
182
+ false,
183
+ props.binding,
184
+ frame:GetName(),
185
+ button
186
+ )
187
+ end
188
+ return function()
189
+ if props.binding ~= nil then
190
+ ClearOverrideBindings(frame)
191
+ end
192
+ frame:SetAttribute("type" .. suffix, nil)
193
+ frame:EnableMouse(false)
194
+ end
195
+ end
196
+ return ____exports
@@ -0,0 +1,3 @@
1
+ export type CommandCallback = (this: void, ...args: string[]) => void;
2
+ /** Native slash registration, with an idempotent cleanup and no shared module state. */
3
+ export declare function registerCommand(command: string, callback: CommandCallback): () => void;