wuira 0.3.3 → 0.4.0

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 (52) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +15 -12
  3. package/docs/source-converters.md +5 -5
  4. package/docs/spells.md +1 -1
  5. package/lib/datasources/NativeApi.d.ts +319 -0
  6. package/lib/datasources/NativeApi.lua +1114 -0
  7. package/lib/datasources/UseSource.d.ts +41 -43
  8. package/lib/datasources/index.d.ts +3 -25
  9. package/lib/datasources/index.lua +45 -74
  10. package/lib/helpers/Auras.d.ts +5 -0
  11. package/lib/helpers/Auras.lua +47 -0
  12. package/lib/helpers/Range.d.ts +2 -0
  13. package/lib/helpers/Range.lua +30 -0
  14. package/lib/helpers/index.d.ts +2 -0
  15. package/lib/helpers/index.lua +12 -0
  16. package/lib/index.d.ts +1 -0
  17. package/lib/index.lua +6 -0
  18. package/lib/platform/forever.d.ts +3 -0
  19. package/lib/rendering/progress.lua +5 -150
  20. package/lib/ui/UnitPortrait.d.ts +1 -2
  21. package/lib/ui/UnitPortrait.lua +11 -18
  22. package/package.json +8 -1
  23. package/lib/datasources/AuraTimer.d.ts +0 -21
  24. package/lib/datasources/AuraTimer.lua +0 -334
  25. package/lib/datasources/Auras.d.ts +0 -32
  26. package/lib/datasources/Auras.lua +0 -300
  27. package/lib/datasources/CastTimer.d.ts +0 -9
  28. package/lib/datasources/CastTimer.lua +0 -255
  29. package/lib/datasources/EditModeLayouts.d.ts +0 -33
  30. package/lib/datasources/EditModeLayouts.lua +0 -698
  31. package/lib/datasources/GroupMembers.d.ts +0 -24
  32. package/lib/datasources/GroupMembers.lua +0 -477
  33. package/lib/datasources/GroupRoster.d.ts +0 -28
  34. package/lib/datasources/GroupRoster.lua +0 -622
  35. package/lib/datasources/KnownSpells.d.ts +0 -33
  36. package/lib/datasources/KnownSpells.lua +0 -1077
  37. package/lib/datasources/ManaRegenTimer.d.ts +0 -29
  38. package/lib/datasources/ManaRegenTimer.lua +0 -683
  39. package/lib/datasources/Resources.d.ts +0 -81
  40. package/lib/datasources/Resources.lua +0 -907
  41. package/lib/datasources/SpellCooldown.d.ts +0 -12
  42. package/lib/datasources/SpellCooldown.lua +0 -240
  43. package/lib/datasources/SpellSource.d.ts +0 -14
  44. package/lib/datasources/SpellSource.lua +0 -236
  45. package/lib/datasources/SwingTimer.d.ts +0 -31
  46. package/lib/datasources/SwingTimer.lua +0 -650
  47. package/lib/datasources/TotemTimer.d.ts +0 -10
  48. package/lib/datasources/TotemTimer.lua +0 -275
  49. package/lib/datasources/UnitInfo.d.ts +0 -51
  50. package/lib/datasources/UnitInfo.lua +0 -801
  51. package/lib/datasources/UnitSource.d.ts +0 -38
  52. package/lib/datasources/UnitSource.lua +0 -613
@@ -29,18 +29,15 @@ local function __TS__ObjectAssign(target, ...)
29
29
  end
30
30
  -- End of Lua Library inline imports
31
31
  local ____exports = {}
32
- local ____UnitSource = require("datasources.UnitSource")
33
- local resolveUnit = ____UnitSource.resolveUnit
34
32
  local ____jsx = require("ui.primitives.jsx")
35
33
  local UI = ____jsx.UI
36
- function ____exports.unitPortrait(self, props, input, crop, preview)
34
+ function ____exports.unitPortrait(self, props, unit, crop, preview)
37
35
  if preview == nil then
38
36
  preview = false
39
37
  end
40
- if issecretvalue(input) or type(input) == "string" and __TS__StringTrim(input) == "" then
38
+ if issecretvalue(unit) or __TS__StringTrim(unit) == "" then
41
39
  error("Unit portrait requires a public unit token", 0)
42
40
  end
43
- local target = resolveUnit(nil, input)
44
41
  return UI:createElement(
45
42
  "cell",
46
43
  __TS__ObjectAssign(
@@ -60,7 +57,7 @@ function ____exports.unitPortrait(self, props, input, crop, preview)
60
57
  local owner = button or host
61
58
  local texture = owner:CreateTexture(nil, "OVERLAY")
62
59
  texture:SetAllPoints(owner)
63
- local buttonUnit = target.Token
60
+ local buttonUnit = unit
64
61
  local stopUnit
65
62
  local stopped = false
66
63
  local stopping = false
@@ -76,7 +73,7 @@ function ____exports.unitPortrait(self, props, input, crop, preview)
76
73
  if stopped or stopping then
77
74
  return
78
75
  end
79
- SetPortraitTexture(texture, target.Token, true)
76
+ SetPortraitTexture(texture, unit, true)
80
77
  local uv = crop or ({0, 1, 0, 1})
81
78
  texture:SetTexCoord(uv[1], uv[2], uv[3], uv[4])
82
79
  end
@@ -103,9 +100,9 @@ function ____exports.unitPortrait(self, props, input, crop, preview)
103
100
  if button == nil or stopped or stopping or InCombatLockdown() then
104
101
  return
105
102
  end
106
- if buttonUnit ~= target.Token then
107
- button:SetAttribute("unit", target.Token)
108
- buttonUnit = target.Token
103
+ if buttonUnit ~= unit then
104
+ button:SetAttribute("unit", unit)
105
+ buttonUnit = unit
109
106
  end
110
107
  if not host:IsVisible() then
111
108
  if button:IsShown() then
@@ -166,7 +163,7 @@ function ____exports.unitPortrait(self, props, input, crop, preview)
166
163
  button:RegisterForClicks("LeftButtonUp", "RightButtonUp")
167
164
  button:SetID(0)
168
165
  button:SetAttribute("useOnKeyDown", false)
169
- button:SetAttribute("unit", target.Token)
166
+ button:SetAttribute("unit", unit)
170
167
  button:SetAttribute("type1", "target")
171
168
  button:SetAttribute("type2", "togglemenu")
172
169
  button:EnableMouse(true)
@@ -187,10 +184,10 @@ function ____exports.unitPortrait(self, props, input, crop, preview)
187
184
  for ____, event in ipairs({"UNIT_PORTRAIT_UPDATE", "UNIT_MODEL_CHANGED", "PORTRAITS_UPDATED", "PLAYER_ENTERING_WORLD"}) do
188
185
  owner:RegisterEvent(event)
189
186
  end
190
- if __TS__StringIncludes(target.Token, "target") then
187
+ if __TS__StringIncludes(unit, "target") then
191
188
  owner:RegisterEvent("PLAYER_TARGET_CHANGED")
192
189
  end
193
- if __TS__StringIncludes(target.Token, "focus") then
190
+ if __TS__StringIncludes(unit, "focus") then
194
191
  owner:RegisterEvent("PLAYER_FOCUS_CHANGED")
195
192
  end
196
193
  owner:SetScript(
@@ -202,15 +199,11 @@ function ____exports.unitPortrait(self, props, input, crop, preview)
202
199
  else
203
200
  sync(nil)
204
201
  end
205
- elseif event ~= "UNIT_PORTRAIT_UPDATE" and event ~= "UNIT_MODEL_CHANGED" or eventUnit == target.Token then
202
+ elseif event ~= "UNIT_PORTRAIT_UPDATE" and event ~= "UNIT_MODEL_CHANGED" or eventUnit == unit then
206
203
  draw(nil)
207
204
  end
208
205
  end
209
206
  )
210
- stopUnit = target:onTokenChange(function()
211
- draw(nil)
212
- sync(nil)
213
- end)
214
207
  draw(nil)
215
208
  sync(nil)
216
209
  end)
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/KerimCETINBAS/wuira.git"
6
6
  },
7
- "version": "0.3.3",
7
+ "version": "0.4.0",
8
8
  "author": {
9
9
  "name": "Kerim Cetinbas",
10
10
  "email": "a.cetinbas@icloud.com"
@@ -54,6 +54,10 @@
54
54
  "./icons": {
55
55
  "types": "./lib/icons/index.d.ts",
56
56
  "default": "./lib/icons/index.lua"
57
+ },
58
+ "./helpers": {
59
+ "types": "./lib/helpers/index.d.ts",
60
+ "default": "./lib/helpers/index.lua"
57
61
  }
58
62
  },
59
63
  "typesVersions": {
@@ -84,6 +88,9 @@
84
88
  ],
85
89
  "icons": [
86
90
  "lib/icons/index.d.ts"
91
+ ],
92
+ "helpers": [
93
+ "lib/helpers/index.d.ts"
87
94
  ]
88
95
  }
89
96
  },
@@ -1,21 +0,0 @@
1
- import { TimerSource } from "./TimerSource";
2
- import { TextureSource } from "./TextureSource";
3
- import { UnitSource } from "./UnitSource";
4
- import type { UnitInput } from "./UnitSource";
5
- export interface AuraTimerOptions {
6
- /** Spell IDs resolve to localized names, so different ranks share a lookup. */
7
- spellIds: readonly number[];
8
- filter?: "HELPFUL" | "HARMFUL" | "HELPFUL|PLAYER" | "HARMFUL|PLAYER";
9
- }
10
- export type AuraTimerStatus = "active" | "inactive" | "restricted" | "unavailable";
11
- /** Selected aura duration and icon; selection policy belongs to the application. */
12
- export declare class AuraTimer extends TimerSource {
13
- private readonly options;
14
- readonly target: UnitSource;
15
- readonly Texture: TextureSource;
16
- private status;
17
- protected constructor(unit: UnitInput, options: AuraTimerOptions);
18
- get Status(): AuraTimerStatus;
19
- private ReadAura;
20
- private ReadDuration;
21
- }
@@ -1,334 +0,0 @@
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__New(target, ...)
36
- local instance = setmetatable({}, target.prototype)
37
- instance:____constructor(...)
38
- return instance
39
- end
40
-
41
- local function __TS__CloneDescriptor(____bindingPattern0)
42
- local value
43
- local writable
44
- local set
45
- local get
46
- local configurable
47
- local enumerable
48
- enumerable = ____bindingPattern0.enumerable
49
- configurable = ____bindingPattern0.configurable
50
- get = ____bindingPattern0.get
51
- set = ____bindingPattern0.set
52
- writable = ____bindingPattern0.writable
53
- value = ____bindingPattern0.value
54
- local descriptor = {enumerable = enumerable == true, configurable = configurable == true}
55
- local hasGetterOrSetter = get ~= nil or set ~= nil
56
- local hasValueOrWritableAttribute = writable ~= nil or value ~= nil
57
- if hasGetterOrSetter and hasValueOrWritableAttribute then
58
- error("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute.", 0)
59
- end
60
- if get or set then
61
- descriptor.get = get
62
- descriptor.set = set
63
- else
64
- descriptor.value = value
65
- descriptor.writable = writable == true
66
- end
67
- return descriptor
68
- end
69
-
70
- local __TS__DescriptorGet
71
- do
72
- local getmetatable = _G.getmetatable
73
- local ____rawget = _G.rawget
74
- function __TS__DescriptorGet(self, metatable, key)
75
- while metatable do
76
- local rawResult = ____rawget(metatable, key)
77
- if rawResult ~= nil then
78
- return rawResult
79
- end
80
- local descriptors = ____rawget(metatable, "_descriptors")
81
- if descriptors then
82
- local descriptor = descriptors[key]
83
- if descriptor ~= nil then
84
- if descriptor.get then
85
- return descriptor.get(self)
86
- end
87
- return descriptor.value
88
- end
89
- end
90
- metatable = getmetatable(metatable)
91
- end
92
- end
93
- end
94
-
95
- local __TS__DescriptorSet
96
- do
97
- local getmetatable = _G.getmetatable
98
- local ____rawget = _G.rawget
99
- local rawset = _G.rawset
100
- function __TS__DescriptorSet(self, metatable, key, value)
101
- while metatable do
102
- local descriptors = ____rawget(metatable, "_descriptors")
103
- if descriptors then
104
- local descriptor = descriptors[key]
105
- if descriptor ~= nil then
106
- if descriptor.set then
107
- descriptor.set(self, value)
108
- else
109
- if descriptor.writable == false then
110
- error(
111
- ((("Cannot assign to read only property '" .. key) .. "' of object '") .. tostring(self)) .. "'",
112
- 0
113
- )
114
- end
115
- descriptor.value = value
116
- end
117
- return
118
- end
119
- end
120
- metatable = getmetatable(metatable)
121
- end
122
- rawset(self, key, value)
123
- end
124
- end
125
-
126
- local __TS__SetDescriptor
127
- do
128
- local getmetatable = _G.getmetatable
129
- local function descriptorIndex(self, key)
130
- return __TS__DescriptorGet(
131
- self,
132
- getmetatable(self),
133
- key
134
- )
135
- end
136
- local function descriptorNewIndex(self, key, value)
137
- return __TS__DescriptorSet(
138
- self,
139
- getmetatable(self),
140
- key,
141
- value
142
- )
143
- end
144
- function __TS__SetDescriptor(target, key, desc, isPrototype)
145
- if isPrototype == nil then
146
- isPrototype = false
147
- end
148
- local ____isPrototype_0
149
- if isPrototype then
150
- ____isPrototype_0 = target
151
- else
152
- ____isPrototype_0 = getmetatable(target)
153
- end
154
- local metatable = ____isPrototype_0
155
- if not metatable then
156
- metatable = {}
157
- setmetatable(target, metatable)
158
- end
159
- if not isPrototype and not rawget(metatable, "_isOwnDescriptorMetatable") then
160
- local instanceMetatable = {}
161
- instanceMetatable._isOwnDescriptorMetatable = true
162
- setmetatable(instanceMetatable, metatable)
163
- setmetatable(target, instanceMetatable)
164
- metatable = instanceMetatable
165
- end
166
- local value = rawget(target, key)
167
- if value ~= nil then
168
- rawset(target, key, nil)
169
- end
170
- if not rawget(metatable, "_descriptors") then
171
- metatable._descriptors = {}
172
- end
173
- metatable._descriptors[key] = __TS__CloneDescriptor(desc)
174
- metatable.__index = descriptorIndex
175
- metatable.__newindex = descriptorNewIndex
176
- end
177
- end
178
- -- End of Lua Library inline imports
179
- local ____exports = {}
180
- local ____TimerSource = require("datasources.TimerSource")
181
- local TimerSource = ____TimerSource.TimerSource
182
- local ____Source = require("datasources.Source")
183
- local registerSource = ____Source.registerSource
184
- local ____UseSource = require("datasources.UseSource")
185
- local UseSource = ____UseSource.UseSource
186
- local ____TextureSource = require("datasources.TextureSource")
187
- local TextureSource = ____TextureSource.TextureSource
188
- local ____UnitSource = require("datasources.UnitSource")
189
- local resolveUnit = ____UnitSource.resolveUnit
190
- --- Selected aura duration and icon; selection policy belongs to the application.
191
- ____exports.AuraTimer = __TS__Class()
192
- local AuraTimer = ____exports.AuraTimer
193
- AuraTimer.name = "AuraTimer"
194
- __TS__ClassExtends(AuraTimer, TimerSource)
195
- function AuraTimer.prototype.____constructor(self, unit, options)
196
- local target = resolveUnit(nil, unit)
197
- local events = {
198
- "UNIT_AURA",
199
- "PLAYER_ENTERING_WORLD",
200
- "PLAYER_TARGET_CHANGED",
201
- "PLAYER_FOCUS_CHANGED",
202
- "SPELLS_CHANGED"
203
- }
204
- TimerSource.prototype.____constructor(
205
- self,
206
- function() return self:ReadDuration() end,
207
- events,
208
- target.Token
209
- )
210
- self.options = options
211
- self.status = "inactive"
212
- self.target = target
213
- self.Texture = UseSource(
214
- nil,
215
- TextureSource,
216
- function()
217
- local ____opt_0 = self:ReadAura()
218
- return ____opt_0 and ____opt_0.icon
219
- end,
220
- events,
221
- target.Token
222
- )
223
- end
224
- function AuraTimer.prototype.ReadAura(self)
225
- local query = C_UnitAuras and C_UnitAuras.GetAuraDataBySpellName
226
- local getName = C_Spell and C_Spell.GetSpellName
227
- if query == nil or getName == nil then
228
- self.status = "unavailable"
229
- return nil
230
- end
231
- do
232
- local function ____catch()
233
- self.status = "unavailable"
234
- end
235
- local ____try, ____hasReturned, ____returnValue = pcall(function()
236
- for ____, id in ipairs(self.options.spellIds) do
237
- do
238
- local __continue8
239
- repeat
240
- local name = getName(id)
241
- if issecretvalue(name) then
242
- self.status = "restricted"
243
- return true, nil
244
- end
245
- if name == nil then
246
- __continue8 = true
247
- break
248
- end
249
- local aura = query(self.target.Token, name, self.options.filter or "HELPFUL")
250
- if issecretvalue(aura) then
251
- self.status = "restricted"
252
- return true, nil
253
- end
254
- if aura ~= nil then
255
- self.status = "active"
256
- return true, aura
257
- end
258
- __continue8 = true
259
- until true
260
- if not __continue8 then
261
- break
262
- end
263
- end
264
- end
265
- local ____opt_6 = C_Secrets and C_Secrets.ShouldAurasBeSecret
266
- local restricted = ____opt_6 and ____opt_6()
267
- self.status = (issecretvalue(restricted) or restricted == true) and "restricted" or "inactive"
268
- end)
269
- if not ____try then
270
- ____hasReturned, ____returnValue = ____catch()
271
- end
272
- if ____hasReturned then
273
- return ____returnValue
274
- end
275
- end
276
- return nil
277
- end
278
- function AuraTimer.prototype.ReadDuration(self)
279
- local aura = self:ReadAura()
280
- if aura == nil then
281
- return nil
282
- end
283
- do
284
- local function ____catch()
285
- self.status = "unavailable"
286
- return true, nil
287
- end
288
- local ____try, ____hasReturned, ____returnValue = pcall(function()
289
- local id = aura.auraInstanceID
290
- if (C_UnitAuras and C_UnitAuras.GetAuraDuration) ~= nil and (issecretvalue(id) or id ~= nil) then
291
- return true, C_UnitAuras.GetAuraDuration(self.target.Token, id)
292
- end
293
- local total = aura.duration
294
- local ____end = aura.expirationTime
295
- if issecretvalue(total) or issecretvalue(____end) then
296
- self.status = "restricted"
297
- return true, nil
298
- end
299
- if total == nil or ____end == nil or total <= 0 then
300
- return true, nil
301
- end
302
- if C_DurationUtil == nil then
303
- self.status = "unavailable"
304
- return true, nil
305
- end
306
- local timer = C_DurationUtil.CreateDuration()
307
- timer:SetTimeFromStart(____end - total, total)
308
- return true, timer
309
- end)
310
- if not ____try then
311
- ____hasReturned, ____returnValue = ____catch()
312
- end
313
- if ____hasReturned then
314
- return ____returnValue
315
- end
316
- end
317
- end;
318
- (function(self)
319
- registerSource(
320
- nil,
321
- ____exports.AuraTimer,
322
- function(____, props) return __TS__New(____exports.AuraTimer, props[1], props[2]) end
323
- )
324
- end)(AuraTimer)
325
- __TS__SetDescriptor(
326
- AuraTimer.prototype,
327
- "Status",
328
- {get = function(self)
329
- self:ReadAura()
330
- return self.status
331
- end},
332
- true
333
- )
334
- return ____exports
@@ -1,32 +0,0 @@
1
- import { DataSource } from "./DataSource";
2
- import { UnitSource } from "./UnitSource";
3
- import type { UnitInput } from "./UnitSource";
4
- export type AuraSourceStatus = "known" | "unknown" | "restricted";
5
- /** Readable aura snapshot. Unit tokens describe the source at snapshot time. */
6
- export declare class Aura {
7
- readonly spellId: number;
8
- readonly name: string;
9
- readonly icon: number;
10
- readonly sourceUnit: string | undefined;
11
- readonly sourceStatus: AuraSourceStatus;
12
- private readonly sourceSelf;
13
- constructor(spellId: number, name: string, icon: number, sourceUnit: string | undefined, sourceStatus: AuraSourceStatus, sourceSelf: boolean | undefined);
14
- /** Undefined means ownership could not be established; it does not mean another caster. */
15
- isSourceSelf(): boolean | undefined;
16
- }
17
- /** Reads a fresh snapshot on access; it does not install listeners or poll. */
18
- export declare abstract class AuraSource extends DataSource<readonly Aura[]> {
19
- private readonly filter;
20
- private restricted;
21
- readonly target: UnitSource;
22
- protected constructor(unit: UnitInput, filter: "HELPFUL" | "HARMFUL");
23
- get unit(): string;
24
- protected HasSecretFields(): boolean;
25
- protected GetValue(): readonly Aura[];
26
- }
27
- export declare class Buffs extends AuraSource {
28
- protected constructor(unit: UnitInput);
29
- }
30
- export declare class Debuffs extends AuraSource {
31
- protected constructor(unit: UnitInput);
32
- }