lycheedev 1.2.0 → 2.0.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.
Files changed (118) hide show
  1. package/LICENSE +49 -0
  2. package/README.md +45 -0
  3. package/THIRD_PARTY_NOTICES +812 -0
  4. package/bin/lycheedev.mjs +56 -0
  5. package/native/windows-amd64/lycheedev.exe +0 -0
  6. package/package.json +12 -33
  7. package/payload/addon/Bridge/CaptureWriter.lua +154 -0
  8. package/payload/addon/Bridge/Definitions.lua +3 -0
  9. package/payload/addon/Bridge/Identity.lua +127 -0
  10. package/{vendor/addon/Libs/AutomationQR.lua → payload/addon/Bridge/MatrixSymbol.lua} +23 -30
  11. package/payload/addon/Bridge/ProbeQueue.lua +136 -0
  12. package/payload/addon/Bridge/ProbeRunner.lua +128 -0
  13. package/payload/addon/Bridge/ReceiptView.lua +160 -0
  14. package/payload/addon/Bridge/Reentry.lua +192 -0
  15. package/payload/addon/Bridge/ReportStore.lua +153 -0
  16. package/payload/addon/Bridge/Session.lua +163 -0
  17. package/payload/addon/Clients/Evergreen.lua +2 -0
  18. package/payload/addon/Clients/Live.lua +2 -0
  19. package/payload/addon/Clients/Pandaria.lua +2 -0
  20. package/payload/addon/Clients/Titan.lua +2 -0
  21. package/payload/addon/Core/Compat.lua +59 -0
  22. package/payload/addon/Core/Controls.lua +168 -0
  23. package/{vendor/addon/Core/Bootstrap.lua → payload/addon/Core/Execute.lua} +12 -23
  24. package/{vendor → payload}/addon/Core/Inspector.lua +19 -235
  25. package/{vendor → payload}/addon/Core/Locale.lua +128 -93
  26. package/{vendor → payload}/addon/Core/Locale_enUS.lua +128 -95
  27. package/payload/addon/Core/Persistence.lua +58 -0
  28. package/payload/addon/Core/Platform.lua +58 -0
  29. package/payload/addon/Core/Runtime.lua +25 -0
  30. package/payload/addon/Core/Safety.lua +56 -0
  31. package/{vendor → payload}/addon/Core/Serializer.lua +18 -6
  32. package/payload/addon/Core/Stores.lua +611 -0
  33. package/payload/addon/Lychee Dev_Forever.toc +52 -0
  34. package/payload/addon/Lychee Dev_Mainline.toc +52 -0
  35. package/payload/addon/Lychee Dev_Mists.toc +52 -0
  36. package/payload/addon/Lychee Dev_Wrath.toc +52 -0
  37. package/payload/addon/Modules/AutomationView.lua +393 -0
  38. package/{vendor → payload}/addon/Modules/Diagnostics.lua +92 -36
  39. package/{vendor → payload}/addon/Modules/Events/Catalog.lua +9 -0
  40. package/{vendor → payload}/addon/Modules/Events/Monitor.lua +45 -5
  41. package/payload/addon/Modules/FunctionTrace.lua +150 -0
  42. package/{vendor → payload}/addon/Modules/ObjectInspector.lua +105 -31
  43. package/{vendor → payload}/addon/UI/Export.lua +64 -34
  44. package/{vendor → payload}/addon/UI/Pages/About.lua +26 -14
  45. package/payload/addon/UI/Pages/Automation.lua +446 -0
  46. package/payload/addon/UI/Pages/Diagnostics.lua +402 -0
  47. package/{vendor/addon/UI/Features.lua → payload/addon/UI/Pages/Events.lua} +192 -302
  48. package/{vendor → payload}/addon/UI/Pages/ExportRecords.lua +213 -132
  49. package/{vendor → payload}/addon/UI/Pages/Object.lua +229 -121
  50. package/payload/addon/UI/Pages/Run.lua +423 -0
  51. package/payload/addon/UI/Pages/Trace.lua +314 -0
  52. package/payload/addon/UI/TreeView.lua +246 -0
  53. package/{vendor/addon/UI/MainWindow.lua → payload/addon/UI/Widgets.lua} +89 -529
  54. package/payload/addon/UI/Window.lua +425 -0
  55. package/payload/skill/SKILL.md +87 -0
  56. package/payload/skill/agents/openai.yaml +7 -0
  57. package/payload/skill/references/addon-validation.md +42 -0
  58. package/payload/skill/references/asset-export.md +109 -0
  59. package/payload/skill/references/commands.md +169 -0
  60. package/payload/skill/references/data-investigation.md +242 -0
  61. package/payload/skill/references/error-diagnosis.md +41 -0
  62. package/payload/skill/references/installation.md +18 -0
  63. package/payload/skill/references/live-investigation.md +129 -0
  64. package/payload/skill/references/source-research.md +82 -0
  65. package/payload/skill/scripts/lycheedev.mjs +59 -0
  66. package/release.json +346 -0
  67. package/bin/lycheedev.js +0 -746
  68. package/src/addon.js +0 -95
  69. package/src/config.js +0 -68
  70. package/src/doctor.js +0 -126
  71. package/src/install.js +0 -145
  72. package/src/paths.js +0 -93
  73. package/src/py/instances.py +0 -165
  74. package/src/python.js +0 -111
  75. package/src/skill.js +0 -48
  76. package/src/wow.js +0 -541
  77. package/vendor/addon/Core/Clients/Forever.lua +0 -9
  78. package/vendor/addon/Core/Clients/Mainline.lua +0 -9
  79. package/vendor/addon/Core/Clients/Mists.lua +0 -9
  80. package/vendor/addon/Core/Clients/Titan.lua +0 -9
  81. package/vendor/addon/Core/Compatibility.lua +0 -43
  82. package/vendor/addon/Core/Database.lua +0 -859
  83. package/vendor/addon/Core/Safety.lua +0 -42
  84. package/vendor/addon/Lychee Dev_Forever.toc +0 -44
  85. package/vendor/addon/Lychee Dev_Mainline.toc +0 -44
  86. package/vendor/addon/Lychee Dev_Mists.toc +0 -44
  87. package/vendor/addon/Lychee Dev_Wrath.toc +0 -44
  88. package/vendor/addon/Modules/Automation/Controller.lua +0 -896
  89. package/vendor/addon/Modules/Automation/Reload.lua +0 -101
  90. package/vendor/addon/Modules/Automation/Report.lua +0 -409
  91. package/vendor/addon/Modules/Automation/auto/auto.lua +0 -12
  92. package/vendor/addon/Modules/FunctionTrace.lua +0 -85
  93. package/vendor/addon/UI/AutomationOverlay.lua +0 -253
  94. package/vendor/addon/UI/Pages/Automation.lua +0 -417
  95. package/vendor/addon/UI/Pages/Diagnostics.lua +0 -289
  96. package/vendor/addon/UI/Pages/Trace.lua +0 -165
  97. package/vendor/skill/SKILL.md +0 -44
  98. package/vendor/skill/agents/openai.yaml +0 -4
  99. package/vendor/skill/references/automation.md +0 -130
  100. package/vendor/skill/references/clients.md +0 -51
  101. package/vendor/skill/references/runtime-investigations.md +0 -104
  102. package/vendor/skill/scripts/automation/__init__.py +0 -1
  103. package/vendor/skill/scripts/automation/registry.py +0 -516
  104. package/vendor/skill/scripts/automation/reload.py +0 -121
  105. package/vendor/skill/scripts/automation/saved_variables.py +0 -438
  106. package/vendor/skill/scripts/automation/session.py +0 -207
  107. package/vendor/skill/scripts/automation/windows.py +0 -792
  108. package/vendor/skill/scripts/automation.py +0 -1067
  109. package/vendor/skill/scripts/requirements.txt +0 -13
  110. package/vendor/skill/scripts/selftest_offline.py +0 -1061
  111. package/vendor/skill/scripts/test_input_safety.py +0 -132
  112. package/vendor/skill/scripts/test_reload.py +0 -120
  113. /package/{vendor → payload}/addon/Media/GitHub.png +0 -0
  114. /package/{vendor → payload}/addon/Media/Logo.png +0 -0
  115. /package/{vendor → payload}/addon/Modules/Events/CatalogData_Forever.lua +0 -0
  116. /package/{vendor → payload}/addon/Modules/Events/CatalogData_Mainline.lua +0 -0
  117. /package/{vendor → payload}/addon/Modules/Events/CatalogData_Mists.lua +0 -0
  118. /package/{vendor → payload}/addon/Modules/Events/CatalogData_Titan.lua +0 -0
@@ -0,0 +1,314 @@
1
+ local ADDON_NAME, ns = ...
2
+ local L = ns.L
3
+
4
+ -- Trace workbench page: one bounded function trace at a time with a 300-record
5
+ -- call list and a per-call argument detail pane.
6
+ local ROW_HEIGHT = 38
7
+ local LIST_WIDTH = 520
8
+ local VISIBLE_ROWS = 18
9
+
10
+ -- The single built page instance; only read by the shell export hook.
11
+ local builtPage
12
+
13
+ local function CreateLineInput(parent)
14
+ local W = ns.Widgets
15
+ local colors = W.Colors
16
+ local panel = W.CreatePanel(parent, colors.editor[1], colors.editor[2], colors.editor[3], 1)
17
+ local editBox = CreateFrame("EditBox", nil, panel)
18
+ editBox:SetAutoFocus(false)
19
+ editBox:SetFontObject(ChatFontNormal)
20
+ editBox:SetTextColor(0.94, 0.95, 0.96)
21
+ editBox:SetTextInsets(9, 9, 0, 0)
22
+ editBox:SetPoint("TOPLEFT", 1, -1)
23
+ editBox:SetPoint("BOTTOMRIGHT", -1, 1)
24
+ editBox:SetScript("OnEscapePressed", function(self)
25
+ self:ClearFocus()
26
+ end)
27
+ panel.editBox = editBox
28
+ return panel
29
+ end
30
+
31
+ local function BuildTracePage(parent)
32
+ local W = ns.Widgets
33
+ local colors = W.Colors
34
+ local layout = ns.Workbench.Layout
35
+ local accent = colors.accent
36
+
37
+ local page = CreateFrame("Frame", nil, parent)
38
+ page:SetAllPoints(parent)
39
+
40
+ local input = CreateLineInput(page)
41
+ input:SetPoint("TOPLEFT", 14, -84)
42
+ input:SetPoint("TOPRIGHT", -250, -84)
43
+ input:SetHeight(30)
44
+ input.editBox:SetText("C_AddOns.GetAddOnInfo")
45
+
46
+ local traceButton = W.CreateButton(page, 112, L.START_TRACE, "primary")
47
+ traceButton:SetPoint("TOPRIGHT", -14, -84)
48
+ local clearButton = W.CreateButton(page, 100, L.CLEAR_LOG, false)
49
+ clearButton:SetPoint("RIGHT", traceButton, "LEFT", -8, 0)
50
+ page.traceButton = traceButton
51
+ page.clearButton = clearButton
52
+ local dot = page:CreateTexture(nil, "ARTWORK")
53
+ dot:SetSize(5, 5)
54
+ dot:SetPoint("TOPLEFT", input, "BOTTOMLEFT", 2, -15)
55
+ local status = page:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
56
+ status:SetPoint("LEFT", dot, "RIGHT", 7, 0)
57
+ local function SetStatus(text, r, g, b)
58
+ status:SetText(text)
59
+ status:SetTextColor(r, g, b, 0.92)
60
+ dot:SetColorTexture(r, g, b, 0.92)
61
+ end
62
+
63
+ local listLabel = W.CreateSectionLabel(page, L.CALL_RECORDS)
64
+ listLabel:SetPoint("TOPLEFT", 17, -152)
65
+ local detailLabel = W.CreateSectionLabel(page, L.CALL_ARGUMENTS)
66
+ detailLabel:SetPoint("TOPLEFT", LIST_WIDTH + 29, -152)
67
+
68
+ local listPanel = W.CreatePanel(page, colors.editor[1], colors.editor[2], colors.editor[3], 0.78)
69
+ listPanel:SetPoint("TOPLEFT", 14, -172)
70
+ listPanel:SetPoint("BOTTOMLEFT", 14, 54)
71
+ listPanel:SetWidth(LIST_WIDTH)
72
+ local scroll = W.CreateScrollArea(listPanel, 8, 8, 7, 8)
73
+ local content = CreateFrame("Frame", nil, scroll)
74
+ content:SetWidth(LIST_WIDTH - 26)
75
+ content:SetHeight(1)
76
+ scroll:SetScrollChild(content)
77
+ local empty = listPanel:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall")
78
+ empty:SetPoint("TOP", 0, -24)
79
+ empty:SetText(L.NO_CALLS_CAPTURED)
80
+ empty:SetTextColor(1, 1, 1, 0.32)
81
+
82
+ local selected
83
+ local detail = W.CreateTextArea(page, true)
84
+ detail:SetPoint("TOPLEFT", LIST_WIDTH + 26, -172)
85
+ detail:SetPoint("BOTTOMRIGHT", -14, 54)
86
+ detail.editBox:SetWidth(layout.WINDOW_WIDTH - LIST_WIDTH - 78)
87
+ W.SetReadOnlyText(detail, L.SELECT_CALL_DETAIL)
88
+
89
+ local exportDetail = W.CreateButton(page, 92, L.SAVE_TO_DISK, false)
90
+ exportDetail:SetPoint("BOTTOMRIGHT", -14, 14)
91
+ exportDetail:SetScript("OnClick", function()
92
+ if ns.Safety.IsCombatBlocked() then
93
+ ns.Safety.PrintBlocked()
94
+ return
95
+ end
96
+ local kind, title, content, metadata = page.GetTracePayload()
97
+ if not kind then
98
+ return
99
+ end
100
+ ns.Workbench.SaveToDisk(kind, title, content, metadata)
101
+ end)
102
+ page.exportDetail = exportDetail
103
+ page.listPanel = listPanel
104
+ page.detailPanel = detail
105
+
106
+ local rows, refreshQueued = {}, false
107
+ local RefreshList
108
+ page.callRows = rows
109
+ local function SyncTraceButton()
110
+ local running = ns.FunctionTrace.IsRunning()
111
+ W.SetButtonText(traceButton, running and L.STOP_TRACE or L.START_TRACE)
112
+ W.SetButtonVariant(traceButton, running and "danger" or "primary")
113
+ end
114
+
115
+ local function Format(record)
116
+ if not record then
117
+ return L.SELECT_CALL_DETAIL
118
+ end
119
+ local lines = {
120
+ string.format(L.TRACE_PATH, record.path),
121
+ string.format(L.ELAPSED_DETAIL, record.elapsed),
122
+ "",
123
+ }
124
+ if #record.arguments == 0 then
125
+ lines[#lines + 1] = L.NO_ARGUMENTS
126
+ end
127
+ for index = 1, #record.arguments do
128
+ lines[#lines + 1] = "[" .. index .. "] = " .. record.arguments[index]
129
+ end
130
+ return table.concat(lines, "\n")
131
+ end
132
+
133
+ local function CreateRow(index)
134
+ local row = W.CreateListRow(content, ROW_HEIGHT)
135
+ row:SetWidth(LIST_WIDTH - 26)
136
+ local elapsed = row:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall")
137
+ elapsed:SetPoint("LEFT", 8, 0)
138
+ elapsed:SetWidth(62)
139
+ elapsed:SetJustifyH("LEFT")
140
+ elapsed:SetTextColor(1, 1, 1, 0.38)
141
+ row.elapsed = elapsed
142
+ local name = row:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
143
+ name:SetPoint("TOPLEFT", 72, -5)
144
+ name:SetPoint("TOPRIGHT", -8, -5)
145
+ name:SetJustifyH("LEFT")
146
+ name:SetWordWrap(false)
147
+ row.name = name
148
+ local summary = row:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall")
149
+ summary:SetPoint("BOTTOMLEFT", 72, 5)
150
+ summary:SetPoint("BOTTOMRIGHT", -8, 5)
151
+ summary:SetJustifyH("LEFT")
152
+ summary:SetWordWrap(false)
153
+ summary:SetTextColor(1, 1, 1, 0.38)
154
+ row.summary = summary
155
+ row:SetScript("OnEnter", function(self)
156
+ self.isHovered = true
157
+ W.SetListRowState(self, self.record == selected, true)
158
+ end)
159
+ row:SetScript("OnLeave", function(self)
160
+ self.isHovered = nil
161
+ W.SetListRowState(self, self.record == selected, false)
162
+ end)
163
+ row:SetScript("OnClick", function(self)
164
+ selected = self.record
165
+ W.SetReadOnlyText(detail, Format(selected))
166
+ RefreshList()
167
+ end)
168
+ rows[index] = row
169
+ return row
170
+ end
171
+
172
+ RefreshList = function()
173
+ for index = 1, #rows do
174
+ rows[index]:Hide()
175
+ end
176
+ local recordCount = ns.FunctionTrace.GetCount()
177
+ W.SetButtonEnabled(clearButton, recordCount > 0)
178
+ W.SetButtonEnabled(exportDetail, recordCount > 0)
179
+ local offset = scroll:GetVerticalScroll()
180
+ if issecretvalue and issecretvalue(offset) then
181
+ offset = 0
182
+ end
183
+ local first = math.floor((offset or 0) / ROW_HEIGHT) + 1
184
+ local last = math.min(recordCount, first + VISIBLE_ROWS - 1)
185
+ local pool = 0
186
+ for recordIndex = first, last do
187
+ pool = pool + 1
188
+ local record = ns.FunctionTrace.GetRecord(recordIndex)
189
+ local row = rows[pool] or CreateRow(pool)
190
+ row.record = record
191
+ row:ClearAllPoints()
192
+ row:SetPoint("TOPLEFT", 0, -((recordIndex - 1) * ROW_HEIGHT))
193
+ row.elapsed:SetText(string.format("+%.2fs", record.elapsed))
194
+ row.name:SetText(record.path)
195
+ row.summary:SetText(record.summary ~= "" and record.summary or L.NO_ARGUMENTS)
196
+ W.SetListRowState(row, record == selected, row.isHovered)
197
+ row:Show()
198
+ end
199
+ content:SetHeight(math.max(1, recordCount * ROW_HEIGHT))
200
+ scroll:UpdateScrollChildRect()
201
+ empty:SetShown(recordCount == 0)
202
+ end
203
+
204
+ scroll.onVerticalScrollChanged = function()
205
+ RefreshList()
206
+ end
207
+
208
+ local function QueueRefresh()
209
+ if refreshQueued then
210
+ return
211
+ end
212
+ refreshQueued = true
213
+ C_Timer.After(0, function()
214
+ refreshQueued = false
215
+ if page:IsShown() then
216
+ RefreshList()
217
+ end
218
+ end)
219
+ end
220
+
221
+ traceButton:SetScript("OnClick", function()
222
+ if ns.FunctionTrace.IsRunning() then
223
+ ns.FunctionTrace.Stop()
224
+ SetStatus(L.STOPPED, 0.55, 0.60, 0.65)
225
+ SyncTraceButton()
226
+ return
227
+ end
228
+
229
+ local succeeded, errorMessage = ns.FunctionTrace.Start(input.editBox:GetText(), QueueRefresh)
230
+ if succeeded then
231
+ SetStatus(string.format(L.TRACING_FUNCTION, ns.FunctionTrace.GetActivePath()), 0.42, 0.76, 0.43)
232
+ else
233
+ SetStatus(errorMessage, accent[1], accent[2], accent[3])
234
+ end
235
+ SyncTraceButton()
236
+ end)
237
+ clearButton:SetScript("OnClick", function()
238
+ if ns.Safety.IsCombatBlocked() then
239
+ ns.Safety.PrintBlocked()
240
+ return
241
+ end
242
+ ns.FunctionTrace.Clear()
243
+ selected = nil
244
+ W.SetReadOnlyText(detail, L.SELECT_CALL_DETAIL)
245
+ RefreshList()
246
+ end)
247
+ input.editBox:SetScript("OnEnterPressed", function()
248
+ traceButton:Click()
249
+ end)
250
+
251
+ function page.HandleActivate()
252
+ input.editBox:SetFocus()
253
+ SyncTraceButton()
254
+ RefreshList()
255
+ end
256
+
257
+ -- One payload builder shared by the page Save button and the shell export
258
+ -- hook; both funnel into the single export UI. Records are newest first
259
+ -- and bounded by the trace ring (300 records).
260
+ function page.GetTracePayload()
261
+ local recordCount = ns.FunctionTrace.GetCount()
262
+ if recordCount <= 0 then
263
+ return nil
264
+ end
265
+ return "function_trace", L.CALL_RECORDS, function()
266
+ local records = {}
267
+ for index = 1, recordCount do
268
+ records[index] = ns.FunctionTrace.GetRecord(index)
269
+ end
270
+ local text = ns.Serializer.SerializeForExport(records)
271
+ return text
272
+ end, { recordCount = recordCount }
273
+ end
274
+
275
+ -- The page stop lives on window hide / combat shutdown: recording is
276
+ -- disabled there and the hook drops back to its inert guard.
277
+ function page.HandleShutdown()
278
+ ns.FunctionTrace.Stop()
279
+ SetStatus(L.STOPPED, 0.55, 0.60, 0.65)
280
+ SyncTraceButton()
281
+ end
282
+
283
+ SetStatus(L.STOPPED, 0.55, 0.60, 0.65)
284
+ SyncTraceButton()
285
+ RefreshList()
286
+ builtPage = page
287
+ return page
288
+ end
289
+
290
+ ns.Workbench.RegisterPage({
291
+ key = "trace",
292
+ titleKey = "TAB_TRACE",
293
+ build = BuildTracePage,
294
+ activate = function(page)
295
+ if page and page.HandleActivate then
296
+ page:HandleActivate()
297
+ end
298
+ end,
299
+ shutdown = function(page)
300
+ if page and page.HandleShutdown then
301
+ page:HandleShutdown()
302
+ end
303
+ end,
304
+ })
305
+
306
+ ns.Workbench.RegisterExportHook({
307
+ key = "trace",
308
+ GetPayload = function()
309
+ if not builtPage then
310
+ return nil
311
+ end
312
+ return builtPage.GetTracePayload()
313
+ end,
314
+ })
@@ -0,0 +1,246 @@
1
+ local ADDON_NAME, ns = ...
2
+
3
+ -- Virtualized value-tree view: 22 px rows from a 32-row pool, expand/collapse,
4
+ -- bounded "load more" rows, right-click context for exportable nodes and
5
+ -- per-kind value colors.
6
+ local TREE_ROW_HEIGHT = 22
7
+ local TREE_ROW_POOL_SIZE = 32
8
+ local VALUE_COLUMN_LEFT = 250
9
+ local KEY_WIDTH_BASE = 218
10
+ local INDENT_WIDTH = 15
11
+
12
+ local function ValueColor(kind)
13
+ if kind == "string" then
14
+ return 0.62, 0.78, 0.64
15
+ elseif kind == "number" then
16
+ return 0.65, 0.74, 0.91
17
+ elseif kind == "boolean" then
18
+ return 0.90, 0.63, 0.42
19
+ elseif kind == "table" then
20
+ return 0.62, 0.67, 0.72
21
+ elseif kind == "load_more" then
22
+ return 0.86, 0.47, 0.55
23
+ elseif kind == "marker" then
24
+ return 0.85, 0.42, 0.48
25
+ end
26
+ return 0.70, 0.73, 0.76
27
+ end
28
+
29
+ ns.TreeView = {}
30
+
31
+ -- options: { contentWidth = number }
32
+ function ns.TreeView.Create(parent, options)
33
+ options = type(options) == "table" and options or {}
34
+ local W = ns.Widgets
35
+ local colors = W.Colors
36
+ local contentWidth = options.contentWidth or 500
37
+
38
+ local panel = W.CreatePanel(parent, colors.editor[1], colors.editor[2], colors.editor[3], 1)
39
+ local scroll = W.CreateScrollArea(panel, 8, 8, 7, 8)
40
+ local content = CreateFrame("Frame", nil, scroll)
41
+ content:SetWidth(contentWidth)
42
+ content:SetHeight(1)
43
+ scroll:SetScrollChild(content)
44
+
45
+ local empty = panel:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall")
46
+ empty:SetPoint("TOP", 0, -24)
47
+ empty:SetText(ns.L.TREE_EMPTY)
48
+ empty:SetTextColor(1, 1, 1, 0.32)
49
+
50
+ local rows = {}
51
+ local visibleNodes = {}
52
+ local tree
53
+ local selectedNode
54
+ local selectionChanged
55
+ local nodeContext
56
+ local view = { panel = panel }
57
+
58
+ local function FlattenNodes(nodes, depth, visible)
59
+ for index = 1, #nodes do
60
+ local node = nodes[index]
61
+ visible[#visible + 1] = { node = node, depth = depth }
62
+ if node.kind == "table" and node.expanded and node.children then
63
+ FlattenNodes(node.children, depth + 1, visible)
64
+ end
65
+ end
66
+ end
67
+
68
+ local function ApplyRowStyle(row)
69
+ if row.node == selectedNode then
70
+ row.hover:SetColorTexture(colors.accent[1], colors.accent[2], colors.accent[3], 0.16)
71
+ elseif row.isHovered then
72
+ row.hover:SetColorTexture(colors.surface[1], colors.surface[2], colors.surface[3], 0.72)
73
+ else
74
+ row.hover:SetColorTexture(0, 0, 0, 0)
75
+ end
76
+ end
77
+
78
+ local function CreateRow(index)
79
+ local row = CreateFrame("Button", nil, content)
80
+ row:SetSize(contentWidth, TREE_ROW_HEIGHT)
81
+ row:RegisterForClicks("LeftButtonUp", "RightButtonUp")
82
+
83
+ local hover = row:CreateTexture(nil, "BACKGROUND")
84
+ hover:SetAllPoints()
85
+ hover:SetColorTexture(0, 0, 0, 0)
86
+ row.hover = hover
87
+
88
+ local toggle = row:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
89
+ toggle:SetJustifyH("CENTER")
90
+ toggle:SetTextColor(colors.accent[1], colors.accent[2], colors.accent[3], 0.95)
91
+ row.toggle = toggle
92
+
93
+ local key = row:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
94
+ key:SetJustifyH("LEFT")
95
+ key:SetTextColor(0.91, 0.93, 0.95, 0.92)
96
+ row.key = key
97
+
98
+ local value = row:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
99
+ value:SetPoint("LEFT", VALUE_COLUMN_LEFT, 0)
100
+ value:SetPoint("RIGHT", -8, 0)
101
+ value:SetJustifyH("LEFT")
102
+ value:SetWordWrap(false)
103
+ row.value = value
104
+
105
+ row:SetScript("OnEnter", function(self)
106
+ self.isHovered = true
107
+ ApplyRowStyle(self)
108
+ end)
109
+ row:SetScript("OnLeave", function(self)
110
+ self.isHovered = nil
111
+ ApplyRowStyle(self)
112
+ end)
113
+ row:SetScript("OnClick", function(self, mouseButton)
114
+ local node = self.node
115
+ if not node then
116
+ return
117
+ elseif mouseButton ~= "RightButton" and node.kind == "load_more" and node.owner then
118
+ ns.Inspector.LoadMore(node.owner)
119
+ view:Refresh()
120
+ return
121
+ end
122
+
123
+ if node.exportable then
124
+ selectedNode = node
125
+ if selectionChanged then
126
+ selectionChanged(node)
127
+ end
128
+ end
129
+ if mouseButton == "RightButton" then
130
+ if node.exportable and nodeContext then
131
+ nodeContext(node)
132
+ end
133
+ view:Refresh()
134
+ return
135
+ end
136
+ if node.kind == "table" then
137
+ if node.expanded then
138
+ node.expanded = false
139
+ else
140
+ if not node.loaded then
141
+ ns.Inspector.LoadMore(node)
142
+ end
143
+ node.expanded = true
144
+ end
145
+ end
146
+ view:Refresh()
147
+ end)
148
+
149
+ rows[index] = row
150
+ return row
151
+ end
152
+
153
+ function view:HasTree()
154
+ return tree and tree.roots and #tree.roots > 0
155
+ end
156
+
157
+ function view:GetSelectedNode()
158
+ return selectedNode
159
+ end
160
+
161
+ function view:SetOnSelectionChanged(callback)
162
+ selectionChanged = type(callback) == "function" and callback or nil
163
+ end
164
+
165
+ function view:SetOnNodeContext(callback)
166
+ nodeContext = type(callback) == "function" and callback or nil
167
+ end
168
+
169
+ function view:SetTree(newTree)
170
+ tree = newTree
171
+ selectedNode = tree and tree.roots and tree.roots[1] and tree.roots[1].exportable
172
+ and tree.roots[1] or nil
173
+ scroll:SetVerticalScroll(0)
174
+ self:Refresh()
175
+ if selectionChanged then
176
+ selectionChanged(selectedNode)
177
+ end
178
+ end
179
+
180
+ function view:RenderRows()
181
+ for index = 1, #rows do
182
+ rows[index]:Hide()
183
+ end
184
+
185
+ local offset = scroll:GetVerticalScroll() or 0
186
+ if issecretvalue and issecretvalue(offset) then
187
+ return
188
+ end
189
+ local firstIndex = math.floor(math.max(0, offset) / TREE_ROW_HEIGHT) + 1
190
+ local lastIndex = math.min(#visibleNodes, firstIndex + TREE_ROW_POOL_SIZE - 1)
191
+
192
+ for visibleIndex = firstIndex, lastIndex do
193
+ local poolIndex = visibleIndex - firstIndex + 1
194
+ local item = visibleNodes[visibleIndex]
195
+ local node = item.node
196
+ local row = rows[poolIndex] or CreateRow(poolIndex)
197
+ local indent = item.depth * INDENT_WIDTH
198
+ row.node = node
199
+ row:ClearAllPoints()
200
+ row:SetPoint("TOPLEFT", 0, -((visibleIndex - 1) * TREE_ROW_HEIGHT))
201
+
202
+ row.toggle:ClearAllPoints()
203
+ row.toggle:SetPoint("LEFT", 6 + indent, 0)
204
+ row.toggle:SetSize(14, TREE_ROW_HEIGHT)
205
+ if node.kind == "table" and (not node.loaded or #node.children > 0) then
206
+ row.toggle:SetText(node.expanded and "-" or "+")
207
+ elseif node.kind == "load_more" then
208
+ row.toggle:SetText("+")
209
+ else
210
+ row.toggle:SetText("")
211
+ end
212
+
213
+ row.key:ClearAllPoints()
214
+ row.key:SetPoint("LEFT", 24 + indent, 0)
215
+ row.key:SetWidth(math.max(70, KEY_WIDTH_BASE - indent))
216
+ row.key:SetText(node.label or "")
217
+
218
+ local r, g, b = ValueColor(node.kind)
219
+ row.value:SetTextColor(r, g, b, 0.92)
220
+ row.value:SetText(node.value or "")
221
+ ApplyRowStyle(row)
222
+ row:Show()
223
+ end
224
+ end
225
+
226
+ function view:Refresh()
227
+ wipe(visibleNodes)
228
+ if tree and tree.roots then
229
+ FlattenNodes(tree.roots, 0, visibleNodes)
230
+ end
231
+
232
+ content:SetHeight(math.max(1, #visibleNodes * TREE_ROW_HEIGHT))
233
+ scroll:UpdateScrollChildRect()
234
+ empty:SetShown(#visibleNodes == 0)
235
+ self:RenderRows()
236
+ end
237
+
238
+ scroll.onVerticalScrollChanged = function()
239
+ view:RenderRows()
240
+ end
241
+
242
+ view.content = content
243
+ view.rows = rows
244
+ view.scroll = scroll
245
+ return view
246
+ end