@toeverything/y-indexeddb
Advanced tools
Comparing version 0.7.0-canary.47 to 0.7.0-canary.48
@@ -1,4 +0,4 @@ | ||
import { openDB as h } from "idb"; | ||
import { mergeUpdates as V, Doc as W, applyUpdate as S, encodeStateVector as I, encodeStateAsUpdate as y, UndoManager as z, diffUpdate as J } from "yjs"; | ||
const P = 1, D = "affine-local"; | ||
import { openDB as D } from "idb"; | ||
import { mergeUpdates as V, Doc as W, applyUpdate as S, encodeStateVector as I, encodeStateAsUpdate as h, UndoManager as z, diffUpdate as J } from "yjs"; | ||
const P = 1, k = "affine-local"; | ||
function j(t) { | ||
@@ -19,3 +19,3 @@ t.createObjectStore("workspace", { keyPath: "id" }), t.createObjectStore("milestone", { keyPath: "id" }); | ||
} | ||
async function Q(t, s, c = D) { | ||
async function Q(t, s, c = k) { | ||
do | ||
@@ -27,3 +27,3 @@ if (!T || localStorage.getItem(`${c}-migration`) !== "true") { | ||
if (await K(s)) { | ||
await h(s, 1).then(async (a) => { | ||
await D(s, 1).then(async (a) => { | ||
if (!a.objectStoreNames.contains("updates")) | ||
@@ -52,3 +52,3 @@ return; | ||
const p = a.name, o = a.version; | ||
return h(p, o).then( | ||
return D(p, o).then( | ||
async (n) => { | ||
@@ -79,4 +79,4 @@ if (!n.objectStoreNames.contains("updates")) | ||
} | ||
async function tt(t, s = D) { | ||
const o = await (await h(s, P, { | ||
async function tt(t, s = k) { | ||
const o = await (await D(s, P, { | ||
upgrade: j | ||
@@ -86,4 +86,4 @@ })).transaction("workspace", "readonly").objectStore("workspace").get(t); | ||
} | ||
async function et(t, s, c = D) { | ||
await (await h(c, P, { | ||
async function et(t, s, c = k) { | ||
await (await D(c, P, { | ||
upgrade: j | ||
@@ -100,3 +100,3 @@ })).transaction("workspace", "readwrite").objectStore("workspace").put({ | ||
} | ||
const E = Symbol("indexeddb-provider-origin"), M = Symbol("snapshot-origin"); | ||
const y = "indexeddb-provider-origin", M = "snapshot-origin"; | ||
let $ = 500; | ||
@@ -116,3 +116,3 @@ const L = (t) => (t.preventDefault(), t.returnValue = "Data is not saved. Are you sure you want to leave?"), U = async (t) => { | ||
S(a, s, M); | ||
const p = I(t), o = I(a), n = y( | ||
const p = I(t), o = I(a), n = h( | ||
t, | ||
@@ -136,3 +136,3 @@ o | ||
S(a, n, M), u.undo(); | ||
const w = y( | ||
const w = h( | ||
a, | ||
@@ -153,6 +153,6 @@ p | ||
} | ||
const rt = async (t, s, c, a = D) => { | ||
const n = (await h(a, P, { | ||
const rt = async (t, s, c, a = k) => { | ||
const n = (await D(a, P, { | ||
upgrade: j | ||
})).transaction("milestone", "readwrite").objectStore("milestone"), u = await n.get("id"), w = y(s); | ||
})).transaction("milestone", "readwrite").objectStore("milestone"), u = await n.get("id"), w = h(s); | ||
u ? (u.milestone[c] = w, await n.put(u)) : await n.put({ | ||
@@ -164,10 +164,10 @@ id: t, | ||
}); | ||
}, st = async (t, s = D) => { | ||
const o = await (await h(s, P, { | ||
}, st = async (t, s = k) => { | ||
const o = await (await D(s, P, { | ||
upgrade: j | ||
})).transaction("milestone", "readonly").objectStore("milestone").get(t); | ||
return o ? o.milestone : null; | ||
}, ot = (t, s = D, c = !0) => { | ||
}, ot = (t, s = k, c = !0) => { | ||
let a, p, o = !0, n = !1; | ||
const u = h(s, P, { | ||
const u = D(s, P, { | ||
upgrade: j | ||
@@ -178,7 +178,7 @@ }), w = /* @__PURE__ */ new WeakMap(), f = /* @__PURE__ */ new WeakMap(), g = /* @__PURE__ */ new WeakMap(), x = (i, e) => { | ||
const r = async function(l, m) { | ||
const k = await u; | ||
if (!n || m === E) | ||
const v = await u; | ||
if (!n || m === y) | ||
return; | ||
const v = k.transaction("workspace", "readwrite").objectStore("workspace"); | ||
let d = await v.get(i); | ||
const E = v.transaction("workspace", "readwrite").objectStore("workspace"); | ||
let d = await E.get(i); | ||
if (d || (d = { | ||
@@ -194,6 +194,6 @@ id: i, | ||
F.forEach((H) => { | ||
S(C, H, E); | ||
S(C, H, y); | ||
}); | ||
}, E); | ||
const N = y(C); | ||
}, y); | ||
const N = h(C); | ||
d = { | ||
@@ -207,5 +207,5 @@ id: i, | ||
] | ||
}, await U(v.put(d)); | ||
}, await U(E.put(d)); | ||
} else | ||
await U(v.put(d)); | ||
await U(E.put(d)); | ||
}; | ||
@@ -252,3 +252,3 @@ return w.set(e, r), r; | ||
timestamp: Date.now(), | ||
update: y(e) | ||
update: h(e) | ||
} | ||
@@ -259,11 +259,11 @@ ] | ||
else { | ||
const m = l.updates.map(({ update: d }) => d), k = new W(); | ||
k.transact(() => { | ||
const m = l.updates.map(({ update: d }) => d), v = new W(); | ||
v.transact(() => { | ||
m.forEach((d) => { | ||
S(k, d); | ||
S(v, d, y); | ||
}); | ||
}, E); | ||
const v = J( | ||
y(e), | ||
y(k) | ||
}, y); | ||
const E = J( | ||
h(e), | ||
h(v) | ||
); | ||
@@ -277,3 +277,3 @@ await U( | ||
timestamp: Date.now(), | ||
update: v | ||
update: E | ||
} | ||
@@ -284,5 +284,5 @@ ] | ||
m.forEach((d) => { | ||
S(e, d); | ||
S(e, d, y); | ||
}); | ||
}, E); | ||
}, y); | ||
} | ||
@@ -326,3 +326,3 @@ } | ||
X as CleanupWhenConnectingError, | ||
D as DEFAULT_DB_NAME, | ||
k as DEFAULT_DB_NAME, | ||
R as EarlyDisconnectError, | ||
@@ -329,0 +329,0 @@ ot as createIndexedDBProvider, |
{ | ||
"name": "@toeverything/y-indexeddb", | ||
"type": "module", | ||
"version": "0.7.0-canary.47", | ||
"version": "0.7.0-canary.48", | ||
"description": "IndexedDB database adapter for Yjs", | ||
@@ -39,6 +39,6 @@ "repository": "toeverything/AFFiNE", | ||
"devDependencies": { | ||
"@blocksuite/blocks": "0.0.0-20230716144121-5b169b38-nightly", | ||
"@blocksuite/store": "0.0.0-20230716144121-5b169b38-nightly", | ||
"vite": "^4.3.9", | ||
"vite-plugin-dts": "3.0.2", | ||
"@blocksuite/blocks": "0.0.0-20230719163314-76d863fc-nightly", | ||
"@blocksuite/store": "0.0.0-20230719163314-76d863fc-nightly", | ||
"vite": "^4.4.4", | ||
"vite-plugin-dts": "3.3.1", | ||
"y-indexeddb": "^9.0.11" | ||
@@ -45,0 +45,0 @@ }, |
{ | ||
"name": "@toeverything/y-indexeddb", | ||
"type": "module", | ||
"version": "0.7.0-canary.47", | ||
"version": "0.7.0-canary.48", | ||
"description": "IndexedDB database adapter for Yjs", | ||
@@ -43,6 +43,6 @@ "repository": "toeverything/AFFiNE", | ||
"devDependencies": { | ||
"@blocksuite/blocks": "0.0.0-20230716144121-5b169b38-nightly", | ||
"@blocksuite/store": "0.0.0-20230716144121-5b169b38-nightly", | ||
"vite": "^4.3.9", | ||
"vite-plugin-dts": "3.0.2", | ||
"@blocksuite/blocks": "0.0.0-20230719163314-76d863fc-nightly", | ||
"@blocksuite/store": "0.0.0-20230719163314-76d863fc-nightly", | ||
"vite": "^4.4.4", | ||
"vite-plugin-dts": "3.3.1", | ||
"y-indexeddb": "^9.0.11" | ||
@@ -49,0 +49,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
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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
75611
418