indexeddbshim 10.1.0 → 11.0.0-beta.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/dist/indexeddbshim-Key.js +32 -29
- 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.js → indexeddbshim-UnicodeIdentifiers-node.cjs} +68 -50
- package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs.map +1 -0
- package/dist/indexeddbshim-UnicodeIdentifiers.js +169 -188
- package/dist/indexeddbshim-UnicodeIdentifiers.js.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers.min.js +2 -8
- package/dist/indexeddbshim-UnicodeIdentifiers.min.js.map +1 -1
- package/dist/{indexeddbshim-node.js → indexeddbshim-node.cjs} +66 -48
- package/dist/indexeddbshim-node.cjs.map +1 -0
- package/dist/indexeddbshim-noninvasive.js +167 -186
- package/dist/indexeddbshim-noninvasive.js.map +1 -1
- package/dist/indexeddbshim-noninvasive.min.js +2 -8
- package/dist/indexeddbshim-noninvasive.min.js.map +1 -1
- package/dist/indexeddbshim.js +167 -186
- package/dist/indexeddbshim.js.map +1 -1
- package/dist/indexeddbshim.min.js +2 -8
- package/dist/indexeddbshim.min.js.map +1 -1
- package/package.json +51 -37
- package/src/IDBTransaction.js +1 -0
- package/src/node-UnicodeIdentifiers.js +2 -3
- package/src/node.js +2 -3
- package/dist/indexeddbshim-UnicodeIdentifiers-node.js.map +0 -1
- package/dist/indexeddbshim-node.js.map +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! indexeddbshim - v10.
|
|
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:(\?(?:(?!#)[\s\S])*)?(#(?:[\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"].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["_"+t]}})})),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,r,t){if(c.DEBUG){t&&t.message&&(t=t.message);var n="function"==typeof console.error?"error":"log";console[n](e+": "+r+". "+(t||"")),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 E(e){return function(e){return e.replace(/((?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])))(?!(?:(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))|(^|(?:(?)[\s\S]))((?:(?:[^\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.replace(/\^/g,"^^").replace(/\0/g,"^0"))}function h(e){return e&&"object"===r(e)}function g(e){return null==e}function D(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 F={invalid:100,number:200,date:300,string:400,binary:500,array:600},N=Object.keys(F);N.forEach((function(e){F[e]=String.fromCodePoint(F[e])}));var I=N.reduce((function(e,r){return e[F[r]]=r,e}),{}),O=["negativeInfinity","bigNegative","smallNegative","smallPositive","bigPositive","positiveInfinity"],w={invalid:{encode:function(e){return F.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)[\s\S])/);return o=o.slice(i),Number.isFinite(Number(e))?e<0?e>-1?(r=O.indexOf("smallNegative"),t=A(i),n=_(S(o))):(r=O.indexOf("bigNegative"),t=_(A(-1!==a?a:o.length)),n=_(S(o))):e<1?(r=O.indexOf("smallPositive"),t=_(A(i)),n=S(o)):(r=O.indexOf("bigPositive"),t=A(-1!==a?a:o.length),n=S(o)):(t=C(2),n=C(11),r=O.indexOf(e>0?"positiveInfinity":"negativeInfinity")),F.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 R(n,t);case"smallPositive":return R(n,t=P(_(t)));case"smallNegative":return t=P(t),-R(n=_(n),t);case"bigNegative":return t=_(t),-R(n=_(n),t);default:throw new Error("Invalid number.")}}},string:{encode:function(e,r){return r&&(e=e.replace(/((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))/g,"-$1")+" "),F.string+"-"+e},decode:function(e,r){return e=e.slice(2),r&&(e=e.slice(0,-1).replace(/\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(F.invalid+"-"),F.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 F.date+"-"+e.toJSON()},decode:function(e){return new Date(e.slice(2))}},binary:{encode:function(e){return F.binary+"-"+(e.byteLength?n(B(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 A(e){return 1===(e=e.toString(32)).length?"0"+e:e}function S(e){return(e+C(11)).slice(0,11)}function _(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 R(e,r){if((r=Number.parseInt(r,32))<0)return T(Number.parseInt(e,32)*Math.pow(32,r-10));if(r<11){var t=e.slice(0,r);t=Number.parseInt(t,32);var n=e.slice(r);return T(t+(n=Number.parseInt(n,32)*Math.pow(32,r-11)))}var o=e+C(r-11);return Number.parseInt(o,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 P(e){return"-"+e}function M(e){if(Array.isArray(e))return"array";if(function(e){return h(e)&&"function"==typeof e.getDate}(e))return"date";if(function(e){return h(e)&&"number"==typeof e.byteLength&&("function"==typeof e.slice||"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 B(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(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=M(e),i={type:a,value:e};switch(a){case"number":return Number.isNaN(e)?{type:"NaN",invalid:!0}:i;case"string":return i;case"binary":return{type:"binary",value:B(e)};case"array":var u=e.length;t.push(e);for(var c=[],l=0;l<u;l++){if(!n&&!Object.prototype.hasOwnProperty.call(e,l))return{type:a,invalid:!0,message:"Does not have own index property"};try{var f=function(){var r=x(e[l],t,!1,o);if(r.invalid)return n?"continue":{v:{type:a,invalid:!0,message:"Bad array entry value-to-key conversion"}};(!n||!o&&c.every((function(e){return 0!==D(e,r.value)}))||o&&c.every((function(e){return 0!==D(e,r)})))&&c.push(o?r:r.value)}();if("continue"===f)continue;if("object"===r(f))return f.v}catch(e){if(!n)throw e}}return{type:a,value:c};case"date":return Number.isNaN(e.getTime())?{type:a,invalid:!0,message:"Not a valid date"}:o?{type:a,value:e.getTime()}:{type:a,value:new Date(e.getTime())};default:var s=null===e?"null":r(e);return{type:s,invalid:!0,message:"Not a valid key; type "+s}}}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 h(e)&&"number"==typeof e.size&&"function"==typeof e.slice&&!("lastModified"in e)}(e))switch(r){case"size":case"type":e=e[r]}else{if(!function(e){return h(e)&&"string"==typeof e.name&&"function"==typeof e.slice&&"lastModified"in e}(e))return!h(e)||!Object.prototype.hasOwnProperty.call(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 void 0!==r.lower&&(r.lowerOpen&&a>i&&(n=!0),!r.lowerOpen&&a>=i&&(n=!0)),void 0!==r.upper&&(r.upperOpen&&a<u&&(o=!0),!r.upperOpen&&a<=u&&(o=!0)),n&&o}function k(e,r){return void 0===e?null:w[M(e)].encode(e,r)}function G(e,r){if("string"==typeof e)return w[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" = ?',[E(r.__currentName)],(function(e,r){1!==r.rows.length?t(1):t(r.rows.item(0).currNum)}),(function(e,r){n(m("DataError","Could not get the auto increment value for key",r))}))}function J(e,r,t,n,o){var a='UPDATE __sys__ SET "currNum" = ? WHERE "name" = ?',i=[t,E(r.__currentName)];c.DEBUG&&console.log(a,i),e.executeSql(a,i,(function(e,r){n(t)}),(function(e,r){o(m("UnknownError","Could not set the auto increment value for key",r))}))}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(!h(e))return!1;if(!Object.prototype.hasOwnProperty.call(e,a))return!0;e=e[a]}}catch(e){o.e(e)}finally{o.f()}return h(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]}(g(t)||K(u,t,!0))&&n.push(u)}}catch(e){a.e(e)}finally{a.f()}}else(g(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.prototype.hasOwnProperty.call(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 - v10.1.0 - 1/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:(\?(?:(?!#)[\s\S])*)?(#(?:[\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"].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["_"+t]}})})),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,r,t){if(c.DEBUG){t&&t.message&&(t=t.message);var n="function"==typeof console.error?"error":"log";console[n](e+": "+r+". "+(t||"")),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 E(e){return function(e){return e.replace(/((?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])))(?!(?:(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))|(^|(?:(?)[\s\S]))((?:(?:[^\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.replace(/\^/g,"^^").replace(/\0/g,"^0"))}function h(e){return e&&"object"===r(e)}function g(e){return null==e}function D(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 F={invalid:100,number:200,date:300,string:400,binary:500,array:600},N=Object.keys(F);N.forEach((function(e){F[e]=String.fromCodePoint(F[e])}));var I=N.reduce((function(e,r){return e[F[r]]=r,e}),{}),O=["negativeInfinity","bigNegative","smallNegative","smallPositive","bigPositive","positiveInfinity"],w={invalid:{encode:function(e){return F.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)[\s\S])/);return o=o.slice(i),Number.isFinite(Number(e))?e<0?e>-1?(r=O.indexOf("smallNegative"),t=A(i),n=_(S(o))):(r=O.indexOf("bigNegative"),t=_(A(-1!==a?a:o.length)),n=_(S(o))):e<1?(r=O.indexOf("smallPositive"),t=_(A(i)),n=S(o)):(r=O.indexOf("bigPositive"),t=A(-1!==a?a:o.length),n=S(o)):(t=C(2),n=C(11),r=O.indexOf(e>0?"positiveInfinity":"negativeInfinity")),F.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 R(n,t);case"smallPositive":return R(n,t=P(_(t)));case"smallNegative":return t=P(t),-R(n=_(n),t);case"bigNegative":return t=_(t),-R(n=_(n),t);default:throw new Error("Invalid number.")}}},string:{encode:function(e,r){return r&&(e=e.replace(/((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))/g,"-$1")+" "),F.string+"-"+e},decode:function(e,r){return e=e.slice(2),r&&(e=e.slice(0,-1).replace(/\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(F.invalid+"-"),F.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 F.date+"-"+e.toJSON()},decode:function(e){return new Date(e.slice(2))}},binary:{encode:function(e){return F.binary+"-"+(e.byteLength?n(B(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 A(e){return 1===(e=e.toString(32)).length?"0"+e:e}function S(e){return(e+C(11)).slice(0,11)}function _(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 R(e,r){if((r=Number.parseInt(r,32))<0)return T(Number.parseInt(e,32)*Math.pow(32,r-10));if(r<11){var t=e.slice(0,r);t=Number.parseInt(t,32);var n=e.slice(r);return T(t+(n=Number.parseInt(n,32)*Math.pow(32,r-11)))}var o=e+C(r-11);return Number.parseInt(o,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 P(e){return"-"+e}function M(e){if(Array.isArray(e))return"array";if(function(e){return h(e)&&"function"==typeof e.getDate}(e))return"date";if(function(e){return h(e)&&"number"==typeof e.byteLength&&("function"==typeof e.slice||"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 B(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(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=M(e),i={type:a,value:e};switch(a){case"number":return Number.isNaN(e)?{type:"NaN",invalid:!0}:i;case"string":return i;case"binary":return{type:"binary",value:B(e)};case"array":var u=e.length;t.push(e);for(var c=[],l=function(){if(!n&&!Object.prototype.hasOwnProperty.call(e,f))return{v:{type:a,invalid:!0,message:"Does not have own index property"}};try{var r=x(e[f],t,!1,o);if(r.invalid)return n?"continue":{v:{type:a,invalid:!0,message:"Bad array entry value-to-key conversion"}};(!n||!o&&c.every((function(e){return 0!==D(e,r.value)}))||o&&c.every((function(e){return 0!==D(e,r)})))&&c.push(o?r:r.value)}catch(e){if(!n)throw e}},f=0;f<u;f++){var s=l();if("continue"!==s&&"object"===r(s))return s.v}return{type:a,value:c};case"date":return Number.isNaN(e.getTime())?{type:a,invalid:!0,message:"Not a valid date"}:o?{type:a,value:e.getTime()}:{type:a,value:new Date(e.getTime())};default:var y=null===e?"null":r(e);return{type:y,invalid:!0,message:"Not a valid key; type "+y}}}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 h(e)&&"number"==typeof e.size&&"function"==typeof e.slice&&!("lastModified"in e)}(e))switch(r){case"size":case"type":e=e[r]}else{if(!function(e){return h(e)&&"string"==typeof e.name&&"function"==typeof e.slice&&"lastModified"in e}(e))return!h(e)||!Object.prototype.hasOwnProperty.call(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 void 0!==r.lower&&(r.lowerOpen&&a>i&&(n=!0),!r.lowerOpen&&a>=i&&(n=!0)),void 0!==r.upper&&(r.upperOpen&&a<u&&(o=!0),!r.upperOpen&&a<=u&&(o=!0)),n&&o}function k(e,r){return void 0===e?null:w[M(e)].encode(e,r)}function G(e,r){if("string"==typeof e)return w[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" = ?',[E(r.__currentName)],(function(e,r){1!==r.rows.length?t(1):t(r.rows.item(0).currNum)}),(function(e,r){n(m("DataError","Could not get the auto increment value for key",r))}))}function J(e,r,t,n,o){var a='UPDATE __sys__ SET "currNum" = ? WHERE "name" = ?',i=[t,E(r.__currentName)];c.DEBUG&&console.log(a,i),e.executeSql(a,i,(function(e,r){n(t)}),(function(e,r){o(m("UnknownError","Could not set the auto increment value for key",r))}))}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(!h(e))return!1;if(!Object.prototype.hasOwnProperty.call(e,a))return!0;e=e[a]}}catch(e){o.e(e)}finally{o.f()}return h(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]}(g(t)||K(u,t,!0))&&n.push(u)}}catch(e){a.e(e)}finally{a.f()}}else(g(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.prototype.hasOwnProperty.call(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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexeddbshim-Key.min.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"indexeddbshim-Key.min.js","sources":["../src/CFG.js","../src/DOMException.js","../src/util.js","../src/cmp.js","../src/Key.js"],"sourcesContent":["const map = {};\nconst CFG = {};\n\n[\n // Boolean for verbose reporting\n 'DEBUG', // Effectively defaults to false (ignored unless `true`)\n\n // Boolean (effectively defaults to true) on whether to cache WebSQL\n // `openDatabase` instances\n 'cacheDatabaseInstances',\n\n // Boolean on whether to auto-name databases (based on an\n // auto-increment) when the empty string is supplied; useful with\n // `memoryDatabase`; defaults to `false` which means the empty string\n // will be used as the (valid) database name\n 'autoName',\n\n // Determines whether the slow-performing `Object.setPrototypeOf`\n // calls required for full WebIDL compliance will be used. Probably\n // only needed for testing or environments where full introspection\n // on class relationships is required; see\n // http://stackoverflow.com/questions/41927589/rationales-consequences-of-webidl-class-inheritance-requirements\n 'fullIDLSupport', // Effectively defaults to false (ignored unless `true`)\n\n // Boolean on whether to perform origin checks in `IDBFactory` methods\n // Effectively defaults to `true` (must be set to `false` to cancel checks)\n 'checkOrigin',\n\n // Used by `IDBCursor` continue methods for number of records to cache;\n // Defaults to 100\n 'cursorPreloadPackSize',\n\n // See optional API (`shimIndexedDB.__setUnicodeIdentifiers`);\n // or just use the Unicode builds which invoke this method\n // automatically using the large, fully spec-compliant, regular\n // expression strings of `src/UnicodeIdentifiers.js`)\n // In the non-Unicode builds, defaults to /[$A-Z_a-z]/\n 'UnicodeIDStart',\n // In the non-Unicode builds, defaults to /[$0-9A-Z_a-z]/\n 'UnicodeIDContinue',\n\n // Used by SCA.js for optional restructuring of typeson-registry\n // Structured Cloning Algorithm; should only be needed for ensuring data\n // created in 3.* versions of IndexedDBShim continue to work; see the\n // library `typeson-registry-sca-reverter` to get a function to do this\n 'registerSCA',\n\n // BROWSER-SPECIFIC CONFIG\n 'avoidAutoShim', // Where WebSQL is detected but where `indexedDB` is\n // missing or poor support is known (non-Chrome Android or\n // non-Safari iOS9), the shim will be auto-applied without\n // `shimIndexedDB.__useShim()`. Set this to `true` to avoid forcing\n // the shim for such cases.\n\n // -----------SQL CONFIG----------\n // Object (`window` in the browser) on which there may be an\n // `openDatabase` method (if any) for WebSQL. (The browser\n // throws if attempting to call `openDatabase` without the window\n // so this is why the config doesn't just allow the function.)\n // Defaults to `window` or `self` in browser builds or\n // a singleton object with the `openDatabase` method set to\n // the \"websql\" package in Node.\n 'win',\n\n // For internal `openDatabase` calls made by `IDBFactory` methods;\n // per the WebSQL spec, \"User agents are expected to use the display name\n // and the estimated database size to optimize the user experience.\n // For example, a user agent could use the estimated size to suggest an\n // initial quota to the user. This allows a site that is aware that it\n // will try to use hundreds of megabytes to declare this upfront, instead\n // of the user agent prompting the user for permission to increase the\n // quota every five megabytes.\"\n // Defaults to (4 * 1024 * 1024) or (25 * 1024 * 1024) in Safari\n 'DEFAULT_DB_SIZE',\n // Whether to create indexes on SQLite tables (and also whether to try\n // dropping)\n // Effectively defaults to `false` (ignored unless `true`)\n 'useSQLiteIndexes',\n\n // NODE-IMPINGING SETTINGS (created for sake of limitations in Node\n // or desktop file system implementation but applied by default in\n // browser for parity)\n\n // File system module with `unlink` to remove deleted database files\n 'fs',\n\n // Used when setting global shims to determine whether to try to add\n // other globals shimmed by the library (`ShimDOMException`,\n // `ShimDOMStringList`, `ShimEvent`, `ShimCustomEvent`, `ShimEventTarget`)\n // Effectively defaults to `false` (ignored unless `true`)\n 'addNonIDBGlobals',\n // Used when setting global shims to determine whether to try to overwrite\n // other globals shimmed by the library (`DOMException`, `DOMStringList`,\n // `Event`, `CustomEvent`, `EventTarget`)\n // Effectively defaults to `false` (ignored unless `true`)\n 'replaceNonIDBGlobals',\n\n // Overcoming limitations with node-sqlite3/storing database name on\n // file systems\n // https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words\n // Defaults to prefixing database with `D_`, escaping\n // `databaseCharacterEscapeList`, escaping NUL, and\n // escaping upper case letters, as well as enforcing\n // `databaseNameLengthLimit`\n 'escapeDatabaseName',\n // Not used internally; usable as a convenience method\n 'unescapeDatabaseName',\n\n // Defaults to global regex representing the following\n // (characters nevertheless commonly reserved in modern,\n // Unicode-supporting systems): 0x00-0x1F 0x7F \" * / : < > ? \\ |\n 'databaseCharacterEscapeList',\n // Defaults to 254 (shortest typical modern file length limit)\n 'databaseNameLengthLimit',\n\n // Boolean defaulting to true on whether to escape NFD-escaping\n // characters to avoid clashes on MacOS which performs NFD on files\n 'escapeNFDForDatabaseNames',\n\n // Boolean on whether to add the `.sqlite` extension to file names;\n // defaults to `true`\n 'addSQLiteExtension',\n // Various types of in-memory databases that can auto-delete\n ['memoryDatabase', (val) => {\n if (!(/^(?::memory:|file::memory:(\\?[^#]*)?(#.*)?)?$/u).test(val)) {\n throw new TypeError(\n '`memoryDatabase` must be the empty string, \":memory:\", or a ' +\n '\"file::memory:[?queryString][#hash] URL\".'\n );\n }\n }],\n\n // NODE-SPECIFIC CONFIG\n // Boolean on whether to delete the database file itself after\n // `deleteDatabase`; defaults to `true` as the database will be empty\n 'deleteDatabaseFiles',\n 'databaseBasePath',\n 'sysDatabaseBasePath',\n\n // NODE-SPECIFIC WEBSQL CONFIG\n 'sqlBusyTimeout', // Defaults to 1000\n 'sqlTrace', // Callback not used by default\n 'sqlProfile' // Callback not used by default\n].forEach((prop) => {\n let validator;\n if (Array.isArray(prop)) {\n [prop, validator] = prop;\n }\n Object.defineProperty(CFG, prop, {\n get () {\n return map[prop];\n },\n set (val) {\n if (validator) {\n validator(val);\n }\n map[prop] = val;\n }\n });\n});\n\nexport default CFG;\n","/* globals DOMException */\nimport CFG from './CFG.js';\n\n/**\n * Creates a native DOMException, for browsers that support it.\n * @param {string} name\n * @param {string} message\n * @returns {DOMException}\n */\nfunction createNativeDOMException (name, message) {\n return new DOMException.prototype.constructor(\n message,\n name || 'DOMException'\n );\n}\n\n// From web-platform-tests testharness.js name_code_map (though not in new spec)\nconst codes = {\n IndexSizeError: 1,\n HierarchyRequestError: 3,\n WrongDocumentError: 4,\n InvalidCharacterError: 5,\n NoModificationAllowedError: 7,\n NotFoundError: 8,\n NotSupportedError: 9,\n InUseAttributeError: 10,\n InvalidStateError: 11,\n SyntaxError: 12,\n InvalidModificationError: 13,\n NamespaceError: 14,\n InvalidAccessError: 15,\n TypeMismatchError: 17,\n SecurityError: 18,\n NetworkError: 19,\n AbortError: 20,\n URLMismatchError: 21,\n QuotaExceededError: 22,\n TimeoutError: 23,\n InvalidNodeTypeError: 24,\n DataCloneError: 25,\n\n EncodingError: 0,\n NotReadableError: 0,\n UnknownError: 0,\n ConstraintError: 0,\n DataError: 0,\n TransactionInactiveError: 0,\n ReadOnlyError: 0,\n VersionError: 0,\n OperationError: 0,\n NotAllowedError: 0\n};\n\nconst legacyCodes = {\n INDEX_SIZE_ERR: 1,\n DOMSTRING_SIZE_ERR: 2,\n HIERARCHY_REQUEST_ERR: 3,\n WRONG_DOCUMENT_ERR: 4,\n INVALID_CHARACTER_ERR: 5,\n NO_DATA_ALLOWED_ERR: 6,\n NO_MODIFICATION_ALLOWED_ERR: 7,\n NOT_FOUND_ERR: 8,\n NOT_SUPPORTED_ERR: 9,\n INUSE_ATTRIBUTE_ERR: 10,\n INVALID_STATE_ERR: 11,\n SYNTAX_ERR: 12,\n INVALID_MODIFICATION_ERR: 13,\n NAMESPACE_ERR: 14,\n INVALID_ACCESS_ERR: 15,\n VALIDATION_ERR: 16,\n TYPE_MISMATCH_ERR: 17,\n SECURITY_ERR: 18,\n NETWORK_ERR: 19,\n ABORT_ERR: 20,\n URL_MISMATCH_ERR: 21,\n QUOTA_EXCEEDED_ERR: 22,\n TIMEOUT_ERR: 23,\n INVALID_NODE_TYPE_ERR: 24,\n DATA_CLONE_ERR: 25\n};\n\n/**\n *\n * @returns {DOMException}\n */\nfunction createNonNativeDOMExceptionClass () {\n function DOMException (message, name) {\n // const err = Error.prototype.constructor.call(this, message); // Any use to this? Won't set this.message\n this[Symbol.toStringTag] = 'DOMException';\n this._code = name in codes ? codes[name] : (legacyCodes[name] || 0);\n this._name = name || 'Error';\n // We avoid `String()` in this next line as it converts Symbols\n this._message = message === undefined ? '' : ('' + message); // eslint-disable-line no-implicit-coercion\n Object.defineProperty(this, 'code', {\n configurable: true,\n enumerable: true,\n writable: true,\n value: this._code\n });\n if (name !== undefined) {\n Object.defineProperty(this, 'name', {\n configurable: true,\n enumerable: true,\n writable: true,\n value: this._name\n });\n }\n if (message !== undefined) {\n Object.defineProperty(this, 'message', {\n configurable: true,\n enumerable: false,\n writable: true,\n value: this._message\n });\n }\n }\n\n // Necessary for W3C tests which complains if `DOMException` has properties on its \"own\" prototype\n\n // class DummyDOMException extends Error {}; // Sometimes causing problems in Node\n // eslint-disable-next-line func-name-matching\n const DummyDOMException = function DOMException () { /* */ };\n DummyDOMException.prototype = Object.create(Error.prototype); // Intended for subclassing\n ['name', 'message'].forEach((prop) => {\n Object.defineProperty(DummyDOMException.prototype, prop, {\n enumerable: true,\n get () {\n if (!(this instanceof DOMException ||\n this instanceof DummyDOMException ||\n this instanceof Error)) {\n throw new TypeError('Illegal invocation');\n }\n return this['_' + prop];\n }\n });\n });\n // DOMException uses the same `toString` as `Error`\n Object.defineProperty(DummyDOMException.prototype, 'code', {\n configurable: true,\n enumerable: true,\n get () {\n throw new TypeError('Illegal invocation');\n }\n });\n DOMException.prototype = new DummyDOMException();\n\n DOMException.prototype[Symbol.toStringTag] = 'DOMExceptionPrototype';\n Object.defineProperty(DOMException, 'prototype', {\n writable: false\n });\n\n Object.keys(codes).forEach((codeName) => {\n Object.defineProperty(DOMException.prototype, codeName, {\n enumerable: true,\n configurable: false,\n value: codes[codeName]\n });\n Object.defineProperty(DOMException, codeName, {\n enumerable: true,\n configurable: false,\n value: codes[codeName]\n });\n });\n Object.keys(legacyCodes).forEach((codeName) => {\n Object.defineProperty(DOMException.prototype, codeName, {\n enumerable: true,\n configurable: false,\n value: legacyCodes[codeName]\n });\n Object.defineProperty(DOMException, codeName, {\n enumerable: true,\n configurable: false,\n value: legacyCodes[codeName]\n });\n });\n Object.defineProperty(DOMException.prototype, 'constructor', {\n writable: true,\n configurable: true,\n enumerable: false,\n value: DOMException\n });\n\n return DOMException;\n}\n\nconst ShimNonNativeDOMException = createNonNativeDOMExceptionClass();\n\n/**\n * Creates a generic Error object.\n * @param {string} name\n * @param {string} message\n * @returns {Error}\n */\nfunction createNonNativeDOMException (name, message) {\n return new ShimNonNativeDOMException(message, name);\n}\n\n/**\n * Logs detailed error information to the console.\n * @param {string} name\n * @param {string} message\n * @param {string|Error|null} error\n * @returns {void}\n */\nfunction logError (name, message, error) {\n if (CFG.DEBUG) {\n if (error && error.message) {\n error = error.message;\n }\n\n const method = typeof (console.error) === 'function' ? 'error' : 'log';\n console[method](name + ': ' + message + '. ' + (error || ''));\n console.trace && console.trace();\n }\n}\n\nfunction isErrorOrDOMErrorOrDOMException (obj) {\n return obj && typeof obj === 'object' && // We don't use util.isObj here as mutual dependency causing problems in Babel with browser\n typeof obj.name === 'string';\n}\n\n/**\n * Finds the error argument. This is useful because some WebSQL callbacks\n * pass the error as the first argument, and some pass it as the second\n * argument.\n * @param {Array} args\n * @returns {Error|DOMException|undefined}\n */\nfunction findError (args) {\n let err;\n if (args) {\n if (args.length === 1) {\n return args[0];\n }\n for (const arg of args) {\n if (isErrorOrDOMErrorOrDOMException(arg)) {\n return arg;\n }\n if (arg && typeof arg.message === 'string') {\n err = arg;\n }\n }\n }\n return err;\n}\n\n/**\n *\n * @param {external:WebSQLError} webSQLErr\n * @returns {DOMException}\n */\nfunction webSQLErrback (webSQLErr) {\n let name, message;\n switch (webSQLErr.code) {\n case 4: { // SQLError.QUOTA_ERR\n name = 'QuotaExceededError';\n message = 'The operation failed because there was not enough ' +\n 'remaining storage space, or the storage quota was reached ' +\n 'and the user declined to give more space to the database.';\n break;\n }\n /*\n // Should a WebSQL timeout treat as IndexedDB `TransactionInactiveError` or `UnknownError`?\n case 7: { // SQLError.TIMEOUT_ERR\n // All transaction errors abort later, so no need to mark inactive\n name = 'TransactionInactiveError';\n message = 'A request was placed against a transaction which is currently not active, or which is finished (Internal SQL Timeout).';\n break;\n }\n */\n default: {\n name = 'UnknownError';\n message = 'The operation failed for reasons unrelated to the database itself and not covered by any other errors.';\n break;\n }\n }\n message += ' (' + webSQLErr.message + ')--(' + webSQLErr.code + ')';\n const err = createDOMException(name, message);\n err.sqlError = webSQLErr;\n return err;\n}\n\nlet test, useNativeDOMException = false;\n\n// Test whether we can use the browser's native DOMException class\ntry {\n test = createNativeDOMException('test name', 'test message');\n if (isErrorOrDOMErrorOrDOMException(test) && test.name === 'test name' && test.message === 'test message') {\n // Native DOMException works as expected\n useNativeDOMException = true;\n }\n} catch (e) {}\n\nconst createDOMException = useNativeDOMException\n ? function (name, message, error) {\n logError(name, message, error);\n return createNativeDOMException(name, message);\n }\n : function (name, message, error) {\n logError(name, message, error);\n return createNonNativeDOMException(name, message);\n };\n\nconst ShimDOMException = useNativeDOMException\n ? DOMException\n : ShimNonNativeDOMException;\n\nexport {logError, findError, ShimDOMException, createDOMException, webSQLErrback};\n","import CFG from './CFG.js';\nimport expandsOnNFD from './unicode-regex.js';\n\nfunction escapeUnmatchedSurrogates (arg) {\n // http://stackoverflow.com/a/6701665/271577\n return arg.replace(\n /([\\uD800-\\uDBFF])(?![\\uDC00-\\uDFFF])|(^|[^\\uD800-\\uDBFF])([\\uDC00-\\uDFFF])/gu,\n function (_, unmatchedHighSurrogate, precedingLow, unmatchedLowSurrogate) {\n // Could add a corresponding surrogate for compatibility with `node-sqlite3`: http://bugs.python.org/issue12569 and http://stackoverflow.com/a/6701665/271577\n // but Chrome having problems\n if (unmatchedHighSurrogate) {\n return '^2' + unmatchedHighSurrogate.codePointAt()\n .toString(16).padStart(4, '0');\n }\n return (precedingLow || '') + '^3' +\n unmatchedLowSurrogate.codePointAt().toString(16).padStart(4, '0');\n }\n );\n}\n\nfunction escapeNameForSQLiteIdentifier (arg) {\n // http://stackoverflow.com/a/6701665/271577\n return '_' + // Prevent empty string\n escapeUnmatchedSurrogates(\n arg.replace(/\\^/gu, '^^') // Escape our escape\n // http://www.sqlite.org/src/tktview?name=57c971fc74\n .replace(/\\0/gu, '^0')\n // We need to avoid identifiers being treated as duplicates based on SQLite's ASCII-only case-insensitive table and column names\n // (For SQL in general, however, see http://stackoverflow.com/a/17215009/271577\n // See also https://www.sqlite.org/faq.html#q18 re: Unicode (non-ASCII) case-insensitive not working\n .replace(/([A-Z])/gu, '^$1')\n );\n}\n\n// The escaping of unmatched surrogates was needed by Chrome but not Node\nfunction escapeSQLiteStatement (arg) {\n return escapeUnmatchedSurrogates(arg.replace(/\\^/gu, '^^').replace(/\\0/gu, '^0'));\n}\nfunction unescapeSQLiteResponse (arg) {\n return unescapeUnmatchedSurrogates(arg)\n .replace(/(\\^+)0/gu, (_, esc) => {\n return esc.length % 2\n ? esc.slice(1) + '\\0'\n : _;\n })\n .replace(/\\^\\^/gu, '^');\n}\n\nfunction sqlEscape (arg) {\n // https://www.sqlite.org/lang_keywords.html\n // http://stackoverflow.com/a/6701665/271577\n // There is no need to escape ', `, or [], as\n // we should always be within double quotes\n // NUL should have already been stripped\n return arg.replace(/\"/gu, '\"\"');\n}\n\nfunction sqlQuote (arg) {\n return '\"' + sqlEscape(arg) + '\"';\n}\n\nfunction escapeDatabaseNameForSQLAndFiles (db) {\n if (CFG.escapeDatabaseName) {\n // We at least ensure NUL is escaped by default, but we need to still\n // handle empty string and possibly also length (potentially\n // throwing if too long), escaping casing (including Unicode?),\n // and escaping special characters depending on file system\n return CFG.escapeDatabaseName(escapeSQLiteStatement(db));\n }\n db = 'D' + escapeNameForSQLiteIdentifier(db);\n if (CFG.escapeNFDForDatabaseNames !== false) {\n // ES6 copying of regex with different flags\n db = db.replace(new RegExp(expandsOnNFD, 'gu'), function (expandable) {\n return '^4' + expandable.codePointAt().toString(16).padStart(6, '0');\n });\n }\n if (CFG.databaseCharacterEscapeList !== false) {\n db = db.replace(\n (CFG.databaseCharacterEscapeList\n ? new RegExp(CFG.databaseCharacterEscapeList, 'gu')\n : /[\\u0000-\\u001F\\u007F\"*/:<>?\\\\|]/gu), // eslint-disable-line no-control-regex\n function (n0) {\n // eslint-disable-next-line unicorn/prefer-code-point -- Switch to `codePointAt`?\n return '^1' + n0.charCodeAt().toString(16).padStart(2, '0');\n }\n );\n }\n if (CFG.databaseNameLengthLimit !== false &&\n db.length >= ((CFG.databaseNameLengthLimit || 254) - (CFG.addSQLiteExtension !== false ? 7 /* '.sqlite'.length */ : 0))) {\n throw new Error(\n 'Unexpectedly long database name supplied; length limit required for Node compatibility; passed length: ' +\n db.length + '; length limit setting: ' + (CFG.databaseNameLengthLimit || 254) + '.'\n );\n }\n return db + (CFG.addSQLiteExtension !== false ? '.sqlite' : ''); // Shouldn't have quoting (do we even need NUL/case escaping here?)\n}\n\nfunction unescapeUnmatchedSurrogates (arg) {\n return arg\n .replace(/(\\^+)3(d[0-9a-f]{3})/gu, (_, esc, lowSurr) => {\n return esc.length % 2\n ? esc.slice(1) + String.fromCodePoint(Number.parseInt(lowSurr, 16))\n : _;\n }).replace(/(\\^+)2(d[0-9a-f]{3})/gu, (_, esc, highSurr) => {\n return esc.length % 2\n ? esc.slice(1) + String.fromCodePoint(Number.parseInt(highSurr, 16))\n : _;\n });\n}\n\n// Not in use internally but supplied for convenience\nfunction unescapeDatabaseNameForSQLAndFiles (db) {\n if (CFG.unescapeDatabaseName) {\n // We at least ensure NUL is unescaped by default, but we need to still\n // handle empty string and possibly also length (potentially\n // throwing if too long), unescaping casing (including Unicode?),\n // and unescaping special characters depending on file system\n return CFG.unescapeDatabaseName(unescapeSQLiteResponse(db));\n }\n\n return unescapeUnmatchedSurrogates(\n db.slice(2) // D_\n // CFG.databaseCharacterEscapeList\n .replace(/(\\^+)1([0-9a-f]{2})/gu, (_, esc, hex) => {\n return esc.length % 2\n ? esc.slice(1) + String.fromCodePoint(Number.parseInt(hex, 16))\n : _;\n // CFG.escapeNFDForDatabaseNames\n }).replace(/(\\^+)4([0-9a-f]{6})/gu, (_, esc, hex) => {\n return esc.length % 2\n ? esc.slice(1) + String.fromCodePoint(Number.parseInt(hex, 16))\n : _;\n })\n // escapeNameForSQLiteIdentifier (including unescapeUnmatchedSurrogates() above)\n ).replace(/(\\^+)([A-Z])/gu, (_, esc, upperCase) => {\n return esc.length % 2\n ? esc.slice(1) + upperCase\n : _;\n }).replace(/(\\^+)0/gu, (_, esc) => {\n return esc.length % 2\n ? esc.slice(1) + '\\0'\n : _;\n }).replace(/\\^\\^/gu, '^');\n}\n\nfunction escapeStoreNameForSQL (store) {\n return sqlQuote('S' + escapeNameForSQLiteIdentifier(store));\n}\n\nfunction escapeIndexNameForSQL (index) {\n return sqlQuote('I' + escapeNameForSQLiteIdentifier(index));\n}\n\nfunction escapeIndexNameForSQLKeyColumn (index) {\n return 'I' + escapeNameForSQLiteIdentifier(index);\n}\n\nfunction sqlLIKEEscape (str) {\n // https://www.sqlite.org/lang_expr.html#like\n return sqlEscape(str).replace(/\\^/gu, '^^');\n}\n\n// Babel doesn't seem to provide a means of using the `instanceof` operator with Symbol.hasInstance (yet?)\nfunction instanceOf (obj, Clss) {\n return Clss[Symbol.hasInstance](obj);\n}\n\nfunction isObj (obj) {\n return obj && typeof obj === 'object';\n}\n\nfunction isDate (obj) {\n return isObj(obj) && typeof obj.getDate === 'function';\n}\n\nfunction isBlob (obj) {\n return isObj(obj) && typeof obj.size === 'number' && typeof obj.slice === 'function' && !('lastModified' in obj);\n}\n\nfunction isRegExp (obj) {\n return isObj(obj) && typeof obj.flags === 'string' && typeof obj.exec === 'function';\n}\n\nfunction isFile (obj) {\n return isObj(obj) && typeof obj.name === 'string' && typeof obj.slice === 'function' && 'lastModified' in obj;\n}\n\nfunction isBinary (obj) {\n return isObj(obj) && typeof obj.byteLength === 'number' && (\n typeof obj.slice === 'function' || // `TypedArray` (view on buffer) or `ArrayBuffer`\n typeof obj.getFloat64 === 'function' // `DataView` (view on buffer)\n );\n}\n\nfunction isIterable (obj) {\n return isObj(obj) && typeof obj[Symbol.iterator] === 'function';\n}\n\nfunction defineOuterInterface (obj, props) {\n props.forEach((prop) => {\n const o = {\n get [prop] () {\n throw new TypeError('Illegal invocation');\n },\n set [prop] (val) {\n throw new TypeError('Illegal invocation');\n }\n };\n const desc = Object.getOwnPropertyDescriptor(o, prop);\n Object.defineProperty(obj, prop, desc);\n });\n}\n\nfunction defineReadonlyOuterInterface (obj, props) {\n props.forEach((prop) => {\n const o = {\n get [prop] () {\n throw new TypeError('Illegal invocation');\n }\n };\n const desc = Object.getOwnPropertyDescriptor(o, prop);\n Object.defineProperty(obj, prop, desc);\n });\n}\n\nfunction defineListenerProperties (obj, listeners) {\n listeners = typeof listeners === 'string' ? [listeners] : listeners;\n listeners.forEach((listener) => {\n const o = {\n get [listener] () {\n return obj['__' + listener];\n },\n set [listener] (val) {\n obj['__' + listener] = val;\n }\n };\n const desc = Object.getOwnPropertyDescriptor(o, listener);\n // desc.enumerable = true; // Default\n // desc.configurable = true; // Default // Needed by support.js in W3C IndexedDB tests (for openListeners)\n Object.defineProperty(obj, listener, desc);\n });\n listeners.forEach((l) => {\n obj[l] = null;\n });\n}\n\nfunction defineReadonlyProperties (obj, props, getter = null) {\n props = typeof props === 'string' ? [props] : props;\n props.forEach(function (prop) {\n let o;\n if (getter && prop in getter) {\n o = getter[prop];\n } else {\n Object.defineProperty(obj, '__' + prop, {\n enumerable: false,\n configurable: false,\n writable: true\n });\n // We must resort to this to get \"get <name>\" as\n // the function `name` for proper IDL\n o = {\n get [prop] () {\n return this['__' + prop];\n }\n };\n }\n\n const desc = Object.getOwnPropertyDescriptor(o, prop);\n // desc.enumerable = true; // Default\n // desc.configurable = true; // Default\n Object.defineProperty(obj, prop, desc);\n });\n}\n\nfunction isIdentifier (item) {\n // For load-time and run-time performance, we don't provide the complete regular\n // expression for identifiers, but these can be passed in, using the expressions\n // found at https://gist.github.com/brettz9/b4cd6821d990daa023b2e604de371407\n // ID_Start (includes Other_ID_Start)\n const UnicodeIDStart = CFG.UnicodeIDStart || '[$A-Z_a-z]';\n // ID_Continue (includes Other_ID_Continue)\n const UnicodeIDContinue = CFG.UnicodeIDContinue || '[$0-9A-Z_a-z]';\n const IdentifierStart = '(?:' + UnicodeIDStart + '|[$_])';\n const IdentifierPart = '(?:' + UnicodeIDContinue + '|[$_\\u200C\\u200D])';\n return (new RegExp('^' + IdentifierStart + IdentifierPart + '*$', 'u')).test(item);\n}\n\nfunction isValidKeyPathString (keyPathString) {\n return typeof keyPathString === 'string' &&\n (keyPathString === '' || isIdentifier(keyPathString) || keyPathString.split('.').every((pathComponent) => {\n return isIdentifier(pathComponent);\n }));\n}\n\nfunction isValidKeyPath (keyPath) {\n return isValidKeyPathString(keyPath) || (\n Array.isArray(keyPath) && keyPath.length &&\n // Convert array from sparse to dense http://www.2ality.com/2012/06/dense-arrays.html\n // See also https://heycam.github.io/webidl/#idl-DOMString\n [...keyPath].every((pathComponent) => {\n return isValidKeyPathString(pathComponent);\n })\n );\n}\n\nfunction enforceRange (number, type) {\n number = Math.floor(Number(number));\n let max, min;\n switch (type) {\n case 'unsigned long long': {\n max = 0x1FFFFFFFFFFFFF; // 2^53 - 1\n min = 0;\n break;\n }\n case 'unsigned long': {\n max = 0xFFFFFFFF; // 2^32 - 1\n min = 0;\n break;\n }\n default:\n throw new Error('Unrecognized type supplied to enforceRange');\n }\n if (!Number.isFinite(number) ||\n number > max ||\n number < min) {\n throw new TypeError('Invalid range: ' + number);\n }\n return number;\n}\n\nfunction convertToDOMString (v, treatNullAs) {\n return v === null && treatNullAs ? '' : ToString(v);\n}\n\nfunction ToString (o) { // Todo: See `es-abstract/es7`\n // `String()` will not throw with Symbols\n return '' + o; // eslint-disable-line no-implicit-coercion\n}\n\nfunction convertToSequenceDOMString (val) {\n // Per <https://heycam.github.io/webidl/#idl-sequence>, converting to a sequence works with iterables\n if (isIterable(val)) { // We don't want conversion to array to convert primitives\n // Per <https://heycam.github.io/webidl/#es-DOMString>, converting to a `DOMString` to be via `ToString`: https://tc39.github.io/ecma262/#sec-tostring\n return [...val].map((item) => {\n return ToString(item);\n });\n }\n return ToString(val);\n}\n\nfunction isNullish (v) {\n return v === null || v === undefined;\n}\n\nfunction hasOwn (obj, prop) {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n\nexport {escapeSQLiteStatement, unescapeSQLiteResponse,\n escapeDatabaseNameForSQLAndFiles, unescapeDatabaseNameForSQLAndFiles,\n escapeStoreNameForSQL, escapeIndexNameForSQL, escapeIndexNameForSQLKeyColumn,\n sqlLIKEEscape, sqlQuote,\n instanceOf,\n isObj, isDate, isBlob, isRegExp, isFile, isBinary, isIterable,\n defineOuterInterface, defineReadonlyOuterInterface,\n defineListenerProperties, defineReadonlyProperties,\n isValidKeyPath, enforceRange,\n convertToDOMString, convertToSequenceDOMString,\n isNullish, hasOwn};\n","import CFG from './CFG.js';\nimport {encode as keyEncode, decode as keyDecode} from './Key.js';\n\n/**\n * Compares two keys.\n * @param first\n * @param second\n * @returns {number}\n */\nfunction cmp (first, second) {\n const encodedKey1 = keyEncode(first);\n const encodedKey2 = keyEncode(second);\n const result = encodedKey1 > encodedKey2\n ? 1\n : encodedKey1 === encodedKey2 ? 0 : -1;\n\n if (CFG.DEBUG) {\n // verify that the keys encoded correctly\n let decodedKey1 = keyDecode(encodedKey1);\n let decodedKey2 = keyDecode(encodedKey2);\n if (typeof first === 'object') {\n first = JSON.stringify(first);\n decodedKey1 = JSON.stringify(decodedKey1);\n }\n if (typeof second === 'object') {\n second = JSON.stringify(second);\n decodedKey2 = JSON.stringify(decodedKey2);\n }\n\n // Encoding/decoding mismatches are usually due to a loss of\n // floating-point precision\n if (decodedKey1 !== first) {\n console.warn(\n first + ' was incorrectly encoded as ' + decodedKey1\n );\n }\n if (decodedKey2 !== second) {\n console.warn(\n second + ' was incorrectly encoded as ' + decodedKey2\n );\n }\n }\n\n return result;\n}\n\nexport default cmp;\n","import {createDOMException} from './DOMException.js';\nimport * as util from './util.js';\nimport cmp from './cmp.js';\nimport CFG from './CFG.js';\n\n/**\n * @module Key\n */\n\n/**\n * Encodes the keys based on their types. This is required to maintain collations\n * We leave space for future keys.\n */\nconst keyTypeToEncodedChar = {\n invalid: 100,\n number: 200,\n date: 300,\n string: 400,\n binary: 500,\n array: 600\n};\nconst keyTypes = Object.keys(keyTypeToEncodedChar);\nkeyTypes.forEach((k) => {\n keyTypeToEncodedChar[k] = String.fromCodePoint(keyTypeToEncodedChar[k]);\n});\n\nconst encodedCharToKeyType = keyTypes.reduce((o, k) => {\n o[keyTypeToEncodedChar[k]] = k;\n return o;\n}, {});\n\n/**\n * The sign values for numbers, ordered from least to greatest.\n * - \"negativeInfinity\": Sorts below all other values.\n * - \"bigNegative\": Negative values less than or equal to negative one.\n * - \"smallNegative\": Negative values between negative one and zero, noninclusive.\n * - \"smallPositive\": Positive values between zero and one, including zero but not one.\n * - \"largePositive\": Positive values greater than or equal to one.\n * - \"positiveInfinity\": Sorts above all other values.\n */\nconst signValues = ['negativeInfinity', 'bigNegative', 'smallNegative', 'smallPositive', 'bigPositive', 'positiveInfinity'];\n\nconst types = {\n invalid: {\n encode (key) {\n return keyTypeToEncodedChar.invalid + '-';\n },\n decode (key) {\n return undefined;\n }\n },\n\n // Numbers are represented in a lexically sortable base-32 sign-exponent-mantissa\n // notation.\n //\n // sign: takes a value between zero and five, inclusive. Represents infinite cases\n // and the signs of both the exponent and the fractional part of the number.\n // exponent: padded to two base-32 digits, represented by the 32's compliment in the\n // \"smallPositive\" and \"bigNegative\" cases to ensure proper lexical sorting.\n // mantissa: also called the fractional part. Normed 11-digit base-32 representation.\n // Represented by the 32's compliment in the \"smallNegative\" and \"bigNegative\"\n // cases to ensure proper lexical sorting.\n number: {\n // The encode step checks for six numeric cases and generates 14-digit encoded\n // sign-exponent-mantissa strings.\n encode (key) {\n let key32 = key === Number.MIN_VALUE\n // Mocha test `IDBFactory/cmp-spec.js` exposed problem for some\n // Node (and Chrome) versions with `Number.MIN_VALUE` being treated\n // as 0\n // https://stackoverflow.com/questions/43305403/number-min-value-and-tostring\n ? '0.' + '0'.repeat(214) + '2'\n : Math.abs(key).toString(32);\n // Get the index of the decimal.\n const decimalIndex = key32.indexOf('.');\n // Remove the decimal.\n key32 = (decimalIndex !== -1) ? key32.replace('.', '') : key32;\n // Get the index of the first significant digit.\n const significantDigitIndex = key32.search(/[^0]/u);\n // Truncate leading zeros.\n key32 = key32.slice(significantDigitIndex);\n let sign, exponent, mantissa;\n\n // Finite cases:\n if (Number.isFinite(\n Number(key)\n )) {\n // Negative cases:\n if (key < 0) {\n // Negative exponent case:\n if (key > -1) {\n sign = signValues.indexOf('smallNegative');\n exponent = padBase32Exponent(significantDigitIndex);\n mantissa = flipBase32(padBase32Mantissa(key32));\n // Non-negative exponent case:\n } else {\n sign = signValues.indexOf('bigNegative');\n exponent = flipBase32(padBase32Exponent(\n (decimalIndex !== -1) ? decimalIndex : key32.length\n ));\n mantissa = flipBase32(padBase32Mantissa(key32));\n }\n // Non-negative cases:\n // Negative exponent case:\n } else if (key < 1) {\n sign = signValues.indexOf('smallPositive');\n exponent = flipBase32(padBase32Exponent(significantDigitIndex));\n mantissa = padBase32Mantissa(key32);\n // Non-negative exponent case:\n } else {\n sign = signValues.indexOf('bigPositive');\n exponent = padBase32Exponent(\n (decimalIndex !== -1) ? decimalIndex : key32.length\n );\n mantissa = padBase32Mantissa(key32);\n }\n // Infinite cases:\n } else {\n exponent = zeros(2);\n mantissa = zeros(11);\n sign = signValues.indexOf(\n key > 0 ? 'positiveInfinity' : 'negativeInfinity'\n );\n }\n\n return keyTypeToEncodedChar.number + '-' + sign + exponent + mantissa;\n },\n // The decode step must interpret the sign, reflip values encoded as the 32's complements,\n // apply signs to the exponent and mantissa, do the base-32 power operation, and return\n // the original JavaScript number values.\n decode (key) {\n const sign = Number(key.slice(2, 3));\n let exponent = key.slice(3, 5);\n let mantissa = key.slice(5, 16);\n\n switch (signValues[sign]) {\n case 'negativeInfinity':\n return Number.NEGATIVE_INFINITY;\n case 'positiveInfinity':\n return Number.POSITIVE_INFINITY;\n case 'bigPositive':\n return pow32(mantissa, exponent);\n case 'smallPositive':\n exponent = negate(flipBase32(exponent));\n return pow32(mantissa, exponent);\n case 'smallNegative':\n exponent = negate(exponent);\n mantissa = flipBase32(mantissa);\n return -pow32(mantissa, exponent);\n case 'bigNegative':\n exponent = flipBase32(exponent);\n mantissa = flipBase32(mantissa);\n return -pow32(mantissa, exponent);\n default:\n throw new Error('Invalid number.');\n }\n }\n },\n\n // Strings are encoded as JSON strings (with quotes and unicode characters escaped).\n //\n // If the strings are in an array, then some extra encoding is done to make sorting work correctly:\n // Since we can't force all strings to be the same length, we need to ensure that characters line-up properly\n // for sorting, while also accounting for the extra characters that are added when the array itself is encoded as JSON.\n // To do this, each character of the string is prepended with a dash (\"-\"), and a space is added to the end of the string.\n // This effectively doubles the size of every string, but it ensures that when two arrays of strings are compared,\n // the indexes of each string's characters line up with each other.\n string: {\n encode (key, inArray) {\n if (inArray) {\n // prepend each character with a dash, and append a space to the end\n key = key.replace(/(.)/gu, '-$1') + ' ';\n }\n return keyTypeToEncodedChar.string + '-' + key;\n },\n decode (key, inArray) {\n key = key.slice(2);\n if (inArray) {\n // remove the space at the end, and the dash before each character\n key = key.slice(0, -1).replace(/-(.)/gu, '$1');\n }\n return key;\n }\n },\n\n // Arrays are encoded as JSON strings.\n // An extra, value is added to each array during encoding to make\n // empty arrays sort correctly.\n array: {\n encode (key) {\n const encoded = [];\n for (const [i, item] of key.entries()) {\n const encodedItem = encode(item, true); // encode the array item\n encoded[i] = encodedItem;\n }\n encoded.push(keyTypeToEncodedChar.invalid + '-'); // append an extra item, so empty arrays sort correctly\n return keyTypeToEncodedChar.array + '-' + JSON.stringify(encoded);\n },\n decode (key) {\n const decoded = JSON.parse(key.slice(2));\n decoded.pop(); // remove the extra item\n for (let i = 0; i < decoded.length; i++) {\n const item = decoded[i];\n const decodedItem = decode(item, true); // decode the item\n decoded[i] = decodedItem;\n }\n return decoded;\n }\n },\n\n // Dates are encoded as ISO 8601 strings, in UTC time zone.\n date: {\n encode (key) {\n return keyTypeToEncodedChar.date + '-' + key.toJSON();\n },\n decode (key) {\n return new Date(key.slice(2));\n }\n },\n binary: {\n // `ArrayBuffer`/Views on buffers (`TypedArray` or `DataView`)\n encode (key) {\n return keyTypeToEncodedChar.binary + '-' + (key.byteLength\n ? [...getCopyBytesHeldByBufferSource(key)].map(\n (b) => String(b).padStart(3, '0')\n ) // e.g., '255,005,254,000,001,033'\n : '');\n },\n decode (key) {\n // Set the entries in buffer's [[ArrayBufferData]] to those in `value`\n const k = key.slice(2);\n const arr = k.length ? k.split(',').map((s) => Number.parseInt(s)) : [];\n const buffer = new ArrayBuffer(arr.length);\n const uint8 = new Uint8Array(buffer);\n uint8.set(arr);\n return buffer;\n }\n }\n};\n\n/**\n * Return a padded base-32 exponent value.\n * @param {number} n\n * @returns {string}\n */\nfunction padBase32Exponent (n) {\n n = n.toString(32);\n return (n.length === 1) ? '0' + n : n;\n}\n\n/**\n * Return a padded base-32 mantissa.\n * @param {string} s\n * @returns {string}\n */\nfunction padBase32Mantissa (s) {\n return (s + zeros(11)).slice(0, 11);\n}\n\n/**\n * Flips each digit of a base-32 encoded string.\n * @param {string} encoded\n * @returns {string}\n */\nfunction flipBase32 (encoded) {\n let flipped = '';\n for (const ch of encoded) {\n flipped += (31 - Number.parseInt(ch, 32)).toString(32);\n }\n return flipped;\n}\n\n/**\n * Base-32 power function.\n * RESEARCH: This function does not precisely decode floats because it performs\n * floating point arithmetic to recover values. But can the original values be\n * recovered exactly?\n * Someone may have already figured out a good way to store JavaScript floats as\n * binary strings and convert back. Barring a better method, however, one route\n * may be to generate decimal strings that `parseFloat` decodes predictably.\n * @param {string} mantissa\n * @param {string} exponent\n * @returns {number}\n */\nfunction pow32 (mantissa, exponent) {\n exponent = Number.parseInt(exponent, 32);\n if (exponent < 0) {\n return roundToPrecision(\n Number.parseInt(mantissa, 32) * (32 ** (exponent - 10))\n );\n }\n if (exponent < 11) {\n let whole = mantissa.slice(0, exponent);\n whole = Number.parseInt(whole, 32);\n let fraction = mantissa.slice(exponent);\n fraction = Number.parseInt(fraction, 32) * (32 ** (exponent - 11));\n return roundToPrecision(whole + fraction);\n }\n const expansion = mantissa + zeros(exponent - 11);\n return Number.parseInt(expansion, 32);\n}\n\n/**\n * @param {Float} num\n * @param {Float} [precision=16]\n * @returns {Float}\n */\nfunction roundToPrecision (num, precision = 16) {\n return Number.parseFloat(num.toPrecision(precision));\n}\n\n/**\n * Returns a string of n zeros.\n * @param {number} n\n * @returns {string}\n */\nfunction zeros (n) {\n return '0'.repeat(n);\n}\n\n/**\n * Negates numeric strings.\n * @param {string} s\n * @returns {string}\n */\nfunction negate (s) {\n return '-' + s;\n}\n\n/**\n* @typedef {\"number\"|\"date\"|\"string\"|\"binary\"|\"array\"} module:Key.KeyType\n*/\n\n/**\n * @param key\n * @returns {module:Key.KeyType}\n */\nfunction getKeyType (key) {\n if (Array.isArray(key)) return 'array';\n if (util.isDate(key)) return 'date';\n if (util.isBinary(key)) return 'binary';\n const keyType = typeof key;\n return ['string', 'number'].includes(keyType) ? keyType : 'invalid';\n}\n\n/**\n * Keys must be strings, numbers (besides `NaN`), Dates (if value is not\n * `NaN`), binary objects or Arrays.\n * @param input The key input\n * @param {?(Array)} [seen] An array of already seen keys\n * @returns {module:Key.keyValueObject}\n */\nfunction convertValueToKey (input, seen) {\n return convertValueToKeyValueDecoded(input, seen, false, true);\n}\n\n/**\n* Currently not in use.\n* @param input\n* @returns {module:Key.keyValueObject}\n*/\nfunction convertValueToMultiEntryKey (input) {\n return convertValueToKeyValueDecoded(input, null, true, true);\n}\n\n/**\n *\n * @param O\n * @throws {TypeError}\n * @see https://heycam.github.io/webidl/#ref-for-dfn-get-buffer-source-copy-2\n * @returns {Uint8Array}\n */\nfunction getCopyBytesHeldByBufferSource (O) {\n let offset = 0;\n let length = 0;\n if (ArrayBuffer.isView(O)) { // Has [[ViewedArrayBuffer]] internal slot\n const arrayBuffer = O.buffer;\n if (arrayBuffer === undefined) {\n throw new TypeError(\n 'Could not copy the bytes held by a buffer source as the buffer was undefined.'\n );\n }\n offset = O.byteOffset; // [[ByteOffset]] (will also throw as desired if detached)\n length = O.byteLength; // [[ByteLength]] (will also throw as desired if detached)\n } else {\n length = O.byteLength; // [[ArrayBufferByteLength]] on ArrayBuffer (will also throw as desired if detached)\n }\n // const octets = new Uint8Array(input);\n // const octets = types.binary.decode(types.binary.encode(input));\n return new Uint8Array(O.buffer || O, offset, length);\n}\n\n/**\n* @typedef {PlainObject} module:Key.keyValueObject\n* @property {module:Key.KeyType|\"NaN\"} type\n* @property {*} [value]\n* @property {boolean} [invalid]\n* @property {string} [message]\n* @todo Specify acceptable `value` more precisely\n*/\n\n/**\n* Shortcut utility to avoid returning full keys from `convertValueToKey`\n* and subsequent need to process in calling code unless `fullKeys` is\n* set; may throw.\n* @param {module:Key.Key} input\n* @param {?(Array)} [seen]\n* @param {boolean} [multiEntry]\n* @param {boolean} [fullKeys]\n* @throws {TypeError} See `getCopyBytesHeldByBufferSource`\n* @todo Document other allowable `input`\n* @returns {module:Key.keyValueObject}\n*/\nfunction convertValueToKeyValueDecoded (input, seen, multiEntry, fullKeys) {\n seen = seen || [];\n if (seen.includes(input)) {\n return {\n type: 'array',\n invalid: true,\n message: 'An array key cannot be circular'\n };\n }\n const type = getKeyType(input);\n const ret = {type, value: input};\n switch (type) {\n case 'number': {\n if (Number.isNaN(input)) {\n // List as 'NaN' type for convenience of consumers in reporting errors\n return {type: 'NaN', invalid: true};\n }\n return ret;\n } case 'string': {\n return ret;\n } case 'binary': { // May throw (if detached)\n // Get a copy of the bytes held by the buffer source\n // https://heycam.github.io/webidl/#ref-for-dfn-get-buffer-source-copy-2\n const octets = getCopyBytesHeldByBufferSource(input);\n return {type: 'binary', value: octets};\n } case 'array': { // May throw (from binary)\n const len = input.length;\n seen.push(input);\n const keys = [];\n for (let i = 0; i < len; i++) { // We cannot iterate here with array extras as we must ensure sparse arrays are invalidated\n if (!multiEntry && !Object.prototype.hasOwnProperty.call(input, i)) {\n return {type, invalid: true, message: 'Does not have own index property'};\n }\n try {\n const entry = input[i];\n const key = convertValueToKeyValueDecoded(entry, seen, false, fullKeys); // Though steps do not list rethrowing, the next is returnifabrupt when not multiEntry\n if (key.invalid) {\n if (multiEntry) {\n continue;\n }\n return {type, invalid: true, message: 'Bad array entry value-to-key conversion'};\n }\n if (!multiEntry ||\n (!fullKeys && keys.every((k) => cmp(k, key.value) !== 0)) ||\n (fullKeys && keys.every((k) => cmp(k, key) !== 0))\n ) {\n keys.push(fullKeys ? key : key.value);\n }\n } catch (err) {\n if (!multiEntry) {\n throw err;\n }\n }\n }\n return {type, value: keys};\n } case 'date': {\n if (!Number.isNaN(input.getTime())) {\n return fullKeys\n ? {type, value: input.getTime()}\n : {type, value: new Date(input.getTime())};\n }\n return {type, invalid: true, message: 'Not a valid date'};\n // Falls through\n } case 'invalid': default: {\n // Other `typeof` types which are not valid keys:\n // 'undefined', 'boolean', 'object' (including `null`), 'symbol', 'function\n const type = input === null ? 'null' : typeof input; // Convert `null` for convenience of consumers in reporting errors\n return {type, invalid: true, message: 'Not a valid key; type ' + type};\n }\n }\n}\n\n/**\n* @typedef {*} module:Key.Key\n* @todo Specify possible value more precisely\n*/\n\n/**\n *\n * @param {module:Key.Key} key\n * @param {boolean} fullKeys\n * @returns {module:Key.keyValueObject}\n * @todo Document other allowable `key`?\n */\nfunction convertValueToMultiEntryKeyDecoded (key, fullKeys) {\n return convertValueToKeyValueDecoded(key, null, true, fullKeys);\n}\n\n/**\n* An internal utility.\n* @param input\n* @param {boolean} seen\n* @throws {DOMException} `DataError`\n* @returns {module:Key.keyValueObject}\n*/\nfunction convertValueToKeyRethrowingAndIfInvalid (input, seen) {\n const key = convertValueToKey(input, seen);\n if (key.invalid) {\n throw createDOMException('DataError', key.message || 'Not a valid key; type: ' + key.type);\n }\n return key;\n}\n\n/**\n *\n * @param value\n * @param keyPath\n * @param {boolean} multiEntry\n * @returns {module:Key.keyValueObject|module:Key.KeyPathEvaluateValue}\n * @todo Document other possible return?\n */\nfunction extractKeyFromValueUsingKeyPath (value, keyPath, multiEntry) {\n return extractKeyValueDecodedFromValueUsingKeyPath(value, keyPath, multiEntry, true);\n}\n/**\n* Not currently in use.\n* @param value\n* @param keyPath\n* @param {boolean} multiEntry\n* @returns {module:Key.KeyPathEvaluateValue}\n*/\nfunction evaluateKeyPathOnValue (value, keyPath, multiEntry) {\n return evaluateKeyPathOnValueToDecodedValue(value, keyPath, multiEntry, true);\n}\n\n/**\n* May throw, return `{failure: true}` (e.g., non-object on keyPath resolution)\n* or `{invalid: true}` (e.g., `NaN`).\n* @param value\n* @param keyPath\n* @param {boolean} multiEntry\n* @param {boolean} fullKeys\n* @returns {module:Key.keyValueObject|module:Key.KeyPathEvaluateValue}\n* @todo Document other possible return?\n*/\nfunction extractKeyValueDecodedFromValueUsingKeyPath (value, keyPath, multiEntry, fullKeys) {\n const r = evaluateKeyPathOnValueToDecodedValue(value, keyPath, multiEntry, fullKeys);\n if (r.failure) {\n return r;\n }\n if (!multiEntry) {\n return convertValueToKeyValueDecoded(r.value, null, false, fullKeys);\n }\n return convertValueToMultiEntryKeyDecoded(r.value, fullKeys);\n}\n\n/**\n* @typedef {PlainObject} module:Key.KeyPathEvaluateFailure\n* @property {boolean} failure\n*/\n\n/**\n* @typedef {PlainObject} module:Key.KeyPathEvaluateValue\n* @property {undefined|array|string} value\n*/\n\n/**\n * Returns the value of an inline key based on a key path (wrapped in an\n * object with key `value`) or `{failure: true}`\n * @param {object} value\n * @param {string|array} keyPath\n * @param {boolean} multiEntry\n * @param {boolean} [fullKeys]\n * @returns {module:Key.KeyPathEvaluateValue}\n */\nfunction evaluateKeyPathOnValueToDecodedValue (value, keyPath, multiEntry, fullKeys) {\n if (Array.isArray(keyPath)) {\n const result = [];\n return keyPath.some((item) => {\n const key = evaluateKeyPathOnValueToDecodedValue(value, item, multiEntry, fullKeys);\n if (key.failure) {\n return true;\n }\n result.push(key.value);\n return false;\n })\n ? {failure: true}\n : {value: result};\n }\n if (keyPath === '') {\n return {value};\n }\n const identifiers = keyPath.split('.');\n return identifiers.some((idntfr, i) => {\n if (idntfr === 'length' && (\n typeof value === 'string' || Array.isArray(value)\n )) {\n value = value.length;\n } else if (util.isBlob(value)) {\n switch (idntfr) {\n case 'size': case 'type':\n value = value[idntfr];\n break;\n }\n } else if (util.isFile(value)) {\n switch (idntfr) {\n case 'name': case 'lastModified':\n value = value[idntfr];\n break;\n case 'lastModifiedDate':\n value = new Date(value.lastModified);\n break;\n }\n } else if (!util.isObj(value) || !Object.prototype.hasOwnProperty.call(value, idntfr)) {\n return true;\n } else {\n value = value[idntfr];\n return value === undefined;\n }\n return false;\n })\n ? {failure: true}\n : {value};\n}\n\n/**\n * Sets the inline key value.\n * @param {object} value\n * @param {*} key\n * @param {string} keyPath\n * @returns {void}\n */\nfunction injectKeyIntoValueUsingKeyPath (value, key, keyPath) {\n const identifiers = keyPath.split('.');\n const last = identifiers.pop();\n identifiers.forEach((identifier) => {\n const hop = Object.prototype.hasOwnProperty.call(value, identifier);\n if (!hop) {\n value[identifier] = {};\n }\n value = value[identifier];\n });\n value[last] = key; // key is already a `keyValue` in our processing so no need to convert\n}\n\n/**\n *\n * @param value\n * @param keyPath\n * @see https://github.com/w3c/IndexedDB/pull/146\n * @returns {boolean}\n */\nfunction checkKeyCouldBeInjectedIntoValue (value, keyPath) {\n const identifiers = keyPath.split('.');\n identifiers.pop();\n for (const identifier of identifiers) {\n if (!util.isObj(value)) {\n return false;\n }\n const hop = Object.prototype.hasOwnProperty.call(value, identifier);\n if (!hop) {\n return true;\n }\n value = value[identifier];\n }\n return util.isObj(value);\n}\n\n/**\n *\n * @param {module:Key.Key} key\n * @param {IDBKeyRange} range\n * @param {boolean} checkCached\n * @returns {boolean}\n */\nfunction isKeyInRange (key, range, checkCached) {\n let lowerMatch = range.lower === undefined;\n let upperMatch = range.upper === undefined;\n const encodedKey = encode(key, true);\n const lower = checkCached ? range.__lowerCached : encode(range.lower, true);\n const upper = checkCached ? range.__upperCached : encode(range.upper, true);\n\n if (range.lower !== undefined) {\n if (range.lowerOpen && encodedKey > lower) {\n lowerMatch = true;\n }\n if (!range.lowerOpen && encodedKey >= lower) {\n lowerMatch = true;\n }\n }\n if (range.upper !== undefined) {\n if (range.upperOpen && encodedKey < upper) {\n upperMatch = true;\n }\n if (!range.upperOpen && encodedKey <= upper) {\n upperMatch = true;\n }\n }\n\n return lowerMatch && upperMatch;\n}\n\n/**\n * Determines whether an index entry matches a multi-entry key value.\n * @param {string} encodedEntry The entry value (already encoded)\n * @param {string} encodedKey The full index key (already encoded)\n * @returns {boolean}\n */\nfunction isMultiEntryMatch (encodedEntry, encodedKey) {\n const keyType = encodedCharToKeyType[encodedKey.slice(0, 1)];\n\n if (keyType === 'array') {\n return encodedKey.indexOf(encodedEntry) > 1;\n }\n return encodedKey === encodedEntry;\n}\n\n/**\n *\n * @param {module:Key.Key} keyEntry\n * @param {IDBKeyRange} range\n * @returns {module:Key.Key[]}\n */\nfunction findMultiEntryMatches (keyEntry, range) {\n const matches = [];\n\n if (Array.isArray(keyEntry)) {\n for (let key of keyEntry) {\n if (Array.isArray(key)) {\n if (range && range.lower === range.upper) {\n continue;\n }\n if (key.length === 1) {\n key = key[0];\n } else {\n const nested = findMultiEntryMatches(key, range);\n if (nested.length > 0) {\n matches.push(key);\n }\n continue;\n }\n }\n\n if (util.isNullish(range) || isKeyInRange(key, range, true)) {\n matches.push(key);\n }\n }\n } else if (util.isNullish(range) || isKeyInRange(keyEntry, range, true)) {\n matches.push(keyEntry);\n }\n return matches;\n}\n\n/**\n* @typedef {number|string|Date|ArrayBuffer|module:Key.ValueTypes[]} module:Key.ValueTypes\n*/\n\n/**\n* Not currently in use but keeping for spec parity.\n* @param {module:Key.Key} key\n* @throws {Error} Upon a \"bad key\"\n* @returns {module:Key.ValueTypes}\n*/\nfunction convertKeyToValue (key) {\n const {type, value} = key;\n switch (type) {\n case 'number': case 'string': {\n return value;\n } case 'array': {\n const array = [];\n const len = value.length;\n let index = 0;\n while (index < len) {\n const entry = convertKeyToValue(value[index]);\n array[index] = entry;\n index++;\n }\n return array;\n } case 'date': {\n return new Date(value);\n } case 'binary': {\n const len = value.length;\n const buffer = new ArrayBuffer(len);\n // Set the entries in buffer's [[ArrayBufferData]] to those in `value`\n const uint8 = new Uint8Array(buffer, value.byteOffset || 0, value.byteLength);\n uint8.set(value);\n return buffer;\n } case 'invalid': default:\n throw new Error('Bad key');\n }\n}\n\n/**\n *\n * @param {module:Key.Key} key\n * @param {boolean} inArray\n * @returns {string|null}\n */\nfunction encode (key, inArray) {\n // Bad keys like `null`, `object`, `boolean`, 'function', 'symbol' should not be passed here due to prior validation\n if (key === undefined) {\n return null;\n }\n // array, date, number, string, binary (should already have detected \"invalid\")\n return types[getKeyType(key)].encode(key, inArray);\n}\n\n/**\n *\n * @param {module:Key.Key} key\n * @param {boolean} inArray\n * @throws {Error} Invalid number\n * @returns {undefined|module:Key.ValueTypes}\n */\nfunction decode (key, inArray) {\n if (typeof key !== 'string') {\n return undefined;\n }\n return types[encodedCharToKeyType[key.slice(0, 1)]].decode(key, inArray);\n}\n\n/**\n *\n * @param {module:Key.Key} key\n * @param {boolean} inArray\n * @returns {undefined|module:Key.ValueTypes}\n */\nfunction roundTrip (key, inArray) {\n return decode(encode(key, inArray), inArray);\n}\n\nconst MAX_ALLOWED_CURRENT_NUMBER = 9007199254740992; // 2 ^ 53 (Also equal to `Number.MAX_SAFE_INTEGER + 1`)\n\n/**\n * @external WebSQLTransaction\n */\n\n/**\n* @typedef {IDBObjectStore} IDBObjectStoreWithCurrentName\n* @property {string} __currentName\n*/\n\n/**\n * @callback CurrentNumberCallback\n * @param {Integer} The current number\n * @returns {void}\n */\n\n/**\n* @callback SQLFailureCallback\n* @param {DOMException} exception\n* @returns {void}\n*/\n\n/**\n *\n * @param {external:WebSQLTransaction} tx\n * @param {IDBObjectStoreWithCurrentName} store\n * @param {CurrentNumberCallback} func\n * @param {SQLFailureCallback} sqlFailCb\n * @returns {void}\n */\nfunction getCurrentNumber (tx, store, func, sqlFailCb) {\n tx.executeSql('SELECT \"currNum\" FROM __sys__ WHERE \"name\" = ?', [\n util.escapeSQLiteStatement(store.__currentName)\n ], function (tx, data) {\n if (data.rows.length !== 1) {\n func(1);\n } else {\n func(data.rows.item(0).currNum);\n }\n }, function (tx, error) {\n sqlFailCb(createDOMException(\n 'DataError',\n 'Could not get the auto increment value for key',\n error\n ));\n });\n}\n\n/**\n *\n * @param {external:WebSQLTransaction} tx\n * @param {IDBObjectStoreWithCurrentName} store\n * @param {Integer} num\n * @param {CurrentNumberCallback} successCb\n * @param {SQLFailureCallback} failCb\n * @returns {void}\n */\nfunction assignCurrentNumber (tx, store, num, successCb, failCb) {\n const sql = 'UPDATE __sys__ SET \"currNum\" = ? WHERE \"name\" = ?';\n const sqlValues = [num, util.escapeSQLiteStatement(store.__currentName)];\n CFG.DEBUG && console.log(sql, sqlValues);\n tx.executeSql(sql, sqlValues, function (tx, data) {\n successCb(num);\n }, function (tx, err) {\n failCb(createDOMException('UnknownError', 'Could not set the auto increment value for key', err));\n });\n}\n\n/**\n * Bump up the auto-inc counter if the key path-resolved value is valid\n * (greater than old value and >=1) OR if a manually passed in key is\n * valid (numeric and >= 1) and >= any primaryKey.\n * @param {external:WebSQLTransaction} tx\n * @param {IDBObjectStoreWithCurrentName} store\n * @param {Integer} num\n * @param {CurrentNumberCallback} successCb\n * @param {SQLFailureCallback} failCb\n * @returns {void}\n */\nfunction setCurrentNumber (tx, store, num, successCb, failCb) {\n num = num === MAX_ALLOWED_CURRENT_NUMBER\n ? num + 2 // Since incrementing by one will have no effect in JavaScript on this unsafe max, we represent the max as a number incremented by two. The getting of the current number is never returned to the user and is only used in safe comparisons, so it is safe for us to represent it in this manner\n : num + 1;\n return assignCurrentNumber(tx, store, num, successCb, failCb);\n}\n\n/**\n * @callback KeyForStoreCallback\n * @param {\"failure\"|null} arg1\n * @param {Integer} [arg2]\n * @param {Integer} [arg3]\n * @returns {void}\n */\n\n/**\n *\n * @param {external:WebSQLTransaction} tx\n * @param {IDBObjectStoreWithCurrentName} store\n * @param {KeyForStoreCallback} cb\n * @param {SQLFailureCallback} sqlFailCb\n * @returns {void}\n */\nfunction generateKeyForStore (tx, store, cb, sqlFailCb) {\n getCurrentNumber(tx, store, function (key) {\n if (key > MAX_ALLOWED_CURRENT_NUMBER) { // 2 ^ 53 (See <https://github.com/w3c/IndexedDB/issues/147>)\n cb('failure'); // eslint-disable-line n/no-callback-literal\n return;\n }\n // Increment current number by 1 (we cannot leverage SQLite's\n // autoincrement (and decrement when not needed), as decrementing\n // will be overwritten/ignored upon the next insert)\n setCurrentNumber(\n tx, store, key,\n function () {\n cb(null, key, key);\n },\n sqlFailCb\n );\n }, sqlFailCb);\n}\n\n// Fractional or numbers exceeding the max do not get changed in the result\n// per https://github.com/w3c/IndexedDB/issues/147\n// so we do not return a key\n/**\n *\n * @param {external:WebSQLTransaction} tx\n * @param {IDBObjectStoreWithCurrentName} store\n * @param {*|Integer} key\n * @param {CurrentNumberCallback|void} successCb\n * @param {SQLFailureCallback} sqlFailCb\n * @returns {void}\n */\nfunction possiblyUpdateKeyGenerator (tx, store, key, successCb, sqlFailCb) {\n // Per https://github.com/w3c/IndexedDB/issues/147 , non-finite numbers\n // (or numbers larger than the max) are now to have the explicit effect of\n // setting the current number (up to the max), so we do not optimize them\n // out here\n if (typeof key !== 'number' || key < 1) { // Optimize with no need to get the current number\n // Auto-increment attempted with a bad key;\n // we are not to change the current number, but the steps don't call for failure\n // Numbers < 1 are optimized out as they will never be greater than the current number which must be at least 1\n successCb();\n } else {\n // If auto-increment and the keyPath item is a valid numeric key, get the old auto-increment to compare if the new is higher\n // to determine which to use and whether to update the current number\n getCurrentNumber(tx, store, function (cn) {\n const value = Math.floor(\n Math.min(key, MAX_ALLOWED_CURRENT_NUMBER)\n );\n const useNewKeyForAutoInc = value >= cn;\n if (useNewKeyForAutoInc) {\n setCurrentNumber(tx, store, value, function () {\n successCb(cn); // Supply old current number in case needs to be reverted\n }, sqlFailCb);\n } else { // Not updated\n successCb();\n }\n }, sqlFailCb);\n }\n}\n\nexport {encode, decode, roundTrip, convertKeyToValue, convertValueToKeyValueDecoded,\n convertValueToMultiEntryKeyDecoded,\n convertValueToKey,\n convertValueToMultiEntryKey, convertValueToKeyRethrowingAndIfInvalid,\n extractKeyFromValueUsingKeyPath, evaluateKeyPathOnValue,\n extractKeyValueDecodedFromValueUsingKeyPath, injectKeyIntoValueUsingKeyPath, checkKeyCouldBeInjectedIntoValue,\n isMultiEntryMatch, isKeyInRange, findMultiEntryMatches,\n assignCurrentNumber,\n generateKeyForStore, possiblyUpdateKeyGenerator};\n"],"names":["map","CFG","createNativeDOMException","name","message","DOMException","prototype","constructor","val","test","TypeError","forEach","prop","validator","Array","isArray","_prop2","_slicedToArray","Object","defineProperty","get","set","codes","IndexSizeError","HierarchyRequestError","WrongDocumentError","InvalidCharacterError","NoModificationAllowedError","NotFoundError","NotSupportedError","InUseAttributeError","InvalidStateError","SyntaxError","InvalidModificationError","NamespaceError","InvalidAccessError","TypeMismatchError","SecurityError","NetworkError","AbortError","URLMismatchError","QuotaExceededError","TimeoutError","InvalidNodeTypeError","DataCloneError","EncodingError","NotReadableError","UnknownError","ConstraintError","DataError","TransactionInactiveError","ReadOnlyError","VersionError","OperationError","NotAllowedError","legacyCodes","INDEX_SIZE_ERR","DOMSTRING_SIZE_ERR","HIERARCHY_REQUEST_ERR","WRONG_DOCUMENT_ERR","INVALID_CHARACTER_ERR","NO_DATA_ALLOWED_ERR","NO_MODIFICATION_ALLOWED_ERR","NOT_FOUND_ERR","NOT_SUPPORTED_ERR","INUSE_ATTRIBUTE_ERR","INVALID_STATE_ERR","SYNTAX_ERR","INVALID_MODIFICATION_ERR","NAMESPACE_ERR","INVALID_ACCESS_ERR","VALIDATION_ERR","TYPE_MISMATCH_ERR","SECURITY_ERR","NETWORK_ERR","ABORT_ERR","URL_MISMATCH_ERR","QUOTA_EXCEEDED_ERR","TIMEOUT_ERR","INVALID_NODE_TYPE_ERR","DATA_CLONE_ERR","ShimNonNativeDOMException","this","Symbol","toStringTag","_code","_name","_message","undefined","configurable","enumerable","writable","value","DummyDOMException","create","Error","keys","codeName","createNonNativeDOMExceptionClass","logError","error","DEBUG","method","console","trace","obj","useNativeDOMException","_typeof","e","createDOMException","createNonNativeDOMException","escapeSQLiteStatement","arg","replace","_","unmatchedHighSurrogate","precedingLow","unmatchedLowSurrogate","codePointAt","toString","padStart","escapeUnmatchedSurrogates","isObj","isNullish","v","cmp","first","second","encodedKey1","keyEncode","encodedKey2","result","decodedKey1","keyDecode","decodedKey2","JSON","stringify","warn","keyTypeToEncodedChar","invalid","number","date","string","binary","array","keyTypes","k","String","fromCodePoint","encodedCharToKeyType","reduce","o","signValues","types","encode","key","decode","sign","exponent","mantissa","key32","Number","MIN_VALUE","repeat","Math","abs","decimalIndex","indexOf","significantDigitIndex","search","slice","isFinite","padBase32Exponent","flipBase32","padBase32Mantissa","length","zeros","NEGATIVE_INFINITY","POSITIVE_INFINITY","pow32","negate","inArray","_step","encoded","entries","_iterator","s","n","done","_step$value","i","encodedItem","err","f","push","decoded","parse","pop","decodedItem","toJSON","Date","byteLength","_toConsumableArray","getCopyBytesHeldByBufferSource","b","arr","split","parseInt","buffer","ArrayBuffer","Uint8Array","_step2","flipped","_iterator2","_createForOfIteratorHelper","ch","roundToPrecision","whole","fraction","expansion","num","precision","parseFloat","toPrecision","getKeyType","getDate","util","getFloat64","keyType","includes","convertValueToKey","input","seen","convertValueToKeyValueDecoded","O","offset","isView","byteOffset","multiEntry","fullKeys","type","ret","isNaN","len","_loop","hasOwnProperty","call","every","_ret","getTime","convertValueToMultiEntryKeyDecoded","extractKeyValueDecodedFromValueUsingKeyPath","keyPath","r","evaluateKeyPathOnValueToDecodedValue","failure","some","item","idntfr","size","lastModified","isKeyInRange","range","checkCached","lowerMatch","lower","upperMatch","upper","encodedKey","__lowerCached","__upperCached","lowerOpen","upperOpen","MAX_ALLOWED_CURRENT_NUMBER","getCurrentNumber","tx","store","func","sqlFailCb","executeSql","__currentName","data","rows","currNum","assignCurrentNumber","successCb","failCb","sql","sqlValues","log","setCurrentNumber","identifiers","_step3","_iterator3","identifier","convertKeyToValue","index","entry","findMultiEntryMatches","keyEntry","matches","_step4","_iterator4","cb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,EAAG,KAAMpJ,EAAKA,EACjB,GACD2H,EAEP,GAAEA,EACP,mCA/TA,SAAyC1L,EAAO+D,EAAKiG,GACjD,IAAMuC,EAAcvC,EAAQ9C,MAAM,KAC5BkG,EAAOb,EAAY9F,MACzB8F,EAAYxR,SAAQ,SAAC2R,GACLpR,OAAOZ,UAAU+O,eAAeC,KAAK1J,EAAO0M,KAEpD1M,EAAM0M,GAAc,IAExB1M,EAAQA,EAAM0M,EAClB,IACA1M,EAAMoN,GAAQrJ,CAClB,uCAiEA,SAA4BsJ,EAAcrC,GAGtC,MAAgB,UAFAvH,EAAqBuH,EAAWlG,MAAM,EAAG,IAG9CkG,EAAWrG,QAAQ0I,GAAgB,EAEvCrC,IAAeqC,CAC1B,+BA0PA,SAAqC9B,EAAIC,EAAOzH,EAAKkI,EAAWP,GAKzC,iBAAR3H,GAAoBA,EAAM,EAIjCkI,IAIAX,EAAiBC,EAAIC,GAAO,SAAU8B,GAClC,IAAMtN,EAAQwE,KAAK+I,MACf/I,KAAKgJ,IAAIzJ,EAAKsH,IAEUrL,GAASsN,EAEjChB,EAAiBf,EAAIC,EAAOxL,GAAO,WAC/BiM,EAAUqB,EACb,GAAE5B,GAEHO,GAEP,GAAEP,EAEX,cArKA,SAAoB3H,EAAK0B,GACrB,OAAOzB,EAAOF,EAAOC,EAAK0B,GAAUA,EACxC"}
|
package/dist/{indexeddbshim-UnicodeIdentifiers-node.js → indexeddbshim-UnicodeIdentifiers-node.cjs}
RENAMED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
/*! indexeddbshim - v10.
|
|
1
|
+
/*! indexeddbshim - v10.1.0 - 1/7/2023 */
|
|
2
2
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
+
var fs$1 = require('node:fs');
|
|
5
6
|
var path = require('path');
|
|
6
7
|
var customOpenDatabase = require('websql/custom/index.js');
|
|
7
8
|
|
|
@@ -57,7 +58,7 @@ function _asyncToGenerator(fn) {
|
|
|
57
58
|
};
|
|
58
59
|
}
|
|
59
60
|
function _defineProperty$1(obj, key, value) {
|
|
60
|
-
key = _toPropertyKey(key);
|
|
61
|
+
key = _toPropertyKey$1(key);
|
|
61
62
|
if (key in obj) {
|
|
62
63
|
Object.defineProperty(obj, key, {
|
|
63
64
|
value: value,
|
|
@@ -80,7 +81,7 @@ function _toPrimitive(input, hint) {
|
|
|
80
81
|
}
|
|
81
82
|
return (hint === "string" ? String : Number)(input);
|
|
82
83
|
}
|
|
83
|
-
function _toPropertyKey(arg) {
|
|
84
|
+
function _toPropertyKey$1(arg) {
|
|
84
85
|
var key = _toPrimitive(arg, "string");
|
|
85
86
|
return typeof key === "symbol" ? key : String(key);
|
|
86
87
|
}
|
|
@@ -2862,26 +2863,26 @@ function possiblyUpdateKeyGenerator(tx, store, key, successCb, sqlFailCb) {
|
|
|
2862
2863
|
|
|
2863
2864
|
var Key = /*#__PURE__*/Object.freeze({
|
|
2864
2865
|
__proto__: null,
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
roundTrip: roundTrip,
|
|
2866
|
+
assignCurrentNumber: assignCurrentNumber,
|
|
2867
|
+
checkKeyCouldBeInjectedIntoValue: checkKeyCouldBeInjectedIntoValue,
|
|
2868
2868
|
convertKeyToValue: convertKeyToValue,
|
|
2869
|
-
convertValueToKeyValueDecoded: convertValueToKeyValueDecoded,
|
|
2870
|
-
convertValueToMultiEntryKeyDecoded: convertValueToMultiEntryKeyDecoded,
|
|
2871
2869
|
convertValueToKey: convertValueToKey,
|
|
2872
|
-
convertValueToMultiEntryKey: convertValueToMultiEntryKey,
|
|
2873
2870
|
convertValueToKeyRethrowingAndIfInvalid: convertValueToKeyRethrowingAndIfInvalid,
|
|
2874
|
-
|
|
2871
|
+
convertValueToKeyValueDecoded: convertValueToKeyValueDecoded,
|
|
2872
|
+
convertValueToMultiEntryKey: convertValueToMultiEntryKey,
|
|
2873
|
+
convertValueToMultiEntryKeyDecoded: convertValueToMultiEntryKeyDecoded,
|
|
2874
|
+
decode: decode$1,
|
|
2875
|
+
encode: encode$1,
|
|
2875
2876
|
evaluateKeyPathOnValue: evaluateKeyPathOnValue,
|
|
2877
|
+
extractKeyFromValueUsingKeyPath: extractKeyFromValueUsingKeyPath,
|
|
2876
2878
|
extractKeyValueDecodedFromValueUsingKeyPath: extractKeyValueDecodedFromValueUsingKeyPath,
|
|
2877
|
-
injectKeyIntoValueUsingKeyPath: injectKeyIntoValueUsingKeyPath,
|
|
2878
|
-
checkKeyCouldBeInjectedIntoValue: checkKeyCouldBeInjectedIntoValue,
|
|
2879
|
-
isMultiEntryMatch: isMultiEntryMatch,
|
|
2880
|
-
isKeyInRange: isKeyInRange,
|
|
2881
2879
|
findMultiEntryMatches: findMultiEntryMatches,
|
|
2882
|
-
assignCurrentNumber: assignCurrentNumber,
|
|
2883
2880
|
generateKeyForStore: generateKeyForStore,
|
|
2884
|
-
|
|
2881
|
+
injectKeyIntoValueUsingKeyPath: injectKeyIntoValueUsingKeyPath,
|
|
2882
|
+
isKeyInRange: isKeyInRange,
|
|
2883
|
+
isMultiEntryMatch: isMultiEntryMatch,
|
|
2884
|
+
possiblyUpdateKeyGenerator: possiblyUpdateKeyGenerator,
|
|
2885
|
+
roundTrip: roundTrip
|
|
2885
2886
|
});
|
|
2886
2887
|
|
|
2887
2888
|
const readonlyProperties$4 = ['lower', 'upper', 'lowerOpen', 'upperOpen'];
|
|
@@ -3294,6 +3295,7 @@ IDBTransaction.prototype.__executeRequests = function () {
|
|
|
3294
3295
|
// Do not set __active flag to false yet: https://github.com/w3c/IndexedDB/issues/87
|
|
3295
3296
|
if (e.__legacyOutputDidListenersThrowError) {
|
|
3296
3297
|
logError('Error', 'An error occurred in a success handler attached to request chain', e.__legacyOutputDidListenersThrowError); // We do nothing else with this error as per spec
|
|
3298
|
+
// me.__active = false;
|
|
3297
3299
|
me.__abortTransaction(createDOMException('AbortError', 'A request was aborted (in user handler after success).'));
|
|
3298
3300
|
return;
|
|
3299
3301
|
}
|
|
@@ -3755,11 +3757,11 @@ function _objectSpread2(e) {
|
|
|
3755
3757
|
return e;
|
|
3756
3758
|
}
|
|
3757
3759
|
function _typeof(e) {
|
|
3758
|
-
return
|
|
3760
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (e) {
|
|
3759
3761
|
return typeof e;
|
|
3760
3762
|
} : function (e) {
|
|
3761
3763
|
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
|
|
3762
|
-
}
|
|
3764
|
+
}, _typeof(e);
|
|
3763
3765
|
}
|
|
3764
3766
|
function _classCallCheck(e, t) {
|
|
3765
3767
|
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
|
|
@@ -3767,7 +3769,7 @@ function _classCallCheck(e, t) {
|
|
|
3767
3769
|
function _defineProperties(e, t) {
|
|
3768
3770
|
for (var r = 0; r < t.length; r++) {
|
|
3769
3771
|
var n = t[r];
|
|
3770
|
-
n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(e, n.key, n);
|
|
3772
|
+
n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(e, _toPropertyKey(n.key), n);
|
|
3771
3773
|
}
|
|
3772
3774
|
}
|
|
3773
3775
|
function _createClass(e, t, r) {
|
|
@@ -3776,7 +3778,7 @@ function _createClass(e, t, r) {
|
|
|
3776
3778
|
}), e;
|
|
3777
3779
|
}
|
|
3778
3780
|
function _defineProperty(e, t, r) {
|
|
3779
|
-
return t in e ? Object.defineProperty(e, t, {
|
|
3781
|
+
return (t = _toPropertyKey(t)) in e ? Object.defineProperty(e, t, {
|
|
3780
3782
|
value: r,
|
|
3781
3783
|
enumerable: !0,
|
|
3782
3784
|
configurable: !0,
|
|
@@ -3791,21 +3793,26 @@ function _slicedToArray(e, t) {
|
|
|
3791
3793
|
if (null != r) {
|
|
3792
3794
|
var n,
|
|
3793
3795
|
a,
|
|
3794
|
-
o
|
|
3795
|
-
i
|
|
3796
|
-
c =
|
|
3796
|
+
o,
|
|
3797
|
+
i,
|
|
3798
|
+
c = [],
|
|
3799
|
+
s = !0,
|
|
3800
|
+
u = !1;
|
|
3797
3801
|
try {
|
|
3798
|
-
|
|
3802
|
+
if (o = (r = r.call(e)).next, 0 === t) {
|
|
3803
|
+
if (Object(r) !== r) return;
|
|
3804
|
+
s = !1;
|
|
3805
|
+
} else for (; !(s = (n = o.call(r)).done) && (c.push(n.value), c.length !== t); s = !0);
|
|
3799
3806
|
} catch (e) {
|
|
3800
|
-
|
|
3807
|
+
u = !0, a = e;
|
|
3801
3808
|
} finally {
|
|
3802
3809
|
try {
|
|
3803
|
-
|
|
3810
|
+
if (!s && null != r.return && (i = r.return(), Object(i) !== i)) return;
|
|
3804
3811
|
} finally {
|
|
3805
|
-
if (
|
|
3812
|
+
if (u) throw a;
|
|
3806
3813
|
}
|
|
3807
3814
|
}
|
|
3808
|
-
return
|
|
3815
|
+
return c;
|
|
3809
3816
|
}
|
|
3810
3817
|
}(e, t) || _unsupportedIterableToArray(e, t) || function _nonIterableRest() {
|
|
3811
3818
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
@@ -3823,6 +3830,19 @@ function _arrayLikeToArray(e, t) {
|
|
|
3823
3830
|
for (var r = 0, n = new Array(t); r < t; r++) n[r] = e[r];
|
|
3824
3831
|
return n;
|
|
3825
3832
|
}
|
|
3833
|
+
function _toPropertyKey(e) {
|
|
3834
|
+
var t = function _toPrimitive(e, t) {
|
|
3835
|
+
if ("object" != typeof e || null === e) return e;
|
|
3836
|
+
var r = e[Symbol.toPrimitive];
|
|
3837
|
+
if (void 0 !== r) {
|
|
3838
|
+
var n = r.call(e, t || "default");
|
|
3839
|
+
if ("object" != typeof n) return n;
|
|
3840
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
3841
|
+
}
|
|
3842
|
+
return ("string" === t ? String : Number)(e);
|
|
3843
|
+
}(e, "string");
|
|
3844
|
+
return "symbol" == typeof t ? t : String(t);
|
|
3845
|
+
}
|
|
3826
3846
|
var e = _createClass(function TypesonPromise(e) {
|
|
3827
3847
|
_classCallCheck(this, TypesonPromise), this.p = new Promise(e);
|
|
3828
3848
|
});
|
|
@@ -3883,10 +3903,10 @@ function isObject(e) {
|
|
|
3883
3903
|
return e && "object" === _typeof(e);
|
|
3884
3904
|
}
|
|
3885
3905
|
function escapeKeyPathComponent(e) {
|
|
3886
|
-
return e.replace(/~/g, "~0").replace(/\./g, "~1");
|
|
3906
|
+
return e.replace(/''/g, "''''").replace(/^$/, "''").replace(/~/g, "~0").replace(/\./g, "~1");
|
|
3887
3907
|
}
|
|
3888
3908
|
function unescapeKeyPathComponent(e) {
|
|
3889
|
-
return e.replace(/~1/g, ".").replace(/~0/g, "~");
|
|
3909
|
+
return e.replace(/~1/g, ".").replace(/~0/g, "~").replace(/^''$/, "").replace(/''''/g, "''");
|
|
3890
3910
|
}
|
|
3891
3911
|
function getByKeyPath(e, t) {
|
|
3892
3912
|
if ("" === t) return e;
|
|
@@ -4111,14 +4131,14 @@ var u = function () {
|
|
|
4111
4131
|
!0 === a && (y.push(r), p.push(t));
|
|
4112
4132
|
}
|
|
4113
4133
|
var _,
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
j = (
|
|
4134
|
+
w = isPlainObject(r),
|
|
4135
|
+
A = i(r),
|
|
4136
|
+
j = (w || A) && (!l.plainObjectReplacers.length || s.replaced) || s.iterateIn ? r : replace(t, r, s, u, w || A, null, O);
|
|
4117
4137
|
if (j !== r ? (h = j, g = {
|
|
4118
4138
|
replaced: j
|
|
4119
|
-
}) : "" === t && hasConstructorOf(r, e) ? (u.push([t, r, a, s, void 0, void 0, s.type]), h = r) :
|
|
4139
|
+
}) : "" === t && hasConstructorOf(r, e) ? (u.push([t, r, a, s, void 0, void 0, s.type]), h = r) : A && "object" !== s.iterateIn || "array" === s.iterateIn ? (_ = new Array(r.length), g = {
|
|
4120
4140
|
clone: _
|
|
4121
|
-
}) : (["function", "symbol"].includes(_typeof(r)) || "toJSON" in r || hasConstructorOf(r, e) || hasConstructorOf(r, Promise) || hasConstructorOf(r, ArrayBuffer)) && !
|
|
4141
|
+
}) : (["function", "symbol"].includes(_typeof(r)) || "toJSON" in r || hasConstructorOf(r, e) || hasConstructorOf(r, Promise) || hasConstructorOf(r, ArrayBuffer)) && !w && "object" !== s.iterateIn ? h = r : (_ = {}, s.addLength && (_.length = r.length), g = {
|
|
4122
4142
|
clone: _
|
|
4123
4143
|
}), O && O(), n.iterateNone) return _ || h;
|
|
4124
4144
|
if (!_) return h;
|
|
@@ -4482,7 +4502,7 @@ const O = {
|
|
|
4482
4502
|
})
|
|
4483
4503
|
}
|
|
4484
4504
|
};
|
|
4485
|
-
const
|
|
4505
|
+
const w = {
|
|
4486
4506
|
cryptokey: {
|
|
4487
4507
|
test: e => "CryptoKey" === toStringTag(e) && e.extractable,
|
|
4488
4508
|
replaceAsync: t => new e( /*#__PURE__*/function () {
|
|
@@ -4510,7 +4530,7 @@ const A = {
|
|
|
4510
4530
|
}) => crypto.subtle.importKey("jwk", e, t, !0, r)
|
|
4511
4531
|
}
|
|
4512
4532
|
},
|
|
4513
|
-
|
|
4533
|
+
A = {
|
|
4514
4534
|
dataview: {
|
|
4515
4535
|
test: e => "DataView" === toStringTag(e),
|
|
4516
4536
|
replace({
|
|
@@ -4823,7 +4843,7 @@ const W = {
|
|
|
4823
4843
|
}
|
|
4824
4844
|
}],
|
|
4825
4845
|
X = [K, x, L],
|
|
4826
|
-
te = [G, W, H, D, X, j, M, E, C, P, N, O].concat("function" == typeof Map ? U : [], "function" == typeof Set ? J : [], "function" == typeof ArrayBuffer ? h : [], "function" == typeof Uint8Array ? q : [], "function" == typeof DataView ?
|
|
4846
|
+
te = [G, W, H, D, X, j, M, E, C, P, N, O].concat("function" == typeof Map ? U : [], "function" == typeof Set ? J : [], "function" == typeof ArrayBuffer ? h : [], "function" == typeof Uint8Array ? q : [], "function" == typeof DataView ? A : [], "undefined" != typeof Intl ? B : [], "undefined" != typeof crypto ? w : [], "undefined" != typeof BigInt ? [m, g] : []);
|
|
4827
4847
|
var re = te.concat({
|
|
4828
4848
|
checkDataCloneException: {
|
|
4829
4849
|
test(e) {
|
|
@@ -4877,9 +4897,9 @@ function clone(val) {
|
|
|
4877
4897
|
|
|
4878
4898
|
var Sca = /*#__PURE__*/Object.freeze({
|
|
4879
4899
|
__proto__: null,
|
|
4880
|
-
encode: encode,
|
|
4881
|
-
decode: decode,
|
|
4882
4900
|
clone: clone,
|
|
4901
|
+
decode: decode,
|
|
4902
|
+
encode: encode,
|
|
4883
4903
|
register: register
|
|
4884
4904
|
});
|
|
4885
4905
|
|
|
@@ -6499,9 +6519,9 @@ Object.defineProperty(IDBDatabase, 'prototype', {
|
|
|
6499
6519
|
});
|
|
6500
6520
|
|
|
6501
6521
|
/* globals location */
|
|
6502
|
-
let fs
|
|
6522
|
+
let fs;
|
|
6503
6523
|
const setFS = _fs => {
|
|
6504
|
-
fs
|
|
6524
|
+
fs = _fs;
|
|
6505
6525
|
};
|
|
6506
6526
|
const getOrigin = () => {
|
|
6507
6527
|
return typeof location !== 'object' || !location ? 'null' : location.origin;
|
|
@@ -6638,8 +6658,8 @@ function cleanupDatabaseResources(__openDatabase, name, escapedDatabaseName, dat
|
|
|
6638
6658
|
});
|
|
6639
6659
|
return;
|
|
6640
6660
|
}
|
|
6641
|
-
if (fs
|
|
6642
|
-
fs
|
|
6661
|
+
if (fs && CFG.deleteDatabaseFiles !== false) {
|
|
6662
|
+
fs.unlink(path.join(CFG.databaseBasePath || '', escapedDatabaseName), err => {
|
|
6643
6663
|
if (err && err.code !== 'ENOENT') {
|
|
6644
6664
|
// Ignore if file is already deleted
|
|
6645
6665
|
dbError({
|
|
@@ -8131,22 +8151,20 @@ const UnicodeIDContinue = '(?:[$0-9A-Z_a-z\\xAA\\xB5\\xB7\\xBA\\xC0-\\xD6\\xD8-\
|
|
|
8131
8151
|
|
|
8132
8152
|
var UnicodeIdentifiers = /*#__PURE__*/Object.freeze({
|
|
8133
8153
|
__proto__: null,
|
|
8134
|
-
|
|
8135
|
-
|
|
8154
|
+
UnicodeIDContinue: UnicodeIDContinue,
|
|
8155
|
+
UnicodeIDStart: UnicodeIDStart
|
|
8136
8156
|
});
|
|
8137
8157
|
|
|
8138
|
-
// eslint-disable-next-line import/no-commonjs
|
|
8139
|
-
const fs = require('fs');
|
|
8140
8158
|
CFG.win = {
|
|
8141
8159
|
openDatabase: nodeWebSQL
|
|
8142
8160
|
};
|
|
8143
8161
|
const __setGlobalVars = function (idb, initialConfig = {}) {
|
|
8144
8162
|
const obj = setGlobalVars(idb, _objectSpread2$1({
|
|
8145
|
-
fs
|
|
8163
|
+
fs: fs$1
|
|
8146
8164
|
}, initialConfig));
|
|
8147
8165
|
obj.shimIndexedDB.__setUnicodeIdentifiers(UnicodeIdentifiers);
|
|
8148
8166
|
return obj;
|
|
8149
8167
|
};
|
|
8150
8168
|
|
|
8151
8169
|
module.exports = __setGlobalVars;
|
|
8152
|
-
//# sourceMappingURL=indexeddbshim-UnicodeIdentifiers-node.
|
|
8170
|
+
//# sourceMappingURL=indexeddbshim-UnicodeIdentifiers-node.cjs.map
|