indexeddbshim 13.0.0-pre.1 → 13.0.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.
- package/README.md +1 -1
- package/badges/licenses-badge-dev.svg +1 -1
- package/dist/indexeddbshim-Key.js +90 -82
- package/dist/indexeddbshim-Key.js.map +1 -1
- package/dist/indexeddbshim-Key.min.js +2 -2
- package/dist/indexeddbshim-Key.min.js.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs +824 -487
- package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers.js +947 -774
- package/dist/indexeddbshim-UnicodeIdentifiers.js.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers.min.js +2 -2
- package/dist/indexeddbshim-UnicodeIdentifiers.min.js.map +1 -1
- package/dist/indexeddbshim-node.cjs +824 -487
- package/dist/indexeddbshim-node.cjs.map +1 -1
- package/dist/indexeddbshim-noninvasive.js +947 -774
- package/dist/indexeddbshim-noninvasive.js.map +1 -1
- package/dist/indexeddbshim-noninvasive.min.js +2 -2
- package/dist/indexeddbshim-noninvasive.min.js.map +1 -1
- package/dist/indexeddbshim.js +947 -774
- package/dist/indexeddbshim.js.map +1 -1
- package/dist/indexeddbshim.min.js +2 -2
- package/dist/indexeddbshim.min.js.map +1 -1
- package/index.html +1 -1
- package/package.json +35 -34
- package/src/DOMException.js +3 -4
- package/src/DOMStringList.js +1 -1
- package/src/IDBCursor.js +19 -17
- package/src/IDBDatabase.js +1 -0
- package/src/IDBFactory.js +23 -16
- package/src/IDBIndex.js +17 -23
- package/src/IDBKeyRange.js +4 -4
- package/src/IDBObjectStore.js +29 -26
- package/src/IDBTransaction.js +7 -8
- package/src/Key.d.ts +1 -0
- package/src/Key.js +11 -12
- package/src/setGlobalVars.js +3 -1
- package/src/util.js +1 -0
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! indexeddbshim -
|
|
2
|
-
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).IDBKeyUtils={})}(this,(function(e){"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function t(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,a,i,u=[],c=!0,l=!1;try{if(a=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;c=!1}else for(;!(c=(n=a.call(t)).done)&&(u.push(n.value),u.length!==r);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(l)throw o}}return u}}(e,r)||o(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||o(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,r){if(e){if("string"==typeof e)return a(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?a(e,r):void 0}}function a(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function i(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=o(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,c=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return u=e.done,e},e:function(e){c=!0,i=e},f:function(){try{u||null==t.return||t.return()}finally{if(c)throw i}}}}var u={},c={};function l(e,r){return new DOMException.prototype.constructor(r,e||"DOMException")}["DEBUG","cacheDatabaseInstances","autoName","fullIDLSupport","checkOrigin","cursorPreloadPackSize","UnicodeIDStart","UnicodeIDContinue","registerSCA","avoidAutoShim","win","DEFAULT_DB_SIZE","useSQLiteIndexes","fs","addNonIDBGlobals","replaceNonIDBGlobals","escapeDatabaseName","unescapeDatabaseName","databaseCharacterEscapeList","databaseNameLengthLimit","escapeNFDForDatabaseNames","addSQLiteExtension",["memoryDatabase",function(e){if(!/^(?::memory:|file::memory:(\?(?:[\0-"\$-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?(#(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?)?$/.test(e))throw new TypeError('`memoryDatabase` must be the empty string, ":memory:", or a "file::memory:[?queryString][#hash] URL".')}],"deleteDatabaseFiles","databaseBasePath","sysDatabaseBasePath","sqlBusyTimeout","sqlTrace","sqlProfile","createIndexes"].forEach((function(e){var r;if(Array.isArray(e)){var n=t(e,2);e=n[0],r=n[1]}Object.defineProperty(c,e,{get:function(){return u[e]},set:function(t){r&&r(t),u[e]=t}})}));var f={IndexSizeError:1,HierarchyRequestError:3,WrongDocumentError:4,InvalidCharacterError:5,NoModificationAllowedError:7,NotFoundError:8,NotSupportedError:9,InUseAttributeError:10,InvalidStateError:11,SyntaxError:12,InvalidModificationError:13,NamespaceError:14,InvalidAccessError:15,TypeMismatchError:17,SecurityError:18,NetworkError:19,AbortError:20,URLMismatchError:21,QuotaExceededError:22,TimeoutError:23,InvalidNodeTypeError:24,DataCloneError:25,EncodingError:0,NotReadableError:0,UnknownError:0,ConstraintError:0,DataError:0,TransactionInactiveError:0,ReadOnlyError:0,VersionError:0,OperationError:0,NotAllowedError:0},s={INDEX_SIZE_ERR:1,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,INVALID_CHARACTER_ERR:5,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:11,SYNTAX_ERR:12,INVALID_MODIFICATION_ERR:13,NAMESPACE_ERR:14,INVALID_ACCESS_ERR:15,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:17,SECURITY_ERR:18,NETWORK_ERR:19,ABORT_ERR:20,URL_MISMATCH_ERR:21,QUOTA_EXCEEDED_ERR:22,TIMEOUT_ERR:23,INVALID_NODE_TYPE_ERR:24,DATA_CLONE_ERR:25};var y=function(){function e(e,r){this[Symbol.toStringTag]="DOMException",this._code=r in f?f[r]:s[r]||0,this._name=r||"Error",this._message=void 0===e?"":""+e,Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,writable:!0,value:this._code}),void 0!==r&&Object.defineProperty(this,"name",{configurable:!0,enumerable:!0,writable:!0,value:this._name}),void 0!==e&&Object.defineProperty(this,"message",{configurable:!0,enumerable:!1,writable:!0,value:this._message})}var r=function(){};return r.prototype=Object.create(Error.prototype),["name","message"].forEach((function(t){Object.defineProperty(r.prototype,t,{enumerable:!0,get:function(){if(!(this instanceof e||this instanceof r||this instanceof Error))throw new TypeError("Illegal invocation");return this["name"===t?"_name":"_message"]}})})),Object.defineProperty(r.prototype,"code",{configurable:!0,enumerable:!0,get:function(){throw new TypeError("Illegal invocation")}}),e.prototype=new r,e.prototype[Symbol.toStringTag]="DOMExceptionPrototype",Object.defineProperty(e,"prototype",{writable:!1}),Object.keys(f).forEach((function(r){Object.defineProperty(e.prototype,r,{enumerable:!0,configurable:!1,value:f[r]}),Object.defineProperty(e,r,{enumerable:!0,configurable:!1,value:f[r]})})),Object.keys(s).forEach((function(r){Object.defineProperty(e.prototype,r,{enumerable:!0,configurable:!1,value:s[r]}),Object.defineProperty(e,r,{enumerable:!0,configurable:!1,value:s[r]})})),Object.defineProperty(e.prototype,"constructor",{writable:!0,configurable:!0,enumerable:!1,value:e}),e}();function d(e,t,n){if(c.DEBUG){var o=n&&"object"===r(n)&&n.message?n.message:n,a="function"==typeof console.error?"error":"log";console[a](e+": "+t+". "+(o||"")),console.trace&&console.trace()}}var p,v,b=!1;try{p=l("test name","test message"),(v=p)&&"object"===r(v)&&"string"==typeof v.name&&"test name"===p.name&&"test message"===p.message&&(b=!0)}catch(e){}var m=b?function(e,r,t){return d(e,r,t),l(e,r)}:function(e,r,t){return d(e,r,t),function(e,r){return new y(r,e)}(e,r)};function F(e){return function(e){return e.replaceAll(/((?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])))(?!(?:(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))|(^|(?:[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))((?:(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))/g,(function(e,r,t,n){return r?"^2"+r.codePointAt().toString(16).padStart(4,"0"):(t||"")+"^3"+n.codePointAt().toString(16).padStart(4,"0")}))}(e.replaceAll("^","^^").replaceAll("\0","^0"))}function D(e){return null!==e&&"object"===r(e)}function E(e){return null==e}function g(e,t){var n=k(e),o=k(t),a=n>o?1:n===o?0:-1;if(c.DEBUG){var i=G(n),u=G(o);"object"===r(e)&&(e=JSON.stringify(e),i=JSON.stringify(i)),"object"===r(t)&&(t=JSON.stringify(t),u=JSON.stringify(u)),i!==e&&console.warn(e+" was incorrectly encoded as "+i),u!==t&&console.warn(t+" was incorrectly encoded as "+u)}return a}var h={invalid:100,number:200,date:300,string:400,binary:500,array:600},N=Object.keys(h);N.forEach((function(e){h[e]=String.fromCodePoint(h[e])}));var I=N.reduce((function(e,r){return e[h[r]]=r,e}),{}),O=["negativeInfinity","bigNegative","smallNegative","smallPositive","bigPositive","positiveInfinity"],A={invalid:{encode:function(e){return h.invalid+"-"},decode:function(e){}},number:{encode:function(e){var r,t,n,o=e===Number.MIN_VALUE?"0."+"0".repeat(214)+"2":Math.abs(e).toString(32),a=o.indexOf("."),i=(o=-1!==a?o.replace(".",""):o).search(/(?:[\0-\/1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/);return o=o.slice(i),Number.isFinite(Number(e))?e<0?e>-1?(r=O.indexOf("smallNegative"),t=_(i),n=R(w(o))):(r=O.indexOf("bigNegative"),t=R(_(-1!==a?a:o.length)),n=R(w(o))):e<1?(r=O.indexOf("smallPositive"),t=R(_(i)),n=w(o)):(r=O.indexOf("bigPositive"),t=_(-1!==a?a:o.length),n=w(o)):(t=C(2),n=C(11),r=O.indexOf(e>0?"positiveInfinity":"negativeInfinity")),h.number+"-"+r+t+n},decode:function(e){var r=Number(e.slice(2,3)),t=e.slice(3,5),n=e.slice(5,16);switch(O[r]){case"negativeInfinity":return Number.NEGATIVE_INFINITY;case"positiveInfinity":return Number.POSITIVE_INFINITY;case"bigPositive":return S(n,t);case"smallPositive":return S(n,t=B(R(t)));case"smallNegative":return t=B(t),-S(n=R(n),t);case"bigNegative":return t=R(t),-S(n=R(n),t);default:throw new Error("Invalid number.")}}},string:{encode:function(e,r){return r&&(e=e.replaceAll(/((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))/g,"-$1")+" "),h.string+"-"+e},decode:function(e,r){return e=e.slice(2),r&&(e=e.slice(0,-1).replaceAll(/\x2D((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))/g,"$1")),e}},array:{encode:function(e){var r,n=[],o=i(e.entries());try{for(o.s();!(r=o.n()).done;){var a=t(r.value,2),u=a[0],c=k(a[1],!0);n[u]=c}}catch(e){o.e(e)}finally{o.f()}return n.push(h.invalid+"-"),h.array+"-"+JSON.stringify(n)},decode:function(e){var r=JSON.parse(e.slice(2));r.pop();for(var t=0;t<r.length;t++){var n=G(r[t],!0);r[t]=n}return r}},date:{encode:function(e){return h.date+"-"+e.toJSON()},decode:function(e){return new Date(e.slice(2))}},binary:{encode:function(e){return h.binary+"-"+(e.byteLength?n(M(e)).map((function(e){return String(e).padStart(3,"0")})):"")},decode:function(e){var r=e.slice(2),t=r.length?r.split(",").map((function(e){return Number.parseInt(e)})):[],n=new ArrayBuffer(t.length);return new Uint8Array(n).set(t),n}}};function _(e){var r=e.toString(32);return 1===r.length?"0"+r:r}function w(e){return(e+C(11)).slice(0,11)}function R(e){var r,t="",n=i(e);try{for(n.s();!(r=n.n()).done;){var o=r.value;t+=(31-Number.parseInt(o,32)).toString(32)}}catch(e){n.e(e)}finally{n.f()}return t}function S(e,r){var t=Number.parseInt(r,32);if(t<0)return T(Number.parseInt(e,32)*Math.pow(32,t-10));if(t<11){var n=e.slice(0,t),o=Number.parseInt(n,32),a=e.slice(t);return T(o+Number.parseInt(a,32)*Math.pow(32,t-11))}var i=e+C(t-11);return Number.parseInt(i,32)}function T(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16;return Number.parseFloat(e.toPrecision(r))}function C(e){return"0".repeat(e)}function B(e){return"-"+e}function P(e){if(Array.isArray(e))return"array";if(function(e){return D(e)&&"getDate"in e&&"function"==typeof e.getDate}(e))return"date";if(function(e){return D(e)&&"byteLength"in e&&"number"==typeof e.byteLength&&("slice"in e&&"function"==typeof e.slice||"getFloat64"in e&&"function"==typeof e.getFloat64)}(e))return"binary";var t=r(e);return["string","number"].includes(t)?t:"invalid"}function j(e,r){return x(e,r,!1,!0)}function M(e){var r=0,t=0;if(ArrayBuffer.isView(e)){if(void 0===e.buffer)throw new TypeError("Could not copy the bytes held by a buffer source as the buffer was undefined.");r=e.byteOffset,t=e.byteLength}else t=e.byteLength;return new Uint8Array("buffer"in e&&e.buffer||e,r,t)}function x(e,t,n,o){if((t=t||[]).includes(e))return{type:"array",invalid:!0,message:"An array key cannot be circular"};var a=P(e),i={type:a,value:e};switch(a){case"number":return Number.isNaN(e)?{type:"NaN",invalid:!0}:Object.is(e,-0)?{type:a,value:0}:i;case"string":return i;case"binary":return{type:"binary",value:M(e)};case"array":var u=e,c=u.length;t.push(e);for(var l=[],f=function(){if(!n&&!Object.hasOwn(u,s))return{v:{type:a,invalid:!0,message:"Does not have own index property"}};try{var e=x(u[s],t,!1,o);if(e.invalid)return n?"continue":{v:{type:a,invalid:!0,message:"Bad array entry value-to-key conversion"}};(!n||!o&&l.every((function(r){return 0!==g(r,e.value)}))||o&&l.every((function(r){return 0!==g(r,e)})))&&l.push(o?e:e.value)}catch(e){if(!n)throw e}},s=0;s<c;s++){var y=f();if("continue"!==y&&"object"===r(y))return y.v}return{type:a,value:l};case"date":var d=e;return Number.isNaN(d.getTime())?{type:a,invalid:!0,message:"Not a valid date"}:o?{type:a,value:d.getTime()}:{type:a,value:new Date(d.getTime())};default:var p=null===e?"null":r(e);return{type:p,invalid:!0,message:"Not a valid key; type "+p}}}function U(e,r){return x(e,null,!0,r)}function L(e,r,t,n){var o=V(e,r);return o.failure?o:t?U(o.value,n):x(o.value,null,!1,n)}function V(e,r,t,n){if(Array.isArray(r)){var o=[];return r.some((function(r){var t=V(e,r);return!!t.failure||(o.push(t.value),!1)}))?{failure:!0}:{value:o}}return""===r?{value:e}:r.split(".").some((function(r,t){if("length"!==r||"string"!=typeof e&&!Array.isArray(e))if(function(e){return D(e)&&"size"in e&&"number"==typeof e.size&&"slice"in e&&"function"==typeof e.slice&&!("lastModified"in e)}(e))switch(r){case"size":case"type":e=e[r]}else{if(!function(e){return D(e)&&"name"in e&&"string"==typeof e.name&&"slice"in e&&"function"==typeof e.slice&&"lastModified"in e}(e))return!D(e)||!Object.hasOwn(e,r)||void 0===(e=e[r]);switch(r){case"name":case"lastModified":e=e[r];break;case"lastModifiedDate":e=new Date(e.lastModified)}}else e=e.length;return!1}))?{failure:!0}:{value:e}}function K(e,r,t){var n=void 0===r.lower,o=void 0===r.upper,a=k(e,!0),i=t?r.__lowerCached:k(r.lower,!0),u=t?r.__upperCached:k(r.upper,!0);return!n&&(r.lowerOpen&&null!==a&&null!==i&&a>i||!r.lowerOpen&&(!a&&!i||null!==a&&null!==i&&a>=i))&&(n=!0),!o&&(r.upperOpen&&null!==a&&null!==u&&a<u||!r.upperOpen&&(!a&&!u||null!==a&&null!==u&&a<=u))&&(o=!0),n&&o}function k(e,r){return void 0===e?null:A[P(e)].encode(e,r)}function G(e,r){if("string"==typeof e)return A[I[e.slice(0,1)]].decode(e,r)}var H=9007199254740992;function q(e,r,t,n){e.executeSql('SELECT "currNum" FROM __sys__ WHERE "name" = ?',[F(r.__currentName)],(function(e,r){1!==r.rows.length?t(1):t(r.rows.item(0).currNum)}),(function(e,r){return n(m("DataError","Could not get the auto increment value for key",r)),!0}))}function J(e,r,t,n,o){var a='UPDATE __sys__ SET "currNum" = ? WHERE "name" = ?',i=[t,F(r.__currentName)];c.DEBUG&&console.log(a,i),e.executeSql(a,i,(function(e,r){n(t)}),(function(e,r){return o(m("UnknownError","Could not set the auto increment value for key",r)),!0}))}function W(e,r,t,n,o){return J(e,r,t=t===H?t+2:t+1,n,o)}e.assignCurrentNumber=J,e.checkKeyCouldBeInjectedIntoValue=function(e,r){var t=r.split(".");t.pop();var n,o=i(t);try{for(o.s();!(n=o.n()).done;){var a=n.value;if(!D(e))return!1;if(!Object.hasOwn(e,a))return!0;e=e[a]}}catch(e){o.e(e)}finally{o.f()}return D(e)},e.convertKeyToValue=function e(r){var t=r.type,n=r.value;switch(t){case"number":case"string":return n;case"array":for(var o=[],a=n.length,i=0;i<a;){var u=e(n[i]);o[i]=u,i++}return o;case"date":return new Date(n);case"binary":var c=n.length,l=new ArrayBuffer(c);return new Uint8Array(l,n.byteOffset||0,n.byteLength).set(n),l;default:throw new Error("Bad key")}},e.convertValueToKey=j,e.convertValueToKeyRethrowingAndIfInvalid=function(e,r){var t=j(e,r);if(t.invalid)throw m("DataError",t.message||"Not a valid key; type: "+t.type);return t},e.convertValueToKeyValueDecoded=x,e.convertValueToMultiEntryKey=function(e){return x(e,null,!0,!0)},e.convertValueToMultiEntryKeyDecoded=U,e.decode=G,e.encode=k,e.evaluateKeyPathOnValue=function(e,r,t){return V(e,r)},e.extractKeyFromValueUsingKeyPath=function(e,r,t){return L(e,r,t,!0)},e.extractKeyValueDecodedFromValueUsingKeyPath=L,e.findMultiEntryMatches=function e(r,t){var n=[];if(Array.isArray(r)){var o,a=i(r);try{for(a.s();!(o=a.n()).done;){var u=o.value;if(Array.isArray(u)){if(t&&t.lower===t.upper)continue;if(1!==u.length){e(u,t).length>0&&n.push(u);continue}u=u[0]}(E(t)||K(u,t,!0))&&n.push(u)}}catch(e){a.e(e)}finally{a.f()}}else(E(t)||K(r,t,!0))&&n.push(r);return n},e.generateKeyForStore=function(e,r,t,n){q(e,r,(function(o){o>H?t("failure"):W(e,r,o,(function(){t(null,o,o)}),n)}),n)},e.injectKeyIntoValueUsingKeyPath=function(e,r,t){var n=t.split("."),o=n.pop();n.forEach((function(r){Object.hasOwn(e,r)||(e[r]={}),e=e[r]})),e[o]=r},e.isKeyInRange=K,e.isMultiEntryMatch=function(e,r){return"array"===I[r.slice(0,1)]?r.indexOf(e)>1:r===e},e.possiblyUpdateKeyGenerator=function(e,r,t,n,o){"number"!=typeof t||t<1?n():q(e,r,(function(a){var i=Math.floor(Math.min(t,H));i>=a?W(e,r,i,(function(){n(a)}),o):n()}),o)},e.roundTrip=function(e,r){return G(k(e,r),r)}}));
|
|
1
|
+
/*! indexeddbshim - v13.0.0 - 12/7/2023 */
|
|
2
|
+
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).IDBKeyUtils={})}(this,(function(e){"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function t(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,a,i,u=[],c=!0,l=!1;try{if(a=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;c=!1}else for(;!(c=(n=a.call(t)).done)&&(u.push(n.value),u.length!==r);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(l)throw o}}return u}}(e,r)||o(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||o(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,r){if(e){if("string"==typeof e)return a(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?a(e,r):void 0}}function a(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function i(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=o(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,c=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return u=e.done,e},e:function(e){c=!0,i=e},f:function(){try{u||null==t.return||t.return()}finally{if(c)throw i}}}}var u={},c={};function l(e,r){return new DOMException.prototype.constructor(r,e||"DOMException")}["DEBUG","cacheDatabaseInstances","autoName","fullIDLSupport","checkOrigin","cursorPreloadPackSize","UnicodeIDStart","UnicodeIDContinue","registerSCA","avoidAutoShim","win","DEFAULT_DB_SIZE","useSQLiteIndexes","fs","addNonIDBGlobals","replaceNonIDBGlobals","escapeDatabaseName","unescapeDatabaseName","databaseCharacterEscapeList","databaseNameLengthLimit","escapeNFDForDatabaseNames","addSQLiteExtension",["memoryDatabase",function(e){if(!/^(?::memory:|file::memory:(\?(?:[\0-"\$-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?(#(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?)?$/.test(e))throw new TypeError('`memoryDatabase` must be the empty string, ":memory:", or a "file::memory:[?queryString][#hash] URL".')}],"deleteDatabaseFiles","databaseBasePath","sysDatabaseBasePath","sqlBusyTimeout","sqlTrace","sqlProfile","createIndexes"].forEach((function(e){var r;if(Array.isArray(e)){var n=t(e,2);e=n[0],r=n[1]}Object.defineProperty(c,e,{get:function(){return u[e]},set:function(t){r&&r(t),u[e]=t}})}));var f={IndexSizeError:1,HierarchyRequestError:3,WrongDocumentError:4,InvalidCharacterError:5,NoModificationAllowedError:7,NotFoundError:8,NotSupportedError:9,InUseAttributeError:10,InvalidStateError:11,SyntaxError:12,InvalidModificationError:13,NamespaceError:14,InvalidAccessError:15,TypeMismatchError:17,SecurityError:18,NetworkError:19,AbortError:20,URLMismatchError:21,QuotaExceededError:22,TimeoutError:23,InvalidNodeTypeError:24,DataCloneError:25,EncodingError:0,NotReadableError:0,UnknownError:0,ConstraintError:0,DataError:0,TransactionInactiveError:0,ReadOnlyError:0,VersionError:0,OperationError:0,NotAllowedError:0},s={INDEX_SIZE_ERR:1,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,INVALID_CHARACTER_ERR:5,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:11,SYNTAX_ERR:12,INVALID_MODIFICATION_ERR:13,NAMESPACE_ERR:14,INVALID_ACCESS_ERR:15,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:17,SECURITY_ERR:18,NETWORK_ERR:19,ABORT_ERR:20,URL_MISMATCH_ERR:21,QUOTA_EXCEEDED_ERR:22,TIMEOUT_ERR:23,INVALID_NODE_TYPE_ERR:24,DATA_CLONE_ERR:25};var y=function(){function e(e,r){this[Symbol.toStringTag]="DOMException",this._code=r in f?f[r]:s[r]||0,this._name=r||"Error",this._message=void 0===e?"":""+e,Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,writable:!0,value:this._code}),void 0!==r&&Object.defineProperty(this,"name",{configurable:!0,enumerable:!0,writable:!0,value:this._name}),void 0!==e&&Object.defineProperty(this,"message",{configurable:!0,enumerable:!1,writable:!0,value:this._message})}var r=function(){};return r.prototype=Object.create(Error.prototype),["name","message"].forEach((function(t){Object.defineProperty(r.prototype,t,{enumerable:!0,get:function(){if(!(this instanceof e||this instanceof r||this instanceof Error))throw new TypeError("Illegal invocation");return this["name"===t?"_name":"_message"]}})})),Object.defineProperty(r.prototype,"code",{configurable:!0,enumerable:!0,get:function(){throw new TypeError("Illegal invocation")}}),e.prototype=new r,e.prototype[Symbol.toStringTag]="DOMExceptionPrototype",Object.defineProperty(e,"prototype",{writable:!1}),Object.keys(f).forEach((function(r){Object.defineProperty(e.prototype,r,{enumerable:!0,configurable:!1,value:f[r]}),Object.defineProperty(e,r,{enumerable:!0,configurable:!1,value:f[r]})})),Object.keys(s).forEach((function(r){Object.defineProperty(e.prototype,r,{enumerable:!0,configurable:!1,value:s[r]}),Object.defineProperty(e,r,{enumerable:!0,configurable:!1,value:s[r]})})),Object.defineProperty(e.prototype,"constructor",{writable:!0,configurable:!0,enumerable:!1,value:e}),e}();function d(e,t,n){if(c.DEBUG){var o=n&&"object"===r(n)&&n.message?n.message:n,a="function"==typeof console.error?"error":"log";console[a](e+": "+t+". "+(o||"")),console.trace&&console.trace()}}var p,v,b=!1;try{p=l("test name","test message"),(v=p)&&"object"===r(v)&&"string"==typeof v.name&&"test name"===p.name&&"test message"===p.message&&(b=!0)}catch(e){}var m=b?function(e,r,t){return d(e,r,t),l(e,r)}:function(e,r,t){return d(e,r,t),function(e,r){return new y(r,e)}(e,r)};function F(e){return function(e){return e.replaceAll(/((?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])))(?!(?:(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))|(^|(?:[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))((?:(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))/g,(function(e,r,t,n){return r?"^2"+r.codePointAt().toString(16).padStart(4,"0"):(t||"")+"^3"+n.codePointAt().toString(16).padStart(4,"0")}))}(e.replaceAll("^","^^").replaceAll("\0","^0"))}function D(e){return null!==e&&"object"===r(e)}function E(e){return null==e}function g(e,t){var n=k(e),o=k(t),a=n>o?1:n===o?0:-1;if(c.DEBUG){var i=G(n),u=G(o);"object"===r(e)&&(e=JSON.stringify(e),i=JSON.stringify(i)),"object"===r(t)&&(t=JSON.stringify(t),u=JSON.stringify(u)),i!==e&&console.warn(e+" was incorrectly encoded as "+i),u!==t&&console.warn(t+" was incorrectly encoded as "+u)}return a}var h={invalid:100,number:200,date:300,string:400,binary:500,array:600},N=Object.keys(h);N.forEach((function(e){h[e]=String.fromCodePoint(h[e])}));var I=N.reduce((function(e,r){return e[h[r]]=r,e}),{}),O=["negativeInfinity","bigNegative","smallNegative","smallPositive","bigPositive","positiveInfinity"],A={invalid:{encode:function(){return h.invalid+"-"},decode:function(){}},number:{encode:function(e){var r,t,n,o=e===Number.MIN_VALUE?"0."+"0".repeat(214)+"2":Math.abs(e).toString(32),a=o.indexOf("."),i=(o=-1!==a?o.replace(".",""):o).search(/(?:[\0-\/1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/);return o=o.slice(i),Number.isFinite(Number(e))?e<0?e>-1?(r=O.indexOf("smallNegative"),t=_(i),n=R(w(o))):(r=O.indexOf("bigNegative"),t=R(_(-1!==a?a:o.length)),n=R(w(o))):e<1?(r=O.indexOf("smallPositive"),t=R(_(i)),n=w(o)):(r=O.indexOf("bigPositive"),t=_(-1!==a?a:o.length),n=w(o)):(t=C(2),n=C(11),r=O.indexOf(e>0?"positiveInfinity":"negativeInfinity")),h.number+"-"+r+t+n},decode:function(e){var r=Number(e.slice(2,3)),t=e.slice(3,5),n=e.slice(5,16);switch(O[r]){case"negativeInfinity":return Number.NEGATIVE_INFINITY;case"positiveInfinity":return Number.POSITIVE_INFINITY;case"bigPositive":return S(n,t);case"smallPositive":return S(n,t=B(R(t)));case"smallNegative":return t=B(t),-S(n=R(n),t);case"bigNegative":return t=R(t),-S(n=R(n),t);default:throw new Error("Invalid number.")}}},string:{encode:function(e,r){return r&&(e=e.replaceAll(/((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))/g,"-$1")+" "),h.string+"-"+e},decode:function(e,r){return e=e.slice(2),r&&(e=e.slice(0,-1).replaceAll(/\x2D((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))/g,"$1")),e}},array:{encode:function(e){var r,n=[],o=i(e.entries());try{for(o.s();!(r=o.n()).done;){var a=t(r.value,2),u=a[0],c=k(a[1],!0);n[u]=c}}catch(e){o.e(e)}finally{o.f()}return n.push(h.invalid+"-"),h.array+"-"+JSON.stringify(n)},decode:function(e){var r=JSON.parse(e.slice(2));r.pop();for(var t=0;t<r.length;t++){var n=G(r[t],!0);r[t]=n}return r}},date:{encode:function(e){return h.date+"-"+e.toJSON()},decode:function(e){return new Date(e.slice(2))}},binary:{encode:function(e){return h.binary+"-"+(e.byteLength?n(j(e)).map((function(e){return String(e).padStart(3,"0")})):"")},decode:function(e){var r=e.slice(2),t=r.length?r.split(",").map((function(e){return Number.parseInt(e)})):[],n=new ArrayBuffer(t.length);return new Uint8Array(n).set(t),n}}};function _(e){var r=e.toString(32);return 1===r.length?"0"+r:r}function w(e){return(e+C(11)).slice(0,11)}function R(e){var r,t="",n=i(e);try{for(n.s();!(r=n.n()).done;){var o=r.value;t+=(31-Number.parseInt(o,32)).toString(32)}}catch(e){n.e(e)}finally{n.f()}return t}function S(e,r){var t=Number.parseInt(r,32);if(t<0)return T(Number.parseInt(e,32)*Math.pow(32,t-10));if(t<11){var n=e.slice(0,t),o=Number.parseInt(n,32),a=e.slice(t);return T(o+Number.parseInt(a,32)*Math.pow(32,t-11))}var i=e+C(t-11);return Number.parseInt(i,32)}function T(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16;return Number.parseFloat(e.toPrecision(r))}function C(e){return"0".repeat(e)}function B(e){return"-"+e}function P(e){if(Array.isArray(e))return"array";if(function(e){return D(e)&&"getDate"in e&&"function"==typeof e.getDate}(e))return"date";if(function(e){return D(e)&&"byteLength"in e&&"number"==typeof e.byteLength&&("slice"in e&&"function"==typeof e.slice||"getFloat64"in e&&"function"==typeof e.getFloat64)}(e))return"binary";var t=r(e);return["string","number"].includes(t)?t:"invalid"}function M(e,r){return x(e,r,!1,!0)}function j(e){var r=0,t=0;if(ArrayBuffer.isView(e)){if(void 0===e.buffer)throw new TypeError("Could not copy the bytes held by a buffer source as the buffer was undefined.");r=e.byteOffset,t=e.byteLength}else t=e.byteLength;return new Uint8Array("buffer"in e&&e.buffer||e,r,t)}function x(e,t,n,o){if((t=t||[]).includes(e))return{type:"array",invalid:!0,message:"An array key cannot be circular"};var a=P(e),i={type:a,value:e};switch(a){case"number":return Number.isNaN(e)?{type:"NaN",invalid:!0}:Object.is(e,-0)?{type:a,value:0}:i;case"string":return i;case"binary":return{type:"binary",value:j(e)};case"array":var u=e,c=u.length;t.push(e);for(var l,f=[],s=function(){if(!n&&!Object.hasOwn(u,y))return{v:{type:a,invalid:!0,message:"Does not have own index property"}};try{var e=x(u[y],t,!1,o);if(e.invalid)return n?0:{v:{type:a,invalid:!0,message:"Bad array entry value-to-key conversion"}};(!n||!o&&f.every((function(r){return 0!==g(r,e.value)}))||o&&f.every((function(r){return 0!==g(r,e)})))&&f.push(o?e:e.value)}catch(e){if(!n)throw e}},y=0;y<c;y++)if(0!==(l=s())&&l)return l.v;return{type:a,value:f};case"date":var d=e;return Number.isNaN(d.getTime())?{type:a,invalid:!0,message:"Not a valid date"}:o?{type:a,value:d.getTime()}:{type:a,value:new Date(d.getTime())};default:var p=null===e?"null":r(e);return{type:p,invalid:!0,message:"Not a valid key; type "+p}}}function U(e,r){return x(e,null,!0,r)}function L(e,r,t,n){var o=V(e,r);return o.failure?o:t?U(o.value,n):x(o.value,null,!1,n)}function V(e,r,t,n){if(Array.isArray(r)){var o=[];return r.some((function(r){var t=V(e,r);return!!t.failure||(o.push(t.value),!1)}))?{failure:!0}:{value:o}}return""===r?{value:e}:r.split(".").some((function(r){if("length"!==r||"string"!=typeof e&&!Array.isArray(e))if(function(e){return D(e)&&"size"in e&&"number"==typeof e.size&&"slice"in e&&"function"==typeof e.slice&&!("lastModified"in e)}(e))switch(r){case"size":case"type":e=e[r]}else{if(!function(e){return D(e)&&"name"in e&&"string"==typeof e.name&&"slice"in e&&"function"==typeof e.slice&&"lastModified"in e}(e))return!D(e)||!Object.hasOwn(e,r)||void 0===(e=e[r]);switch(r){case"name":case"lastModified":e=e[r];break;case"lastModifiedDate":e=new Date(e.lastModified)}}else e=e.length;return!1}))?{failure:!0}:{value:e}}function K(e,r,t){var n=void 0===r.lower,o=void 0===r.upper,a=k(e,!0),i=t?r.__lowerCached:k(r.lower,!0),u=t?r.__upperCached:k(r.upper,!0);return!n&&(r.lowerOpen&&null!==a&&null!==i&&a>i||!r.lowerOpen&&(!a&&!i||null!==a&&null!==i&&a>=i))&&(n=!0),!o&&(r.upperOpen&&null!==a&&null!==u&&a<u||!r.upperOpen&&(!a&&!u||null!==a&&null!==u&&a<=u))&&(o=!0),n&&o}function k(e,r){return void 0===e?null:A[P(e)].encode(e,r)}function G(e,r){if("string"==typeof e)return A[I[e.slice(0,1)]].decode(e,r)}var H=9007199254740992;function q(e,r,t,n){e.executeSql('SELECT "currNum" FROM __sys__ WHERE "name" = ?',[F(r.__currentName)],(function(e,r){1!==r.rows.length?t(1):t(r.rows.item(0).currNum)}),(function(e,r){return n(m("DataError","Could not get the auto increment value for key",r)),!1}))}function J(e,r,t,n,o){var a='UPDATE __sys__ SET "currNum" = ? WHERE "name" = ?',i=[t,F(r.__currentName)];c.DEBUG&&console.log(a,i),e.executeSql(a,i,(function(){n(t)}),(function(e,r){return o(m("UnknownError","Could not set the auto increment value for key",r)),!1}))}function W(e,r,t,n,o){return J(e,r,t=t===H?t+2:t+1,n,o)}e.assignCurrentNumber=J,e.checkKeyCouldBeInjectedIntoValue=function(e,r){var t=r.split(".");t.pop();var n,o=i(t);try{for(o.s();!(n=o.n()).done;){var a=n.value;if(!D(e))return!1;if(!Object.hasOwn(e,a))return!0;e=e[a]}}catch(e){o.e(e)}finally{o.f()}return D(e)},e.convertKeyToValue=function e(r){var t=r.type,n=r.value;switch(t){case"number":case"string":return n;case"array":for(var o=[],a=n.length,i=0;i<a;){var u=e(n[i]);o[i]=u,i++}return o;case"date":return new Date(n);case"binary":var c=n.length,l=new ArrayBuffer(c);return new Uint8Array(l,n.byteOffset||0,n.byteLength).set(n),l;default:throw new Error("Bad key")}},e.convertValueToKey=M,e.convertValueToKeyRethrowingAndIfInvalid=function(e,r){var t=M(e,r);if(t.invalid)throw m("DataError",t.message||"Not a valid key; type: "+t.type);return t},e.convertValueToKeyValueDecoded=x,e.convertValueToMultiEntryKey=function(e){return x(e,null,!0,!0)},e.convertValueToMultiEntryKeyDecoded=U,e.decode=G,e.encode=k,e.evaluateKeyPathOnValue=function(e,r,t){return V(e,r)},e.extractKeyFromValueUsingKeyPath=function(e,r,t){return L(e,r,t,!0)},e.extractKeyValueDecodedFromValueUsingKeyPath=L,e.findMultiEntryMatches=function e(r,t){var n=[];if(Array.isArray(r)){var o,a=i(r);try{for(a.s();!(o=a.n()).done;){var u=o.value;if(Array.isArray(u)){if(t&&t.lower===t.upper)continue;if(1!==u.length){e(u,t).length>0&&n.push(u);continue}u=u[0]}(E(t)||K(u,t,!0))&&n.push(u)}}catch(e){a.e(e)}finally{a.f()}}else(E(t)||K(r,t,!0))&&n.push(r);return n},e.generateKeyForStore=function(e,r,t,n){q(e,r,(function(o){o>H?t("failure"):W(e,r,o,(function(){t(null,o,o)}),n)}),n)},e.injectKeyIntoValueUsingKeyPath=function(e,r,t){var n=t.split("."),o=n.pop();n.forEach((function(r){Object.hasOwn(e,r)||(e[r]={}),e=e[r]})),e[o]=r},e.isKeyInRange=K,e.isMultiEntryMatch=function(e,r){return"array"===I[r.slice(0,1)]?r.indexOf(e)>1:r===e},e.possiblyUpdateKeyGenerator=function(e,r,t,n,o){"number"!=typeof t||t<1?n():q(e,r,(function(a){var i=Math.floor(Math.min(t,H));i>=a?W(e,r,i,(function(){n(a)}),o):n()}),o)},e.roundTrip=function(e,r){return G(k(e,r),r)}}));
|
|
3
3
|
//# sourceMappingURL=indexeddbshim-Key.min.js.map
|