lycheedev 1.0.0 → 1.0.2
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/bin/lycheedev.js +58 -8
- package/package.json +1 -1
- package/vendor/addon/Core/Bootstrap.lua +131 -131
- package/vendor/addon/Core/Clients/Mainline.lua +9 -9
- package/vendor/addon/Core/Clients/Mists.lua +9 -9
- package/vendor/addon/Core/Clients/Titan.lua +9 -9
- package/vendor/addon/Core/Compatibility.lua +43 -43
- package/vendor/addon/Core/Database.lua +859 -859
- package/vendor/addon/Core/Inspector.lua +647 -647
- package/vendor/addon/Core/Locale.lua +307 -307
- package/vendor/addon/Core/Locale_enUS.lua +318 -318
- package/vendor/addon/Core/Safety.lua +42 -42
- package/vendor/addon/Core/Serializer.lua +324 -324
- package/vendor/addon/Libs/AutomationQR.lua +1176 -1176
- package/vendor/addon/Lychee Dev_Mainline.toc +43 -43
- package/vendor/addon/Lychee Dev_Mists.toc +43 -43
- package/vendor/addon/Lychee Dev_Wrath.toc +43 -43
- package/vendor/addon/Modules/Automation/Controller.lua +757 -757
- package/vendor/addon/Modules/Automation/Report.lua +409 -409
- package/vendor/addon/Modules/Automation/auto/auto.lua +12 -12
- package/vendor/addon/Modules/Diagnostics.lua +238 -238
- package/vendor/addon/Modules/Events/Catalog.lua +184 -184
- package/vendor/addon/Modules/Events/CatalogData_Mainline.lua +1788 -1788
- package/vendor/addon/Modules/Events/CatalogData_Mists.lua +1489 -1489
- package/vendor/addon/Modules/Events/CatalogData_Titan.lua +1492 -1492
- package/vendor/addon/Modules/Events/Monitor.lua +181 -181
- package/vendor/addon/Modules/FunctionTrace.lua +85 -85
- package/vendor/addon/Modules/ObjectInspector.lua +329 -329
- package/vendor/addon/UI/AutomationOverlay.lua +183 -183
- package/vendor/addon/UI/Export.lua +140 -140
- package/vendor/addon/UI/Features.lua +890 -890
- package/vendor/addon/UI/MainWindow.lua +1145 -1145
- package/vendor/addon/UI/Pages/About.lua +223 -223
- package/vendor/addon/UI/Pages/Automation.lua +417 -417
- package/vendor/addon/UI/Pages/Diagnostics.lua +289 -289
- package/vendor/addon/UI/Pages/ExportRecords.lua +387 -387
- package/vendor/addon/UI/Pages/Object.lua +573 -573
- package/vendor/addon/UI/Pages/Trace.lua +165 -165
- package/vendor/skill/SKILL.md +94 -94
- package/vendor/skill/agents/openai.yaml +4 -4
- package/vendor/skill/references/automation.md +327 -327
- package/vendor/skill/references/runtime-investigations.md +97 -97
- package/vendor/skill/scripts/automation/__init__.py +1 -1
- package/vendor/skill/scripts/automation/registry.py +516 -516
- package/vendor/skill/scripts/automation/saved_variables.py +438 -438
- package/vendor/skill/scripts/automation/session.py +207 -207
- package/vendor/skill/scripts/automation/windows.py +573 -573
- package/vendor/skill/scripts/automation.py +865 -865
- package/vendor/skill/scripts/requirements.txt +13 -13
- package/vendor/skill/scripts/selftest_offline.py +981 -981
|
@@ -1,181 +1,181 @@
|
|
|
1
|
-
local ADDON_NAME, ns = ...
|
|
2
|
-
local L = ns.L
|
|
3
|
-
|
|
4
|
-
local MAX_RECORDS = 500
|
|
5
|
-
local MAX_ARGUMENTS = 16
|
|
6
|
-
local MAX_ARGUMENT_BYTES = 256
|
|
7
|
-
|
|
8
|
-
local monitor = {}
|
|
9
|
-
local driver
|
|
10
|
-
local records = {}
|
|
11
|
-
local head = 0
|
|
12
|
-
local count = 0
|
|
13
|
-
local changedCallback
|
|
14
|
-
local running = false
|
|
15
|
-
local activeEventCount = 0
|
|
16
|
-
local monitoringAllEvents = false
|
|
17
|
-
local startedAt = 0
|
|
18
|
-
|
|
19
|
-
local function IsSecret(value)
|
|
20
|
-
return issecretvalue and issecretvalue(value)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
local function FormatArgument(value)
|
|
24
|
-
if IsSecret(value) then
|
|
25
|
-
return "<secret>"
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
local valueType = type(value)
|
|
29
|
-
local text
|
|
30
|
-
if valueType == "string" then
|
|
31
|
-
text = string.format("%q", value)
|
|
32
|
-
elseif valueType == "number" or valueType == "boolean" or valueType == "nil" then
|
|
33
|
-
text = tostring(value)
|
|
34
|
-
elseif valueType == "table" then
|
|
35
|
-
text = "<table>"
|
|
36
|
-
else
|
|
37
|
-
text = "<" .. valueType .. ">"
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
if #text > MAX_ARGUMENT_BYTES then
|
|
41
|
-
return text:sub(1, MAX_ARGUMENT_BYTES) .. "..."
|
|
42
|
-
end
|
|
43
|
-
return text
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
local function AddRecord(event, ...)
|
|
47
|
-
local suppliedCount = select("#", ...)
|
|
48
|
-
local argumentCount = math.min(suppliedCount, MAX_ARGUMENTS)
|
|
49
|
-
local arguments = {}
|
|
50
|
-
for index = 1, argumentCount do
|
|
51
|
-
arguments[index] = FormatArgument(select(index, ...))
|
|
52
|
-
end
|
|
53
|
-
if suppliedCount > MAX_ARGUMENTS then
|
|
54
|
-
arguments[#arguments + 1] = "<" .. (suppliedCount - MAX_ARGUMENTS) .. " more arguments>"
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
head = head % MAX_RECORDS + 1
|
|
58
|
-
records[head] = {
|
|
59
|
-
elapsed = math.max(0, GetTime() - startedAt),
|
|
60
|
-
event = event,
|
|
61
|
-
arguments = arguments,
|
|
62
|
-
summary = table.concat(arguments, ", "),
|
|
63
|
-
}
|
|
64
|
-
count = math.min(count + 1, MAX_RECORDS)
|
|
65
|
-
|
|
66
|
-
if changedCallback then
|
|
67
|
-
changedCallback(records[head])
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
local function EnsureDriver()
|
|
72
|
-
if driver then
|
|
73
|
-
return driver
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
driver = CreateFrame("Frame")
|
|
77
|
-
driver:SetScript("OnEvent", function(_, event, ...)
|
|
78
|
-
AddRecord(event, ...)
|
|
79
|
-
end)
|
|
80
|
-
return driver
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
function monitor.Start(eventNames, callback)
|
|
84
|
-
if ns.IsCombatBlocked() then
|
|
85
|
-
return false, L.COMBAT_BLOCKED
|
|
86
|
-
end
|
|
87
|
-
if type(eventNames) ~= "table" or #eventNames == 0 then
|
|
88
|
-
return false, L.SELECT_ONE_EVENT
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
local uniqueNames = {}
|
|
92
|
-
local names = {}
|
|
93
|
-
for index = 1, #eventNames do
|
|
94
|
-
local eventName = eventNames[index]
|
|
95
|
-
if type(eventName) ~= "string" or not eventName:match("^[A-Z][A-Z0-9_]*$") then
|
|
96
|
-
return false, L.INVALID_EVENT .. tostring(eventName)
|
|
97
|
-
elseif not uniqueNames[eventName] then
|
|
98
|
-
uniqueNames[eventName] = true
|
|
99
|
-
names[#names + 1] = eventName
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
local eventDriver = EnsureDriver()
|
|
104
|
-
eventDriver:UnregisterAllEvents()
|
|
105
|
-
running = false
|
|
106
|
-
activeEventCount = 0
|
|
107
|
-
monitoringAllEvents = false
|
|
108
|
-
changedCallback = nil
|
|
109
|
-
|
|
110
|
-
if uniqueNames.ALL then
|
|
111
|
-
local succeeded = pcall(eventDriver.RegisterAllEvents, eventDriver)
|
|
112
|
-
if not succeeded then
|
|
113
|
-
return false, L.UNAVAILABLE_EVENT .. "ALL"
|
|
114
|
-
end
|
|
115
|
-
changedCallback = callback
|
|
116
|
-
running = true
|
|
117
|
-
monitoringAllEvents = true
|
|
118
|
-
activeEventCount = 1
|
|
119
|
-
startedAt = GetTime()
|
|
120
|
-
return true
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
for index = 1, #names do
|
|
124
|
-
local eventName = names[index]
|
|
125
|
-
local succeeded = pcall(eventDriver.RegisterEvent, eventDriver, eventName)
|
|
126
|
-
local registered = succeeded and eventDriver:IsEventRegistered(eventName)
|
|
127
|
-
if not registered or IsSecret(registered) then
|
|
128
|
-
eventDriver:UnregisterAllEvents()
|
|
129
|
-
return false, L.UNAVAILABLE_EVENT .. eventName
|
|
130
|
-
end
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
changedCallback = callback
|
|
134
|
-
running = true
|
|
135
|
-
activeEventCount = #names
|
|
136
|
-
startedAt = GetTime()
|
|
137
|
-
return true
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
function monitor.Stop()
|
|
141
|
-
if driver then
|
|
142
|
-
driver:UnregisterAllEvents()
|
|
143
|
-
end
|
|
144
|
-
changedCallback = nil
|
|
145
|
-
running = false
|
|
146
|
-
activeEventCount = 0
|
|
147
|
-
monitoringAllEvents = false
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
function monitor.Clear()
|
|
151
|
-
wipe(records)
|
|
152
|
-
head = 0
|
|
153
|
-
count = 0
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
function monitor.GetCount()
|
|
157
|
-
return count
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
function monitor.GetRecord(newestIndex)
|
|
161
|
-
if type(newestIndex) ~= "number" or newestIndex < 1 or newestIndex > count then
|
|
162
|
-
return nil
|
|
163
|
-
end
|
|
164
|
-
local physicalIndex = (head - newestIndex) % MAX_RECORDS + 1
|
|
165
|
-
return records[physicalIndex]
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
function monitor.IsRunning()
|
|
169
|
-
return running
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
function monitor.GetActiveEventCount()
|
|
173
|
-
return activeEventCount
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
function monitor.IsMonitoringAllEvents()
|
|
177
|
-
return monitoringAllEvents
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
ns.EventMonitor = monitor
|
|
181
|
-
ns.RegisterCombatShutdown(monitor.Stop)
|
|
1
|
+
local ADDON_NAME, ns = ...
|
|
2
|
+
local L = ns.L
|
|
3
|
+
|
|
4
|
+
local MAX_RECORDS = 500
|
|
5
|
+
local MAX_ARGUMENTS = 16
|
|
6
|
+
local MAX_ARGUMENT_BYTES = 256
|
|
7
|
+
|
|
8
|
+
local monitor = {}
|
|
9
|
+
local driver
|
|
10
|
+
local records = {}
|
|
11
|
+
local head = 0
|
|
12
|
+
local count = 0
|
|
13
|
+
local changedCallback
|
|
14
|
+
local running = false
|
|
15
|
+
local activeEventCount = 0
|
|
16
|
+
local monitoringAllEvents = false
|
|
17
|
+
local startedAt = 0
|
|
18
|
+
|
|
19
|
+
local function IsSecret(value)
|
|
20
|
+
return issecretvalue and issecretvalue(value)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
local function FormatArgument(value)
|
|
24
|
+
if IsSecret(value) then
|
|
25
|
+
return "<secret>"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
local valueType = type(value)
|
|
29
|
+
local text
|
|
30
|
+
if valueType == "string" then
|
|
31
|
+
text = string.format("%q", value)
|
|
32
|
+
elseif valueType == "number" or valueType == "boolean" or valueType == "nil" then
|
|
33
|
+
text = tostring(value)
|
|
34
|
+
elseif valueType == "table" then
|
|
35
|
+
text = "<table>"
|
|
36
|
+
else
|
|
37
|
+
text = "<" .. valueType .. ">"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
if #text > MAX_ARGUMENT_BYTES then
|
|
41
|
+
return text:sub(1, MAX_ARGUMENT_BYTES) .. "..."
|
|
42
|
+
end
|
|
43
|
+
return text
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
local function AddRecord(event, ...)
|
|
47
|
+
local suppliedCount = select("#", ...)
|
|
48
|
+
local argumentCount = math.min(suppliedCount, MAX_ARGUMENTS)
|
|
49
|
+
local arguments = {}
|
|
50
|
+
for index = 1, argumentCount do
|
|
51
|
+
arguments[index] = FormatArgument(select(index, ...))
|
|
52
|
+
end
|
|
53
|
+
if suppliedCount > MAX_ARGUMENTS then
|
|
54
|
+
arguments[#arguments + 1] = "<" .. (suppliedCount - MAX_ARGUMENTS) .. " more arguments>"
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
head = head % MAX_RECORDS + 1
|
|
58
|
+
records[head] = {
|
|
59
|
+
elapsed = math.max(0, GetTime() - startedAt),
|
|
60
|
+
event = event,
|
|
61
|
+
arguments = arguments,
|
|
62
|
+
summary = table.concat(arguments, ", "),
|
|
63
|
+
}
|
|
64
|
+
count = math.min(count + 1, MAX_RECORDS)
|
|
65
|
+
|
|
66
|
+
if changedCallback then
|
|
67
|
+
changedCallback(records[head])
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
local function EnsureDriver()
|
|
72
|
+
if driver then
|
|
73
|
+
return driver
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
driver = CreateFrame("Frame")
|
|
77
|
+
driver:SetScript("OnEvent", function(_, event, ...)
|
|
78
|
+
AddRecord(event, ...)
|
|
79
|
+
end)
|
|
80
|
+
return driver
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
function monitor.Start(eventNames, callback)
|
|
84
|
+
if ns.IsCombatBlocked() then
|
|
85
|
+
return false, L.COMBAT_BLOCKED
|
|
86
|
+
end
|
|
87
|
+
if type(eventNames) ~= "table" or #eventNames == 0 then
|
|
88
|
+
return false, L.SELECT_ONE_EVENT
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
local uniqueNames = {}
|
|
92
|
+
local names = {}
|
|
93
|
+
for index = 1, #eventNames do
|
|
94
|
+
local eventName = eventNames[index]
|
|
95
|
+
if type(eventName) ~= "string" or not eventName:match("^[A-Z][A-Z0-9_]*$") then
|
|
96
|
+
return false, L.INVALID_EVENT .. tostring(eventName)
|
|
97
|
+
elseif not uniqueNames[eventName] then
|
|
98
|
+
uniqueNames[eventName] = true
|
|
99
|
+
names[#names + 1] = eventName
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
local eventDriver = EnsureDriver()
|
|
104
|
+
eventDriver:UnregisterAllEvents()
|
|
105
|
+
running = false
|
|
106
|
+
activeEventCount = 0
|
|
107
|
+
monitoringAllEvents = false
|
|
108
|
+
changedCallback = nil
|
|
109
|
+
|
|
110
|
+
if uniqueNames.ALL then
|
|
111
|
+
local succeeded = pcall(eventDriver.RegisterAllEvents, eventDriver)
|
|
112
|
+
if not succeeded then
|
|
113
|
+
return false, L.UNAVAILABLE_EVENT .. "ALL"
|
|
114
|
+
end
|
|
115
|
+
changedCallback = callback
|
|
116
|
+
running = true
|
|
117
|
+
monitoringAllEvents = true
|
|
118
|
+
activeEventCount = 1
|
|
119
|
+
startedAt = GetTime()
|
|
120
|
+
return true
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
for index = 1, #names do
|
|
124
|
+
local eventName = names[index]
|
|
125
|
+
local succeeded = pcall(eventDriver.RegisterEvent, eventDriver, eventName)
|
|
126
|
+
local registered = succeeded and eventDriver:IsEventRegistered(eventName)
|
|
127
|
+
if not registered or IsSecret(registered) then
|
|
128
|
+
eventDriver:UnregisterAllEvents()
|
|
129
|
+
return false, L.UNAVAILABLE_EVENT .. eventName
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
changedCallback = callback
|
|
134
|
+
running = true
|
|
135
|
+
activeEventCount = #names
|
|
136
|
+
startedAt = GetTime()
|
|
137
|
+
return true
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
function monitor.Stop()
|
|
141
|
+
if driver then
|
|
142
|
+
driver:UnregisterAllEvents()
|
|
143
|
+
end
|
|
144
|
+
changedCallback = nil
|
|
145
|
+
running = false
|
|
146
|
+
activeEventCount = 0
|
|
147
|
+
monitoringAllEvents = false
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
function monitor.Clear()
|
|
151
|
+
wipe(records)
|
|
152
|
+
head = 0
|
|
153
|
+
count = 0
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
function monitor.GetCount()
|
|
157
|
+
return count
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
function monitor.GetRecord(newestIndex)
|
|
161
|
+
if type(newestIndex) ~= "number" or newestIndex < 1 or newestIndex > count then
|
|
162
|
+
return nil
|
|
163
|
+
end
|
|
164
|
+
local physicalIndex = (head - newestIndex) % MAX_RECORDS + 1
|
|
165
|
+
return records[physicalIndex]
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
function monitor.IsRunning()
|
|
169
|
+
return running
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
function monitor.GetActiveEventCount()
|
|
173
|
+
return activeEventCount
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
function monitor.IsMonitoringAllEvents()
|
|
177
|
+
return monitoringAllEvents
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
ns.EventMonitor = monitor
|
|
181
|
+
ns.RegisterCombatShutdown(monitor.Stop)
|
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
local ADDON_NAME, ns = ...
|
|
2
|
-
|
|
3
|
-
local trace = {}
|
|
4
|
-
local MAX_RECORDS = 300
|
|
5
|
-
local MAX_ARGUMENTS = 16
|
|
6
|
-
local MAX_ARGUMENT_BYTES = 180
|
|
7
|
-
local hooks = {}
|
|
8
|
-
local records = {}
|
|
9
|
-
local head, count = 0, 0
|
|
10
|
-
local activePath
|
|
11
|
-
local enabled = false
|
|
12
|
-
local changedCallback
|
|
13
|
-
local startedAt = 0
|
|
14
|
-
|
|
15
|
-
local function IsSecret(value)
|
|
16
|
-
return issecretvalue and issecretvalue(value)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
local function FormatArgument(value)
|
|
20
|
-
if IsSecret(value) then return "<secret>" end
|
|
21
|
-
local valueType = type(value)
|
|
22
|
-
local text
|
|
23
|
-
if valueType == "string" then
|
|
24
|
-
text = string.format("%q", value)
|
|
25
|
-
elseif valueType == "number" or valueType == "boolean" or valueType == "nil" then
|
|
26
|
-
text = tostring(value)
|
|
27
|
-
elseif valueType == "table" then
|
|
28
|
-
text = "<table>"
|
|
29
|
-
else
|
|
30
|
-
text = "<" .. valueType .. ">"
|
|
31
|
-
end
|
|
32
|
-
return #text > MAX_ARGUMENT_BYTES and (text:sub(1, MAX_ARGUMENT_BYTES) .. "...") or text
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
local function OnCall(path, ...)
|
|
36
|
-
if not enabled or activePath ~= path or ns.IsCombatBlocked() then return end
|
|
37
|
-
local suppliedCount = select("#", ...)
|
|
38
|
-
local arguments = {}
|
|
39
|
-
for index = 1, math.min(suppliedCount, MAX_ARGUMENTS) do
|
|
40
|
-
arguments[index] = FormatArgument(select(index, ...))
|
|
41
|
-
end
|
|
42
|
-
if suppliedCount > MAX_ARGUMENTS then
|
|
43
|
-
arguments[#arguments + 1] = "<" .. (suppliedCount - MAX_ARGUMENTS) .. " more arguments>"
|
|
44
|
-
end
|
|
45
|
-
head = head % MAX_RECORDS + 1
|
|
46
|
-
records[head] = { elapsed = math.max(0, GetTime() - startedAt), path = path, arguments = arguments, summary = table.concat(arguments, ", ") }
|
|
47
|
-
count = math.min(count + 1, MAX_RECORDS)
|
|
48
|
-
if changedCallback then changedCallback(records[head]) end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
function trace.Start(path, callback)
|
|
52
|
-
if ns.IsCombatBlocked() then return false, ns.L.COMBAT_BLOCKED end
|
|
53
|
-
path = tostring(path or ""):match("^%s*(.-)%s*$")
|
|
54
|
-
local succeeded, owner, functionName, errorMessage = ns.ObjectInspector.ResolveFunctionTarget(path)
|
|
55
|
-
if not succeeded then return false, errorMessage end
|
|
56
|
-
local target = owner[functionName]
|
|
57
|
-
if IsSecret(target) or type(target) ~= "function" then return false, ns.L.FUNCTION_NOT_FOUND end
|
|
58
|
-
if not hooks[path] then
|
|
59
|
-
local hooked = pcall(hooksecurefunc, owner, functionName, function(...) OnCall(path, ...) end)
|
|
60
|
-
if not hooked then return false, ns.L.FUNCTION_HOOK_FAILED end
|
|
61
|
-
hooks[path] = true
|
|
62
|
-
end
|
|
63
|
-
activePath, enabled, changedCallback, startedAt = path, true, callback, GetTime()
|
|
64
|
-
return true
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
function trace.Stop()
|
|
68
|
-
enabled, activePath, changedCallback = false, nil, nil
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
function trace.Clear()
|
|
72
|
-
wipe(records)
|
|
73
|
-
head, count = 0, 0
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
function trace.GetCount() return count end
|
|
77
|
-
function trace.GetRecord(newestIndex)
|
|
78
|
-
if type(newestIndex) ~= "number" or newestIndex < 1 or newestIndex > count then return nil end
|
|
79
|
-
return records[(head - newestIndex) % MAX_RECORDS + 1]
|
|
80
|
-
end
|
|
81
|
-
function trace.IsRunning() return enabled end
|
|
82
|
-
function trace.GetActivePath() return activePath end
|
|
83
|
-
|
|
84
|
-
ns.RegisterCombatShutdown(trace.Stop)
|
|
85
|
-
ns.FunctionTrace = trace
|
|
1
|
+
local ADDON_NAME, ns = ...
|
|
2
|
+
|
|
3
|
+
local trace = {}
|
|
4
|
+
local MAX_RECORDS = 300
|
|
5
|
+
local MAX_ARGUMENTS = 16
|
|
6
|
+
local MAX_ARGUMENT_BYTES = 180
|
|
7
|
+
local hooks = {}
|
|
8
|
+
local records = {}
|
|
9
|
+
local head, count = 0, 0
|
|
10
|
+
local activePath
|
|
11
|
+
local enabled = false
|
|
12
|
+
local changedCallback
|
|
13
|
+
local startedAt = 0
|
|
14
|
+
|
|
15
|
+
local function IsSecret(value)
|
|
16
|
+
return issecretvalue and issecretvalue(value)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
local function FormatArgument(value)
|
|
20
|
+
if IsSecret(value) then return "<secret>" end
|
|
21
|
+
local valueType = type(value)
|
|
22
|
+
local text
|
|
23
|
+
if valueType == "string" then
|
|
24
|
+
text = string.format("%q", value)
|
|
25
|
+
elseif valueType == "number" or valueType == "boolean" or valueType == "nil" then
|
|
26
|
+
text = tostring(value)
|
|
27
|
+
elseif valueType == "table" then
|
|
28
|
+
text = "<table>"
|
|
29
|
+
else
|
|
30
|
+
text = "<" .. valueType .. ">"
|
|
31
|
+
end
|
|
32
|
+
return #text > MAX_ARGUMENT_BYTES and (text:sub(1, MAX_ARGUMENT_BYTES) .. "...") or text
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
local function OnCall(path, ...)
|
|
36
|
+
if not enabled or activePath ~= path or ns.IsCombatBlocked() then return end
|
|
37
|
+
local suppliedCount = select("#", ...)
|
|
38
|
+
local arguments = {}
|
|
39
|
+
for index = 1, math.min(suppliedCount, MAX_ARGUMENTS) do
|
|
40
|
+
arguments[index] = FormatArgument(select(index, ...))
|
|
41
|
+
end
|
|
42
|
+
if suppliedCount > MAX_ARGUMENTS then
|
|
43
|
+
arguments[#arguments + 1] = "<" .. (suppliedCount - MAX_ARGUMENTS) .. " more arguments>"
|
|
44
|
+
end
|
|
45
|
+
head = head % MAX_RECORDS + 1
|
|
46
|
+
records[head] = { elapsed = math.max(0, GetTime() - startedAt), path = path, arguments = arguments, summary = table.concat(arguments, ", ") }
|
|
47
|
+
count = math.min(count + 1, MAX_RECORDS)
|
|
48
|
+
if changedCallback then changedCallback(records[head]) end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
function trace.Start(path, callback)
|
|
52
|
+
if ns.IsCombatBlocked() then return false, ns.L.COMBAT_BLOCKED end
|
|
53
|
+
path = tostring(path or ""):match("^%s*(.-)%s*$")
|
|
54
|
+
local succeeded, owner, functionName, errorMessage = ns.ObjectInspector.ResolveFunctionTarget(path)
|
|
55
|
+
if not succeeded then return false, errorMessage end
|
|
56
|
+
local target = owner[functionName]
|
|
57
|
+
if IsSecret(target) or type(target) ~= "function" then return false, ns.L.FUNCTION_NOT_FOUND end
|
|
58
|
+
if not hooks[path] then
|
|
59
|
+
local hooked = pcall(hooksecurefunc, owner, functionName, function(...) OnCall(path, ...) end)
|
|
60
|
+
if not hooked then return false, ns.L.FUNCTION_HOOK_FAILED end
|
|
61
|
+
hooks[path] = true
|
|
62
|
+
end
|
|
63
|
+
activePath, enabled, changedCallback, startedAt = path, true, callback, GetTime()
|
|
64
|
+
return true
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
function trace.Stop()
|
|
68
|
+
enabled, activePath, changedCallback = false, nil, nil
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
function trace.Clear()
|
|
72
|
+
wipe(records)
|
|
73
|
+
head, count = 0, 0
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
function trace.GetCount() return count end
|
|
77
|
+
function trace.GetRecord(newestIndex)
|
|
78
|
+
if type(newestIndex) ~= "number" or newestIndex < 1 or newestIndex > count then return nil end
|
|
79
|
+
return records[(head - newestIndex) % MAX_RECORDS + 1]
|
|
80
|
+
end
|
|
81
|
+
function trace.IsRunning() return enabled end
|
|
82
|
+
function trace.GetActivePath() return activePath end
|
|
83
|
+
|
|
84
|
+
ns.RegisterCombatShutdown(trace.Stop)
|
|
85
|
+
ns.FunctionTrace = trace
|