diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 262d32b..06c7cab 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@v4 with: repository: AlexAllocated/libchev - ref: 445c0cf5b3dd40d36461f6e0b9adc2feb8dfb16b + ref: bd83b65fcbd21d108d8f6c02677acddb30541c6a path: library - run: sudo apt-get update && sudo apt-get install -y lua${{ matrix.lua }} - run: lua${{ matrix.lua }} scripts/test.lua diff --git a/CHANGELOG.md b/CHANGELOG.md index c2fbaa0..7f85cba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # NoPoizen changelog +## 1.2.2 — 2026-09-24 + +Announce the installed version, supported clients and settings command once per login or UI reload. Include addon-specific CurseForge and GitHub feedback links; clicking a link opens a native-style copy window. Share message behavior and safe copy UI through private libchev 1.2.0. If link registration or the copy window is unavailable, show the full URL in chat. An unavailable welcome helper cannot interrupt normal addon startup. + +Validation: 142 tests pass in both orders on Lua 5.1 and 5.2, with client API checks, Lua parsing and exact library vendor verification. NoPoizen smoke simulations exercise both feedback links on all seven client/ruleset profiles. Live rendering remains a separate check. + ## 1.2.1 — 2026-09-24 Show Blizzard's poison icon beside NoPoizen in the AddOns list instead of the default question mark. diff --git a/Core.lua b/Core.lua index e66ec95..0c625d9 100644 --- a/Core.lua +++ b/Core.lua @@ -685,6 +685,7 @@ function NoPoizen:OnLogin() else self:Disable() end + self:PrintWelcomeMessage() end function NoPoizen:ADDON_LOADED(_, loadedAddonName) diff --git a/CoreTests.lua b/CoreTests.lua index 509164f..6e47f16 100644 --- a/CoreTests.lua +++ b/CoreTests.lua @@ -26,6 +26,37 @@ local function TestReportFixture() return f end +NoPoizen:RegisterTest("welcome login keeps monitoring active announces once and routes addon feedback", function() + local f = TestReportFixture() + local handler + f.Enable = function(owner) + owner.isEnabled = true + end + f.GetWelcomeUIPolicy = f.GetDebugUIPolicy + f.RegisterWelcomeLink = function(_, kind, callback) + Equal(kind, "nopoizenfeedback") + handler = callback + return true + end + f:OnLogin() + f:OnLogin() + Equal(f.hasLoggedIn, true) + Equal(f.isEnabled, true) + Equal(#f.messages, 1) + assert(f.messages[1]:find("vfixture-version loaded!", 1, true)) + assert(f.messages[1]:find("Type /np for settings.", 1, true)) + handler("nopoizenfeedback:curseforge") + Equal(f.messages[2], "Feedback: https://www.curseforge.com/wow/addons/nopoizen") + handler("nopoizenfeedback:github") + Equal(f.messages[3], "Feedback: https://github.com/AlexAllocated/NoPoizen") + f.GetWelcomeController = function() + error("welcome unavailable") + end + f:OnLogin() + Equal(f.isEnabled, true) + Equal(#f.messages, 3) +end) + NoPoizen:RegisterTest("test runner remains headless with unchanged returns and order", function() local f = TestReportFixture() local order = {} diff --git a/Libs/libchev/ReportWindow.lua b/Libs/libchev/ReportWindow.lua index d5c3520..1ecc23d 100644 --- a/Libs/libchev/ReportWindow.lua +++ b/Libs/libchev/ReportWindow.lua @@ -20,24 +20,40 @@ function LibChev.OpenReportWindow(owner, text, policy) local success, allowed = pcall(policy.canMutate, region) return success and LibChev.CanAccess(allowed) and allowed == true end + local copyLink = policy.copyLink == true + local width, height = copyLink and 620 or 660, copyLink and 200 or 460 local frame = owner.diagnosticsWindow if not frame then - frame = policy.createFrame("Frame", nil, policy.parent) + frame = policy.createFrame("Frame", nil, policy.parent, copyLink and "BackdropTemplate" or nil) if not CanMutate(frame) then return false end - frame:SetSize(660, 460) + frame:SetSize(width, height) frame:SetPoint("CENTER") frame:SetFrameStrata("DIALOG") frame:SetClampedToScreen(true) frame:EnableMouse(true) frame:Hide() + if copyLink then + frame:SetToplevel(true) + if frame.SetFlattensRenderLayers then + frame:SetFlattensRenderLayers(true) + end + frame:SetBackdrop({ + bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", + edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", + tile = true, + tileSize = 32, + edgeSize = 32, + insets = { left = 11, right = 12, top = 12, bottom = 11 }, + }) + end local background = frame:CreateTexture(nil, "BACKGROUND") if not CanMutate(background) then return false end background:SetAllPoints() - background:SetColorTexture(0.04, 0.04, 0.04, 0.97) + background:SetColorTexture(0.04, 0.04, 0.04, copyLink and 0 or 0.97) local title = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge") if not CanMutate(title) then return false @@ -49,7 +65,10 @@ function LibChev.OpenReportWindow(owner, text, policy) return false end hint:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -10) - hint:SetText("Report selected: press Ctrl+C to copy. Use the mouse wheel to scroll.") + hint:SetText( + copyLink and "Press Ctrl+C to copy this address, then open it in your browser." + or "Report selected: press Ctrl+C to copy. Use the mouse wheel to scroll." + ) local scroll = policy.createFrame("ScrollFrame", nil, frame) if not CanMutate(scroll) then return false @@ -61,7 +80,7 @@ function LibChev.OpenReportWindow(owner, text, policy) if not CanMutate(box) then return false end - box:SetWidth(600) + box:SetWidth(width - 60) box:SetHeight(1) box:SetMultiLine(true) box:SetAutoFocus(false) @@ -72,7 +91,7 @@ function LibChev.OpenReportWindow(owner, text, policy) if not CanMutate(measure) then return false end - measure:SetWidth(592) + measure:SetWidth(width - 68) measure:Hide() frame.TextBox, frame.Scroll, frame.Measure = box, scroll, measure scroll:SetScript("OnMouseWheel", function(_, delta) @@ -122,7 +141,7 @@ function LibChev.OpenReportWindow(owner, text, policy) end selectAll:SetSize(120, 24) selectAll:SetPoint("BOTTOMLEFT", 20, 16) - selectAll:SetText("Select Report") + selectAll:SetText(copyLink and "Select Link" or "Select Report") selectAll:SetScript("OnClick", function() if CanMutate(box) then box:SetFocus() diff --git a/Libs/libchev/libchev.lua b/Libs/libchev/libchev.lua index b80a14f..a8a57ba 100644 --- a/Libs/libchev/libchev.lua +++ b/Libs/libchev/libchev.lua @@ -2,7 +2,7 @@ -- Private embedding: every addon receives its own library through its loader -- namespace. No global registry, Blizzard mutation, hooks, events or saved data. local _, namespace = ... -local LibChev = { VERSION = "1.1.3", API_VERSION = 1 } +local LibChev = { VERSION = "1.2.0", API_VERSION = 1 } local unpackValues = unpack or table.unpack local secret = type(issecretvalue) == "function" and issecretvalue or nil local accessible = type(canaccessvalue) == "function" and canaccessvalue or nil @@ -422,6 +422,81 @@ function LibChev.TestSummary(result) return string.format("Test summary: %d passed, %d failed (%d total).", result.passed, result.failed, result.total) end +-- The consumer owns all configuration, link registration and UI policies. +-- Only a primitive link string crosses into this controller from the client. +function LibChev.NewWelcomeController(policy) + local controller = {} + local destinations = { + { key = "curseforge", label = "CurseForge", url = policy.curseforgeURL }, + { key = "github", label = "GitHub", url = policy.githubURL }, + } + local function PlainText(value, fallback) + return (LibChev.Text(value, fallback):gsub("|", "||")) + end + function controller:HandleLink(link) + if not LibChev.CanAccess(link) or type(link) ~= "string" then + return false + end + for _, destination in ipairs(destinations) do + if link == policy.linkType .. ":" .. destination.key then + local ui = policy.ui + local ok, shown = pcall(LibChev.OpenReportWindow, self, destination.url, { + parent = ui.parent, + createFrame = ui.createFrame, + restricted = ui.restricted, + canMutate = ui.canMutate, + title = policy.addonName .. " Feedback", + copyLink = true, + }) + if not ok or shown ~= true then + pcall(policy.print, "Feedback: " .. destination.url) + end + return true + end + end + return false + end + function controller:Announce() + if self.announced then + return false + end + if not self.linksRegistered then + local ok, registered = pcall(policy.registerLink, policy.linkType, function(link) + self:HandleLink(link) + -- The public link dispatcher treats nil as handled. No foreign + -- linkData/context tables or global response constants are needed. + end) + self.linksRegistered = ok and registered == true + end + local labels = {} + for index, destination in ipairs(destinations) do + labels[index] = self.linksRegistered + and ("|cff71d5ff|H" .. policy.linkType .. ":" .. destination.key .. "|h[" .. destination.label .. "]|h|r") + or (destination.label .. " (" .. destination.url .. ")") + end + local ok, version = pcall(policy.getVersion) + version = ok and PlainText(version, "unknown") or "unknown" + if version == "" then + version = "unknown" + end + local message = "v" + .. version + .. " loaded! Now supports " + .. policy.clients + .. ". Type " + .. policy.command + .. " for settings. If you run into any issues, please leave feedback on " + .. labels[1] + .. " or " + .. labels[2] + .. "." + local printed = pcall(policy.print, message) + self.announced = printed + return printed + end + return controller +end + if type(namespace) == "table" then namespace.LibChev = LibChev end diff --git a/Libs/libchev/manifest.json b/Libs/libchev/manifest.json index 0f2600c..2509acf 100644 --- a/Libs/libchev/manifest.json +++ b/Libs/libchev/manifest.json @@ -1,13 +1,13 @@ { "schema": 1, "repository": "https://github.com/AlexAllocated/libchev", - "revision": "445c0cf5b3dd40d36461f6e0b9adc2feb8dfb16b", - "version": "1.1.3", + "revision": "bd83b65fcbd21d108d8f6c02677acddb30541c6a", + "version": "1.2.0", "files": { - "libchev.lua": "e0d6bae4a49d2bf9945fae6a6176af5a47b7af45384696b2c707e18aac897c4f", + "libchev.lua": "78e01683da6d82a6a8c3c783f3b804c5e4e384485f0c0520d7b0b5f5852a1f87", "Debug.lua": "1a9b8354d9b9b4e38e8fff3bb97ba2a9916200bf03ad1fb494a071c22091e8b6", "DebugWindow.lua": "b0777bf7f0cb25a0629c82ed09f50b330f7598aca53b9e862954acbb1cf59ac4", - "ReportWindow.lua": "925e0dde12cb01e0575442343b3cddf462c6b57e7c741b5aba0b9ddb35aaa125", + "ReportWindow.lua": "3ea726f617979f7c69d9b521fa736f53e929358b61c40879252a012e1081095e", "SelfTests.lua": "0ba6b144616dd8264ce9417b05d3efbf73166fae876a730421f7de9112daaef0", "LICENSE": "d1bc39a4c90fbac0fc97b6a98786200011eab7ff77a29c2274603ae4e12fe03b" } diff --git a/NoPoizen.toc b/NoPoizen.toc index 55ee61b..ed5f191 100644 --- a/NoPoizen.toc +++ b/NoPoizen.toc @@ -7,7 +7,7 @@ ## Interface-Titan: 38001, 38002 ## Title: NoPoizen ## IconTexture: 132273 -## Version: 1.2.1 +## Version: 1.2.2 ## Notes: Warns Rogues when required aura or weapon poisons are missing. ## SavedVariablesPerCharacter: NoPoizenDBChar ## Author: Chev @@ -18,6 +18,7 @@ Libs/libchev/DebugWindow.lua Libs/libchev/ReportWindow.lua Libs/libchev/SelfTests.lua Core.lua +Welcome.lua ClientDiagnostics.lua Diagnostics.lua PoisonData.lua diff --git a/Tests.lua b/Tests.lua index 57b933f..1df1344 100644 --- a/Tests.lua +++ b/Tests.lua @@ -126,6 +126,9 @@ function NoPoizen:CreateTestFixture() end, } end + fixture.RegisterWelcomeLink = function() + return false + end fixture.LogDiagnostic = function() end fixture.RecordPoisonObservation = function() end return fixture diff --git a/Welcome.lua b/Welcome.lua new file mode 100644 index 0000000..1244f3d --- /dev/null +++ b/Welcome.lua @@ -0,0 +1,68 @@ +-- Shared welcome formatting, session state and copy UI live in private libchev. +local Addon = _G.NoPoizen +local LibChev = Addon.LibChev + +-- Register only our own link type through Blizzard's public dispatcher. The +-- handler consumes the primitive link string, never foreign context tables. +function Addon:RegisterWelcomeLink(linkType, callback) + if not self:CanAccessTable(LinkUtil) then + return false + end + local exists, register = LinkUtil.IsLinkHandlerRegistered, LinkUtil.RegisterLinkHandler + if + not self:CanAccessValue(exists) + or not self:CanAccessValue(register) + or type(exists) ~= "function" + or type(register) ~= "function" + then + return false + end + local ok, registered = pcall(exists, linkType) + if not ok or not self:CanAccessValue(registered) or registered ~= false then + return false + end + return pcall(register, linkType, callback) +end + +function Addon:GetWelcomeUIPolicy() + return self:GetDebugUIPolicy() +end + +function Addon:GetWelcomeController() + local controller = rawget(self, "welcomeController") + if not controller then + controller = LibChev.NewWelcomeController({ + addonName = "NoPoizen", + linkType = "nopoizenfeedback", + curseforgeURL = "https://www.curseforge.com/wow/addons/nopoizen", + githubURL = "https://github.com/AlexAllocated/NoPoizen", + command = "/np", + clients = "Retail, WoW Forever, Classic Era, Hardcore, Season of Discovery, TBC Anniversary, Mists Classic, and Titan Reforged", + getVersion = function() + return self.API.GetAddOnVersion(self.addonName) + end, + registerLink = function(linkType, callback) + return self:RegisterWelcomeLink(linkType, callback) + end, + print = function(text) + self:Print(text) + end, + ui = self:GetWelcomeUIPolicy(), + }) + self.welcomeController = controller + end + return controller +end + +function Addon:PrintWelcomeMessage() + -- A partially updated installation must never prevent normal addon startup. + if type(LibChev.NewWelcomeController) ~= "function" then + return false + end + local ok, controller = pcall(self.GetWelcomeController, self) + if not ok then + return false + end + local announced, result = pcall(controller.Announce, controller) + return announced and result == true +end diff --git a/scripts/smoke.lua b/scripts/smoke.lua index f523064..d12689c 100644 --- a/scripts/smoke.lua +++ b/scripts/smoke.lua @@ -19,6 +19,16 @@ local coatings = { local unpack = table.unpack or unpack local now, timers, sounds, restricted = 0, {}, {}, false local frameCount, chat = 0, {} +local feedbackHandlers = {} +LinkUtil = { + IsLinkHandlerRegistered = function(kind) + return feedbackHandlers[kind] ~= nil + end, + RegisterLinkHandler = function(kind, callback) + assert(feedbackHandlers[kind] == nil) + feedbackHandlers[kind] = callback + end, +} DEFAULT_CHAT_FRAME = { AddMessage = function(_, message) chat[#chat + 1] = message @@ -382,6 +392,17 @@ end NoPoizen:ADDON_LOADED("ADDON_LOADED", "NoPoizen") NoPoizen:PLAYER_LOGIN() assert(NoPoizen.isEnabled and NoPoizen.optionsCategory) +local welcomeCount = #chat +assert(chat[welcomeCount]:find("loaded! Now supports Retail, WoW Forever", 1, true)) +assert(chat[welcomeCount]:find("|Hnopoizenfeedback:github|h[GitHub]|h", 1, true)) +NoPoizen:PLAYER_LOGIN() +assert(#chat == welcomeCount, "duplicate login must not repeat the welcome") +feedbackHandlers.nopoizenfeedback("nopoizenfeedback:curseforge") +local feedbackWindow = NoPoizen:GetWelcomeController().diagnosticsWindow +assert(feedbackWindow.TextBox:GetText() == "https://www.curseforge.com/wow/addons/nopoizen") +feedbackHandlers.nopoizenfeedback("nopoizenfeedback:github") +assert(feedbackWindow.TextBox:GetText() == "https://github.com/AlexAllocated/NoPoizen") +feedbackWindow:Hide() Advance(5) assert(#sounds == 0, "initial state must be quiet") if not weaponClient then