CI / Build & Test (push) Failing after 28s
Split monolithic dashboard.js (2753 lines) into 18 focused modules
under dashboard/{core,data,ui,pages}/ with refresh.js and events.js
as orchestrators. Extracted ~900-line inline <style> into dashboard.css
and moved dashboard.html to dashboard/dashboard.html.
Split background.js (609 lines) into background/{logs,state,proxy,
native-messaging,tab-lifecycle,message-router}.js with a thin entry
point using importScripts().
Deleted dead files: wrong-domain.js (duplicate of inline script).
Updated manifest.json web_accessible_resources for new paths.
Updated docs/ARCHITECTURE.md to reflect the new file structure.
No functionality changed. No build step introduced.
30 lines
941 B
JavaScript
30 lines
941 B
JavaScript
// Wrapper around chrome.runtime.sendMessage for native host communication.
|
|
|
|
/** Send a typed message to the native host and return a Promise resolving to the response. */
|
|
function sendToNative(type, payload) {
|
|
return new Promise((resolve) => {
|
|
chrome.runtime.sendMessage(
|
|
{ target: 'holesail-native', action: 'send', payload: { type, payload } },
|
|
(response) => resolve(response)
|
|
);
|
|
});
|
|
}
|
|
|
|
/** Fetch the full extension state from the background service worker. */
|
|
async function fetchState() {
|
|
return new Promise((resolve) => {
|
|
chrome.runtime.sendMessage(
|
|
{ target: 'holesail-native', action: 'getState' },
|
|
(response) => {
|
|
if (chrome.runtime.lastError) {
|
|
log('fetchState error:', chrome.runtime.lastError.message);
|
|
resolve(null);
|
|
return;
|
|
}
|
|
if (response && response.ok) resolve(response.state);
|
|
else resolve(null);
|
|
}
|
|
);
|
|
});
|
|
}
|