@christianriedl/utils 1.0.33 → 1.0.35

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.
@@ -2,7 +2,7 @@ import { ILocalStorage } from './iLocalStorage';
2
2
  import { IAppConfig, IConfigItem, ItemType, Dictionary, ISubscribePushNotification } from './types';
3
3
  import { ILogger, LogLevel } from './iLogger';
4
4
  export declare class AppConfig implements IAppConfig {
5
- private storage;
5
+ localStorage: ILocalStorage;
6
6
  items: Dictionary<IConfigItem>;
7
7
  subscribePush?: ISubscribePushNotification;
8
8
  constructor(storage: ILocalStorage);
package/dist/appConfig.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { LogLevel } from './iLogger';
2
2
  export class AppConfig {
3
- storage;
3
+ localStorage;
4
4
  items = {};
5
5
  subscribePush;
6
6
  constructor(storage) {
7
- this.storage = storage;
7
+ this.localStorage = storage;
8
8
  }
9
9
  add(name, description, value, values) {
10
10
  const item = { name: name, description: description, value: value, default: value, values: values };
@@ -15,13 +15,13 @@ export class AppConfig {
15
15
  const item = this.items[key];
16
16
  switch (typeof item.default) {
17
17
  case "string":
18
- item.value = this.storage.getItemString(item.name, item.default);
18
+ item.value = this.localStorage.getItemString(item.name, item.default);
19
19
  break;
20
20
  case "number":
21
- item.value = this.storage.getItemNumber(item.name, item.default);
21
+ item.value = this.localStorage.getItemNumber(item.name, item.default);
22
22
  break;
23
23
  case "boolean":
24
- item.value = this.storage.getItemBoolean(item.name, item.default);
24
+ item.value = this.localStorage.getItemBoolean(item.name, item.default);
25
25
  break;
26
26
  }
27
27
  }
@@ -29,7 +29,7 @@ export class AppConfig {
29
29
  save() {
30
30
  for (const key in this.items) {
31
31
  const item = this.items[key];
32
- this.storage.setItem(item.name, item.value);
32
+ this.localStorage.setItem(item.name, item.value);
33
33
  }
34
34
  }
35
35
  restoreDefaults() {
@@ -1 +1 @@
1
- {"version":3,"file":"appConfig.js","sourceRoot":"","sources":["../src/appConfig.ts"],"names":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,3 +1,4 @@
1
+ import { ILocalStorage } from './iLocalStorage';
1
2
  import { LogLevel, ILogger } from './iLogger';
2
3
  export declare type Dictionary<T> = {
3
4
  [key: string]: T;
@@ -74,6 +75,7 @@ export interface IConfigItem {
74
75
  default: ItemType;
75
76
  }
76
77
  export interface IAppConfig {
78
+ localStorage: ILocalStorage;
77
79
  items: Dictionary<IConfigItem>;
78
80
  subscribePush?: ISubscribePushNotification;
79
81
  add(name: string, description: string, value: ItemType, values?: string[]): void;
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AASC,CAAC;AAUF,MAAM,CAAN,IAAY,QASX;AATD,WAAY,QAAQ;IAChB,6CAAW,CAAA;IACX,6CAAO,CAAA;IACP,6CAAO,CAAA;IACP,yCAAK,CAAA;IACL,uCAAI,CAAA;IACJ,iDAAS,CAAA;IACT,2CAAM,CAAA;IACN,2CAAM,CAAA;AACV,CAAC,EATW,QAAQ,KAAR,QAAQ,QASnB;AACD,MAAM,CAAN,IAAY,OAMX;AAND,WAAY,OAAO;IACf,2CAAW,CAAA;IACX,yCAAM,CAAA;IACN,qCAAI,CAAA;IACJ,iCAAE,CAAA;IACF,6CAAQ,CAAA;AACZ,CAAC,EANW,OAAO,KAAP,OAAO,QAMlB;AAYD,MAAM,CAAN,IAAY,UAMX;AAND,WAAY,UAAU;IAClB,2CAAQ,CAAA;IACR,2CAAI,CAAA;IACJ,6CAAK,CAAA;IACL,uCAAE,CAAA;IACF,2CAAI,CAAA;AACR,CAAC,EANW,UAAU,KAAV,UAAU,QAMrB"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAUC,CAAC;AAUF,MAAM,CAAN,IAAY,QASX;AATD,WAAY,QAAQ;IAChB,6CAAW,CAAA;IACX,6CAAO,CAAA;IACP,6CAAO,CAAA;IACP,yCAAK,CAAA;IACL,uCAAI,CAAA;IACJ,iDAAS,CAAA;IACT,2CAAM,CAAA;IACN,2CAAM,CAAA;AACV,CAAC,EATW,QAAQ,KAAR,QAAQ,QASnB;AACD,MAAM,CAAN,IAAY,OAMX;AAND,WAAY,OAAO;IACf,2CAAW,CAAA;IACX,yCAAM,CAAA;IACN,qCAAI,CAAA;IACJ,iCAAE,CAAA;IACF,6CAAQ,CAAA;AACZ,CAAC,EANW,OAAO,KAAP,OAAO,QAMlB;AAYD,MAAM,CAAN,IAAY,UAMX;AAND,WAAY,UAAU;IAClB,2CAAQ,CAAA;IACR,2CAAI,CAAA;IACJ,6CAAK,CAAA;IACL,uCAAE,CAAA;IACF,2CAAI,CAAA;AACR,CAAC,EANW,UAAU,KAAV,UAAU,QAMrB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@christianriedl/utils",
3
- "version": "1.0.33",
3
+ "version": "1.0.35",
4
4
  "description": "Interfaces, local storage, service worker, configuration, application state",
5
5
 
6
6
  "main": "dist/index.js",