wuira 0.3.2 → 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 (64) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +27 -9
  3. package/docs/source-converters.md +6 -6
  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/NativeNumberSource.d.ts +1 -1
  8. package/lib/datasources/NativeNumberSource.lua +16 -1
  9. package/lib/datasources/ProgressSource.lua +5 -9
  10. package/lib/datasources/Source.d.ts +18 -0
  11. package/lib/datasources/Source.lua +300 -0
  12. package/lib/datasources/SourceConverter.d.ts +1 -1
  13. package/lib/datasources/SourceConverter.lua +10 -1
  14. package/lib/datasources/TextureSource.d.ts +1 -1
  15. package/lib/datasources/TextureSource.lua +16 -1
  16. package/lib/datasources/TimerSource.d.ts +1 -1
  17. package/lib/datasources/TimerSource.lua +16 -1
  18. package/lib/datasources/UseSource.d.ts +49 -0
  19. package/lib/datasources/UseSource.lua +9 -0
  20. package/lib/datasources/index.d.ts +5 -25
  21. package/lib/datasources/index.lua +49 -69
  22. package/lib/helpers/Auras.d.ts +5 -0
  23. package/lib/helpers/Auras.lua +47 -0
  24. package/lib/helpers/Range.d.ts +2 -0
  25. package/lib/helpers/Range.lua +30 -0
  26. package/lib/helpers/index.d.ts +2 -0
  27. package/lib/helpers/index.lua +12 -0
  28. package/lib/index.d.ts +1 -0
  29. package/lib/index.lua +6 -0
  30. package/lib/platform/forever.d.ts +3 -0
  31. package/lib/rendering/progress.lua +5 -150
  32. package/lib/ui/UnitPortrait.d.ts +1 -2
  33. package/lib/ui/UnitPortrait.lua +11 -18
  34. package/package.json +8 -1
  35. package/lib/datasources/AuraTimer.d.ts +0 -21
  36. package/lib/datasources/AuraTimer.lua +0 -322
  37. package/lib/datasources/Auras.d.ts +0 -32
  38. package/lib/datasources/Auras.lua +0 -284
  39. package/lib/datasources/CastTimer.d.ts +0 -9
  40. package/lib/datasources/CastTimer.lua +0 -240
  41. package/lib/datasources/EditModeLayouts.d.ts +0 -33
  42. package/lib/datasources/EditModeLayouts.lua +0 -689
  43. package/lib/datasources/GroupMembers.d.ts +0 -24
  44. package/lib/datasources/GroupMembers.lua +0 -454
  45. package/lib/datasources/GroupRoster.d.ts +0 -28
  46. package/lib/datasources/GroupRoster.lua +0 -611
  47. package/lib/datasources/KnownSpells.d.ts +0 -33
  48. package/lib/datasources/KnownSpells.lua +0 -1068
  49. package/lib/datasources/ManaRegenTimer.d.ts +0 -29
  50. package/lib/datasources/ManaRegenTimer.lua +0 -674
  51. package/lib/datasources/Resources.d.ts +0 -60
  52. package/lib/datasources/Resources.lua +0 -824
  53. package/lib/datasources/SpellCooldown.d.ts +0 -12
  54. package/lib/datasources/SpellCooldown.lua +0 -218
  55. package/lib/datasources/SpellSource.d.ts +0 -14
  56. package/lib/datasources/SpellSource.lua +0 -224
  57. package/lib/datasources/SwingTimer.d.ts +0 -31
  58. package/lib/datasources/SwingTimer.lua +0 -641
  59. package/lib/datasources/TotemTimer.d.ts +0 -10
  60. package/lib/datasources/TotemTimer.lua +0 -260
  61. package/lib/datasources/UnitInfo.d.ts +0 -51
  62. package/lib/datasources/UnitInfo.lua +0 -783
  63. package/lib/datasources/UnitSource.d.ts +0 -38
  64. package/lib/datasources/UnitSource.lua +0 -602
@@ -8,91 +8,71 @@ do
8
8
  local ____SourceConverter = require("datasources.SourceConverter")
9
9
  ____exports.SourceConverter = ____SourceConverter.SourceConverter
10
10
  end
11
- do
12
- local ____EditModeLayouts = require("datasources.EditModeLayouts")
13
- ____exports.EditModeLayouts = ____EditModeLayouts.EditModeLayouts
14
- end
15
11
  do
16
12
  local ____ProgressSource = require("datasources.ProgressSource")
17
13
  ____exports.ProgressSource = ____ProgressSource.ProgressSource
18
14
  end
19
15
  do
20
- local ____Resources = require("datasources.Resources")
21
- ____exports.HP = ____Resources.HP
22
- ____exports.Mana = ____Resources.Mana
23
- ____exports.Unit = ____Resources.Unit
24
- ____exports.DataSources = ____Resources.DataSources
25
- ____exports.HealthPrediction = ____Resources.HealthPrediction
26
- end
27
- do
28
- local ____Auras = require("datasources.Auras")
29
- ____exports.Aura = ____Auras.Aura
30
- ____exports.AuraSource = ____Auras.AuraSource
31
- ____exports.Buffs = ____Auras.Buffs
32
- ____exports.Debuffs = ____Auras.Debuffs
33
- end
34
- do
35
- local ____GroupMembers = require("datasources.GroupMembers")
36
- ____exports.GroupMembers = ____GroupMembers.GroupMembers
37
- ____exports.PartyMembers = ____GroupMembers.PartyMembers
38
- ____exports.RaidMembers = ____GroupMembers.RaidMembers
39
- end
40
- do
41
- local ____GroupRoster = require("datasources.GroupRoster")
42
- ____exports.GroupRoster = ____GroupRoster.GroupRoster
43
- ____exports.getPetUnitToken = ____GroupRoster.getPetUnitToken
44
- end
45
- do
46
- local ____UnitInfo = require("datasources.UnitInfo")
47
- ____exports.ClassSource = ____UnitInfo.ClassSource
48
- ____exports.SpecSource = ____UnitInfo.SpecSource
49
- ____exports.Specializations = ____UnitInfo.Specializations
50
- end
51
- do
52
- local ____UnitSource = require("datasources.UnitSource")
53
- ____exports.UnitSource = ____UnitSource.UnitSource
54
- ____exports.resolveUnit = ____UnitSource.resolveUnit
16
+ local ____Source = require("datasources.Source")
17
+ ____exports.Source = ____Source.Source
55
18
  end
56
19
  do
57
- local ____SwingTimer = require("datasources.SwingTimer")
58
- ____exports.SwingTimer = ____SwingTimer.SwingTimer
59
- ____exports.SwingHand = ____SwingTimer.SwingHand
20
+ local ____UseSource = require("datasources.UseSource")
21
+ ____exports.UseSource = ____UseSource.UseSource
60
22
  end
61
23
  do
62
24
  local ____TimerSource = require("datasources.TimerSource")
63
25
  ____exports.TimerSource = ____TimerSource.TimerSource
64
26
  end
65
- do
66
- local ____TotemTimer = require("datasources.TotemTimer")
67
- ____exports.TotemTimer = ____TotemTimer.TotemTimer
68
- end
69
27
  do
70
28
  local ____TextureSource = require("datasources.TextureSource")
71
29
  ____exports.TextureSource = ____TextureSource.TextureSource
72
30
  end
73
31
  do
74
- local ____CastTimer = require("datasources.CastTimer")
75
- ____exports.CastTimer = ____CastTimer.CastTimer
76
- end
77
- do
78
- local ____AuraTimer = require("datasources.AuraTimer")
79
- ____exports.AuraTimer = ____AuraTimer.AuraTimer
80
- end
81
- do
82
- local ____SpellCooldown = require("datasources.SpellCooldown")
83
- ____exports.SpellCooldown = ____SpellCooldown.SpellCooldown
84
- ____exports.GlobalCooldown = ____SpellCooldown.GlobalCooldown
85
- end
86
- do
87
- local ____SpellSource = require("datasources.SpellSource")
88
- ____exports.SpellSource = ____SpellSource.SpellSource
89
- end
90
- do
91
- local ____KnownSpells = require("datasources.KnownSpells")
92
- ____exports.KnownSpells = ____KnownSpells.KnownSpells
93
- end
94
- do
95
- local ____ManaRegenTimer = require("datasources.ManaRegenTimer")
96
- ____exports.ManaRegenTimer = ____ManaRegenTimer.ManaRegenTimer
32
+ local ____NativeNumberSource = require("datasources.NativeNumberSource")
33
+ ____exports.NativeNumberSource = ____NativeNumberSource.NativeNumberSource
34
+ end
35
+ do
36
+ local ____NativeApi = require("datasources.NativeApi")
37
+ ____exports.GetAuraDataByIndex = ____NativeApi.GetAuraDataByIndex
38
+ ____exports.GetAuraDataBySpellName = ____NativeApi.GetAuraDataBySpellName
39
+ ____exports.GetAuraDuration = ____NativeApi.GetAuraDuration
40
+ ____exports.GetLayouts = ____NativeApi.GetLayouts
41
+ ____exports.GetNumGroupMembers = ____NativeApi.GetNumGroupMembers
42
+ ____exports.GetNumSpellBookSkillLines = ____NativeApi.GetNumSpellBookSkillLines
43
+ ____exports.GetNumSpecializationsForClassID = ____NativeApi.GetNumSpecializationsForClassID
44
+ ____exports.GetNumSpellTabs = ____NativeApi.GetNumSpellTabs
45
+ ____exports.GetNumTotemSlots = ____NativeApi.GetNumTotemSlots
46
+ ____exports.GetRaidRosterInfo = ____NativeApi.GetRaidRosterInfo
47
+ ____exports.GetSpecializationInfo = ____NativeApi.GetSpecializationInfo
48
+ ____exports.GetSpellBookItemInfo = ____NativeApi.GetSpellBookItemInfo
49
+ ____exports.GetSpellBookSkillLineInfo = ____NativeApi.GetSpellBookSkillLineInfo
50
+ ____exports.GetSpellCooldownDuration = ____NativeApi.GetSpellCooldownDuration
51
+ ____exports.GetSpellName = ____NativeApi.GetSpellName
52
+ ____exports.GetSpellPowerCost = ____NativeApi.GetSpellPowerCost
53
+ ____exports.GetSpellTabInfo = ____NativeApi.GetSpellTabInfo
54
+ ____exports.GetSpellTexture = ____NativeApi.GetSpellTexture
55
+ ____exports.GetTotemDuration = ____NativeApi.GetTotemDuration
56
+ ____exports.GetTotemInfo = ____NativeApi.GetTotemInfo
57
+ ____exports.IsInRaid = ____NativeApi.IsInRaid
58
+ ____exports.IsSpellPassive = ____NativeApi.IsSpellPassive
59
+ ____exports.UnitCastingDuration = ____NativeApi.UnitCastingDuration
60
+ ____exports.UnitCastingInfo = ____NativeApi.UnitCastingInfo
61
+ ____exports.UnitChannelDuration = ____NativeApi.UnitChannelDuration
62
+ ____exports.UnitChannelInfo = ____NativeApi.UnitChannelInfo
63
+ ____exports.UnitClass = ____NativeApi.UnitClass
64
+ ____exports.UnitExists = ____NativeApi.UnitExists
65
+ ____exports.UnitFullName = ____NativeApi.UnitFullName
66
+ ____exports.UnitGUID = ____NativeApi.UnitGUID
67
+ ____exports.UnitGetIncomingHeals = ____NativeApi.UnitGetIncomingHeals
68
+ ____exports.UnitGetTotalAbsorbs = ____NativeApi.UnitGetTotalAbsorbs
69
+ ____exports.UnitHealth = ____NativeApi.UnitHealth
70
+ ____exports.UnitHealthMax = ____NativeApi.UnitHealthMax
71
+ ____exports.UnitHealthPercent = ____NativeApi.UnitHealthPercent
72
+ ____exports.UnitIsPlayer = ____NativeApi.UnitIsPlayer
73
+ ____exports.UnitIsUnit = ____NativeApi.UnitIsUnit
74
+ ____exports.UnitPower = ____NativeApi.UnitPower
75
+ ____exports.UnitPowerMax = ____NativeApi.UnitPowerMax
76
+ ____exports.UnitPowerPercent = ____NativeApi.UnitPowerPercent
97
77
  end
98
78
  return ____exports
@@ -0,0 +1,5 @@
1
+ import type { AuraData } from "../datasources/NativeApi";
2
+ /** Walks `GetAuraDataByIndex` until the API returns no row. This client does not return the list itself. */
3
+ export declare function ReadAuras(unit: string, filter: string): AuraData[];
4
+ /** True when the current list contains the spell id or the aura name. */
5
+ export declare function FilterAura(auras: readonly AuraData[], spell: string | number): boolean;
@@ -0,0 +1,47 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____exports = {}
3
+ --- Walks `GetAuraDataByIndex` until the API returns no row. This client does not return the list itself.
4
+ function ____exports.ReadAuras(self, unit, filter)
5
+ local read = C_UnitAuras and C_UnitAuras.GetAuraDataByIndex
6
+ if read == nil then
7
+ error("ReadAuras: this client does not expose C_UnitAuras.GetAuraDataByIndex")
8
+ end
9
+ local result = {}
10
+ do
11
+ local index = 1
12
+ while index <= 1024 do
13
+ local aura = read(unit, index, filter)
14
+ if issecretvalue(aura) or aura ~= nil and (issecretvalue(aura.spellId) or issecretvalue(aura.name) or issecretvalue(aura.icon)) then
15
+ error("ReadAuras: secret data cannot be read")
16
+ end
17
+ if aura == nil then
18
+ return result
19
+ end
20
+ result[#result + 1] = aura
21
+ index = index + 1
22
+ end
23
+ end
24
+ error("ReadAuras: aura enumeration exceeded its safety limit")
25
+ end
26
+ --- True when the current list contains the spell id or the aura name.
27
+ function ____exports.FilterAura(self, auras, spell)
28
+ if issecretvalue(spell) or type(spell) ~= "string" and type(spell) ~= "number" then
29
+ error("FilterAura expects a public spell id or name")
30
+ end
31
+ for ____, aura in ipairs(auras) do
32
+ if issecretvalue(aura) or issecretvalue(aura.spellId) or issecretvalue(aura.name) then
33
+ error("FilterAura: secret data cannot be read")
34
+ end
35
+ local ____temp_2
36
+ if type(spell) == "number" then
37
+ ____temp_2 = aura.spellId == spell
38
+ else
39
+ ____temp_2 = aura.name == spell
40
+ end
41
+ if ____temp_2 then
42
+ return true
43
+ end
44
+ end
45
+ return false
46
+ end
47
+ return ____exports
@@ -0,0 +1,2 @@
1
+ /** Inclusive integer span. `Range(1, 5)` is `[1, 2, 3, 4, 5]`. An inverted span is empty. */
2
+ export declare function Range(from: number, to: number): number[];
@@ -0,0 +1,30 @@
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
+
7
+ local function __TS__NumberIsInteger(value)
8
+ return __TS__NumberIsFinite(value) and math.floor(value) == value
9
+ end
10
+ -- End of Lua Library inline imports
11
+ local ____exports = {}
12
+ --- Inclusive integer span. `Range(1, 5)` is `[1, 2, 3, 4, 5]`. An inverted span is empty.
13
+ function ____exports.Range(self, from, to)
14
+ if issecretvalue(from) or issecretvalue(to) or type(from) ~= "number" or type(to) ~= "number" or not __TS__NumberIsInteger(from) or not __TS__NumberIsInteger(to) then
15
+ error("Range expects public integers")
16
+ end
17
+ local values = {}
18
+ if to < from then
19
+ return values
20
+ end
21
+ do
22
+ local value = from
23
+ while value <= to do
24
+ values[#values + 1] = value
25
+ value = value + 1
26
+ end
27
+ end
28
+ return values
29
+ end
30
+ return ____exports
@@ -0,0 +1,2 @@
1
+ export { Range } from "./Range";
2
+ export { FilterAura, ReadAuras } from "./Auras";
@@ -0,0 +1,12 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____exports = {}
3
+ do
4
+ local ____Range = require("helpers.Range")
5
+ ____exports.Range = ____Range.Range
6
+ end
7
+ do
8
+ local ____Auras = require("helpers.Auras")
9
+ ____exports.FilterAura = ____Auras.FilterAura
10
+ ____exports.ReadAuras = ____Auras.ReadAuras
11
+ end
12
+ return ____exports
package/lib/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /// <reference path="./platform/forever.d.ts" />
2
2
  import "./console-polyfill";
3
+ export { FilterAura, Range, ReadAuras } from "./helpers";
3
4
  export { Wuira, wuira } from "./wuira";
4
5
  export { WuiraApp } from "./WuiraApp";
5
6
  export type { CommandCallback } from "./platform/SlashCommands";
package/lib/index.lua CHANGED
@@ -1,6 +1,12 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
3
  require("console-polyfill")
4
+ do
5
+ local ____helpers = require("helpers.index")
6
+ ____exports.FilterAura = ____helpers.FilterAura
7
+ ____exports.Range = ____helpers.Range
8
+ ____exports.ReadAuras = ____helpers.ReadAuras
9
+ end
4
10
  do
5
11
  local ____wuira = require("wuira")
6
12
  ____exports.Wuira = ____wuira.Wuira
@@ -144,6 +144,9 @@ interface wuiraNativeAuraData {
144
144
  expirationTime?: number;
145
145
  }
146
146
  declare const C_UnitAuras: {
147
+ GetAuraDataByIndex?: (this: void, unit: string, index: number, filter: string) => {
148
+ spellId: number; name: string; icon: number; sourceUnit?: string;
149
+ } | undefined;
147
150
  GetAuraDataBySpellName?: (this: void, unit: string, name: string, filter: string) => wuiraNativeAuraData | undefined;
148
151
  GetAuraDuration?: (this: void, unit: string, id: number) => import("../datasources/TimerSource").NativeDuration | undefined;
149
152
  } | undefined;
@@ -1,58 +1,5 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
- -- Lua Library inline imports
3
- local __TS__Symbol, Symbol
4
- do
5
- local symbolMetatable = {__tostring = function(self)
6
- return ("Symbol(" .. (self.description or "")) .. ")"
7
- end}
8
- function __TS__Symbol(description)
9
- return setmetatable({description = description}, symbolMetatable)
10
- end
11
- Symbol = {
12
- asyncDispose = __TS__Symbol("Symbol.asyncDispose"),
13
- dispose = __TS__Symbol("Symbol.dispose"),
14
- iterator = __TS__Symbol("Symbol.iterator"),
15
- hasInstance = __TS__Symbol("Symbol.hasInstance"),
16
- species = __TS__Symbol("Symbol.species"),
17
- toStringTag = __TS__Symbol("Symbol.toStringTag")
18
- }
19
- end
20
-
21
- local function __TS__InstanceOf(obj, classTbl)
22
- if type(classTbl) ~= "table" then
23
- error("Right-hand side of 'instanceof' is not an object", 0)
24
- end
25
- if classTbl[Symbol.hasInstance] ~= nil then
26
- return not not classTbl[Symbol.hasInstance](classTbl, obj)
27
- end
28
- if type(obj) == "table" then
29
- local luaClass = obj.constructor
30
- while luaClass ~= nil do
31
- if luaClass == classTbl then
32
- return true
33
- end
34
- luaClass = luaClass.____super
35
- end
36
- end
37
- return false
38
- end
39
-
40
- local function __TS__ObjectAssign(target, ...)
41
- local sources = {...}
42
- for i = 1, #sources do
43
- local source = sources[i]
44
- if type(source) == "table" then
45
- for key in pairs(source) do
46
- target[key] = source[key]
47
- end
48
- end
49
- end
50
- return target
51
- end
52
- -- End of Lua Library inline imports
53
2
  local ____exports = {}
54
- local ____Resources = require("datasources.Resources")
55
- local HP = ____Resources.HP
56
3
  local ____statusBarTextures = require("ui.decorations.statusBarTextures")
57
4
  local applyStatusBarTexture = ____statusBarTextures.applyStatusBarTexture
58
5
  local resolveStatusBarTexture = ____statusBarTextures.resolveStatusBarTexture
@@ -97,105 +44,13 @@ function ____exports.renderProgress(self, item, tree, onActiveChange)
97
44
  ____bar_SetReverseFill_19(bar, ____props_reverse_18)
98
45
  bar:SetMinMaxValues(props.min or 0, props.max or 100)
99
46
  local source = item.cell.source or props.source
100
- if source ~= nil then
101
- local healPredictionBar
102
- local absorbPredictionBar
103
- if __TS__InstanceOf(source, HP) then
104
- local function overlay(____, style, heal)
105
- bar:SetClipsChildren(true)
106
- local layer = CreateFrame("StatusBar", nil, bar)
107
- local ____tree_frames_20 = tree.frames
108
- ____tree_frames_20[#____tree_frames_20 + 1] = layer
109
- layer:EnableMouse(false)
110
- layer:SetFrameLevel(bar:GetFrameLevel())
111
- layer:SetSize(item.width, item.height)
112
- applyStatusBarTexture(
113
- nil,
114
- layer,
115
- resolveStatusBarTexture(nil, style.texture or "solid")
116
- )
117
- local tint = style.color
118
- layer:SetStatusBarColor(tint.r, tint.g, tint.b, tint.a or 0.5)
119
- local texture = layer:GetStatusBarTexture()
120
- texture:SetBlendMode(style.blendMode or "BLEND")
121
- local ____texture_SetHorizTile_22 = texture.SetHorizTile
122
- local ____style_tileX_21 = style.tileX
123
- if ____style_tileX_21 == nil then
124
- ____style_tileX_21 = false
125
- end
126
- ____texture_SetHorizTile_22(texture, ____style_tileX_21)
127
- local ____texture_SetVertTile_24 = texture.SetVertTile
128
- local ____style_tileY_23 = style.tileY
129
- if ____style_tileY_23 == nil then
130
- ____style_tileY_23 = false
131
- end
132
- ____texture_SetVertTile_24(texture, ____style_tileY_23)
133
- local uv = style.texCoords or ({0, 1, 0, 1})
134
- texture:SetTexCoord(uv[1], uv[2], uv[3], uv[4])
135
- local vertical = props.orientation == "vertical"
136
- local ____props_reverse_25 = props.reverse
137
- if ____props_reverse_25 == nil then
138
- ____props_reverse_25 = false
139
- end
140
- local reverse = ____props_reverse_25
141
- layer:SetOrientation(vertical and "VERTICAL" or "HORIZONTAL")
142
- local ____layer_SetReverseFill_27 = layer.SetReverseFill
143
- local ____heal_26
144
- if heal then
145
- ____heal_26 = reverse
146
- else
147
- ____heal_26 = not reverse
148
- end
149
- ____layer_SetReverseFill_27(layer, ____heal_26)
150
- if heal then
151
- local point = vertical and (reverse and "TOPLEFT" or "BOTTOMLEFT") or (reverse and "TOPRIGHT" or "TOPLEFT")
152
- local relative = vertical and (reverse and "BOTTOMLEFT" or "TOPLEFT") or (reverse and "TOPLEFT" or "TOPRIGHT")
153
- layer:SetPoint(
154
- point,
155
- bar:GetStatusBarTexture(),
156
- relative,
157
- 0,
158
- 0
159
- )
160
- else
161
- layer:SetAllPoints(bar)
162
- end
163
- return layer
164
- end
165
- local ____opt_28 = source.HealPrediction
166
- if (____opt_28 and ____opt_28.IsAvailable) == true and props.healPrediction ~= false then
167
- local ____props_healPrediction_32 = props.healPrediction
168
- local ____opt_30 = props.healPrediction
169
- healPredictionBar = overlay(
170
- nil,
171
- __TS__ObjectAssign({}, ____props_healPrediction_32, {color = ____opt_30 and ____opt_30.color or ({r = 0.4, g = 1, b = 0.5, a = 0.5})}),
172
- true
173
- )
174
- end
175
- local ____opt_33 = source.AbsorbPrediction
176
- if (____opt_33 and ____opt_33.IsAvailable) == true and props.absorbPrediction ~= false then
177
- local ____props_absorbPrediction_37 = props.absorbPrediction
178
- local ____opt_35 = props.absorbPrediction
179
- absorbPredictionBar = overlay(
180
- nil,
181
- __TS__ObjectAssign({}, ____props_absorbPrediction_37, {color = ____opt_35 and ____opt_35.color or ({r = 0.8, g = 0.9, b = 1, a = 0.55})}),
182
- false
183
- )
184
- end
185
- end
186
- local dispose = source:BindTo(bar, {
187
- min = props.min,
188
- max = props.max,
189
- current = props.current or props.value,
190
- onActiveChange = onActiveChange,
191
- healPredictionBar = healPredictionBar,
192
- absorbPredictionBar = absorbPredictionBar
193
- })
47
+ if source ~= nil and source.BindTo ~= nil then
48
+ local dispose = source:BindTo(bar, {min = props.min, max = props.max, current = props.current or props.value, onActiveChange = onActiveChange})
194
49
  if dispose ~= nil then
195
- local ____tree_bindings_38 = tree.bindings
196
- ____tree_bindings_38[#____tree_bindings_38 + 1] = dispose
50
+ local ____tree_bindings_20 = tree.bindings
51
+ ____tree_bindings_20[#____tree_bindings_20 + 1] = dispose
197
52
  end
198
- else
53
+ elseif source == nil then
199
54
  bar:SetValue(props.current or props.value or 0)
200
55
  end
201
56
  end
@@ -1,3 +1,2 @@
1
- import type { UnitInput } from "../datasources/UnitSource";
2
1
  import type { CellProps } from "./Cell";
3
- export declare function unitPortrait(props: Partial<CellProps>, input: UnitInput, crop?: readonly number[], preview?: boolean): import("./primitives/jsx").Element;
2
+ export declare function unitPortrait(props: Partial<CellProps>, unit: string, crop?: readonly number[], preview?: boolean): import("./primitives/jsx").Element;
@@ -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.2",
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
- constructor(unit: UnitInput, options: AuraTimerOptions);
18
- get Status(): AuraTimerStatus;
19
- private ReadAura;
20
- private ReadDuration;
21
- }