From 62671bf146c1583b8dbdd9bd14883e3f3ec6030e Mon Sep 17 00:00:00 2001 From: Abraham K Date: Fri, 28 Apr 2017 02:29:18 +0530 Subject: [PATCH 1/2] Added cookie support for fixing in safari private browsing --- dist/local-storage.service.d.ts | 4 +- dist/local-storage.service.js | 18 +++++++-- dist/local-storage.service.js.map | 2 +- dist/local-storage.service.metadata.json | 2 +- package.json | 3 ++ src/local-storage.service.ts | 49 ++++++++++++++---------- 6 files changed, 51 insertions(+), 27 deletions(-) diff --git a/dist/local-storage.service.d.ts b/dist/local-storage.service.d.ts index 5bb914c..bf84eba 100644 --- a/dist/local-storage.service.d.ts +++ b/dist/local-storage.service.d.ts @@ -2,7 +2,9 @@ import { Observable } from 'rxjs/Observable'; import 'rxjs/add/operator/share'; import { ILocalStorageEvent } from './local-storage-events.interface'; import { ILocalStorageServiceConfig } from './local-storage.config.interface'; +import { CookieService } from 'angular2-cookie/core'; export declare class LocalStorageService { + private _cookieService; isSupported: boolean; errors$: Observable; removeItems$: Observable; @@ -16,7 +18,7 @@ export declare class LocalStorageService { private removeItems; private setItems; private warnings; - constructor(config: ILocalStorageServiceConfig); + constructor(config: ILocalStorageServiceConfig, _cookieService: CookieService); add(key: string, value: any): boolean; clearAll(regularExpression?: string): boolean; deriveKey(key: string): string; diff --git a/dist/local-storage.service.js b/dist/local-storage.service.js index 4b6ffcf..fe4565c 100644 --- a/dist/local-storage.service.js +++ b/dist/local-storage.service.js @@ -15,11 +15,13 @@ var core_1 = require('@angular/core'); var Observable_1 = require('rxjs/Observable'); var Subscriber_1 = require('rxjs/Subscriber'); require('rxjs/add/operator/share'); +var core_2 = require('angular2-cookie/core'); var DEPRECATED = 'This function is deprecated.'; var LOCAL_STORAGE_NOT_SUPPORTED = 'LOCAL_STORAGE_NOT_SUPPORTED'; var LocalStorageService = (function () { - function LocalStorageService(config) { + function LocalStorageService(config, _cookieService) { var _this = this; + this._cookieService = _cookieService; this.isSupported = false; this.notifyOptions = { setItem: false, @@ -85,7 +87,13 @@ var LocalStorageService = (function () { LocalStorageService.prototype.get = function (key) { if (!this.isSupported) { this.warnings.next(LOCAL_STORAGE_NOT_SUPPORTED); - return null; + var item_1 = this._cookieService.get(key); + if (!item_1 || item_1 === 'null') { + return null; + } + else { + return JSON.parse(item_1); + } } var item = this.webStorage ? this.webStorage.getItem(this.deriveKey(key)) : null; // FIXME: not a perfect solution, since a valid 'null' string can't be stored @@ -170,8 +178,10 @@ var LocalStorageService = (function () { value = JSON.stringify(value); } if (!this.isSupported) { + // Store in cookie if not supported + this._cookieService.put(key, value); this.warnings.next(LOCAL_STORAGE_NOT_SUPPORTED); - return false; + return true; } try { if (this.webStorage) { @@ -237,7 +247,7 @@ var LocalStorageService = (function () { LocalStorageService = __decorate([ core_1.Injectable(), __param(0, core_1.Inject('LOCAL_STORAGE_SERVICE_CONFIG')), - __metadata('design:paramtypes', [Object]) + __metadata('design:paramtypes', [Object, core_2.CookieService]) ], LocalStorageService); return LocalStorageService; }()); diff --git a/dist/local-storage.service.js.map b/dist/local-storage.service.js.map index 922c463..30c314c 100644 --- a/dist/local-storage.service.js.map +++ b/dist/local-storage.service.js.map @@ -1 +1 @@ -{"version":3,"file":"local-storage.service.js","sourceRoot":"","sources":["../src/local-storage.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,qBAAmC,eAAe,CAAC,CAAA;AACnD,2BAA2B,iBAAiB,CAAC,CAAA;AAC7C,2BAA2B,iBAAiB,CAAC,CAAA;AAC7C,QAAO,yBAAyB,CAAC,CAAA;AAMjC,IAAM,UAAU,GAAW,8BAA8B,CAAC;AAC1D,IAAM,2BAA2B,GAAW,6BAA6B,CAAC;AAG1E;IAqBI,6BAC4C,MAAkC;QAtBlF,iBAqPC;QApPU,gBAAW,GAAY,KAAK,CAAC;QAO5B,kBAAa,GAAmB;YACpC,OAAO,EAAE,KAAK;YACd,UAAU,EAAE,KAAK;SACpB,CAAC;QACM,WAAM,GAAW,IAAI,CAAC;QACtB,gBAAW,GAAsC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CAAC;IArPL;QAAC,iBAAU,EAAE;mBAuBJ,aAAM,CAAC,8BAA8B,CAAC;;2BAvBlC;IAsPb,0BAAC;AAAD,CAAC,AArPD,IAqPC;AArPY,2BAAmB,sBAqP/B,CAAA"} \ No newline at end of file +{"version":3,"file":"local-storage.service.js","sourceRoot":"","sources":["../src/local-storage.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,qBAAmC,eAAe,CAAC,CAAA;AACnD,2BAA2B,iBAAiB,CAAC,CAAA;AAC7C,2BAA2B,iBAAiB,CAAC,CAAA;AAC7C,QAAO,yBAAyB,CAAC,CAAA;AAKjC,qBAA8B,sBAAsB,CAAC,CAAA;AAErD,IAAM,UAAU,GAAW,8BAA8B,CAAC;AAC1D,IAAM,2BAA2B,GAAW,6BAA6B,CAAC;AAG1E;IAqBI,6BAC4C,MAAkC,EAClE,cAA6B;QAvB7C,iBA6PC;QAtOe,mBAAc,GAAd,cAAc,CAAe;QAtBlC,gBAAW,GAAY,KAAK,CAAC;QAO5B,kBAAa,GAAmB;YACpC,OAAO,EAAE,KAAK;YACd,UAAU,EAAE,KAAK;SACpB,CAAC;QACM,WAAM,GAAW,IAAI,CAAC;QACtB,gBAAW,GAAsC,cAAc,CAAC;QAGhE,WAAM,GAAuB,IAAI,uBAAU,EAAU,CAAC;QACtD,gBAAW,GAAmC,IAAI,uBAAU,EAAsB,CAAC;QACnF,aAAQ,GAAmC,IAAI,uBAAU,EAAsB,CAAC;QAChF,aAAQ,GAAuB,IAAI,uBAAU,EAAU,CAAC;QAMtD,wCAAa,EAAE,sBAAM,EAAE,gCAAW,CAAY;QAEpD,EAAE,CAAC,CAAC,aAAa,IAAI,IAAI,CAAC,CAAC,CAAC;YAClB,mCAAO,EAAE,qCAAU,CAAmB;YAC5C,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;QAC5C,CAAC;QACD,EAAE,CAAC,CAAC,MAAM,IAAI,IAAI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PY,2BAAmB,sBA6P/B,CAAA"} \ No newline at end of file diff --git a/dist/local-storage.service.metadata.json b/dist/local-storage.service.metadata.json index eac5c71..83e080f 100644 --- a/dist/local-storage.service.metadata.json +++ b/dist/local-storage.service.metadata.json @@ -1 +1 @@ -[{"__symbolic":"module","version":3,"metadata":{"LocalStorageService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":["LOCAL_STORAGE_SERVICE_CONFIG"]}]],"parameters":[{"__symbolic":"reference","module":"./local-storage.config.interface","name":"ILocalStorageServiceConfig"}]}],"add":[{"__symbolic":"method"}],"clearAll":[{"__symbolic":"method"}],"deriveKey":[{"__symbolic":"method"}],"get":[{"__symbolic":"method"}],"getStorageType":[{"__symbolic":"method"}],"keys":[{"__symbolic":"method"}],"length":[{"__symbolic":"method"}],"remove":[{"__symbolic":"method"}],"set":[{"__symbolic":"method"}],"checkSupport":[{"__symbolic":"method"}],"setPrefix":[{"__symbolic":"method"}],"setStorageType":[{"__symbolic":"method"}],"setNotify":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"LocalStorageService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":["LOCAL_STORAGE_SERVICE_CONFIG"]}]],"parameters":[{"__symbolic":"reference","module":"./local-storage.config.interface","name":"ILocalStorageServiceConfig"}]}],"add":[{"__symbolic":"method"}],"clearAll":[{"__symbolic":"method"}],"deriveKey":[{"__symbolic":"method"}],"get":[{"__symbolic":"method"}],"getStorageType":[{"__symbolic":"method"}],"keys":[{"__symbolic":"method"}],"length":[{"__symbolic":"method"}],"remove":[{"__symbolic":"method"}],"set":[{"__symbolic":"method"}],"checkSupport":[{"__symbolic":"method"}],"setPrefix":[{"__symbolic":"method"}],"setStorageType":[{"__symbolic":"method"}],"setNotify":[{"__symbolic":"method"}]}}}}] \ No newline at end of file +[{"__symbolic":"module","version":3,"metadata":{"LocalStorageService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":["LOCAL_STORAGE_SERVICE_CONFIG"]}],null],"parameters":[{"__symbolic":"reference","module":"./local-storage.config.interface","name":"ILocalStorageServiceConfig"},{"__symbolic":"reference","module":"angular2-cookie/core","name":"CookieService"}]}],"add":[{"__symbolic":"method"}],"clearAll":[{"__symbolic":"method"}],"deriveKey":[{"__symbolic":"method"}],"get":[{"__symbolic":"method"}],"getStorageType":[{"__symbolic":"method"}],"keys":[{"__symbolic":"method"}],"length":[{"__symbolic":"method"}],"remove":[{"__symbolic":"method"}],"set":[{"__symbolic":"method"}],"checkSupport":[{"__symbolic":"method"}],"setPrefix":[{"__symbolic":"method"}],"setStorageType":[{"__symbolic":"method"}],"setNotify":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"LocalStorageService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":["LOCAL_STORAGE_SERVICE_CONFIG"]}],null],"parameters":[{"__symbolic":"reference","module":"./local-storage.config.interface","name":"ILocalStorageServiceConfig"},{"__symbolic":"reference","module":"angular2-cookie/core","name":"CookieService"}]}],"add":[{"__symbolic":"method"}],"clearAll":[{"__symbolic":"method"}],"deriveKey":[{"__symbolic":"method"}],"get":[{"__symbolic":"method"}],"getStorageType":[{"__symbolic":"method"}],"keys":[{"__symbolic":"method"}],"length":[{"__symbolic":"method"}],"remove":[{"__symbolic":"method"}],"set":[{"__symbolic":"method"}],"checkSupport":[{"__symbolic":"method"}],"setPrefix":[{"__symbolic":"method"}],"setStorageType":[{"__symbolic":"method"}],"setNotify":[{"__symbolic":"method"}]}}}}] \ No newline at end of file diff --git a/package.json b/package.json index efd0fad..a85f95c 100644 --- a/package.json +++ b/package.json @@ -35,5 +35,8 @@ "rxjs": "^5.0.3", "typescript": "2.0.10", "zone.js": "0.7.6" + }, + "dependencies": { + "angular2-cookie": "^1.2.6" } } diff --git a/src/local-storage.service.ts b/src/local-storage.service.ts index 03c0fe5..2de8ed8 100644 --- a/src/local-storage.service.ts +++ b/src/local-storage.service.ts @@ -6,6 +6,7 @@ import 'rxjs/add/operator/share'; import { ILocalStorageEvent } from './local-storage-events.interface'; import { INotifyOptions } from './notify-options.interface'; import { ILocalStorageServiceConfig } from './local-storage.config.interface'; +import { CookieService } from 'angular2-cookie/core'; const DEPRECATED: string = 'This function is deprecated.'; const LOCAL_STORAGE_NOT_SUPPORTED: string = 'LOCAL_STORAGE_NOT_SUPPORTED'; @@ -28,12 +29,13 @@ export class LocalStorageService { private webStorage: Storage; private errors: Subscriber = new Subscriber(); - private removeItems: Subscriber = new Subscriber() ; + private removeItems: Subscriber = new Subscriber(); private setItems: Subscriber = new Subscriber(); private warnings: Subscriber = new Subscriber(); - constructor ( - @Inject('LOCAL_STORAGE_SERVICE_CONFIG') config: ILocalStorageServiceConfig + constructor( + @Inject('LOCAL_STORAGE_SERVICE_CONFIG') config: ILocalStorageServiceConfig, + private _cookieService: CookieService ) { let { notifyOptions, prefix, storageType } = config; @@ -56,7 +58,7 @@ export class LocalStorageService { this.isSupported = this.checkSupport(); } - public add (key: string, value: any): boolean { + public add(key: string, value: any): boolean { if (console && console.warn) { console.warn(DEPRECATED); console.warn('Use `LocalStorageService.set` instead.'); @@ -65,7 +67,7 @@ export class LocalStorageService { return this.set(key, value); } - public clearAll (regularExpression?: string): boolean { + public clearAll(regularExpression?: string): boolean { // Setting both regular expressions independently // Empty strings result in catchall RegExp let prefixRegex = !!this.prefix ? new RegExp('^' + this.prefix) : new RegExp(''); @@ -92,14 +94,19 @@ export class LocalStorageService { return true; } - public deriveKey (key: string): string { + public deriveKey(key: string): string { return `${this.prefix}${key}`; } - public get (key: string): T { + public get(key: string): T { if (!this.isSupported) { this.warnings.next(LOCAL_STORAGE_NOT_SUPPORTED); - return null; + let item = this._cookieService.get(key); + if (!item || item === 'null') { + return null; + } else { + return JSON.parse(item); + } } let item = this.webStorage ? this.webStorage.getItem(this.deriveKey(key)) : null; @@ -115,11 +122,11 @@ export class LocalStorageService { } } - public getStorageType (): string { + public getStorageType(): string { return this.storageType; } - public keys (): Array { + public keys(): Array { if (!this.isSupported) { this.warnings.next(LOCAL_STORAGE_NOT_SUPPORTED); return []; @@ -141,10 +148,10 @@ export class LocalStorageService { return keys; } - public length (): number { + public length(): number { let count = 0; let storage = this.webStorage; - for(let i = 0; i < storage.length; i++) { + for (let i = 0; i < storage.length; i++) { if (storage.key(i).indexOf(this.prefix) === 0) { count += 1; } @@ -152,7 +159,7 @@ export class LocalStorageService { return count; } - public remove (...keys: Array): boolean { + public remove(...keys: Array): boolean { let result = true; keys.forEach((key: string) => { if (!this.isSupported) { @@ -176,7 +183,7 @@ export class LocalStorageService { return result; } - public set (key: string, value: any): boolean { + public set(key: string, value: any): boolean { // Let's convert `undefined` values to `null` to get the value consistent if (value === undefined) { value = null; @@ -185,8 +192,10 @@ export class LocalStorageService { } if (!this.isSupported) { + // Store in cookie if not supported + this._cookieService.put(key, value); this.warnings.next(LOCAL_STORAGE_NOT_SUPPORTED); - return false; + return true; } try { @@ -207,10 +216,10 @@ export class LocalStorageService { return true; } - private checkSupport (): boolean { + private checkSupport(): boolean { try { let supported = this.storageType in window - && window[this.storageType] !== null; + && window[this.storageType] !== null; if (supported) { this.webStorage = window[this.storageType]; @@ -233,7 +242,7 @@ export class LocalStorageService { } } - private setPrefix (prefix: string): void { + private setPrefix(prefix: string): void { this.prefix = prefix; // If there is a prefix set in the config let's use that with an appended @@ -244,11 +253,11 @@ export class LocalStorageService { } } - private setStorageType (storageType: 'sessionStorage' | 'localStorage'): void { + private setStorageType(storageType: 'sessionStorage' | 'localStorage'): void { this.storageType = storageType; } - private setNotify (setItem: boolean, removeItem: boolean): void { + private setNotify(setItem: boolean, removeItem: boolean): void { if (setItem != null) { this.notifyOptions.setItem = setItem; } From cb2f27360a99f91ab542302ce767a61ba21b1d72 Mon Sep 17 00:00:00 2001 From: Abraham K Date: Fri, 28 Apr 2017 02:36:12 +0530 Subject: [PATCH 2/2] Added cookie support for fixing in safari private browsing - removeAll --- dist/local-storage.service.js | 1 + dist/local-storage.service.js.map | 2 +- src/local-storage.service.ts | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dist/local-storage.service.js b/dist/local-storage.service.js index fe4565c..f0b8567 100644 --- a/dist/local-storage.service.js +++ b/dist/local-storage.service.js @@ -64,6 +64,7 @@ var LocalStorageService = (function () { var testRegex = !!regularExpression ? new RegExp(regularExpression) : new RegExp(''); if (!this.isSupported) { this.warnings.next(LOCAL_STORAGE_NOT_SUPPORTED); + this._cookieService.removeAll(); return false; } var prefixLength = this.prefix.length; diff --git a/dist/local-storage.service.js.map b/dist/local-storage.service.js.map index 30c314c..1250bdf 100644 --- a/dist/local-storage.service.js.map +++ b/dist/local-storage.service.js.map @@ -1 +1 @@ -{"version":3,"file":"local-storage.service.js","sourceRoot":"","sources":["../src/local-storage.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,qBAAmC,eAAe,CAAC,CAAA;AACnD,2BAA2B,iBAAiB,CAAC,CAAA;AAC7C,2BAA2B,iBAAiB,CAAC,CAAA;AAC7C,QAAO,yBAAyB,CAAC,CAAA;AAKjC,qBAA8B,sBAAsB,CAAC,CAAA;AAEr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AAM,GAAW,GAAG,CAAC;QAC3B,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC/C,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,KAAG,IAAI,CAAC,MAAM,GAAG,MAAQ,GAAG,EAAE,CAAC;QACjE,CAAC;IACL,CAAC;IAEO,4CAAc,GAAtB,UAAuB,WAA8C;QACjE,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACnC,CAAC;IAEO,uCAAS,GAAjB,UAAkB,OAAgB,EAAE,UAAmB;QACnD,EAAE,CAAC,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC;YAClB,IAAI,CAAC,aAAa,CAAC,OAAO,GAAG,OAAO,CAAC;QACzC,CAAC;QACD,EAAE,CAAC,CAAC,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC;YACrB,IAAI,CAAC,aAAa,CAAC,UAAU,GAAG,UAAU,CAAC;QAC/C,CAAC;IACL,CAAC;IA7PL;QAAC,iBAAU,EAAE;mBAuBJ,aAAM,CAAC,8BAA8B,CAAC;;2BAvBlC;IA8Pb,0BAAC;AAAD,CAAC,AA7PD,IA6PC;AA7PY,2BAAmB,sBA6P/B,CAAA"} \ No newline at end of file +{"version":3,"file":"local-storage.service.js","sourceRoot":"","sources":["../src/local-storage.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,qBAAmC,eAAe,CAAC,CAAA;AACnD,2BAA2B,iBAAiB,CAAC,CAAA;AAC7C,2BAA2B,iBAAiB,CAAC,CAAA;AAC7C,QAAO,yBAAyB,CAAC,CAAA;AAKjC,qBAA8B,sBAAsB,CAAC,CAAA;AAErD,IAAM,UAAU,GAAW,8BAA8B,CAAC;AAC1D,IAAM,2BAA2B,GAAW,6BAA6B,CAAC;AAG1E;IAqBI,6BAC4C,MAAkC,EAClE,cAA6B;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CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC/C,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,KAAG,IAAI,CAAC,MAAM,GAAG,MAAQ,GAAG,EAAE,CAAC;QACjE,CAAC;IACL,CAAC;IAEO,4CAAc,GAAtB,UAAuB,WAA8C;QACjE,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACnC,CAAC;IAEO,uCAAS,GAAjB,UAAkB,OAAgB,EAAE,UAAmB;QACnD,EAAE,CAAC,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC;YAClB,IAAI,CAAC,aAAa,CAAC,OAAO,GAAG,OAAO,CAAC;QACzC,CAAC;QACD,EAAE,CAAC,CAAC,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC;YACrB,IAAI,CAAC,aAAa,CAAC,UAAU,GAAG,UAAU,CAAC;QAC/C,CAAC;IACL,CAAC;IA9PL;QAAC,iBAAU,EAAE;mBAuBJ,aAAM,CAAC,8BAA8B,CAAC;;2BAvBlC;IA+Pb,0BAAC;AAAD,CAAC,AA9PD,IA8PC;AA9PY,2BAAmB,sBA8P/B,CAAA"} \ No newline at end of file diff --git a/src/local-storage.service.ts b/src/local-storage.service.ts index 2de8ed8..a0dadcc 100644 --- a/src/local-storage.service.ts +++ b/src/local-storage.service.ts @@ -75,6 +75,7 @@ export class LocalStorageService { if (!this.isSupported) { this.warnings.next(LOCAL_STORAGE_NOT_SUPPORTED); + this._cookieService.removeAll(); return false; }