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
@@ -1,783 +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 __TS__Symbol, Symbol
36
- do
37
- local symbolMetatable = {__tostring = function(self)
38
- return ("Symbol(" .. (self.description or "")) .. ")"
39
- end}
40
- function __TS__Symbol(description)
41
- return setmetatable({description = description}, symbolMetatable)
42
- end
43
- Symbol = {
44
- asyncDispose = __TS__Symbol("Symbol.asyncDispose"),
45
- dispose = __TS__Symbol("Symbol.dispose"),
46
- iterator = __TS__Symbol("Symbol.iterator"),
47
- hasInstance = __TS__Symbol("Symbol.hasInstance"),
48
- species = __TS__Symbol("Symbol.species"),
49
- toStringTag = __TS__Symbol("Symbol.toStringTag")
50
- }
51
- end
52
-
53
- local __TS__Iterator
54
- do
55
- local function iteratorGeneratorStep(self)
56
- local co = self.____coroutine
57
- local status, value = coroutine.resume(co)
58
- if not status then
59
- error(value, 0)
60
- end
61
- if coroutine.status(co) == "dead" then
62
- return
63
- end
64
- return true, value
65
- end
66
- local function iteratorIteratorStep(self)
67
- local result = self:next()
68
- if result.done then
69
- return
70
- end
71
- return true, result.value
72
- end
73
- local function iteratorStringStep(self, index)
74
- index = index + 1
75
- if index > #self then
76
- return
77
- end
78
- return index, string.sub(self, index, index)
79
- end
80
- function __TS__Iterator(iterable)
81
- if type(iterable) == "string" then
82
- return iteratorStringStep, iterable, 0
83
- elseif iterable.____coroutine ~= nil then
84
- return iteratorGeneratorStep, iterable
85
- elseif iterable[Symbol.iterator] then
86
- local iterator = iterable[Symbol.iterator](iterable)
87
- return iteratorIteratorStep, iterator
88
- else
89
- return ipairs(iterable)
90
- end
91
- end
92
- end
93
-
94
- local function __TS__New(target, ...)
95
- local instance = setmetatable({}, target.prototype)
96
- instance:____constructor(...)
97
- return instance
98
- end
99
-
100
- local Set
101
- do
102
- Set = __TS__Class()
103
- Set.name = "Set"
104
- function Set.prototype.____constructor(self, values)
105
- self[Symbol.toStringTag] = "Set"
106
- self.size = 0
107
- self.nextKey = {}
108
- self.previousKey = {}
109
- if values == nil then
110
- return
111
- end
112
- local iterable = values
113
- if iterable[Symbol.iterator] then
114
- local iterator = iterable[Symbol.iterator](iterable)
115
- while true do
116
- local result = iterator:next()
117
- if result.done then
118
- break
119
- end
120
- self:add(result.value)
121
- end
122
- else
123
- local array = values
124
- for ____, value in ipairs(array) do
125
- self:add(value)
126
- end
127
- end
128
- end
129
- function Set.prototype.add(self, value)
130
- local isNewValue = not self:has(value)
131
- if isNewValue then
132
- self.size = self.size + 1
133
- end
134
- if self.firstKey == nil then
135
- self.firstKey = value
136
- self.lastKey = value
137
- elseif isNewValue then
138
- self.nextKey[self.lastKey] = value
139
- self.previousKey[value] = self.lastKey
140
- self.lastKey = value
141
- end
142
- return self
143
- end
144
- function Set.prototype.clear(self)
145
- self.nextKey = {}
146
- self.previousKey = {}
147
- self.firstKey = nil
148
- self.lastKey = nil
149
- self.size = 0
150
- end
151
- function Set.prototype.delete(self, value)
152
- local contains = self:has(value)
153
- if contains then
154
- self.size = self.size - 1
155
- local next = self.nextKey[value]
156
- local previous = self.previousKey[value]
157
- if next ~= nil and previous ~= nil then
158
- self.nextKey[previous] = next
159
- self.previousKey[next] = previous
160
- elseif next ~= nil then
161
- self.firstKey = next
162
- self.previousKey[next] = nil
163
- elseif previous ~= nil then
164
- self.lastKey = previous
165
- self.nextKey[previous] = nil
166
- else
167
- self.firstKey = nil
168
- self.lastKey = nil
169
- end
170
- self.nextKey[value] = nil
171
- self.previousKey[value] = nil
172
- end
173
- return contains
174
- end
175
- function Set.prototype.forEach(self, callback)
176
- for ____, key in __TS__Iterator(self:keys()) do
177
- callback(nil, key, key, self)
178
- end
179
- end
180
- function Set.prototype.has(self, value)
181
- return self.nextKey[value] ~= nil or self.lastKey == value
182
- end
183
- Set.prototype[Symbol.iterator] = function(self)
184
- return self:values()
185
- end
186
- function Set.prototype.entries(self)
187
- local function getFirstKey()
188
- return self.firstKey
189
- end
190
- local nextKey = self.nextKey
191
- local key
192
- local started = false
193
- return {
194
- [Symbol.iterator] = function(self)
195
- return self
196
- end,
197
- next = function(self)
198
- if not started then
199
- started = true
200
- key = getFirstKey(nil)
201
- else
202
- key = nextKey[key]
203
- end
204
- return {done = not key, value = {key, key}}
205
- end
206
- }
207
- end
208
- function Set.prototype.keys(self)
209
- local function getFirstKey()
210
- return self.firstKey
211
- end
212
- local nextKey = self.nextKey
213
- local key
214
- local started = false
215
- return {
216
- [Symbol.iterator] = function(self)
217
- return self
218
- end,
219
- next = function(self)
220
- if not started then
221
- started = true
222
- key = getFirstKey(nil)
223
- else
224
- key = nextKey[key]
225
- end
226
- return {done = not key, value = key}
227
- end
228
- }
229
- end
230
- function Set.prototype.values(self)
231
- local function getFirstKey()
232
- return self.firstKey
233
- end
234
- local nextKey = self.nextKey
235
- local key
236
- local started = false
237
- return {
238
- [Symbol.iterator] = function(self)
239
- return self
240
- end,
241
- next = function(self)
242
- if not started then
243
- started = true
244
- key = getFirstKey(nil)
245
- else
246
- key = nextKey[key]
247
- end
248
- return {done = not key, value = key}
249
- end
250
- }
251
- end
252
- function Set.prototype.union(self, other)
253
- local result = __TS__New(Set, self)
254
- for ____, item in __TS__Iterator(other) do
255
- result:add(item)
256
- end
257
- return result
258
- end
259
- function Set.prototype.intersection(self, other)
260
- local result = __TS__New(Set)
261
- for ____, item in __TS__Iterator(self) do
262
- if other:has(item) then
263
- result:add(item)
264
- end
265
- end
266
- return result
267
- end
268
- function Set.prototype.difference(self, other)
269
- local result = __TS__New(Set, self)
270
- for ____, item in __TS__Iterator(other) do
271
- result:delete(item)
272
- end
273
- return result
274
- end
275
- function Set.prototype.symmetricDifference(self, other)
276
- local result = __TS__New(Set, self)
277
- for ____, item in __TS__Iterator(other) do
278
- if self:has(item) then
279
- result:delete(item)
280
- else
281
- result:add(item)
282
- end
283
- end
284
- return result
285
- end
286
- function Set.prototype.isSubsetOf(self, other)
287
- for ____, item in __TS__Iterator(self) do
288
- if not other:has(item) then
289
- return false
290
- end
291
- end
292
- return true
293
- end
294
- function Set.prototype.isSupersetOf(self, other)
295
- for ____, item in __TS__Iterator(other) do
296
- if not self:has(item) then
297
- return false
298
- end
299
- end
300
- return true
301
- end
302
- function Set.prototype.isDisjointFrom(self, other)
303
- for ____, item in __TS__Iterator(self) do
304
- if other:has(item) then
305
- return false
306
- end
307
- end
308
- return true
309
- end
310
- Set[Symbol.species] = Set
311
- end
312
-
313
- local function __TS__CloneDescriptor(____bindingPattern0)
314
- local value
315
- local writable
316
- local set
317
- local get
318
- local configurable
319
- local enumerable
320
- enumerable = ____bindingPattern0.enumerable
321
- configurable = ____bindingPattern0.configurable
322
- get = ____bindingPattern0.get
323
- set = ____bindingPattern0.set
324
- writable = ____bindingPattern0.writable
325
- value = ____bindingPattern0.value
326
- local descriptor = {enumerable = enumerable == true, configurable = configurable == true}
327
- local hasGetterOrSetter = get ~= nil or set ~= nil
328
- local hasValueOrWritableAttribute = writable ~= nil or value ~= nil
329
- if hasGetterOrSetter and hasValueOrWritableAttribute then
330
- error("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute.", 0)
331
- end
332
- if get or set then
333
- descriptor.get = get
334
- descriptor.set = set
335
- else
336
- descriptor.value = value
337
- descriptor.writable = writable == true
338
- end
339
- return descriptor
340
- end
341
-
342
- local __TS__DescriptorGet
343
- do
344
- local getmetatable = _G.getmetatable
345
- local ____rawget = _G.rawget
346
- function __TS__DescriptorGet(self, metatable, key)
347
- while metatable do
348
- local rawResult = ____rawget(metatable, key)
349
- if rawResult ~= nil then
350
- return rawResult
351
- end
352
- local descriptors = ____rawget(metatable, "_descriptors")
353
- if descriptors then
354
- local descriptor = descriptors[key]
355
- if descriptor ~= nil then
356
- if descriptor.get then
357
- return descriptor.get(self)
358
- end
359
- return descriptor.value
360
- end
361
- end
362
- metatable = getmetatable(metatable)
363
- end
364
- end
365
- end
366
-
367
- local __TS__DescriptorSet
368
- do
369
- local getmetatable = _G.getmetatable
370
- local ____rawget = _G.rawget
371
- local rawset = _G.rawset
372
- function __TS__DescriptorSet(self, metatable, key, value)
373
- while metatable do
374
- local descriptors = ____rawget(metatable, "_descriptors")
375
- if descriptors then
376
- local descriptor = descriptors[key]
377
- if descriptor ~= nil then
378
- if descriptor.set then
379
- descriptor.set(self, value)
380
- else
381
- if descriptor.writable == false then
382
- error(
383
- ((("Cannot assign to read only property '" .. key) .. "' of object '") .. tostring(self)) .. "'",
384
- 0
385
- )
386
- end
387
- descriptor.value = value
388
- end
389
- return
390
- end
391
- end
392
- metatable = getmetatable(metatable)
393
- end
394
- rawset(self, key, value)
395
- end
396
- end
397
-
398
- local __TS__SetDescriptor
399
- do
400
- local getmetatable = _G.getmetatable
401
- local function descriptorIndex(self, key)
402
- return __TS__DescriptorGet(
403
- self,
404
- getmetatable(self),
405
- key
406
- )
407
- end
408
- local function descriptorNewIndex(self, key, value)
409
- return __TS__DescriptorSet(
410
- self,
411
- getmetatable(self),
412
- key,
413
- value
414
- )
415
- end
416
- function __TS__SetDescriptor(target, key, desc, isPrototype)
417
- if isPrototype == nil then
418
- isPrototype = false
419
- end
420
- local ____isPrototype_0
421
- if isPrototype then
422
- ____isPrototype_0 = target
423
- else
424
- ____isPrototype_0 = getmetatable(target)
425
- end
426
- local metatable = ____isPrototype_0
427
- if not metatable then
428
- metatable = {}
429
- setmetatable(target, metatable)
430
- end
431
- if not isPrototype and not rawget(metatable, "_isOwnDescriptorMetatable") then
432
- local instanceMetatable = {}
433
- instanceMetatable._isOwnDescriptorMetatable = true
434
- setmetatable(instanceMetatable, metatable)
435
- setmetatable(target, instanceMetatable)
436
- metatable = instanceMetatable
437
- end
438
- local value = rawget(target, key)
439
- if value ~= nil then
440
- rawset(target, key, nil)
441
- end
442
- if not rawget(metatable, "_descriptors") then
443
- metatable._descriptors = {}
444
- end
445
- metatable._descriptors[key] = __TS__CloneDescriptor(desc)
446
- metatable.__index = descriptorIndex
447
- metatable.__newindex = descriptorNewIndex
448
- end
449
- end
450
-
451
- local function __TS__NumberIsFinite(value)
452
- return type(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge
453
- end
454
-
455
- local function __TS__NumberIsInteger(value)
456
- return __TS__NumberIsFinite(value) and math.floor(value) == value
457
- end
458
-
459
- local function __TS__ArraySome(self, callbackfn, thisArg)
460
- for i = 1, #self do
461
- if callbackfn(thisArg, self[i], i - 1, self) then
462
- return true
463
- end
464
- end
465
- return false
466
- end
467
- -- End of Lua Library inline imports
468
- local ____exports = {}
469
- local ____DataSource = require("datasources.DataSource")
470
- local DataSource = ____DataSource.DataSource
471
- local ____UnitSource = require("datasources.UnitSource")
472
- local resolveUnit = ____UnitSource.resolveUnit
473
- ____exports.ClassSource = __TS__Class()
474
- local ClassSource = ____exports.ClassSource
475
- ClassSource.name = "ClassSource"
476
- __TS__ClassExtends(ClassSource, DataSource)
477
- function ClassSource.prototype.____constructor(self, unit)
478
- DataSource.prototype.____constructor(self, nil)
479
- self.restricted = false
480
- self.listeners = __TS__New(Set)
481
- self.target = resolveUnit(nil, unit)
482
- end
483
- function ClassSource.prototype.HasSecretFields(self)
484
- return self.restricted
485
- end
486
- function ClassSource.prototype.GetValue(self)
487
- self.restricted = false
488
- local player = UnitIsPlayer(self.unit)
489
- if issecretvalue(player) then
490
- self.restricted = true
491
- return nil
492
- end
493
- if not player then
494
- return nil
495
- end
496
- local name, token, id = UnitClass(self.unit)
497
- if issecretvalue(name) or issecretvalue(token) or issecretvalue(id) then
498
- self.restricted = true
499
- return nil
500
- end
501
- if name == nil or token == nil or id == nil then
502
- return nil
503
- end
504
- return {name = name, token = token, id = id}
505
- end
506
- function ClassSource.prototype.onChange(self, listener)
507
- self.listeners:add(listener)
508
- if self.listeners.size == 1 then
509
- local function refresh()
510
- if not self:IsSecret() then
511
- local value = self.Value
512
- if self:CanEmit(value) then
513
- for ____, callback in __TS__Iterator(self.listeners) do
514
- callback(nil, value)
515
- end
516
- end
517
- end
518
- end
519
- local events = CreateFrame("Frame", nil, UIParent)
520
- self.events = events
521
- for ____, event in ipairs({"UNIT_NAME_UPDATE", "GROUP_ROSTER_UPDATE", "PLAYER_ENTERING_WORLD"}) do
522
- events:RegisterEvent(event)
523
- end
524
- events:SetScript(
525
- "OnEvent",
526
- function(_frame, event, unit)
527
- if event ~= "UNIT_NAME_UPDATE" or not issecretvalue(unit) and unit == self.unit then
528
- refresh(nil)
529
- end
530
- end
531
- )
532
- self.stopUnit = self.target:onChange(refresh)
533
- end
534
- return function()
535
- self.listeners:delete(listener)
536
- if self.listeners.size == 0 then
537
- self:StopListening()
538
- end
539
- end
540
- end
541
- function ClassSource.prototype.StopListening(self)
542
- local ____opt_0 = self.stopUnit
543
- if ____opt_0 ~= nil then
544
- ____opt_0(self)
545
- end
546
- self.stopUnit = nil
547
- local ____opt_2 = self.events
548
- if ____opt_2 ~= nil then
549
- ____opt_2:UnregisterAllEvents()
550
- end
551
- local ____opt_4 = self.events
552
- if ____opt_4 ~= nil then
553
- ____opt_4:SetScript("OnEvent", nil)
554
- end
555
- local ____opt_6 = self.events
556
- if ____opt_6 ~= nil then
557
- ____opt_6:Hide()
558
- end
559
- self.events = nil
560
- end
561
- function ClassSource.prototype.Dispose(self)
562
- self:StopListening()
563
- self.listeners:clear()
564
- end
565
- __TS__SetDescriptor(
566
- ClassSource.prototype,
567
- "unit",
568
- {get = function(self)
569
- return self.target.Token
570
- end},
571
- true
572
- )
573
- --- Own data is read live; other units require an explicit inspect request.
574
- ____exports.SpecSource = __TS__Class()
575
- local SpecSource = ____exports.SpecSource
576
- SpecSource.name = "SpecSource"
577
- __TS__ClassExtends(SpecSource, DataSource)
578
- function SpecSource.prototype.____constructor(self, unit)
579
- DataSource.prototype.____constructor(self, nil)
580
- self.restricted = false
581
- self.status = "idle"
582
- self.target = resolveUnit(nil, unit)
583
- end
584
- function SpecSource.prototype.HasSecretFields(self)
585
- return self.restricted
586
- end
587
- function SpecSource.prototype.GetValue(self)
588
- local player = UnitIsPlayer(self.unit)
589
- if issecretvalue(player) then
590
- self.restricted = true
591
- return nil
592
- end
593
- if not player then
594
- self.restricted = false
595
- return nil
596
- end
597
- local ____self = UnitIsUnit(self.unit, "player")
598
- if issecretvalue(____self) then
599
- self.restricted = true
600
- return nil
601
- end
602
- if ____self then
603
- return self:Read(false)
604
- end
605
- local guid = UnitGUID(self.unit)
606
- if issecretvalue(guid) then
607
- self.restricted = true
608
- return nil
609
- end
610
- if guid == nil or guid ~= self.snapshotGUID then
611
- self.restricted = false
612
- return nil
613
- end
614
- return self.snapshot
615
- end
616
- function SpecSource.prototype.Read(self, inspect)
617
- self.restricted = false
618
- local api = C_SpecializationInfo
619
- if (api and api.GetNumSpecializationsForClassID) == nil or api.GetSpecializationInfo == nil then
620
- self.status = "unsupported"
621
- return nil
622
- end
623
- local classes = __TS__New(____exports.ClassSource, self.target)
624
- if classes:IsSecret() then
625
- self.restricted = true
626
- return nil
627
- end
628
- local info = classes.Value
629
- if info == nil then
630
- return nil
631
- end
632
- local count = api.GetNumSpecializationsForClassID(info.id)
633
- if issecretvalue(count) then
634
- self.restricted = true
635
- return nil
636
- end
637
- if not __TS__NumberIsInteger(count) or count < 0 or count > 32 then
638
- error("Specializations: invalid specialization count")
639
- end
640
- local result = {}
641
- do
642
- local index = 1
643
- while index <= count do
644
- local id, name, _description, icon, role, _stat, pointsSpent = api.GetSpecializationInfo(
645
- index,
646
- inspect,
647
- false,
648
- inspect and self.unit or nil,
649
- nil,
650
- nil,
651
- info.id
652
- )
653
- if __TS__ArraySome(
654
- {
655
- id,
656
- name,
657
- icon,
658
- role,
659
- pointsSpent
660
- },
661
- function(____, value) return issecretvalue(value) end
662
- ) then
663
- self.restricted = true
664
- return nil
665
- end
666
- if id <= 0 then
667
- return nil
668
- end
669
- result[#result + 1] = {
670
- id = id,
671
- name = name,
672
- icon = icon,
673
- role = role,
674
- pointsSpent = pointsSpent
675
- }
676
- index = index + 1
677
- end
678
- end
679
- self.status = "ready"
680
- return result
681
- end
682
- function SpecSource.prototype.RequestInspect(self)
683
- self:Dispose()
684
- self.snapshot = nil
685
- self.snapshotGUID = nil
686
- self.restricted = false
687
- local player = UnitIsPlayer(self.unit)
688
- if issecretvalue(player) then
689
- self.restricted = true
690
- return false
691
- end
692
- if not player then
693
- return false
694
- end
695
- if CanInspect == nil or NotifyInspect == nil or (C_SpecializationInfo and C_SpecializationInfo.GetSpecializationInfo) == nil then
696
- self.status = "unsupported"
697
- return false
698
- end
699
- if InCombatLockdown() then
700
- return false
701
- end
702
- local guid = UnitGUID(self.unit)
703
- if issecretvalue(guid) then
704
- self.restricted = true
705
- return false
706
- end
707
- local allowed = CanInspect(self.unit)
708
- if issecretvalue(allowed) then
709
- self.restricted = true
710
- return false
711
- end
712
- if guid == nil or not allowed then
713
- return false
714
- end
715
- self.snapshotGUID = guid
716
- self.status = "pending"
717
- local listener = CreateFrame("Frame", nil, UIParent)
718
- self.listener = listener
719
- listener:RegisterEvent("INSPECT_READY")
720
- listener:SetScript(
721
- "OnEvent",
722
- function(_frame, _event, inspectedGUID)
723
- if issecretvalue(inspectedGUID) or inspectedGUID ~= guid then
724
- return
725
- end
726
- local current = UnitGUID(self.unit)
727
- if issecretvalue(current) or current ~= guid then
728
- self:Dispose()
729
- return
730
- end
731
- self.snapshot = self:Read(true)
732
- self:StopListening()
733
- if self.status == "pending" then
734
- self.status = "idle"
735
- end
736
- end
737
- )
738
- NotifyInspect(self.unit)
739
- return true
740
- end
741
- function SpecSource.prototype.StopListening(self)
742
- local ____opt_12 = self.listener
743
- if ____opt_12 ~= nil then
744
- ____opt_12:UnregisterAllEvents()
745
- end
746
- local ____opt_14 = self.listener
747
- if ____opt_14 ~= nil then
748
- ____opt_14:SetScript("OnEvent", nil)
749
- end
750
- local ____opt_16 = self.listener
751
- if ____opt_16 ~= nil then
752
- ____opt_16:Hide()
753
- end
754
- self.listener = nil
755
- end
756
- function SpecSource.prototype.Dispose(self)
757
- self:StopListening()
758
- self.status = "idle"
759
- self.snapshot = nil
760
- self.snapshotGUID = nil
761
- end
762
- __TS__SetDescriptor(
763
- SpecSource.prototype,
764
- "unit",
765
- {get = function(self)
766
- return self.target.Token
767
- end},
768
- true
769
- )
770
- __TS__SetDescriptor(
771
- SpecSource.prototype,
772
- "Status",
773
- {get = function(self)
774
- local guid = UnitGUID(self.unit)
775
- if not issecretvalue(guid) and self.snapshotGUID ~= nil and guid ~= self.snapshotGUID then
776
- return "idle"
777
- end
778
- return self.status
779
- end},
780
- true
781
- )
782
- ____exports.Specializations = ____exports.SpecSource
783
- return ____exports