dexie 4.0.1-alpha.10 → 4.0.1-alpha.12
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/dist/dexie.d.ts +134 -84
- package/dist/dexie.js +563 -137
- 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 +563 -137
- 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 +563 -132
- package/dist/modern/dexie.mjs.map +1 -1
- package/import-wrapper-prod.d.mts +2 -0
- package/import-wrapper.d.mts +2 -0
- package/package.json +2 -2
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.0.1-alpha.
|
|
7
|
+
* Version 4.0.1-alpha.12, Tue May 30 2023
|
|
8
8
|
*
|
|
9
9
|
* https://dexie.org
|
|
10
10
|
*
|
|
@@ -65,6 +65,7 @@ export interface Transaction {
|
|
|
65
65
|
mode: IDBTransactionMode;
|
|
66
66
|
//tables: { [type: string]: Table<any, any> }; Deprecated since 2.0. Obsolete from v3.0.
|
|
67
67
|
storeNames: Array<string>;
|
|
68
|
+
explicit?: boolean;
|
|
68
69
|
parent?: Transaction;
|
|
69
70
|
on: TransactionEvents;
|
|
70
71
|
abort(): void;
|
|
@@ -357,7 +358,8 @@ export interface PromiseExtended<T = any> extends Promise<T> {
|
|
|
357
358
|
timeout(ms: number, msg?: string): PromiseExtended<T>;
|
|
358
359
|
}
|
|
359
360
|
export type KeyPaths<T> = {
|
|
360
|
-
[P in keyof T]: P extends string ? T[P] extends
|
|
361
|
+
[P in keyof T]: P extends string ? T[P] extends Array<infer K> ? K extends object // only drill into the array element if it's an object
|
|
362
|
+
? P | `${P}.${number}` | `${P}.${number}.${KeyPaths<K>}` : P | `${P}.${number}` : T[P] extends (...args: any[]) => any // Method
|
|
361
363
|
? never : T[P] extends object ? P | `${P}.${KeyPaths<T[P]>}` : P : never;
|
|
362
364
|
}[keyof T];
|
|
363
365
|
export type KeyPathValue<T, PATH> = PATH extends `${infer R}.${infer S}` ? R extends keyof T ? KeyPathValue<T[R], S> : T extends any[] ? PATH extends `${number}.${infer S}` ? KeyPathValue<T[number], S> : void : void : PATH extends `${number}` ? T extends any[] ? T[number] : void : PATH extends keyof T ? T[PATH] : void;
|
|
@@ -416,6 +418,88 @@ export interface Collection<T = any, TKey = IndexableType> {
|
|
|
416
418
|
}) => void | boolean): PromiseExtended<number>;
|
|
417
419
|
modify(changes: UpdateSpec<T>): PromiseExtended<number>;
|
|
418
420
|
}
|
|
421
|
+
export type IntervalTree = IntervalTreeNode | EmptyRange;
|
|
422
|
+
export interface IntervalTreeNode {
|
|
423
|
+
from: IndexableType; // lower bound
|
|
424
|
+
to: IndexableType; // upper bound
|
|
425
|
+
l: IntervalTreeNode | null; // left
|
|
426
|
+
r: IntervalTreeNode | null; // right
|
|
427
|
+
d: number; // depth
|
|
428
|
+
}
|
|
429
|
+
export interface EmptyRange {
|
|
430
|
+
d: 0;
|
|
431
|
+
}
|
|
432
|
+
export interface DexieOnReadyEvent {
|
|
433
|
+
subscribe(fn: (vipDb: Dexie) => any, bSticky: boolean): void;
|
|
434
|
+
unsubscribe(fn: (vipDb: Dexie) => any): void;
|
|
435
|
+
fire(vipDb: Dexie): any;
|
|
436
|
+
}
|
|
437
|
+
export interface DexieVersionChangeEvent {
|
|
438
|
+
subscribe(fn: (event: IDBVersionChangeEvent) => any): void;
|
|
439
|
+
unsubscribe(fn: (event: IDBVersionChangeEvent) => any): void;
|
|
440
|
+
fire(event: IDBVersionChangeEvent): any;
|
|
441
|
+
}
|
|
442
|
+
export interface DexiePopulateEvent {
|
|
443
|
+
subscribe(fn: (trans: Transaction) => any): void;
|
|
444
|
+
unsubscribe(fn: (trans: Transaction) => any): void;
|
|
445
|
+
fire(trans: Transaction): any;
|
|
446
|
+
}
|
|
447
|
+
export interface DexieCloseEvent {
|
|
448
|
+
subscribe(fn: (event: Event) => any): void;
|
|
449
|
+
unsubscribe(fn: (event: Event) => any): void;
|
|
450
|
+
fire(event: Event): any;
|
|
451
|
+
}
|
|
452
|
+
export interface DbEvents extends DexieEventSet {
|
|
453
|
+
(eventName: "ready", subscriber: (vipDb: Dexie) => any, bSticky?: boolean): void;
|
|
454
|
+
(eventName: "populate", subscriber: (trans: Transaction) => any): void;
|
|
455
|
+
(eventName: "blocked", subscriber: (event: IDBVersionChangeEvent) => any): void;
|
|
456
|
+
(eventName: "versionchange", subscriber: (event: IDBVersionChangeEvent) => any): void;
|
|
457
|
+
(eventName: "close", subscriber: (event: Event) => any): void;
|
|
458
|
+
ready: DexieOnReadyEvent;
|
|
459
|
+
populate: DexiePopulateEvent;
|
|
460
|
+
blocked: DexieEvent;
|
|
461
|
+
versionchange: DexieVersionChangeEvent;
|
|
462
|
+
close: DexieCloseEvent;
|
|
463
|
+
}
|
|
464
|
+
/** Set of mutated parts of the database
|
|
465
|
+
*/
|
|
466
|
+
export type ObservabilitySet = {
|
|
467
|
+
/** Database part having been mutated.
|
|
468
|
+
*
|
|
469
|
+
* This structure is produced in observability-middleware.ts
|
|
470
|
+
* and consumed in live-query.ts.
|
|
471
|
+
*
|
|
472
|
+
* Format of 'part':
|
|
473
|
+
*
|
|
474
|
+
* `idb://${dbName}/${tableName}/${indexName}`
|
|
475
|
+
*
|
|
476
|
+
* * dbName is the database name
|
|
477
|
+
* * tableName is the table name
|
|
478
|
+
* * indexName is any of:
|
|
479
|
+
* 1. An empty string - represents the primary keys of the affected objs
|
|
480
|
+
* 2. ":dels" - represents primary keys of deleted objects in the table
|
|
481
|
+
* 3. The keyPath of an index, such as "name", "age" or "address.city" -
|
|
482
|
+
* represents indexes that, if used in a query, might affect the
|
|
483
|
+
* result of that query.
|
|
484
|
+
*
|
|
485
|
+
* IntervalTree
|
|
486
|
+
* * See definition of IntervalTree type in rangeset.d.ts
|
|
487
|
+
* * See rangesOverlap() in rangeset.ts that can be used to compare two
|
|
488
|
+
* IntervalTrees and detect collissions.
|
|
489
|
+
* * See RangeSet class that can be used to create an IntervalTree and add
|
|
490
|
+
* ranges to it.
|
|
491
|
+
*/
|
|
492
|
+
[part: string]: IntervalTree;
|
|
493
|
+
};
|
|
494
|
+
export interface DexieOnStorageMutatedEvent {
|
|
495
|
+
subscribe(fn: (parts: ObservabilitySet) => any): void;
|
|
496
|
+
unsubscribe(fn: (parts: ObservabilitySet) => any): void;
|
|
497
|
+
fire(parts: ObservabilitySet): any;
|
|
498
|
+
}
|
|
499
|
+
export interface GlobalDexieEvents extends DexieEventSet {
|
|
500
|
+
(eventName: "storagemutated", subscriber: (parts: ObservabilitySet) => any): void;
|
|
501
|
+
storagemutated: DexieOnStorageMutatedEvent;
|
|
502
|
+
}
|
|
419
503
|
export const enum DBCoreRangeType {
|
|
420
504
|
Equal = 1,
|
|
421
505
|
Range = 2,
|
|
@@ -449,6 +533,7 @@ export interface DBCoreAddRequest {
|
|
|
449
533
|
trans: DBCoreTransaction;
|
|
450
534
|
values: readonly any[];
|
|
451
535
|
keys?: any[];
|
|
536
|
+
mutatedParts?: ObservabilitySet;
|
|
452
537
|
/** @deprecated Will always get results since 3.1.0-alpha.5 */
|
|
453
538
|
wantResults?: boolean;
|
|
454
539
|
}
|
|
@@ -457,6 +542,7 @@ export interface DBCorePutRequest {
|
|
|
457
542
|
trans: DBCoreTransaction;
|
|
458
543
|
values: readonly any[];
|
|
459
544
|
keys?: any[];
|
|
545
|
+
mutatedParts?: ObservabilitySet;
|
|
460
546
|
criteria?: {
|
|
461
547
|
index: string | null;
|
|
462
548
|
range: DBCoreKeyRange;
|
|
@@ -477,6 +563,7 @@ export interface DBCoreDeleteRequest {
|
|
|
477
563
|
type: "delete";
|
|
478
564
|
trans: DBCoreTransaction;
|
|
479
565
|
keys: any[];
|
|
566
|
+
mutatedParts?: ObservabilitySet;
|
|
480
567
|
criteria?: {
|
|
481
568
|
index: string | null;
|
|
482
569
|
range: DBCoreKeyRange;
|
|
@@ -486,15 +573,18 @@ export interface DBCoreDeleteRangeRequest {
|
|
|
486
573
|
type: "deleteRange";
|
|
487
574
|
trans: DBCoreTransaction;
|
|
488
575
|
range: DBCoreKeyRange;
|
|
576
|
+
mutatedParts?: ObservabilitySet;
|
|
489
577
|
}
|
|
490
578
|
export interface DBCoreGetManyRequest {
|
|
491
579
|
trans: DBCoreTransaction;
|
|
492
580
|
keys: any[];
|
|
493
581
|
cache?: "immutable" | "clone";
|
|
582
|
+
obsSet?: ObservabilitySet;
|
|
494
583
|
}
|
|
495
584
|
export interface DBCoreGetRequest {
|
|
496
585
|
trans: DBCoreTransaction;
|
|
497
586
|
key: any;
|
|
587
|
+
obsSet?: ObservabilitySet;
|
|
498
588
|
}
|
|
499
589
|
export interface DBCoreQuery {
|
|
500
590
|
index: DBCoreIndex; //keyPath: null | string | string[]; // null represents primary key. string a property, string[] several properties.
|
|
@@ -505,6 +595,7 @@ export interface DBCoreQueryRequest {
|
|
|
505
595
|
values?: boolean;
|
|
506
596
|
limit?: number;
|
|
507
597
|
query: DBCoreQuery;
|
|
598
|
+
obsSet?: ObservabilitySet;
|
|
508
599
|
}
|
|
509
600
|
export interface DBCoreQueryResponse {
|
|
510
601
|
result: any[];
|
|
@@ -515,10 +606,12 @@ export interface DBCoreOpenCursorRequest {
|
|
|
515
606
|
unique?: boolean;
|
|
516
607
|
reverse?: boolean;
|
|
517
608
|
query: DBCoreQuery;
|
|
609
|
+
obsSet?: ObservabilitySet;
|
|
518
610
|
}
|
|
519
611
|
export interface DBCoreCountRequest {
|
|
520
612
|
trans: DBCoreTransaction;
|
|
521
613
|
query: DBCoreQuery;
|
|
614
|
+
obsSet?: ObservabilitySet;
|
|
522
615
|
}
|
|
523
616
|
export interface DBCoreCursor {
|
|
524
617
|
readonly trans: DBCoreTransaction;
|
|
@@ -656,88 +749,6 @@ export interface Version {
|
|
|
656
749
|
}): Version;
|
|
657
750
|
upgrade(fn: (trans: Transaction) => PromiseLike<any> | void): Version;
|
|
658
751
|
}
|
|
659
|
-
export type IntervalTree = IntervalTreeNode | EmptyRange;
|
|
660
|
-
export interface IntervalTreeNode {
|
|
661
|
-
from: IndexableType; // lower bound
|
|
662
|
-
to: IndexableType; // upper bound
|
|
663
|
-
l: IntervalTreeNode | null; // left
|
|
664
|
-
r: IntervalTreeNode | null; // right
|
|
665
|
-
d: number; // depth
|
|
666
|
-
}
|
|
667
|
-
export interface EmptyRange {
|
|
668
|
-
d: 0;
|
|
669
|
-
}
|
|
670
|
-
export interface DexieOnReadyEvent {
|
|
671
|
-
subscribe(fn: (vipDb: Dexie) => any, bSticky: boolean): void;
|
|
672
|
-
unsubscribe(fn: (vipDb: Dexie) => any): void;
|
|
673
|
-
fire(vipDb: Dexie): any;
|
|
674
|
-
}
|
|
675
|
-
export interface DexieVersionChangeEvent {
|
|
676
|
-
subscribe(fn: (event: IDBVersionChangeEvent) => any): void;
|
|
677
|
-
unsubscribe(fn: (event: IDBVersionChangeEvent) => any): void;
|
|
678
|
-
fire(event: IDBVersionChangeEvent): any;
|
|
679
|
-
}
|
|
680
|
-
export interface DexiePopulateEvent {
|
|
681
|
-
subscribe(fn: (trans: Transaction) => any): void;
|
|
682
|
-
unsubscribe(fn: (trans: Transaction) => any): void;
|
|
683
|
-
fire(trans: Transaction): any;
|
|
684
|
-
}
|
|
685
|
-
export interface DexieCloseEvent {
|
|
686
|
-
subscribe(fn: (event: Event) => any): void;
|
|
687
|
-
unsubscribe(fn: (event: Event) => any): void;
|
|
688
|
-
fire(event: Event): any;
|
|
689
|
-
}
|
|
690
|
-
export interface DbEvents extends DexieEventSet {
|
|
691
|
-
(eventName: "ready", subscriber: (vipDb: Dexie) => any, bSticky?: boolean): void;
|
|
692
|
-
(eventName: "populate", subscriber: (trans: Transaction) => any): void;
|
|
693
|
-
(eventName: "blocked", subscriber: (event: IDBVersionChangeEvent) => any): void;
|
|
694
|
-
(eventName: "versionchange", subscriber: (event: IDBVersionChangeEvent) => any): void;
|
|
695
|
-
(eventName: "close", subscriber: (event: Event) => any): void;
|
|
696
|
-
ready: DexieOnReadyEvent;
|
|
697
|
-
populate: DexiePopulateEvent;
|
|
698
|
-
blocked: DexieEvent;
|
|
699
|
-
versionchange: DexieVersionChangeEvent;
|
|
700
|
-
close: DexieCloseEvent;
|
|
701
|
-
}
|
|
702
|
-
/** Set of mutated parts of the database
|
|
703
|
-
*/
|
|
704
|
-
export type ObservabilitySet = {
|
|
705
|
-
/** Database part having been mutated.
|
|
706
|
-
*
|
|
707
|
-
* This structure is produced in observability-middleware.ts
|
|
708
|
-
* and consumed in live-query.ts.
|
|
709
|
-
*
|
|
710
|
-
* Format of 'part':
|
|
711
|
-
*
|
|
712
|
-
* `idb://${dbName}/${tableName}/${indexName}`
|
|
713
|
-
*
|
|
714
|
-
* * dbName is the database name
|
|
715
|
-
* * tableName is the table name
|
|
716
|
-
* * indexName is any of:
|
|
717
|
-
* 1. An empty string - represents the primary keys of the affected objs
|
|
718
|
-
* 2. ":dels" - represents primary keys of deleted objects in the table
|
|
719
|
-
* 3. The keyPath of an index, such as "name", "age" or "address.city" -
|
|
720
|
-
* represents indexes that, if used in a query, might affect the
|
|
721
|
-
* result of that query.
|
|
722
|
-
*
|
|
723
|
-
* IntervalTree
|
|
724
|
-
* * See definition of IntervalTree type in rangeset.d.ts
|
|
725
|
-
* * See rangesOverlap() in rangeset.ts that can be used to compare two
|
|
726
|
-
* IntervalTrees and detect collissions.
|
|
727
|
-
* * See RangeSet class that can be used to create an IntervalTree and add
|
|
728
|
-
* ranges to it.
|
|
729
|
-
*/
|
|
730
|
-
[part: string]: IntervalTree;
|
|
731
|
-
};
|
|
732
|
-
export interface DexieOnStorageMutatedEvent {
|
|
733
|
-
subscribe(fn: (parts: ObservabilitySet) => any): void;
|
|
734
|
-
unsubscribe(fn: (parts: ObservabilitySet) => any): void;
|
|
735
|
-
fire(parts: ObservabilitySet): any;
|
|
736
|
-
}
|
|
737
|
-
export interface GlobalDexieEvents extends DexieEventSet {
|
|
738
|
-
(eventName: "storagemutated", subscriber: (parts: ObservabilitySet) => any): void;
|
|
739
|
-
storagemutated: DexieOnStorageMutatedEvent;
|
|
740
|
-
}
|
|
741
752
|
export type TransactionMode = "readonly" | "readwrite" | "r" | "r!" | "r?" | "rw" | "rw!" | "rw?";
|
|
742
753
|
export type DbSchema = {
|
|
743
754
|
[tableName: string]: TableSchema;
|
|
@@ -976,6 +987,8 @@ export interface Unsubscribable {
|
|
|
976
987
|
export interface Observable<T = any> {
|
|
977
988
|
subscribe(observerOrNext?: Observer<T> | ((value: T) => void)): Subscription;
|
|
978
989
|
subscribe(next?: ((value: T) => void) | null, error?: ((error: any) => void) | null, complete?: (() => void) | null): Subscription;
|
|
990
|
+
getValue?(): T;
|
|
991
|
+
hasValue?(): boolean;
|
|
979
992
|
[Symbol.observable]: () => Subscribable<T>;
|
|
980
993
|
}
|
|
981
994
|
export interface Subscription {
|
|
@@ -988,6 +1001,41 @@ export interface Observer<T = any> {
|
|
|
988
1001
|
error?: (error: any) => void;
|
|
989
1002
|
complete?: () => void;
|
|
990
1003
|
}
|
|
1004
|
+
export type GlobalQueryCache = {
|
|
1005
|
+
// TODO: Change to parts: {[part: string]: TblQueryCache}
|
|
1006
|
+
// och unsignaledParts: ObservabilitySet;
|
|
1007
|
+
[part: string]: TblQueryCache; // part is `idb://${dbName}/${tableName}`
|
|
1008
|
+
};
|
|
1009
|
+
export interface TblQueryCache {
|
|
1010
|
+
queries: {
|
|
1011
|
+
query: {
|
|
1012
|
+
[indexName: string]: CacheEntry[];
|
|
1013
|
+
};
|
|
1014
|
+
count: {
|
|
1015
|
+
[indexName: string]: CacheEntry[];
|
|
1016
|
+
};
|
|
1017
|
+
};
|
|
1018
|
+
objs: Map<string | number, object>;
|
|
1019
|
+
optimisticOps: DBCoreMutateRequest[];
|
|
1020
|
+
unsignaledParts: ObservabilitySet;
|
|
1021
|
+
signalTimer?: number;
|
|
1022
|
+
}
|
|
1023
|
+
export interface CacheEntryCommon {
|
|
1024
|
+
subscribers: Set<() => void>;
|
|
1025
|
+
obsSet: ObservabilitySet;
|
|
1026
|
+
//txObsSet: ObservabilitySet;
|
|
1027
|
+
promise: Promise<any>;
|
|
1028
|
+
dirty: boolean;
|
|
1029
|
+
}
|
|
1030
|
+
export type CacheEntry = CacheEntryCommon & ({
|
|
1031
|
+
type: "query";
|
|
1032
|
+
req: DBCoreQueryRequest;
|
|
1033
|
+
res?: readonly any[];
|
|
1034
|
+
} | {
|
|
1035
|
+
type: "count";
|
|
1036
|
+
req: DBCoreCountRequest;
|
|
1037
|
+
res?: number;
|
|
1038
|
+
});
|
|
991
1039
|
export type ChromeTransactionDurability = "default" | "strict" | "relaxed";
|
|
992
1040
|
export interface DexieOptions {
|
|
993
1041
|
addons?: Array<(db: Dexie) => void>;
|
|
@@ -1003,6 +1051,7 @@ export interface DexieOptions {
|
|
|
1003
1051
|
allowEmptyDB?: boolean;
|
|
1004
1052
|
modifyChunkSize?: number;
|
|
1005
1053
|
chromeTransactionDurability?: ChromeTransactionDurability;
|
|
1054
|
+
cache?: "immutable" | "cloned" | "disabled";
|
|
1006
1055
|
}
|
|
1007
1056
|
export interface DexieConstructor extends DexieExceptionClasses {
|
|
1008
1057
|
new (databaseName: string, options?: DexieOptions): Dexie;
|
|
@@ -1031,6 +1080,7 @@ export interface DexieConstructor extends DexieExceptionClasses {
|
|
|
1031
1080
|
delete(dbName: string): Promise<void>;
|
|
1032
1081
|
dependencies: DexieDOMDependencies;
|
|
1033
1082
|
default: Dexie; // Work-around for different build tools handling default imports differently.
|
|
1083
|
+
cache: GlobalQueryCache;
|
|
1034
1084
|
Promise: PromiseExtendedConstructor;
|
|
1035
1085
|
//TableSchema: {}; // Deprecate!
|
|
1036
1086
|
//IndexSpec: {new():IndexSpec}; //? Deprecate
|