From ddae48590bb3934940542c17604fcb767f2bb15b Mon Sep 17 00:00:00 2001 From: jinkwon Date: Wed, 22 Mar 2017 10:39:47 +0900 Subject: [PATCH 1/3] task: fix wrong example codes --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index d875d34..35ebd0e 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,7 @@ This project is not maintained. Please consider taking it over. More information import {WebStorageModule, LocalStorageService} from "angular2-localstorage"; @NgModule({ - import: [WebStorageModule] - @Component({ + imports: [WebStorageModule], providers: [LocalStorageService] }) export class AppModule {} From 08b212bdd629a19def86d2fd68e8cf34762bebe8 Mon Sep 17 00:00:00 2001 From: jinkwon Date: Tue, 28 Mar 2017 17:07:01 +0900 Subject: [PATCH 2/3] task: compatible ng4 --- README.md | 12 ++++++------ dist/decorator/index.js | 1 + dist/decorator/index.js.map | 2 +- dist/decorator/webstorage.js | 4 ++++ dist/decorator/webstorage.js.map | 2 +- dist/index.js | 7 ++----- dist/index.js.map | 2 +- dist/service/index.js | 1 + dist/service/index.js.map | 2 +- dist/service/webstorage.service.js | 16 +++++++++++----- dist/service/webstorage.service.js.map | 2 +- dist/utility/index.js | 1 + dist/utility/index.js.map | 2 +- dist/utility/webstorage.utiltiy.js | 1 + dist/utility/webstorage.utiltiy.js.map | 2 +- package.json | 24 +++++++++++++----------- tsconfig.json | 3 ++- 17 files changed, 49 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 35ebd0e..45e2f1e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Angular2 @LocalStorage +# Angular @LocalStorage -This little Angular2/typescript decorator makes it super easy to save and restore *automatically* a variable state in your +This little Angular/typescript decorator makes it super easy to save and restore *automatically* a variable state in your directive (class property) using HTML5' LocalStorage. ## Seeking new maintainer @@ -9,11 +9,11 @@ This project is not maintained. Please consider taking it over. More information ## Use -1. Download the library using npm or github: `npm install --save angular2-localstorage` +1. Download the library using npm or github: `npm install --save angular-localstorage` 2. Import the WebStorageModule in your app module: ```typescript - import {Component} from "angular2/core"; - import {WebStorageModule, LocalStorageService} from "angular2-localstorage"; + import {Component} from "@angular/core"; + import {WebStorageModule, LocalStorageService} from "angular-localstorage"; @NgModule({ imports: [WebStorageModule], @@ -25,7 +25,7 @@ This project is not maintained. Please consider taking it over. More information 3. Use the `LocalStorage` decorator ```typescript -import {LocalStorage, SessionStorage} from "angular2-localstorage/WebStorage"; +import {LocalStorage, SessionStorage} from "angular-localstorage/WebStorage"; class MySuperComponent { @LocalStorage() public lastSearchQuery:Object = {}; diff --git a/dist/decorator/index.js b/dist/decorator/index.js index bc2dfc7..64ea583 100644 --- a/dist/decorator/index.js +++ b/dist/decorator/index.js @@ -2,5 +2,6 @@ function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } +Object.defineProperty(exports, "__esModule", { value: true }); __export(require("./webstorage")); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/decorator/index.js.map b/dist/decorator/index.js.map index d04f423..f004fa8 100644 --- a/dist/decorator/index.js.map +++ b/dist/decorator/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorator/index.ts"],"names":[],"mappings":";;;;AAAA,kCAA6B","sourcesContent":["export * from './webstorage';"]} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorator/index.ts"],"names":[],"mappings":";;;;;AAAA,kCAA6B","sourcesContent":["export * from './webstorage';"]} \ No newline at end of file diff --git a/dist/decorator/webstorage.js b/dist/decorator/webstorage.js index 2f57db2..a0f9cb7 100644 --- a/dist/decorator/webstorage.js +++ b/dist/decorator/webstorage.js @@ -1,4 +1,5 @@ "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var webstorage_utiltiy_1 = require("../utility/webstorage.utiltiy"); function LocalStorage(key) { return exports.WebStorage(localStorage, key); @@ -8,6 +9,7 @@ function SessionStorage(key) { return exports.WebStorage(sessionStorage, key); } exports.SessionStorage = SessionStorage; +// initialization cache var cache = {}; exports.WebStorage = function (webStorage, key) { return function (target, propertyName) { @@ -20,7 +22,9 @@ exports.WebStorage = function (webStorage, key) { }, set: function (value) { if (!cache[key]) { + // first setter handle if (storedValue === null) { + // if no value in localStorage, set it to initializer webstorage_utiltiy_1.WebStorageUtility.set(webStorage, key, value); } cache[key] = true; diff --git a/dist/decorator/webstorage.js.map b/dist/decorator/webstorage.js.map index 6959fef..7b3dc0c 100644 --- a/dist/decorator/webstorage.js.map +++ b/dist/decorator/webstorage.js.map @@ -1 +1 @@ -{"version":3,"file":"webstorage.js","sourceRoot":"","sources":["../../src/decorator/webstorage.ts"],"names":[],"mappings":";AAAA,oEAAgE;AAEhE,sBAA6B,GAAY;IACrC,MAAM,CAAC,kBAAU,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;AACzC,CAAC;AAFD,oCAEC;AAED,wBAA+B,GAAY;IACvC,MAAM,CAAC,kBAAU,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;AAC3C,CAAC;AAFD,wCAEC;AAGD,IAAI,KAAK,GAAG,EAAE,CAAC;AAEJ,QAAA,UAAU,GAAG,UAAC,UAAmB,EAAE,GAAW;IACrD,MAAM,CAAC,UAAC,MAAc,EAAE,YAAoB;QACxC,GAAG,GAAG,GAAG,IAAI,YAAY,CAAC;QAE1B,IAAI,UAAU,GAAG,sCAAiB,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAC3D,IAAI,WAAW,GAAG,sCAAiB,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QAEzD,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY,EAAE;YACxC,GAAG,EAAE;gBACD,MAAM,CAAC,sCAAiB,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;YAClD,CAAC;YACD,GAAG,EAAE,UAAS,KAAU;gBACpB,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;oBAEd,EAAE,CAAC,CAAC,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC;wBAEvB,sCAAiB,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;oBAClD,CAAC;oBAED,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;oBAClB,MAAM,CAAC;gBACX,CAAC;gBAED,sCAAiB,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;YAClD,CAAC;SACJ,CAAC,CAAC;IACP,CAAC,CAAA;AACL,CAAC,CAAA","sourcesContent":["import {WebStorageUtility} from \"../utility/webstorage.utiltiy\";\r\n\r\nexport function LocalStorage(key?: string) {\r\n return WebStorage(localStorage, key);\r\n}\r\n\r\nexport function SessionStorage(key?: string) {\r\n return WebStorage(sessionStorage, key);\r\n}\r\n\r\n// initialization cache\r\nlet cache = {};\r\n\r\nexport let WebStorage = (webStorage: Storage, key: string) => {\r\n return (target: Object, propertyName: string): void => {\r\n key = key || propertyName;\r\n\r\n let storageKey = WebStorageUtility.generateStorageKey(key);\r\n let storedValue = WebStorageUtility.get(webStorage, key);\r\n\r\n Object.defineProperty(target, propertyName, {\r\n get: function() {\n return WebStorageUtility.get(webStorage, key);\r\n },\r\n set: function(value: any) {\r\n if (!cache[key]) {\r\n // first setter handle\r\n if (storedValue === null) {\r\n // if no value in localStorage, set it to initializer\r\n WebStorageUtility.set(webStorage, key, value);\r\n }\r\n\r\n cache[key] = true;\r\n return;\r\n }\r\n\r\n WebStorageUtility.set(webStorage, key, value);\r\n },\r\n });\r\n }\r\n}\r\n"]} \ No newline at end of file +{"version":3,"file":"webstorage.js","sourceRoot":"","sources":["../../src/decorator/webstorage.ts"],"names":[],"mappings":";;AAAA,oEAAgE;AAEhE,sBAA6B,GAAY;IACrC,MAAM,CAAC,kBAAU,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;AACzC,CAAC;AAFD,oCAEC;AAED,wBAA+B,GAAY;IACvC,MAAM,CAAC,kBAAU,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;AAC3C,CAAC;AAFD,wCAEC;AAED,uBAAuB;AACvB,IAAI,KAAK,GAAG,EAAE,CAAC;AAEJ,QAAA,UAAU,GAAG,UAAC,UAAmB,EAAE,GAAW;IACrD,MAAM,CAAC,UAAC,MAAc,EAAE,YAAoB;QACxC,GAAG,GAAG,GAAG,IAAI,YAAY,CAAC;QAE1B,IAAI,UAAU,GAAG,sCAAiB,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAC3D,IAAI,WAAW,GAAG,sCAAiB,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QAEzD,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY,EAAE;YACxC,GAAG,EAAE;gBACD,MAAM,CAAC,sCAAiB,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;YAClD,CAAC;YACD,GAAG,EAAE,UAAS,KAAU;gBACpB,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;oBACd,sBAAsB;oBACtB,EAAE,CAAC,CAAC,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC;wBACvB,qDAAqD;wBACrD,sCAAiB,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;oBAClD,CAAC;oBAED,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;oBAClB,MAAM,CAAC;gBACX,CAAC;gBAED,sCAAiB,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;YAClD,CAAC;SACJ,CAAC,CAAC;IACP,CAAC,CAAA;AACL,CAAC,CAAA","sourcesContent":["import {WebStorageUtility} from \"../utility/webstorage.utiltiy\";\n\nexport function LocalStorage(key?: string) {\n return WebStorage(localStorage, key);\n}\n\nexport function SessionStorage(key?: string) {\n return WebStorage(sessionStorage, key);\n}\n\n// initialization cache\nlet cache = {};\n\nexport let WebStorage = (webStorage: Storage, key: string) => {\n return (target: Object, propertyName: string): void => {\n key = key || propertyName;\n\n let storageKey = WebStorageUtility.generateStorageKey(key);\n let storedValue = WebStorageUtility.get(webStorage, key);\n\n Object.defineProperty(target, propertyName, {\n get: function() {\n return WebStorageUtility.get(webStorage, key);\n },\n set: function(value: any) {\n if (!cache[key]) {\n // first setter handle\n if (storedValue === null) {\n // if no value in localStorage, set it to initializer\n WebStorageUtility.set(webStorage, key, value);\n }\n\n cache[key] = true;\n return;\n }\n\n WebStorageUtility.set(webStorage, key, value);\n },\n });\n }\n}\n"]} \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 1fdca4d..2fb04c4 100644 --- a/dist/index.js +++ b/dist/index.js @@ -5,12 +5,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } +Object.defineProperty(exports, "__esModule", { value: true }); var core_1 = require("@angular/core"); var webstorage_service_1 = require("./service/webstorage.service"); __export(require("./decorator/index")); @@ -24,8 +22,7 @@ var WebStorageModule = (function () { WebStorageModule = __decorate([ core_1.NgModule({ providers: [webstorage_service_1.LocalStorageService, webstorage_service_1.SessionStorageService] - }), - __metadata("design:paramtypes", []) + }) ], WebStorageModule); exports.WebStorageModule = WebStorageModule; //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map index e9c348c..0ec7c40 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,sCAAuC;AACvC,mEAAwF;AAExF,uCAAiC;AACjC,qCAA+B;AAC/B,qCAA+B;AAK/B;IAAA;IAA+B,CAAC;IAAD,uBAAC;AAAD,CAAC,AAAhC,IAAgC;AAAhC;IAHC,eAAQ,CAAC;QACN,SAAS,EAAE,CAAC,wCAAmB,EAAE,0CAAqB,CAAC;KAC1D,CAAC;;oBAC8B;AAAnB,2BAAA,gBAAgB,CAAA","sourcesContent":["import {NgModule} from \"@angular/core\";\r\nimport {LocalStorageService, SessionStorageService} from \"./service/webstorage.service\";\r\n\r\nexport * from './decorator/index'\r\nexport * from './service/index'\r\nexport * from './utility/index'\r\n\r\n@NgModule({\r\n providers: [LocalStorageService, SessionStorageService]\r\n})\r\nexport class WebStorageModule {}"]} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,sCAAuC;AACvC,mEAAwF;AAExF,uCAAiC;AACjC,qCAA+B;AAC/B,qCAA+B;AAK/B,IAAa,gBAAgB;IAA7B;IAA+B,CAAC;IAAD,uBAAC;AAAD,CAAC,AAAhC,IAAgC;AAAnB,gBAAgB;IAH5B,eAAQ,CAAC;QACN,SAAS,EAAE,CAAC,wCAAmB,EAAE,0CAAqB,CAAC;KAC1D,CAAC;GACW,gBAAgB,CAAG;AAAnB,4CAAgB","sourcesContent":["import {NgModule} from \"@angular/core\";\nimport {LocalStorageService, SessionStorageService} from \"./service/webstorage.service\";\n\nexport * from './decorator/index'\nexport * from './service/index'\nexport * from './utility/index'\n\n@NgModule({\n providers: [LocalStorageService, SessionStorageService]\n})\nexport class WebStorageModule {}"]} \ No newline at end of file diff --git a/dist/service/index.js b/dist/service/index.js index 7901d35..d4faa4d 100644 --- a/dist/service/index.js +++ b/dist/service/index.js @@ -2,5 +2,6 @@ function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } +Object.defineProperty(exports, "__esModule", { value: true }); __export(require("./webstorage.service")); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/service/index.js.map b/dist/service/index.js.map index 4b7e32c..f96c9ce 100644 --- a/dist/service/index.js.map +++ b/dist/service/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":";;;;AAAA,0CAAqC","sourcesContent":["export * from './webstorage.service';"]} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":";;;;;AAAA,0CAAqC","sourcesContent":["export * from './webstorage.service';"]} \ No newline at end of file diff --git a/dist/service/webstorage.service.js b/dist/service/webstorage.service.js index 1f58c79..bb454f9 100644 --- a/dist/service/webstorage.service.js +++ b/dist/service/webstorage.service.js @@ -1,9 +1,14 @@ "use strict"; -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); @@ -13,6 +18,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; +Object.defineProperty(exports, "__esModule", { value: true }); var core_1 = require("@angular/core"); var webstorage_utiltiy_1 = require("../utility/webstorage.utiltiy"); var WebStorageService = (function () { diff --git a/dist/service/webstorage.service.js.map b/dist/service/webstorage.service.js.map index 936de82..cb78068 100644 --- a/dist/service/webstorage.service.js.map +++ b/dist/service/webstorage.service.js.map @@ -1 +1 @@ -{"version":3,"file":"webstorage.service.js","sourceRoot":"","sources":["../../src/service/webstorage.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sCAAyC;AACzC,oEAAgE;AAEhE;IACI,2BAAoB,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;IAEpC,CAAC;IAED,+BAAG,GAAH,UAAI,GAAW;QACX,MAAM,CAAC,sCAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IACpD,CAAC;IAED,+BAAG,GAAH,UAAI,GAAW,EAAE,KAAU;QACvB,sCAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC;IAED,kCAAM,GAAN,UAAO,GAAW;QACd,sCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAChD,CAAC;IAED,iCAAK,GAAL;QACI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;IACL,wBAAC;AAAD,CAAC,AApBD,IAoBC;AApBD,8CAoBC;AAGD;IAAyC,uCAAiB;IACtD;eACI,kBAAM,YAAY,CAAC;IACvB,CAAC;IACL,0BAAC;AAAD,CAAC,AAJD,CAAyC,iBAAiB,GAIzD;AAJD;IADC,iBAAU,EAAE;;uBAKZ;AAJY,8BAAA,mBAAmB,CAAA;AAOhC;IAA2C,yCAAiB;IACxD;eACI,kBAAM,cAAc,CAAC;IACzB,CAAC;IACL,4BAAC;AAAD,CAAC,AAJD,CAA2C,iBAAiB,GAI3D;AAJD;IADC,iBAAU,EAAE;;yBAKZ;AAJY,gCAAA,qBAAqB,CAAA","sourcesContent":["import {Injectable} from \"@angular/core\";\r\nimport {WebStorageUtility} from \"../utility/webstorage.utiltiy\";\r\n\r\nexport class WebStorageService {\r\n constructor(private storage: Storage) {\r\n\r\n }\r\n\r\n get(key: string): any {\r\n return WebStorageUtility.get(this.storage, key);\r\n }\r\n\r\n set(key: string, value: any): void {\r\n WebStorageUtility.set(this.storage, key, value);\r\n }\r\n\r\n remove(key: string): void {\r\n WebStorageUtility.remove(this.storage, key);\r\n }\r\n\r\n clear(): void {\r\n this.storage.clear();\r\n }\r\n}\r\n\r\n@Injectable()\r\nexport class LocalStorageService extends WebStorageService {\r\n constructor() {\r\n super(localStorage);\r\n }\r\n}\r\n\r\n@Injectable()\r\nexport class SessionStorageService extends WebStorageService {\r\n constructor() {\r\n super(sessionStorage);\r\n }\r\n}\r\n"]} \ No newline at end of file +{"version":3,"file":"webstorage.service.js","sourceRoot":"","sources":["../../src/service/webstorage.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,sCAAyC;AACzC,oEAAgE;AAEhE;IACI,2BAAoB,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;IAEpC,CAAC;IAED,+BAAG,GAAH,UAAI,GAAW;QACX,MAAM,CAAC,sCAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IACpD,CAAC;IAED,+BAAG,GAAH,UAAI,GAAW,EAAE,KAAU;QACvB,sCAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC;IAED,kCAAM,GAAN,UAAO,GAAW;QACd,sCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAChD,CAAC;IAED,iCAAK,GAAL;QACI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;IACL,wBAAC;AAAD,CAAC,AApBD,IAoBC;AApBY,8CAAiB;AAuB9B,IAAa,mBAAmB;IAAS,uCAAiB;IACtD;eACI,kBAAM,YAAY,CAAC;IACvB,CAAC;IACL,0BAAC;AAAD,CAAC,AAJD,CAAyC,iBAAiB,GAIzD;AAJY,mBAAmB;IAD/B,iBAAU,EAAE;;GACA,mBAAmB,CAI/B;AAJY,kDAAmB;AAOhC,IAAa,qBAAqB;IAAS,yCAAiB;IACxD;eACI,kBAAM,cAAc,CAAC;IACzB,CAAC;IACL,4BAAC;AAAD,CAAC,AAJD,CAA2C,iBAAiB,GAI3D;AAJY,qBAAqB;IADjC,iBAAU,EAAE;;GACA,qBAAqB,CAIjC;AAJY,sDAAqB","sourcesContent":["import {Injectable} from \"@angular/core\";\nimport {WebStorageUtility} from \"../utility/webstorage.utiltiy\";\n\nexport class WebStorageService {\n constructor(private storage: Storage) {\n\n }\n\n get(key: string): any {\n return WebStorageUtility.get(this.storage, key);\n }\n\n set(key: string, value: any): void {\n WebStorageUtility.set(this.storage, key, value);\n }\n\n remove(key: string): void {\n WebStorageUtility.remove(this.storage, key);\n }\n\n clear(): void {\n this.storage.clear();\n }\n}\n\n@Injectable()\nexport class LocalStorageService extends WebStorageService {\n constructor() {\n super(localStorage);\n }\n}\n\n@Injectable()\nexport class SessionStorageService extends WebStorageService {\n constructor() {\n super(sessionStorage);\n }\n}\n"]} \ No newline at end of file diff --git a/dist/utility/index.js b/dist/utility/index.js index 3936971..85f1add 100644 --- a/dist/utility/index.js +++ b/dist/utility/index.js @@ -2,5 +2,6 @@ function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } +Object.defineProperty(exports, "__esModule", { value: true }); __export(require("./webstorage.utiltiy")); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/utility/index.js.map b/dist/utility/index.js.map index 9695968..72bc8e3 100644 --- a/dist/utility/index.js.map +++ b/dist/utility/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utility/index.ts"],"names":[],"mappings":";;;;AAAA,0CAAqC","sourcesContent":["export * from './webstorage.utiltiy';\r\n"]} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utility/index.ts"],"names":[],"mappings":";;;;;AAAA,0CAAqC","sourcesContent":["export * from './webstorage.utiltiy';\n"]} \ No newline at end of file diff --git a/dist/utility/webstorage.utiltiy.js b/dist/utility/webstorage.utiltiy.js index bc94750..4832b73 100644 --- a/dist/utility/webstorage.utiltiy.js +++ b/dist/utility/webstorage.utiltiy.js @@ -1,4 +1,5 @@ "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); var KEY_PREFIX = "angular2ws"; var WebStorageUtility = (function () { function WebStorageUtility() { diff --git a/dist/utility/webstorage.utiltiy.js.map b/dist/utility/webstorage.utiltiy.js.map index ebeb1a3..deaf843 100644 --- a/dist/utility/webstorage.utiltiy.js.map +++ b/dist/utility/webstorage.utiltiy.js.map @@ -1 +1 @@ -{"version":3,"file":"webstorage.utiltiy.js","sourceRoot":"","sources":["../../src/utility/webstorage.utiltiy.ts"],"names":[],"mappings":";AAAA,IAAM,UAAU,GAAG,YAAY,CAAC;AAEhC;IAAA;IAoCA,CAAC;IAnCU,oCAAkB,GAAzB,UAA0B,GAAW;QACjC,MAAM,CAAI,UAAU,SAAI,GAAK,CAAA;IACjC,CAAC;IAEM,qBAAG,GAAV,UAAW,OAAgB,EAAE,GAAW;QACpC,IAAI,UAAU,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAE3D,IAAI,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAExC,MAAM,CAAC,iBAAiB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IAEM,qBAAG,GAAV,UAAW,OAAgB,EAAE,GAAW,EAAE,KAAU;QAChD,IAAI,UAAU,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAE3D,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,iBAAiB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;IACtE,CAAC;IAEM,wBAAM,GAAb,UAAc,OAAgB,EAAE,GAAW;QACvC,IAAI,UAAU,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAE3D,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC;IAEc,6BAAW,GAA1B,UAA2B,KAAU;QACjC,MAAM,CAAC,OAAO,KAAK,KAAK,QAAQ,GAAG,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACrE,CAAC;IAEc,6BAAW,GAA1B,UAA2B,KAAa;QACpC,IAAI,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAE;QAAA,KAAK,CAAA,CAAC,CAAC,CAAC,CAAC,CAAC;YACR,MAAM,CAAC,KAAK,CAAC;QACjB,CAAC;IACL,CAAC;IACL,wBAAC;AAAD,CAAC,AApCD,IAoCC;AApCD,8CAoCC","sourcesContent":["const KEY_PREFIX = \"angular2ws\";\r\n\r\nexport class WebStorageUtility {\r\n static generateStorageKey(key: string): string {\r\n return `${KEY_PREFIX}_${key}`\r\n }\r\n\r\n static get(storage: Storage, key: string): any {\r\n let storageKey = WebStorageUtility.generateStorageKey(key);\r\n\r\n let value = storage.getItem(storageKey);\r\n\r\n return WebStorageUtility.getGettable(value);\r\n }\r\n\r\n static set(storage: Storage, key: string, value: any): void {\r\n let storageKey = WebStorageUtility.generateStorageKey(key);\r\n\r\n storage.setItem(storageKey, WebStorageUtility.getSettable(value));\r\n }\r\n\r\n static remove(storage: Storage, key: string): void {\r\n let storageKey = WebStorageUtility.generateStorageKey(key);\r\n\r\n storage.removeItem(storageKey);\r\n }\r\n\r\n private static getSettable(value: any): string {\r\n return typeof value === \"string\" ? value : JSON.stringify(value);\r\n }\r\n\r\n private static getGettable(value: string): any {\r\n try {\r\n return JSON.parse(value);\r\n } catch(e) {\r\n return value;\r\n }\r\n }\r\n}\r\n"]} \ No newline at end of file +{"version":3,"file":"webstorage.utiltiy.js","sourceRoot":"","sources":["../../src/utility/webstorage.utiltiy.ts"],"names":[],"mappings":";;AAAA,IAAM,UAAU,GAAG,YAAY,CAAC;AAEhC;IAAA;IAoCA,CAAC;IAnCU,oCAAkB,GAAzB,UAA0B,GAAW;QACjC,MAAM,CAAI,UAAU,SAAI,GAAK,CAAA;IACjC,CAAC;IAEM,qBAAG,GAAV,UAAW,OAAgB,EAAE,GAAW;QACpC,IAAI,UAAU,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAE3D,IAAI,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAExC,MAAM,CAAC,iBAAiB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IAEM,qBAAG,GAAV,UAAW,OAAgB,EAAE,GAAW,EAAE,KAAU;QAChD,IAAI,UAAU,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAE3D,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,iBAAiB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;IACtE,CAAC;IAEM,wBAAM,GAAb,UAAc,OAAgB,EAAE,GAAW;QACvC,IAAI,UAAU,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAE3D,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC;IAEc,6BAAW,GAA1B,UAA2B,KAAU;QACjC,MAAM,CAAC,OAAO,KAAK,KAAK,QAAQ,GAAG,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACrE,CAAC;IAEc,6BAAW,GAA1B,UAA2B,KAAa;QACpC,IAAI,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;QAAC,KAAK,CAAA,CAAC,CAAC,CAAC,CAAC,CAAC;YACR,MAAM,CAAC,KAAK,CAAC;QACjB,CAAC;IACL,CAAC;IACL,wBAAC;AAAD,CAAC,AApCD,IAoCC;AApCY,8CAAiB","sourcesContent":["const KEY_PREFIX = \"angular2ws\";\n\nexport class WebStorageUtility {\n static generateStorageKey(key: string): string {\n return `${KEY_PREFIX}_${key}`\n }\n\n static get(storage: Storage, key: string): any {\n let storageKey = WebStorageUtility.generateStorageKey(key);\n\n let value = storage.getItem(storageKey);\n\n return WebStorageUtility.getGettable(value);\n }\n\n static set(storage: Storage, key: string, value: any): void {\n let storageKey = WebStorageUtility.generateStorageKey(key);\n\n storage.setItem(storageKey, WebStorageUtility.getSettable(value));\n }\n\n static remove(storage: Storage, key: string): void {\n let storageKey = WebStorageUtility.generateStorageKey(key);\n\n storage.removeItem(storageKey);\n }\n\n private static getSettable(value: any): string {\n return typeof value === \"string\" ? value : JSON.stringify(value);\n }\n\n private static getGettable(value: string): any {\n try {\n return JSON.parse(value);\n } catch(e) {\n return value;\n }\n }\n}\n"]} \ No newline at end of file diff --git a/package.json b/package.json index 968f1da..b212492 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "angular2-localstorage", - "version": "0.4.0", - "description": "Angular2 decorator to save and restore class properties automatically from LocalStorage.", + "name": "angular-localstorage4", + "version": "0.5.1", + "description": "Angular decorator to save and restore class properties automatically from LocalStorage.", "scripts": { "lint": "tslint ./*.ts -t verbose", "build": "rimraf dist && tsc", @@ -10,31 +10,33 @@ }, "repository": { "type": "git", - "url": "git@github.com:marcj/angular2-localstorage.git" + "url": "git@github.com:Jinkwon/angular-localstorage.git" }, "keywords": [ + "Angular", "Angular2", + "Angular4", "LocalStorage" ], "author": "Marc J. Schmidt", "license": "ISC", "bugs": { - "url": "https://github.com/marcj/angular2-localstorage/issues" + "url": "https://github.com/Jinkwon/angular-localstorage/issues" }, - "homepage": "https://github.com/marcj/angular2-localstorage", + "homepage": "https://github.com/Jinkwon/angular-localstorage", "peerDependencies": { "@angular/core": "^2.0.0", "core-js": "^2.4.1", - "rxjs": "^5.0.0-beta.12", - "zone.js": "^0.6.25" + "rxjs": "^5.2.0", + "zone.js": "^0.8.5" }, "devDependencies": { - "@angular/core": "^2.0.0", + "@angular/core": "^4.0.0", "@types/core-js": "^0.9.34", "rimraf": "^2.5.4", - "rxjs": "^5.0.0-beta.12", + "rxjs": "^5.2.0", "tslint": "^3.15.1", "typings": "^1.3.3", - "zone.js": "^0.6.25" + "zone.js": "^0.8.5" } } diff --git a/tsconfig.json b/tsconfig.json index 277ca2a..82511c4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,7 +8,8 @@ "experimentalDecorators": true, "inlineSources": true, "outDir": "dist", - "declaration": true + "declaration": true, + "lib": ["es2017", "dom", "scriptHost"] }, "exclude": [ "node_modules", From 7ec8c08c50269a50d6f8f3740cdd7ccdb73a7c24 Mon Sep 17 00:00:00 2001 From: jinkwon Date: Tue, 28 Mar 2017 17:19:39 +0900 Subject: [PATCH 3/3] task: update document --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 45e2f1e..fe43bb7 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,7 @@ This little Angular/typescript decorator makes it super easy to save and restore *automatically* a variable state in your directive (class property) using HTML5' LocalStorage. -## Seeking new maintainer - -This project is not maintained. Please consider taking it over. More information at https://github.com/open-source-chest/take-it-over. +Compatible with angular 4.0.0. ## Use