indexeddbshim 17.3.4 → 17.4.0

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.
Files changed (34) hide show
  1. package/README.md +3 -146
  2. package/dist/CFG.d.ts +1 -0
  3. package/dist/CFG.d.ts.map +1 -1
  4. package/dist/DOMException.d.ts +4 -4
  5. package/dist/DOMException.d.ts.map +1 -1
  6. package/dist/indexeddbshim-Key.js +3 -2
  7. package/dist/indexeddbshim-Key.js.map +1 -1
  8. package/dist/indexeddbshim-Key.min.js +2 -2
  9. package/dist/indexeddbshim-Key.min.js.map +1 -1
  10. package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs +48 -34
  11. package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs.map +1 -1
  12. package/dist/indexeddbshim-UnicodeIdentifiers.js +33 -33
  13. package/dist/indexeddbshim-UnicodeIdentifiers.js.map +1 -1
  14. package/dist/indexeddbshim-UnicodeIdentifiers.min.js +2 -2
  15. package/dist/indexeddbshim-UnicodeIdentifiers.min.js.map +1 -1
  16. package/dist/indexeddbshim-node.cjs +48 -34
  17. package/dist/indexeddbshim-node.cjs.map +1 -1
  18. package/dist/indexeddbshim-noninvasive.js +33 -33
  19. package/dist/indexeddbshim-noninvasive.js.map +1 -1
  20. package/dist/indexeddbshim-noninvasive.min.js +2 -2
  21. package/dist/indexeddbshim-noninvasive.min.js.map +1 -1
  22. package/dist/indexeddbshim.js +33 -33
  23. package/dist/indexeddbshim.js.map +1 -1
  24. package/dist/indexeddbshim.min.js +2 -2
  25. package/dist/indexeddbshim.min.js.map +1 -1
  26. package/dist/nodeSQLiteDatabase.d.ts.map +1 -1
  27. package/dist/nodeWebSQL.d.ts.map +1 -1
  28. package/package.json +6 -7
  29. package/src/CFG.js +2 -0
  30. package/src/DOMException.js +21 -21
  31. package/src/IDBObjectStore.js +1 -1
  32. package/src/nodeSQLiteDatabase.js +10 -1
  33. package/src/nodeWebSQL.js +3 -0
  34. package/src/setGlobalVars.js +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"nodeSQLiteDatabase.d.ts","sourceRoot":"","sources":["../src/nodeSQLiteDatabase.js"],"names":[],"mappings":";iCAyBa,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI;+BAIvC,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC,GAAC,SAAS;AAkC9C;;;;;;GAMG;AACH;SAHgB,GAAG;gBAAc,MAAM;SAF5B,MAAM,SACN;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,kBAAkB,CAAA;CAAC,GAEjF,IAAI,CAmEhB;;IAxED;;;;;;OAMG;IACH;aAHgB,GAAG;oBAAc,MAAM;aAF5B,MAAM,SACN;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;QAAC,OAAO,CAAC,EAAE,kBAAkB,CAAA;KAAC,EAqE7F;IAhEG,mBAAsB;IAkBtB,SA6CE;IAyBN;;;;;OAKG;IACH,cALW;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,EAAE,CAAA;KAAC,EAAE,YAChC,OAAO,YACP,CAAC,GAAG,EAAE,KAAK,GAAC,IAAI,EAAE,OAAO,CAAC,EAAE,YAAY,EAAE,KAAK,IAAI,GACjD,IAAI,CA2IhB;;AA5SD;;GAEG;AACH;IACI;;;;;OAKG;IACH,mBALW,KAAK,GAAC,IAAI,GAAC,SAAS,aACpB,MAAM,GAAC,SAAS,iBAChB,MAAM,SACN,MAAM,EAAE,EAOlB;IAJG,gCAAkB;IAClB,6BAAwB;IACxB,iCAAgC;IAChC,2BAAgB;CAEvB"}
1
+ {"version":3,"file":"nodeSQLiteDatabase.d.ts","sourceRoot":"","sources":["../src/nodeSQLiteDatabase.js"],"names":[],"mappings":";iCAyBa,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI;+BAIvC,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC,GAAC,SAAS;AAkC9C;;;;;;GAMG;AACH;SAHgB,GAAG;gBAAc,MAAM;SAF5B,MAAM,SACN;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,kBAAkB,CAAA;CAAC,GAEjF,IAAI,CA4EhB;;IAjFD;;;;;;OAMG;IACH;aAHgB,GAAG;oBAAc,MAAM;aAF5B,MAAM,SACN;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;QAAC,OAAO,CAAC,EAAE,kBAAkB,CAAA;KAAC,EA8E7F;IAzEG,mBAAsB;IAkBtB,SAsDE;IAyBN;;;;;OAKG;IACH,cALW;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,EAAE,CAAA;KAAC,EAAE,YAChC,OAAO,YACP,CAAC,GAAG,EAAE,KAAK,GAAC,IAAI,EAAE,OAAO,CAAC,EAAE,YAAY,EAAE,KAAK,IAAI,GACjD,IAAI,CA2IhB;;AArTD;;GAEG;AACH;IACI;;;;;OAKG;IACH,mBALW,KAAK,GAAC,IAAI,GAAC,SAAS,aACpB,MAAM,GAAC,SAAS,iBAChB,MAAM,SACN,MAAM,EAAE,EAOlB;IAJG,gCAAkB;IAClB,6BAAwB;IACxB,iCAAgC;IAChC,2BAAgB;CAEvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"nodeWebSQL.d.ts","sourceRoot":"","sources":["../src/nodeWebSQL.js"],"names":[],"mappings":";qCAKa;IACR,GAAG,EAAE,GAAG,CAAC;IACT,IAAI,EAAE,CAAA,OAAO,cAAc,EAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAA;CACjD;;;;;;;;;;;wCAYS,KAAK,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,sBAAsB;AA6BrE,qHAAsK;2BAhD3I,yBAAyB"}
1
+ {"version":3,"file":"nodeWebSQL.d.ts","sourceRoot":"","sources":["../src/nodeWebSQL.js"],"names":[],"mappings":";qCAKa;IACR,GAAG,EAAE,GAAG,CAAC;IACT,IAAI,EAAE,CAAA,OAAO,cAAc,EAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAA;CACjD;;;;;;;;;;;wCAYS,KAAK,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,sBAAsB;AAgCrE,qHAAsK;2BAnD3I,yBAAyB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "indexeddbshim",
3
- "version": "17.3.4",
3
+ "version": "17.4.0",
4
4
  "type": "module",
5
5
  "author": "Parashuram <code@nparashuram.com>",
6
6
  "contributors": [
@@ -47,13 +47,13 @@
47
47
  "clean-mocha": "rimraf D_indexeddbshim_test_database_* D_test.sqlite",
48
48
  "clean-fake": "rimraf D_test0.*",
49
49
  "clean-mock": "rimraf D_test_database*",
50
- "clean-w3c": "rimraf D_^D^B2* D_db* D_test* D_about* D_^I^D^B* D_blank* D_database_name* D_idbtransaction* D_x D_x.sqlite D_y D_y.sqlite D_webworker* D_http*",
50
+ "clean-w3c": "rimraf D_opaque* D_inbox* D_output* D_*_bucket_* D_^D^B2* D_db* D_test* D_about* D_^I^D^B* D_blank* D_database_name* D_idbtransaction* D_x D_x.sqlite D_y D_y.sqlite D_webworker* D_http*",
51
51
  "clean-w3cOld": "rimraf D_db.sqlite* D_test* D_database_name* D_idbtransaction*",
52
52
  "clean-w3c-built": "rimraf test-support/js",
53
53
  "copy": "copyup node_modules/source-map-support/browser-source-map-support.js node_modules/mocha/mocha.css node_modules/mocha/mocha.js node_modules/chai/chai.js node_modules/sinon/pkg/sinon-no-sourcemaps.js test-support",
54
54
  "fix-permissions": "chmod +x node_modules/npm-run-all/bin/*/index.js",
55
55
  "lint": "eslint .",
56
- "eslint": "npm run lint",
56
+ "eslint": "npm run lint --",
57
57
  "sqlite-rebuild": "cd node_modules/sqlite3 && npm i",
58
58
  "w3c-build-only": "node test-support/node-buildjs",
59
59
  "w3c-build": "run-s clean-w3c clean-w3c-built w3c-build-only",
@@ -186,9 +186,9 @@
186
186
  "@rollup/plugin-node-resolve": "^16.0.3",
187
187
  "@rollup/plugin-terser": "^1.0.0",
188
188
  "@types/better-sqlite3": "^9.6.0",
189
- "@types/node": "^26.3.0",
189
+ "@types/node": "^26.4.0",
190
190
  "@types/websql": "^0.0.30",
191
- "@unicode/unicode-17.0.0": "^1.6.17",
191
+ "@unicode/unicode-17.0.0": "^2.0.2",
192
192
  "babel-plugin-add-module-exports": "1.0.4",
193
193
  "bson": "^7.3.2",
194
194
  "builtin-modules": "^5.3.0",
@@ -198,7 +198,6 @@
198
198
  "colors": "1.4.0",
199
199
  "copyfiles": "^2.4.1",
200
200
  "coveradge": "^0.8.2",
201
- "cyclonejs": "1.1.4",
202
201
  "delay-cli": "^3.0.0",
203
202
  "eslint": "^10.9.1",
204
203
  "eslint-config-ash-nazg": "^42.6.0",
@@ -207,7 +206,7 @@
207
206
  "isomorphic-fetch": "^3.0.0",
208
207
  "jsdom": "^30.0.1",
209
208
  "license-badger": "^0.23.0",
210
- "local-xmlhttprequest": "3.0.0",
209
+ "local-xmlhttprequest": "4.0.0",
211
210
  "mocha": "^11.8.0",
212
211
  "mocha-badge-generator": "^0.11.0",
213
212
  "mocha-multi-reporters": "^1.5.1",
package/src/CFG.js CHANGED
@@ -43,6 +43,7 @@
43
43
  * sqlBusyTimeout: number,
44
44
  * sqlTrace: () => void,
45
45
  * sqlProfile: () => void,
46
+ * sqlMemoryQuota: number,
46
47
  * escapeNULForSQLiteStatements: boolean,
47
48
  * createIndexes: boolean
48
49
  * }} ConfigValues
@@ -220,6 +221,7 @@ const CFG = /** @type {ConfigValues} */ ({});
220
221
  // Defaults to true except in Node builds where we can preserve literal NUL with better-sqlite3
221
222
  'escapeNULForSQLiteStatements',
222
223
 
224
+ 'sqlMemoryQuota',
223
225
  'createIndexes'
224
226
  ]).forEach((prop) => {
225
227
  /** @type {(val: any) => void} */
@@ -330,15 +330,14 @@ function findError (args) {
330
330
  * optional here and, in practice, always `undefined` today (the `case 4`/
331
331
  * `case 7` branches below are effectively unreachable pending upstream
332
332
  * support for surfacing a real error code).
333
- * @param {Error & {code?: number}} webSQLErr
333
+ * @param {Error & {code?: number|string}} webSQLErr
334
334
  * @returns {(DOMException|Error) & {
335
- * sqlError: Error & {code?: number}
335
+ * sqlError: Error & {code?: number|string}
336
336
  * }|QuotaExceededError}
337
337
  */
338
338
  function webSQLErrback (webSQLErr) {
339
339
  let name, message, useQuotaExceededError = false;
340
- switch (webSQLErr.code) {
341
- case 4: { // SQLError.QUOTA_ERR
340
+ if (webSQLErr.code === 4 || webSQLErr.code === 'SQLITE_FULL') { // SQLError.QUOTA_ERR or better-sqlite3 SQLITE_FULL
342
341
  name = 'QuotaExceededError';
343
342
  message = 'The operation failed because there was not enough ' +
344
343
  'remaining storage space, or the storage quota was reached ' +
@@ -346,22 +345,23 @@ function webSQLErrback (webSQLErr) {
346
345
  if (typeof QuotaExceededError !== 'undefined') {
347
346
  useQuotaExceededError = true;
348
347
  }
349
- break;
350
- }
351
- /*
352
- // Should a WebSQL timeout treat as IndexedDB `TransactionInactiveError` or `UnknownError`?
353
- case 7: { // SQLError.TIMEOUT_ERR
354
- // All transaction errors abort later, so no need to mark inactive
355
- name = 'TransactionInactiveError';
356
- message = 'A request was placed against a transaction which is currently not active, or which is finished (Internal SQL Timeout).';
357
- break;
358
- }
359
- */
360
- default: {
361
- name = 'UnknownError';
362
- message = 'The operation failed for reasons unrelated to the database itself and not covered by any other errors.';
363
- break;
364
- }
348
+ } else {
349
+ switch (webSQLErr.code) {
350
+ /*
351
+ // Should a WebSQL timeout treat as IndexedDB `TransactionInactiveError` or `UnknownError`?
352
+ case 7: { // SQLError.TIMEOUT_ERR
353
+ // All transaction errors abort later, so no need to mark inactive
354
+ name = 'TransactionInactiveError';
355
+ message = 'A request was placed against a transaction which is currently not active, or which is finished (Internal SQL Timeout).';
356
+ break;
357
+ }
358
+ */
359
+ default: {
360
+ name = 'UnknownError';
361
+ message = 'The operation failed for reasons unrelated to the database itself and not covered by any other errors.';
362
+ break;
363
+ }
364
+ }
365
365
  }
366
366
  message += ' (' + webSQLErr.message + ')--(' + webSQLErr.code + ')';
367
367
 
@@ -372,7 +372,7 @@ function webSQLErrback (webSQLErr) {
372
372
  const err =
373
373
  /**
374
374
  * @type {(Error | DOMException) & {
375
- * sqlError: Error & {code?: number}
375
+ * sqlError: Error & {code?: number|string}
376
376
  * }}
377
377
  */
378
378
  (createDOMException(name, message));
@@ -322,7 +322,7 @@ IDBObjectStore.__createObjectStore = function (db, store) {
322
322
  encodedKeyPath,
323
323
  // For why converting here, see comment and following
324
324
  // discussion at:
325
- // https://github.com/axemclion/IndexedDBShim/issues/313#issuecomment-590086778
325
+ // https://github.com/indexeddbshim/IndexedDBShim/issues/313#issuecomment-590086778
326
326
  Number(store.autoIncrement),
327
327
  '{}',
328
328
  1
@@ -91,7 +91,7 @@ function SQLiteDatabase (name, opts = {}) {
91
91
  _db: db,
92
92
  /**
93
93
  * Compatibility with node-sqlite3's configure API.
94
- * @param {'busyTimeout'|'trace'|'profile'} option
94
+ * @param {'busyTimeout'|'trace'|'profile'|'memoryQuota'} option
95
95
  * @param {number|((sql: string, duration?: number) => void)} value
96
96
  * @returns {void}
97
97
  */
@@ -106,6 +106,15 @@ function SQLiteDatabase (name, opts = {}) {
106
106
  }
107
107
  if (option === 'profile') {
108
108
  profile = /** @type {SQLProfileCallback} */ (value);
109
+ return;
110
+ }
111
+ if (option === 'memoryQuota') {
112
+ const bytes = Number(value);
113
+ // `better-sqlite3` doesn't have a direct `sqlite3_quota_set` binding,
114
+ // but we can limit the max pages:
115
+ const pageSizeObj = db.pragma('page_size', {simple: true});
116
+ const pageSize = Number(pageSizeObj);
117
+ db.pragma('max_page_count = ' + Math.ceil(bytes / pageSize));
109
118
  }
110
119
  },
111
120
  /**
package/src/nodeWebSQL.js CHANGED
@@ -37,6 +37,9 @@ function wrappedSQLiteDatabase (name) {
37
37
  if (CFG.sqlProfile) {
38
38
  db._db.configure('profile', CFG.sqlProfile);
39
39
  }
40
+ if (CFG.sqlMemoryQuota) {
41
+ db._db.configure('memoryQuota', /** @type {number} */ (CFG.sqlMemoryQuota));
42
+ }
40
43
  return db;
41
44
  }
42
45
 
@@ -368,7 +368,7 @@ function setGlobalVars (idb, initialConfig) {
368
368
  !navigator.userAgent.includes('Chrome')
369
369
  ) ||
370
370
  (
371
- // Bad non-Safari iOS9 support (see <https://github.com/axemclion/IndexedDBShim/issues/252>)
371
+ // Bad non-Safari iOS9 support (see <https://github.com/indexeddbshim/IndexedDBShim/issues/252>)
372
372
  (!navigator.userAgent.includes('Safari') || navigator.userAgent.includes('Chrome')) && // Exclude genuine Safari: https://stackoverflow.com/a/7768006/271577
373
373
  // Detect iOS: https://stackoverflow.com/questions/9038625/detect-if-device-is-ios/9039885#9039885
374
374
  // and detect version 9: https://stackoverflow.com/a/26363560/271577
@@ -381,8 +381,8 @@ function setGlobalVars (idb, initialConfig) {
381
381
  if (!CFG.DEFAULT_DB_SIZE) {
382
382
  CFG.DEFAULT_DB_SIZE = (
383
383
  ( // Safari currently requires larger size: (We don't need a larger size for Node as node-websql doesn't use this info)
384
- // https://github.com/axemclion/IndexedDBShim/issues/41
385
- // https://github.com/axemclion/IndexedDBShim/issues/115
384
+ // https://github.com/indexeddbshim/IndexedDBShim/issues/41
385
+ // https://github.com/indexeddbshim/IndexedDBShim/issues/115
386
386
  typeof navigator !== 'undefined' &&
387
387
  // React Native
388
388
  navigator.userAgent &&