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).

This commit is contained in:
2026-10-16 23:06:27 +03:00
parent ef764183ec
commit 7cd3e4a392
6 changed files with 17 additions and 34 deletions
+3 -1
View File
@@ -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.
+2 -2
View File
@@ -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",
+1 -1
View File
@@ -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",
-10
View File
@@ -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;
});
+11 -10
View File
@@ -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);
});
-10
View File
@@ -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;
});