wuira 0.3.0 → 0.3.3
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.
- package/CHANGELOG.md +32 -0
- package/README.md +20 -5
- package/docs/source-converters.md +5 -5
- package/lib/datasources/AuraTimer.d.ts +1 -1
- package/lib/datasources/AuraTimer.lua +14 -2
- package/lib/datasources/Auras.d.ts +2 -2
- package/lib/datasources/Auras.lua +18 -2
- package/lib/datasources/CastTimer.d.ts +1 -1
- package/lib/datasources/CastTimer.lua +16 -1
- package/lib/datasources/EditModeLayouts.d.ts +1 -1
- package/lib/datasources/EditModeLayouts.lua +10 -1
- package/lib/datasources/GroupMembers.d.ts +3 -3
- package/lib/datasources/GroupMembers.lua +26 -3
- package/lib/datasources/GroupRoster.d.ts +1 -1
- package/lib/datasources/GroupRoster.lua +19 -8
- package/lib/datasources/KnownSpells.d.ts +1 -1
- package/lib/datasources/KnownSpells.lua +10 -1
- package/lib/datasources/ManaRegenTimer.d.ts +1 -1
- package/lib/datasources/ManaRegenTimer.lua +10 -1
- package/lib/datasources/NativeNumberSource.d.ts +1 -1
- package/lib/datasources/NativeNumberSource.lua +16 -1
- package/lib/datasources/ProgressSource.lua +5 -9
- package/lib/datasources/Resources.d.ts +35 -14
- package/lib/datasources/Resources.lua +141 -58
- package/lib/datasources/Source.d.ts +18 -0
- package/lib/datasources/Source.lua +300 -0
- package/lib/datasources/SourceConverter.d.ts +1 -1
- package/lib/datasources/SourceConverter.lua +10 -1
- package/lib/datasources/SpellCooldown.d.ts +2 -2
- package/lib/datasources/SpellCooldown.lua +24 -2
- package/lib/datasources/SpellSource.d.ts +1 -1
- package/lib/datasources/SpellSource.lua +15 -3
- package/lib/datasources/SwingTimer.d.ts +1 -1
- package/lib/datasources/SwingTimer.lua +10 -1
- package/lib/datasources/TextureSource.d.ts +1 -1
- package/lib/datasources/TextureSource.lua +16 -1
- package/lib/datasources/TimerSource.d.ts +1 -1
- package/lib/datasources/TimerSource.lua +16 -1
- package/lib/datasources/TotemTimer.d.ts +1 -1
- package/lib/datasources/TotemTimer.lua +16 -1
- package/lib/datasources/UnitInfo.d.ts +2 -2
- package/lib/datasources/UnitInfo.lua +21 -3
- package/lib/datasources/UnitSource.d.ts +1 -1
- package/lib/datasources/UnitSource.lua +13 -2
- package/lib/datasources/UseSource.d.ts +51 -0
- package/lib/datasources/UseSource.lua +9 -0
- package/lib/datasources/index.d.ts +3 -1
- package/lib/datasources/index.lua +10 -1
- package/lib/platform/forever.d.ts +2 -1
- package/lib/rendering/layout.lua +2 -2
- package/lib/rendering/progress.lua +11 -5
- package/lib/rendering/widgets.lua +8 -1
- package/lib/ui/Cell.d.ts +1 -1
- package/lib/ui/FlowLayout.d.ts +16 -4
- package/lib/ui/GridLayout.d.ts +10 -1
- package/lib/ui/ScrollHost.lua +9 -4
- package/lib/ui/decorations/backgroundTextures.d.ts +2 -22
- package/lib/ui/decorations/backgroundTextures.lua +3 -7
- package/lib/ui/decorations/borderTextures.d.ts +2 -37
- package/lib/ui/decorations/borderTextures.lua +3 -9
- package/lib/ui/decorations/statusBarTextures.d.ts +5 -12
- package/lib/ui/decorations/statusBarTextures.lua +83 -4
- package/lib/ui/index.d.ts +5 -0
- package/lib/ui/index.lua +15 -0
- package/lib/ui/layout/calculateFlow.d.ts +16 -4
- package/lib/ui/layout/calculateFlow.lua +153 -46
- package/lib/ui/layout/calculateGrid.d.ts +6 -5
- package/lib/ui/layout/calculateGrid.lua +80 -6
- package/lib/ui/layout/measureLayout.lua +118 -39
- package/lib/ui/media/clientMedia.d.ts +177 -0
- package/lib/ui/media/clientMedia.lua +49 -0
- package/lib/ui/overlayGlow.d.ts +21 -0
- package/lib/ui/overlayGlow.lua +350 -0
- package/package.json +1 -1
|
@@ -487,10 +487,13 @@ local ProgressSource = ____ProgressSource.ProgressSource
|
|
|
487
487
|
local ____UnitSource = require("datasources.UnitSource")
|
|
488
488
|
local Unit = ____UnitSource.Unit
|
|
489
489
|
local resolveUnit = ____UnitSource.resolveUnit
|
|
490
|
-
local ____DataSource = require("datasources.DataSource")
|
|
491
|
-
local DataSource = ____DataSource.DataSource
|
|
492
490
|
local ____ManaRegenTimer = require("datasources.ManaRegenTimer")
|
|
493
491
|
local ManaRegenTimer = ____ManaRegenTimer.ManaRegenTimer
|
|
492
|
+
local ____Source = require("datasources.Source")
|
|
493
|
+
local Source = ____Source.Source
|
|
494
|
+
local registerSource = ____Source.registerSource
|
|
495
|
+
local ____UseSource = require("datasources.UseSource")
|
|
496
|
+
local UseSource = ____UseSource.UseSource
|
|
494
497
|
do
|
|
495
498
|
local ____UnitSource = require("datasources.UnitSource")
|
|
496
499
|
____exports.Unit = ____UnitSource.Unit
|
|
@@ -621,24 +624,24 @@ end
|
|
|
621
624
|
function Resource.prototype.Listen(self, _frame, refresh)
|
|
622
625
|
return self:Observe(function() return refresh(nil) end)
|
|
623
626
|
end
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
__TS__ClassExtends(HealthPrediction, DataSource)
|
|
629
|
-
function HealthPrediction.prototype.____constructor(self, read)
|
|
630
|
-
DataSource.prototype.____constructor(self, 0)
|
|
631
|
-
self.read = read
|
|
632
|
-
end
|
|
633
|
-
function HealthPrediction.prototype.GetValue(self)
|
|
634
|
-
local ____opt_9 = self.read
|
|
635
|
-
local value = ____opt_9 and ____opt_9(self)
|
|
627
|
+
local function unitToken(self, unit)
|
|
628
|
+
return type(unit) == "string" and unit or unit.Token
|
|
629
|
+
end
|
|
630
|
+
local function nativeAmount(self, value)
|
|
636
631
|
if issecretvalue(value) then
|
|
637
632
|
return value
|
|
638
633
|
end
|
|
639
634
|
return value or 0
|
|
640
635
|
end
|
|
641
|
-
|
|
636
|
+
--- One optional unit amount. A missing native function stays unavailable and is never called.
|
|
637
|
+
local UnitAmount = __TS__Class()
|
|
638
|
+
UnitAmount.name = "UnitAmount"
|
|
639
|
+
__TS__ClassExtends(UnitAmount, Source)
|
|
640
|
+
function UnitAmount.prototype.____constructor(self, unit)
|
|
641
|
+
Source.prototype.____constructor(self, 0, unit)
|
|
642
|
+
self.target = resolveUnit(nil, unit)
|
|
643
|
+
end
|
|
644
|
+
function UnitAmount.prototype.ApplyTo(self, frame, maximum)
|
|
642
645
|
if not self.IsAvailable then
|
|
643
646
|
frame:Hide()
|
|
644
647
|
return
|
|
@@ -653,13 +656,70 @@ function HealthPrediction.prototype.ApplyTo(self, frame, maximum)
|
|
|
653
656
|
frame:Show()
|
|
654
657
|
end
|
|
655
658
|
__TS__SetDescriptor(
|
|
656
|
-
|
|
659
|
+
UnitAmount.prototype,
|
|
657
660
|
"IsAvailable",
|
|
658
661
|
{get = function(self)
|
|
659
|
-
return self.read ~= nil
|
|
660
662
|
end},
|
|
661
663
|
true
|
|
662
664
|
)
|
|
665
|
+
--- Total absorbs on a unit. `UnitGetTotalAbsorbs`.
|
|
666
|
+
____exports.Absorb = __TS__Class()
|
|
667
|
+
local Absorb = ____exports.Absorb
|
|
668
|
+
Absorb.name = "Absorb"
|
|
669
|
+
__TS__ClassExtends(Absorb, UnitAmount)
|
|
670
|
+
function Absorb.prototype.____constructor(self, unit)
|
|
671
|
+
UnitAmount.prototype.____constructor(self, unit)
|
|
672
|
+
end
|
|
673
|
+
function Absorb.prototype.read(self, props)
|
|
674
|
+
return UnitGetTotalAbsorbs == nil and 0 or nativeAmount(
|
|
675
|
+
nil,
|
|
676
|
+
UnitGetTotalAbsorbs(unitToken(nil, props[1]))
|
|
677
|
+
)
|
|
678
|
+
end
|
|
679
|
+
__TS__SetDescriptor(
|
|
680
|
+
Absorb.prototype,
|
|
681
|
+
"IsAvailable",
|
|
682
|
+
{get = function(self)
|
|
683
|
+
return UnitGetTotalAbsorbs ~= nil
|
|
684
|
+
end},
|
|
685
|
+
true
|
|
686
|
+
);
|
|
687
|
+
(function(self)
|
|
688
|
+
registerSource(
|
|
689
|
+
nil,
|
|
690
|
+
____exports.Absorb,
|
|
691
|
+
function(____, props) return __TS__New(____exports.Absorb, props[1]) end
|
|
692
|
+
)
|
|
693
|
+
end)(Absorb)
|
|
694
|
+
--- Incoming heals on a unit. `UnitGetIncomingHeals`.
|
|
695
|
+
____exports.Prediction = __TS__Class()
|
|
696
|
+
local Prediction = ____exports.Prediction
|
|
697
|
+
Prediction.name = "Prediction"
|
|
698
|
+
__TS__ClassExtends(Prediction, UnitAmount)
|
|
699
|
+
function Prediction.prototype.____constructor(self, unit)
|
|
700
|
+
UnitAmount.prototype.____constructor(self, unit)
|
|
701
|
+
end
|
|
702
|
+
function Prediction.prototype.read(self, props)
|
|
703
|
+
return UnitGetIncomingHeals == nil and 0 or nativeAmount(
|
|
704
|
+
nil,
|
|
705
|
+
UnitGetIncomingHeals(unitToken(nil, props[1]))
|
|
706
|
+
)
|
|
707
|
+
end
|
|
708
|
+
__TS__SetDescriptor(
|
|
709
|
+
Prediction.prototype,
|
|
710
|
+
"IsAvailable",
|
|
711
|
+
{get = function(self)
|
|
712
|
+
return UnitGetIncomingHeals ~= nil
|
|
713
|
+
end},
|
|
714
|
+
true
|
|
715
|
+
);
|
|
716
|
+
(function(self)
|
|
717
|
+
registerSource(
|
|
718
|
+
nil,
|
|
719
|
+
____exports.Prediction,
|
|
720
|
+
function(____, props) return __TS__New(____exports.Prediction, props[1]) end
|
|
721
|
+
)
|
|
722
|
+
end)(Prediction)
|
|
663
723
|
____exports.HP = __TS__Class()
|
|
664
724
|
local HP = ____exports.HP
|
|
665
725
|
HP.name = "HP"
|
|
@@ -679,38 +739,30 @@ function HP.prototype.____constructor(self, unit)
|
|
|
679
739
|
)
|
|
680
740
|
self.target = target
|
|
681
741
|
end
|
|
682
|
-
function HP.prototype.
|
|
683
|
-
if self.
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
____temp_11 = nil
|
|
688
|
-
else
|
|
689
|
-
____temp_11 = function() return UnitGetIncomingHeals(self.unit) end
|
|
690
|
-
end
|
|
691
|
-
self.healPrediction = __TS__New(____exports_HealthPrediction_12, ____temp_11)
|
|
692
|
-
if self.healPrediction.IsAvailable then
|
|
693
|
-
self:AddEvents("UNIT_HEAL_PREDICTION")
|
|
742
|
+
function HP.prototype.UseAbsorb(self)
|
|
743
|
+
if self.absorb == nil then
|
|
744
|
+
self.absorb = UseSource(nil, ____exports.Absorb, self.target)
|
|
745
|
+
if self.absorb.IsAvailable then
|
|
746
|
+
self:AddEvents("UNIT_ABSORB_AMOUNT_CHANGED")
|
|
694
747
|
end
|
|
695
748
|
end
|
|
696
749
|
return self
|
|
697
750
|
end
|
|
698
|
-
function HP.prototype.
|
|
699
|
-
if self.
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
____temp_13 = nil
|
|
704
|
-
else
|
|
705
|
-
____temp_13 = function() return UnitGetTotalAbsorbs(self.unit) end
|
|
706
|
-
end
|
|
707
|
-
self.absorbPrediction = __TS__New(____exports_HealthPrediction_14, ____temp_13)
|
|
708
|
-
if self.absorbPrediction.IsAvailable then
|
|
709
|
-
self:AddEvents("UNIT_ABSORB_AMOUNT_CHANGED")
|
|
751
|
+
function HP.prototype.UsePrediction(self)
|
|
752
|
+
if self.prediction == nil then
|
|
753
|
+
self.prediction = UseSource(nil, ____exports.Prediction, self.target)
|
|
754
|
+
if self.prediction.IsAvailable then
|
|
755
|
+
self:AddEvents("UNIT_HEAL_PREDICTION")
|
|
710
756
|
end
|
|
711
757
|
end
|
|
712
758
|
return self
|
|
713
759
|
end
|
|
760
|
+
function HP.prototype.UseAbsorbPrediction(self)
|
|
761
|
+
return self:UseAbsorb()
|
|
762
|
+
end
|
|
763
|
+
function HP.prototype.UseHealPrediction(self)
|
|
764
|
+
return self:UsePrediction()
|
|
765
|
+
end
|
|
714
766
|
function HP.prototype.BindTo(self, frame, options)
|
|
715
767
|
if options == nil then
|
|
716
768
|
options = {}
|
|
@@ -728,23 +780,23 @@ function HP.prototype.BindTo(self, frame, options)
|
|
|
728
780
|
if options.healPredictionBar ~= nil or options.absorbPredictionBar ~= nil then
|
|
729
781
|
local maximum = UnitHealthMax(self.unit)
|
|
730
782
|
if options.healPredictionBar ~= nil then
|
|
731
|
-
local
|
|
732
|
-
if
|
|
733
|
-
|
|
783
|
+
local ____opt_9 = self.prediction
|
|
784
|
+
if ____opt_9 ~= nil then
|
|
785
|
+
____opt_9:ApplyTo(options.healPredictionBar, maximum)
|
|
734
786
|
end
|
|
735
787
|
end
|
|
736
788
|
if options.absorbPredictionBar ~= nil then
|
|
737
|
-
local
|
|
738
|
-
if
|
|
739
|
-
|
|
789
|
+
local ____opt_11 = self.absorb
|
|
790
|
+
if ____opt_11 ~= nil then
|
|
791
|
+
____opt_11:ApplyTo(options.absorbPredictionBar, maximum)
|
|
740
792
|
end
|
|
741
793
|
end
|
|
742
794
|
end
|
|
743
|
-
local
|
|
744
|
-
|
|
745
|
-
local
|
|
746
|
-
if
|
|
747
|
-
|
|
795
|
+
local ____this_14
|
|
796
|
+
____this_14 = options
|
|
797
|
+
local ____opt_13 = ____this_14.onRefresh
|
|
798
|
+
if ____opt_13 ~= nil then
|
|
799
|
+
____opt_13(____this_14)
|
|
748
800
|
end
|
|
749
801
|
end}
|
|
750
802
|
)
|
|
@@ -752,9 +804,17 @@ function HP.prototype.BindTo(self, frame, options)
|
|
|
752
804
|
end
|
|
753
805
|
__TS__SetDescriptor(
|
|
754
806
|
HP.prototype,
|
|
755
|
-
"
|
|
807
|
+
"Absorb",
|
|
808
|
+
{get = function(self)
|
|
809
|
+
return self.absorb
|
|
810
|
+
end},
|
|
811
|
+
true
|
|
812
|
+
)
|
|
813
|
+
__TS__SetDescriptor(
|
|
814
|
+
HP.prototype,
|
|
815
|
+
"Prediction",
|
|
756
816
|
{get = function(self)
|
|
757
|
-
return self.
|
|
817
|
+
return self.prediction
|
|
758
818
|
end},
|
|
759
819
|
true
|
|
760
820
|
)
|
|
@@ -762,7 +822,15 @@ __TS__SetDescriptor(
|
|
|
762
822
|
HP.prototype,
|
|
763
823
|
"AbsorbPrediction",
|
|
764
824
|
{get = function(self)
|
|
765
|
-
return self.
|
|
825
|
+
return self.absorb
|
|
826
|
+
end},
|
|
827
|
+
true
|
|
828
|
+
)
|
|
829
|
+
__TS__SetDescriptor(
|
|
830
|
+
HP.prototype,
|
|
831
|
+
"HealPrediction",
|
|
832
|
+
{get = function(self)
|
|
833
|
+
return self.prediction
|
|
766
834
|
end},
|
|
767
835
|
true
|
|
768
836
|
)
|
|
@@ -773,7 +841,14 @@ __TS__SetDescriptor(
|
|
|
773
841
|
return self.target.Token
|
|
774
842
|
end},
|
|
775
843
|
true
|
|
776
|
-
)
|
|
844
|
+
);
|
|
845
|
+
(function(self)
|
|
846
|
+
registerSource(
|
|
847
|
+
nil,
|
|
848
|
+
____exports.HP,
|
|
849
|
+
function(____, props) return __TS__New(____exports.HP, props[1]) end
|
|
850
|
+
)
|
|
851
|
+
end)(HP)
|
|
777
852
|
--- Explicit mana (power type 0), even while the unit uses rage/energy.
|
|
778
853
|
____exports.Mana = __TS__Class()
|
|
779
854
|
local Mana = ____exports.Mana
|
|
@@ -797,7 +872,8 @@ function Mana.prototype.UseRegenTimer(self)
|
|
|
797
872
|
end
|
|
798
873
|
if self.regenTimer == nil then
|
|
799
874
|
self:AddEvents("UNIT_SPELLCAST_SUCCEEDED")
|
|
800
|
-
self.regenTimer =
|
|
875
|
+
self.regenTimer = UseSource(
|
|
876
|
+
nil,
|
|
801
877
|
ManaRegenTimer,
|
|
802
878
|
function(____, listener) return self:Observe(listener) end
|
|
803
879
|
)
|
|
@@ -819,6 +895,13 @@ __TS__SetDescriptor(
|
|
|
819
895
|
return self.target.Token
|
|
820
896
|
end},
|
|
821
897
|
true
|
|
822
|
-
)
|
|
898
|
+
);
|
|
899
|
+
(function(self)
|
|
900
|
+
registerSource(
|
|
901
|
+
nil,
|
|
902
|
+
____exports.Mana,
|
|
903
|
+
function(____, props) return __TS__New(____exports.Mana, props[1]) end
|
|
904
|
+
)
|
|
905
|
+
end)(Mana)
|
|
823
906
|
____exports.DataSources = {Resources = {HP = ____exports.HP, Mana = ____exports.Mana}}
|
|
824
907
|
return ____exports
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DataSource } from "./DataSource";
|
|
2
|
+
/** Lets a protected constructor stay closed while UseSource can still open it. */
|
|
3
|
+
export declare function registerSource(ctor: Function, open: (props: readonly unknown[]) => unknown): boolean;
|
|
4
|
+
export declare function openSource(ctor: Function, props: readonly unknown[]): unknown;
|
|
5
|
+
/** Opens a registered source. Public call sites use the typed overloads in UseSource.ts. */
|
|
6
|
+
export declare function UseSource<T>(source: {
|
|
7
|
+
prototype: T;
|
|
8
|
+
}, ...props: unknown[]): T;
|
|
9
|
+
/**
|
|
10
|
+
* One query. Construction stores the props; every read passes those same props back in.
|
|
11
|
+
* The source value is the reading.
|
|
12
|
+
*/
|
|
13
|
+
export declare abstract class Source<TReading, TProps extends readonly unknown[] = []> extends DataSource<TReading> {
|
|
14
|
+
protected readonly props: TProps;
|
|
15
|
+
protected constructor(initial: TReading, ...props: TProps);
|
|
16
|
+
protected abstract read(props: TProps): TReading;
|
|
17
|
+
protected GetValue(): TReading;
|
|
18
|
+
}
|
|
@@ -0,0 +1,300 @@
|
|
|
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 __TS__Symbol, Symbol
|
|
11
|
+
do
|
|
12
|
+
local symbolMetatable = {__tostring = function(self)
|
|
13
|
+
return ("Symbol(" .. (self.description or "")) .. ")"
|
|
14
|
+
end}
|
|
15
|
+
function __TS__Symbol(description)
|
|
16
|
+
return setmetatable({description = description}, symbolMetatable)
|
|
17
|
+
end
|
|
18
|
+
Symbol = {
|
|
19
|
+
asyncDispose = __TS__Symbol("Symbol.asyncDispose"),
|
|
20
|
+
dispose = __TS__Symbol("Symbol.dispose"),
|
|
21
|
+
iterator = __TS__Symbol("Symbol.iterator"),
|
|
22
|
+
hasInstance = __TS__Symbol("Symbol.hasInstance"),
|
|
23
|
+
species = __TS__Symbol("Symbol.species"),
|
|
24
|
+
toStringTag = __TS__Symbol("Symbol.toStringTag")
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
local __TS__Iterator
|
|
29
|
+
do
|
|
30
|
+
local function iteratorGeneratorStep(self)
|
|
31
|
+
local co = self.____coroutine
|
|
32
|
+
local status, value = coroutine.resume(co)
|
|
33
|
+
if not status then
|
|
34
|
+
error(value, 0)
|
|
35
|
+
end
|
|
36
|
+
if coroutine.status(co) == "dead" then
|
|
37
|
+
return
|
|
38
|
+
end
|
|
39
|
+
return true, value
|
|
40
|
+
end
|
|
41
|
+
local function iteratorIteratorStep(self)
|
|
42
|
+
local result = self:next()
|
|
43
|
+
if result.done then
|
|
44
|
+
return
|
|
45
|
+
end
|
|
46
|
+
return true, result.value
|
|
47
|
+
end
|
|
48
|
+
local function iteratorStringStep(self, index)
|
|
49
|
+
index = index + 1
|
|
50
|
+
if index > #self then
|
|
51
|
+
return
|
|
52
|
+
end
|
|
53
|
+
return index, string.sub(self, index, index)
|
|
54
|
+
end
|
|
55
|
+
function __TS__Iterator(iterable)
|
|
56
|
+
if type(iterable) == "string" then
|
|
57
|
+
return iteratorStringStep, iterable, 0
|
|
58
|
+
elseif iterable.____coroutine ~= nil then
|
|
59
|
+
return iteratorGeneratorStep, iterable
|
|
60
|
+
elseif iterable[Symbol.iterator] then
|
|
61
|
+
local iterator = iterable[Symbol.iterator](iterable)
|
|
62
|
+
return iteratorIteratorStep, iterator
|
|
63
|
+
else
|
|
64
|
+
return ipairs(iterable)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
local Map
|
|
70
|
+
do
|
|
71
|
+
Map = __TS__Class()
|
|
72
|
+
Map.name = "Map"
|
|
73
|
+
function Map.prototype.____constructor(self, entries)
|
|
74
|
+
self[Symbol.toStringTag] = "Map"
|
|
75
|
+
self.items = {}
|
|
76
|
+
self.size = 0
|
|
77
|
+
self.nextKey = {}
|
|
78
|
+
self.previousKey = {}
|
|
79
|
+
if entries == nil then
|
|
80
|
+
return
|
|
81
|
+
end
|
|
82
|
+
local iterable = entries
|
|
83
|
+
if iterable[Symbol.iterator] then
|
|
84
|
+
local iterator = iterable[Symbol.iterator](iterable)
|
|
85
|
+
while true do
|
|
86
|
+
local result = iterator:next()
|
|
87
|
+
if result.done then
|
|
88
|
+
break
|
|
89
|
+
end
|
|
90
|
+
local value = result.value
|
|
91
|
+
self:set(value[1], value[2])
|
|
92
|
+
end
|
|
93
|
+
else
|
|
94
|
+
local array = entries
|
|
95
|
+
for ____, kvp in ipairs(array) do
|
|
96
|
+
self:set(kvp[1], kvp[2])
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
function Map.prototype.clear(self)
|
|
101
|
+
self.items = {}
|
|
102
|
+
self.nextKey = {}
|
|
103
|
+
self.previousKey = {}
|
|
104
|
+
self.firstKey = nil
|
|
105
|
+
self.lastKey = nil
|
|
106
|
+
self.size = 0
|
|
107
|
+
end
|
|
108
|
+
function Map.prototype.delete(self, key)
|
|
109
|
+
local contains = self:has(key)
|
|
110
|
+
if contains then
|
|
111
|
+
self.size = self.size - 1
|
|
112
|
+
local next = self.nextKey[key]
|
|
113
|
+
local previous = self.previousKey[key]
|
|
114
|
+
if next ~= nil and previous ~= nil then
|
|
115
|
+
self.nextKey[previous] = next
|
|
116
|
+
self.previousKey[next] = previous
|
|
117
|
+
elseif next ~= nil then
|
|
118
|
+
self.firstKey = next
|
|
119
|
+
self.previousKey[next] = nil
|
|
120
|
+
elseif previous ~= nil then
|
|
121
|
+
self.lastKey = previous
|
|
122
|
+
self.nextKey[previous] = nil
|
|
123
|
+
else
|
|
124
|
+
self.firstKey = nil
|
|
125
|
+
self.lastKey = nil
|
|
126
|
+
end
|
|
127
|
+
self.nextKey[key] = nil
|
|
128
|
+
self.previousKey[key] = nil
|
|
129
|
+
end
|
|
130
|
+
self.items[key] = nil
|
|
131
|
+
return contains
|
|
132
|
+
end
|
|
133
|
+
function Map.prototype.forEach(self, callback)
|
|
134
|
+
for ____, key in __TS__Iterator(self:keys()) do
|
|
135
|
+
callback(nil, self.items[key], key, self)
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
function Map.prototype.get(self, key)
|
|
139
|
+
return self.items[key]
|
|
140
|
+
end
|
|
141
|
+
function Map.prototype.has(self, key)
|
|
142
|
+
return self.nextKey[key] ~= nil or self.lastKey == key
|
|
143
|
+
end
|
|
144
|
+
function Map.prototype.set(self, key, value)
|
|
145
|
+
local isNewValue = not self:has(key)
|
|
146
|
+
if isNewValue then
|
|
147
|
+
self.size = self.size + 1
|
|
148
|
+
end
|
|
149
|
+
self.items[key] = value
|
|
150
|
+
if self.firstKey == nil then
|
|
151
|
+
self.firstKey = key
|
|
152
|
+
self.lastKey = key
|
|
153
|
+
elseif isNewValue then
|
|
154
|
+
self.nextKey[self.lastKey] = key
|
|
155
|
+
self.previousKey[key] = self.lastKey
|
|
156
|
+
self.lastKey = key
|
|
157
|
+
end
|
|
158
|
+
return self
|
|
159
|
+
end
|
|
160
|
+
Map.prototype[Symbol.iterator] = function(self)
|
|
161
|
+
return self:entries()
|
|
162
|
+
end
|
|
163
|
+
function Map.prototype.entries(self)
|
|
164
|
+
local function getFirstKey()
|
|
165
|
+
return self.firstKey
|
|
166
|
+
end
|
|
167
|
+
local items = self.items
|
|
168
|
+
local nextKey = self.nextKey
|
|
169
|
+
local key
|
|
170
|
+
local started = false
|
|
171
|
+
return {
|
|
172
|
+
[Symbol.iterator] = function(self)
|
|
173
|
+
return self
|
|
174
|
+
end,
|
|
175
|
+
next = function(self)
|
|
176
|
+
if not started then
|
|
177
|
+
started = true
|
|
178
|
+
key = getFirstKey(nil)
|
|
179
|
+
else
|
|
180
|
+
key = nextKey[key]
|
|
181
|
+
end
|
|
182
|
+
return {done = not key, value = {key, items[key]}}
|
|
183
|
+
end
|
|
184
|
+
}
|
|
185
|
+
end
|
|
186
|
+
function Map.prototype.keys(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}
|
|
205
|
+
end
|
|
206
|
+
}
|
|
207
|
+
end
|
|
208
|
+
function Map.prototype.values(self)
|
|
209
|
+
local function getFirstKey()
|
|
210
|
+
return self.firstKey
|
|
211
|
+
end
|
|
212
|
+
local items = self.items
|
|
213
|
+
local nextKey = self.nextKey
|
|
214
|
+
local key
|
|
215
|
+
local started = false
|
|
216
|
+
return {
|
|
217
|
+
[Symbol.iterator] = function(self)
|
|
218
|
+
return self
|
|
219
|
+
end,
|
|
220
|
+
next = function(self)
|
|
221
|
+
if not started then
|
|
222
|
+
started = true
|
|
223
|
+
key = getFirstKey(nil)
|
|
224
|
+
else
|
|
225
|
+
key = nextKey[key]
|
|
226
|
+
end
|
|
227
|
+
return {done = not key, value = items[key]}
|
|
228
|
+
end
|
|
229
|
+
}
|
|
230
|
+
end
|
|
231
|
+
Map[Symbol.species] = Map
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
local function __TS__New(target, ...)
|
|
235
|
+
local instance = setmetatable({}, target.prototype)
|
|
236
|
+
instance:____constructor(...)
|
|
237
|
+
return instance
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
local function __TS__ClassExtends(target, base)
|
|
241
|
+
target.____super = base
|
|
242
|
+
local staticMetatable = setmetatable({__index = base}, base)
|
|
243
|
+
setmetatable(target, staticMetatable)
|
|
244
|
+
local baseMetatable = getmetatable(base)
|
|
245
|
+
if baseMetatable then
|
|
246
|
+
if type(baseMetatable.__index) == "function" then
|
|
247
|
+
staticMetatable.__index = baseMetatable.__index
|
|
248
|
+
end
|
|
249
|
+
if type(baseMetatable.__newindex) == "function" then
|
|
250
|
+
staticMetatable.__newindex = baseMetatable.__newindex
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
setmetatable(target.prototype, base.prototype)
|
|
254
|
+
if type(base.prototype.__index) == "function" then
|
|
255
|
+
target.prototype.__index = base.prototype.__index
|
|
256
|
+
end
|
|
257
|
+
if type(base.prototype.__newindex) == "function" then
|
|
258
|
+
target.prototype.__newindex = base.prototype.__newindex
|
|
259
|
+
end
|
|
260
|
+
if type(base.prototype.__tostring) == "function" then
|
|
261
|
+
target.prototype.__tostring = base.prototype.__tostring
|
|
262
|
+
end
|
|
263
|
+
end
|
|
264
|
+
-- End of Lua Library inline imports
|
|
265
|
+
local ____exports = {}
|
|
266
|
+
local ____DataSource = require("datasources.DataSource")
|
|
267
|
+
local DataSource = ____DataSource.DataSource
|
|
268
|
+
local openers = __TS__New(Map)
|
|
269
|
+
--- Lets a protected constructor stay closed while UseSource can still open it.
|
|
270
|
+
function ____exports.registerSource(self, ctor, open)
|
|
271
|
+
openers:set(ctor, open)
|
|
272
|
+
return true
|
|
273
|
+
end
|
|
274
|
+
function ____exports.openSource(self, ctor, props)
|
|
275
|
+
local open = openers:get(ctor)
|
|
276
|
+
if open == nil then
|
|
277
|
+
error("UseSource: this source is not registered")
|
|
278
|
+
end
|
|
279
|
+
return open(nil, props)
|
|
280
|
+
end
|
|
281
|
+
--- Opens a registered source. Public call sites use the typed overloads in UseSource.ts.
|
|
282
|
+
function ____exports.UseSource(self, source, ...)
|
|
283
|
+
local props = {...}
|
|
284
|
+
return ____exports.openSource(nil, source, props)
|
|
285
|
+
end
|
|
286
|
+
--- One query. Construction stores the props; every read passes those same props back in.
|
|
287
|
+
-- The source value is the reading.
|
|
288
|
+
____exports.Source = __TS__Class()
|
|
289
|
+
local Source = ____exports.Source
|
|
290
|
+
Source.name = "Source"
|
|
291
|
+
__TS__ClassExtends(Source, DataSource)
|
|
292
|
+
function Source.prototype.____constructor(self, initial, ...)
|
|
293
|
+
local props = {...}
|
|
294
|
+
DataSource.prototype.____constructor(self, initial)
|
|
295
|
+
self.props = props
|
|
296
|
+
end
|
|
297
|
+
function Source.prototype.GetValue(self)
|
|
298
|
+
return self:read(self.props)
|
|
299
|
+
end
|
|
300
|
+
return ____exports
|
|
@@ -17,7 +17,7 @@ export declare class SourceConverter<TInput, TOutput> extends DataSource<TOutput
|
|
|
17
17
|
private blocked;
|
|
18
18
|
private previous?;
|
|
19
19
|
private readable;
|
|
20
|
-
constructor(input: ValueSource<TInput>, convert: (value: TInput) => TOutput);
|
|
20
|
+
protected constructor(input: ValueSource<TInput>, convert: (value: TInput) => TOutput);
|
|
21
21
|
protected GetValue(): TOutput;
|
|
22
22
|
private Convert;
|
|
23
23
|
protected HasSecretFields(value: TOutput): boolean;
|
|
@@ -323,6 +323,8 @@ end
|
|
|
323
323
|
local ____exports = {}
|
|
324
324
|
local ____DataSource = require("datasources.DataSource")
|
|
325
325
|
local DataSource = ____DataSource.DataSource
|
|
326
|
+
local ____Source = require("datasources.Source")
|
|
327
|
+
local registerSource = ____Source.registerSource
|
|
326
328
|
local function restricted(self, value, seen, depth)
|
|
327
329
|
if seen == nil then
|
|
328
330
|
seen = __TS__New(Set)
|
|
@@ -471,5 +473,12 @@ function SourceConverter.prototype.Dispose(self)
|
|
|
471
473
|
end
|
|
472
474
|
self.stop = nil
|
|
473
475
|
self.listeners:clear()
|
|
474
|
-
end
|
|
476
|
+
end;
|
|
477
|
+
(function(self)
|
|
478
|
+
registerSource(
|
|
479
|
+
nil,
|
|
480
|
+
____exports.SourceConverter,
|
|
481
|
+
function(____, props) return __TS__New(____exports.SourceConverter, props[1], props[2]) end
|
|
482
|
+
)
|
|
483
|
+
end)(SourceConverter)
|
|
475
484
|
return ____exports
|
|
@@ -2,11 +2,11 @@ import { TimerSource } from "./TimerSource";
|
|
|
2
2
|
/** Native cooldown duration, including opaque timings during combat. */
|
|
3
3
|
export declare class SpellCooldown extends TimerSource {
|
|
4
4
|
readonly spellId: number | string;
|
|
5
|
-
constructor(spellId: number | string, options?: {
|
|
5
|
+
protected constructor(spellId: number | string, options?: {
|
|
6
6
|
ignoreGCD?: boolean;
|
|
7
7
|
});
|
|
8
8
|
get IsAvailable(): boolean;
|
|
9
9
|
}
|
|
10
10
|
export declare class GlobalCooldown extends SpellCooldown {
|
|
11
|
-
constructor();
|
|
11
|
+
protected constructor();
|
|
12
12
|
}
|