dexie 4.1.0-beta.43 → 4.1.0-beta.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -1
- package/dist/dexie.d.ts +9 -6
- package/dist/dexie.js +84 -33
- package/dist/dexie.js.map +1 -1
- package/dist/dexie.min.js +1 -1
- package/dist/dexie.min.js.map +1 -1
- package/dist/dexie.mjs +84 -33
- package/dist/dexie.mjs.map +1 -1
- package/dist/modern/dexie.min.mjs +1 -1
- package/dist/modern/dexie.min.mjs.map +1 -1
- package/dist/modern/dexie.mjs +71 -30
- package/dist/modern/dexie.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,9 +1,31 @@
|
|
|
1
1
|
# Dexie.js
|
|
2
2
|
|
|
3
|
-
[![NPM Version][npm-image]][npm-url] 
|
|
3
|
+
[![NPM Version][npm-image]][npm-url]  [](https://discord.gg/huhre7MHBF)
|
|
4
4
|
|
|
5
5
|
Dexie.js is a wrapper library for indexedDB - the standard database in the browser. https://dexie.org.
|
|
6
6
|
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
/$$ /$$ /$$ /$$ /$$
|
|
10
|
+
| $$ | $$ | $$ | $$ | $$
|
|
11
|
+
| $$ | $$ /$$$$$$ /$$$$$$$| $$ /$$ /$$$$$$ /$$$$$$ | $$$$$$$ /$$$$$$ /$$$$$$$
|
|
12
|
+
| $$$$$$$$ |____ $$ /$$_____/| $$ /$$/ |____ $$|_ $$_/ | $$__ $$ /$$__ $$| $$__ $$
|
|
13
|
+
| $$__ $$ /$$$$$$$| $$ | $$$$$$/ /$$$$$$$ | $$ | $$ \ $$| $$ \ $$| $$ \ $$
|
|
14
|
+
| $$ | $$ /$$__ $$| $$ | $$_ $$ /$$__ $$ | $$ /$$| $$ | $$| $$ | $$| $$ | $$
|
|
15
|
+
| $$ | $$| $$$$$$$| $$$$$$$| $$ \ $$| $$$$$$$ | $$$$/| $$ | $$| $$$$$$/| $$ | $$
|
|
16
|
+
|__/ |__/ \_______/ \_______/|__/ \__/ \_______/ \___/ |__/ |__/ \______/ |__/ |__/
|
|
17
|
+
|
|
18
|
+
🌟 Welcome to Dexie Global Hackathon 25! 🌟
|
|
19
|
+
📅 Date: February 14 --> April 13, 2025
|
|
20
|
+
🕒 Start coding with Dexie Cloud and win prices!
|
|
21
|
+
|
|
22
|
+
For more information: dexie.org/hackathon
|
|
23
|
+
|
|
24
|
+
Good luck! 🚀
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
[dexie.org/hackathon](https://dexie.org/hackathon/)
|
|
28
|
+
|
|
7
29
|
#### Why Dexie.js?
|
|
8
30
|
|
|
9
31
|
IndexedDB is the portable database for all browser engines. Dexie.js makes it fun and easy to work with.
|
package/dist/dexie.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* By David Fahlander, david.fahlander@gmail.com
|
|
6
6
|
*
|
|
7
|
-
* Version 4.1.0-beta.
|
|
7
|
+
* Version 4.1.0-beta.45, Mon Mar 31 2025
|
|
8
8
|
*
|
|
9
9
|
* https://dexie.org
|
|
10
10
|
*
|
|
@@ -1337,22 +1337,25 @@ declare class DexieYProvider$1<YDoc extends YjsDoc = any> implements DexieYProvi
|
|
|
1337
1337
|
private stopObserving;
|
|
1338
1338
|
private cleanupHandlers;
|
|
1339
1339
|
private graceTimer;
|
|
1340
|
-
private graceTimeout
|
|
1340
|
+
private graceTimeout;
|
|
1341
1341
|
doc: YDoc;
|
|
1342
1342
|
awareness?: any;
|
|
1343
|
-
|
|
1344
|
-
|
|
1343
|
+
private _error?;
|
|
1344
|
+
private _whenLoaded;
|
|
1345
|
+
private _whenSynced;
|
|
1345
1346
|
on: DexieEventSet & ((name: string, f: (...args: any[]) => any) => void);
|
|
1346
1347
|
off: (name: string, f: (...args: any[]) => any) => void;
|
|
1347
1348
|
destroyed: boolean;
|
|
1348
1349
|
static on: DexieEventSet & ((name: string, f: (...args: any[]) => any) => void);
|
|
1349
1350
|
static getOrCreateDocument(db: Dexie, table: string, prop: string, id: any): YjsDoc;
|
|
1350
|
-
static load<YDoc extends YjsDoc>(doc: YDoc): DexieYProvider$1<YDoc>;
|
|
1351
|
-
static release<YDoc extends YjsDoc>(doc: YDoc
|
|
1351
|
+
static load<YDoc extends YjsDoc>(doc: YDoc, options?: ReleaseOptions): DexieYProvider$1<YDoc>;
|
|
1352
|
+
static release<YDoc extends YjsDoc>(doc: YDoc): void;
|
|
1352
1353
|
private _release;
|
|
1353
1354
|
static for<YDoc extends YjsDoc>(doc: YDoc): DexieYProvider$1<YDoc> | undefined;
|
|
1354
1355
|
static getDocCache: typeof getDocCache;
|
|
1355
1356
|
static currentUpdateRow: YUpdateRow | null;
|
|
1357
|
+
get whenLoaded(): Promise<void>;
|
|
1358
|
+
get whenSynced(): Promise<void>;
|
|
1356
1359
|
constructor(doc: YDoc);
|
|
1357
1360
|
destroy(): void;
|
|
1358
1361
|
addCleanupHandler(cleanupHandler: (() => void) | Unsubscribable): void;
|
package/dist/dexie.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* By David Fahlander, david.fahlander@gmail.com
|
|
6
6
|
*
|
|
7
|
-
* Version 4.1.0-beta.
|
|
7
|
+
* Version 4.1.0-beta.45, Mon Mar 31 2025
|
|
8
8
|
*
|
|
9
9
|
* https://dexie.org
|
|
10
10
|
*
|
|
@@ -1179,7 +1179,7 @@
|
|
|
1179
1179
|
}
|
|
1180
1180
|
}
|
|
1181
1181
|
|
|
1182
|
-
var DEXIE_VERSION = '4.1.0-beta.
|
|
1182
|
+
var DEXIE_VERSION = '4.1.0-beta.45';
|
|
1183
1183
|
var maxString = String.fromCharCode(65535);
|
|
1184
1184
|
var minKey = -Infinity;
|
|
1185
1185
|
var INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
|
|
@@ -1340,7 +1340,7 @@
|
|
|
1340
1340
|
var destroyedDocs = new WeakSet();
|
|
1341
1341
|
function throwIfDestroyed(doc) {
|
|
1342
1342
|
if (destroyedDocs.has(doc))
|
|
1343
|
-
throw new Error(
|
|
1343
|
+
throw new Error("Y.Doc ".concat(doc.meta.parentId, " has been destroyed"));
|
|
1344
1344
|
}
|
|
1345
1345
|
function getYDocCacheKey(table, primaryKey, ydocProp) {
|
|
1346
1346
|
return "".concat(table, "[").concat(primaryKey, "].").concat(ydocProp);
|
|
@@ -6608,18 +6608,11 @@
|
|
|
6608
6608
|
var _this = this;
|
|
6609
6609
|
this.refCount = 1;
|
|
6610
6610
|
this.cleanupHandlers = [];
|
|
6611
|
+
this.graceTimeout = -1;
|
|
6611
6612
|
this.destroyed = false;
|
|
6612
6613
|
this.on = createEvents();
|
|
6613
6614
|
this.doc = doc;
|
|
6614
6615
|
this.off = function (name, f) { var _a; return (_a = _this.on[name]) === null || _a === void 0 ? void 0 : _a.unsubscribe(f); };
|
|
6615
|
-
this.whenLoaded = new Promise(function (resolve, reject) {
|
|
6616
|
-
_this.on('load', resolve);
|
|
6617
|
-
_this.on('error', reject);
|
|
6618
|
-
});
|
|
6619
|
-
this.whenSynced = new Promise(function (resolve, reject) {
|
|
6620
|
-
_this.on('sync', resolve);
|
|
6621
|
-
_this.on('error', reject);
|
|
6622
|
-
});
|
|
6623
6616
|
if ('dispose' in Symbol) {
|
|
6624
6617
|
this[Symbol.dispose] =
|
|
6625
6618
|
function () { return DexieYProvider.release(doc); };
|
|
@@ -6627,16 +6620,20 @@
|
|
|
6627
6620
|
doc.on('load', function () { return _this.on('load').fire(); });
|
|
6628
6621
|
doc.on('sync', function (sync) { return sync !== false && _this.on('sync').fire(); });
|
|
6629
6622
|
doc.on('destroy', this.destroy.bind(this));
|
|
6623
|
+
this.on('error', function (error) {
|
|
6624
|
+
_this._error = error;
|
|
6625
|
+
});
|
|
6630
6626
|
var _a = doc.meta || {}, db = _a.db, parentTable = _a.parentTable, parentId = _a.parentId, updatesTable = _a.updatesTable;
|
|
6631
|
-
if (db
|
|
6632
|
-
|
|
6633
|
-
throw new Error("Table ".concat(parentTable, " or ").concat(updatesTable, " not found in db"));
|
|
6634
|
-
}
|
|
6635
|
-
throwIfDestroyed(doc);
|
|
6636
|
-
var Y = getYLibrary(db);
|
|
6637
|
-
this.stopObserving = observeYDocUpdates(this, doc, db, parentTable, updatesTable, parentId, Y);
|
|
6638
|
-
db.on.y.fire(this, Y);
|
|
6627
|
+
if (!db || !parentTable || !updatesTable) {
|
|
6628
|
+
throw new Error("Missing Dexie-related metadata in Y.Doc. Documents need to be obtained through Y.Doc properties from dexie queries.");
|
|
6639
6629
|
}
|
|
6630
|
+
if (!db.table(parentTable) || !db.table(updatesTable)) {
|
|
6631
|
+
throw new Error("Table ".concat(parentTable, " or ").concat(updatesTable, " not found in db"));
|
|
6632
|
+
}
|
|
6633
|
+
throwIfDestroyed(doc);
|
|
6634
|
+
var Y = getYLibrary(db);
|
|
6635
|
+
this.stopObserving = observeYDocUpdates(this, doc, db, parentTable, updatesTable, parentId, Y);
|
|
6636
|
+
db.on.y.fire(this, Y);
|
|
6640
6637
|
}
|
|
6641
6638
|
DexieYProvider.getOrCreateDocument = function (db, table, prop, id) {
|
|
6642
6639
|
var _a, _b;
|
|
@@ -6644,39 +6641,42 @@
|
|
|
6644
6641
|
var updatesTable = (_b = (_a = db.table(table).schema.yProps) === null || _a === void 0 ? void 0 : _a.find(function (p) { return p.prop === prop; })) === null || _b === void 0 ? void 0 : _b.updatesTable;
|
|
6645
6642
|
return getOrCreateDocument(db, docCache, getYLibrary(db), table, prop, updatesTable, id);
|
|
6646
6643
|
};
|
|
6647
|
-
DexieYProvider.load = function (doc) {
|
|
6644
|
+
DexieYProvider.load = function (doc, options) {
|
|
6645
|
+
var _a;
|
|
6648
6646
|
var p = wm.get(doc);
|
|
6649
6647
|
if (p) {
|
|
6650
6648
|
++p.refCount;
|
|
6649
|
+
if ((options === null || options === void 0 ? void 0 : options.gracePeriod) != null && p.graceTimeout < options.gracePeriod) {
|
|
6650
|
+
p.graceTimeout = options.gracePeriod;
|
|
6651
|
+
}
|
|
6652
|
+
if (p.graceTimer) {
|
|
6653
|
+
clearTimeout(p.graceTimer);
|
|
6654
|
+
p.graceTimer = null;
|
|
6655
|
+
}
|
|
6651
6656
|
}
|
|
6652
6657
|
else {
|
|
6653
6658
|
p = new DexieYProvider(doc);
|
|
6659
|
+
p.graceTimeout = (_a = options === null || options === void 0 ? void 0 : options.gracePeriod) !== null && _a !== void 0 ? _a : -1;
|
|
6654
6660
|
wm.set(doc, p);
|
|
6655
6661
|
}
|
|
6656
6662
|
return p;
|
|
6657
6663
|
};
|
|
6658
|
-
DexieYProvider.release = function (doc
|
|
6659
|
-
|
|
6660
|
-
if (destroyedDocs.has(doc))
|
|
6664
|
+
DexieYProvider.release = function (doc) {
|
|
6665
|
+
if (!doc || destroyedDocs.has(doc))
|
|
6661
6666
|
return;
|
|
6662
6667
|
var p = wm.get(doc);
|
|
6663
6668
|
if (p) {
|
|
6664
6669
|
if (--p.refCount <= 0) {
|
|
6665
|
-
|
|
6666
|
-
var computedGracePeriod = Math.max((_b = options === null || options === void 0 ? void 0 : options.gracePeriod) !== null && _b !== void 0 ? _b : -1, ((_c = p.graceTimeout) !== null && _c !== void 0 ? _c : 0) - Date.now());
|
|
6667
|
-
if (computedGracePeriod < 0) {
|
|
6670
|
+
if (p.graceTimeout < 0) {
|
|
6668
6671
|
p._release();
|
|
6669
6672
|
}
|
|
6670
|
-
else if (!p.graceTimer
|
|
6671
|
-
if (p.graceTimer)
|
|
6672
|
-
clearTimeout(p.graceTimer);
|
|
6673
|
-
p.graceTimeout = Date.now() + computedGracePeriod;
|
|
6673
|
+
else if (!p.graceTimer) {
|
|
6674
6674
|
p.graceTimer = setTimeout(function () {
|
|
6675
6675
|
p.graceTimer = null;
|
|
6676
6676
|
if (p.refCount === 0) {
|
|
6677
6677
|
p._release();
|
|
6678
6678
|
}
|
|
6679
|
-
},
|
|
6679
|
+
}, p.graceTimeout
|
|
6680
6680
|
);
|
|
6681
6681
|
}
|
|
6682
6682
|
}
|
|
@@ -6687,6 +6687,8 @@
|
|
|
6687
6687
|
};
|
|
6688
6688
|
DexieYProvider.prototype._release = function () {
|
|
6689
6689
|
var _this = this;
|
|
6690
|
+
if (!this.doc)
|
|
6691
|
+
return;
|
|
6690
6692
|
Promise.resolve(DexieYProvider.on('beforeunload').fire(this)).finally(function () {
|
|
6691
6693
|
var _a;
|
|
6692
6694
|
if (_this.refCount === 0) {
|
|
@@ -6697,13 +6699,62 @@
|
|
|
6697
6699
|
DexieYProvider.for = function (doc) {
|
|
6698
6700
|
return wm.get(doc);
|
|
6699
6701
|
};
|
|
6702
|
+
Object.defineProperty(DexieYProvider.prototype, "whenLoaded", {
|
|
6703
|
+
get: function () {
|
|
6704
|
+
var _this = this;
|
|
6705
|
+
if (!this._whenLoaded) {
|
|
6706
|
+
this._whenLoaded = new Promise(function (resolve, reject) {
|
|
6707
|
+
if (_this.doc.isLoaded)
|
|
6708
|
+
resolve();
|
|
6709
|
+
else if (_this._error)
|
|
6710
|
+
reject(_this._error);
|
|
6711
|
+
else if (destroyedDocs.has(_this.doc)) {
|
|
6712
|
+
reject(new exceptions.Abort('Document was destroyed before loaded'));
|
|
6713
|
+
}
|
|
6714
|
+
else {
|
|
6715
|
+
_this.on('load', resolve);
|
|
6716
|
+
_this.on('error', reject);
|
|
6717
|
+
_this.doc.on('destroy', function () { return reject(new exceptions.Abort('Document was destroyed before loaded')); });
|
|
6718
|
+
}
|
|
6719
|
+
});
|
|
6720
|
+
}
|
|
6721
|
+
return this._whenLoaded;
|
|
6722
|
+
},
|
|
6723
|
+
enumerable: false,
|
|
6724
|
+
configurable: true
|
|
6725
|
+
});
|
|
6726
|
+
Object.defineProperty(DexieYProvider.prototype, "whenSynced", {
|
|
6727
|
+
get: function () {
|
|
6728
|
+
var _this = this;
|
|
6729
|
+
if (!this._whenSynced) {
|
|
6730
|
+
this._whenSynced = new Promise(function (resolve, reject) {
|
|
6731
|
+
if (_this.doc.isSynced)
|
|
6732
|
+
resolve();
|
|
6733
|
+
else if (_this._error)
|
|
6734
|
+
reject(_this._error);
|
|
6735
|
+
else if (destroyedDocs.has(_this.doc)) {
|
|
6736
|
+
reject(new exceptions.Abort('Document was destroyed before synced'));
|
|
6737
|
+
}
|
|
6738
|
+
else {
|
|
6739
|
+
_this.on('sync', resolve);
|
|
6740
|
+
_this.on('error', reject);
|
|
6741
|
+
_this.doc.on('destroy', function () { return reject(new exceptions.Abort('Document was destroyed before synced')); });
|
|
6742
|
+
}
|
|
6743
|
+
});
|
|
6744
|
+
}
|
|
6745
|
+
return this._whenSynced;
|
|
6746
|
+
},
|
|
6747
|
+
enumerable: false,
|
|
6748
|
+
configurable: true
|
|
6749
|
+
});
|
|
6700
6750
|
DexieYProvider.prototype.destroy = function () {
|
|
6701
|
-
var _a;
|
|
6751
|
+
var _a, _b;
|
|
6752
|
+
console.debug("YDoc ".concat((_a = this.doc.meta) === null || _a === void 0 ? void 0 : _a.parentId, " was destroyed"));
|
|
6702
6753
|
wm.delete(this.doc);
|
|
6703
6754
|
this.doc = null;
|
|
6704
6755
|
this.destroyed = true;
|
|
6705
6756
|
this.refCount = 0;
|
|
6706
|
-
(
|
|
6757
|
+
(_b = this.stopObserving) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
6707
6758
|
this.on = createEvents();
|
|
6708
6759
|
this.cleanupHandlers.forEach(function (cleanup) { return cleanup(); });
|
|
6709
6760
|
};
|