dexie 4.0.8 → 4.0.9-alpha.1
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/README.md +46 -0
- package/dist/dexie.d.ts +175 -9
- package/dist/dexie.js +457 -49
- 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 +456 -49
- 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 +421 -54
- package/dist/modern/dexie.mjs.map +1 -1
- package/import-wrapper-prod.mjs +4 -2
- package/import-wrapper.mjs +5 -2
- package/package.json +6 -4
package/dist/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
## Can't find dexie.js?
|
|
2
|
+
Dexie's dist files are no longer checked in to github except temporarily when tagging
|
|
3
|
+
a release version (just so that bower will continue to work). The reason for this is because
|
|
4
|
+
checking in dist files bloats the commit history and makes it error prone to contribute to the
|
|
5
|
+
repo. To support bower though, we have to continue checking in dist files when releasing,
|
|
6
|
+
but that is now handled by the release.sh script, who also removes them directly afterwards.
|
|
7
|
+
|
|
8
|
+
If you still just want to download dexie.js to include in a test HTML page, go
|
|
9
|
+
to the following download site:
|
|
10
|
+
|
|
11
|
+
### Download
|
|
12
|
+
[dexie.min.js](https://unpkg.com/dexie/dist/dexie.min.js)
|
|
13
|
+
|
|
14
|
+
[dexie.min.js.map](https://unpkg.com/dexie/dist/dexie.min.js.map)
|
|
15
|
+
|
|
16
|
+
### Typings
|
|
17
|
+
[dexie.d.ts](https://unpkg.com/dexie/dist/dexie.d.ts)
|
|
18
|
+
|
|
19
|
+
### Optional Stuff
|
|
20
|
+
[dexie.js (non-minified version)](https://unpkg.com/dexie/dist/dexie.js)
|
|
21
|
+
|
|
22
|
+
[dexie.js.map](https://unpkg.com/dexie/dist/dexie.js.map)
|
|
23
|
+
|
|
24
|
+
[dexie.min.js.gz (Minified and gzipped)](https://unpkg.com/dexie/dist/dexie.min.js.gz)
|
|
25
|
+
|
|
26
|
+
## Install from NPM
|
|
27
|
+
```
|
|
28
|
+
npm install dexie
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## How to build
|
|
32
|
+
1. cd to dexie package
|
|
33
|
+
2. npm install
|
|
34
|
+
3. npm run build
|
|
35
|
+
|
|
36
|
+
## Contributing to Dexie.js?
|
|
37
|
+
|
|
38
|
+
Watch:
|
|
39
|
+
```
|
|
40
|
+
npm run watch
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Test:
|
|
44
|
+
```
|
|
45
|
+
npm test
|
|
46
|
+
```
|
package/dist/dexie.d.ts
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
*
|
|
5
5
|
* By David Fahlander, david.fahlander@gmail.com
|
|
6
6
|
*
|
|
7
|
-
* Version 4.0.
|
|
7
|
+
* Version 4.0.9-alpha.1, Fri Aug 23 2024
|
|
8
8
|
*
|
|
9
9
|
* https://dexie.org
|
|
10
10
|
*
|
|
11
11
|
* Apache License Version 2.0, January 2004, http://www.apache.org/licenses/
|
|
12
12
|
*/
|
|
13
|
-
// Generated by dts-bundle-generator
|
|
13
|
+
// Generated by dts-bundle-generator v9.3.1
|
|
14
14
|
|
|
15
15
|
export interface IndexSpec {
|
|
16
16
|
name: string;
|
|
@@ -20,11 +20,16 @@ export interface IndexSpec {
|
|
|
20
20
|
auto: boolean | undefined;
|
|
21
21
|
compound: boolean | undefined;
|
|
22
22
|
src: string;
|
|
23
|
+
type?: string | undefined;
|
|
23
24
|
}
|
|
24
25
|
export interface TableSchema {
|
|
25
26
|
name: string;
|
|
26
27
|
primKey: IndexSpec;
|
|
27
28
|
indexes: IndexSpec[];
|
|
29
|
+
yProps?: {
|
|
30
|
+
prop: string;
|
|
31
|
+
updatesTable: string;
|
|
32
|
+
}[];
|
|
28
33
|
mappedClass: Function;
|
|
29
34
|
idxByName: {
|
|
30
35
|
[name: string]: IndexSpec;
|
|
@@ -359,10 +364,122 @@ export interface PromiseExtended<T = any> extends Promise<T> {
|
|
|
359
364
|
finally<U>(onFinally?: () => U | PromiseLike<U>): PromiseExtended<T>;
|
|
360
365
|
timeout(ms: number, msg?: string): PromiseExtended<T>;
|
|
361
366
|
}
|
|
367
|
+
export interface DucktypedY {
|
|
368
|
+
Doc: new (options?: {
|
|
369
|
+
guid?: string;
|
|
370
|
+
collectionid?: string;
|
|
371
|
+
gc?: boolean;
|
|
372
|
+
gcFilter?: any;
|
|
373
|
+
meta?: any;
|
|
374
|
+
autoLoad?: boolean;
|
|
375
|
+
shouldLoad?: boolean;
|
|
376
|
+
}) => DucktypedYDoc;
|
|
377
|
+
applyUpdate: Function;
|
|
378
|
+
applyUpdateV2: Function;
|
|
379
|
+
encodeStateAsUpdate: Function;
|
|
380
|
+
encodeStateAsUpdateV2: Function;
|
|
381
|
+
encodeStateVector: Function;
|
|
382
|
+
encodeStateVectorFromUpdate: Function;
|
|
383
|
+
encodeStateVectorFromUpdateV2: Function;
|
|
384
|
+
mergeUpdates: Function;
|
|
385
|
+
mergeUpdatesV2: Function;
|
|
386
|
+
diffUpdate: Function;
|
|
387
|
+
diffUpdateV2: Function;
|
|
388
|
+
transact: Function;
|
|
389
|
+
}
|
|
390
|
+
export interface DucktypedYObservable {
|
|
391
|
+
on(name: string, f: (...args: any[]) => any): void;
|
|
392
|
+
off(name: string, f: (...args: any[]) => any): void;
|
|
393
|
+
once(name: string, f: (...args: any[]) => any): void;
|
|
394
|
+
emit(name: string, args: any[]): void;
|
|
395
|
+
destroy(): void;
|
|
396
|
+
}
|
|
397
|
+
/** Dock-typed Y.Doc */
|
|
398
|
+
export interface DucktypedYDoc extends DucktypedYObservable {
|
|
399
|
+
guid?: any;
|
|
400
|
+
collectionid?: any;
|
|
401
|
+
collection?: any;
|
|
402
|
+
whenLoaded: PromiseLike<any>;
|
|
403
|
+
whenSynced: PromiseLike<any>;
|
|
404
|
+
isLoaded: any;
|
|
405
|
+
isSynced: any;
|
|
406
|
+
transact: any;
|
|
407
|
+
toJSON: () => any;
|
|
408
|
+
destroy: () => void;
|
|
409
|
+
meta?: any;
|
|
410
|
+
share: Map<any, any>;
|
|
411
|
+
}
|
|
412
|
+
export interface DexieYDocMeta {
|
|
413
|
+
db: Dexie;
|
|
414
|
+
parentTable: string;
|
|
415
|
+
parentId: any;
|
|
416
|
+
parentProp: string;
|
|
417
|
+
updatesTable: string;
|
|
418
|
+
}
|
|
419
|
+
/** Stored in the updates table with auto-incremented number as primary key
|
|
420
|
+
*
|
|
421
|
+
*/
|
|
422
|
+
export interface YUpdateRow {
|
|
423
|
+
/** The primary key in the update-table
|
|
424
|
+
*
|
|
425
|
+
*/
|
|
426
|
+
i: number;
|
|
427
|
+
/** The primary key of the row in related table holding the document property.
|
|
428
|
+
*
|
|
429
|
+
*/
|
|
430
|
+
k: IndexableType;
|
|
431
|
+
/** The Y update
|
|
432
|
+
*
|
|
433
|
+
*/
|
|
434
|
+
u: Uint8Array;
|
|
435
|
+
/** Optional flag
|
|
436
|
+
*
|
|
437
|
+
* 1 = LOCAL_CHANGE_MAYBE_UNSYNCED
|
|
438
|
+
*
|
|
439
|
+
*/
|
|
440
|
+
f?: number;
|
|
441
|
+
}
|
|
442
|
+
/** Stored in update tables along with YUpdateRows but with a string representing the syncing enging, as primary key
|
|
443
|
+
* A syncing engine can create an YSyncer row with an unsentFrom value set to the a number representing primary key (i)
|
|
444
|
+
* of updates that has not been sent to server or peer yet. Dexie will spare all updates that occur after the least
|
|
445
|
+
* unsentFrom value in the updates table from being compressed and garbage collected into the main update.
|
|
446
|
+
*/
|
|
447
|
+
export interface YSyncer {
|
|
448
|
+
i: string;
|
|
449
|
+
unsentFrom: number;
|
|
450
|
+
}
|
|
451
|
+
/** A stamp of the last compressed and garbage collected update in the update table.
|
|
452
|
+
* The garbage collection process will find out which documents have got new updates since the last compressed update
|
|
453
|
+
* and compress them into their corresponding main update.
|
|
454
|
+
*
|
|
455
|
+
* The id of this row is always 0 - which is a reserved id for this purpose.
|
|
456
|
+
*/
|
|
457
|
+
export interface YLastCompressed {
|
|
458
|
+
i: 0;
|
|
459
|
+
lastCompressed: number;
|
|
460
|
+
lastRun?: Date;
|
|
461
|
+
}
|
|
462
|
+
export interface DexieYProvider<YDoc = any> {
|
|
463
|
+
readonly doc: YDoc;
|
|
464
|
+
awareness?: any;
|
|
465
|
+
whenLoaded: Promise<any>;
|
|
466
|
+
whenSynced: Promise<any>;
|
|
467
|
+
on: DexieEventSet & ((name: string, f: (...args: any[]) => any) => void);
|
|
468
|
+
off(name: string, f: (...args: any[]) => any): void;
|
|
469
|
+
destroy(): void;
|
|
470
|
+
readonly destroyed: boolean;
|
|
471
|
+
}
|
|
472
|
+
export interface YDocCache {
|
|
473
|
+
readonly size: number;
|
|
474
|
+
find: (table: string, primaryKey: any, ydocProp: string) => DucktypedYDoc | undefined;
|
|
475
|
+
add: (doc: DucktypedYDoc) => void;
|
|
476
|
+
delete: (doc: DucktypedYDoc) => void;
|
|
477
|
+
}
|
|
362
478
|
export type KeyPaths<T> = {
|
|
363
479
|
[P in keyof T]: P extends string ? T[P] extends Array<infer K> ? K extends any[] // Array of arrays (issue #2026)
|
|
364
480
|
? P | `${P}.${number}` | `${P}.${number}.${number}` : K extends object // only drill into the array element if it's an object
|
|
365
481
|
? P | `${P}.${number}` | `${P}.${number}.${KeyPaths<K>}` : P | `${P}.${number}` : T[P] extends (...args: any[]) => any // Method
|
|
482
|
+
? never : T[P] extends DucktypedYDoc // Not valid in update spec or where clause (+ avoid circular reference)
|
|
366
483
|
? never : T[P] extends object ? P | `${P}.${KeyPaths<T[P]>}` : P : never;
|
|
367
484
|
}[keyof T];
|
|
368
485
|
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] : any;
|
|
@@ -452,6 +569,22 @@ export interface IntervalTreeNode {
|
|
|
452
569
|
export interface EmptyRange {
|
|
453
570
|
d: 0;
|
|
454
571
|
}
|
|
572
|
+
export interface RangeSetPrototype {
|
|
573
|
+
add(rangeSet: IntervalTree | {
|
|
574
|
+
from: IndexableType;
|
|
575
|
+
to: IndexableType;
|
|
576
|
+
}): RangeSet;
|
|
577
|
+
addKey(key: IndexableType): RangeSet;
|
|
578
|
+
addKeys(keys: IndexableType[]): RangeSet;
|
|
579
|
+
hasKey(key: IndexableType): boolean;
|
|
580
|
+
[Symbol.iterator](): Iterator<IntervalTreeNode, undefined, IndexableType | undefined>;
|
|
581
|
+
}
|
|
582
|
+
export type RangeSet = RangeSetPrototype & IntervalTree;
|
|
583
|
+
export interface RangeSetConstructor {
|
|
584
|
+
(tree: IntervalTree): RangeSet;
|
|
585
|
+
new (): RangeSet;
|
|
586
|
+
new (from: IndexableType, to?: IndexableType): RangeSet;
|
|
587
|
+
}
|
|
455
588
|
export interface DexieOnReadyEvent {
|
|
456
589
|
subscribe(fn: (vipDb: Dexie) => any, bSticky: boolean): void;
|
|
457
590
|
unsubscribe(fn: (vipDb: Dexie) => any): void;
|
|
@@ -472,17 +605,26 @@ export interface DexieCloseEvent {
|
|
|
472
605
|
unsubscribe(fn: (event: Event) => any): void;
|
|
473
606
|
fire(event: Event): any;
|
|
474
607
|
}
|
|
475
|
-
export interface
|
|
476
|
-
(
|
|
608
|
+
export interface DexieYEvent {
|
|
609
|
+
subscribe(fn: (provider: DexieYProvider, Y: any) => void): void;
|
|
610
|
+
unsubscribe(fn: (provider: DexieYProvider, Y: any) => void): void;
|
|
611
|
+
fire(provider: DexieYProvider, Y: any): void;
|
|
612
|
+
}
|
|
613
|
+
export interface DbEventFns {
|
|
477
614
|
(eventName: "populate", subscriber: (trans: Transaction) => any): void;
|
|
478
615
|
(eventName: "blocked", subscriber: (event: IDBVersionChangeEvent) => any): void;
|
|
479
616
|
(eventName: "versionchange", subscriber: (event: IDBVersionChangeEvent) => any): void;
|
|
480
617
|
(eventName: "close", subscriber: (event: Event) => any): void;
|
|
618
|
+
(eventName: "y", subscriber: (provider: DexieYProvider, Y: any) => void): void;
|
|
619
|
+
}
|
|
620
|
+
export interface DbEvents extends DbEventFns, DexieEventSet {
|
|
621
|
+
(eventName: "ready", subscriber: (vipDb: Dexie) => any, bSticky?: boolean): void;
|
|
481
622
|
ready: DexieOnReadyEvent;
|
|
482
623
|
populate: DexiePopulateEvent;
|
|
483
624
|
blocked: DexieEvent;
|
|
484
625
|
versionchange: DexieVersionChangeEvent;
|
|
485
626
|
close: DexieCloseEvent;
|
|
627
|
+
y: DexieYEvent;
|
|
486
628
|
}
|
|
487
629
|
/** Set of mutated parts of the database
|
|
488
630
|
*/
|
|
@@ -813,12 +955,14 @@ export interface Dexie {
|
|
|
813
955
|
readonly _allTables: {
|
|
814
956
|
[name: string]: Table<any, IndexableType>;
|
|
815
957
|
};
|
|
958
|
+
readonly _options: DexieOptions;
|
|
816
959
|
readonly core: DBCore;
|
|
817
960
|
_createTransaction: (this: Dexie, mode: IDBTransactionMode, storeNames: ArrayLike<string>, dbschema: DbSchema, parentTransaction?: Transaction | null) => Transaction;
|
|
818
961
|
readonly _novip: Dexie;
|
|
819
962
|
_dbSchema: DbSchema;
|
|
820
963
|
version(versionNumber: number): Version;
|
|
821
964
|
on: DbEvents;
|
|
965
|
+
once: DbEventFns;
|
|
822
966
|
open(): PromiseExtended<Dexie>;
|
|
823
967
|
table<T = any, TKey = IndexableType, TInsertType = T>(tableName: string): Table<T, TKey, TInsertType>;
|
|
824
968
|
transaction<U>(mode: TransactionMode, tables: readonly (string | Table)[], scope: (trans: TXWithTables<this>) => PromiseLike<U> | U): PromiseExtended<U>;
|
|
@@ -847,6 +991,7 @@ export interface Dexie {
|
|
|
847
991
|
stack: keyof DexieStacks;
|
|
848
992
|
name: string;
|
|
849
993
|
}): this;
|
|
994
|
+
gc(): Promise<void>;
|
|
850
995
|
// Make it possible to touch physical class constructors where they reside - as properties on db instance.
|
|
851
996
|
// For example, checking if (x instanceof db.Table). Can't do (x instanceof Dexie.Table because it's just a virtual interface)
|
|
852
997
|
Table: {
|
|
@@ -1005,6 +1150,7 @@ export interface DexieDOMDependencies {
|
|
|
1005
1150
|
indexedDB: IDBFactory;
|
|
1006
1151
|
IDBKeyRange: typeof IDBKeyRange;
|
|
1007
1152
|
}
|
|
1153
|
+
// There typings are extracted from https://github.com/tc39/proposal-observable
|
|
1008
1154
|
declare global {
|
|
1009
1155
|
interface SymbolConstructor {
|
|
1010
1156
|
readonly observable: symbol;
|
|
@@ -1083,6 +1229,7 @@ export interface DexieOptions {
|
|
|
1083
1229
|
modifyChunkSize?: number;
|
|
1084
1230
|
chromeTransactionDurability?: ChromeTransactionDurability;
|
|
1085
1231
|
cache?: "immutable" | "cloned" | "disabled";
|
|
1232
|
+
Y?: DucktypedY; // Caller supplies Y from the following: import * as Y from 'yjs';
|
|
1086
1233
|
}
|
|
1087
1234
|
export interface DexieConstructor extends DexieExceptionClasses {
|
|
1088
1235
|
new (databaseName: string, options?: DexieOptions): Dexie;
|
|
@@ -1129,16 +1276,24 @@ export class Entity<TDexieSubClass extends Dexie = Dexie> {
|
|
|
1129
1276
|
export type IsStrictlyAny<T> = (T extends never ? true : false) extends false ? false : true;
|
|
1130
1277
|
/** Extract the union of literal method names in T
|
|
1131
1278
|
*/
|
|
1132
|
-
export type
|
|
1279
|
+
export type NonInsertProps<T> = {
|
|
1133
1280
|
[P in keyof T]: IsStrictlyAny<T[P]> extends true ? never // Plain property of type any (not method)
|
|
1134
1281
|
: T[P] extends (...args: any[]) => any ? P // a function (method)
|
|
1282
|
+
: T[P] extends {
|
|
1283
|
+
on: any;
|
|
1284
|
+
subdocs: any;
|
|
1285
|
+
gc: any;
|
|
1286
|
+
isSynced: any;
|
|
1287
|
+
isLoaded: any;
|
|
1288
|
+
shouldLoad: any;
|
|
1289
|
+
} ? P // an YDoc property - should be generated by dexie and not by user
|
|
1135
1290
|
: never;
|
|
1136
1291
|
}[keyof T];
|
|
1137
1292
|
/** Default insert type of T is a subset of T where:
|
|
1138
1293
|
* * given optional props (such as an auto-generated primary key) are made optional
|
|
1139
1294
|
* * methods are omitted
|
|
1140
1295
|
*/
|
|
1141
|
-
export type InsertType<T, OptionalProps extends keyof T> = Omit<T, OptionalProps |
|
|
1296
|
+
export type InsertType<T, OptionalProps extends keyof T> = Omit<T, OptionalProps | NonInsertProps<T>> & {
|
|
1142
1297
|
[P in OptionalProps]?: T[P];
|
|
1143
1298
|
};
|
|
1144
1299
|
/** IDType extract the actual type of the primary key:
|
|
@@ -1148,10 +1303,13 @@ export type InsertType<T, OptionalProps extends keyof T> = Omit<T, OptionalProps
|
|
|
1148
1303
|
export type IDType<T, TKeyPropNameOrKeyType> = IsStrictlyAny<T> extends true ? TKeyPropNameOrKeyType : TKeyPropNameOrKeyType extends string ? TKeyPropNameOrKeyType extends keyof T ? T[TKeyPropNameOrKeyType] : TKeyPropNameOrKeyType : TKeyPropNameOrKeyType;
|
|
1149
1304
|
export type EntityTable<T, TKeyPropName extends keyof T = never, TInsertType = InsertType<T, TKeyPropName>> = Table<T, IDType<T, TKeyPropName>, TInsertType>;
|
|
1150
1305
|
export declare var Dexie: DexieConstructor;
|
|
1306
|
+
// Alias of Table and Collection in order to be able to refer them from module below...
|
|
1151
1307
|
export interface _Table<T, TKey, TInsertType> extends Table<T, TKey, TInsertType> {
|
|
1152
1308
|
}
|
|
1153
1309
|
export interface _Collection<T, TKey> extends Collection<T, TKey> {
|
|
1154
1310
|
}
|
|
1311
|
+
// Besides being the only exported value, let Dexie also be
|
|
1312
|
+
// a namespace for types...
|
|
1155
1313
|
export declare module Dexie {
|
|
1156
1314
|
// The "Dexie.Promise" type.
|
|
1157
1315
|
type Promise<T = any> = PromiseExtended<T>; // Because many samples have been Dexie.Promise.
|
|
@@ -1165,12 +1323,20 @@ export declare module Dexie {
|
|
|
1165
1323
|
export function liveQuery<T>(querier: () => T | Promise<T>): Observable<T>;
|
|
1166
1324
|
export function mergeRanges(target: IntervalTree, newSet: IntervalTree): void;
|
|
1167
1325
|
export function rangesOverlap(rangeSet1: IntervalTree, rangeSet2: IntervalTree): boolean;
|
|
1326
|
+
declare var RangeSet$1: RangeSetConstructor;
|
|
1168
1327
|
export function cmp(a: any, b: any): number;
|
|
1169
1328
|
export function replacePrefix(a: string, b: string): PropModification;
|
|
1170
1329
|
export function add(num: number | bigint | any[]): PropModification;
|
|
1171
1330
|
export function remove(num: number | bigint | any[]): PropModification;
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1331
|
+
export declare var DexieYProvider: {
|
|
1332
|
+
(doc: DucktypedYDoc): DexieYProvider;
|
|
1333
|
+
new (doc: DucktypedYDoc): DexieYProvider;
|
|
1334
|
+
getDocCache: (db: Dexie) => YDocCache;
|
|
1335
|
+
};
|
|
1336
|
+
|
|
1337
|
+
export {
|
|
1338
|
+
Dexie as default,
|
|
1339
|
+
RangeSet$1 as RangeSet,
|
|
1340
|
+
};
|
|
1175
1341
|
|
|
1176
1342
|
export {};
|