mirror of
https://github.com/luanslimadev/Wand-Enhancer.git
synced 2026-08-28 17:01:05 +00:00
feat: update changelog for version 1.0.8.3, enhance Pro activation handling, minor fixes and improve renderer script management
This commit is contained in:
+35
-28
@@ -12,45 +12,52 @@ const rendererScriptsRoot = resolve(bridgeRoot, "scripts", "default")
|
||||
const rendererScriptsOutdir = resolve(distRoot, "renderer-scripts")
|
||||
|
||||
await build({
|
||||
banner: {
|
||||
js: "// Generated by bridge/build.mjs. Do not edit this bundle by hand.",
|
||||
},
|
||||
bundle: true,
|
||||
entryPoints: [bridgeEntryPoint],
|
||||
format: "cjs",
|
||||
legalComments: "none",
|
||||
minify: true,
|
||||
outfile: bridgeOutfile,
|
||||
platform: "node",
|
||||
target: "node16",
|
||||
banner: {
|
||||
js: "// Generated by bridge/build.mjs. Do not edit this bundle by hand.",
|
||||
},
|
||||
bundle: true,
|
||||
entryPoints: [bridgeEntryPoint],
|
||||
format: "cjs",
|
||||
legalComments: "none",
|
||||
minify: true,
|
||||
outfile: bridgeOutfile,
|
||||
platform: "node",
|
||||
target: "node16",
|
||||
})
|
||||
|
||||
const EXCLUDED_RENDERER_SCRIPTS = new Set(["activate-pro.js"])
|
||||
|
||||
const rendererEntries = (
|
||||
await readdir(rendererScriptsRoot, { withFileTypes: true })
|
||||
await readdir(rendererScriptsRoot, { withFileTypes: true })
|
||||
)
|
||||
.filter((entry) => entry.isFile() && entry.name.endsWith(".js"))
|
||||
.map((entry) => resolve(rendererScriptsRoot, entry.name))
|
||||
.filter(
|
||||
(entry) =>
|
||||
entry.isFile() &&
|
||||
entry.name.endsWith(".js") &&
|
||||
!EXCLUDED_RENDERER_SCRIPTS.has(entry.name)
|
||||
)
|
||||
.map((entry) => resolve(rendererScriptsRoot, entry.name))
|
||||
|
||||
if (rendererEntries.length === 0) {
|
||||
throw new Error(`No renderer script entries found in ${rendererScriptsRoot}`)
|
||||
throw new Error(`No renderer script entries found in ${rendererScriptsRoot}`)
|
||||
}
|
||||
|
||||
await build({
|
||||
banner: {
|
||||
js: "// Generated by bridge/build.mjs. Do not edit this bundle by hand.",
|
||||
},
|
||||
bundle: true,
|
||||
entryNames: "[name]",
|
||||
entryPoints: rendererEntries,
|
||||
format: "iife",
|
||||
legalComments: "none",
|
||||
minify: true,
|
||||
outdir: rendererScriptsOutdir,
|
||||
platform: "browser",
|
||||
target: "es2020",
|
||||
banner: {
|
||||
js: "// Generated by bridge/build.mjs. Do not edit this bundle by hand.",
|
||||
},
|
||||
bundle: true,
|
||||
entryNames: "[name]",
|
||||
entryPoints: rendererEntries,
|
||||
format: "iife",
|
||||
legalComments: "none",
|
||||
minify: true,
|
||||
outdir: rendererScriptsOutdir,
|
||||
platform: "browser",
|
||||
target: "es2020",
|
||||
})
|
||||
|
||||
console.log(`Built ${bridgeOutfile}`)
|
||||
console.log(
|
||||
`Built ${rendererEntries.length} renderer script(s) in ${rendererScriptsOutdir}`
|
||||
`Built ${rendererEntries.length} renderer script(s) in ${rendererScriptsOutdir}`
|
||||
)
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// NOTE: Not wired into the build. Pro activation currently lives in the C# asar
|
||||
// patch (EPatchType.ActivatePro). This renderer-side variant is kept for future
|
||||
// use and is excluded from bridge/build.mjs (EXCLUDED_RENDERER_SCRIPTS), so it is
|
||||
// neither bundled nor injected. To re-enable, remove it from that exclusion list.
|
||||
import { installActivatePro } from "./activate-pro/index.js"
|
||||
|
||||
installActivatePro(globalThis.WandEnhancer)
|
||||
@@ -0,0 +1,140 @@
|
||||
// NOTE: Currently unused. Pro activation lives in the C# asar patch
|
||||
// (EPatchType.ActivatePro). This renderer-side variant patches the account service
|
||||
// prototype to inject the Pro subscription at the source. Kept for future use;
|
||||
// the entry `../activate-pro.js` is excluded from bridge/build.mjs.
|
||||
import { createLogger } from "../installed-apps-sync/logger.js"
|
||||
import {
|
||||
findExportedConstructor,
|
||||
getWebpackRequire,
|
||||
isRecord,
|
||||
} from "../installed-apps-sync/runtime.js"
|
||||
|
||||
const GLOBAL_FLAG = "__wandActivateProInstalled"
|
||||
const SERVICE_PATCH_KEY = "__wandEnhancerProAccountServicePatched"
|
||||
const ACCOUNT_SERVICE_METHODS = [
|
||||
"getUserAccount",
|
||||
"setAccountLanguage",
|
||||
"setAccountWandBrandExperience",
|
||||
]
|
||||
const RETRY_DELAY_MS = 400
|
||||
const MAX_ATTEMPTS = 90
|
||||
const DEFAULT_SUBSCRIPTION = Object.freeze({ period: "yearly", state: "active" })
|
||||
|
||||
export function installActivatePro(WandEnhancer) {
|
||||
if (globalThis[GLOBAL_FLAG]) {
|
||||
return
|
||||
}
|
||||
|
||||
globalThis[GLOBAL_FLAG] = true
|
||||
|
||||
const state = {
|
||||
attempts: 0,
|
||||
log: createLogger(WandEnhancer),
|
||||
}
|
||||
|
||||
state.log("info", "Activate Pro bootstrap starting.")
|
||||
retryBootstrap(state)
|
||||
}
|
||||
|
||||
function retryBootstrap(state) {
|
||||
if (patchAccountService(state)) {
|
||||
return
|
||||
}
|
||||
|
||||
state.attempts += 1
|
||||
if (state.attempts < MAX_ATTEMPTS) {
|
||||
setTimeout(() => retryBootstrap(state), RETRY_DELAY_MS)
|
||||
return
|
||||
}
|
||||
|
||||
state.log("error", "Activate Pro bootstrap exhausted; account service not found.")
|
||||
}
|
||||
|
||||
function patchAccountService(state) {
|
||||
const webpackRequire = getWebpackRequire()
|
||||
if (!webpackRequire) {
|
||||
return false
|
||||
}
|
||||
|
||||
const ctor = findExportedConstructor(
|
||||
webpackRequire,
|
||||
(prototype) =>
|
||||
typeof prototype.getUserAccount === "function" &&
|
||||
typeof prototype.setAccountLanguage === "function" &&
|
||||
typeof prototype.setAccountWandBrandExperience === "function"
|
||||
)
|
||||
if (!ctor?.prototype) {
|
||||
return false
|
||||
}
|
||||
|
||||
const prototype = ctor.prototype
|
||||
if (prototype[SERVICE_PATCH_KEY]) {
|
||||
return true
|
||||
}
|
||||
|
||||
try {
|
||||
for (const name of ACCOUNT_SERVICE_METHODS) {
|
||||
const original = prototype[name]
|
||||
if (typeof original !== "function") {
|
||||
continue
|
||||
}
|
||||
|
||||
prototype[name] = function patchedAccountMethod(...args) {
|
||||
return Promise.resolve(original.apply(this, args)).then((account) =>
|
||||
normalizeProAccount(account)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Object.defineProperty(prototype, SERVICE_PATCH_KEY, { value: true })
|
||||
state.log("info", "Pro account service patched.")
|
||||
return true
|
||||
} catch (error) {
|
||||
state.log(
|
||||
"warn",
|
||||
"Failed to patch account service.",
|
||||
error?.stack || String(error)
|
||||
)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeProAccount(account) {
|
||||
if (!isRecord(account)) {
|
||||
return account
|
||||
}
|
||||
|
||||
const nextSubscription = normalizeProSubscription(account.subscription)
|
||||
if (nextSubscription === account.subscription) {
|
||||
return account
|
||||
}
|
||||
|
||||
return {
|
||||
...account,
|
||||
subscription: nextSubscription,
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeProSubscription(subscription) {
|
||||
if (!isRecord(subscription)) {
|
||||
return { ...DEFAULT_SUBSCRIPTION }
|
||||
}
|
||||
|
||||
const nextSubscription = { ...subscription }
|
||||
let changed = false
|
||||
|
||||
if (
|
||||
typeof nextSubscription.period !== "string" ||
|
||||
!nextSubscription.period.trim()
|
||||
) {
|
||||
nextSubscription.period = DEFAULT_SUBSCRIPTION.period
|
||||
changed = true
|
||||
}
|
||||
|
||||
if (nextSubscription.state !== "active") {
|
||||
nextSubscription.state = DEFAULT_SUBSCRIPTION.state
|
||||
changed = true
|
||||
}
|
||||
|
||||
return changed ? nextSubscription : subscription
|
||||
}
|
||||
@@ -8,6 +8,10 @@
|
||||
const style = document.createElement("style")
|
||||
style.id = "wand-remote-popup-cleanup-style"
|
||||
style.textContent = `
|
||||
.pro-onboarding-card--remote {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
remote-tooltip .remote-tooltip .top-wrapper,
|
||||
remote-tooltip .remote-tooltip .remote-tooltip-section-divider,
|
||||
remote-tooltip .remote-tooltip .instructions .header,
|
||||
|
||||
Reference in New Issue
Block a user