lycheedev 3.1.2 → 3.2.1
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/README.md +16 -38
- package/THIRD_PARTY_NOTICES +4 -314
- package/bin/lycheedev.mjs +1 -1
- package/bin/update.mjs +26 -32
- package/native/windows-amd64/lycheedev.exe +0 -0
- package/package.json +1 -1
- package/payload/addon/Bindings.xml +12 -0
- package/payload/addon/Bridge/ActivityView.lua +2 -5
- package/payload/addon/Bridge/CaptureWriter.lua +9 -115
- package/payload/addon/Bridge/FocusBindings.lua +71 -0
- package/payload/addon/Bridge/InputProtection.lua +2 -9
- package/payload/addon/Bridge/InputState.lua +15 -19
- package/payload/addon/Bridge/MemoryProtocol.lua +1 -1
- package/payload/addon/Bridge/ProbeExecution.lua +1 -0
- package/payload/addon/Bridge/ReceiverBindings.lua +73 -279
- package/payload/addon/Bridge/SlotProtocol.lua +30 -12
- package/payload/addon/Bridge/SlotRuntime.lua +9 -12
- package/payload/addon/Core/ClientGate.lua +3 -0
- package/payload/addon/Core/Compat.lua +25 -24
- package/payload/addon/Core/Controls.lua +27 -248
- package/payload/addon/Core/Execute.lua +22 -19
- package/payload/addon/Core/Locale.lua +4 -116
- package/payload/addon/Core/Locale_enUS.lua +4 -116
- package/payload/addon/Core/Persistence.lua +2 -2
- package/payload/addon/Core/Runtime.lua +46 -64
- package/payload/addon/Core/Serializer.lua +9 -1
- package/payload/addon/Core/Startup.lua +20 -0
- package/payload/addon/Core/Stores.lua +63 -95
- package/payload/addon/LICENSE +21 -0
- package/payload/addon/Lychee Dev.toc +10 -21
- package/payload/addon/Modules/AutomationView.lua +47 -383
- package/payload/addon/Modules/Diagnostics.lua +0 -4
- package/payload/addon/Modules/Events/Catalog.lua +1 -1
- package/payload/addon/Modules/Events/CatalogData_Anniversary.lua +1489 -0
- package/payload/addon/Modules/Events/CatalogData_Era.lua +1489 -0
- package/payload/addon/Modules/FunctionTrace.lua +17 -6
- package/payload/addon/Modules/ObjectInspector.lua +27 -25
- package/payload/addon/THIRD_PARTY_NOTICES +483 -0
- package/payload/addon/UI/Pages/Automation.lua +7 -64
- package/payload/addon/UI/Pages/Events.lua +0 -4
- package/payload/addon/UI/Pages/ExportRecords.lua +1 -1
- package/payload/addon/UI/Pages/Object.lua +5 -4
- package/payload/addon/UI/Pages/Run.lua +7 -1
- package/payload/addon/UI/TreeView.lua +0 -11
- package/payload/addon/UI/Widgets.lua +0 -102
- package/payload/addon/UI/Window.lua +0 -6
- package/payload/skill/SKILL.md +11 -2
- package/payload/skill/references/commands.md +17 -27
- package/payload/skill/references/data-hotfix.md +6 -3
- package/payload/skill/references/data-investigation.md +5 -2
- package/payload/skill/references/data-tables.md +4 -0
- package/payload/skill/references/data-targets.md +4 -2
- package/payload/skill/references/installation.md +9 -3
- package/payload/skill/references/live-investigation.md +14 -6
- package/payload/skill/references/live-probes.md +9 -8
- package/payload/skill/references/live-recovery.md +73 -43
- package/payload/skill/references/live-startup.md +97 -76
- package/payload/skill/references/runtime-investigations.md +10 -8
- package/payload/skill/references/source-preparation.md +23 -2
- package/payload/skill/references/source-research.md +58 -5
- package/payload/skill/scripts/lycheedev.mjs +16 -12
- package/release.json +136 -176
- package/payload/addon/Bridge/Definitions.lua +0 -3
- package/payload/addon/Bridge/FaultRunner.lua +0 -44
- package/payload/addon/Bridge/Identity.lua +0 -127
- package/payload/addon/Bridge/InputProtocol.lua +0 -76
- package/payload/addon/Bridge/InputSignal.lua +0 -36
- package/payload/addon/Bridge/Investigation.lua +0 -159
- package/payload/addon/Bridge/MatrixSymbol.lua +0 -1169
- package/payload/addon/Bridge/ProbeQueue.lua +0 -205
- package/payload/addon/Bridge/ProbeRunner.lua +0 -349
- package/payload/addon/Bridge/ReceiptView.lua +0 -316
- package/payload/addon/Bridge/Receiver.lua +0 -326
- package/payload/addon/Bridge/Reentry.lua +0 -261
- package/payload/addon/Bridge/ReportStore.lua +0 -224
- package/payload/addon/Bridge/Session.lua +0 -173
- package/payload/addon/Bridge/StartupBeacon.lua +0 -63
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
local ADDON_NAME, ns = ...
|
|
2
|
-
|
|
3
|
-
local frame, strips, lastBytes, lastReady, lastGeneration, lastScale, lastRefresh, lastReadySignal
|
|
4
|
-
local focusWatch
|
|
5
|
-
local revision = 0
|
|
6
|
-
local focusEvent = "ChatFrame.OnEditBoxFocusGained"
|
|
7
|
-
-- One optical symbol in the top-left corner. Paired report/readiness proofs
|
|
8
|
-
-- share a transport envelope, not two separately padded QR symbols.
|
|
9
|
-
local MAX_CARD_UI_SIZE = 480
|
|
10
|
-
local function restricted(value)
|
|
11
|
-
return issecretvalue and issecretvalue(value)
|
|
12
|
-
end
|
|
13
|
-
local function stopFocusWatch()
|
|
14
|
-
local watch = focusWatch
|
|
15
|
-
focusWatch = nil
|
|
16
|
-
if watch then watch.registry:UnregisterCallback(focusEvent, watch) end
|
|
17
|
-
end
|
|
18
|
-
local function hide()
|
|
19
|
-
revision = revision + 1
|
|
20
|
-
stopFocusWatch()
|
|
21
|
-
if ns.Session and type(ns.Session.CancelInputWait) == "function" then ns.Session.CancelInputWait() end
|
|
22
|
-
if ns.Identity and type(ns.Identity.CancelWait) == "function" then ns.Identity.CancelWait() end
|
|
23
|
-
lastBytes, lastReady, lastGeneration, lastScale = nil, nil, nil, nil
|
|
24
|
-
lastRefresh, lastReadySignal = nil, nil
|
|
25
|
-
if frame then
|
|
26
|
-
frame:Hide()
|
|
27
|
-
frame:UnregisterAllEvents()
|
|
28
|
-
frame:SetScript("OnEvent", nil)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
local function create()
|
|
32
|
-
frame = CreateFrame("Frame", nil, UIParent)
|
|
33
|
-
frame:Hide()
|
|
34
|
-
frame:EnableMouse(false)
|
|
35
|
-
frame:SetFrameStrata("DIALOG")
|
|
36
|
-
frame:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 16, -16)
|
|
37
|
-
local background = frame:CreateTexture(nil, "BACKGROUND")
|
|
38
|
-
background:SetAllPoints(frame)
|
|
39
|
-
background:SetColorTexture(1, 1, 1, 1)
|
|
40
|
-
strips = {}
|
|
41
|
-
end
|
|
42
|
-
local function payload(value, limit)
|
|
43
|
-
if restricted(value) or type(value) ~= "string" or #value == 0
|
|
44
|
-
or #value > (limit or 2048) then
|
|
45
|
-
return nil, "receipt_invalid_payload"
|
|
46
|
-
end
|
|
47
|
-
return value
|
|
48
|
-
end
|
|
49
|
-
-- One visual system for every receipt kind. The generation key only memoizes
|
|
50
|
-
-- identical redisplays; it is never an identity or an input permission.
|
|
51
|
-
--
|
|
52
|
-
-- One square symbol and its quiet zone. Module size is fixed in UI units.
|
|
53
|
-
--
|
|
54
|
-
-- It is deliberately NOT derived from the screen: the engines disagree about
|
|
55
|
-
-- what GetScreenHeight means (Retail reports the UIParent height, Classic the
|
|
56
|
-
-- display height), and GetPhysicalScreenSize is unavailable on several clients,
|
|
57
|
-
-- so any ratio built from them either shrinks or inflates the card by a large
|
|
58
|
-
-- factor on the clients that matter. A fixed module makes the card the same
|
|
59
|
-
-- readable size everywhere; the UI scale, not this addon, decides how many
|
|
60
|
-
-- physical pixels that is. The only other bound is the card budget, which keeps
|
|
61
|
-
-- a dense symbol on screen instead of clipping it.
|
|
62
|
-
local TARGET_CARD_MODULES = 2
|
|
63
|
-
local MIN_CARD_MODULES = 2
|
|
64
|
-
local function cardGeometry(sizes)
|
|
65
|
-
local across, tall = 8, 8
|
|
66
|
-
for index, size in ipairs(sizes) do
|
|
67
|
-
if size + 8 > across then across = size + 8 end
|
|
68
|
-
tall = tall + size
|
|
69
|
-
if index > 1 then tall = tall + 8 end
|
|
70
|
-
end
|
|
71
|
-
-- The card budget is a ceiling, not a target: a module that would push a
|
|
72
|
-
-- dense symbol past MAX_CARD_UI_SIZE is reduced, but never below the floor
|
|
73
|
-
-- that keeps the grid readable. A symbol too dense for even the floor is
|
|
74
|
-
-- drawn oversized, because the host reading a clipped grid is exactly the
|
|
75
|
-
-- failure this whole path exists to avoid.
|
|
76
|
-
local modules = math.max(MIN_CARD_MODULES, TARGET_CARD_MODULES)
|
|
77
|
-
local budget = math.min(
|
|
78
|
-
math.max(1, math.floor(MAX_CARD_UI_SIZE / across)),
|
|
79
|
-
math.max(1, math.floor(MAX_CARD_UI_SIZE / tall)))
|
|
80
|
-
if budget >= MIN_CARD_MODULES then
|
|
81
|
-
modules = math.min(modules, budget)
|
|
82
|
-
end
|
|
83
|
-
return modules, across, tall
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
local display, suspend, suspendEnvironment
|
|
87
|
-
local function environmentEvent(refresh, generation, event)
|
|
88
|
-
if event == "PLAYER_REGEN_DISABLED" or event == "LOADING_SCREEN_ENABLED" or event == "PLAYER_LEAVING_WORLD" then
|
|
89
|
-
suspendEnvironment(refresh, generation, event)
|
|
90
|
-
else hide() end
|
|
91
|
-
end
|
|
92
|
-
suspendEnvironment = function(refresh, generation, event)
|
|
93
|
-
hide()
|
|
94
|
-
if type(refresh) ~= "function" then return end
|
|
95
|
-
local expected = revision
|
|
96
|
-
local loading = event == "LOADING_SCREEN_ENABLED"
|
|
97
|
-
local leaving = event == "PLAYER_LEAVING_WORLD"
|
|
98
|
-
local function retry()
|
|
99
|
-
if revision ~= expected or loading or leaving then return end
|
|
100
|
-
if generation ~= 0 then
|
|
101
|
-
local current = ns.Session.Current()
|
|
102
|
-
if not current or current.generation ~= generation then hide(); return end
|
|
103
|
-
end
|
|
104
|
-
local ready, reason = ns.Platform.ObserveInputState()
|
|
105
|
-
if not ready then
|
|
106
|
-
if reason == "input_keyboard_focus" then suspend(refresh, generation)
|
|
107
|
-
elseif reason ~= "input_combat_lockdown" then hide() end
|
|
108
|
-
return
|
|
109
|
-
end
|
|
110
|
-
local ok, receipt, readiness, readySignal = pcall(refresh)
|
|
111
|
-
if revision ~= expected then return end
|
|
112
|
-
if not ok or not receipt then hide(); return end
|
|
113
|
-
display(receipt, readiness, generation, refresh, readySignal)
|
|
114
|
-
end
|
|
115
|
-
frame:RegisterEvent("PLAYER_REGEN_ENABLED")
|
|
116
|
-
frame:RegisterEvent("PLAYER_REGEN_DISABLED")
|
|
117
|
-
frame:RegisterEvent("LOADING_SCREEN_ENABLED")
|
|
118
|
-
frame:RegisterEvent("LOADING_SCREEN_DISABLED")
|
|
119
|
-
frame:RegisterEvent("PLAYER_LEAVING_WORLD")
|
|
120
|
-
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
|
|
121
|
-
frame:SetScript("OnEvent", function(_, received)
|
|
122
|
-
if revision ~= expected then return end
|
|
123
|
-
if received == "PLAYER_LEAVING_WORLD" then leaving = true
|
|
124
|
-
elseif received == "PLAYER_ENTERING_WORLD" then leaving = false
|
|
125
|
-
elseif received == "LOADING_SCREEN_ENABLED" then loading = true
|
|
126
|
-
elseif received == "LOADING_SCREEN_DISABLED" then loading = false end
|
|
127
|
-
retry()
|
|
128
|
-
end)
|
|
129
|
-
end
|
|
130
|
-
-- Focus invalidates pixels, not the pending result. Restore only through a
|
|
131
|
-
-- producer which observes current state; never latch an old inputReady=true.
|
|
132
|
-
suspend = function(refresh, generation)
|
|
133
|
-
hide()
|
|
134
|
-
if type(refresh) ~= "function" then return end
|
|
135
|
-
local expected = revision
|
|
136
|
-
local source = generation == 0 and ns.Identity or ns.Session
|
|
137
|
-
if not source or type(source.WhenInputReady) ~= "function" then return end
|
|
138
|
-
-- Explicit Hide, replacement, opt-out and leaving the world invalidate this
|
|
139
|
-
-- one-shot wait. No frame is allocated until the first displayed receipt.
|
|
140
|
-
frame:RegisterEvent("PLAYER_LEAVING_WORLD")
|
|
141
|
-
frame:RegisterEvent("LOADING_SCREEN_ENABLED")
|
|
142
|
-
frame:RegisterEvent("PLAYER_REGEN_DISABLED")
|
|
143
|
-
frame:SetScript("OnEvent", function(_, event) environmentEvent(refresh, generation, event) end)
|
|
144
|
-
local waiting = source.WhenInputReady(function(ready)
|
|
145
|
-
if revision ~= expected then return end
|
|
146
|
-
if not ready then
|
|
147
|
-
local _, reason = ns.Platform.ObserveInputState()
|
|
148
|
-
if reason == "input_combat_lockdown" then suspendEnvironment(refresh, generation, "PLAYER_REGEN_DISABLED")
|
|
149
|
-
else hide() end
|
|
150
|
-
return
|
|
151
|
-
end
|
|
152
|
-
if generation ~= 0 then
|
|
153
|
-
local current = ns.Session.Current()
|
|
154
|
-
if not current or current.generation ~= generation then hide(); return end
|
|
155
|
-
end
|
|
156
|
-
local ok, receipt, readiness, readySignal = pcall(refresh)
|
|
157
|
-
if revision ~= expected then return end
|
|
158
|
-
if not ok or not receipt then hide(); return end
|
|
159
|
-
display(receipt, readiness, generation, refresh, readySignal)
|
|
160
|
-
end)
|
|
161
|
-
if not waiting and revision == expected then hide() end
|
|
162
|
-
end
|
|
163
|
-
display = function(receipt, readiness, generation, refresh, readySignal)
|
|
164
|
-
local valid, failure = payload(receipt, 4096)
|
|
165
|
-
if not valid then hide(); return nil, failure end
|
|
166
|
-
if readiness ~= nil then
|
|
167
|
-
local auxiliary, auxiliaryFailure = payload(readiness)
|
|
168
|
-
if not auxiliary then hide(); return nil, auxiliaryFailure end
|
|
169
|
-
end
|
|
170
|
-
if restricted(EventRegistry) or type(EventRegistry) ~= "table"
|
|
171
|
-
or type(EventRegistry.RegisterCallback) ~= "function"
|
|
172
|
-
or type(EventRegistry.UnregisterCallback) ~= "function" then
|
|
173
|
-
hide(); return nil, "receipt_events_unavailable"
|
|
174
|
-
end
|
|
175
|
-
local scale = UIParent:GetEffectiveScale()
|
|
176
|
-
if restricted(scale) or type(scale) ~= "number" or scale ~= scale or scale <= 0 or scale == math.huge then
|
|
177
|
-
hide(); return nil, "receipt_invalid_scale"
|
|
178
|
-
end
|
|
179
|
-
if lastBytes == receipt and lastReady == readiness and lastGeneration == generation
|
|
180
|
-
and lastScale == scale and lastRefresh == refresh then return true end
|
|
181
|
-
-- A replacement owns the card and its input wait, even with identical
|
|
182
|
-
-- pixels. Cancel the previous producer before installing the new one.
|
|
183
|
-
hide()
|
|
184
|
-
-- Merge horizontal black runs instead of allocating a texture per cell.
|
|
185
|
-
-- Matrix coordinates are [x][y]. Every symbol owns a 4-module quiet zone.
|
|
186
|
-
-- Pairing changes only the optical transport. Producers retain the original
|
|
187
|
-
-- receipt and refresh readiness from current state after focus changes.
|
|
188
|
-
local optical = receipt
|
|
189
|
-
if readiness ~= nil then
|
|
190
|
-
local reason
|
|
191
|
-
optical, reason = ns.CaptureWriter.EncodeReceiptPair(receipt, readySignal)
|
|
192
|
-
if not optical then hide(); return nil, reason end
|
|
193
|
-
end
|
|
194
|
-
local runs, sizes = {}, {}
|
|
195
|
-
local origin = 4
|
|
196
|
-
local rowOffset = 0
|
|
197
|
-
for _, bytes in ipairs({optical}) do
|
|
198
|
-
local matrix, reason = ns.MatrixSymbol.Encode(bytes)
|
|
199
|
-
if not matrix then hide(); return nil, reason end
|
|
200
|
-
local size = #matrix
|
|
201
|
-
if size < 21 or size > 177 then hide(); return nil, "receipt_invalid_symbol" end
|
|
202
|
-
sizes[#sizes + 1] = size
|
|
203
|
-
local count = 0
|
|
204
|
-
for y = 1, size do
|
|
205
|
-
local x = 1
|
|
206
|
-
while x <= size do
|
|
207
|
-
if matrix[x][y] > 0 then
|
|
208
|
-
local start = x
|
|
209
|
-
repeat x = x + 1 until x > size or matrix[x][y] <= 0
|
|
210
|
-
runs[#runs + 1] = { origin + start, rowOffset + y, x - start }
|
|
211
|
-
count = count + 1
|
|
212
|
-
if count > 8192 then hide(); return nil, "receipt_texture_limit" end
|
|
213
|
-
else x = x + 1 end
|
|
214
|
-
end
|
|
215
|
-
end
|
|
216
|
-
rowOffset = rowOffset + size + 8
|
|
217
|
-
end
|
|
218
|
-
local modules, across, tall = cardGeometry(sizes)
|
|
219
|
-
if not frame then create() end
|
|
220
|
-
frame:Hide()
|
|
221
|
-
frame:SetSize(across * modules, tall * modules)
|
|
222
|
-
for index, run in ipairs(runs) do
|
|
223
|
-
local texture = strips[index]
|
|
224
|
-
if not texture then
|
|
225
|
-
texture = frame:CreateTexture(nil, "ARTWORK")
|
|
226
|
-
texture:SetColorTexture(0, 0, 0, 1)
|
|
227
|
-
strips[index] = texture
|
|
228
|
-
end
|
|
229
|
-
texture:ClearAllPoints()
|
|
230
|
-
texture:SetPoint("TOPLEFT", frame, "TOPLEFT", (run[1] - 1) * modules, -(run[2] + 3) * modules)
|
|
231
|
-
texture:SetSize(run[3] * modules, modules)
|
|
232
|
-
texture:Show()
|
|
233
|
-
end
|
|
234
|
-
for index = #runs + 1, #strips do strips[index]:Hide() end
|
|
235
|
-
frame:SetScript("OnEvent", function(_, event) environmentEvent(refresh, generation, event) end)
|
|
236
|
-
frame:RegisterEvent("PLAYER_LEAVING_WORLD")
|
|
237
|
-
frame:RegisterEvent("LOADING_SCREEN_ENABLED")
|
|
238
|
-
frame:RegisterEvent("PLAYER_REGEN_DISABLED")
|
|
239
|
-
-- Visible receipts are point-in-time observations, not latched input
|
|
240
|
-
-- permission. Invalidate on known focus/combat changes without polling.
|
|
241
|
-
stopFocusWatch()
|
|
242
|
-
local watch = { registry = EventRegistry }
|
|
243
|
-
focusWatch = watch
|
|
244
|
-
watch.registry:RegisterCallback(focusEvent, function()
|
|
245
|
-
if focusWatch == watch then suspend(refresh, generation) end
|
|
246
|
-
end, watch)
|
|
247
|
-
lastBytes, lastReady, lastGeneration, lastScale = receipt, readiness, generation, scale
|
|
248
|
-
lastRefresh, lastReadySignal = refresh, readySignal
|
|
249
|
-
-- A producer may finish while combat is already active; there will be no
|
|
250
|
-
-- second combat-start event to invalidate this newly produced receipt.
|
|
251
|
-
if ns.Platform and type(ns.Platform.ObserveInputState) == "function" then
|
|
252
|
-
local _, reason = ns.Platform.ObserveInputState()
|
|
253
|
-
if reason == "input_combat_lockdown" then
|
|
254
|
-
suspendEnvironment(refresh, generation, "PLAYER_REGEN_DISABLED")
|
|
255
|
-
return true
|
|
256
|
-
end
|
|
257
|
-
end
|
|
258
|
-
frame:Show()
|
|
259
|
-
if ns.ActivityView then ns.ActivityView.Anchor() end
|
|
260
|
-
return true
|
|
261
|
-
end
|
|
262
|
-
|
|
263
|
-
ns.ReceiptView = {
|
|
264
|
-
Hide = hide,
|
|
265
|
-
Current = function() return lastBytes end,
|
|
266
|
-
-- A visual companion stays outside the QR quiet zone, following its
|
|
267
|
-
-- actual width even when a later receiver receipt changes matrix size.
|
|
268
|
-
-- This neither creates the display nor grants input readiness.
|
|
269
|
-
AnchorCompanion = function(companion)
|
|
270
|
-
if not frame or not lastBytes then return false end
|
|
271
|
-
companion:ClearAllPoints()
|
|
272
|
-
companion:SetPoint("TOPLEFT", frame, "TOPRIGHT", 8, -4)
|
|
273
|
-
return true
|
|
274
|
-
end,
|
|
275
|
-
ShowTransient = function(receipt,seconds)
|
|
276
|
-
if type(C_Timer)~="table" or type(C_Timer.NewTimer)~="function" then return nil,"receipt_timer_unavailable" end
|
|
277
|
-
local session,reason=ns.Session.Current()
|
|
278
|
-
if not session then return nil,reason end
|
|
279
|
-
local shown,failure=display(receipt,nil,session.generation)
|
|
280
|
-
if not shown then return nil,failure end
|
|
281
|
-
local owned=revision
|
|
282
|
-
C_Timer.NewTimer(seconds,function()
|
|
283
|
-
if revision==owned and lastBytes==receipt then hide() end
|
|
284
|
-
end)
|
|
285
|
-
return receipt
|
|
286
|
-
end,
|
|
287
|
-
-- Explicit host dismissal after the displayed receipt's evidence has been
|
|
288
|
-
-- archived. A request-scoped operation in flight owns the display, so
|
|
289
|
-
-- uncertainty fails closed; clearing without a shown card is a no-op.
|
|
290
|
-
Dismiss = function()
|
|
291
|
-
if type(ns.ProbeQueue) == "table" and type(ns.ProbeQueue.Busy) == "function" then
|
|
292
|
-
local busy, reason = ns.ProbeQueue.Busy()
|
|
293
|
-
if busy == nil then return nil, reason end
|
|
294
|
-
if busy then return nil, "receipt_busy" end
|
|
295
|
-
end
|
|
296
|
-
if type(ns.Reentry) == "table" and type(ns.Reentry.Busy) == "function" then
|
|
297
|
-
local busy, reason = ns.Reentry.Busy()
|
|
298
|
-
if busy == nil then return nil, reason end
|
|
299
|
-
if busy then return nil, "receipt_busy" end
|
|
300
|
-
end
|
|
301
|
-
hide()
|
|
302
|
-
return true
|
|
303
|
-
end,
|
|
304
|
-
Show = function(receipt, readiness, refresh, readySignal)
|
|
305
|
-
if not payload(receipt) then hide(); return nil, "receipt_invalid_payload" end
|
|
306
|
-
local session, failure = ns.Session.Current()
|
|
307
|
-
if not session then hide(); return nil, failure end
|
|
308
|
-
return display(receipt, readiness, session.generation, refresh, readySignal)
|
|
309
|
-
end,
|
|
310
|
-
-- Identity markers bind no session. They share the exact display,
|
|
311
|
-
-- invalidation and focus/combat rules; only the memo key differs.
|
|
312
|
-
ShowIdentity = function(receipt, refresh)
|
|
313
|
-
if not payload(receipt) then hide(); return nil, "receipt_invalid_payload" end
|
|
314
|
-
return display(receipt, nil, 0, refresh)
|
|
315
|
-
end,
|
|
316
|
-
}
|
|
@@ -1,326 +0,0 @@
|
|
|
1
|
-
local _, ns = ...
|
|
2
|
-
|
|
3
|
-
local frame, editor, deadline
|
|
4
|
-
local active, stage, challenge, nonce, epoch, actor, phase
|
|
5
|
-
local sequence = 0
|
|
6
|
-
local accepted, acceptedCount = {}, 0
|
|
7
|
-
local boot, epochRoot
|
|
8
|
-
local counter = 0
|
|
9
|
-
local constructionFailed
|
|
10
|
-
local function restricted(value) return issecretvalue and issecretvalue(value) end
|
|
11
|
-
local function randomHex()
|
|
12
|
-
return string.format("%04x%04x%04x%04x", math.random(0, 65535),
|
|
13
|
-
math.random(0, 65535), math.random(0, 65535), math.random(0, 65535))
|
|
14
|
-
end
|
|
15
|
-
local function encodeReceipt(state, reason, receiptStage)
|
|
16
|
-
if restricted(reason) then reason = "receiver_dispatch_failed" end
|
|
17
|
-
sequence = sequence + 1
|
|
18
|
-
local focus = editor and editor:HasFocus()
|
|
19
|
-
if restricted(focus) then focus = false end
|
|
20
|
-
local signal = { schema = "lycheedev.signal.v1", kind = "receiver_" .. state,
|
|
21
|
-
release = ns.Release, product = ns.Startup.identity.product,
|
|
22
|
-
build = ns.Startup.identity.build, receiverNonce = nonce,
|
|
23
|
-
runtimeEpoch = epoch, sequence = sequence,
|
|
24
|
-
inputReady = active and focus == true or false,
|
|
25
|
-
accepted = state == "accepted" }
|
|
26
|
-
if state == "ready" then
|
|
27
|
-
signal.receiverProtocol = "intent-v2"
|
|
28
|
-
signal.reportScope = "character-v1"
|
|
29
|
-
local bindings = ns.ReceiverBindings.Current()
|
|
30
|
-
if not bindings then return nil, "receiver_bindings_unavailable" end
|
|
31
|
-
signal.wakeBinding, signal.submitBinding, signal.closeBinding =
|
|
32
|
-
bindings.wake, bindings.submit, bindings.close
|
|
33
|
-
local session = ns.Session.Current()
|
|
34
|
-
if session then
|
|
35
|
-
signal.sessionNonce = session.sessionNonce
|
|
36
|
-
signal.priorSessionSequence = session.sequence
|
|
37
|
-
signal.priorSessionEpoch = session.runtimeEpoch
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
if actor then
|
|
41
|
-
signal.character, signal.realm, signal.guid = actor.character, actor.realm, actor.guid
|
|
42
|
-
end
|
|
43
|
-
local input = receiptStage or stage
|
|
44
|
-
if input then
|
|
45
|
-
signal.requestId, signal.attemptId = input.requestId, input.attemptId
|
|
46
|
-
signal.bodyBytes, signal.bodyAdler32 = input.bodyBytes, input.bodyAdler32
|
|
47
|
-
end
|
|
48
|
-
if challenge and state == "commit_ready" then signal.commitNonce = challenge end
|
|
49
|
-
if reason then signal.errorCode = reason end
|
|
50
|
-
local encoded, failure = ns.CaptureWriter.EncodeSignal(signal, 2048)
|
|
51
|
-
if not encoded then return nil, failure end
|
|
52
|
-
return encoded
|
|
53
|
-
end
|
|
54
|
-
local function receipt(state, reason, receiptStage)
|
|
55
|
-
local encoded, failure = encodeReceipt(state, reason, receiptStage)
|
|
56
|
-
if not encoded then return nil, failure end
|
|
57
|
-
local shown, failure = ns.ReceiptView.ShowIdentity(encoded)
|
|
58
|
-
if shown and ns.ActivityView then ns.ActivityView.Anchor() end
|
|
59
|
-
return shown, failure
|
|
60
|
-
end
|
|
61
|
-
local function release(state, reason)
|
|
62
|
-
active = false
|
|
63
|
-
phase = state
|
|
64
|
-
if deadline then deadline:Cancel(); deadline = nil end
|
|
65
|
-
if frame then frame:SetScript("OnUpdate", nil) end
|
|
66
|
-
if editor then editor:ClearFocus() end
|
|
67
|
-
if frame then frame:Hide(); frame:UnregisterAllEvents() end
|
|
68
|
-
if ns.ActivityView then ns.ActivityView.Receiving(false) end
|
|
69
|
-
if state then receipt(state, reason) end
|
|
70
|
-
end
|
|
71
|
-
local function reject(reason)
|
|
72
|
-
-- A malformed frame cannot define a trusted request identity. Any staged
|
|
73
|
-
-- identity shown here came from an earlier, fully validated frame.
|
|
74
|
-
release("rejected", reason or "receiver_invalid_frame")
|
|
75
|
-
end
|
|
76
|
-
local function command(staged)
|
|
77
|
-
local action, requestId, arg = staged.action, staged.requestId, staged.argument
|
|
78
|
-
if action == "identify" then return "bridge identify " .. arg end
|
|
79
|
-
if action == "connect" then return "connect" end
|
|
80
|
-
if action == "reset" then return "bridge reset " .. arg end
|
|
81
|
-
if action == "ready" or action == "hide" then return "bridge " .. action end
|
|
82
|
-
if action == "refresh" then return "bridge refresh " .. arg end
|
|
83
|
-
if action == "ack" or action == "bugs" or action == "bugs-ack" or
|
|
84
|
-
action == "verify" or action == "prepare" or action == "clean" or action == "flush" or action == "observe" or action == "finish" then
|
|
85
|
-
return "bridge " .. action .. " " .. requestId .. " " .. arg
|
|
86
|
-
end
|
|
87
|
-
return "bridge " .. action .. " " .. requestId
|
|
88
|
-
end
|
|
89
|
-
local function accept()
|
|
90
|
-
if not active or phase ~= "committed" or not stage or not challenge then return end
|
|
91
|
-
local staged = stage
|
|
92
|
-
-- These three actions create or execute request-scoped work. The other
|
|
93
|
-
-- actions are read-only/idempotent or own an atomic reentry ticket in their
|
|
94
|
-
-- business module, so they do not consume receiver replay slots.
|
|
95
|
-
local track = staged.action == "load" or staged.action == "run" or staged.action == "bugs"
|
|
96
|
-
local businessKey = staged.action .. ":" .. staged.requestId
|
|
97
|
-
local body = ns.InputProtocol.Body(staged.action, staged.requestId, staged.argument)
|
|
98
|
-
local previous = track and accepted[businessKey] or nil
|
|
99
|
-
if previous and previous.body ~= body then reject("receiver_request_changed"); return end
|
|
100
|
-
if previous then
|
|
101
|
-
release("accepted", previous.errorCode)
|
|
102
|
-
phase, stage, challenge = nil, nil, nil
|
|
103
|
-
return
|
|
104
|
-
end
|
|
105
|
-
if track and acceptedCount >= 256 then reject("receiver_accept_limit"); return end
|
|
106
|
-
-- Record before business dispatch, including an exception or reload. The
|
|
107
|
-
-- same request is never invoked again in this runtime.
|
|
108
|
-
if track then
|
|
109
|
-
accepted[businessKey] = { body = body }
|
|
110
|
-
acceptedCount = acceptedCount + 1
|
|
111
|
-
end
|
|
112
|
-
release("accepted")
|
|
113
|
-
-- Delivery ends before business dispatch. The replay fence above survives
|
|
114
|
-
-- independently of focus, this input buffer and the currently visible QR.
|
|
115
|
-
-- No host CLOSE or transient accepted card is needed to accept a new input.
|
|
116
|
-
phase, stage, challenge = nil, nil, nil
|
|
117
|
-
local dispatchFailure
|
|
118
|
-
local ok, result, failure = pcall(ns.Controls.Handle, command(staged))
|
|
119
|
-
if not ok or restricted(result) then dispatchFailure = "receiver_dispatch_exception"
|
|
120
|
-
elseif not result then dispatchFailure = not restricted(failure) and
|
|
121
|
-
type(failure) == "string" and #failure <= 64 and
|
|
122
|
-
string.match(failure, "^[A-Za-z0-9_%-]+$") and failure or "receiver_dispatch_failed" end
|
|
123
|
-
if dispatchFailure then receipt("accepted", dispatchFailure, staged) end
|
|
124
|
-
if track then accepted[businessKey].errorCode = dispatchFailure end
|
|
125
|
-
-- An exact ACK retires this operation's receiver entries only after the
|
|
126
|
-
-- business dispatcher succeeds. Unresolved work keeps its replay fence.
|
|
127
|
-
if ok and not restricted(result) and result and
|
|
128
|
-
(staged.action == "ack" or staged.action == "bugs-ack") then
|
|
129
|
-
for _, verb in ipairs({"load", "run", "bugs", "ack", "bugs-ack"}) do
|
|
130
|
-
local key = verb .. ":" .. staged.requestId
|
|
131
|
-
if accepted[key] then accepted[key] = nil; acceptedCount = acceptedCount - 1 end
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
local function submit()
|
|
136
|
-
if not active or phase ~= "staged" or not stage then return end
|
|
137
|
-
-- A key carries no attempt identity. It only issues a fresh optical
|
|
138
|
-
-- challenge; a separate correlated LDC1 frame is needed to dispatch.
|
|
139
|
-
challenge = randomHex()
|
|
140
|
-
phase = "challenge"
|
|
141
|
-
editor:SetText("")
|
|
142
|
-
return receipt("commit_ready")
|
|
143
|
-
end
|
|
144
|
-
local function onTextChanged(self)
|
|
145
|
-
if not active then return end
|
|
146
|
-
local text = self:GetText()
|
|
147
|
-
if restricted(text) or type(text) ~= "string" then reject("receiver_restricted_input"); return end
|
|
148
|
-
if phase == "committed" then
|
|
149
|
-
if text ~= stage.commitFrame then reject("receiver_commit_changed") end
|
|
150
|
-
return
|
|
151
|
-
end
|
|
152
|
-
-- The initial wake key may land after focus. Strip that single punctuation
|
|
153
|
-
-- immediately; waiting for key-up stalled the proven background sender.
|
|
154
|
-
if (phase == "ready" and ns.ReceiverBindings.MatchKey(text, "wake"))
|
|
155
|
-
or (phase == "challenge" and ns.ReceiverBindings.MatchKey(text, "submit")) then
|
|
156
|
-
self:SetText(""); return
|
|
157
|
-
end
|
|
158
|
-
if phase == "staged" then
|
|
159
|
-
if text ~= stage.frame then self:SetText(stage.frame) end
|
|
160
|
-
return
|
|
161
|
-
end
|
|
162
|
-
if #text > ns.InputProtocol.MaxBytes then reject("receiver_capacity"); return end
|
|
163
|
-
if text == "" then return end
|
|
164
|
-
if not string.match(text, "^[A-Za-z0-9_:%-]+$") then reject("receiver_encoding"); return end
|
|
165
|
-
local expected = phase == "challenge" and "LDC1:" or "LDB1:"
|
|
166
|
-
if #text <= #expected and string.sub(expected, 1, #text) ~= text then reject("receiver_format"); return end
|
|
167
|
-
-- Only a complete trailing checksum permits a parse. Partial frames stay
|
|
168
|
-
-- inert until they finish or hit the independent hard deadline.
|
|
169
|
-
local colonCount = select(2, string.gsub(text, ":", ""))
|
|
170
|
-
local requiredColons = phase == "challenge" and 5 or 8
|
|
171
|
-
if colonCount ~= requiredColons or
|
|
172
|
-
not string.match(text, ":[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]$") then return end
|
|
173
|
-
if phase == "challenge" then
|
|
174
|
-
local matched, failure = ns.InputProtocol.Commit(text, stage, challenge)
|
|
175
|
-
if not matched then reject(failure); return end
|
|
176
|
-
-- Text changes carry no hardware-event context. Keep the validated
|
|
177
|
-
-- commit inert until the host's final Enter; reload and other protected
|
|
178
|
-
-- operations must be dispatched from that key event.
|
|
179
|
-
stage.commitFrame, phase = text, "committed"
|
|
180
|
-
elseif phase == "ready" then
|
|
181
|
-
local parsed, failure = ns.InputProtocol.Stage(text, nonce, epoch)
|
|
182
|
-
if not parsed then reject(failure); return end
|
|
183
|
-
parsed.frame = text
|
|
184
|
-
stage, phase = parsed, "staged"
|
|
185
|
-
receipt("staged")
|
|
186
|
-
end
|
|
187
|
-
end
|
|
188
|
-
local function makeFrame()
|
|
189
|
-
frame = CreateFrame("Frame", nil, UIParent)
|
|
190
|
-
-- A new WoW Frame starts visible. Keep the full-screen input shield hidden
|
|
191
|
-
-- while every child control and script is being constructed.
|
|
192
|
-
frame:Hide()
|
|
193
|
-
frame:SetAllPoints(UIParent); frame:SetFrameStrata("FULLSCREEN_DIALOG")
|
|
194
|
-
frame:EnableMouse(true); frame:EnableMouseWheel(true)
|
|
195
|
-
frame:SetScript("OnMouseDown", function() if active then editor:SetFocus() end end)
|
|
196
|
-
frame:SetScript("OnMouseWheel", function() end)
|
|
197
|
-
editor = CreateFrame("EditBox", nil, frame)
|
|
198
|
-
editor:SetSize(1, 1)
|
|
199
|
-
editor:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, 0)
|
|
200
|
-
editor:SetFont(ns.Theme.font, 14, "")
|
|
201
|
-
-- Alpha hides both native text and caret without removing keyboard focus.
|
|
202
|
-
-- This control must remain shown until release(), including staged input.
|
|
203
|
-
editor:SetAlpha(0)
|
|
204
|
-
editor:SetAutoFocus(false); editor:SetMaxLetters(ns.InputProtocol.MaxBytes + 1)
|
|
205
|
-
editor:SetScript("OnTextChanged", onTextChanged)
|
|
206
|
-
editor:SetScript("OnKeyDown", function(_, key)
|
|
207
|
-
if not active or restricted(key) then return end
|
|
208
|
-
-- Focused punctuation is receiver-local. The isolated Retail lab proved
|
|
209
|
-
-- delivery of these keys, not physical modifier-state distinction.
|
|
210
|
-
if ns.ReceiverBindings.MatchKey(key, "close") then release("cancelled", "receiver_manual_close")
|
|
211
|
-
elseif ns.ReceiverBindings.MatchKey(key, "submit") then submit() end
|
|
212
|
-
end)
|
|
213
|
-
editor:SetScript("OnEnterPressed", accept)
|
|
214
|
-
editor:SetScript("OnEscapePressed", function() end)
|
|
215
|
-
editor:SetScript("OnTabPressed", function() end)
|
|
216
|
-
-- The shield owns focus until acceptance, explicit close, combat or the
|
|
217
|
-
-- deadline. A click/focus notification cannot cancel a valid transaction.
|
|
218
|
-
editor:SetScript("OnEditFocusLost", function(self) if active then self:SetFocus() end end)
|
|
219
|
-
frame:SetScript("OnEvent", function(_, event)
|
|
220
|
-
if active then release("cancelled", event == "PLAYER_REGEN_DISABLED"
|
|
221
|
-
and "receiver_combat" or "receiver_world_changed") end
|
|
222
|
-
end)
|
|
223
|
-
end
|
|
224
|
-
local function rollbackWake(partialConstruction)
|
|
225
|
-
active = false
|
|
226
|
-
phase, stage, challenge = nil, nil, nil
|
|
227
|
-
if deadline then pcall(deadline.Cancel, deadline); deadline = nil end
|
|
228
|
-
if frame then
|
|
229
|
-
pcall(frame.SetScript, frame, "OnUpdate", nil)
|
|
230
|
-
pcall(frame.Hide, frame)
|
|
231
|
-
pcall(frame.UnregisterAllEvents, frame)
|
|
232
|
-
end
|
|
233
|
-
if editor then pcall(editor.ClearFocus, editor) end
|
|
234
|
-
if ns.ActivityView then pcall(ns.ActivityView.Receiving, false) end
|
|
235
|
-
if partialConstruction then
|
|
236
|
-
-- A partial frame cannot be reused. Fence repeated wake attempts in
|
|
237
|
-
-- this runtime so a persistent API failure cannot allocate more UI.
|
|
238
|
-
constructionFailed = true
|
|
239
|
-
editor = nil
|
|
240
|
-
end
|
|
241
|
-
end
|
|
242
|
-
local function canOpen()
|
|
243
|
-
if constructionFailed then return nil, "receiver_ui_unavailable" end
|
|
244
|
-
if not ns.ReceiverBindings or not ns.ReceiverBindings.Current() then return nil, "receiver_bindings_unavailable" end
|
|
245
|
-
if not ns.Startup.ready then return nil, "addon_not_ready" end
|
|
246
|
-
local state, failure = ns.Persistence.Bridge()
|
|
247
|
-
if not state then return nil, failure end
|
|
248
|
-
local ok, inCombat = pcall(InCombatLockdown)
|
|
249
|
-
if not ok or restricted(inCombat) or inCombat ~= false then return nil, "receiver_combat" end
|
|
250
|
-
local actorValue, actorFailure = ns.Platform.ObserveActor()
|
|
251
|
-
if not actorValue then return nil, actorFailure end
|
|
252
|
-
local session = ns.Session.Current()
|
|
253
|
-
if session then return state, actorValue, session.runtimeEpoch end
|
|
254
|
-
if state ~= epochRoot then
|
|
255
|
-
local previous = state.runtimeEpoch or 0
|
|
256
|
-
if restricted(previous) or type(previous) ~= "number" or previous < 0 or
|
|
257
|
-
previous % 1 ~= 0 or previous >= 9007199254740991 then return nil, "receiver_invalid_epoch" end
|
|
258
|
-
state.runtimeEpoch = previous + 1
|
|
259
|
-
epochRoot = state
|
|
260
|
-
end
|
|
261
|
-
return state, actorValue, state.runtimeEpoch
|
|
262
|
-
end
|
|
263
|
-
local function wake()
|
|
264
|
-
if active then return true end -- No deadline extension and no text reset.
|
|
265
|
-
local state, observed, currentEpoch = canOpen()
|
|
266
|
-
if not state then return nil, observed end
|
|
267
|
-
if not frame then
|
|
268
|
-
if not pcall(makeFrame) then
|
|
269
|
-
rollbackWake(true)
|
|
270
|
-
return nil, "receiver_ui_unavailable"
|
|
271
|
-
end
|
|
272
|
-
end
|
|
273
|
-
-- Prepare the deadline and all visible copy before exposing the input
|
|
274
|
-
-- shield. Any API exception leaves no focus, event, timer or visible frame.
|
|
275
|
-
local ok, shown, failure = pcall(function()
|
|
276
|
-
if not boot then boot = string.format("%04x%04x", math.random(0, 65535), math.random(0, 65535)) end
|
|
277
|
-
counter = counter + 1
|
|
278
|
-
if counter > 4294967295 then return nil, "receiver_nonce_exhausted" end
|
|
279
|
-
nonce, epoch, actor, stage, challenge = boot .. string.format("%08x", counter) .. randomHex(), currentEpoch, observed, nil, nil
|
|
280
|
-
phase = "ready"
|
|
281
|
-
editor:SetText("")
|
|
282
|
-
if type(C_Timer) ~= "table" or type(C_Timer.NewTimer) ~= "function" then
|
|
283
|
-
return nil, "receiver_timer_unavailable"
|
|
284
|
-
end
|
|
285
|
-
deadline = C_Timer.NewTimer(20, function() if active then release("timeout", "receiver_deadline") end end)
|
|
286
|
-
if not deadline then return nil, "receiver_timer_unavailable" end
|
|
287
|
-
active = true
|
|
288
|
-
if ns.ActivityView then ns.ActivityView.Receiving(true) end
|
|
289
|
-
frame:RegisterEvent("PLAYER_REGEN_DISABLED")
|
|
290
|
-
frame:RegisterEvent("PLAYER_LEAVING_WORLD")
|
|
291
|
-
frame:Show()
|
|
292
|
-
editor:SetFocus()
|
|
293
|
-
return receipt("ready")
|
|
294
|
-
end)
|
|
295
|
-
if not ok or not shown then
|
|
296
|
-
rollbackWake(false)
|
|
297
|
-
return nil, ok and (failure or "receiver_ui_unavailable") or "receiver_ui_unavailable"
|
|
298
|
-
end
|
|
299
|
-
if ns.StartupBeacon then ns.StartupBeacon.Stop() end
|
|
300
|
-
return shown, failure
|
|
301
|
-
end
|
|
302
|
-
local function close()
|
|
303
|
-
-- Emergency cancellation belongs only to the input surface. It cannot
|
|
304
|
-
-- acknowledge business work, hide its receipt or gate the next command.
|
|
305
|
-
if active then
|
|
306
|
-
release("cancelled", "receiver_manual_close")
|
|
307
|
-
else
|
|
308
|
-
if frame then
|
|
309
|
-
pcall(frame.Hide, frame)
|
|
310
|
-
pcall(frame.SetScript, frame, "OnUpdate", nil)
|
|
311
|
-
pcall(frame.UnregisterAllEvents, frame)
|
|
312
|
-
end
|
|
313
|
-
if editor then pcall(editor.ClearFocus, editor) end
|
|
314
|
-
end
|
|
315
|
-
phase, stage, challenge = nil, nil, nil
|
|
316
|
-
return true
|
|
317
|
-
end
|
|
318
|
-
|
|
319
|
-
ns.Receiver = {
|
|
320
|
-
Wake = wake, Submit = submit, Close = close,
|
|
321
|
-
IsActive = function() return active == true end,
|
|
322
|
-
Register = function()
|
|
323
|
-
if not ns.ReceiverBindings then return nil, "receiver_bindings_unavailable" end
|
|
324
|
-
return ns.ReceiverBindings.Register({ wake = wake, submit = submit, close = close })
|
|
325
|
-
end,
|
|
326
|
-
}
|