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
@@ -1,1077 +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__StringIncludes(self, searchString, position)
314
- if not position then
315
- position = 1
316
- else
317
- position = position + 1
318
- end
319
- local index = string.find(self, searchString, position, true)
320
- return index ~= nil
321
- end
322
-
323
- local function __TS__ObjectAssign(target, ...)
324
- local sources = {...}
325
- for i = 1, #sources do
326
- local source = sources[i]
327
- if type(source) == "table" then
328
- for key in pairs(source) do
329
- target[key] = source[key]
330
- end
331
- end
332
- end
333
- return target
334
- end
335
-
336
- local function __TS__ArrayFilter(self, callbackfn, thisArg)
337
- local result = {}
338
- local len = 0
339
- for i = 1, #self do
340
- if callbackfn(thisArg, self[i], i - 1, self) then
341
- len = len + 1
342
- result[len] = self[i]
343
- end
344
- end
345
- return result
346
- end
347
-
348
- local function __TS__ArrayMap(self, callbackfn, thisArg)
349
- local result = {}
350
- for i = 1, #self do
351
- result[i] = callbackfn(thisArg, self[i], i - 1, self)
352
- end
353
- return result
354
- end
355
-
356
- local function __TS__ArraySlice(self, first, last)
357
- local len = #self
358
- first = first or 0
359
- if first < 0 then
360
- first = len + first
361
- if first < 0 then
362
- first = 0
363
- end
364
- else
365
- if first > len then
366
- first = len
367
- end
368
- end
369
- last = last or len
370
- if last < 0 then
371
- last = len + last
372
- if last < 0 then
373
- last = 0
374
- end
375
- else
376
- if last > len then
377
- last = len
378
- end
379
- end
380
- local out = {}
381
- first = first + 1
382
- last = last + 1
383
- local n = 1
384
- while first < last do
385
- out[n] = self[first]
386
- first = first + 1
387
- n = n + 1
388
- end
389
- return out
390
- end
391
-
392
- local function __TS__ArrayFind(self, predicate, thisArg)
393
- for i = 1, #self do
394
- local elem = self[i]
395
- if predicate(thisArg, elem, i - 1, self) then
396
- return elem
397
- end
398
- end
399
- return nil
400
- end
401
-
402
- local Map
403
- do
404
- Map = __TS__Class()
405
- Map.name = "Map"
406
- function Map.prototype.____constructor(self, entries)
407
- self[Symbol.toStringTag] = "Map"
408
- self.items = {}
409
- self.size = 0
410
- self.nextKey = {}
411
- self.previousKey = {}
412
- if entries == nil then
413
- return
414
- end
415
- local iterable = entries
416
- if iterable[Symbol.iterator] then
417
- local iterator = iterable[Symbol.iterator](iterable)
418
- while true do
419
- local result = iterator:next()
420
- if result.done then
421
- break
422
- end
423
- local value = result.value
424
- self:set(value[1], value[2])
425
- end
426
- else
427
- local array = entries
428
- for ____, kvp in ipairs(array) do
429
- self:set(kvp[1], kvp[2])
430
- end
431
- end
432
- end
433
- function Map.prototype.clear(self)
434
- self.items = {}
435
- self.nextKey = {}
436
- self.previousKey = {}
437
- self.firstKey = nil
438
- self.lastKey = nil
439
- self.size = 0
440
- end
441
- function Map.prototype.delete(self, key)
442
- local contains = self:has(key)
443
- if contains then
444
- self.size = self.size - 1
445
- local next = self.nextKey[key]
446
- local previous = self.previousKey[key]
447
- if next ~= nil and previous ~= nil then
448
- self.nextKey[previous] = next
449
- self.previousKey[next] = previous
450
- elseif next ~= nil then
451
- self.firstKey = next
452
- self.previousKey[next] = nil
453
- elseif previous ~= nil then
454
- self.lastKey = previous
455
- self.nextKey[previous] = nil
456
- else
457
- self.firstKey = nil
458
- self.lastKey = nil
459
- end
460
- self.nextKey[key] = nil
461
- self.previousKey[key] = nil
462
- end
463
- self.items[key] = nil
464
- return contains
465
- end
466
- function Map.prototype.forEach(self, callback)
467
- for ____, key in __TS__Iterator(self:keys()) do
468
- callback(nil, self.items[key], key, self)
469
- end
470
- end
471
- function Map.prototype.get(self, key)
472
- return self.items[key]
473
- end
474
- function Map.prototype.has(self, key)
475
- return self.nextKey[key] ~= nil or self.lastKey == key
476
- end
477
- function Map.prototype.set(self, key, value)
478
- local isNewValue = not self:has(key)
479
- if isNewValue then
480
- self.size = self.size + 1
481
- end
482
- self.items[key] = value
483
- if self.firstKey == nil then
484
- self.firstKey = key
485
- self.lastKey = key
486
- elseif isNewValue then
487
- self.nextKey[self.lastKey] = key
488
- self.previousKey[key] = self.lastKey
489
- self.lastKey = key
490
- end
491
- return self
492
- end
493
- Map.prototype[Symbol.iterator] = function(self)
494
- return self:entries()
495
- end
496
- function Map.prototype.entries(self)
497
- local function getFirstKey()
498
- return self.firstKey
499
- end
500
- local items = self.items
501
- local nextKey = self.nextKey
502
- local key
503
- local started = false
504
- return {
505
- [Symbol.iterator] = function(self)
506
- return self
507
- end,
508
- next = function(self)
509
- if not started then
510
- started = true
511
- key = getFirstKey(nil)
512
- else
513
- key = nextKey[key]
514
- end
515
- return {done = not key, value = {key, items[key]}}
516
- end
517
- }
518
- end
519
- function Map.prototype.keys(self)
520
- local function getFirstKey()
521
- return self.firstKey
522
- end
523
- local nextKey = self.nextKey
524
- local key
525
- local started = false
526
- return {
527
- [Symbol.iterator] = function(self)
528
- return self
529
- end,
530
- next = function(self)
531
- if not started then
532
- started = true
533
- key = getFirstKey(nil)
534
- else
535
- key = nextKey[key]
536
- end
537
- return {done = not key, value = key}
538
- end
539
- }
540
- end
541
- function Map.prototype.values(self)
542
- local function getFirstKey()
543
- return self.firstKey
544
- end
545
- local items = self.items
546
- local nextKey = self.nextKey
547
- local key
548
- local started = false
549
- return {
550
- [Symbol.iterator] = function(self)
551
- return self
552
- end,
553
- next = function(self)
554
- if not started then
555
- started = true
556
- key = getFirstKey(nil)
557
- else
558
- key = nextKey[key]
559
- end
560
- return {done = not key, value = items[key]}
561
- end
562
- }
563
- end
564
- Map[Symbol.species] = Map
565
- end
566
-
567
- local __TS__ArrayFrom
568
- do
569
- local function arrayLikeStep(self, index)
570
- index = index + 1
571
- if index > self.length then
572
- return
573
- end
574
- return index, self[index]
575
- end
576
- local function arrayLikeIterator(arr)
577
- if type(arr.length) == "number" then
578
- return arrayLikeStep, arr, 0
579
- end
580
- return __TS__Iterator(arr)
581
- end
582
- function __TS__ArrayFrom(arrayLike, mapFn, thisArg)
583
- local result = {}
584
- if mapFn == nil then
585
- for ____, v in arrayLikeIterator(arrayLike) do
586
- result[#result + 1] = v
587
- end
588
- else
589
- local i = 0
590
- for ____, v in arrayLikeIterator(arrayLike) do
591
- local ____mapFn_3 = mapFn
592
- local ____thisArg_1 = thisArg
593
- local ____v_2 = v
594
- local ____i_0 = i
595
- i = ____i_0 + 1
596
- result[#result + 1] = ____mapFn_3(____thisArg_1, ____v_2, ____i_0)
597
- end
598
- end
599
- return result
600
- end
601
- end
602
-
603
- local function __TS__ArraySort(self, compareFn)
604
- if compareFn ~= nil then
605
- table.sort(
606
- self,
607
- function(a, b) return compareFn(nil, a, b) < 0 end
608
- )
609
- else
610
- table.sort(self)
611
- end
612
- return self
613
- end
614
-
615
- local function __TS__CloneDescriptor(____bindingPattern0)
616
- local value
617
- local writable
618
- local set
619
- local get
620
- local configurable
621
- local enumerable
622
- enumerable = ____bindingPattern0.enumerable
623
- configurable = ____bindingPattern0.configurable
624
- get = ____bindingPattern0.get
625
- set = ____bindingPattern0.set
626
- writable = ____bindingPattern0.writable
627
- value = ____bindingPattern0.value
628
- local descriptor = {enumerable = enumerable == true, configurable = configurable == true}
629
- local hasGetterOrSetter = get ~= nil or set ~= nil
630
- local hasValueOrWritableAttribute = writable ~= nil or value ~= nil
631
- if hasGetterOrSetter and hasValueOrWritableAttribute then
632
- error("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute.", 0)
633
- end
634
- if get or set then
635
- descriptor.get = get
636
- descriptor.set = set
637
- else
638
- descriptor.value = value
639
- descriptor.writable = writable == true
640
- end
641
- return descriptor
642
- end
643
-
644
- local __TS__DescriptorGet
645
- do
646
- local getmetatable = _G.getmetatable
647
- local ____rawget = _G.rawget
648
- function __TS__DescriptorGet(self, metatable, key)
649
- while metatable do
650
- local rawResult = ____rawget(metatable, key)
651
- if rawResult ~= nil then
652
- return rawResult
653
- end
654
- local descriptors = ____rawget(metatable, "_descriptors")
655
- if descriptors then
656
- local descriptor = descriptors[key]
657
- if descriptor ~= nil then
658
- if descriptor.get then
659
- return descriptor.get(self)
660
- end
661
- return descriptor.value
662
- end
663
- end
664
- metatable = getmetatable(metatable)
665
- end
666
- end
667
- end
668
-
669
- local __TS__DescriptorSet
670
- do
671
- local getmetatable = _G.getmetatable
672
- local ____rawget = _G.rawget
673
- local rawset = _G.rawset
674
- function __TS__DescriptorSet(self, metatable, key, value)
675
- while metatable do
676
- local descriptors = ____rawget(metatable, "_descriptors")
677
- if descriptors then
678
- local descriptor = descriptors[key]
679
- if descriptor ~= nil then
680
- if descriptor.set then
681
- descriptor.set(self, value)
682
- else
683
- if descriptor.writable == false then
684
- error(
685
- ((("Cannot assign to read only property '" .. key) .. "' of object '") .. tostring(self)) .. "'",
686
- 0
687
- )
688
- end
689
- descriptor.value = value
690
- end
691
- return
692
- end
693
- end
694
- metatable = getmetatable(metatable)
695
- end
696
- rawset(self, key, value)
697
- end
698
- end
699
-
700
- local __TS__SetDescriptor
701
- do
702
- local getmetatable = _G.getmetatable
703
- local function descriptorIndex(self, key)
704
- return __TS__DescriptorGet(
705
- self,
706
- getmetatable(self),
707
- key
708
- )
709
- end
710
- local function descriptorNewIndex(self, key, value)
711
- return __TS__DescriptorSet(
712
- self,
713
- getmetatable(self),
714
- key,
715
- value
716
- )
717
- end
718
- function __TS__SetDescriptor(target, key, desc, isPrototype)
719
- if isPrototype == nil then
720
- isPrototype = false
721
- end
722
- local ____isPrototype_0
723
- if isPrototype then
724
- ____isPrototype_0 = target
725
- else
726
- ____isPrototype_0 = getmetatable(target)
727
- end
728
- local metatable = ____isPrototype_0
729
- if not metatable then
730
- metatable = {}
731
- setmetatable(target, metatable)
732
- end
733
- if not isPrototype and not rawget(metatable, "_isOwnDescriptorMetatable") then
734
- local instanceMetatable = {}
735
- instanceMetatable._isOwnDescriptorMetatable = true
736
- setmetatable(instanceMetatable, metatable)
737
- setmetatable(target, instanceMetatable)
738
- metatable = instanceMetatable
739
- end
740
- local value = rawget(target, key)
741
- if value ~= nil then
742
- rawset(target, key, nil)
743
- end
744
- if not rawget(metatable, "_descriptors") then
745
- metatable._descriptors = {}
746
- end
747
- metatable._descriptors[key] = __TS__CloneDescriptor(desc)
748
- metatable.__index = descriptorIndex
749
- metatable.__newindex = descriptorNewIndex
750
- end
751
- end
752
- -- End of Lua Library inline imports
753
- local ____exports = {}
754
- local ____DataSource = require("datasources.DataSource")
755
- local DataSource = ____DataSource.DataSource
756
- local ____Source = require("datasources.Source")
757
- local registerSource = ____Source.registerSource
758
- --- Cached learned player spellbook IDs. Native events refresh the snapshot; no polling.
759
- ____exports.KnownSpells = __TS__Class()
760
- local KnownSpells = ____exports.KnownSpells
761
- KnownSpells.name = "KnownSpells"
762
- __TS__ClassExtends(KnownSpells, DataSource)
763
- function KnownSpells.prototype.____constructor(self)
764
- DataSource.prototype.____constructor(self, {})
765
- self.ids = {}
766
- self.entries = {}
767
- self.status = "unavailable"
768
- self.listeners = __TS__New(Set)
769
- self.disposed = false
770
- self.frame = CreateFrame("Frame", nil, UIParent)
771
- for ____, event in ipairs({
772
- "PLAYER_ENTERING_WORLD",
773
- "PLAYER_LEVEL_UP",
774
- "SPELLS_CHANGED",
775
- "LEARNED_SPELL_IN_SKILL_LINE",
776
- "PLAYER_TALENT_UPDATE",
777
- "CHARACTER_POINTS_CHANGED"
778
- }) do
779
- do
780
- pcall(function()
781
- self.frame:RegisterEvent(event)
782
- end)
783
- end
784
- end
785
- self.frame:SetScript(
786
- "OnEvent",
787
- function() return self:Refresh() end
788
- )
789
- self:Refresh()
790
- end
791
- function KnownSpells.prototype.Filter(self, pattern)
792
- if issecretvalue(pattern) or type(pattern) ~= "string" then
793
- error("KnownSpells.Filter requires a public name pattern")
794
- end
795
- local glob = "^"
796
- for ____, character in __TS__Iterator(string.lower(pattern)) do
797
- if character == "*" then
798
- glob = glob .. ".*"
799
- elseif character == "?" then
800
- glob = glob .. "."
801
- else
802
- glob = glob .. (__TS__StringIncludes("^$()%.[]+-", character) and "%" or "") .. character
803
- end
804
- end
805
- glob = glob .. "$"
806
- return __TS__ArrayMap(
807
- __TS__ArrayFilter(
808
- self.entries,
809
- function(____, entry) return entry.name ~= nil and string.match(
810
- string.lower(entry.name),
811
- glob
812
- ) ~= nil end
813
- ),
814
- function(____, entry) return __TS__ObjectAssign({}, entry) end
815
- )
816
- end
817
- function KnownSpells.prototype.GetValue(self)
818
- return __TS__ArraySlice(self.ids)
819
- end
820
- function KnownSpells.prototype.HasSecretFields(self)
821
- return self.status == "restricted"
822
- end
823
- function KnownSpells.prototype.Has(self, spell)
824
- return self:Find(spell) ~= nil
825
- end
826
- function KnownSpells.prototype.Find(self, spell)
827
- if self.status ~= "ready" or issecretvalue(spell) then
828
- return nil
829
- end
830
- local exact = __TS__ArrayFind(
831
- self.entries,
832
- function(____, entry) return entry.id == spell end
833
- )
834
- if exact ~= nil then
835
- return __TS__ObjectAssign({}, exact)
836
- end
837
- local ____temp_4
838
- if type(spell) == "string" then
839
- ____temp_4 = spell
840
- else
841
- local ____opt_0 = C_Spell and C_Spell.GetSpellName
842
- ____temp_4 = ____opt_0 and ____opt_0(spell)
843
- end
844
- local name = ____temp_4
845
- if issecretvalue(name) or name == nil then
846
- return nil
847
- end
848
- local entry = __TS__ArrayFind(
849
- self.entries,
850
- function(____, entry) return entry.name == name end
851
- )
852
- local ____temp_5
853
- if entry == nil then
854
- ____temp_5 = nil
855
- else
856
- ____temp_5 = __TS__ObjectAssign({}, entry)
857
- end
858
- return ____temp_5
859
- end
860
- function KnownSpells.prototype.onChange(self, listener)
861
- if self.disposed then
862
- error("KnownSpells: source is disposed")
863
- end
864
- self.listeners:add(listener)
865
- return function()
866
- self.listeners:delete(listener)
867
- end
868
- end
869
- function KnownSpells.prototype.Refresh(self)
870
- local function signature()
871
- return (self.status .. ":") .. table.concat(
872
- __TS__ArrayMap(
873
- self.entries,
874
- function(____, entry) return (((tostring(entry.id) .. ":") .. (entry.name or "")) .. ":") .. tostring(entry.isPassive) end
875
- ),
876
- "|"
877
- )
878
- end
879
- local previous = signature(nil)
880
- local ids = __TS__New(Set)
881
- local entries = __TS__New(Map)
882
- self.status = "ready"
883
- local function add(____, id, name, passive)
884
- if issecretvalue(id) or issecretvalue(name) then
885
- self.status = "restricted"
886
- return
887
- end
888
- if id == nil or id <= 0 then
889
- return
890
- end
891
- ids:add(id)
892
- local ____name_10 = name
893
- if ____name_10 == nil then
894
- local ____opt_6 = C_Spell and C_Spell.GetSpellName
895
- ____name_10 = ____opt_6 and ____opt_6(id)
896
- end
897
- local resolved = ____name_10
898
- if issecretvalue(resolved) then
899
- self.status = "restricted"
900
- return
901
- end
902
- local ____passive_15 = passive
903
- if ____passive_15 == nil then
904
- local ____opt_11 = C_Spell and C_Spell.IsSpellPassive
905
- ____passive_15 = ____opt_11 and ____opt_11(id)
906
- end
907
- local isPassive = ____passive_15
908
- if issecretvalue(isPassive) then
909
- self.status = "restricted"
910
- return
911
- end
912
- entries:set(id, {id = id, name = resolved, isPassive = isPassive})
913
- end
914
- local book = C_SpellBook
915
- local ____opt_16 = Enum and Enum.SpellBookSpellBank
916
- local bank = ____opt_16 and ____opt_16.Player
917
- local ____opt_20 = Enum and Enum.SpellBookItemType
918
- local spellType = ____opt_20 and ____opt_20.Spell
919
- if (book and book.GetNumSpellBookSkillLines) ~= nil and book.GetSpellBookSkillLineInfo ~= nil and book.GetSpellBookItemInfo ~= nil and bank ~= nil and spellType ~= nil then
920
- local count = book.GetNumSpellBookSkillLines()
921
- if issecretvalue(count) then
922
- self.status = "restricted"
923
- else
924
- do
925
- local line = 1
926
- while line <= count do
927
- do
928
- local __continue40
929
- repeat
930
- local info = book.GetSpellBookSkillLineInfo(line)
931
- if issecretvalue(info) then
932
- self.status = "restricted"
933
- break
934
- end
935
- if info == nil then
936
- __continue40 = true
937
- break
938
- end
939
- if issecretvalue(info.itemIndexOffset) or issecretvalue(info.numSpellBookItems) then
940
- self.status = "restricted"
941
- break
942
- end
943
- do
944
- local slot = info.itemIndexOffset + 1
945
- while slot <= info.itemIndexOffset + info.numSpellBookItems do
946
- do
947
- local __continue45
948
- repeat
949
- local item = book.GetSpellBookItemInfo(slot, bank)
950
- if issecretvalue(item) then
951
- self.status = "restricted"
952
- break
953
- end
954
- if item == nil then
955
- __continue45 = true
956
- break
957
- end
958
- if issecretvalue(item.itemType) or issecretvalue(item.isOffSpec) then
959
- self.status = "restricted"
960
- break
961
- end
962
- if item.itemType == spellType and not item.isOffSpec then
963
- add(nil, item.spellID, item.name, item.isPassive)
964
- end
965
- __continue45 = true
966
- until true
967
- if not __continue45 then
968
- break
969
- end
970
- end
971
- slot = slot + 1
972
- end
973
- end
974
- __continue40 = true
975
- until true
976
- if not __continue40 then
977
- break
978
- end
979
- end
980
- line = line + 1
981
- end
982
- end
983
- end
984
- elseif GetNumSpellTabs ~= nil and GetSpellTabInfo ~= nil and GetSpellBookItemInfo ~= nil then
985
- local count = GetNumSpellTabs()
986
- if issecretvalue(count) then
987
- self.status = "restricted"
988
- else
989
- do
990
- local tab = 1
991
- while tab <= count do
992
- local ____, ____, offset, size = GetSpellTabInfo(tab)
993
- if issecretvalue(offset) or issecretvalue(size) then
994
- self.status = "restricted"
995
- break
996
- end
997
- do
998
- local slot = offset + 1
999
- while slot <= offset + size do
1000
- local kind, id = GetSpellBookItemInfo(slot, "spell")
1001
- if issecretvalue(kind) then
1002
- self.status = "restricted"
1003
- break
1004
- end
1005
- if kind == "SPELL" then
1006
- add(
1007
- nil,
1008
- id,
1009
- nil,
1010
- IsPassiveSpell and IsPassiveSpell(slot, "spell")
1011
- )
1012
- end
1013
- slot = slot + 1
1014
- end
1015
- end
1016
- tab = tab + 1
1017
- end
1018
- end
1019
- end
1020
- else
1021
- self.status = "unavailable"
1022
- end
1023
- self.ids = self.status == "ready" and __TS__ArraySort(
1024
- __TS__ArrayFrom(ids),
1025
- function(____, a, b) return a - b end
1026
- ) or ({})
1027
- self.entries = __TS__ArrayMap(
1028
- self.ids,
1029
- function(____, id) return entries:get(id) end
1030
- )
1031
- local next = signature(nil)
1032
- if next ~= previous and self.status == "ready" and self:CanEmit(self.ids) then
1033
- for ____, listener in __TS__Iterator(self.listeners) do
1034
- listener(
1035
- nil,
1036
- __TS__ArraySlice(self.ids)
1037
- )
1038
- end
1039
- end
1040
- end
1041
- function KnownSpells.prototype.Dispose(self)
1042
- if self.disposed then
1043
- return
1044
- end
1045
- self.disposed = true
1046
- self.frame:UnregisterAllEvents()
1047
- self.frame:SetScript("OnEvent", nil)
1048
- self.frame:Hide()
1049
- self.listeners:clear()
1050
- end;
1051
- (function(self)
1052
- registerSource(
1053
- nil,
1054
- ____exports.KnownSpells,
1055
- function() return __TS__New(____exports.KnownSpells) end
1056
- )
1057
- end)(KnownSpells)
1058
- __TS__SetDescriptor(
1059
- KnownSpells.prototype,
1060
- "Status",
1061
- {get = function(self)
1062
- return self.status
1063
- end},
1064
- true
1065
- )
1066
- __TS__SetDescriptor(
1067
- KnownSpells.prototype,
1068
- "Entries",
1069
- {get = function(self)
1070
- return __TS__ArrayMap(
1071
- self.entries,
1072
- function(____, entry) return __TS__ObjectAssign({}, entry) end
1073
- )
1074
- end},
1075
- true
1076
- )
1077
- return ____exports