@toeverything/y-indexeddb
Advanced tools
Comparing version 0.7.0-canary.10 to 0.7.0-canary.11
@@ -17,1 +17,2 @@ import { Doc } from 'yjs'; | ||
export * from './utils'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -30,3 +30,3 @@ import { openDB as h } from "idb"; | ||
const o = await t.transaction("updates", "readonly").objectStore("updates").getAll(); | ||
if (!Array.isArray(o) || !o.every((p) => p instanceof Uint8Array)) | ||
if (!Array.isArray(o) || !o.every((u) => u instanceof Uint8Array)) | ||
return; | ||
@@ -58,4 +58,4 @@ const n = x(o), d = e.transaction("workspace", "readwrite").objectStore("workspace"); | ||
return; | ||
const p = x(s), u = e.transaction("workspace", "readwrite").objectStore("workspace"); | ||
await u.get(i) || (console.log("upgrading the database"), await u.put({ | ||
const u = x(s), p = e.transaction("workspace", "readwrite").objectStore("workspace"); | ||
await p.get(i) || (console.log("upgrading the database"), await p.put({ | ||
id: i, | ||
@@ -65,3 +65,3 @@ updates: [ | ||
timestamp: Date.now(), | ||
update: p | ||
update: u | ||
} | ||
@@ -104,10 +104,10 @@ ] | ||
), d = new V( | ||
[...t.share.keys()].map((p) => { | ||
const u = r(p); | ||
if (u === "Text") | ||
return t.getText(p); | ||
if (u === "Map") | ||
return t.getMap(p); | ||
if (u === "Array") | ||
return t.getArray(p); | ||
[...t.share.keys()].map((u) => { | ||
const p = r(u); | ||
if (p === "Text") | ||
return t.getText(u); | ||
if (p === "Map") | ||
return t.getMap(u); | ||
if (p === "Array") | ||
return t.getArray(u); | ||
throw new Error("Unknown type"); | ||
@@ -187,11 +187,11 @@ }), | ||
upgrade: E | ||
}), p = async () => { | ||
}), u = async () => { | ||
n = !0, (await s).close(); | ||
}, u = { | ||
}, p = { | ||
connect: async () => { | ||
if (n) | ||
return; | ||
u.whenSynced = new Promise((w, c) => { | ||
p.whenSynced = new Promise((w, c) => { | ||
o = !0, t = w, i = c; | ||
}), n = !0, a.on("update", d), a.on("destroy", p); | ||
}), n = !0, a.on("update", d), a.on("destroy", u); | ||
const f = await s; | ||
@@ -245,3 +245,3 @@ await _(f, e, r); | ||
disconnect() { | ||
n = !1, o && i(new $()), a.off("update", d), a.off("destroy", p); | ||
n = !1, o && i(new $()), a.off("update", d), a.off("destroy", u); | ||
}, | ||
@@ -258,3 +258,3 @@ async cleanup() { | ||
}; | ||
return u; | ||
return p; | ||
}; | ||
@@ -261,0 +261,0 @@ export { |
@@ -40,1 +40,2 @@ import type { DBSchema, IDBPDatabase } from 'idb/build/entry'; | ||
} | ||
//# sourceMappingURL=shared.d.ts.map |
@@ -10,1 +10,2 @@ import type { IDBPDatabase } from 'idb/build/entry'; | ||
export declare function downloadBinary(id: string, dbName?: string): Promise<UpdateMessage['update'] | false>; | ||
//# sourceMappingURL=utils.d.ts.map |
{ | ||
"name": "@toeverything/y-indexeddb", | ||
"type": "module", | ||
"version": "0.7.0-canary.10", | ||
"version": "0.7.0-canary.11", | ||
"scripts": { | ||
@@ -35,4 +35,4 @@ "build": "vite build" | ||
"devDependencies": { | ||
"@blocksuite/blocks": "0.0.0-20230606130340-805f430b-nightly", | ||
"@blocksuite/store": "0.0.0-20230606130340-805f430b-nightly", | ||
"@blocksuite/blocks": "0.0.0-20230607055421-9b20fcaf-nightly", | ||
"@blocksuite/store": "0.0.0-20230607055421-9b20fcaf-nightly", | ||
"vite": "^4.3.9", | ||
@@ -39,0 +39,0 @@ "vite-plugin-dts": "^2.3.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
60608
12