From 7cd3e4a39212858180d09fb09ba42b2eabc5774b Mon Sep 17 00:00:00 2001 From: Tero Date: Fri, 16 Oct 2026 23:06:27 +0300 Subject: [PATCH] Refractoring Stage 6.22 Removed the transitional global aliases from renderer-state.js; renderer state is now exposed only through window.epMailState. Updated the state regression test and bumped to 0.4.34 (Android version code 434). --- REFACTOR_PLAN.md | 4 +++- package-lock.json | 4 ++-- package.json | 2 +- renderer-state.js | 10 ---------- tests/renderer-state.test.cjs | 21 +++++++++++---------- www/renderer-state.js | 10 ---------- 6 files changed, 17 insertions(+), 34 deletions(-) diff --git a/REFACTOR_PLAN.md b/REFACTOR_PLAN.md index 9352c01..79542e0 100644 --- a/REFACTOR_PLAN.md +++ b/REFACTOR_PLAN.md @@ -122,6 +122,7 @@ This is a gradual destination, not a requirement to move everything at once. IPC - [x] Encapsulate attachment UI helpers locally; its navigation and renderer hooks continue through the mail API (`attachments.js`). - [x] Encapsulate snooze UI helpers locally while preserving explicit mail/productivity API usage (`snooze-ui.js`). - [x] Encapsulate keyboard shortcut settings and handlers locally; integrations remain through the mail/productivity feature APIs (`shortcuts.js`). +- [x] Remove transitional renderer-state globals after all consumers migrated to the namespaced state API (`renderer-state.js`). - [x] Migrate additional mail-related consumers to unique local aliases to avoid classic-script lexical redeclarations. - [x] Add a combined-script parse test to prevent duplicate top-level lexical declarations from stopping later UI scripts. - [ ] Migrate remaining mail-related consumers and remove transitional global dependencies. @@ -150,7 +151,7 @@ This is a gradual destination, not a requirement to move everything at once. IPC - Electron Builder and the desktop Actions artifact name derive from `package.json`. - Android `versionName` derives from the same package version. Its current `versionCode` mapping is `major * 10000 + minor * 100 + patch`; keep minor and patch below 100, and revise the mapping before reaching that boundary to avoid collisions. - `scripts/build-all.ps1` uses the package version for APK naming. Before a release, bump once with `npm run bump:build`, verify the lockfile and computed Android version code, and build every target without another bump. -- Latest version check: `package.json` and both lockfile version fields are `0.4.33`; Android derives `versionName 0.4.33` and `versionCode 433`. The user confirms the previous artifact works; this bump is for the next build. +- Latest version check: `package.json` and both lockfile version fields are `0.4.34`; Android derives `versionName 0.4.34` and `versionCode 434`. The user confirms the previous artifact works; this bump is for the next build. ## Progress log @@ -186,5 +187,6 @@ This is a gradual destination, not a requirement to move everything at once. IPC - Step 6 at version `0.4.31` scopes attachment preview and search helpers while retaining their event-driven integrations. - Step 6 at version `0.4.32` scopes snooze UI helpers; message labeling and mail-state access remain routed through feature APIs. - Step 6 at version `0.4.33` scopes keyboard shortcut helpers and event handlers without changing their Preferences integration. +- Step 6 at version `0.4.34` removes legacy global renderer-state accessors; the state module now exposes only `window.epMailState` to the renderer. - The current IPC/DAV validation changes pass the full suite: 108 tests. - While work continued, `package.json` and `package-lock.json` reflected a version bump to `0.4.6`; those changes were preserved. diff --git a/package-lock.json b/package-lock.json index f30b451..9fbe14f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ep-mail", - "version": "0.4.33", + "version": "0.4.34", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ep-mail", - "version": "0.4.33", + "version": "0.4.34", "dependencies": { "@capacitor/android": "^8.5.2", "@capacitor/core": "^8.5.2", diff --git a/package.json b/package.json index a44eab5..68ab5a6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ep-mail", - "version": "0.4.33", + "version": "0.4.34", "private": true, "description": "Eternity Project mail client", "homepage": "https://git.eternityproject.fi/thuttu/ep-mail-client", diff --git a/renderer-state.js b/renderer-state.js index ed8091f..653b38e 100644 --- a/renderer-state.js +++ b/renderer-state.js @@ -23,15 +23,5 @@ writable: false }); - // Transitional aliases keep the existing classic-script features working while they migrate. - for (const key of Object.keys(state)) { - Object.defineProperty(root, key, { - get() { return state[key]; }, - set(value) { state[key] = value; }, - enumerable: false, - configurable: false - }); - } - return state; }); diff --git a/tests/renderer-state.test.cjs b/tests/renderer-state.test.cjs index 290ff1d..fc32815 100644 --- a/tests/renderer-state.test.cjs +++ b/tests/renderer-state.test.cjs @@ -3,29 +3,30 @@ const assert = require('node:assert/strict'); const vm = require('node:vm'); const { createRendererState } = require('../renderer-state.js'); -test('creates namespaced shared renderer state with compatibility accessors', () => { +test('creates namespaced shared renderer state without legacy globals', () => { const root = {}; const state = createRendererState(root); assert.equal(root.epMailState, state); assert.deepEqual(state.messages, []); assert.deepEqual(state.contacts, []); - assert.equal(root.activeFolder, 'Inbox'); - assert.equal(root.activeView, 'mail'); - assert.equal(root.activeMessage, 1); - assert.equal(root.query, ''); - assert.ok(root.selectedIds instanceof Set); + for (const key of Object.keys(state)) assert.equal(Object.hasOwn(root, key), false, `${key} must stay namespaced`); + assert.equal(state.activeFolder, 'Inbox'); + assert.equal(state.activeView, 'mail'); + assert.equal(state.activeMessage, 1); + assert.equal(state.query, ''); + assert.ok(state.selectedIds instanceof Set); - root.activeFolder = 'Archive'; + state.activeFolder = 'Archive'; assert.equal(state.activeFolder, 'Archive'); state.query = 'from:alice'; - assert.equal(root.query, 'from:alice'); + assert.equal(state.query, 'from:alice'); vm.createContext(root); - vm.runInContext('messages.push({ id: 1 }); activeFolder = "Sent"; selectedIds.add(5);', root); + vm.runInContext('epMailState.messages.push({ id: 1 }); epMailState.activeFolder = "Sent"; epMailState.selectedIds.add(5);', root); assert.equal(state.messages.length, 1); assert.equal(state.messages[0].id, 1); assert.equal(state.activeFolder, 'Sent'); assert.equal(state.selectedIds.has(5), true); - root.epMailState = {}; assert.equal(root.epMailState, state); + assert.equal(Object.getOwnPropertyDescriptor(root, 'epMailState').writable, false); }); diff --git a/www/renderer-state.js b/www/renderer-state.js index ed8091f..653b38e 100644 --- a/www/renderer-state.js +++ b/www/renderer-state.js @@ -23,15 +23,5 @@ writable: false }); - // Transitional aliases keep the existing classic-script features working while they migrate. - for (const key of Object.keys(state)) { - Object.defineProperty(root, key, { - get() { return state[key]; }, - set(value) { state[key] = value; }, - enumerable: false, - configurable: false - }); - } - return state; });