Open boggen opened 7 years ago
Been wanting to do this for a long time, but indexeddb api makes it very hard to create an effective explorer. I promise to look into this if Observer API will make it into IndexedDB spec
@jusio, what about chrome.debugger API? The only drawback is that a warning is displayed at the top of the page about it being debugged by an extension so I guess it should be performed only after the user has clicked on some button in the extension UI.
Here's PoC:
(async () => {
const {tabId} = chrome.devtools.inspectedWindow;
const {url} = await browser.tabs.get(tabId);
const securityOrigin = new URL(url).origin;
const IDB = new Proxy({}, {
get: (_, cmd) =>
params => new Promise((resolve, reject) => {
params = params && Object.assign({securityOrigin}, params);
chrome.debugger.sendCommand({tabId}, 'IndexedDB.' + cmd, params, response => {
if (!chrome.runtime.lastError) {
resolve(response);
} else {
reject(chrome.runtime.lastError);
}
});
})
});
await browser.debugger.attach({tabId}, '1.3');
// to receive modification events
await IDB.enable();
const dbs = new Map();
for (const databaseName of (await IDB.requestDatabaseNames({})).databaseNames) {
const db = (await IDB.requestDatabase({databaseName})).databaseWithObjectStores;
dbs.set(db.name, db);
for (const store of db.objectStores) {
store.data = await IDB.requestData({
databaseName,
indexName: '',
objectStoreName: store.name,
pageSize: 100,
skipCount: 0
});
}
}
console.log(dbs);
})();
I think this is a good idea, which can be theoretically even better than official apis I was planning on using. Unfortunately I have pretty much abandoned Storage Area Explorer lately, so I can't promise if I will be ever able to implement this :(
Well, maybe add a "Help wanted" or "Pullrequests welcome" label to all the feature requests that you think are useful?
Ok, I'll do that over the weekend. I just never thought that somebody would be willing to do anything on this project:D
web-sql from understanding is getting dismantled some time in the future leaving indexeddb.
the default "chrome -> developer tools -> application" for indexeddb is rather poor.