@widget-js/core 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/cjs/api/ElectronApi.js +73 -53
  2. package/dist/cjs/api/Keys.js +11 -0
  3. package/dist/cjs/index.js +5 -0
  4. package/dist/cjs/model/BroadcastEvent.js +12 -0
  5. package/dist/cjs/model/SocialInfo.js +10 -0
  6. package/dist/cjs/model/Widget.js +60 -29
  7. package/dist/cjs/model/WidgetData.js +16 -0
  8. package/dist/cjs/model/WidgetParams.js +143 -0
  9. package/dist/cjs/repository/WidgetDataRepository.js +88 -0
  10. package/dist/cjs/router/encoding.js +144 -0
  11. package/dist/cjs/router/query.js +107 -0
  12. package/dist/esm/api/ElectronApi.js +73 -54
  13. package/dist/esm/api/Keys.js +7 -0
  14. package/dist/esm/index.js +5 -0
  15. package/dist/esm/model/BroadcastEvent.js +8 -0
  16. package/dist/esm/model/SocialInfo.js +6 -0
  17. package/dist/esm/model/Widget.js +60 -30
  18. package/dist/esm/model/WidgetData.js +12 -0
  19. package/dist/esm/model/WidgetParams.js +139 -0
  20. package/dist/esm/repository/WidgetDataRepository.js +81 -0
  21. package/dist/esm/router/encoding.js +135 -0
  22. package/dist/esm/router/query.js +101 -0
  23. package/dist/types/api/ElectronApi.d.ts +8 -0
  24. package/dist/types/api/Keys.d.ts +7 -0
  25. package/dist/types/index.d.ts +5 -0
  26. package/dist/types/model/BroadcastEvent.d.ts +7 -0
  27. package/dist/types/model/SocialInfo.d.ts +6 -0
  28. package/dist/types/model/Widget.d.ts +47 -5
  29. package/dist/types/model/WidgetData.d.ts +35 -0
  30. package/dist/types/model/WidgetParams.d.ts +63 -0
  31. package/dist/types/repository/WidgetDataRepository.d.ts +27 -0
  32. package/dist/types/router/encoding.d.ts +62 -0
  33. package/dist/types/router/query.d.ts +62 -0
  34. package/dist/umd/index.js +2 -1
  35. package/dist/umd/index.js.LICENSE.txt +6 -0
  36. package/package.json +7 -4
@@ -0,0 +1,27 @@
1
+ import { WidgetData } from "../model/WidgetData";
2
+ export declare class WidgetDataRepository {
3
+ private static stores;
4
+ /**
5
+ * 保存组件数据
6
+ * @param data
7
+ */
8
+ static save(data: WidgetData): Promise<string>;
9
+ /**
10
+ * 获取组件 LocalForage 存储实例
11
+ * @param name
12
+ */
13
+ static getStore(name: string): LocalForage;
14
+ /**
15
+ * 通过组件名保存组件信息,通常用于存储可以在同类组件中共用的数据
16
+ * @param name
17
+ * @param json
18
+ */
19
+ static saveByName(name: string, json: string): Promise<string>;
20
+ static findWithName<T extends WidgetData>(name: string, type: {
21
+ new (name: string, id?: string): T;
22
+ }): Promise<T | undefined>;
23
+ static find<T extends WidgetData>(name: string, id: string, type: {
24
+ new (name: string, id?: string): T;
25
+ }): Promise<T | undefined>;
26
+ private static getKey;
27
+ }
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Encoding Rules ␣ = Space Path: ␣ " < > # ? { } Query: ␣ " < > # & = Hash: ␣ "
3
+ * < > `
4
+ *
5
+ * On top of that, the RFC3986 (https://tools.ietf.org/html/rfc3986#section-2.2)
6
+ * defines some extra characters to be encoded. Most browsers do not encode them
7
+ * in encodeURI https://github.com/whatwg/url/issues/369, so it may be safer to
8
+ * also encode `!'()*`. Leaving un-encoded only ASCII alphanumeric(`a-zA-Z0-9`)
9
+ * plus `-._~`. This extra safety should be applied to query by patching the
10
+ * string returned by encodeURIComponent encodeURI also encodes `[\]^`. `\`
11
+ * should be encoded to avoid ambiguity. Browsers (IE, FF, C) transform a `\`
12
+ * into a `/` if directly typed in. The _backtick_ (`````) should also be
13
+ * encoded everywhere because some browsers like FF encode it when directly
14
+ * written while others don't. Safari and IE don't encode ``"<>{}``` in hash.
15
+ */
16
+ export declare const PLUS_RE: RegExp;
17
+ /**
18
+ * Encode characters that need to be encoded on the hash section of the URL.
19
+ *
20
+ * @param text - string to encode
21
+ * @returns encoded string
22
+ */
23
+ export declare function encodeHash(text: string): string;
24
+ /**
25
+ * Encode characters that need to be encoded query values on the query
26
+ * section of the URL.
27
+ *
28
+ * @param text - string to encode
29
+ * @returns encoded string
30
+ */
31
+ export declare function encodeQueryValue(text: string | number): string;
32
+ /**
33
+ * Like `encodeQueryValue` but also encodes the `=` character.
34
+ *
35
+ * @param text - string to encode
36
+ */
37
+ export declare function encodeQueryKey(text: string | number): string;
38
+ /**
39
+ * Encode characters that need to be encoded on the path section of the URL.
40
+ *
41
+ * @param text - string to encode
42
+ * @returns encoded string
43
+ */
44
+ export declare function encodePath(text: string | number): string;
45
+ /**
46
+ * Encode characters that need to be encoded on the path section of the URL as a
47
+ * param. This function encodes everything {@link encodePath} does plus the
48
+ * slash (`/`) character. If `text` is `null` or `undefined`, returns an empty
49
+ * string instead.
50
+ *
51
+ * @param text - string to encode
52
+ * @returns encoded string
53
+ */
54
+ export declare function encodeParam(text: string | number | null | undefined): string;
55
+ /**
56
+ * Decode text using `decodeURIComponent`. Returns the original text if it
57
+ * fails.
58
+ *
59
+ * @param text - string to decode
60
+ * @returns decoded string
61
+ */
62
+ export declare function decode(text: string | number): string;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Possible values in normalized {@link LocationQuery}. `null` renders the query
3
+ * param but without an `=`.
4
+ *
5
+ * @example
6
+ * ```
7
+ * ?isNull&isEmpty=&other=other
8
+ * gives
9
+ * `{ isNull: null, isEmpty: '', other: 'other' }`.
10
+ * ```
11
+ *
12
+ * @internal
13
+ */
14
+ export type LocationQueryValue = string | null;
15
+ /**
16
+ * Possible values when defining a query.
17
+ *
18
+ * @internal
19
+ */
20
+ export type LocationQueryValueRaw = LocationQueryValue | number | undefined;
21
+ /**
22
+ * Normalized query object that appears in {@link RouteLocationNormalized}
23
+ *
24
+ * @public
25
+ */
26
+ export type LocationQuery = Record<string, LocationQueryValue | LocationQueryValue[]>;
27
+ /**
28
+ * Loose {@link LocationQuery} object that can be passed to functions like
29
+ * {@link Router.push} and {@link Router.replace} or anywhere when creating a
30
+ * {@link RouteLocationRaw}
31
+ *
32
+ * @public
33
+ */
34
+ export type LocationQueryRaw = Record<string | number, LocationQueryValueRaw | LocationQueryValueRaw[]>;
35
+ /**
36
+ * Transforms a queryString into a {@link LocationQuery} object. Accept both, a
37
+ * version with the leading `?` and without Should work as URLSearchParams
38
+ * @internal
39
+ *
40
+ * @param search - search string to parse
41
+ * @returns a query object
42
+ */
43
+ export declare function parseQuery(search: string): LocationQuery;
44
+ /**
45
+ * Stringifies a {@link LocationQueryRaw} object. Like `URLSearchParams`, it
46
+ * doesn't prepend a `?`
47
+ *
48
+ * @internal
49
+ *
50
+ * @param query - query object to stringify
51
+ * @returns string version of the query without the leading `?`
52
+ */
53
+ export declare function stringifyQuery(query: LocationQueryRaw): string;
54
+ /**
55
+ * Transforms a {@link LocationQueryRaw} into a {@link LocationQuery} by casting
56
+ * numbers into strings, removing keys with an undefined value and replacing
57
+ * undefined with null in arrays
58
+ *
59
+ * @param query - query object to normalize
60
+ * @returns a normalized query object
61
+ */
62
+ export declare function normalizeQuery(query: LocationQueryRaw | undefined): LocationQuery;
package/dist/umd/index.js CHANGED
@@ -1 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.exampleTypescriptPackage=e():t.exampleTypescriptPackage=e()}(this,(()=>(()=>{"use strict";var t={991:function(t,e){var n=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{a(i.next(t))}catch(t){o(t)}}function c(t){try{a(i.throw(t))}catch(t){o(t)}}function a(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,c)}a((i=i.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(c){return function(a){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(s=0)),s;)try{if(n=1,i&&(r=2&c[0]?i.return:c[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,c[1])).done)return r;switch(i=0,r&&(c=[2&c[0],r.value]),c[0]){case 0:case 1:r=c;break;case 4:return s.label++,{value:c[1],done:!1};case 5:s.label++,i=c[1],c=[0];continue;case 7:c=s.ops.pop(),s.trys.pop();continue;default:if(!((r=(r=s.trys).length>0&&r[r.length-1])||6!==c[0]&&2!==c[0])){s=0;continue}if(3===c[0]&&(!r||c[1]>r[0]&&c[1]<r[3])){s.label=c[1];break}if(6===c[0]&&s.label<r[1]){s.label=r[1],r=c;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(c);break}r[2]&&s.ops.pop(),s.trys.pop();continue}c=e.call(t,s)}catch(t){c=[6,t],i=0}finally{n=r=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.ElectronApi=void 0;var r=function(){function t(){}return t.openAddWidgetWindow=function(){this.hasElectronApi()&&window.electronAPI.invokeIpc("openAddWidgetWindow")},t.registerWidgets=function(t){return n(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return this.hasElectronApi()?(e=JSON.parse(JSON.stringify(t.map((function(t){return t.stringify()})))),[4,window.electronAPI.invokeIpc("registerWidgets",e)]):[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.hasElectronApi=function(){return Reflect.has(window,"electronAPI")},t}();e.ElectronApi=r},432:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(n(203),e),r(n(991),e)},203:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.WidgetKeyword=e.Widget=void 0;var n,i=function(){function t(t,e,n,i,r,o,s,c,a,u,l,f,p,d){this.lang="zh",this.name=t,this.title=e,this.desc=n,this.keywords=i,this.lang=r,this.w=o,this.h=s,this.maxW=c,this.maxH=a,this.minW=u,this.minH=l,this.url=f,this.configUrl=p,this.debugUrl=d}return t.prototype.getTitle=function(t){return t?this.title.get(t):this.title.get(this.lang)},t.prototype.getDesc=function(t){return t?this.desc.get(t):this.desc.get(this.lang)},t.prototype.stringify=function(){var t=JSON.parse(JSON.stringify(this));return t.title=Object.fromEntries(this.title),t.desc=Object.fromEntries(this.desc),JSON.stringify(t)},t}();e.Widget=i,(n=e.WidgetKeyword||(e.WidgetKeyword={})).RECOMMEND="recommend",n.TOOLS="tools",n.EFFICIENCY="efficiency",n.PICTURE="picture",n.LIFE="life",n.SHORTCUT="shortcut",n.COUNTDOWN="countdown",n.TIMER="timer",n.INFO="info",n.DASHBOARD="dashboard"}},e={};return function n(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,n),o.exports}(432)})()));
1
+ /*! For license information please see index.js.LICENSE.txt */
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.exampleTypescriptPackage=t():e.exampleTypescriptPackage=t()}(this,(()=>(()=>{var e={483:(e,t,n)=>{e.exports=function e(t,n,r){function o(a,c){if(!n[a]){if(!t[a]){if(i)return i(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var s=n[a]={exports:{}};t[a][0].call(s.exports,(function(e){return o(t[a][1][e]||e)}),s,s.exports,e,t,n,r)}return n[a].exports}for(var i=void 0,a=0;a<r.length;a++)o(r[a]);return o}({1:[function(e,t,r){(function(e){"use strict";var n,r,o=e.MutationObserver||e.WebKitMutationObserver;if(o){var i=0,a=new o(f),c=e.document.createTextNode("");a.observe(c,{characterData:!0}),n=function(){c.data=i=++i%2}}else if(e.setImmediate||void 0===e.MessageChannel)n="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){f(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(f,0)};else{var u=new e.MessageChannel;u.port1.onmessage=f,n=function(){u.port2.postMessage(0)}}var s=[];function f(){var e,t;r=!0;for(var n=s.length;n;){for(t=s,s=[],e=-1;++e<n;)t[e]();n=s.length}r=!1}t.exports=function(e){1!==s.push(e)||r||n()}}).call(this,void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,n){"use strict";var r=e(1);function o(){}var i={},a=["REJECTED"],c=["FULFILLED"],u=["PENDING"];function s(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=u,this.queue=[],this.outcome=void 0,e!==o&&h(this,e)}function f(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function l(e,t,n){r((function(){var r;try{r=t(n)}catch(t){return i.reject(e,t)}r===e?i.reject(e,new TypeError("Cannot resolve promise with itself")):i.resolve(e,r)}))}function d(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function h(e,t){var n=!1;function r(t){n||(n=!0,i.reject(e,t))}function o(t){n||(n=!0,i.resolve(e,t))}var a=v((function(){t(o,r)}));"error"===a.status&&r(a.value)}function v(e,t){var n={};try{n.value=e(t),n.status="success"}catch(e){n.status="error",n.value=e}return n}t.exports=s,s.prototype.catch=function(e){return this.then(null,e)},s.prototype.then=function(e,t){if("function"!=typeof e&&this.state===c||"function"!=typeof t&&this.state===a)return this;var n=new this.constructor(o);return this.state!==u?l(n,this.state===c?e:t,this.outcome):this.queue.push(new f(n,e,t)),n},f.prototype.callFulfilled=function(e){i.resolve(this.promise,e)},f.prototype.otherCallFulfilled=function(e){l(this.promise,this.onFulfilled,e)},f.prototype.callRejected=function(e){i.reject(this.promise,e)},f.prototype.otherCallRejected=function(e){l(this.promise,this.onRejected,e)},i.resolve=function(e,t){var n=v(d,t);if("error"===n.status)return i.reject(e,n.value);var r=n.value;if(r)h(e,r);else{e.state=c,e.outcome=t;for(var o=-1,a=e.queue.length;++o<a;)e.queue[o].callFulfilled(t)}return e},i.reject=function(e,t){e.state=a,e.outcome=t;for(var n=-1,r=e.queue.length;++n<r;)e.queue[n].callRejected(t);return e},s.resolve=function(e){return e instanceof this?e:i.resolve(new this(o),e)},s.reject=function(e){var t=new this(o);return i.reject(t,e)},s.all=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,r=!1;if(!n)return this.resolve([]);for(var a=new Array(n),c=0,u=-1,s=new this(o);++u<n;)f(e[u],u);return s;function f(e,o){t.resolve(e).then((function(e){a[o]=e,++c!==n||r||(r=!0,i.resolve(s,a))}),(function(e){r||(r=!0,i.reject(s,e))}))}},s.race=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n,r=e.length,a=!1;if(!r)return this.resolve([]);for(var c=-1,u=new this(o);++c<r;)n=e[c],t.resolve(n).then((function(e){a||(a=!0,i.resolve(u,e))}),(function(e){a||(a=!0,i.reject(u,e))}));return u}},{1:1}],3:[function(e,t,r){(function(t){"use strict";"function"!=typeof t.Promise&&(t.Promise=e(2))}).call(this,void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(e,t,n){"use strict";var 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};var o=function(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(e){return}}();function i(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(o){if("TypeError"!==o.name)throw o;for(var n=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),r=0;r<e.length;r+=1)n.append(e[r]);return n.getBlob(t.type)}}"undefined"==typeof Promise&&e(3);var a=Promise;function c(e,t){t&&e.then((function(e){t(null,e)}),(function(e){t(e)}))}function u(e,t,n){"function"==typeof t&&e.then(t),"function"==typeof n&&e.catch(n)}function s(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function f(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var l="local-forage-detect-blob-support",d=void 0,h={},v=Object.prototype.toString,p="readonly",y="readwrite";function g(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),o=0;o<t;o++)r[o]=e.charCodeAt(o);return n}function m(e){return"boolean"==typeof d?a.resolve(d):function(e){return new a((function(t){var n=e.transaction(l,y),r=i([""]);n.objectStore(l).put(r,"key"),n.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)},n.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);t(n||!e||parseInt(e[1],10)>=43)}})).catch((function(){return!1}))}(e).then((function(e){return d=e}))}function b(e){var t=h[e.name],n={};n.promise=new a((function(e,t){n.resolve=e,n.reject=t})),t.deferredOperations.push(n),t.dbReady?t.dbReady=t.dbReady.then((function(){return n.promise})):t.dbReady=n.promise}function _(e){var t=h[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function A(e,t){var n=h[e.name].deferredOperations.pop();if(n)return n.reject(t),n.promise}function w(e,t){return new a((function(n,r){if(h[e.name]=h[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return n(e.db);b(e),e.db.close()}var i=[e.name];t&&i.push(e.version);var a=o.open.apply(o,i);t&&(a.onupgradeneeded=function(t){var n=a.result;try{n.createObjectStore(e.storeName),t.oldVersion<=1&&n.createObjectStore(l)}catch(n){if("ConstraintError"!==n.name)throw n;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),a.onerror=function(e){e.preventDefault(),r(a.error)},a.onsuccess=function(){var t=a.result;t.onversionchange=function(e){e.target.close()},n(t),_(e)}}))}function I(e){return w(e,!1)}function E(e){return w(e,!0)}function S(e,t){if(!e.db)return!0;var n=!e.db.objectStoreNames.contains(e.storeName),r=e.version<e.db.version,o=e.version>e.db.version;if(r&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),o||n){if(n){var i=e.db.version+1;i>e.version&&(e.version=i)}return!0}return!1}function R(e){return i([g(atob(e.data))],{type:e.type})}function P(e){return e&&e.__local_forage_encoded_blob}function O(e){var t=this,n=t._initReady().then((function(){var e=h[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return u(n,e,e),n}function N(e,t,n,r){void 0===r&&(r=1);try{var o=e.db.transaction(e.storeName,t);n(null,o)}catch(o){if(r>0&&(!e.db||"InvalidStateError"===o.name||"NotFoundError"===o.name))return a.resolve().then((function(){if(!e.db||"NotFoundError"===o.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),E(e)})).then((function(){return function(e){b(e);for(var t=h[e.name],n=t.forages,r=0;r<n.length;r++){var o=n[r];o._dbInfo.db&&(o._dbInfo.db.close(),o._dbInfo.db=null)}return e.db=null,I(e).then((function(t){return e.db=t,S(e)?E(e):t})).then((function(r){e.db=t.db=r;for(var o=0;o<n.length;o++)n[o]._dbInfo.db=r})).catch((function(t){throw A(e,t),t}))}(e).then((function(){N(e,t,n,r-1)}))})).catch(n);n(o)}}var D={_driver:"asyncStorage",_initStorage:function(e){var t=this,n={db:null};if(e)for(var r in e)n[r]=e[r];var o=h[n.name];o||(o={forages:[],db:null,dbReady:null,deferredOperations:[]},h[n.name]=o),o.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=O);var i=[];function c(){return a.resolve()}for(var u=0;u<o.forages.length;u++){var s=o.forages[u];s!==t&&i.push(s._initReady().catch(c))}var f=o.forages.slice(0);return a.all(i).then((function(){return n.db=o.db,I(n)})).then((function(e){return n.db=e,S(n,t._defaultConfig.version)?E(n):e})).then((function(e){n.db=o.db=e,t._dbInfo=n;for(var r=0;r<f.length;r++){var i=f[r];i!==t&&(i._dbInfo.db=n.db,i._dbInfo.version=n.version)}}))},_support:function(){try{if(!o||!o.open)return!1;var e="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!e||t)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(e){return!1}}(),iterate:function(e,t){var n=this,r=new a((function(t,r){n.ready().then((function(){N(n._dbInfo,p,(function(o,i){if(o)return r(o);try{var a=i.objectStore(n._dbInfo.storeName).openCursor(),c=1;a.onsuccess=function(){var n=a.result;if(n){var r=n.value;P(r)&&(r=R(r));var o=e(r,n.key,c++);void 0!==o?t(o):n.continue()}else t()},a.onerror=function(){r(a.error)}}catch(e){r(e)}}))})).catch(r)}));return c(r,t),r},getItem:function(e,t){var n=this;e=s(e);var r=new a((function(t,r){n.ready().then((function(){N(n._dbInfo,p,(function(o,i){if(o)return r(o);try{var a=i.objectStore(n._dbInfo.storeName).get(e);a.onsuccess=function(){var e=a.result;void 0===e&&(e=null),P(e)&&(e=R(e)),t(e)},a.onerror=function(){r(a.error)}}catch(e){r(e)}}))})).catch(r)}));return c(r,t),r},setItem:function(e,t,n){var r=this;e=s(e);var o=new a((function(n,o){var i;r.ready().then((function(){return i=r._dbInfo,"[object Blob]"===v.call(t)?m(i.db).then((function(e){return e?t:(n=t,new a((function(e,t){var r=new FileReader;r.onerror=t,r.onloadend=function(t){var r=btoa(t.target.result||"");e({__local_forage_encoded_blob:!0,data:r,type:n.type})},r.readAsBinaryString(n)})));var n})):t})).then((function(t){N(r._dbInfo,y,(function(i,a){if(i)return o(i);try{var c=a.objectStore(r._dbInfo.storeName);null===t&&(t=void 0);var u=c.put(t,e);a.oncomplete=function(){void 0===t&&(t=null),n(t)},a.onabort=a.onerror=function(){var e=u.error?u.error:u.transaction.error;o(e)}}catch(e){o(e)}}))})).catch(o)}));return c(o,n),o},removeItem:function(e,t){var n=this;e=s(e);var r=new a((function(t,r){n.ready().then((function(){N(n._dbInfo,y,(function(o,i){if(o)return r(o);try{var a=i.objectStore(n._dbInfo.storeName).delete(e);i.oncomplete=function(){t()},i.onerror=function(){r(a.error)},i.onabort=function(){var e=a.error?a.error:a.transaction.error;r(e)}}catch(e){r(e)}}))})).catch(r)}));return c(r,t),r},clear:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){N(t._dbInfo,y,(function(r,o){if(r)return n(r);try{var i=o.objectStore(t._dbInfo.storeName).clear();o.oncomplete=function(){e()},o.onabort=o.onerror=function(){var e=i.error?i.error:i.transaction.error;n(e)}}catch(e){n(e)}}))})).catch(n)}));return c(n,e),n},length:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){N(t._dbInfo,p,(function(r,o){if(r)return n(r);try{var i=o.objectStore(t._dbInfo.storeName).count();i.onsuccess=function(){e(i.result)},i.onerror=function(){n(i.error)}}catch(e){n(e)}}))})).catch(n)}));return c(n,e),n},key:function(e,t){var n=this,r=new a((function(t,r){e<0?t(null):n.ready().then((function(){N(n._dbInfo,p,(function(o,i){if(o)return r(o);try{var a=i.objectStore(n._dbInfo.storeName),c=!1,u=a.openKeyCursor();u.onsuccess=function(){var n=u.result;n?0===e||c?t(n.key):(c=!0,n.advance(e)):t(null)},u.onerror=function(){r(u.error)}}catch(e){r(e)}}))})).catch(r)}));return c(r,t),r},keys:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){N(t._dbInfo,p,(function(r,o){if(r)return n(r);try{var i=o.objectStore(t._dbInfo.storeName).openKeyCursor(),a=[];i.onsuccess=function(){var t=i.result;t?(a.push(t.key),t.continue()):e(a)},i.onerror=function(){n(i.error)}}catch(e){n(e)}}))})).catch(n)}));return c(n,e),n},dropInstance:function(e,t){t=f.apply(this,arguments);var n=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName);var r,i=this;if(e.name){var u=e.name===n.name&&i._dbInfo.db?a.resolve(i._dbInfo.db):I(e).then((function(t){var n=h[e.name],r=n.forages;n.db=t;for(var o=0;o<r.length;o++)r[o]._dbInfo.db=t;return t}));r=e.storeName?u.then((function(t){if(t.objectStoreNames.contains(e.storeName)){var n=t.version+1;b(e);var r=h[e.name],i=r.forages;t.close();for(var c=0;c<i.length;c++){var u=i[c];u._dbInfo.db=null,u._dbInfo.version=n}var s=new a((function(t,r){var i=o.open(e.name,n);i.onerror=function(e){i.result.close(),r(e)},i.onupgradeneeded=function(){i.result.deleteObjectStore(e.storeName)},i.onsuccess=function(){var e=i.result;e.close(),t(e)}}));return s.then((function(e){r.db=e;for(var t=0;t<i.length;t++){var n=i[t];n._dbInfo.db=e,_(n._dbInfo)}})).catch((function(t){throw(A(e,t)||a.resolve()).catch((function(){})),t}))}})):u.then((function(t){b(e);var n=h[e.name],r=n.forages;t.close();for(var i=0;i<r.length;i++)r[i]._dbInfo.db=null;var c=new a((function(t,n){var r=o.deleteDatabase(e.name);r.onerror=function(){var e=r.result;e&&e.close(),n(r.error)},r.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},r.onsuccess=function(){var e=r.result;e&&e.close(),t(e)}}));return c.then((function(e){n.db=e;for(var t=0;t<r.length;t++)_(r[t]._dbInfo)})).catch((function(t){throw(A(e,t)||a.resolve()).catch((function(){})),t}))}))}else r=a.reject("Invalid arguments");return c(r,t),r}};var M="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",T=/^~~local_forage_type~([^~]+)~/,j="__lfsc__:",x=j.length,B="arbf",W="blob",C="si08",k="ui08",L="uic8",U="si16",H="si32",F="ur16",z="ui32",K="fl32",G="fl64",Q=x+B.length,V=Object.prototype.toString;function J(e){var t,n,r,o,i,a=.75*e.length,c=e.length,u=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var s=new ArrayBuffer(a),f=new Uint8Array(s);for(t=0;t<c;t+=4)n=M.indexOf(e[t]),r=M.indexOf(e[t+1]),o=M.indexOf(e[t+2]),i=M.indexOf(e[t+3]),f[u++]=n<<2|r>>4,f[u++]=(15&r)<<4|o>>2,f[u++]=(3&o)<<6|63&i;return s}function q(e){var t,n=new Uint8Array(e),r="";for(t=0;t<n.length;t+=3)r+=M[n[t]>>2],r+=M[(3&n[t])<<4|n[t+1]>>4],r+=M[(15&n[t+1])<<2|n[t+2]>>6],r+=M[63&n[t+2]];return n.length%3==2?r=r.substring(0,r.length-1)+"=":n.length%3==1&&(r=r.substring(0,r.length-2)+"=="),r}var X={serialize:function(e,t){var n="";if(e&&(n=V.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===V.call(e.buffer))){var r,o=j;e instanceof ArrayBuffer?(r=e,o+=B):(r=e.buffer,"[object Int8Array]"===n?o+=C:"[object Uint8Array]"===n?o+=k:"[object Uint8ClampedArray]"===n?o+=L:"[object Int16Array]"===n?o+=U:"[object Uint16Array]"===n?o+=F:"[object Int32Array]"===n?o+=H:"[object Uint32Array]"===n?o+=z:"[object Float32Array]"===n?o+=K:"[object Float64Array]"===n?o+=G:t(new Error("Failed to get type for BinaryArray"))),t(o+q(r))}else if("[object Blob]"===n){var i=new FileReader;i.onload=function(){var n="~~local_forage_type~"+e.type+"~"+q(this.result);t("__lfsc__:blob"+n)},i.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(n){console.error("Couldn't convert value into a JSON string: ",e),t(null,n)}},deserialize:function(e){if(e.substring(0,x)!==j)return JSON.parse(e);var t,n=e.substring(Q),r=e.substring(x,Q);if(r===W&&T.test(n)){var o=n.match(T);t=o[1],n=n.substring(o[0].length)}var a=J(n);switch(r){case B:return a;case W:return i([a],{type:t});case C:return new Int8Array(a);case k:return new Uint8Array(a);case L:return new Uint8ClampedArray(a);case U:return new Int16Array(a);case F:return new Uint16Array(a);case H:return new Int32Array(a);case z:return new Uint32Array(a);case K:return new Float32Array(a);case G:return new Float64Array(a);default:throw new Error("Unkown type: "+r)}},stringToBuffer:J,bufferToString:q};function Y(e,t,n,r){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],n,r)}function $(e,t,n,r,o,i){e.executeSql(n,r,o,(function(e,a){a.code===a.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,c){c.rows.length?i(e,a):Y(e,t,(function(){e.executeSql(n,r,o,i)}),i)}),i):i(e,a)}),i)}function Z(e,t,n,r){var o=this;e=s(e);var i=new a((function(i,a){o.ready().then((function(){void 0===t&&(t=null);var c=t,u=o._dbInfo;u.serializer.serialize(t,(function(t,s){s?a(s):u.db.transaction((function(n){$(n,u,"INSERT OR REPLACE INTO "+u.storeName+" (key, value) VALUES (?, ?)",[e,t],(function(){i(c)}),(function(e,t){a(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(r>0)return void i(Z.apply(o,[e,c,n,r-1]));a(t)}}))}))})).catch(a)}));return c(i,n),i}function ee(e){return new a((function(t,n){e.transaction((function(r){r.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(n,r){for(var o=[],i=0;i<r.rows.length;i++)o.push(r.rows.item(i).name);t({db:e,storeNames:o})}),(function(e,t){n(t)}))}),(function(e){n(e)}))}))}var te={_driver:"webSQLStorage",_initStorage:function(e){var t=this,n={db:null};if(e)for(var r in e)n[r]="string"!=typeof e[r]?e[r].toString():e[r];var o=new a((function(e,r){try{n.db=openDatabase(n.name,String(n.version),n.description,n.size)}catch(e){return r(e)}n.db.transaction((function(o){Y(o,n,(function(){t._dbInfo=n,e()}),(function(e,t){r(t)}))}),r)}));return n.serializer=X,o},_support:"function"==typeof openDatabase,iterate:function(e,t){var n=this,r=new a((function(t,r){n.ready().then((function(){var o=n._dbInfo;o.db.transaction((function(n){$(n,o,"SELECT * FROM "+o.storeName,[],(function(n,r){for(var i=r.rows,a=i.length,c=0;c<a;c++){var u=i.item(c),s=u.value;if(s&&(s=o.serializer.deserialize(s)),void 0!==(s=e(s,u.key,c+1)))return void t(s)}t()}),(function(e,t){r(t)}))}))})).catch(r)}));return c(r,t),r},getItem:function(e,t){var n=this;e=s(e);var r=new a((function(t,r){n.ready().then((function(){var o=n._dbInfo;o.db.transaction((function(n){$(n,o,"SELECT * FROM "+o.storeName+" WHERE key = ? LIMIT 1",[e],(function(e,n){var r=n.rows.length?n.rows.item(0).value:null;r&&(r=o.serializer.deserialize(r)),t(r)}),(function(e,t){r(t)}))}))})).catch(r)}));return c(r,t),r},setItem:function(e,t,n){return Z.apply(this,[e,t,n,1])},removeItem:function(e,t){var n=this;e=s(e);var r=new a((function(t,r){n.ready().then((function(){var o=n._dbInfo;o.db.transaction((function(n){$(n,o,"DELETE FROM "+o.storeName+" WHERE key = ?",[e],(function(){t()}),(function(e,t){r(t)}))}))})).catch(r)}));return c(r,t),r},clear:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){var r=t._dbInfo;r.db.transaction((function(t){$(t,r,"DELETE FROM "+r.storeName,[],(function(){e()}),(function(e,t){n(t)}))}))})).catch(n)}));return c(n,e),n},length:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){var r=t._dbInfo;r.db.transaction((function(t){$(t,r,"SELECT COUNT(key) as c FROM "+r.storeName,[],(function(t,n){var r=n.rows.item(0).c;e(r)}),(function(e,t){n(t)}))}))})).catch(n)}));return c(n,e),n},key:function(e,t){var n=this,r=new a((function(t,r){n.ready().then((function(){var o=n._dbInfo;o.db.transaction((function(n){$(n,o,"SELECT key FROM "+o.storeName+" WHERE id = ? LIMIT 1",[e+1],(function(e,n){var r=n.rows.length?n.rows.item(0).key:null;t(r)}),(function(e,t){r(t)}))}))})).catch(r)}));return c(r,t),r},keys:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){var r=t._dbInfo;r.db.transaction((function(t){$(t,r,"SELECT key FROM "+r.storeName,[],(function(t,n){for(var r=[],o=0;o<n.rows.length;o++)r.push(n.rows.item(o).key);e(r)}),(function(e,t){n(t)}))}))})).catch(n)}));return c(n,e),n},dropInstance:function(e,t){t=f.apply(this,arguments);var n=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName);var r,o=this;return c(r=e.name?new a((function(t){var r;r=e.name===n.name?o._dbInfo.db:openDatabase(e.name,"","",0),e.storeName?t({db:r,storeNames:[e.storeName]}):t(ee(r))})).then((function(e){return new a((function(t,n){e.db.transaction((function(r){function o(e){return new a((function(t,n){r.executeSql("DROP TABLE IF EXISTS "+e,[],(function(){t()}),(function(e,t){n(t)}))}))}for(var i=[],c=0,u=e.storeNames.length;c<u;c++)i.push(o(e.storeNames[c]));a.all(i).then((function(){t()})).catch((function(e){n(e)}))}),(function(e){n(e)}))}))})):a.reject("Invalid arguments"),t),r}};function ne(e,t){var n=e.name+"/";return e.storeName!==t.storeName&&(n+=e.storeName+"/"),n}function re(){return!function(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch(e){return!0}}()||localStorage.length>0}var oe={_driver:"localStorageWrapper",_initStorage:function(e){var t={};if(e)for(var n in e)t[n]=e[n];return t.keyPrefix=ne(e,this._defaultConfig),re()?(this._dbInfo=t,t.serializer=X,a.resolve()):a.reject()},_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}(),iterate:function(e,t){var n=this,r=n.ready().then((function(){for(var t=n._dbInfo,r=t.keyPrefix,o=r.length,i=localStorage.length,a=1,c=0;c<i;c++){var u=localStorage.key(c);if(0===u.indexOf(r)){var s=localStorage.getItem(u);if(s&&(s=t.serializer.deserialize(s)),void 0!==(s=e(s,u.substring(o),a++)))return s}}}));return c(r,t),r},getItem:function(e,t){var n=this;e=s(e);var r=n.ready().then((function(){var t=n._dbInfo,r=localStorage.getItem(t.keyPrefix+e);return r&&(r=t.serializer.deserialize(r)),r}));return c(r,t),r},setItem:function(e,t,n){var r=this;e=s(e);var o=r.ready().then((function(){void 0===t&&(t=null);var n=t;return new a((function(o,i){var a=r._dbInfo;a.serializer.serialize(t,(function(t,r){if(r)i(r);else try{localStorage.setItem(a.keyPrefix+e,t),o(n)}catch(e){"QuotaExceededError"!==e.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==e.name||i(e),i(e)}}))}))}));return c(o,n),o},removeItem:function(e,t){var n=this;e=s(e);var r=n.ready().then((function(){var t=n._dbInfo;localStorage.removeItem(t.keyPrefix+e)}));return c(r,t),r},clear:function(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo.keyPrefix,n=localStorage.length-1;n>=0;n--){var r=localStorage.key(n);0===r.indexOf(e)&&localStorage.removeItem(r)}}));return c(n,e),n},length:function(e){var t=this.keys().then((function(e){return e.length}));return c(t,e),t},key:function(e,t){var n=this,r=n.ready().then((function(){var t,r=n._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(r.keyPrefix.length)),t}));return c(r,t),r},keys:function(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo,n=localStorage.length,r=[],o=0;o<n;o++){var i=localStorage.key(o);0===i.indexOf(e.keyPrefix)&&r.push(i.substring(e.keyPrefix.length))}return r}));return c(n,e),n},dropInstance:function(e,t){if(t=f.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var n=this.config();e.name=e.name||n.name,e.storeName=e.storeName||n.storeName}var r,o=this;return r=e.name?new a((function(t){e.storeName?t(ne(e,o._defaultConfig)):t(e.name+"/")})).then((function(e){for(var t=localStorage.length-1;t>=0;t--){var n=localStorage.key(t);0===n.indexOf(e)&&localStorage.removeItem(n)}})):a.reject("Invalid arguments"),c(r,t),r}},ie=function(e,t){for(var n=e.length,r=0;r<n;){if((o=e[r])===(i=t)||"number"==typeof o&&"number"==typeof i&&isNaN(o)&&isNaN(i))return!0;r++}var o,i;return!1},ae=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},ce={},ue={},se={INDEXEDDB:D,WEBSQL:te,LOCALSTORAGE:oe},fe=[se.INDEXEDDB._driver,se.WEBSQL._driver,se.LOCALSTORAGE._driver],le=["dropInstance"],de=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(le),he={description:"",driver:fe.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function ve(e,t){e[t]=function(){var n=arguments;return e.ready().then((function(){return e[t].apply(e,n)}))}}function pe(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var n in t)t.hasOwnProperty(n)&&(ae(t[n])?arguments[0][n]=t[n].slice():arguments[0][n]=t[n])}return arguments[0]}var ye=function(){function e(t){for(var n in function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),se)if(se.hasOwnProperty(n)){var r=se[n],o=r._driver;this[n]=o,ce[o]||this.defineDriver(r)}this._defaultConfig=pe({},he),this._config=pe({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch((function(){}))}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":r(e))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return new Error("Database version must be a number.");this._config[t]=e[t]}return!("driver"in e)||!e.driver||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config},e.prototype.defineDriver=function(e,t,n){var r=new a((function(t,n){try{var r=e._driver,o=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void n(o);for(var i=de.concat("_initStorage"),u=0,s=i.length;u<s;u++){var f=i[u];if((!ie(le,f)||e[f])&&"function"!=typeof e[f])return void n(o)}!function(){for(var t=function(e){return function(){var t=new Error("Method "+e+" is not implemented by the current driver"),n=a.reject(t);return c(n,arguments[arguments.length-1]),n}},n=0,r=le.length;n<r;n++){var o=le[n];e[o]||(e[o]=t(o))}}();var l=function(n){ce[r]&&console.info("Redefining LocalForage driver: "+r),ce[r]=e,ue[r]=n,t()};"_support"in e?e._support&&"function"==typeof e._support?e._support().then(l,n):l(!!e._support):l(!0)}catch(e){n(e)}}));return u(r,t,n),r},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,t,n){var r=ce[e]?a.resolve(ce[e]):a.reject(new Error("Driver not found."));return u(r,t,n),r},e.prototype.getSerializer=function(e){var t=a.resolve(X);return u(t,e),t},e.prototype.ready=function(e){var t=this,n=t._driverSet.then((function(){return null===t._ready&&(t._ready=t._initDriver()),t._ready}));return u(n,e,e),n},e.prototype.setDriver=function(e,t,n){var r=this;ae(e)||(e=[e]);var o=this._getSupportedDrivers(e);function i(){r._config.driver=r.driver()}function c(e){return r._extend(e),i(),r._ready=r._initStorage(r._config),r._ready}var s=null!==this._driverSet?this._driverSet.catch((function(){return a.resolve()})):a.resolve();return this._driverSet=s.then((function(){var e=o[0];return r._dbInfo=null,r._ready=null,r.getDriver(e).then((function(e){r._driver=e._driver,i(),r._wrapLibraryMethodsWithReady(),r._initDriver=function(e){return function(){var t=0;return function n(){for(;t<e.length;){var o=e[t];return t++,r._dbInfo=null,r._ready=null,r.getDriver(o).then(c).catch(n)}i();var u=new Error("No available storage method found.");return r._driverSet=a.reject(u),r._driverSet}()}}(o)}))})).catch((function(){i();var e=new Error("No available storage method found.");return r._driverSet=a.reject(e),r._driverSet})),u(this._driverSet,t,n),this._driverSet},e.prototype.supports=function(e){return!!ue[e]},e.prototype._extend=function(e){pe(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],n=0,r=e.length;n<r;n++){var o=e[n];this.supports(o)&&t.push(o)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=de.length;e<t;e++)ve(this,de[e])},e.prototype.createInstance=function(t){return new e(t)},e}(),ge=new ye;t.exports=ge},{3:3}]},{},[4])(4)},991:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function c(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ElectronApi=void 0;const o=n(873);t.ElectronApi=class{static openAddWidgetWindow(){this.hasElectronApi()&&window.electronAPI.invokeIpc("openAddWidgetWindow")}static registerWidgets(e){return r(this,void 0,void 0,(function*(){if(this.hasElectronApi()){const t=JSON.parse(JSON.stringify(e.map((e=>JSON.stringify(e)))));yield window.electronAPI.invokeIpc("registerWidgets",t)}}))}static setConfig(e,t){return r(this,void 0,void 0,(function*(){this.hasElectronApi()&&(yield window.electronAPI.invokeIpc("setConfig",{key:e,value:t}))}))}static sendBroadcastEvent(e){return r(this,void 0,void 0,(function*(){this.hasElectronApi()&&(yield window.electronAPI.invokeIpc(o.Keys.BROADCAST_EVENT,JSON.stringify(e)))}))}static registerBroadcast(e){return r(this,void 0,void 0,(function*(){yield this.addIpcListener(o.Keys.BROADCAST_EVENT,(t=>{e(JSON.parse(t))}))}))}static unregisterBroadcast(){return r(this,void 0,void 0,(function*(){yield this.removeIpcListener(o.Keys.BROADCAST_EVENT)}))}static addIpcListener(e,t){return r(this,void 0,void 0,(function*(){this.hasElectronApi()&&(yield window.electronAPI.addIpcListener(e,t))}))}static removeIpcListener(e){return r(this,void 0,void 0,(function*(){this.hasElectronApi()&&(yield window.electronAPI.removeIpcListener(e))}))}static getConfig(e,t){return r(this,void 0,void 0,(function*(){if(this.hasElectronApi()){const n=yield window.electronAPI.invokeIpc("getConfig",e);return null==n?t:"boolean"==typeof t?"true"===n:n}}))}static hasElectronApi(){return Reflect.has(window,"electronAPI")}}},873:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Keys=void 0;class n{}t.Keys=n,n.CONFIG_LAUNCH_AT_STARTUP="LAUNCH_AT_STARTUP",n.CONFIG_WIDGET_SHADOW="WIDGET_SHADOW",n.CHANNEL_MAIN="WeiZ5kaKijae",n.EVENT_WIDGET_UPDATED="WIDGET_SHADOW",n.BROADCAST_EVENT="sendBroadcastEvent"},432:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(203),t),o(n(982),t),o(n(791),t),o(n(387),t),o(n(991),t),o(n(873),t),o(n(865),t)},982:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BroadcastEvent=void 0;class n{constructor(e,t,n){this.type=e,this.from=t,this.payload=n}}t.BroadcastEvent=n,n.TYPE_WIDGET_UPDATED="BROADCAST:WIDGET_UPDATED"},203:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WidgetKeyword=t.Widget=void 0;class n{constructor(e){var t,n,r,o,i;this.lang="zh",this.name=e.name,this.title=e.title,this.description=e.description,this.keywords=e.keywords,this.lang=e.lang,this.w=e.w,this.h=e.h,this.maxW=null!==(t=e.maxW)&&void 0!==t?t:e.w,this.maxH=null!==(n=e.maxH)&&void 0!==n?n:e.h,this.minW=null!==(r=e.minW)&&void 0!==r?r:e.w,this.minH=null!==(o=e.minH)&&void 0!==o?o:e.h,this.url=e.url,this.configUrl=e.configUrl,this.extraUrl=null!==(i=e.extraUrl)&&void 0!==i?i:new Map}getTitle(e){return e?this.title.get(e):this.title.get(this.lang)}getDescription(e){return e?this.description.get(e):this.description.get(this.lang)}toJSON(){return{name:this.name,title:Object.fromEntries(this.title),description:Object.fromEntries(this.description),keywords:this.keywords,lang:this.lang,w:this.w,h:this.h,maxW:this.maxW,maxH:this.maxH,minW:this.minW,minH:this.minH,url:this.url,configUrl:this.configUrl,extraUrl:Object.fromEntries(this.extraUrl)}}static parse(e){const t=JSON.parse(e);return new n({configUrl:t.configUrl,description:new Map(Object.entries(t.description)),extraUrl:new Map(Object.entries(t.extraUrl)),h:t.h,keywords:t.keywords,lang:t.lang,maxH:t.maxH,maxW:t.maxW,minH:t.minH,minW:t.minW,name:t.name,title:new Map(Object.entries(t.title)),url:t.url,w:t.w})}}var r;t.Widget=n,(r=t.WidgetKeyword||(t.WidgetKeyword={})).RECOMMEND="recommend",r.TOOLS="tools",r.EFFICIENCY="efficiency",r.PICTURE="picture",r.LIFE="life",r.SHORTCUT="shortcut",r.COUNTDOWN="countdown",r.TIMER="timer",r.INFO="info",r.DASHBOARD="dashboard"},791:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WidgetData=void 0,t.WidgetData=class{constructor(e,t){this.id=t,this.name=e}parseJSON(e){Object.assign(this,e)}}},387:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WidgetHostMode=t.ThemeMode=t.WidgetParams=void 0;const r=n(470);class o{toUrlParams(){const e=new URLSearchParams,t=Object.getOwnPropertyNames(this);for(let n of t){const t=this[n];t&&e.append(o.PARAM_PREFIX+n,t.toString())}return e}getPersistKey(){return`${this.name}-${this.id}`}static fromCurrentLocation(){let e=window.location.href.split("?")[1];return this.fromObject((0,r.parseQuery)(e))}static setValue(e,t,n){const r=t.replace(this.PARAM_PREFIX,"");r==o.PARAM_ID?e.id=n:r==o.PARAM_X?e.x=parseInt(n):r==o.PARAM_Y?e.y=parseInt(n):r==o.PARAM_H?e.h=parseInt(n):r==o.PARAM_W?e.w=parseInt(n):r==o.PARAM_LANG?e.lang=n:r==o.PARAM_THEME?e.theme=n:r==o.PARAM_MODE?e.mode=parseInt(n):r==o.PARAM_RADIUS?e.radius=parseInt(n):r==o.PARAM_WIDTH?e.width=parseInt(n):r==o.PARAM_HEIGHT?e.height=parseInt(n):r==o.PARAM_NAME?e.name=n:r==o.PARAM_TITLE?e.title=n:r==o.PARAM_PREVIEW&&(e.preview="true"===n)}static fromObject(e){const t=new o,n=Object.getOwnPropertyNames(e);for(let r of n){const n=r,o=e[n];this.setValue(t,n,o)}return t}}var i,a;t.WidgetParams=o,o.PARAM_PREFIX="w_",o.PARAM_ID="id",o.PARAM_W="w",o.PARAM_H="h",o.PARAM_WIDTH="width",o.PARAM_HEIGHT="height",o.PARAM_X="x",o.PARAM_Y="y",o.PARAM_LANG="lang",o.PARAM_THEME="theme",o.PARAM_MODE="mode",o.PARAM_RADIUS="radius",o.PARAM_NAME="name",o.PARAM_TITLE="title",o.PARAM_PREVIEW="preview",o.PARAMS=[o.PARAM_ID,o.PARAM_W,o.PARAM_H,o.PARAM_X,o.PARAM_Y,o.PARAM_LANG,o.PARAM_THEME,o.PARAM_MODE,o.PARAM_WIDTH,o.PARAM_HEIGHT,o.PARAM_NAME,o.PARAM_TITLE,o.PARAM_PREVIEW],(a=t.ThemeMode||(t.ThemeMode={})).AUTO="auto",a.LIGHT="LIGHT",a.DARK="DARK",(i=t.WidgetHostMode||(t.WidgetHostMode={}))[i.DEFAULT=0]="DEFAULT",i[i.OVERLAP=1]="OVERLAP"},865:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function c(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WidgetDataRepository=void 0;const i=o(n(483)),a=n(982),c=n(991);class u{static save(e){return r(this,void 0,void 0,(function*(){let t=this.getStore(e.name);const n=yield t.setItem(this.getKey(e.name,e.id),JSON.stringify(e)),r=new a.BroadcastEvent(a.BroadcastEvent.TYPE_WIDGET_UPDATED,"",e);return yield c.ElectronApi.sendBroadcastEvent(r),n}))}static getStore(e){if(this.stores.has(e))return this.stores.get(e);const t=i.default.createInstance({name:e});return this.stores.set(e,t),t}static saveByName(e,t){return r(this,void 0,void 0,(function*(){let n=this.getStore(e);const r=yield n.setItem(e,t),o=new a.BroadcastEvent(a.BroadcastEvent.TYPE_WIDGET_UPDATED,"",{name:e,json:t});return yield c.ElectronApi.sendBroadcastEvent(o),r}))}static findWithName(e,t){return r(this,void 0,void 0,(function*(){let n=this.getStore(e),r=yield n.getItem(e);if(r){const n=new t(e);return n.parseJSON(JSON.parse(r)),n}}))}static find(e,t,n){return r(this,void 0,void 0,(function*(){let r=this.getStore(e),o=yield r.getItem(this.getKey(e,t));if(o){const r=new n(e,t);return r.parseJSON(JSON.parse(o)),r}}))}static getKey(e,t){return`${e}@${t}`}}t.WidgetDataRepository=u,u.stores=new Map},194:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=t.encodeParam=t.encodePath=t.encodeQueryKey=t.encodeQueryValue=t.encodeHash=t.PLUS_RE=void 0;const n=/#/g,r=/&/g,o=/\//g,i=/=/g,a=/\?/g;t.PLUS_RE=/\+/g;const c=/%5B/g,u=/%5D/g,s=/%5E/g,f=/%60/g,l=/%7B/g,d=/%7C/g,h=/%7D/g,v=/%20/g;function p(e){return encodeURI(""+e).replace(d,"|").replace(c,"[").replace(u,"]")}function y(e){return p(e).replace(t.PLUS_RE,"%2B").replace(v,"+").replace(n,"%23").replace(r,"%26").replace(f,"`").replace(l,"{").replace(h,"}").replace(s,"^")}function g(e){return p(e).replace(n,"%23").replace(a,"%3F")}t.encodeHash=function(e){return p(e).replace(l,"{").replace(h,"}").replace(s,"^")},t.encodeQueryValue=y,t.encodeQueryKey=function(e){return y(e).replace(i,"%3D")},t.encodePath=g,t.encodeParam=function(e){return null==e?"":g(e).replace(o,"%2F")},t.decode=function(e){try{return decodeURIComponent(""+e)}catch(e){}return""+e}},470:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeQuery=t.stringifyQuery=t.parseQuery=void 0;const r=n(194),o=Array.isArray;t.parseQuery=function(e){const t={};if(""===e||"?"===e)return t;const n=("?"===e[0]?e.slice(1):e).split("&");for(let e=0;e<n.length;++e){const i=n[e].replace(r.PLUS_RE," "),a=i.indexOf("="),c=(0,r.decode)(a<0?i:i.slice(0,a)),u=a<0?null:(0,r.decode)(i.slice(a+1));if(c in t){let e=t[c];o(e)||(e=t[c]=[e]),e.push(u)}else t[c]=u}return t},t.stringifyQuery=function(e){let t="";for(let n in e){const i=e[n];(n=(0,r.encodeQueryKey)(n),null!=i)?(o(i)?i.map((e=>e&&(0,r.encodeQueryValue)(e))):[i&&(0,r.encodeQueryValue)(i)]).forEach((e=>{void 0!==e&&(t+=(t.length?"&":"")+n,null!=e&&(t+="="+e))})):void 0!==i&&(t+=(t.length?"&":"")+n)}return t},t.normalizeQuery=function(e){const t={};for(const n in e){const r=e[n];void 0!==r&&(t[n]=o(r)?r.map((e=>null==e?null:""+e)):null==r?r:""+r)}return t}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}return n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n(432)})()));
@@ -0,0 +1,6 @@
1
+ /*!
2
+ localForage -- Offline Storage, Improved
3
+ Version 1.10.0
4
+ https://localforage.github.io/localForage
5
+ (c) 2013-2017 Mozilla, Apache License 2.0
6
+ */
package/package.json CHANGED
@@ -1,17 +1,18 @@
1
1
  {
2
2
  "name": "@widget-js/core",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
8
  "types": "./dist/types/index.d.ts",
9
- "exports": "./dist/esm",
9
+ "exports": "./dist/umd/index.js",
10
10
  "scripts": {
11
11
  "prepublishOnly": "pinst --disable",
12
12
  "test": "jest --no-cache --runInBand",
13
13
  "test:cov": "jest --coverage --no-cache --runInBand",
14
- "build": "npm run build:cjs && npm run build:esm && npm run build:umd && npm run build:types",
14
+ "build": "npm run build:esm && npm run build:types && npm run build:cjs && npm run build:umd",
15
+ "build:update": "npm run build && yarn --cwd ../../../ upgrade @widget-js/core && yarn --cwd ../../../electron upgrade @widget-js/core",
15
16
  "build:cjs": "node tools/cleanup cjs && tsc -p config/tsconfig.cjs.json",
16
17
  "build:esm": "node tools/cleanup esm && tsc -p config/tsconfig.esm.json",
17
18
  "build:umd": "node tools/cleanup umd && webpack --config config/webpack.config.js",
@@ -48,5 +49,7 @@
48
49
  "webpack": "^5.75.0",
49
50
  "webpack-cli": "^5.0.0"
50
51
  },
51
- "dependencies": {}
52
+ "dependencies": {
53
+ "localforage": "^1.10.0"
54
+ }
52
55
  }