dexie 4.0.9-alpha.1 → 4.1.0-alpha.3
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 +101 -55
- package/dist/dexie.js +421 -158
- 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 +421 -158
- 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 +104 -47
- package/dist/modern/dexie.mjs.map +1 -1
- package/package.json +1 -1
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
|
|
7
|
+
* Version 4.1.0-alpha.3, Fri Oct 11 2024
|
|
8
8
|
*
|
|
9
9
|
* https://dexie.org
|
|
10
10
|
*
|
|
@@ -364,7 +364,36 @@ export interface PromiseExtended<T = any> extends Promise<T> {
|
|
|
364
364
|
finally<U>(onFinally?: () => U | PromiseLike<U>): PromiseExtended<T>;
|
|
365
365
|
timeout(ms: number, msg?: string): PromiseExtended<T>;
|
|
366
366
|
}
|
|
367
|
-
|
|
367
|
+
// There typings are extracted from https://github.com/tc39/proposal-observable
|
|
368
|
+
declare global {
|
|
369
|
+
interface SymbolConstructor {
|
|
370
|
+
readonly observable: symbol;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
export interface Subscribable<T> {
|
|
374
|
+
subscribe(observer: Partial<Observer<T>>): Unsubscribable;
|
|
375
|
+
}
|
|
376
|
+
export interface Unsubscribable {
|
|
377
|
+
unsubscribe(): void;
|
|
378
|
+
}
|
|
379
|
+
export interface Observable<T = any> {
|
|
380
|
+
subscribe(observerOrNext?: Observer<T> | ((value: T) => void)): Subscription;
|
|
381
|
+
subscribe(next?: ((value: T) => void) | null, error?: ((error: any) => void) | null, complete?: (() => void) | null): Subscription;
|
|
382
|
+
getValue?(): T;
|
|
383
|
+
hasValue?(): boolean;
|
|
384
|
+
[Symbol.observable]: () => Subscribable<T>;
|
|
385
|
+
}
|
|
386
|
+
export interface Subscription {
|
|
387
|
+
unsubscribe(): void;
|
|
388
|
+
readonly closed: boolean;
|
|
389
|
+
}
|
|
390
|
+
export interface Observer<T = any> {
|
|
391
|
+
start?: (subscription: Subscription) => void;
|
|
392
|
+
next?: (value: T) => void;
|
|
393
|
+
error?: (error: any) => void;
|
|
394
|
+
complete?: () => void;
|
|
395
|
+
}
|
|
396
|
+
export interface YjsLib {
|
|
368
397
|
Doc: new (options?: {
|
|
369
398
|
guid?: string;
|
|
370
399
|
collectionid?: string;
|
|
@@ -373,7 +402,7 @@ export interface DucktypedY {
|
|
|
373
402
|
meta?: any;
|
|
374
403
|
autoLoad?: boolean;
|
|
375
404
|
shouldLoad?: boolean;
|
|
376
|
-
}) =>
|
|
405
|
+
}) => YjsDoc;
|
|
377
406
|
applyUpdate: Function;
|
|
378
407
|
applyUpdateV2: Function;
|
|
379
408
|
encodeStateAsUpdate: Function;
|
|
@@ -387,15 +416,15 @@ export interface DucktypedY {
|
|
|
387
416
|
diffUpdateV2: Function;
|
|
388
417
|
transact: Function;
|
|
389
418
|
}
|
|
390
|
-
export interface
|
|
419
|
+
export interface YjsObservable {
|
|
391
420
|
on(name: string, f: (...args: any[]) => any): void;
|
|
392
421
|
off(name: string, f: (...args: any[]) => any): void;
|
|
393
422
|
once(name: string, f: (...args: any[]) => any): void;
|
|
394
423
|
emit(name: string, args: any[]): void;
|
|
395
424
|
destroy(): void;
|
|
396
425
|
}
|
|
397
|
-
/**
|
|
398
|
-
export interface
|
|
426
|
+
/** Duck-typed Y.Doc */
|
|
427
|
+
export interface YjsDoc extends YjsObservable {
|
|
399
428
|
guid?: any;
|
|
400
429
|
collectionid?: any;
|
|
401
430
|
collection?: any;
|
|
@@ -409,6 +438,18 @@ export interface DucktypedYDoc extends DucktypedYObservable {
|
|
|
409
438
|
meta?: any;
|
|
410
439
|
share: Map<any, any>;
|
|
411
440
|
}
|
|
441
|
+
/** Docktyped Awareness */
|
|
442
|
+
export interface YjsAwareness extends YjsObservable {
|
|
443
|
+
doc: YjsDoc;
|
|
444
|
+
destroy: () => void;
|
|
445
|
+
clientID: any;
|
|
446
|
+
states: any;
|
|
447
|
+
meta: any;
|
|
448
|
+
getLocalState: any;
|
|
449
|
+
setLocalState: any;
|
|
450
|
+
setLocalStateField: any;
|
|
451
|
+
getStates: any;
|
|
452
|
+
}
|
|
412
453
|
export interface DexieYDocMeta {
|
|
413
454
|
db: Dexie;
|
|
414
455
|
parentTable: string;
|
|
@@ -440,13 +481,14 @@ export interface YUpdateRow {
|
|
|
440
481
|
f?: number;
|
|
441
482
|
}
|
|
442
483
|
/** 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
|
|
444
|
-
* of updates that has not been sent to server or peer yet. Dexie will
|
|
445
|
-
*
|
|
484
|
+
* A syncing engine can create an YSyncState row with an unsentFrom or receivedUntil value set to the a number representing primary key (i)
|
|
485
|
+
* of updates that has not been sent to server or peer yet. Dexie will compute the least value of unsentFrom and receivedUntil + 1 and
|
|
486
|
+
* spare all updates with an 'i' of that value or greater in the updates table from being compressed and garbage collected into the main update.
|
|
446
487
|
*/
|
|
447
|
-
export interface
|
|
488
|
+
export interface YSyncState {
|
|
448
489
|
i: string;
|
|
449
|
-
unsentFrom
|
|
490
|
+
unsentFrom?: number;
|
|
491
|
+
receivedUntil?: number;
|
|
450
492
|
}
|
|
451
493
|
/** A stamp of the last compressed and garbage collected update in the update table.
|
|
452
494
|
* The garbage collection process will find out which documents have got new updates since the last compressed update
|
|
@@ -459,27 +501,40 @@ export interface YLastCompressed {
|
|
|
459
501
|
lastCompressed: number;
|
|
460
502
|
lastRun?: Date;
|
|
461
503
|
}
|
|
462
|
-
export interface
|
|
504
|
+
export interface ProviderReleaseOptions {
|
|
505
|
+
// Optional grace period to optimize for unload/reload scenarios when releasing a document
|
|
506
|
+
// and refcount reached zero - to avoid destroying the document immediately in case
|
|
507
|
+
// it's going to be reloaded soon.
|
|
508
|
+
// If not set, the document will be destroyed immediately when refcount reaches zero.
|
|
509
|
+
gracePeriod?: number;
|
|
510
|
+
}
|
|
511
|
+
declare class DexieYProvider<YDoc = any> {
|
|
463
512
|
readonly doc: YDoc;
|
|
464
|
-
awareness?:
|
|
465
|
-
whenLoaded: Promise<
|
|
466
|
-
whenSynced: Promise<
|
|
513
|
+
awareness?: YjsAwareness;
|
|
514
|
+
whenLoaded: Promise<void>;
|
|
515
|
+
whenSynced: Promise<void>;
|
|
467
516
|
on: DexieEventSet & ((name: string, f: (...args: any[]) => any) => void);
|
|
468
|
-
off(name: string, f: (...args: any[]) => any)
|
|
517
|
+
off: (name: string, f: (...args: any[]) => any) => void;
|
|
518
|
+
addCleanupHandler(cleanupHandler: Unsubscribable | (() => void)): void;
|
|
469
519
|
destroy(): void;
|
|
470
520
|
readonly destroyed: boolean;
|
|
521
|
+
static load<YDoc extends YjsDoc>(doc: YDoc): DexieYProvider<YDoc>;
|
|
522
|
+
static release<YDoc extends YjsDoc>(doc: YDoc, options?: ProviderReleaseOptions): void;
|
|
523
|
+
static for<YDoc extends YjsDoc>(doc: YDoc): DexieYProvider<YDoc> | undefined;
|
|
524
|
+
static getDocCache: (db: Dexie) => YDocCache;
|
|
525
|
+
static currentUpdateRow: YUpdateRow | null;
|
|
471
526
|
}
|
|
472
527
|
export interface YDocCache {
|
|
473
528
|
readonly size: number;
|
|
474
|
-
find: (table: string, primaryKey: any, ydocProp: string) =>
|
|
475
|
-
add: (doc:
|
|
476
|
-
delete: (doc:
|
|
529
|
+
find: (table: string, primaryKey: any, ydocProp: string) => YjsDoc | undefined;
|
|
530
|
+
add: (doc: YjsDoc) => void;
|
|
531
|
+
delete: (doc: YjsDoc) => void;
|
|
477
532
|
}
|
|
478
533
|
export type KeyPaths<T> = {
|
|
479
534
|
[P in keyof T]: P extends string ? T[P] extends Array<infer K> ? K extends any[] // Array of arrays (issue #2026)
|
|
480
535
|
? P | `${P}.${number}` | `${P}.${number}.${number}` : K extends object // only drill into the array element if it's an object
|
|
481
536
|
? P | `${P}.${number}` | `${P}.${number}.${KeyPaths<K>}` : P | `${P}.${number}` : T[P] extends (...args: any[]) => any // Method
|
|
482
|
-
? never : T[P] extends
|
|
537
|
+
? never : T[P] extends YjsDoc // Not valid in update spec or where clause (+ avoid circular reference)
|
|
483
538
|
? never : T[P] extends object ? P | `${P}.${KeyPaths<T[P]>}` : P : never;
|
|
484
539
|
}[keyof T];
|
|
485
540
|
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;
|
|
@@ -1150,35 +1205,6 @@ export interface DexieDOMDependencies {
|
|
|
1150
1205
|
indexedDB: IDBFactory;
|
|
1151
1206
|
IDBKeyRange: typeof IDBKeyRange;
|
|
1152
1207
|
}
|
|
1153
|
-
// There typings are extracted from https://github.com/tc39/proposal-observable
|
|
1154
|
-
declare global {
|
|
1155
|
-
interface SymbolConstructor {
|
|
1156
|
-
readonly observable: symbol;
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
export interface Subscribable<T> {
|
|
1160
|
-
subscribe(observer: Partial<Observer<T>>): Unsubscribable;
|
|
1161
|
-
}
|
|
1162
|
-
export interface Unsubscribable {
|
|
1163
|
-
unsubscribe(): void;
|
|
1164
|
-
}
|
|
1165
|
-
export interface Observable<T = any> {
|
|
1166
|
-
subscribe(observerOrNext?: Observer<T> | ((value: T) => void)): Subscription;
|
|
1167
|
-
subscribe(next?: ((value: T) => void) | null, error?: ((error: any) => void) | null, complete?: (() => void) | null): Subscription;
|
|
1168
|
-
getValue?(): T;
|
|
1169
|
-
hasValue?(): boolean;
|
|
1170
|
-
[Symbol.observable]: () => Subscribable<T>;
|
|
1171
|
-
}
|
|
1172
|
-
export interface Subscription {
|
|
1173
|
-
unsubscribe(): void;
|
|
1174
|
-
readonly closed: boolean;
|
|
1175
|
-
}
|
|
1176
|
-
export interface Observer<T = any> {
|
|
1177
|
-
start?: (subscription: Subscription) => void;
|
|
1178
|
-
next?: (value: T) => void;
|
|
1179
|
-
error?: (error: any) => void;
|
|
1180
|
-
complete?: () => void;
|
|
1181
|
-
}
|
|
1182
1208
|
export type GlobalQueryCache = {
|
|
1183
1209
|
// TODO: Change to parts: {[part: string]: TblQueryCache}
|
|
1184
1210
|
// och unsignaledParts: ObservabilitySet;
|
|
@@ -1229,7 +1255,7 @@ export interface DexieOptions {
|
|
|
1229
1255
|
modifyChunkSize?: number;
|
|
1230
1256
|
chromeTransactionDurability?: ChromeTransactionDurability;
|
|
1231
1257
|
cache?: "immutable" | "cloned" | "disabled";
|
|
1232
|
-
Y?:
|
|
1258
|
+
Y?: YjsLib; // Caller supplies Y from the following: import * as Y from 'yjs';
|
|
1233
1259
|
}
|
|
1234
1260
|
export interface DexieConstructor extends DexieExceptionClasses {
|
|
1235
1261
|
new (databaseName: string, options?: DexieOptions): Dexie;
|
|
@@ -1302,6 +1328,30 @@ export type InsertType<T, OptionalProps extends keyof T> = Omit<T, OptionalProps
|
|
|
1302
1328
|
*/
|
|
1303
1329
|
export type IDType<T, TKeyPropNameOrKeyType> = IsStrictlyAny<T> extends true ? TKeyPropNameOrKeyType : TKeyPropNameOrKeyType extends string ? TKeyPropNameOrKeyType extends keyof T ? T[TKeyPropNameOrKeyType] : TKeyPropNameOrKeyType : TKeyPropNameOrKeyType;
|
|
1304
1330
|
export type EntityTable<T, TKeyPropName extends keyof T = never, TInsertType = InsertType<T, TKeyPropName>> = Table<T, IDType<T, TKeyPropName>, TInsertType>;
|
|
1331
|
+
declare function getDocCache(db: Dexie): YDocCache;
|
|
1332
|
+
export interface ReleaseOptions {
|
|
1333
|
+
gracePeriod?: number;
|
|
1334
|
+
}
|
|
1335
|
+
declare class DexieYProvider$1<YDoc extends YjsDoc = any> implements DexieYProvider<YDoc> {
|
|
1336
|
+
private refCount;
|
|
1337
|
+
private stopObserving;
|
|
1338
|
+
private cleanupHandlers;
|
|
1339
|
+
doc: YDoc;
|
|
1340
|
+
awareness?: any;
|
|
1341
|
+
whenLoaded: Promise<void>;
|
|
1342
|
+
whenSynced: Promise<void>;
|
|
1343
|
+
on: DexieEventSet & ((name: string, f: (...args: any[]) => any) => void);
|
|
1344
|
+
off: (name: string, f: (...args: any[]) => any) => void;
|
|
1345
|
+
destroyed: boolean;
|
|
1346
|
+
static load<YDoc extends YjsDoc>(doc: YDoc): DexieYProvider$1<YDoc>;
|
|
1347
|
+
static release<YDoc extends YjsDoc>(doc: YDoc, options?: ReleaseOptions): void;
|
|
1348
|
+
static for<YDoc extends YjsDoc>(doc: YDoc): DexieYProvider$1<YDoc> | undefined;
|
|
1349
|
+
static getDocCache: typeof getDocCache;
|
|
1350
|
+
static currentUpdateRow: YUpdateRow | null;
|
|
1351
|
+
constructor(doc: YDoc);
|
|
1352
|
+
destroy(): void;
|
|
1353
|
+
addCleanupHandler(cleanupHandler: (() => void) | Unsubscribable): void;
|
|
1354
|
+
}
|
|
1305
1355
|
export declare var Dexie: DexieConstructor;
|
|
1306
1356
|
// Alias of Table and Collection in order to be able to refer them from module below...
|
|
1307
1357
|
export interface _Table<T, TKey, TInsertType> extends Table<T, TKey, TInsertType> {
|
|
@@ -1328,14 +1378,10 @@ export function cmp(a: any, b: any): number;
|
|
|
1328
1378
|
export function replacePrefix(a: string, b: string): PropModification;
|
|
1329
1379
|
export function add(num: number | bigint | any[]): PropModification;
|
|
1330
1380
|
export function remove(num: number | bigint | any[]): PropModification;
|
|
1331
|
-
export declare var DexieYProvider: {
|
|
1332
|
-
(doc: DucktypedYDoc): DexieYProvider;
|
|
1333
|
-
new (doc: DucktypedYDoc): DexieYProvider;
|
|
1334
|
-
getDocCache: (db: Dexie) => YDocCache;
|
|
1335
|
-
};
|
|
1336
1381
|
|
|
1337
1382
|
export {
|
|
1338
1383
|
Dexie as default,
|
|
1384
|
+
DexieYProvider$1 as DexieYProvider,
|
|
1339
1385
|
RangeSet$1 as RangeSet,
|
|
1340
1386
|
};
|
|
1341
1387
|
|