lycheedev 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/bin/lycheedev.js +257 -0
  2. package/package.json +42 -0
  3. package/src/addon.js +87 -0
  4. package/src/config.js +64 -0
  5. package/src/doctor.js +100 -0
  6. package/src/install.js +131 -0
  7. package/src/paths.js +93 -0
  8. package/src/python.js +107 -0
  9. package/src/skill.js +48 -0
  10. package/src/wow.js +110 -0
  11. package/vendor/addon/Core/Bootstrap.lua +131 -0
  12. package/vendor/addon/Core/Clients/Mainline.lua +9 -0
  13. package/vendor/addon/Core/Clients/Mists.lua +9 -0
  14. package/vendor/addon/Core/Clients/Titan.lua +9 -0
  15. package/vendor/addon/Core/Compatibility.lua +43 -0
  16. package/vendor/addon/Core/Database.lua +859 -0
  17. package/vendor/addon/Core/Inspector.lua +647 -0
  18. package/vendor/addon/Core/Locale.lua +307 -0
  19. package/vendor/addon/Core/Locale_enUS.lua +318 -0
  20. package/vendor/addon/Core/Safety.lua +42 -0
  21. package/vendor/addon/Core/Serializer.lua +324 -0
  22. package/vendor/addon/Libs/AutomationQR.lua +1176 -0
  23. package/vendor/addon/Lychee Dev_Mainline.toc +43 -0
  24. package/vendor/addon/Lychee Dev_Mists.toc +43 -0
  25. package/vendor/addon/Lychee Dev_Wrath.toc +43 -0
  26. package/vendor/addon/Media/GitHub.png +0 -0
  27. package/vendor/addon/Media/Logo.png +0 -0
  28. package/vendor/addon/Modules/Automation/Controller.lua +757 -0
  29. package/vendor/addon/Modules/Automation/Report.lua +409 -0
  30. package/vendor/addon/Modules/Automation/auto/auto.lua +12 -0
  31. package/vendor/addon/Modules/Diagnostics.lua +238 -0
  32. package/vendor/addon/Modules/Events/Catalog.lua +184 -0
  33. package/vendor/addon/Modules/Events/CatalogData_Mainline.lua +1788 -0
  34. package/vendor/addon/Modules/Events/CatalogData_Mists.lua +1489 -0
  35. package/vendor/addon/Modules/Events/CatalogData_Titan.lua +1492 -0
  36. package/vendor/addon/Modules/Events/Monitor.lua +181 -0
  37. package/vendor/addon/Modules/FunctionTrace.lua +85 -0
  38. package/vendor/addon/Modules/ObjectInspector.lua +329 -0
  39. package/vendor/addon/UI/AutomationOverlay.lua +183 -0
  40. package/vendor/addon/UI/Export.lua +140 -0
  41. package/vendor/addon/UI/Features.lua +890 -0
  42. package/vendor/addon/UI/MainWindow.lua +1145 -0
  43. package/vendor/addon/UI/Pages/About.lua +223 -0
  44. package/vendor/addon/UI/Pages/Automation.lua +417 -0
  45. package/vendor/addon/UI/Pages/Diagnostics.lua +289 -0
  46. package/vendor/addon/UI/Pages/ExportRecords.lua +387 -0
  47. package/vendor/addon/UI/Pages/Object.lua +573 -0
  48. package/vendor/addon/UI/Pages/Trace.lua +165 -0
  49. package/vendor/skill/SKILL.md +94 -0
  50. package/vendor/skill/agents/openai.yaml +4 -0
  51. package/vendor/skill/references/automation.md +327 -0
  52. package/vendor/skill/references/runtime-investigations.md +97 -0
  53. package/vendor/skill/scripts/automation/__init__.py +1 -0
  54. package/vendor/skill/scripts/automation/registry.py +516 -0
  55. package/vendor/skill/scripts/automation/saved_variables.py +438 -0
  56. package/vendor/skill/scripts/automation/session.py +207 -0
  57. package/vendor/skill/scripts/automation/windows.py +573 -0
  58. package/vendor/skill/scripts/automation.py +865 -0
  59. package/vendor/skill/scripts/requirements.txt +13 -0
  60. package/vendor/skill/scripts/selftest_offline.py +981 -0
@@ -0,0 +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)
@@ -0,0 +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
@@ -0,0 +1,329 @@
1
+ local ADDON_NAME, ns = ...
2
+
3
+ local inspector = {}
4
+ local MAX_SEARCH_RESULTS = 200
5
+ local MAX_SEARCH_SCANS = 10000
6
+ local MAX_SEARCH_NODES = 2000
7
+ local MAX_SEARCH_DEPTH = 6
8
+ local MAX_PREVIEW_BYTES = 120
9
+
10
+ local function IsSecret(value)
11
+ return issecretvalue and issecretvalue(value)
12
+ end
13
+
14
+ local function Trim(text)
15
+ return tostring(text or ""):match("^%s*(.-)%s*$")
16
+ end
17
+
18
+ local function ParsePath(path)
19
+ path = Trim(path)
20
+ if path == "" then
21
+ return nil, ns.L.OBJECT_PATH_REQUIRED
22
+ elseif path == "_G" then
23
+ return {}
24
+ elseif path:sub(1, 3) == "_G." then
25
+ path = path:sub(4)
26
+ end
27
+
28
+ local tokens = {}
29
+ local remaining = path
30
+ while remaining ~= "" do
31
+ if remaining:sub(1, 1) == "." then
32
+ remaining = remaining:sub(2)
33
+ end
34
+ local identifier, tail = remaining:match("^([_%a][_%w]*)(.*)$")
35
+ if identifier then
36
+ tokens[#tokens + 1] = identifier
37
+ remaining = tail
38
+ else
39
+ local numberKey
40
+ numberKey, tail = remaining:match("^%[(-?%d+)%](.*)$")
41
+ if numberKey then
42
+ tokens[#tokens + 1] = tonumber(numberKey)
43
+ remaining = tail
44
+ else
45
+ local stringKey
46
+ stringKey, tail = remaining:match('^%["([^"%]]+)"%](.*)$')
47
+ if not stringKey then
48
+ stringKey, tail = remaining:match("^%['([^'%]]+)'%](.*)$")
49
+ end
50
+ if not stringKey then
51
+ return nil, ns.L.OBJECT_PATH_INVALID
52
+ end
53
+ tokens[#tokens + 1] = stringKey
54
+ remaining = tail
55
+ end
56
+ end
57
+ if remaining ~= "" and remaining:sub(1, 1) ~= "." and remaining:sub(1, 1) ~= "[" then
58
+ return nil, ns.L.OBJECT_PATH_INVALID
59
+ end
60
+ end
61
+ return tokens
62
+ end
63
+
64
+ local function ReadMember(value, key)
65
+ if IsSecret(value) or IsSecret(key) then
66
+ return false, nil, ns.L.SECRET_VALUE_BLOCKED
67
+ elseif type(value) == "table" then
68
+ return true, rawget(value, key)
69
+ end
70
+ local succeeded, result = pcall(function() return value[key] end)
71
+ if not succeeded then
72
+ return false, nil, ns.L.OBJECT_PATH_UNREADABLE
73
+ end
74
+ return true, result
75
+ end
76
+
77
+ local function ResolveTokens(tokens, count)
78
+ local value = _G
79
+ for index = 1, count or #tokens do
80
+ local succeeded, nextValue, errorMessage = ReadMember(value, tokens[index])
81
+ if not succeeded then
82
+ return false, nil, errorMessage
83
+ elseif nextValue == nil then
84
+ return false, nil, ns.L.OBJECT_NOT_FOUND
85
+ end
86
+ value = nextValue
87
+ end
88
+ return true, value
89
+ end
90
+
91
+ local function SafePreview(value)
92
+ if IsSecret(value) then return "<secret>" end
93
+ local valueType = type(value)
94
+ local text
95
+ if valueType == "string" then
96
+ text = string.format("%q", value)
97
+ elseif valueType == "number" or valueType == "boolean" or valueType == "nil" then
98
+ text = tostring(value)
99
+ elseif valueType == "table" then
100
+ text = "table"
101
+ else
102
+ local succeeded, result = pcall(tostring, value)
103
+ text = succeeded and result or ("<" .. valueType .. ">")
104
+ end
105
+ return #text > MAX_PREVIEW_BYTES and (text:sub(1, MAX_PREVIEW_BYTES) .. "...") or text
106
+ end
107
+
108
+ local function SafeMethod(value, methodName)
109
+ if IsSecret(value) then return nil end
110
+ local methodSucceeded, method = pcall(function() return value[methodName] end)
111
+ if not methodSucceeded or type(method) ~= "function" then return nil end
112
+ local succeeded, result = pcall(method, value)
113
+ if not succeeded or IsSecret(result) then return nil end
114
+ return result
115
+ end
116
+
117
+ local function SafeMethodResults(value, methodName)
118
+ if IsSecret(value) then return nil end
119
+ local methodSucceeded, method = pcall(function() return value[methodName] end)
120
+ if not methodSucceeded or type(method) ~= "function" then return nil end
121
+ local packed = { pcall(method, value) }
122
+ if not packed[1] then return nil end
123
+ local results = {}
124
+ for index = 2, #packed do
125
+ if packed[index] ~= nil and not IsSecret(packed[index]) then
126
+ results[#results + 1] = packed[index]
127
+ end
128
+ end
129
+ return results
130
+ end
131
+
132
+ local function IsScriptRegion(value)
133
+ if IsSecret(value) then return false end
134
+ local succeeded, method = pcall(function() return value.GetObjectType end)
135
+ return succeeded and type(method) == "function"
136
+ end
137
+
138
+ local function BuildInspection(value, label)
139
+ if IsSecret(value) then return nil, ns.L.SECRET_VALUE_BLOCKED end
140
+ local isFrame = IsScriptRegion(value)
141
+ local textStream = ns.CreateSerializationStream(value)
142
+ local serialized = textStream:ReadChunk()
143
+ return {
144
+ label = label,
145
+ valueType = type(value),
146
+ value = value,
147
+ preview = SafePreview(value),
148
+ isFrame = isFrame,
149
+ text = string.format(ns.L.OBJECT_TEXT_HEADER, label or "", type(value)) .. "\n" .. serialized,
150
+ textStream = textStream,
151
+ tree = ns.CreateValueTree({ n = 1, value }),
152
+ }
153
+ end
154
+
155
+ function inspector.ResolvePath(path)
156
+ local tokens, errorMessage = ParsePath(path)
157
+ if not tokens then return false, nil, errorMessage end
158
+ return ResolveTokens(tokens)
159
+ end
160
+
161
+ function inspector.ResolveFunctionTarget(path)
162
+ local tokens, errorMessage = ParsePath(path)
163
+ if not tokens then return false, nil, nil, errorMessage end
164
+ if #tokens == 0 or type(tokens[#tokens]) ~= "string" then
165
+ return false, nil, nil, ns.L.FUNCTION_PATH_INVALID
166
+ end
167
+ local key = tokens[#tokens]
168
+ local succeeded, owner, resolveError = ResolveTokens(tokens, #tokens - 1)
169
+ if not succeeded then return false, nil, nil, resolveError end
170
+ return true, owner, key
171
+ end
172
+
173
+ function inspector.InspectPath(path)
174
+ if ns.IsCombatBlocked() then return false, nil, ns.L.COMBAT_BLOCKED end
175
+ local succeeded, value, errorMessage = inspector.ResolvePath(path)
176
+ if not succeeded then return false, nil, errorMessage end
177
+ local inspection, inspectError = BuildInspection(value, Trim(path))
178
+ return inspection ~= nil, inspection, inspectError
179
+ end
180
+
181
+ function inspector.InspectValue(value, label)
182
+ if ns.IsCombatBlocked() then return false, nil, ns.L.COMBAT_BLOCKED end
183
+ local inspection, inspectError = BuildInspection(value, Trim(label))
184
+ return inspection ~= nil, inspection, inspectError
185
+ end
186
+
187
+ function inspector.CaptureMouseFocus()
188
+ if ns.IsCombatBlocked() then return false, nil, ns.L.COMBAT_BLOCKED end
189
+ local focus = ns.Client.GetMouseFocus()
190
+ if not focus then
191
+ return false, nil, ns.L.NO_MOUSE_FOCUS
192
+ end
193
+ local inspection, errorMessage = BuildInspection(focus, SafeMethod(focus, "GetName") or SafePreview(focus))
194
+ return inspection ~= nil, inspection, errorMessage
195
+ end
196
+
197
+ function inspector.GetMouseFocusLabel()
198
+ if ns.IsCombatBlocked() then return false, nil, nil, ns.L.COMBAT_BLOCKED end
199
+ local focus = ns.Client.GetMouseFocus()
200
+ if not focus then return false, nil, nil, ns.L.NO_MOUSE_FOCUS end
201
+ return true,
202
+ SafeMethod(focus, "GetName") or SafePreview(focus),
203
+ SafeMethod(focus, "GetObjectType") or type(focus)
204
+ end
205
+
206
+ function inspector.SearchValue(value, query, limit, maxDepth)
207
+ if ns.IsCombatBlocked() then return false, nil, ns.L.COMBAT_BLOCKED end
208
+ query = Trim(query):lower()
209
+ if query == "" then return false, nil, ns.L.SEARCH_TERM_REQUIRED end
210
+ if (type(value) ~= "table" and not IsScriptRegion(value)) or IsSecret(value) then
211
+ return false, nil, ns.L.SEARCH_REQUIRES_TABLE
212
+ end
213
+
214
+ limit = math.max(1, math.floor(tonumber(limit) or MAX_SEARCH_RESULTS))
215
+ maxDepth = math.max(0, math.floor(tonumber(maxDepth) or MAX_SEARCH_DEPTH))
216
+ local exact, prefixes, contains = {}, {}, {}
217
+ local matchCount = 0
218
+ local scanned = 0
219
+ local visitedCount = 0
220
+ local seen = {}
221
+ local stack = { { value = value, path = "", depth = 0 } }
222
+
223
+ local function ChildPath(path, key)
224
+ local segment
225
+ if type(key) == "string" and key:match("^[_%a][_%w]*$") then
226
+ segment = key
227
+ return path == "" and segment or (path .. "." .. segment)
228
+ end
229
+ segment = "[" .. SafePreview(key) .. "]"
230
+ return path .. segment
231
+ end
232
+
233
+ local function Push(childValue, path, depth)
234
+ if depth <= maxDepth and (type(childValue) == "table" or IsScriptRegion(childValue))
235
+ and not IsSecret(childValue) and not seen[childValue] then
236
+ stack[#stack + 1] = { value = childValue, path = path, depth = depth }
237
+ end
238
+ end
239
+
240
+ local function AddMatch(key, childValue, path)
241
+ if type(key) ~= "string" or IsSecret(key) then return end
242
+ local lowerKey = key:lower()
243
+ local matchStart = lowerKey:find(query, 1, true)
244
+ if not matchStart then return end
245
+ matchCount = matchCount + 1
246
+ local bucket = lowerKey == query and exact or (matchStart == 1 and prefixes or contains)
247
+ if #exact + #prefixes + #contains < limit and not IsSecret(childValue) then
248
+ bucket[#bucket + 1] = {
249
+ key = key,
250
+ path = path,
251
+ value = childValue,
252
+ valueType = type(childValue),
253
+ preview = SafePreview(childValue),
254
+ }
255
+ end
256
+ end
257
+
258
+ while #stack > 0 and scanned < MAX_SEARCH_SCANS and visitedCount < MAX_SEARCH_NODES do
259
+ local item = stack[#stack]
260
+ stack[#stack] = nil
261
+ local current = item.value
262
+ if not seen[current] then
263
+ seen[current] = true
264
+ visitedCount = visitedCount + 1
265
+
266
+ if type(current) == "table" then
267
+ local cursor
268
+ while scanned < MAX_SEARCH_SCANS do
269
+ local succeeded, key, childValue = pcall(next, current, cursor)
270
+ if not succeeded or key == nil then break end
271
+ cursor = key
272
+ scanned = scanned + 1
273
+ if not IsSecret(key) then
274
+ local path = ChildPath(item.path, key)
275
+ AddMatch(key, childValue, path)
276
+ Push(childValue, path, item.depth + 1)
277
+ end
278
+ end
279
+ end
280
+
281
+ if item.depth < maxDepth and IsScriptRegion(current) then
282
+ local childFrames = SafeMethodResults(current, "GetChildren") or {}
283
+ for index = 1, #childFrames do
284
+ Push(childFrames[index], ChildPath(item.path, ns.L.FRAME_CHILDREN) .. "[" .. index .. "]", item.depth + 1)
285
+ end
286
+ local regions = SafeMethodResults(current, "GetRegions") or {}
287
+ for index = 1, #regions do
288
+ Push(regions[index], ChildPath(item.path, ns.L.FRAME_REGIONS) .. "[" .. index .. "]", item.depth + 1)
289
+ end
290
+ end
291
+
292
+ local metaSucceeded, metatable = pcall(getmetatable, current)
293
+ if metaSucceeded and type(metatable) == "table" then
294
+ local indexTable = rawget(metatable, "__index")
295
+ if type(indexTable) == "table" then
296
+ Push(indexTable, item.path, item.depth + 1)
297
+ end
298
+ end
299
+ end
300
+ end
301
+ table.sort(prefixes, function(left, right) return left.key < right.key end)
302
+ table.sort(contains, function(left, right) return left.key < right.key end)
303
+ local results = {}
304
+ local function Append(bucket)
305
+ for index = 1, #bucket do
306
+ if #results >= limit then return end
307
+ results[#results + 1] = bucket[index]
308
+ end
309
+ end
310
+ Append(exact) Append(prefixes) Append(contains)
311
+ return true, {
312
+ results = results,
313
+ totalMatches = matchCount,
314
+ truncated = matchCount > #results or scanned >= MAX_SEARCH_SCANS or visitedCount >= MAX_SEARCH_NODES,
315
+ }
316
+ end
317
+
318
+ function inspector.SearchGlobal(query, limit)
319
+ return inspector.SearchValue(_G, query, limit, 0)
320
+ end
321
+
322
+ function inspector.SearchPath(path, query, limit)
323
+ if ns.IsCombatBlocked() then return false, nil, ns.L.COMBAT_BLOCKED end
324
+ local succeeded, value, errorMessage = inspector.ResolvePath(path)
325
+ if not succeeded then return false, nil, errorMessage end
326
+ return inspector.SearchValue(value, query, limit)
327
+ end
328
+
329
+ ns.ObjectInspector = inspector