vue-persistent-storage-manager
Advanced tools
Comparing version
@@ -1,1 +0,1 @@ | ||
(function(s,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(s=typeof globalThis<"u"?globalThis:s||self,e(s.VuePersistentStorageManager={},s.Vue))})(this,function(s,e){var f;"use strict";var m=Object.defineProperty;var c=(s,e,r)=>e in s?m(s,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[e]=r;var n=(s,e,r)=>(c(s,typeof e!="symbol"?e+"":e,r),r);const r={watchStorage:!1},l=class{constructor(){n(this,"isAvailable",typeof navigator<"u"&&((f=navigator==null?void 0:navigator.storage)==null?void 0:f.persist)!==void 0);n(this,"storageEstimate",{quota:void 0,usage:void 0});n(this,"_isPersistent",!1);var t,o;this.isAvailable&&(this._refreshIsPersistent(),this._refreshStorageEstimate(),(o=(t=navigator.permissions)==null?void 0:t.query({name:"persistent-storage"}))==null||o.then(a=>{a.onchange=()=>this._refreshIsPersistent()}),window.addEventListener("storage",()=>{this._refreshStorageEstimate()}))}get isPersistent(){return this._isPersistent}requestPersistentStorage(){return this.isAvailable?navigator.storage.persist().then(t=>(this._isPersistent=t,t)):Promise.resolve(!1)}_refreshIsPersistent(){navigator.storage.persisted().then(t=>this._isPersistent=t)}_refreshStorageEstimate(){navigator.storage.estimate().then(({quota:t,usage:o})=>{e.set(this.storageEstimate,"quota",t),e.set(this.storageEstimate,"usage",o)})}_modifyLocalStorageFunctions(){if(typeof localStorage>"u")return;const t=this;typeof localStorage.originalSetItem>"u"&&(localStorage.originalSetItem=localStorage.setItem);const o=localStorage.setItem;localStorage.setItem=function(...i){o.apply(this,i),t._refreshStorageEstimate()},typeof localStorage.originalRemoveItem>"u"&&(localStorage.originalRemoveItem=localStorage.removeItem);const a=localStorage.removeItem;localStorage.removeItem=function(...i){a.apply(this,i),t._refreshStorageEstimate()}}};let g=l;n(g,"install",(t,o)=>{const a={...r,...o},i=e.observable(new l);a.watchStorage&&i._modifyLocalStorageFunctions(),t.prototype.$storageManager=i,t.prototype.$storageEstimate=i.storageEstimate}),s.VuePersistentStorageManager=g,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})}); | ||
var m=Object.defineProperty;var c=(s,e,r)=>e in s?m(s,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[e]=r;var n=(s,e,r)=>(c(s,typeof e!="symbol"?e+"":e,r),r);(function(s,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(s=typeof globalThis<"u"?globalThis:s||self,e(s.VuePersistentStorageManager={},s.Vue))})(this,function(s,e){var f;"use strict";const r={watchStorage:!1},g=class g{constructor(){n(this,"isAvailable",typeof navigator<"u"&&((f=navigator==null?void 0:navigator.storage)==null?void 0:f.persist)!==void 0);n(this,"storageEstimate",{quota:void 0,usage:void 0});n(this,"_isPersistent",!1);var t,o;this.isAvailable&&(this._refreshIsPersistent(),this._refreshStorageEstimate(),(o=(t=navigator.permissions)==null?void 0:t.query({name:"persistent-storage"}))==null||o.then(a=>{a.onchange=()=>this._refreshIsPersistent()}),window.addEventListener("storage",()=>{this._refreshStorageEstimate()}))}get isPersistent(){return this._isPersistent}requestPersistentStorage(){return this.isAvailable?navigator.storage.persist().then(t=>(this._isPersistent=t,t)):Promise.resolve(!1)}_refreshIsPersistent(){navigator.storage.persisted().then(t=>this._isPersistent=t)}_refreshStorageEstimate(){navigator.storage.estimate().then(({quota:t,usage:o})=>{e.set(this.storageEstimate,"quota",t),e.set(this.storageEstimate,"usage",o)})}_modifyLocalStorageFunctions(){if(typeof localStorage>"u")return;const t=this;typeof localStorage.originalSetItem>"u"&&(localStorage.originalSetItem=localStorage.setItem);const o=localStorage.setItem;localStorage.setItem=function(...i){o.apply(this,i),t._refreshStorageEstimate()},typeof localStorage.originalRemoveItem>"u"&&(localStorage.originalRemoveItem=localStorage.removeItem);const a=localStorage.removeItem;localStorage.removeItem=function(...i){a.apply(this,i),t._refreshStorageEstimate()}}};n(g,"install",(t,o)=>{const a={...r,...o},i=e.observable(new g);a.watchStorage&&i._modifyLocalStorageFunctions(),t.prototype.$storageManager=i,t.prototype.$storageEstimate=i.storageEstimate});let l=g;s.VuePersistentStorageManager=l,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})}); |
{ | ||
"name": "vue-persistent-storage-manager", | ||
"version": "2.1.2", | ||
"version": "2.2.0", | ||
"private": false, | ||
@@ -22,2 +22,14 @@ "description": "Vue plugin that wraps the StorageManager API and provides the state of the persistent-storage permission alongside a storage estimate.", | ||
], | ||
"exports": { | ||
".": { | ||
"require": { | ||
"types": "./dist/types/index.d.ts", | ||
"default": "./dist/index.umd.js" | ||
}, | ||
"import": { | ||
"types": "./dist/types/index.d.mts", | ||
"default": "./dist/index.mjs" | ||
} | ||
} | ||
}, | ||
"main": "dist/index.umd.js", | ||
@@ -35,15 +47,12 @@ "browser": "dist/index.mjs", | ||
"devDependencies": { | ||
"@vitest/coverage-c8": "0.29.1", | ||
"@vue/test-utils": "1.3.4", | ||
"@vue/test-utils": "1.3.6", | ||
"bundlesize2": "0.0.31", | ||
"c8": "7.13.0", | ||
"flush-promises": "1.0.2", | ||
"jsdom": "21.1.0", | ||
"typescript": "4.9.5", | ||
"vite": "4.1.4", | ||
"vitest": "0.29.1", | ||
"jsdom": "22.1.0", | ||
"typescript": "5.1.6", | ||
"vite": "4.4.7", | ||
"vue": "2.7.14", | ||
"vue-template-compiler": "2.7.14", | ||
"@yeger/tsconfig": "1.1.2", | ||
"vite-plugin-lib": "1.2.1" | ||
"vite-plugin-lib": "1.3.0" | ||
}, | ||
@@ -56,7 +65,8 @@ "publishConfig": { | ||
"bundlesize": "bundlesize", | ||
"check:publish": "publint run --strict", | ||
"check:tsc": "tsc", | ||
"dev": "vite build --watch", | ||
"lint": "yeger-lint", | ||
"test": "vitest", | ||
"check:tsc": "tsc --noEmit" | ||
"test": "vitest" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
15531
16.33%10
-23.08%7
16.67%