wuira 0.2.7 → 0.2.8
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
CHANGED
|
@@ -7,6 +7,16 @@ with the release date and highlight breaking changes explicitly.
|
|
|
7
7
|
|
|
8
8
|
## Unreleased
|
|
9
9
|
|
|
10
|
+
## 0.2.8 — 2026-10-17
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- `UnitSource("target").onChange` invalidates on `PLAYER_TARGET_CHANGED`, including
|
|
15
|
+
combat and target removal, without reading secret identities or notifying other
|
|
16
|
+
unit sources. Event subscriptions stop with the last consumer.
|
|
17
|
+
- Add `onTokenChange` for secure consumers that should only rewrite bindings after
|
|
18
|
+
an explicit `Retarget`, not when a stable target address points to another unit.
|
|
19
|
+
|
|
10
20
|
## 0.2.7 — 2026-10-16
|
|
11
21
|
|
|
12
22
|
### Added
|
|
@@ -20,11 +20,16 @@ export declare class UnitSource extends DataSource<UnitIdentity | undefined> {
|
|
|
20
20
|
readonly Is: UnitPredicates;
|
|
21
21
|
private restricted;
|
|
22
22
|
private readonly listeners;
|
|
23
|
+
private readonly tokenListeners;
|
|
24
|
+
private events?;
|
|
23
25
|
constructor(token: string);
|
|
24
26
|
get Token(): string;
|
|
25
27
|
/** Keep source objects/subscriptions while a stable identity moves to another unit slot. */
|
|
26
28
|
Retarget(token: string): void;
|
|
29
|
+
/** Secure consumers only need notification when the actual unit address changes. */
|
|
30
|
+
onTokenChange(listener: () => void): () => void;
|
|
27
31
|
onChange(listener: () => void): () => void;
|
|
32
|
+
private UpdateEvents;
|
|
28
33
|
protected HasSecretFields(): boolean;
|
|
29
34
|
protected GetValue(): UnitIdentity | undefined;
|
|
30
35
|
}
|
|
@@ -506,32 +506,76 @@ function UnitSource.prototype.____constructor(self, token)
|
|
|
506
506
|
self.token = token
|
|
507
507
|
self.restricted = false
|
|
508
508
|
self.listeners = __TS__New(Set)
|
|
509
|
+
self.tokenListeners = __TS__New(Set)
|
|
509
510
|
self.Is = __TS__New(
|
|
510
511
|
____exports.UnitPredicates,
|
|
511
512
|
function() return self.Token end
|
|
512
513
|
)
|
|
513
514
|
end
|
|
514
515
|
function UnitSource.prototype.Retarget(self, token)
|
|
516
|
+
if issecretvalue(token) or type(token) ~= "string" or __TS__StringTrim(token) == "" then
|
|
517
|
+
error("UnitSource: expected a public unit token")
|
|
518
|
+
end
|
|
515
519
|
if token == self.token then
|
|
516
520
|
return
|
|
517
521
|
end
|
|
518
522
|
if InCombatLockdown() then
|
|
519
523
|
error("UnitSource: retarget after combat so secure actions and displayed data stay aligned")
|
|
520
524
|
end
|
|
521
|
-
if issecretvalue(token) or type(token) ~= "string" or __TS__StringTrim(token) == "" then
|
|
522
|
-
error("UnitSource: expected a public unit token")
|
|
523
|
-
end
|
|
524
525
|
self.token = token
|
|
526
|
+
self:UpdateEvents()
|
|
527
|
+
for ____, listener in __TS__Iterator(self.tokenListeners) do
|
|
528
|
+
listener(nil)
|
|
529
|
+
end
|
|
525
530
|
for ____, listener in __TS__Iterator(self.listeners) do
|
|
526
531
|
listener(nil)
|
|
527
532
|
end
|
|
528
533
|
end
|
|
534
|
+
function UnitSource.prototype.onTokenChange(self, listener)
|
|
535
|
+
self.tokenListeners:add(listener)
|
|
536
|
+
return function()
|
|
537
|
+
self.tokenListeners:delete(listener)
|
|
538
|
+
end
|
|
539
|
+
end
|
|
529
540
|
function UnitSource.prototype.onChange(self, listener)
|
|
530
541
|
self.listeners:add(listener)
|
|
542
|
+
self:UpdateEvents()
|
|
531
543
|
return function()
|
|
532
544
|
self.listeners:delete(listener)
|
|
545
|
+
self:UpdateEvents()
|
|
533
546
|
end
|
|
534
547
|
end
|
|
548
|
+
function UnitSource.prototype.UpdateEvents(self)
|
|
549
|
+
local ____opt_2 = self.events
|
|
550
|
+
if ____opt_2 ~= nil then
|
|
551
|
+
____opt_2:UnregisterAllEvents()
|
|
552
|
+
end
|
|
553
|
+
if self.listeners.size == 0 or self.token ~= "target" then
|
|
554
|
+
local ____opt_4 = self.events
|
|
555
|
+
if ____opt_4 ~= nil then
|
|
556
|
+
____opt_4:SetScript("OnEvent", nil)
|
|
557
|
+
end
|
|
558
|
+
local ____opt_6 = self.events
|
|
559
|
+
if ____opt_6 ~= nil then
|
|
560
|
+
____opt_6:Hide()
|
|
561
|
+
end
|
|
562
|
+
self.events = nil
|
|
563
|
+
return
|
|
564
|
+
end
|
|
565
|
+
if self.events == nil then
|
|
566
|
+
self.events = CreateFrame("Frame", nil, UIParent)
|
|
567
|
+
end
|
|
568
|
+
local frame = self.events
|
|
569
|
+
frame:RegisterEvent("PLAYER_TARGET_CHANGED")
|
|
570
|
+
frame:SetScript(
|
|
571
|
+
"OnEvent",
|
|
572
|
+
function()
|
|
573
|
+
for ____, listener in __TS__Iterator(self.listeners) do
|
|
574
|
+
listener(nil)
|
|
575
|
+
end
|
|
576
|
+
end
|
|
577
|
+
)
|
|
578
|
+
end
|
|
535
579
|
function UnitSource.prototype.HasSecretFields(self)
|
|
536
580
|
return self.restricted
|
|
537
581
|
end
|