dexie 4.0.9 → 4.0.11

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 CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * By David Fahlander, david.fahlander@gmail.com
6
6
  *
7
- * Version 4.0.9, Mon Oct 21 2024
7
+ * Version 4.0.11, Wed Jan 15 2025
8
8
  *
9
9
  * https://dexie.org
10
10
  *
@@ -366,7 +366,6 @@ export type KeyPaths<T> = {
366
366
  ? never : T[P] extends object ? P | `${P}.${KeyPaths<T[P]>}` : P : never;
367
367
  }[keyof T];
368
368
  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;
369
- export declare const PropModSymbol: unique symbol;
370
369
  export type PropModSpec = {
371
370
  replacePrefix?: [
372
371
  string,
@@ -375,16 +374,10 @@ export type PropModSpec = {
375
374
  add?: number | bigint | Array<string | number>;
376
375
  remove?: number | bigint | Array<string | number>;
377
376
  };
378
- export class PropModification implements PropModSpec {
379
- [PropModSymbol]?: true;
380
- replacePrefix?: [
381
- string,
382
- string
383
- ];
384
- add?: number | bigint | Array<string | number>;
385
- remove?: number | bigint | Array<string | number>;
386
- execute<T>(value: T): T;
377
+ export class PropModification {
378
+ ["@@propmod"]: PropModSpec;
387
379
  constructor(spec: PropModSpec);
380
+ execute<T>(value: T): T;
388
381
  }
389
382
  export type UpdateSpec<T> = {
390
383
  [KP in KeyPaths<T>]?: KeyPathValue<T, KP> | PropModification;
@@ -1080,7 +1073,9 @@ export interface DexieOptions {
1080
1073
  upperBound: Function;
1081
1074
  };
1082
1075
  allowEmptyDB?: boolean;
1083
- modifyChunkSize?: number;
1076
+ modifyChunkSize?: number | {
1077
+ [key: string]: number;
1078
+ };
1084
1079
  chromeTransactionDurability?: ChromeTransactionDurability;
1085
1080
  cache?: "immutable" | "cloned" | "disabled";
1086
1081
  }
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.0.9, Mon Oct 21 2024
7
+ * Version 4.0.11, Wed Jan 15 2025
8
8
  *
9
9
  * https://dexie.org
10
10
  *
@@ -1152,7 +1152,7 @@
1152
1152
  }
1153
1153
  }
1154
1154
 
1155
- var DEXIE_VERSION = '4.0.9';
1155
+ var DEXIE_VERSION = '4.0.11';
1156
1156
  var maxString = String.fromCharCode(65535);
1157
1157
  var minKey = -Infinity;
1158
1158
  var INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
@@ -1804,15 +1804,15 @@
1804
1804
  });
1805
1805
  }
1806
1806
 
1807
- var PropModSymbol = Symbol();
1808
1807
  var PropModification = (function () {
1809
1808
  function PropModification(spec) {
1810
- Object.assign(this, spec);
1809
+ this["@@propmod"] = spec;
1811
1810
  }
1812
1811
  PropModification.prototype.execute = function (value) {
1813
1812
  var _a;
1814
- if (this.add !== undefined) {
1815
- var term = this.add;
1813
+ var spec = this["@@propmod"];
1814
+ if (spec.add !== undefined) {
1815
+ var term = spec.add;
1816
1816
  if (isArray(term)) {
1817
1817
  return __spreadArray(__spreadArray([], (isArray(value) ? value : []), true), term, true).sort();
1818
1818
  }
@@ -1828,8 +1828,8 @@
1828
1828
  }
1829
1829
  throw new TypeError("Invalid term ".concat(term));
1830
1830
  }
1831
- if (this.remove !== undefined) {
1832
- var subtrahend_1 = this.remove;
1831
+ if (spec.remove !== undefined) {
1832
+ var subtrahend_1 = spec.remove;
1833
1833
  if (isArray(subtrahend_1)) {
1834
1834
  return isArray(value) ? value.filter(function (item) { return !subtrahend_1.includes(item); }).sort() : [];
1835
1835
  }
@@ -1845,9 +1845,9 @@
1845
1845
  }
1846
1846
  throw new TypeError("Invalid subtrahend ".concat(subtrahend_1));
1847
1847
  }
1848
- var prefixToReplace = (_a = this.replacePrefix) === null || _a === void 0 ? void 0 : _a[0];
1848
+ var prefixToReplace = (_a = spec.replacePrefix) === null || _a === void 0 ? void 0 : _a[0];
1849
1849
  if (prefixToReplace && typeof value === 'string' && value.startsWith(prefixToReplace)) {
1850
- return this.replacePrefix[1] + value.substring(prefixToReplace.length);
1850
+ return spec.replacePrefix[1] + value.substring(prefixToReplace.length);
1851
1851
  }
1852
1852
  return value;
1853
1853
  };
@@ -2142,7 +2142,16 @@
2142
2142
  }
2143
2143
  var coreTable = ctx.table.core;
2144
2144
  var _a = coreTable.schema.primaryKey, outbound = _a.outbound, extractKey = _a.extractKey;
2145
- var limit = _this.db._options.modifyChunkSize || 200;
2145
+ var limit = 200;
2146
+ var modifyChunkSize = _this.db._options.modifyChunkSize;
2147
+ if (modifyChunkSize) {
2148
+ if (typeof modifyChunkSize == 'object') {
2149
+ limit = modifyChunkSize[coreTable.name] || modifyChunkSize['*'] || 200;
2150
+ }
2151
+ else {
2152
+ limit = modifyChunkSize;
2153
+ }
2154
+ }
2146
2155
  var totalFailures = [];
2147
2156
  var successCount = 0;
2148
2157
  var failedKeys = [];
@@ -4679,7 +4688,9 @@
4679
4688
  indexesWithAutoIncPK.forEach(function (idx) {
4680
4689
  var idxVals = req.values.map(function (v) { return idx.extractKey(v); });
4681
4690
  var pkPos = idx.keyPath.findIndex(function (prop) { return prop === primaryKey.keyPath; });
4682
- res.results.forEach(function (pk) { return idxVals[pkPos] = pk; });
4691
+ for (var i = 0, len = res.results.length; i < len; ++i) {
4692
+ idxVals[i][pkPos] = res.results[i];
4693
+ }
4683
4694
  getRangeSet(idx.name).addKeys(idxVals);
4684
4695
  });
4685
4696
  }
@@ -5909,7 +5920,6 @@
5909
5920
  liveQuery: liveQuery,
5910
5921
  Entity: Entity,
5911
5922
  cmp: cmp,
5912
- PropModSymbol: PropModSymbol,
5913
5923
  PropModification: PropModification,
5914
5924
  replacePrefix: replacePrefix,
5915
5925
  add: add,