@johnnywang/vue-localstore
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -24,3 +24,3 @@ (function (global, factory) { | ||
if (isDef(i) && isDef(i = i.data) && isDef(i = i.registerRouteInstance)) { | ||
if (isDef(i) && isDef(i = i.data)) { | ||
i(vm, callVal); | ||
@@ -206,3 +206,3 @@ } | ||
VueLocalStore.install = install; | ||
VueLocalStore.version = '0.0.3'; | ||
VueLocalStore.version = '0.0.4'; | ||
@@ -209,0 +209,0 @@ if (inBrowser && window.Vue) { |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).VueLocalStore=e()}(this,(function(){"use strict";var t;var e="undefined"!=typeof window,o=e?window.localStorage:Object.create(null),n="version_name",i="event_data",a="anonymous";function s(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.app=null,this.options=e,e.prefix=e.prefix||"",e.uid=e.uid||a,e.versionNameKey=e.versionNameKey||n,e.eventDataKey=e.eventDataKey||i,t.observable(this)}return function(t){t.prototype.init=function(t){var e=this;if(t.$once("hook:destroyed",(function(){e.app===t&&(e.app=null)})),!this.app){this.app=t;!function(){var t={},n=e.options.versionName,i=e.options,a=i.versionNameKey,s=i.eventDataKey;if(e.app.$set(e,"__data__",t),n===o[a])try{e.app.$set(t,s,JSON.parse(o[s]))}catch(o){console.warn('[vue-local-store] "event_data" was not defined, use fallback empty object'),e.app.$set(t,s,Object.create(null))}e.setRoot(a,n),e.refreshEventData()}()}},t.prototype.setUid=function(t){t&&(this.options.uid=t)}}(s),function(t){t.prototype.setRoot=function(t,e){var n=this.options.versionNameKey;if(t===n&&this.__version_name_locked__)console.warn('[vue-local-store] key "version_name" cannot be modified');else{if("string"==typeof e)o[t]=e;else try{o[t]=JSON.stringify(e)}catch(e){return void console.warn('[vue-local-store] root key "'.concat(t,'" failed to set'))}this.app.$set(this.__data__,t,e),t===n&&Object.defineProperty(this,"__version_name_locked__",{get:function(){return!0}})}},t.prototype.getRoot=function(t){return this.__data__[t]},t.prototype.removeRoot=function(t){this.app.$set(this.__data__,t,null),delete o[t],delete this.__data__[t]}}(s),function(t){t.prototype.set=function(t,e){var o=this.options.eventDataKey,n=this.getPrefixedKey(t);this.app.$set(this.__data__[o],n,e),this.refreshEventData()},t.prototype.get=function(t){var e=this.options.eventDataKey,o=this.getPrefixedKey(t);return this.__data__[e][o]},t.prototype.remove=function(t){var e=this.options.eventDataKey,o=this.getPrefixedKey(t);this.app.$set(this.__data__[e],o,null),delete this.__data__[e][o],this.refreshEventData()},t.prototype.refreshEventData=function(){var t=this.options.eventDataKey;this.setRoot(t,this.__data__[t]||Object.create(null))},t.prototype.getPrefixedKey=function(t){var e=this.options,o=e.uid,n=e.prefix;return"".concat(n).concat(o,"_").concat(t)}}(s),s.install=function e(o){if(!e.installed||t!==o){e.installed=!0,t=o;var n=function(t){return void 0!==t},i=function(t,e){var o=t.$options._parentVnode;n(o)&&n(o=o.data)&&n(o=o.registerRouteInstance)&&o(t,e)};o.mixin({beforeCreate:function(){n(this.$options.localStore)?(this._localStoreRoot=this,this._localStore=this.$options.localStore,this._localStore.init(this)):this._localStoreRoot=this.$parent&&this.$parent._localStoreRoot||this,i(this,this)},destroyed:function(){i(this)}}),Object.defineProperty(o.prototype,"$localStore",{get:function(){return this._localStoreRoot._localStore}})}},s.version="0.0.3",e&&window.Vue&&window.Vue.use(s),s})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).VueLocalStore=e()}(this,(function(){"use strict";var t;var e="undefined"!=typeof window,o=e?window.localStorage:Object.create(null),n="version_name",i="event_data",a="anonymous";function s(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.app=null,this.options=e,e.prefix=e.prefix||"",e.uid=e.uid||a,e.versionNameKey=e.versionNameKey||n,e.eventDataKey=e.eventDataKey||i,t.observable(this)}return function(t){t.prototype.init=function(t){var e=this;if(t.$once("hook:destroyed",(function(){e.app===t&&(e.app=null)})),!this.app){this.app=t;!function(){var t={},n=e.options.versionName,i=e.options,a=i.versionNameKey,s=i.eventDataKey;if(e.app.$set(e,"__data__",t),n===o[a])try{e.app.$set(t,s,JSON.parse(o[s]))}catch(o){console.warn('[vue-local-store] "event_data" was not defined, use fallback empty object'),e.app.$set(t,s,Object.create(null))}e.setRoot(a,n),e.refreshEventData()}()}},t.prototype.setUid=function(t){t&&(this.options.uid=t)}}(s),function(t){t.prototype.setRoot=function(t,e){var n=this.options.versionNameKey;if(t===n&&this.__version_name_locked__)console.warn('[vue-local-store] key "version_name" cannot be modified');else{if("string"==typeof e)o[t]=e;else try{o[t]=JSON.stringify(e)}catch(e){return void console.warn('[vue-local-store] root key "'.concat(t,'" failed to set'))}this.app.$set(this.__data__,t,e),t===n&&Object.defineProperty(this,"__version_name_locked__",{get:function(){return!0}})}},t.prototype.getRoot=function(t){return this.__data__[t]},t.prototype.removeRoot=function(t){this.app.$set(this.__data__,t,null),delete o[t],delete this.__data__[t]}}(s),function(t){t.prototype.set=function(t,e){var o=this.options.eventDataKey,n=this.getPrefixedKey(t);this.app.$set(this.__data__[o],n,e),this.refreshEventData()},t.prototype.get=function(t){var e=this.options.eventDataKey,o=this.getPrefixedKey(t);return this.__data__[e][o]},t.prototype.remove=function(t){var e=this.options.eventDataKey,o=this.getPrefixedKey(t);this.app.$set(this.__data__[e],o,null),delete this.__data__[e][o],this.refreshEventData()},t.prototype.refreshEventData=function(){var t=this.options.eventDataKey;this.setRoot(t,this.__data__[t]||Object.create(null))},t.prototype.getPrefixedKey=function(t){var e=this.options,o=e.uid,n=e.prefix;return"".concat(n).concat(o,"_").concat(t)}}(s),s.install=function e(o){if(!e.installed||t!==o){e.installed=!0,t=o;var n=function(t){return void 0!==t},i=function(t,e){var o=t.$options._parentVnode;n(o)&&n(o=o.data)&&o(t,e)};o.mixin({beforeCreate:function(){n(this.$options.localStore)?(this._localStoreRoot=this,this._localStore=this.$options.localStore,this._localStore.init(this)):this._localStoreRoot=this.$parent&&this.$parent._localStoreRoot||this,i(this,this)},destroyed:function(){i(this)}}),Object.defineProperty(o.prototype,"$localStore",{get:function(){return this._localStoreRoot._localStore}})}},s.version="0.0.4",e&&window.Vue&&window.Vue.use(s),s})); |
{ | ||
"name": "@johnnywang/vue-localstore", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "A tiny plugin for vue localstorage with version control & prefixed keys", | ||
@@ -5,0 +5,0 @@ "author": "johnnywang", |
14985