@claspo/common 7.0.3-rc1 → 7.0.3-rc2
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/package.json
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import BaseCachingStorage from './BaseCachingStorage';
|
|
2
|
-
|
|
3
|
-
path?: string;
|
|
4
|
-
expires?: Date | string;
|
|
5
|
-
[key: string]: string | Date | boolean | undefined;
|
|
6
|
-
}
|
|
2
|
+
import { CookieOptionsI } from './setCookie';
|
|
7
3
|
declare class CachingCookieStorage extends BaseCachingStorage {
|
|
8
4
|
get(name: string): string | null;
|
|
9
|
-
set(name: string, value: string, options?: CookieOptionsI): void;
|
|
5
|
+
set(name: string, value: string | object, options?: CookieOptionsI): void;
|
|
10
6
|
remove(name: string): void;
|
|
11
7
|
}
|
|
12
8
|
declare const _default: CachingCookieStorage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import BaseCachingStorage from"./BaseCachingStorage";class CachingCookieStorage extends BaseCachingStorage{get(e){const o=this._getFromCache(e);return null!==o?o:this._process(()=>{
|
|
1
|
+
import BaseCachingStorage from"./BaseCachingStorage";import getCookie from"./getCookie";import setCookie from"./setCookie";class CachingCookieStorage extends BaseCachingStorage{get(e){const o=this._getFromCache(e);return null!==o?o:this._process(()=>{var o;const t=null!==(o=getCookie(e))&&void 0!==o?o:null;return this._setToCache(e,t),t})}set(e,o,t={}){const s="string"==typeof o?o:this._process(()=>JSON.stringify(o));this._setToCache(e,s),this._process(()=>(setCookie(e,s,t),null))}remove(e){this._removeFromCache(e),this._process(()=>(setCookie(e,"",{expires:new Date(0)}),null))}}export default new CachingCookieStorage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function getCookie(name: string): string | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function getCookie(e){try{const o=document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));return o?decodeURIComponent(o[1]):void 0}catch(e){return}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import getCookie from"./getCookie";export default function setCookie(o,e,t={}){var n;const i=Object.assign({path:"/",expires:new Date((new Date).getFullYear()+5,0)},t);i.expires instanceof Date&&(i.expires=i.expires.toUTCString());let c=encodeURIComponent(o)+"="+encodeURIComponent(String(e));for(const o in i){c+="; "+o;const e=i[o];!0!==e&&(c+="="+e)}try{const t=null!==(n=location.host)&&void 0!==n?n:"localhost";if(1===t.split(".").length)return void(document.cookie=c+"; path=/");const i=t.split(".");i.shift();let s="."+i.join(".");document.cookie=c+"; path=/; domain="+s,null!=getCookie(o)&&getCookie(o)===String(e)||(s="."+t,document.cookie=c+"; path=/; domain="+s)}catch(o){}}
|