Comparing version 4.1.0-alpha.12 to 4.1.0-alpha.23
@@ -7,3 +7,3 @@ /* | ||
* | ||
* Version 4.1.0-alpha.12, Wed Oct 16 2024 | ||
* Version 4.1.0-alpha.23, Wed Nov 27 2024 | ||
* | ||
@@ -368,2 +368,115 @@ * https://dexie.org | ||
} | ||
export type KeyPathIgnoreObject = ArrayBuffer | ArrayBufferView | RegExp | Blob | FileList | FileSystemFileHandle | FileSystemDirectoryHandle | DataView | ImageBitmap | ImageData | Map<any, any> | Set<any> | CryptoKey | Promise<any> | ReadableStream<any> | ReadableStreamDefaultReader<any> | ReadableStreamDefaultController<any> | { | ||
whenLoaded: Promise<any>; | ||
}; // Y.Doc | ||
export type KeyPaths<T, MAXDEPTH = "II", CURRDEPTH extends string = ""> = { | ||
[P in keyof T]: P extends string ? CURRDEPTH extends MAXDEPTH ? P : T[P] extends Array<infer K> ? K extends any[] // Array of arrays (issue #2026) | ||
? P | `${P}.${number}` | `${P}.${number}.${number}` : K extends object // only drill into the array element if it's an object | ||
? P | `${P}.${number}` | `${P}.${number}.${KeyPaths<Required<K>>}` : P | `${P}.${number}` : T[P] extends (...args: any[]) => any // Method | ||
? never : T[P] extends KeyPathIgnoreObject // Not valid in update spec or where clause (+ avoid circular reference) | ||
? P : T[P] extends object ? P | `${P}.${KeyPaths<Required<T[P]>, MAXDEPTH, `${CURRDEPTH}I`>}` : P : never; | ||
}[keyof T]; | ||
export type KeyPathValue<T, PATH> = PATH extends `${infer R}.${infer S}` ? R extends keyof T ? KeyPathValue<Required<T[R]>, S> : T extends any[] ? PATH extends `${number}.${infer S}` ? KeyPathValue<Required<T[number]>, S> : void : void : PATH extends `${number}` ? T extends any[] ? T[number] : void : PATH extends keyof T ? T[PATH] : any; | ||
export declare const PropModSymbol: unique symbol; | ||
export type PropModSpec = { | ||
replacePrefix?: [ | ||
string, | ||
string | ||
]; | ||
add?: number | bigint | Array<string | number>; | ||
remove?: number | bigint | Array<string | number>; | ||
}; | ||
export class PropModification implements PropModSpec { | ||
[PropModSymbol]?: true; | ||
replacePrefix?: [ | ||
string, | ||
string | ||
]; | ||
add?: number | bigint | Array<string | number>; | ||
remove?: number | bigint | Array<string | number>; | ||
execute<T>(value: T): T; | ||
constructor(spec: PropModSpec); | ||
} | ||
export type UpdateSpec<T> = { | ||
[KP in KeyPaths<Required<T>>]?: KeyPathValue<Required<T>, KP> | PropModification; | ||
}; | ||
export interface Collection<T = any, TKey = IndexableType, TInsertType = T> { | ||
db: Dexie; | ||
and(filter: (x: T) => boolean): Collection<T, TKey, TInsertType>; | ||
clone(props?: Object): Collection<T, TKey, TInsertType>; | ||
count(): PromiseExtended<number>; | ||
count<R>(thenShortcut: ThenShortcut<number, R>): PromiseExtended<R>; | ||
distinct(): Collection<T, TKey, TInsertType>; | ||
each(callback: (obj: T, cursor: { | ||
key: IndexableType; | ||
primaryKey: TKey; | ||
}) => any): PromiseExtended<void>; | ||
eachKey(callback: (key: IndexableType, cursor: { | ||
key: IndexableType; | ||
primaryKey: TKey; | ||
}) => any): PromiseExtended<void>; | ||
eachPrimaryKey(callback: (key: TKey, cursor: { | ||
key: IndexableType; | ||
primaryKey: TKey; | ||
}) => any): PromiseExtended<void>; | ||
eachUniqueKey(callback: (key: IndexableType, cursor: { | ||
key: IndexableType; | ||
primaryKey: TKey; | ||
}) => any): PromiseExtended<void>; | ||
filter<S extends T>(filter: (x: T) => x is S): Collection<S, TKey>; | ||
filter(filter: (x: T) => boolean): Collection<T, TKey, TInsertType>; | ||
first(): PromiseExtended<T | undefined>; | ||
first<R>(thenShortcut: ThenShortcut<T | undefined, R>): PromiseExtended<R>; | ||
keys(): PromiseExtended<IndexableTypeArray>; | ||
keys<R>(thenShortcut: ThenShortcut<IndexableTypeArray, R>): PromiseExtended<R>; | ||
primaryKeys(): PromiseExtended<TKey[]>; | ||
primaryKeys<R>(thenShortcut: ThenShortcut<TKey[], R>): PromiseExtended<R>; | ||
last(): PromiseExtended<T | undefined>; | ||
last<R>(thenShortcut: ThenShortcut<T | undefined, R>): PromiseExtended<R>; | ||
limit(n: number): Collection<T, TKey, TInsertType>; | ||
offset(n: number): Collection<T, TKey, TInsertType>; | ||
or(indexOrPrimayKey: string): WhereClause<T, TKey, TInsertType>; | ||
raw(): Collection<T, TKey, TInsertType>; | ||
reverse(): Collection<T, TKey, TInsertType>; | ||
sortBy(keyPath: string): PromiseExtended<T[]>; | ||
sortBy<R>(keyPath: string, thenShortcut: ThenShortcut<T[], R>): PromiseExtended<R>; | ||
toArray(): PromiseExtended<Array<T>>; | ||
toArray<R>(thenShortcut: ThenShortcut<T[], R>): PromiseExtended<R>; | ||
uniqueKeys(): PromiseExtended<IndexableTypeArray>; | ||
uniqueKeys<R>(thenShortcut: ThenShortcut<IndexableTypeArray, R>): PromiseExtended<R>; | ||
until(filter: (value: T) => boolean, includeStopEntry?: boolean): Collection<T, TKey, TInsertType>; | ||
// Mutating methods | ||
delete(): PromiseExtended<number>; | ||
modify(changeCallback: (obj: T, ctx: { | ||
value: TInsertType; | ||
}) => void | boolean): PromiseExtended<number>; | ||
modify(changes: UpdateSpec<TInsertType>): PromiseExtended<number>; | ||
} | ||
export type IntervalTree = IntervalTreeNode | EmptyRange; | ||
export interface IntervalTreeNode { | ||
from: IndexableType; // lower bound | ||
to: IndexableType; // upper bound | ||
l?: IntervalTreeNode | null; // left | ||
r?: IntervalTreeNode | null; // right | ||
d: number; // depth | ||
} | ||
export interface EmptyRange { | ||
d: 0; | ||
} | ||
export interface RangeSetPrototype { | ||
add(rangeSet: IntervalTree | { | ||
from: IndexableType; | ||
to: IndexableType; | ||
}): RangeSet; | ||
addKey(key: IndexableType): RangeSet; | ||
addKeys(keys: IndexableType[]): RangeSet; | ||
hasKey(key: IndexableType): boolean; | ||
[Symbol.iterator](): Iterator<IntervalTreeNode, undefined, IndexableType | undefined>; | ||
} | ||
export type RangeSet = RangeSetPrototype & IntervalTree; | ||
export interface RangeSetConstructor { | ||
(tree: IntervalTree): RangeSet; | ||
new (): RangeSet; | ||
new (from: IndexableType, to?: IndexableType): RangeSet; | ||
} | ||
// There typings are extracted from https://github.com/tc39/proposal-observable | ||
@@ -535,112 +648,2 @@ declare global { | ||
} | ||
export type KeyPaths<T> = { | ||
[P in keyof T]: P extends string ? T[P] extends Array<infer K> ? K extends any[] // Array of arrays (issue #2026) | ||
? P | `${P}.${number}` | `${P}.${number}.${number}` : K extends object // only drill into the array element if it's an object | ||
? P | `${P}.${number}` | `${P}.${number}.${KeyPaths<K>}` : P | `${P}.${number}` : T[P] extends (...args: any[]) => any // Method | ||
? never : T[P] extends YjsDoc // Not valid in update spec or where clause (+ avoid circular reference) | ||
? never : T[P] extends object ? P | `${P}.${KeyPaths<T[P]>}` : P : never; | ||
}[keyof T]; | ||
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; | ||
export declare const PropModSymbol: unique symbol; | ||
export type PropModSpec = { | ||
replacePrefix?: [ | ||
string, | ||
string | ||
]; | ||
add?: number | bigint | Array<string | number>; | ||
remove?: number | bigint | Array<string | number>; | ||
}; | ||
export class PropModification implements PropModSpec { | ||
[PropModSymbol]?: true; | ||
replacePrefix?: [ | ||
string, | ||
string | ||
]; | ||
add?: number | bigint | Array<string | number>; | ||
remove?: number | bigint | Array<string | number>; | ||
execute<T>(value: T): T; | ||
constructor(spec: PropModSpec); | ||
} | ||
export type UpdateSpec<T> = { | ||
[KP in KeyPaths<T>]?: KeyPathValue<T, KP> | PropModification; | ||
}; | ||
export interface Collection<T = any, TKey = IndexableType, TInsertType = T> { | ||
db: Dexie; | ||
and(filter: (x: T) => boolean): Collection<T, TKey, TInsertType>; | ||
clone(props?: Object): Collection<T, TKey, TInsertType>; | ||
count(): PromiseExtended<number>; | ||
count<R>(thenShortcut: ThenShortcut<number, R>): PromiseExtended<R>; | ||
distinct(): Collection<T, TKey, TInsertType>; | ||
each(callback: (obj: T, cursor: { | ||
key: IndexableType; | ||
primaryKey: TKey; | ||
}) => any): PromiseExtended<void>; | ||
eachKey(callback: (key: IndexableType, cursor: { | ||
key: IndexableType; | ||
primaryKey: TKey; | ||
}) => any): PromiseExtended<void>; | ||
eachPrimaryKey(callback: (key: TKey, cursor: { | ||
key: IndexableType; | ||
primaryKey: TKey; | ||
}) => any): PromiseExtended<void>; | ||
eachUniqueKey(callback: (key: IndexableType, cursor: { | ||
key: IndexableType; | ||
primaryKey: TKey; | ||
}) => any): PromiseExtended<void>; | ||
filter<S extends T>(filter: (x: T) => x is S): Collection<S, TKey>; | ||
filter(filter: (x: T) => boolean): Collection<T, TKey, TInsertType>; | ||
first(): PromiseExtended<T | undefined>; | ||
first<R>(thenShortcut: ThenShortcut<T | undefined, R>): PromiseExtended<R>; | ||
keys(): PromiseExtended<IndexableTypeArray>; | ||
keys<R>(thenShortcut: ThenShortcut<IndexableTypeArray, R>): PromiseExtended<R>; | ||
primaryKeys(): PromiseExtended<TKey[]>; | ||
primaryKeys<R>(thenShortcut: ThenShortcut<TKey[], R>): PromiseExtended<R>; | ||
last(): PromiseExtended<T | undefined>; | ||
last<R>(thenShortcut: ThenShortcut<T | undefined, R>): PromiseExtended<R>; | ||
limit(n: number): Collection<T, TKey, TInsertType>; | ||
offset(n: number): Collection<T, TKey, TInsertType>; | ||
or(indexOrPrimayKey: string): WhereClause<T, TKey, TInsertType>; | ||
raw(): Collection<T, TKey, TInsertType>; | ||
reverse(): Collection<T, TKey, TInsertType>; | ||
sortBy(keyPath: string): PromiseExtended<T[]>; | ||
sortBy<R>(keyPath: string, thenShortcut: ThenShortcut<T[], R>): PromiseExtended<R>; | ||
toArray(): PromiseExtended<Array<T>>; | ||
toArray<R>(thenShortcut: ThenShortcut<T[], R>): PromiseExtended<R>; | ||
uniqueKeys(): PromiseExtended<IndexableTypeArray>; | ||
uniqueKeys<R>(thenShortcut: ThenShortcut<IndexableTypeArray, R>): PromiseExtended<R>; | ||
until(filter: (value: T) => boolean, includeStopEntry?: boolean): Collection<T, TKey, TInsertType>; | ||
// Mutating methods | ||
delete(): PromiseExtended<number>; | ||
modify(changeCallback: (obj: T, ctx: { | ||
value: TInsertType; | ||
}) => void | boolean): PromiseExtended<number>; | ||
modify(changes: UpdateSpec<TInsertType>): PromiseExtended<number>; | ||
} | ||
export type IntervalTree = IntervalTreeNode | EmptyRange; | ||
export interface IntervalTreeNode { | ||
from: IndexableType; // lower bound | ||
to: IndexableType; // upper bound | ||
l?: IntervalTreeNode | null; // left | ||
r?: IntervalTreeNode | null; // right | ||
d: number; // depth | ||
} | ||
export interface EmptyRange { | ||
d: 0; | ||
} | ||
export interface RangeSetPrototype { | ||
add(rangeSet: IntervalTree | { | ||
from: IndexableType; | ||
to: IndexableType; | ||
}): RangeSet; | ||
addKey(key: IndexableType): RangeSet; | ||
addKeys(keys: IndexableType[]): RangeSet; | ||
hasKey(key: IndexableType): boolean; | ||
[Symbol.iterator](): Iterator<IntervalTreeNode, undefined, IndexableType | undefined>; | ||
} | ||
export type RangeSet = RangeSetPrototype & IntervalTree; | ||
export interface RangeSetConstructor { | ||
(tree: IntervalTree): RangeSet; | ||
new (): RangeSet; | ||
new (from: IndexableType, to?: IndexableType): RangeSet; | ||
} | ||
export interface DexieOnReadyEvent { | ||
@@ -941,7 +944,6 @@ subscribe(fn: (vipDb: Dexie) => any, bSticky: boolean): void; | ||
add(item: TInsertType, key?: TKey): PromiseExtended<TKey>; | ||
update(key: TKey | T, changes: ((obj: T, ctx: { | ||
update(key: TKey | T, changes: UpdateSpec<TInsertType> | ((obj: T, ctx: { | ||
value: any; | ||
primKey: IndexableType; | ||
}) => void | boolean)): PromiseExtended<number>; | ||
update(key: TKey | T, changes: UpdateSpec<TInsertType>): PromiseExtended<number>; | ||
put(item: TInsertType, key?: TKey): PromiseExtended<TKey>; | ||
@@ -996,3 +998,3 @@ delete(key: TKey): PromiseExtended<void>; | ||
} | ||
export type TableProp<DX extends Dexie> = { | ||
export type TableProp<DX> = { | ||
[K in keyof DX]: DX[K] extends { | ||
@@ -1260,3 +1262,5 @@ schema: any; | ||
allowEmptyDB?: boolean; | ||
modifyChunkSize?: number; | ||
modifyChunkSize?: number | { | ||
[key: string]: number; | ||
}; | ||
chromeTransactionDurability?: ChromeTransactionDurability; | ||
@@ -1269,3 +1273,3 @@ cache?: "immutable" | "cloned" | "disabled"; | ||
new (databaseName: string, options?: DexieOptions): Dexie; | ||
prototype: Dexie; | ||
prototype: any; | ||
addons: Array<(db: Dexie) => void>; | ||
@@ -1272,0 +1276,0 @@ version: number; |
{ | ||
"name": "dexie", | ||
"version": "4.1.0-alpha.12", | ||
"version": "4.1.0-alpha.23", | ||
"description": "A Minimalistic Wrapper for IndexedDB", | ||
@@ -131,3 +131,3 @@ "main": "dist/dexie.js", | ||
"tslib": "^2.1.0", | ||
"typescript": "^5.3.3", | ||
"typescript": "^5.6.3", | ||
"uglify-js": "^3.9.2", | ||
@@ -134,0 +134,0 @@ "y-protocols": "^1.0.6", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
3300571
21665