Skip to content

Commit fd7ed18

Browse files
committed
Fix issue #29 and prepare for 1.1.7 release
1 parent a340c57 commit fd7ed18

File tree

5 files changed

+77
-4
lines changed

5 files changed

+77
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
## [1.1.7] - 2025-??-??
5+
## [1.1.7] - 2025-10-01
66

77
### Changes
88

99
- Fixed [issue #10](https://github.com/codedread/spaces/issues/10): Display space window bounds at their last known position and size.
1010
- Fixed [issue #20](https://github.com/codedread/spaces/issues/20): Close browser windows from the Spaces window.
11-
- Increased unit test coverage from 10.75% to 16.35%.
11+
- Fixed [issue #29](https://github.com/codedread/spaces/issues/29): Provide a debug method to export anonymized Spaces DB for debugging.
12+
- Fixed [issue #30](https://github.com/codedread/spaces/issues/30): Do not prompt twice to overwrite space name.
13+
- Increased unit test coverage from 10.75% to 16.17%.
1214

1315
## [1.1.6] - 2025-09-17
1416

js/background/background.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,20 @@ export function initializeServiceWorker() {
232232

233233
console.log(`Initializing spacesService...`);
234234
spacesService.initialiseSpaces();
235+
236+
// Make debugging function available globally in service worker scope
237+
globalThis.spaces = {
238+
async dumpAnonymizedDatabase() {
239+
try {
240+
const exportData = await spacesService.exportDatabaseForDebugging();
241+
const jsonString = JSON.stringify(exportData, null, 2);
242+
const dataUrl = `data:application/json;charset=utf-8,${encodeURIComponent(jsonString)}`;
243+
await chrome.downloads.download({ url: dataUrl, filename: 'spaces-db.json' });
244+
} catch (error) {
245+
console.error('Failed to export database for debugging:', error);
246+
}
247+
}
248+
};
235249
}
236250

237251
/**

js/background/dbService.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,6 @@ class DbService {
238238

239239
// Export an instantiated object
240240
export const dbService = new DbService();
241+
242+
// Export schema function and constants for debugging purposes
243+
export { getSchema, DB_VERSION, DB_SERVER, DB_SESSIONS };

js/background/spacesService.js

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
/** @typedef {import('./dbService.js').Session} Session */
88

9-
import { dbService } from './dbService.js';
9+
import { dbService, getSchema, DB_VERSION } from './dbService.js';
1010

1111
// Module-level properties
1212
const debug = false;
@@ -371,6 +371,59 @@ class SpacesService {
371371
return [...(this.sessions || [])];
372372
}
373373

374+
/**
375+
* Exports the entire database for debugging purposes with anonymized data.
376+
* @returns {Promise<Object>} Promise that resolves to an object containing:
377+
* - version: database version
378+
* - schema: database schema
379+
* - sessions: anonymized session data
380+
*/
381+
async exportDatabaseForDebugging() {
382+
await this.ensureInitialized();
383+
384+
const anonymizedSessions = (await dbService.fetchAllSessions()).map((session, index) => {
385+
const anonymizedSession = { ...session };
386+
if (session.name) anonymizedSession.name = `Space_${index + 1}`;
387+
if (session.tabs && Array.isArray(session.tabs)) {
388+
anonymizedSession.tabs = session.tabs.map((tab, tabIndex) =>
389+
this._anonymizeTab(tab, tabIndex + 1, 'Tab')
390+
);
391+
}
392+
if (session.history && Array.isArray(session.history)) {
393+
anonymizedSession.history = session.history.map((historyTab, historyIndex) =>
394+
this._anonymizeTab(historyTab, historyIndex + 1, 'History Tab')
395+
);
396+
}
397+
return anonymizedSession;
398+
});
399+
400+
return {
401+
version: {
402+
database: DB_VERSION,
403+
extension: await this.fetchLastVersion(),
404+
manifest: chrome.runtime.getManifest().version
405+
},
406+
schema: getSchema(),
407+
sessions: anonymizedSessions,
408+
};
409+
}
410+
411+
/**
412+
* Anonymizes a tab object for debugging export
413+
* @private
414+
* @param {Object} tab - The tab object to anonymize
415+
* @param {number} index - The index number for generating unique placeholder values
416+
* @param {string} prefix - The prefix for the title (e.g., 'Tab' or 'History Tab')
417+
* @returns {Object} Anonymized tab object
418+
*/
419+
_anonymizeTab(tab, index, prefix) {
420+
const anonymizedTab = { ...tab };
421+
if (tab.url) anonymizedTab.url = `https://example-${index}.com/path`;
422+
if (tab.title) anonymizedTab.title = `${prefix} ${index}`;
423+
if (tab.favIconUrl) anonymizedTab.favIconUrl = 'data:anonymized-favicon';
424+
return anonymizedTab;
425+
}
426+
374427
/**
375428
* Find a session by windowId, checking both in-memory sessions and database
376429
* @param {number} windowId - The window ID to search for

manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"name": "Spaces",
33
"description": "Intuitive tab management",
4-
"version": "1.1.7.4",
4+
"version": "1.1.7",
55
"permissions": [
66
"contextMenus",
7+
"downloads",
78
"favicon",
89
"history",
910
"storage",

0 commit comments

Comments
 (0)