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,573 @@
1
+ local ADDON_NAME, ns = ...
2
+ local L = ns.L
3
+
4
+ local ROW_HEIGHT = 38
5
+ local VISIBLE_ROWS = 16
6
+ local LIST_WIDTH = 420
7
+ local TEXT_CHUNK_BYTES = 44000
8
+ local TEXT_LOAD_THRESHOLD = 80
9
+
10
+ local function CreateLineInput(parent, ui)
11
+ local panel = ui.CreatePanel(parent, ui.editorR, ui.editorG, ui.editorB, 1)
12
+ local editBox = CreateFrame("EditBox", nil, panel)
13
+ editBox:SetAutoFocus(false)
14
+ editBox:SetFontObject(ChatFontNormal)
15
+ editBox:SetTextColor(0.94, 0.95, 0.96)
16
+ editBox:SetTextInsets(9, 9, 0, 0)
17
+ editBox:SetPoint("TOPLEFT", 1, -1)
18
+ editBox:SetPoint("BOTTOMRIGHT", -1, 1)
19
+ editBox:SetScript("OnEscapePressed", function(self) self:ClearFocus() end)
20
+ editBox:SetScript("OnEditFocusGained", function() ui.SetBorderColor(panel, true, 0.75) end)
21
+ editBox:SetScript("OnEditFocusLost", function() ui.SetBorderColor(panel, false) end)
22
+ panel.editBox = editBox
23
+ return panel
24
+ end
25
+
26
+ function ns.CreateObjectPage(parent, ui)
27
+ local page = CreateFrame("Frame", nil, parent)
28
+ page:SetAllPoints(parent)
29
+
30
+ local mouseButton = ui.CreateButton(page, 118, L.CAPTURE_MOUSE)
31
+ mouseButton:SetPoint("TOPRIGHT", -14, -84)
32
+ local searchButton = ui.CreateButton(page, 82, L.SEARCH)
33
+ searchButton:SetPoint("RIGHT", mouseButton, "LEFT", -8, 0)
34
+ local inspectButton = ui.CreateButton(page, 82, L.INSPECT, true)
35
+ inspectButton:SetPoint("RIGHT", searchButton, "LEFT", -8, 0)
36
+
37
+ local pathPanel = CreateLineInput(page, ui)
38
+ pathPanel:SetPoint("TOPLEFT", 14, -84)
39
+ pathPanel:SetPoint("TOPRIGHT", inspectButton, "TOPLEFT", -8, 0)
40
+ pathPanel:SetHeight(30)
41
+ pathPanel.editBox:SetText("_G")
42
+
43
+ local inputHint = pathPanel:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall")
44
+ inputHint:SetPoint("LEFT", 10, 0)
45
+ inputHint:SetText(L.OBJECT_INPUT_HINT)
46
+ inputHint:SetTextColor(1, 1, 1, 0.3)
47
+ inputHint:Hide()
48
+
49
+ local statusDot = page:CreateTexture(nil, "ARTWORK")
50
+ statusDot:SetSize(5, 5)
51
+ statusDot:SetPoint("TOPLEFT", 17, -135)
52
+ local status = page:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
53
+ status:SetPoint("LEFT", statusDot, "RIGHT", 7, 0)
54
+ status:SetPoint("RIGHT", -14, 0)
55
+ status:SetJustifyH("LEFT")
56
+ local function SetStatus(text, r, g, b)
57
+ status:SetText(text)
58
+ status:SetTextColor(r, g, b, 0.92)
59
+ statusDot:SetColorTexture(r, g, b, 0.92)
60
+ end
61
+
62
+ local function BindIncrementalText(panel, textStream, onProgress)
63
+ panel.serializationStream = textStream
64
+ panel.loadingSerialization = false
65
+
66
+ local function LoadNextChunk()
67
+ local stream = panel.serializationStream
68
+ if panel.loadingSerialization or not stream or stream:IsFinished() then
69
+ return
70
+ end
71
+ panel.loadingSerialization = true
72
+ local chunk, finished = stream:ReadChunk(TEXT_CHUNK_BYTES)
73
+ if chunk ~= "" then
74
+ ui.AppendReadOnlyText(panel, chunk)
75
+ end
76
+ panel.loadingSerialization = false
77
+ if onProgress then
78
+ onProgress(#panel.editBox.savedText, finished, stream:WasLimited())
79
+ end
80
+ end
81
+
82
+ panel.scroll.onVerticalScrollChanged = function(offset)
83
+ local range = panel.scroll.verticalRange or 0
84
+ if range - (tonumber(offset) or 0) <= TEXT_LOAD_THRESHOLD then
85
+ LoadNextChunk()
86
+ end
87
+ end
88
+ panel.LoadNextChunk = LoadNextChunk
89
+ end
90
+
91
+ local listLabel = ui.CreateSectionLabel(page, L.SEARCH_RESULTS)
92
+ listLabel:SetPoint("TOPLEFT", 17, -161)
93
+ local detailLabel = ui.CreateSectionLabel(page, L.OBJECT_SNAPSHOT)
94
+ detailLabel:SetPoint("TOPLEFT", LIST_WIDTH + 29, -161)
95
+
96
+ local treeHint = page:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall")
97
+ treeHint:SetPoint("LEFT", detailLabel, "RIGHT", 10, 0)
98
+ treeHint:SetText(L.TREE_CONTEXT_HINT)
99
+ treeHint:SetTextColor(1, 1, 1, 0.32)
100
+
101
+ local listPanel = ui.CreatePanel(page, ui.editorR, ui.editorG, ui.editorB, 0.78)
102
+ listPanel:SetPoint("TOPLEFT", 14, -181)
103
+ listPanel:SetPoint("BOTTOMLEFT", 14, 54)
104
+ listPanel:SetWidth(LIST_WIDTH)
105
+ local listScroll = ui.CreateScrollArea(listPanel, 8, 8, 7, 8)
106
+ local listContent = CreateFrame("Frame", nil, listScroll)
107
+ listContent:SetWidth(LIST_WIDTH - 26)
108
+ listContent:SetHeight(1)
109
+ listScroll:SetScrollChild(listContent)
110
+ local empty = listPanel:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall")
111
+ empty:SetPoint("TOP", 0, -24)
112
+ empty:SetText(L.NO_SEARCH_RESULTS)
113
+ empty:SetTextColor(1, 1, 1, 0.32)
114
+
115
+ local treeView = ns.CreateTreeView(page, {
116
+ CreatePanel = ui.CreatePanel,
117
+ CreateScrollArea = ui.CreateScrollArea,
118
+ editorR = ui.editorR, editorG = ui.editorG, editorB = ui.editorB,
119
+ surfaceR = ui.surfaceR, surfaceG = ui.surfaceG, surfaceB = ui.surfaceB,
120
+ accentR = ui.accentR, accentG = ui.accentG, accentB = ui.accentB,
121
+ contentWidth = ui.windowWidth - LIST_WIDTH - 54,
122
+ })
123
+ treeView.panel:SetPoint("TOPLEFT", LIST_WIDTH + 26, -181)
124
+ treeView.panel:SetPoint("BOTTOMRIGHT", -14, 54)
125
+
126
+ local textView = ui.CreateTextArea(page, true)
127
+ textView:SetPoint("TOPLEFT", LIST_WIDTH + 26, -181)
128
+ textView:SetPoint("BOTTOMRIGHT", -14, 54)
129
+ textView.editBox:SetWidth(ui.windowWidth - LIST_WIDTH - 78)
130
+ textView.editBox:SetScript("OnMouseUp", function(self) self:SetFocus() end)
131
+
132
+ local textModeButton = ui.CreateViewTab(page, L.TEXT)
133
+ ui.FitViewTab(textModeButton, 58, 28)
134
+ textModeButton:SetPoint("TOPRIGHT", -14, -150)
135
+ local treeModeButton = ui.CreateViewTab(page, L.TREE)
136
+ ui.FitViewTab(treeModeButton, 58, 28)
137
+ treeModeButton:SetPoint("RIGHT", textModeButton, "LEFT", -2, 0)
138
+ local snapshotMode = "tree"
139
+ local function SetSnapshotMode(mode)
140
+ snapshotMode = mode == "text" and "text" or "tree"
141
+ treeView.panel:SetShown(snapshotMode == "tree")
142
+ textView:SetShown(snapshotMode == "text")
143
+ treeModeButton:SetActive(snapshotMode == "tree")
144
+ textModeButton:SetActive(snapshotMode == "text")
145
+ treeHint:SetShown(snapshotMode == "tree")
146
+ end
147
+ treeModeButton:SetScript("OnClick", function() SetSnapshotMode("tree") end)
148
+ textModeButton:SetScript("OnClick", function() SetSnapshotMode("text") end)
149
+
150
+ local selectSnapshot = ui.CreateButton(page, 132, L.SELECT_LOADED_TEXT, false)
151
+ selectSnapshot:SetPoint("BOTTOMRIGHT", -14, 14)
152
+ selectSnapshot:SetScript("OnClick", function()
153
+ SetSnapshotMode("text")
154
+ textView:SelectAll()
155
+ end)
156
+
157
+ local exportSnapshot = ui.CreateButton(page, 92, L.SAVE_TO_DISK, false)
158
+ exportSnapshot:SetPoint("RIGHT", selectSnapshot, "LEFT", -8, 0)
159
+ page.inspectButton = inspectButton
160
+ page.searchButton = searchButton
161
+ page.mouseButton = mouseButton
162
+ page.selectSnapshot = selectSnapshot
163
+ page.exportSnapshot = exportSnapshot
164
+ page.treeView = treeView
165
+ page.textView = textView
166
+
167
+ local pickerDock
168
+ local pickerPrompt
169
+ local pickerActive = false
170
+ local StopPicker
171
+ local ShowInspection
172
+ local currentValue
173
+ local currentLabel
174
+ local searchRootLabel
175
+ local nodePopup
176
+
177
+ local function GetNodePath(node)
178
+ local labels = {}
179
+ while node and node.parent do
180
+ labels[#labels + 1] = node.label or "?"
181
+ node = node.parent
182
+ end
183
+ local path = currentLabel or "?"
184
+ for index = #labels, 1, -1 do
185
+ path = path .. " / " .. labels[index]
186
+ end
187
+ return path
188
+ end
189
+
190
+ local function EnsureNodePopup()
191
+ if nodePopup then
192
+ return nodePopup
193
+ end
194
+
195
+ local overlay = ui.CreatePanel(page, 0, 0, 0, 0.76)
196
+ overlay:SetAllPoints(page)
197
+ overlay:SetFrameLevel(page:GetFrameLevel() + 40)
198
+ overlay:EnableMouse(true)
199
+
200
+ local panel = ui.CreatePanel(overlay, ui.surfaceR, ui.surfaceG, ui.surfaceB, 1)
201
+ panel:SetSize(760, 520)
202
+ panel:SetPoint("CENTER")
203
+ panel:SetFrameLevel(overlay:GetFrameLevel() + 1)
204
+
205
+ local title = panel:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
206
+ title:SetPoint("TOPLEFT", 18, -17)
207
+ title:SetText(L.NODE_TEXT_TITLE)
208
+
209
+ local path = panel:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall")
210
+ path:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -8)
211
+ path:SetPoint("RIGHT", -18, 0)
212
+ path:SetJustifyH("LEFT")
213
+ path:SetWordWrap(false)
214
+ path:SetTextColor(1, 1, 1, 0.42)
215
+
216
+ local textPanel = ui.CreateTextArea(panel, true)
217
+ textPanel:SetPoint("TOPLEFT", 14, -66)
218
+ textPanel:SetPoint("BOTTOMRIGHT", -14, 56)
219
+ textPanel.editBox:SetWidth(712)
220
+
221
+ local progress = panel:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall")
222
+ progress:SetPoint("BOTTOMLEFT", 18, 21)
223
+ progress:SetTextColor(1, 1, 1, 0.36)
224
+
225
+ local closeButton = ui.CreateButton(panel, 82, L.CLOSE, false)
226
+ closeButton:SetPoint("BOTTOMRIGHT", -14, 14)
227
+ closeButton:SetScript("OnClick", function()
228
+ overlay:Hide()
229
+ BindIncrementalText(textPanel, nil)
230
+ end)
231
+
232
+ local selectButton = ui.CreateButton(panel, 118, L.SELECT_LOADED_TEXT, false)
233
+ selectButton:SetPoint("RIGHT", closeButton, "LEFT", -8, 0)
234
+ selectButton:SetScript("OnClick", function() textPanel:SelectAll() end)
235
+
236
+ local exportButton = ui.CreateButton(panel, 92, L.SAVE_TO_DISK, false)
237
+ exportButton:SetPoint("RIGHT", selectButton, "LEFT", -8, 0)
238
+ exportButton:SetScript("OnClick", function()
239
+ local nodePath = path:GetText()
240
+ ui.ExportText("object_node", nodePath, function()
241
+ return ns.SerializeForExport(nodePopup.source)
242
+ end, {
243
+ path = path:GetText(),
244
+ valueType = type(nodePopup.source),
245
+ })
246
+ end)
247
+
248
+ nodePopup = {
249
+ overlay = overlay,
250
+ path = path,
251
+ progress = progress,
252
+ textPanel = textPanel,
253
+ closeButton = closeButton,
254
+ exportButton = exportButton,
255
+ }
256
+ page.nodePopup = nodePopup
257
+ overlay:Hide()
258
+ return nodePopup
259
+ end
260
+
261
+ local function OpenNodePopup(node)
262
+ if not node or not node.exportable then
263
+ return
264
+ end
265
+ local popup = EnsureNodePopup()
266
+ local nodePath = GetNodePath(node)
267
+ popup.source = node.source
268
+ local stream = ns.CreateSerializationStream(node.source)
269
+ local serialized, finished = stream:ReadChunk(TEXT_CHUNK_BYTES)
270
+ popup.path:SetText(nodePath)
271
+ ui.SetReadOnlyText(popup.textPanel,
272
+ string.format(L.OBJECT_TEXT_HEADER, nodePath, type(node.source)) .. "\n" .. serialized)
273
+ local function UpdateProgress(bytes, isFinished, limited)
274
+ popup.progress:SetText(string.format(isFinished and L.TEXT_LOADED_COMPLETE or L.TEXT_LOADED_MORE,
275
+ math.floor(bytes / 1024 + 0.5)))
276
+ if isFinished and limited then
277
+ popup.progress:SetText(L.TEXT_LIMIT_REACHED)
278
+ end
279
+ end
280
+ BindIncrementalText(popup.textPanel, stream, UpdateProgress)
281
+ UpdateProgress(#popup.textPanel.editBox.savedText, finished, stream:WasLimited())
282
+ popup.overlay:Show()
283
+ end
284
+
285
+ treeView:SetOnNodeContext(OpenNodePopup)
286
+
287
+ exportSnapshot:SetScript("OnClick", function()
288
+ local label = currentLabel or L.OBJECT_SNAPSHOT
289
+ ui.ExportText("object_snapshot", label, function()
290
+ return ns.SerializeForExport(currentValue)
291
+ end, { path = currentLabel or "", valueType = type(currentValue) })
292
+ end)
293
+
294
+ local function CompletePicker()
295
+ local succeeded, inspection, errorMessage = ns.ObjectInspector.CaptureMouseFocus()
296
+ StopPicker(false)
297
+ if ns.IsCombatBlocked() then
298
+ return
299
+ end
300
+ parent:Show()
301
+ if succeeded then
302
+ pathPanel.editBox:SetText("")
303
+ ShowInspection(inspection)
304
+ else
305
+ SetStatus(errorMessage or L.NO_MOUSE_FOCUS, ui.accentR, ui.accentG, ui.accentB)
306
+ end
307
+ end
308
+
309
+ local function EnsurePickerDock()
310
+ if pickerDock then
311
+ return
312
+ end
313
+
314
+ pickerDock = CreateFrame("Button", "LycheeDevPickerDock", UIParent, "BackdropTemplate")
315
+ pickerDock:SetSize(48, 48)
316
+ pickerDock:SetPoint("TOP", UIParent, "TOP", 0, -36)
317
+ pickerDock:SetFrameStrata("TOOLTIP")
318
+ pickerDock:SetClampedToScreen(true)
319
+
320
+ local logo = pickerDock:CreateTexture(nil, "ARTWORK")
321
+ logo:SetTexture("Interface\\AddOns\\" .. ADDON_NAME .. "\\Media\\Logo.png")
322
+ logo:SetTexCoord(0.18, 0.79, 0.17, 0.80)
323
+ logo:SetPoint("TOPLEFT", 5, -5)
324
+ logo:SetPoint("BOTTOMRIGHT", -5, 5)
325
+
326
+ pickerPrompt = ui.CreatePanel(pickerDock, ui.editorR, ui.editorG, ui.editorB, 0.98)
327
+ pickerPrompt:SetPoint("TOP", pickerDock, "BOTTOM", 0, -7)
328
+ pickerPrompt:SetSize(220, 28)
329
+ pickerPrompt:SetFrameLevel(pickerDock:GetFrameLevel() + 1)
330
+ local promptText = pickerPrompt:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
331
+ promptText:SetPoint("CENTER")
332
+ promptText:SetText(L.PICKER_PROMPT)
333
+ promptText:SetTextColor(1, 1, 1, 0.86)
334
+ pickerPrompt:Hide()
335
+
336
+ pickerDock:SetScript("OnClick", function()
337
+ StopPicker(true, L.PICKER_CANCELLED)
338
+ end)
339
+ pickerDock:Hide()
340
+ end
341
+
342
+ StopPicker = function(restoreWindow, statusText)
343
+ pickerActive = false
344
+ if pickerDock then
345
+ pickerDock:SetScript("OnKeyDown", nil)
346
+ if not ns.IsCombatBlocked() then
347
+ pickerDock:EnableKeyboard(false)
348
+ end
349
+ pickerDock:Hide()
350
+ pickerPrompt:Hide()
351
+ end
352
+ if restoreWindow and not ns.IsCombatBlocked() then
353
+ parent:Show()
354
+ SetStatus(statusText or L.PICKER_CANCELLED, 0.55, 0.60, 0.65)
355
+ end
356
+ end
357
+
358
+ local function StartPicker()
359
+ if ns.IsCombatBlocked() then
360
+ SetStatus(L.COMBAT_BLOCKED, ui.accentR, ui.accentG, ui.accentB)
361
+ return
362
+ end
363
+ EnsurePickerDock()
364
+ SetStatus(L.PICKER_ACTIVE, 0.42, 0.76, 0.43)
365
+ parent:Hide()
366
+ pickerActive = true
367
+ pickerDock:EnableKeyboard(true)
368
+ pickerDock:SetScript("OnKeyDown", function(self, key)
369
+ if key == "F" or key == "ENTER" then
370
+ self:SetPropagateKeyboardInput(false)
371
+ CompletePicker()
372
+ elseif key == "ESCAPE" then
373
+ self:SetPropagateKeyboardInput(false)
374
+ StopPicker(true, L.PICKER_CANCELLED)
375
+ else
376
+ self:SetPropagateKeyboardInput(true)
377
+ end
378
+ end)
379
+ pickerDock:Show()
380
+ pickerPrompt:Show()
381
+ print("|cffd83b4eLychee Dev:|r " .. L.PICKER_HELP)
382
+ end
383
+
384
+ local results = {}
385
+ local rows = {}
386
+ ShowInspection = function(inspection)
387
+ currentValue = inspection.value
388
+ currentLabel = inspection.label
389
+ treeView:SetTree(inspection.tree)
390
+ ui.SetReadOnlyText(textView, inspection.text)
391
+ if inspection.textStream then
392
+ BindIncrementalText(textView, inspection.textStream, function(bytes, finished, limited)
393
+ if finished and limited then
394
+ SetStatus(L.TEXT_LIMIT_REACHED, ui.accentR, ui.accentG, ui.accentB)
395
+ elseif finished then
396
+ SetStatus(string.format(L.OBJECT_READY, inspection.label, inspection.valueType),
397
+ 0.42, 0.76, 0.43)
398
+ else
399
+ SetStatus(string.format(L.OBJECT_LOADING_PROGRESS, inspection.label,
400
+ inspection.valueType, math.floor(bytes / 1024 + 0.5)), 0.42, 0.76, 0.43)
401
+ end
402
+ end)
403
+ else
404
+ BindIncrementalText(textView, nil)
405
+ end
406
+ SetSnapshotMode("tree")
407
+ ui.SetButtonEnabled(selectSnapshot, true)
408
+ ui.SetButtonEnabled(exportSnapshot, true)
409
+ local readyText = L.OBJECT_READY
410
+ if inspection.textStream and not inspection.textStream:IsFinished() then
411
+ readyText = L.OBJECT_READY_MORE
412
+ end
413
+ SetStatus(string.format(readyText, inspection.label, inspection.valueType), 0.42, 0.76, 0.43)
414
+ end
415
+
416
+ local function InspectPath(path)
417
+ local succeeded, inspection, errorMessage = ns.ObjectInspector.InspectPath(path)
418
+ if succeeded then
419
+ pathPanel.editBox:SetText(path)
420
+ ShowInspection(inspection)
421
+ else
422
+ SetStatus(errorMessage or L.OBJECT_NOT_FOUND, ui.accentR, ui.accentG, ui.accentB)
423
+ end
424
+ end
425
+
426
+ local function ChildPath(root, key)
427
+ if key:match("^[_%a][_%w]*$") then return root .. "." .. key end
428
+ return root .. "[" .. string.format("%q", key) .. "]"
429
+ end
430
+
431
+ local function ResultPath(root, result)
432
+ local path = result.path or result.key
433
+ if path:sub(1, 1) == "[" then return root .. path end
434
+ return root .. "." .. path
435
+ end
436
+
437
+ local function CreateRow(index)
438
+ local row = ui.CreateListRow(listContent, ROW_HEIGHT)
439
+ row:SetWidth(LIST_WIDTH - 26)
440
+ local name = row:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
441
+ name:SetPoint("TOPLEFT", 9, -6)
442
+ name:SetPoint("TOPRIGHT", -9, -6)
443
+ name:SetJustifyH("LEFT")
444
+ name:SetWordWrap(false)
445
+ row.name = name
446
+ local preview = row:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall")
447
+ preview:SetPoint("BOTTOMLEFT", 9, 5)
448
+ preview:SetPoint("BOTTOMRIGHT", -9, 5)
449
+ preview:SetJustifyH("LEFT")
450
+ preview:SetWordWrap(false)
451
+ preview:SetTextColor(1, 1, 1, 0.38)
452
+ row.preview = preview
453
+ row:SetScript("OnEnter", function(self)
454
+ self.isHovered = true
455
+ ui.SetListRowState(self, false, true)
456
+ end)
457
+ row:SetScript("OnLeave", function(self)
458
+ self.isHovered = nil
459
+ ui.SetListRowState(self, false, false)
460
+ end)
461
+ row:SetScript("OnClick", function(self)
462
+ if not self.result then return end
463
+ local label = ResultPath(searchRootLabel or currentLabel or "_G", self.result)
464
+ local succeeded, inspection, errorMessage = ns.ObjectInspector.InspectValue(self.result.value, label)
465
+ if succeeded then
466
+ pathPanel.editBox:SetText("")
467
+ ShowInspection(inspection)
468
+ else
469
+ SetStatus(errorMessage or L.OBJECT_NOT_FOUND, ui.accentR, ui.accentG, ui.accentB)
470
+ end
471
+ end)
472
+ rows[index] = row
473
+ return row
474
+ end
475
+
476
+ local function RefreshResults()
477
+ for index = 1, #rows do rows[index]:Hide() end
478
+ local offset = listScroll:GetVerticalScroll()
479
+ if issecretvalue and issecretvalue(offset) then offset = 0 end
480
+ local first = math.floor((offset or 0) / ROW_HEIGHT) + 1
481
+ local last = math.min(#results, first + VISIBLE_ROWS - 1)
482
+ local pool = 0
483
+ for resultIndex = first, last do
484
+ pool = pool + 1
485
+ local result = results[resultIndex]
486
+ local row = rows[pool] or CreateRow(pool)
487
+ row.result = result
488
+ row:ClearAllPoints()
489
+ row:SetPoint("TOPLEFT", 0, -((resultIndex - 1) * ROW_HEIGHT))
490
+ row.name:SetText(result.path or result.key)
491
+ row.preview:SetText(result.valueType .. " " .. result.preview)
492
+ ui.SetListRowState(row, false, row.isHovered)
493
+ row:Show()
494
+ end
495
+ listContent:SetHeight(math.max(1, #results * ROW_HEIGHT))
496
+ listScroll:UpdateScrollChildRect()
497
+ empty:SetShown(#results == 0)
498
+ end
499
+ listScroll.onVerticalScrollChanged = RefreshResults
500
+
501
+ inspectButton:SetScript("OnClick", function() InspectPath(pathPanel.editBox:GetText()) end)
502
+ mouseButton:SetScript("OnClick", StartPicker)
503
+ local function Search()
504
+ local query = pathPanel.editBox:GetText()
505
+ local succeeded, searchResult, errorMessage
506
+ local searchedGlobal = currentValue == nil
507
+ if searchedGlobal then
508
+ succeeded, searchResult, errorMessage = ns.ObjectInspector.SearchGlobal(query)
509
+ else
510
+ succeeded, searchResult, errorMessage = ns.ObjectInspector.SearchValue(currentValue, query)
511
+ if succeeded and searchResult.totalMatches == 0 then
512
+ succeeded, searchResult, errorMessage = ns.ObjectInspector.SearchGlobal(query)
513
+ searchedGlobal = succeeded
514
+ end
515
+ end
516
+ if succeeded then
517
+ results = searchResult.results
518
+ searchRootLabel = searchedGlobal and "_G" or currentLabel
519
+ RefreshResults()
520
+ local message = searchedGlobal
521
+ and string.format(L.GLOBAL_MATCH_COUNT, searchResult.totalMatches)
522
+ or string.format(L.MATCH_COUNT, searchResult.totalMatches)
523
+ SetStatus(message, 0.55, 0.60, 0.65)
524
+ else
525
+ SetStatus(errorMessage, ui.accentR, ui.accentG, ui.accentB)
526
+ end
527
+ end
528
+ searchButton:SetScript("OnClick", Search)
529
+ pathPanel.editBox:SetScript("OnEnterPressed", function(self)
530
+ if currentValue ~= nil and self:GetText() ~= "_G" then
531
+ Search()
532
+ else
533
+ InspectPath(self:GetText())
534
+ end
535
+ end)
536
+ pathPanel.editBox:SetScript("OnTextChanged", function(self)
537
+ inputHint:SetShown(self:GetText() == "" and not self:HasFocus())
538
+ end)
539
+ pathPanel.editBox:SetScript("OnEditFocusGained", function()
540
+ inputHint:Hide()
541
+ ui.SetBorderColor(pathPanel, true, 0.75)
542
+ end)
543
+ pathPanel.editBox:SetScript("OnEditFocusLost", function(self)
544
+ inputHint:SetShown(self:GetText() == "")
545
+ ui.SetBorderColor(pathPanel, false)
546
+ end)
547
+
548
+ function page:Activate()
549
+ if pickerActive then
550
+ StopPicker(false)
551
+ end
552
+ pathPanel.editBox:SetFocus()
553
+ end
554
+ function page:Stop()
555
+ StopPicker(false)
556
+ BindIncrementalText(textView, nil)
557
+ if nodePopup then
558
+ nodePopup.overlay:Hide()
559
+ BindIncrementalText(nodePopup.textPanel, nil)
560
+ end
561
+ end
562
+ function page:GetSelection()
563
+ return currentValue, currentLabel
564
+ end
565
+ SetStatus(L.READY, 0.55, 0.60, 0.65)
566
+ treeView:SetTree(nil)
567
+ ui.SetReadOnlyText(textView, "")
568
+ ui.SetButtonEnabled(selectSnapshot, false)
569
+ ui.SetButtonEnabled(exportSnapshot, false)
570
+ SetSnapshotMode("tree")
571
+ RefreshResults()
572
+ return page
573
+ end