diff --git a/REFACTOR_PLAN.md b/REFACTOR_PLAN.md
index 3790cad..4d3b8a5 100644
--- a/REFACTOR_PLAN.md
+++ b/REFACTOR_PLAN.md
@@ -111,6 +111,7 @@ This is a gradual destination, not a requirement to move everything at once. IPC
- [x] Migrate OpenPGP key UI to the mail feature API for active-account access (`pgp-ui.js`).
- [x] Make the core app shell consume the namespaced renderer state instead of compatibility aliases.
- [x] Expose core shell behavior through an explicit renderer API and migrate mail UI selectors, notifications, rendering, and compose hooks to that API (`app.js`, `mail-ui.js`).
+- [x] Hide the account-manager script in a local module scope and route selectors, escaping, notifications, and DAV navigation through explicit feature APIs (`account-ui.js`, `dav-ui.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.
@@ -139,7 +140,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.22`; Android derives `versionName 0.4.22` and `versionCode 422`. The user confirms the current artifact works.
+- Latest version check: `package.json` and both lockfile version fields are `0.4.23`; Android derives `versionName 0.4.23` and `versionCode 423`. The user confirms the previous artifact works; this bump is for the next build.
## Progress log
@@ -164,5 +165,6 @@ This is a gradual destination, not a requirement to move everything at once. IPC
- Step 6 migrated snooze, attachment, OpenPGP mail/key, shortcut, productivity state/render, and DAV UI integrations to feature APIs; compatibility globals remain in the core shell and some cross-feature hooks. The core app now reads shared state through `renderer-state.js`; the suite passes 123 tests.
- Step 6 added an explicit `epMailShell` interface for mail UI selectors, notifications, views, and renderer wrappers. `mail-ui.js` now uses it rather than directly replacing core renderer functions; search resets use namespaced state, and preferences remain owned by the productivity feature.
- Step 6 verification at version `0.4.22` / Android build number `422`: all 123 tests pass, including generated `www/` parity and combined classic-script parsing.
+- Step 6 at version `0.4.23` moves account-manager dependencies onto feature APIs and publishes the DAV manager through `window.epMailFeatures.dav` instead of a free global function.
- 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/account-ui.js b/account-ui.js
index 351f581..3def3e6 100644
--- a/account-ui.js
+++ b/account-ui.js
@@ -1,11 +1,13 @@
+(() => {
const accountMailUi = window.epMailFeatures.mail;
+const accountDavUi = window.epMailFeatures.dav;
async function openAccountManager(){
- const root=$('#modal-root');
+ const root=accountMailUi.select('#modal-root');
try{
const data=await window.daybreakMail.listAccounts();
const accounts=data.accounts||[];
- const rows=accounts.map(account=>`
${esc(account.displayName||account.email)} ${esc(account.email)} · ${esc(account.imapHost)} · ${esc(account.smtpHost)}
${account.id===data.activeId?'Current ':`Switch `}Edit Remove
`).join('');
+ const rows=accounts.map(account=>`${accountMailUi.escapeHtml(account.displayName||account.email)} ${accountMailUi.escapeHtml(account.email)} · ${accountMailUi.escapeHtml(account.imapHost)} · ${accountMailUi.escapeHtml(account.smtpHost)}
${account.id===data.activeId?'Current ':`Switch `}Edit Remove
`).join('');
root.innerHTML=`Account Settings ×
${rows||'
No mailboxes connected yet.
'}
Calendar and contacts Configure CalDAV calendar and CardDAV address book servers.
Calendar servers Contact servers
`;
const close=()=>root.innerHTML='';
root.querySelectorAll('.modal-close').forEach(button=>button.onclick=close);
@@ -13,16 +15,17 @@ async function openAccountManager(){
root.querySelector('#add-mail-account').onclick=()=>{close();accountMailUi.openMailAccount()};
root.onclick=async event=>{
const switchButton=event.target.closest('[data-switch-account]');
- if(switchButton){switchButton.disabled=true;try{accountMailUi.connectedAccount=await window.daybreakMail.selectAccount(switchButton.dataset.switchAccount);accountMailUi.state.activeFolder='Inbox';accountMailUi.setPageOffset(0);document.querySelectorAll('.folder').forEach(button=>button.classList.toggle('active',button.dataset.folder==='Inbox'));$('#sidebar-title').textContent='Inbox';$('#crumb-current').textContent='Inbox';accountMailUi.updateAccountCard(accountMailUi.connectedAccount);close();await accountMailUi.syncMailbox(true,{offset:0})}catch(error){toast(error.message||'Could not switch accounts');switchButton.disabled=false}return}
+ if(switchButton){switchButton.disabled=true;try{accountMailUi.connectedAccount=await window.daybreakMail.selectAccount(switchButton.dataset.switchAccount);accountMailUi.state.activeFolder='Inbox';accountMailUi.setPageOffset(0);document.querySelectorAll('.folder').forEach(button=>button.classList.toggle('active',button.dataset.folder==='Inbox'));accountMailUi.select('#sidebar-title').textContent='Inbox';accountMailUi.select('#crumb-current').textContent='Inbox';accountMailUi.updateAccountCard(accountMailUi.connectedAccount);close();await accountMailUi.syncMailbox(true,{offset:0})}catch(error){accountMailUi.toast(error.message||'Could not switch accounts');switchButton.disabled=false}return}
const davButton=event.target.closest('[data-open-dav]');
- if(davButton){close();openDavManager(davButton.dataset.openDav);return}
+ if(davButton){close();accountDavUi.openManager(davButton.dataset.openDav);return}
const editButton=event.target.closest('[data-edit-account]');
if(editButton){const account=accounts.find(item=>item.id===editButton.dataset.editAccount);if(account)accountMailUi.openMailAccount(account);return}
const removeButton=event.target.closest('[data-remove-account]');
- if(removeButton){const email=removeButton.closest('.account-row').querySelector('strong').textContent;if(!confirm(`Remove ${email} from this device?`))return;removeButton.disabled=true;try{const result=await window.daybreakMail.removeAccount(removeButton.dataset.removeAccount);const active=result.accounts.find(account=>account.id===result.activeId)||null;accountMailUi.connectedAccount=active;if(active){accountMailUi.updateAccountCard(active);close();accountMailUi.state.activeFolder='Inbox';accountMailUi.setPageOffset(0);await accountMailUi.syncMailbox(false,{offset:0})}else{accountMailUi.updateAccountCard({email:'Connect a mailbox',imapHost:''});accountMailUi.state.messages.splice(0,accountMailUi.state.messages.length);accountMailUi.renderList();$('#reader-pane').innerHTML=accountMailUi.emptyReader();toast('Mail account removed');openAccountManager()}}catch(error){toast(error.message||'Could not remove the account');removeButton.disabled=false}return}
+ if(removeButton){const email=removeButton.closest('.account-row').querySelector('strong').textContent;if(!confirm(`Remove ${email} from this device?`))return;removeButton.disabled=true;try{const result=await window.daybreakMail.removeAccount(removeButton.dataset.removeAccount);const active=result.accounts.find(account=>account.id===result.activeId)||null;accountMailUi.connectedAccount=active;if(active){accountMailUi.updateAccountCard(active);close();accountMailUi.state.activeFolder='Inbox';accountMailUi.setPageOffset(0);await accountMailUi.syncMailbox(false,{offset:0})}else{accountMailUi.updateAccountCard({email:'Connect a mailbox',imapHost:''});accountMailUi.state.messages.splice(0,accountMailUi.state.messages.length);accountMailUi.renderList();accountMailUi.select('#reader-pane').innerHTML=accountMailUi.emptyReader();accountMailUi.toast('Mail account removed');openAccountManager()}}catch(error){accountMailUi.toast(error.message||'Could not remove the account');removeButton.disabled=false}return}
};
- }catch(error){toast(error.message||'Could not load mail accounts')}
+ }catch(error){accountMailUi.toast(error.message||'Could not load mail accounts')}
}
document.addEventListener('click',event=>{const card=event.target.closest('#account-settings');if(!card)return;event.preventDefault();event.stopImmediatePropagation();openAccountManager()},true);
document.addEventListener('keydown',event=>{const card=event.target.closest('#account-settings');if(!card||!['Enter',' '].includes(event.key))return;event.preventDefault();event.stopImmediatePropagation();openAccountManager()},true);
+})();
diff --git a/dav-ui.js b/dav-ui.js
index 6a3bbbd..72a15ed 100644
--- a/dav-ui.js
+++ b/dav-ui.js
@@ -40,3 +40,8 @@ function showDavConnect(type){
root.querySelector('#dav-server-url').focus();
}
document.addEventListener('click',event=>{const button=event.target.closest('#caldav-sync,#carddav-sync');if(!button)return;event.preventDefault();event.stopImmediatePropagation();syncDav(button.id.startsWith('caldav')?'caldav':'carddav')},true);
+
+window.epMailFeatures.dav = Object.freeze({
+ openManager: openDavManager,
+ sync: syncDav
+});
diff --git a/index.html b/index.html
index f218c0a..fdc7c00 100644
--- a/index.html
+++ b/index.html
@@ -72,8 +72,8 @@
-
+
diff --git a/package-lock.json b/package-lock.json
index 73e4459..0b6786b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "ep-mail",
- "version": "0.4.22",
+ "version": "0.4.23",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "ep-mail",
- "version": "0.4.22",
+ "version": "0.4.23",
"dependencies": {
"@capacitor/android": "^8.5.2",
"@capacitor/core": "^8.5.2",
diff --git a/package.json b/package.json
index e993787..a29f300 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "ep-mail",
- "version": "0.4.22",
+ "version": "0.4.23",
"private": true,
"description": "Eternity Project mail client",
"homepage": "https://git.eternityproject.fi/thuttu/ep-mail-client",
diff --git a/tests/renderer-bootstrap.test.cjs b/tests/renderer-bootstrap.test.cjs
index 6683714..6b3ce30 100644
--- a/tests/renderer-bootstrap.test.cjs
+++ b/tests/renderer-bootstrap.test.cjs
@@ -15,7 +15,11 @@ test('renderer bootstrap loads shared state and mail security before the applica
const app = html.indexOf('');
const platformBridge = html.indexOf('');
const mailUi = html.indexOf('');
+ const productivity = html.indexOf('');
+ const davUi = html.indexOf('');
+ const accountUi = html.indexOf('');
assert.ok(state >= 0 && contentSecurity > state && app > contentSecurity && mailApi > platformBridge && mailUi > mailApi);
+ assert.ok(productivity > mailUi && davUi > productivity && accountUi > davUi);
});
test('core app shell uses the namespaced renderer state', () => {
diff --git a/tests/renderer-mail-api.test.cjs b/tests/renderer-mail-api.test.cjs
index 9d01450..a95b320 100644
--- a/tests/renderer-mail-api.test.cjs
+++ b/tests/renderer-mail-api.test.cjs
@@ -63,6 +63,7 @@ test('account and snooze UI consume the explicit mail API instead of selected le
const attachmentUi = fs.readFileSync(path.join(root, 'attachments.js'), 'utf8');
const pgpMailUi = fs.readFileSync(path.join(root, 'pgp-mail-ui.js'), 'utf8');
const pgpUi = fs.readFileSync(path.join(root, 'pgp-ui.js'), 'utf8');
+ const davUi = fs.readFileSync(path.join(root, 'dav-ui.js'), 'utf8');
const appShell = fs.readFileSync(path.join(root, 'app.js'), 'utf8');
const mailUi = fs.readFileSync(path.join(root, 'mail-ui.js'), 'utf8');
const shortcutsUi = fs.readFileSync(path.join(root, 'shortcuts.js'), 'utf8');
@@ -72,6 +73,10 @@ test('account and snooze UI consume the explicit mail API instead of selected le
assert.match(attachmentUi, /window\.epMailFeatures\.mail/);
assert.match(pgpMailUi, /window\.epMailFeatures\.mail/);
assert.match(pgpUi, /window\.epMailFeatures\.mail\.connectedAccount/);
+ assert.match(accountUi, /const accountDavUi = window\.epMailFeatures\.dav/);
+ assert.match(accountUi, /accountDavUi\.openManager/);
+ assert.doesNotMatch(accountUi, /(? {
const accountMailUi = window.epMailFeatures.mail;
+const accountDavUi = window.epMailFeatures.dav;
async function openAccountManager(){
- const root=$('#modal-root');
+ const root=accountMailUi.select('#modal-root');
try{
const data=await window.daybreakMail.listAccounts();
const accounts=data.accounts||[];
- const rows=accounts.map(account=>`${esc(account.displayName||account.email)} ${esc(account.email)} · ${esc(account.imapHost)} · ${esc(account.smtpHost)}
${account.id===data.activeId?'Current ':`Switch `}Edit Remove
`).join('');
+ const rows=accounts.map(account=>`${accountMailUi.escapeHtml(account.displayName||account.email)} ${accountMailUi.escapeHtml(account.email)} · ${accountMailUi.escapeHtml(account.imapHost)} · ${accountMailUi.escapeHtml(account.smtpHost)}
${account.id===data.activeId?'Current ':`Switch `}Edit Remove
`).join('');
root.innerHTML=`Account Settings ×
${rows||'
No mailboxes connected yet.
'}
Calendar and contacts Configure CalDAV calendar and CardDAV address book servers.
Calendar servers Contact servers
`;
const close=()=>root.innerHTML='';
root.querySelectorAll('.modal-close').forEach(button=>button.onclick=close);
@@ -13,16 +15,17 @@ async function openAccountManager(){
root.querySelector('#add-mail-account').onclick=()=>{close();accountMailUi.openMailAccount()};
root.onclick=async event=>{
const switchButton=event.target.closest('[data-switch-account]');
- if(switchButton){switchButton.disabled=true;try{accountMailUi.connectedAccount=await window.daybreakMail.selectAccount(switchButton.dataset.switchAccount);accountMailUi.state.activeFolder='Inbox';accountMailUi.setPageOffset(0);document.querySelectorAll('.folder').forEach(button=>button.classList.toggle('active',button.dataset.folder==='Inbox'));$('#sidebar-title').textContent='Inbox';$('#crumb-current').textContent='Inbox';accountMailUi.updateAccountCard(accountMailUi.connectedAccount);close();await accountMailUi.syncMailbox(true,{offset:0})}catch(error){toast(error.message||'Could not switch accounts');switchButton.disabled=false}return}
+ if(switchButton){switchButton.disabled=true;try{accountMailUi.connectedAccount=await window.daybreakMail.selectAccount(switchButton.dataset.switchAccount);accountMailUi.state.activeFolder='Inbox';accountMailUi.setPageOffset(0);document.querySelectorAll('.folder').forEach(button=>button.classList.toggle('active',button.dataset.folder==='Inbox'));accountMailUi.select('#sidebar-title').textContent='Inbox';accountMailUi.select('#crumb-current').textContent='Inbox';accountMailUi.updateAccountCard(accountMailUi.connectedAccount);close();await accountMailUi.syncMailbox(true,{offset:0})}catch(error){accountMailUi.toast(error.message||'Could not switch accounts');switchButton.disabled=false}return}
const davButton=event.target.closest('[data-open-dav]');
- if(davButton){close();openDavManager(davButton.dataset.openDav);return}
+ if(davButton){close();accountDavUi.openManager(davButton.dataset.openDav);return}
const editButton=event.target.closest('[data-edit-account]');
if(editButton){const account=accounts.find(item=>item.id===editButton.dataset.editAccount);if(account)accountMailUi.openMailAccount(account);return}
const removeButton=event.target.closest('[data-remove-account]');
- if(removeButton){const email=removeButton.closest('.account-row').querySelector('strong').textContent;if(!confirm(`Remove ${email} from this device?`))return;removeButton.disabled=true;try{const result=await window.daybreakMail.removeAccount(removeButton.dataset.removeAccount);const active=result.accounts.find(account=>account.id===result.activeId)||null;accountMailUi.connectedAccount=active;if(active){accountMailUi.updateAccountCard(active);close();accountMailUi.state.activeFolder='Inbox';accountMailUi.setPageOffset(0);await accountMailUi.syncMailbox(false,{offset:0})}else{accountMailUi.updateAccountCard({email:'Connect a mailbox',imapHost:''});accountMailUi.state.messages.splice(0,accountMailUi.state.messages.length);accountMailUi.renderList();$('#reader-pane').innerHTML=accountMailUi.emptyReader();toast('Mail account removed');openAccountManager()}}catch(error){toast(error.message||'Could not remove the account');removeButton.disabled=false}return}
+ if(removeButton){const email=removeButton.closest('.account-row').querySelector('strong').textContent;if(!confirm(`Remove ${email} from this device?`))return;removeButton.disabled=true;try{const result=await window.daybreakMail.removeAccount(removeButton.dataset.removeAccount);const active=result.accounts.find(account=>account.id===result.activeId)||null;accountMailUi.connectedAccount=active;if(active){accountMailUi.updateAccountCard(active);close();accountMailUi.state.activeFolder='Inbox';accountMailUi.setPageOffset(0);await accountMailUi.syncMailbox(false,{offset:0})}else{accountMailUi.updateAccountCard({email:'Connect a mailbox',imapHost:''});accountMailUi.state.messages.splice(0,accountMailUi.state.messages.length);accountMailUi.renderList();accountMailUi.select('#reader-pane').innerHTML=accountMailUi.emptyReader();accountMailUi.toast('Mail account removed');openAccountManager()}}catch(error){accountMailUi.toast(error.message||'Could not remove the account');removeButton.disabled=false}return}
};
- }catch(error){toast(error.message||'Could not load mail accounts')}
+ }catch(error){accountMailUi.toast(error.message||'Could not load mail accounts')}
}
document.addEventListener('click',event=>{const card=event.target.closest('#account-settings');if(!card)return;event.preventDefault();event.stopImmediatePropagation();openAccountManager()},true);
document.addEventListener('keydown',event=>{const card=event.target.closest('#account-settings');if(!card||!['Enter',' '].includes(event.key))return;event.preventDefault();event.stopImmediatePropagation();openAccountManager()},true);
+})();
diff --git a/www/dav-ui.js b/www/dav-ui.js
index 6a3bbbd..72a15ed 100644
--- a/www/dav-ui.js
+++ b/www/dav-ui.js
@@ -40,3 +40,8 @@ function showDavConnect(type){
root.querySelector('#dav-server-url').focus();
}
document.addEventListener('click',event=>{const button=event.target.closest('#caldav-sync,#carddav-sync');if(!button)return;event.preventDefault();event.stopImmediatePropagation();syncDav(button.id.startsWith('caldav')?'caldav':'carddav')},true);
+
+window.epMailFeatures.dav = Object.freeze({
+ openManager: openDavManager,
+ sync: syncDav
+});
diff --git a/www/index.html b/www/index.html
index f218c0a..fdc7c00 100644
--- a/www/index.html
+++ b/www/index.html
@@ -72,8 +72,8 @@
-
+