@rxap/ngx-memory 19.1.0 → 21.0.1-dev.1

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.
Files changed (76) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/compodoc/changelog.html +4 -0
  3. package/compodoc/dependencies.html +2 -2
  4. package/compodoc/js/search/search_index.js +2 -2
  5. package/compodoc/properties.html +1 -1
  6. package/docs/documentation.json +205 -101
  7. package/docs/html/classes/EphemeralStorageService.html +3 -3
  8. package/docs/html/classes/LocalStorageService.html +3 -3
  9. package/docs/html/classes/MockStorage.html +8 -12
  10. package/docs/html/classes/SessionStorageService.html +3 -3
  11. package/docs/html/classes/StorageService.html +3 -3
  12. package/docs/html/functions/LocalStorage.html +2 -2
  13. package/docs/html/functions/SessionStorage.html +2 -2
  14. package/docs/html/functions/StorageGet.html +1 -1
  15. package/docs/html/functions/StorageHas.html +1 -1
  16. package/docs/html/functions/StorageKey.html +1 -1
  17. package/docs/html/functions/StorageRemove.html +1 -1
  18. package/docs/html/functions/StorageSet.html +1 -1
  19. package/docs/html/functions/WebStorage.html +1 -1
  20. package/docs/html/functions/getExpired.html +1 -1
  21. package/docs/html/functions/stringify.html +1 -1
  22. package/docs/html/hierarchy.html +1 -1
  23. package/docs/html/index.html +2 -2
  24. package/docs/html/modules.html +1 -1
  25. package/docs/html/types/ExpiredUnit.html +2 -2
  26. package/docs/html/variables/isBrowser.html +2 -2
  27. package/docs/markdown/README.md +1 -1
  28. package/docs/markdown/classes/EphemeralStorageService.md +8 -8
  29. package/docs/markdown/classes/LocalStorageService.md +8 -8
  30. package/docs/markdown/classes/MockStorage.md +15 -23
  31. package/docs/markdown/classes/SessionStorageService.md +8 -8
  32. package/docs/markdown/classes/StorageService.md +8 -8
  33. package/docs/markdown/functions/LocalStorage.md +2 -2
  34. package/docs/markdown/functions/SessionStorage.md +2 -2
  35. package/docs/markdown/functions/StorageGet.md +2 -2
  36. package/docs/markdown/functions/StorageHas.md +2 -2
  37. package/docs/markdown/functions/StorageKey.md +2 -2
  38. package/docs/markdown/functions/StorageRemove.md +2 -2
  39. package/docs/markdown/functions/StorageSet.md +2 -2
  40. package/docs/markdown/functions/WebStorage.md +2 -2
  41. package/docs/markdown/functions/getExpired.md +2 -2
  42. package/docs/markdown/functions/stringify.md +2 -2
  43. package/docs/markdown/globals.md +2 -2
  44. package/docs/markdown/type-aliases/ExpiredUnit.md +2 -2
  45. package/docs/markdown/variables/isBrowser.md +2 -2
  46. package/docs/wiki/Class.EphemeralStorageService.md +7 -7
  47. package/docs/wiki/Class.LocalStorageService.md +7 -7
  48. package/docs/wiki/Class.MockStorage.md +14 -22
  49. package/docs/wiki/Class.SessionStorageService.md +7 -7
  50. package/docs/wiki/Class.StorageService.md +7 -7
  51. package/docs/wiki/Function.LocalStorage.md +1 -1
  52. package/docs/wiki/Function.SessionStorage.md +1 -1
  53. package/docs/wiki/Function.StorageGet.md +1 -1
  54. package/docs/wiki/Function.StorageHas.md +1 -1
  55. package/docs/wiki/Function.StorageKey.md +1 -1
  56. package/docs/wiki/Function.StorageRemove.md +1 -1
  57. package/docs/wiki/Function.StorageSet.md +1 -1
  58. package/docs/wiki/Function.WebStorage.md +1 -1
  59. package/docs/wiki/Function.getExpired.md +1 -1
  60. package/docs/wiki/Function.stringify.md +1 -1
  61. package/docs/wiki/TypeAlias.ExpiredUnit.md +1 -1
  62. package/docs/wiki/Variable.isBrowser.md +1 -1
  63. package/docs/wiki/globals.md +1 -1
  64. package/fesm2022/rxap-ngx-memory.mjs +12 -12
  65. package/fesm2022/rxap-ngx-memory.mjs.map +1 -1
  66. package/package.json +12 -7
  67. package/types/rxap-ngx-memory.d.ts +101 -0
  68. package/index.d.ts +0 -8
  69. package/lib/decorators/local-storage.d.ts +0 -9
  70. package/lib/decorators/session-storage.d.ts +0 -9
  71. package/lib/decorators/web-storage.d.ts +0 -9
  72. package/lib/ephemeral-storage.service.d.ts +0 -7
  73. package/lib/local-storage.service.d.ts +0 -7
  74. package/lib/session-storage.service.d.ts +0 -7
  75. package/lib/storage-utility.d.ts +0 -33
  76. package/lib/storage.service.d.ts +0 -19
@@ -4,7 +4,7 @@
4
4
 
5
5
  > **SessionStorage**(`key`?, `expiredAt`?, `expiredUnit`?): (`target`, `propertyName`) => `void`
6
6
 
7
- Defined in: [decorators/session-storage.ts:14](https://gitlab.com/rxap/packages/-/blob/3648307d22f6f77230de9b76f6335a68f0ed3849/packages/angular/memory/src/lib/decorators/session-storage.ts#L14)
7
+ Defined in: [decorators/session-storage.ts:14](https://gitlab.com/rxap/packages/-/blob/be7e221de2deba638078b6c685a94021679a1a5b/packages/angular/memory/src/lib/decorators/session-storage.ts#L14)
8
8
 
9
9
  `sessionStorage` Decorator
10
10
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  > **StorageGet**(`storage`, `key`): `unknown`
6
6
 
7
- Defined in: [storage-utility.ts:20](https://gitlab.com/rxap/packages/-/blob/3648307d22f6f77230de9b76f6335a68f0ed3849/packages/angular/memory/src/lib/storage-utility.ts#L20)
7
+ Defined in: [storage-utility.ts:20](https://gitlab.com/rxap/packages/-/blob/be7e221de2deba638078b6c685a94021679a1a5b/packages/angular/memory/src/lib/storage-utility.ts#L20)
8
8
 
9
9
  ## Parameters
10
10
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  > **StorageHas**(`storage`, `key`): `boolean`
6
6
 
7
- Defined in: [storage-utility.ts:37](https://gitlab.com/rxap/packages/-/blob/3648307d22f6f77230de9b76f6335a68f0ed3849/packages/angular/memory/src/lib/storage-utility.ts#L37)
7
+ Defined in: [storage-utility.ts:37](https://gitlab.com/rxap/packages/-/blob/be7e221de2deba638078b6c685a94021679a1a5b/packages/angular/memory/src/lib/storage-utility.ts#L37)
8
8
 
9
9
  ## Parameters
10
10
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  > **StorageKey**(`storage`, `index`): `null` \| `string`
6
6
 
7
- Defined in: [storage-utility.ts:65](https://gitlab.com/rxap/packages/-/blob/3648307d22f6f77230de9b76f6335a68f0ed3849/packages/angular/memory/src/lib/storage-utility.ts#L65)
7
+ Defined in: [storage-utility.ts:65](https://gitlab.com/rxap/packages/-/blob/be7e221de2deba638078b6c685a94021679a1a5b/packages/angular/memory/src/lib/storage-utility.ts#L65)
8
8
 
9
9
  ## Parameters
10
10
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  > **StorageRemove**(`storage`, `key`): `void`
6
6
 
7
- Defined in: [storage-utility.ts:58](https://gitlab.com/rxap/packages/-/blob/3648307d22f6f77230de9b76f6335a68f0ed3849/packages/angular/memory/src/lib/storage-utility.ts#L58)
7
+ Defined in: [storage-utility.ts:58](https://gitlab.com/rxap/packages/-/blob/be7e221de2deba638078b6c685a94021679a1a5b/packages/angular/memory/src/lib/storage-utility.ts#L58)
8
8
 
9
9
  ## Parameters
10
10
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  > **StorageSet**(`storage`, `key`, `value`, `expiredAt`, `expiredUnit`): `void`
6
6
 
7
- Defined in: [storage-utility.ts:44](https://gitlab.com/rxap/packages/-/blob/3648307d22f6f77230de9b76f6335a68f0ed3849/packages/angular/memory/src/lib/storage-utility.ts#L44)
7
+ Defined in: [storage-utility.ts:44](https://gitlab.com/rxap/packages/-/blob/be7e221de2deba638078b6c685a94021679a1a5b/packages/angular/memory/src/lib/storage-utility.ts#L44)
8
8
 
9
9
  ## Parameters
10
10
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  > **WebStorage**(`storage`, `key`?, `expiredAt`?, `expiredUnit`?): (`target`, `propertyName`) => `void`
6
6
 
7
- Defined in: [decorators/web-storage.ts:16](https://gitlab.com/rxap/packages/-/blob/3648307d22f6f77230de9b76f6335a68f0ed3849/packages/angular/memory/src/lib/decorators/web-storage.ts#L16)
7
+ Defined in: [decorators/web-storage.ts:16](https://gitlab.com/rxap/packages/-/blob/be7e221de2deba638078b6c685a94021679a1a5b/packages/angular/memory/src/lib/decorators/web-storage.ts#L16)
8
8
 
9
9
  **`Internal`**
10
10
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  > **getExpired**(`val`, `unit`): `number`
6
6
 
7
- Defined in: [storage-utility.ts:72](https://gitlab.com/rxap/packages/-/blob/3648307d22f6f77230de9b76f6335a68f0ed3849/packages/angular/memory/src/lib/storage-utility.ts#L72)
7
+ Defined in: [storage-utility.ts:72](https://gitlab.com/rxap/packages/-/blob/be7e221de2deba638078b6c685a94021679a1a5b/packages/angular/memory/src/lib/storage-utility.ts#L72)
8
8
 
9
9
  ## Parameters
10
10
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  > **stringify**(`value`): `string`
6
6
 
7
- Defined in: [storage-utility.ts:98](https://gitlab.com/rxap/packages/-/blob/3648307d22f6f77230de9b76f6335a68f0ed3849/packages/angular/memory/src/lib/storage-utility.ts#L98)
7
+ Defined in: [storage-utility.ts:98](https://gitlab.com/rxap/packages/-/blob/be7e221de2deba638078b6c685a94021679a1a5b/packages/angular/memory/src/lib/storage-utility.ts#L98)
8
8
 
9
9
  ## Parameters
10
10
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  > **ExpiredUnit**: `"s"` \| `"m"` \| `"h"` \| `"d"` \| `"w"` \| `"y"` \| `"t"`
6
6
 
7
- Defined in: [storage-utility.ts:11](https://gitlab.com/rxap/packages/-/blob/3648307d22f6f77230de9b76f6335a68f0ed3849/packages/angular/memory/src/lib/storage-utility.ts#L11)
7
+ Defined in: [storage-utility.ts:11](https://gitlab.com/rxap/packages/-/blob/be7e221de2deba638078b6c685a94021679a1a5b/packages/angular/memory/src/lib/storage-utility.ts#L11)
8
8
 
9
9
  Expiration time unit
10
10
  s: seconds
@@ -4,7 +4,7 @@
4
4
 
5
5
  > `const` **isBrowser**: `boolean`
6
6
 
7
- Defined in: [storage-utility.ts:18](https://gitlab.com/rxap/packages/-/blob/3648307d22f6f77230de9b76f6335a68f0ed3849/packages/angular/memory/src/lib/storage-utility.ts#L18)
7
+ Defined in: [storage-utility.ts:18](https://gitlab.com/rxap/packages/-/blob/be7e221de2deba638078b6c685a94021679a1a5b/packages/angular/memory/src/lib/storage-utility.ts#L18)
8
8
 
9
9
  Determining if an Angular application is rendered in the browser
10
10
  The Angular `PLATFORM_ID` identifier cannot be used directly by the `decorator`.
@@ -1,4 +1,4 @@
1
- # @rxap/ngx-memory v19.1.0
1
+ # @rxap/ngx-memory v21.0.1-dev.1
2
2
 
3
3
  ## Classes
4
4
 
@@ -223,10 +223,10 @@ class StorageService {
223
223
  clear() {
224
224
  this.storage?.clear();
225
225
  }
226
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: StorageService, deps: [{ token: Storage }], target: i0.ɵɵFactoryTarget.Injectable }); }
227
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: StorageService }); }
226
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: StorageService, deps: [{ token: Storage }], target: i0.ɵɵFactoryTarget.Injectable }); }
227
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: StorageService }); }
228
228
  }
229
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: StorageService, decorators: [{
229
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: StorageService, decorators: [{
230
230
  type: Injectable
231
231
  }], ctorParameters: () => [{ type: Storage }] });
232
232
 
@@ -234,10 +234,10 @@ class EphemeralStorageService extends StorageService {
234
234
  constructor() {
235
235
  super(new MockStorage());
236
236
  }
237
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: EphemeralStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
238
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: EphemeralStorageService, providedIn: 'root' }); }
237
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: EphemeralStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
238
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: EphemeralStorageService, providedIn: 'root' }); }
239
239
  }
240
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: EphemeralStorageService, decorators: [{
240
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: EphemeralStorageService, decorators: [{
241
241
  type: Injectable,
242
242
  args: [{ providedIn: 'root' }]
243
243
  }], ctorParameters: () => [] });
@@ -246,10 +246,10 @@ class LocalStorageService extends StorageService {
246
246
  constructor() {
247
247
  super(isBrowser ? localStorage : null);
248
248
  }
249
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: LocalStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
250
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: LocalStorageService, providedIn: 'root' }); }
249
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: LocalStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
250
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: LocalStorageService, providedIn: 'root' }); }
251
251
  }
252
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: LocalStorageService, decorators: [{
252
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: LocalStorageService, decorators: [{
253
253
  type: Injectable,
254
254
  args: [{ providedIn: 'root' }]
255
255
  }], ctorParameters: () => [] });
@@ -258,10 +258,10 @@ class SessionStorageService extends StorageService {
258
258
  constructor() {
259
259
  super(isBrowser ? sessionStorage : null);
260
260
  }
261
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: SessionStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
262
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: SessionStorageService, providedIn: 'root' }); }
261
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: SessionStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
262
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: SessionStorageService, providedIn: 'root' }); }
263
263
  }
264
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: SessionStorageService, decorators: [{
264
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: SessionStorageService, decorators: [{
265
265
  type: Injectable,
266
266
  args: [{ providedIn: 'root' }]
267
267
  }], ctorParameters: () => [] });
@@ -1 +1 @@
1
- {"version":3,"file":"rxap-ngx-memory.mjs","sources":["../../../../../packages/angular/memory/src/lib/storage-utility.ts","../../../../../packages/angular/memory/src/lib/decorators/web-storage.ts","../../../../../packages/angular/memory/src/lib/decorators/local-storage.ts","../../../../../packages/angular/memory/src/lib/decorators/session-storage.ts","../../../../../packages/angular/memory/src/lib/storage.service.ts","../../../../../packages/angular/memory/src/lib/ephemeral-storage.service.ts","../../../../../packages/angular/memory/src/lib/local-storage.service.ts","../../../../../packages/angular/memory/src/lib/session-storage.service.ts","../../../../../packages/angular/memory/src/index.ts","../../../../../packages/angular/memory/src/rxap-ngx-memory.ts"],"sourcesContent":["/**\n * Expiration time unit\n * s: seconds\n * m: minute\n * h: hour\n * d: day\n * w: week\n * y: year\n * t: Custom (millisecond)\n */\nexport type ExpiredUnit = 's' | 'm' | 'h' | 'd' | 'w' | 'y' | 't';\n\n/**\n * Determining if an Angular application is rendered in the browser\n * The Angular `PLATFORM_ID` identifier cannot be used directly by the `decorator`.\n * The advantage of this is that it also works well when the server populates the Document itself.\n */\nexport const isBrowser = typeof document === 'object' && !!document;\n\nexport function StorageGet(storage: Storage | null, key: string): unknown {\n if (storage === null) {\n return null;\n }\n const value = parse(storage.getItem(key) ?? 'null') ?? null;\n if (value === null) {\n return null;\n }\n if (typeof value === 'object' && typeof value._expired !== 'undefined' && value._expired !== 0 && +new Date() >\n value._expired) {\n StorageRemove(storage, key);\n return null;\n }\n\n return value._value ?? null;\n}\n\nexport function StorageHas(storage: Storage | null, key: string): boolean {\n if (storage === null) {\n return false;\n }\n return storage.getItem(key) !== null;\n}\n\nexport function StorageSet(\n storage: Storage | null, key: string, value: any, expiredAt = 0, expiredUnit: ExpiredUnit = 't'): void {\n if (storage === null) {\n return;\n }\n storage.setItem(\n key,\n stringify({\n _expired: getExpired(expiredAt, expiredUnit),\n _value: value,\n }),\n );\n}\n\nexport function StorageRemove(storage: Storage | null, key: string): void {\n if (storage === null) {\n return;\n }\n storage.removeItem(key);\n}\n\nexport function StorageKey(storage: Storage | null, index: number): string | null {\n if (storage === null) {\n return null;\n }\n return storage.key(index);\n}\n\nexport function getExpired(val: number, unit: ExpiredUnit): number {\n if (val <= 0) {\n return 0;\n }\n const now = +new Date();\n switch (unit) {\n case 's': // second\n return now + 1000 * val;\n case 'm': // minute\n return now + 1000 * 60 * val;\n case 'h': // hour\n return now + 1000 * 60 * 60 * val;\n case 'd': // day\n return now + 1000 * 60 * 60 * 24 * val;\n case 'w': // week\n return now + 1000 * 60 * 60 * 24 * 7 * val;\n case 'y': // year\n return now + 1000 * 60 * 60 * 24 * 365 * val;\n case 't': // customisation\n return now + val;\n default:\n throw new Error('Invalid expired unit');\n }\n return 0;\n}\n\nexport function stringify(value: any): string {\n return JSON.stringify(value);\n}\n\nfunction parse(text: string): any {\n try {\n return JSON.parse(text) ?? null;\n } catch (e) {\n return text;\n }\n}\n\nexport class MockStorage implements Storage {\n\n cache: Record<string, string> = {};\n\n get length(): number {\n return Object.keys(this.cache).length;\n }\n\n getItem(key: string): string | null {\n return this.cache[key] ?? null;\n }\n\n key(index: number): string | null {\n return Object.keys(this.cache)[index] ?? null;\n }\n\n removeItem(key: string): void {\n if (this.cache[key] !== undefined) {\n delete this.cache[key];\n }\n }\n\n setItem(key: string, value: string): void {\n this.cache[key] = value;\n }\n\n clear(): void {\n this.cache = {};\n }\n\n}\n","import {\n ExpiredUnit,\n StorageGet,\n StorageHas,\n StorageRemove,\n StorageSet,\n} from '../storage-utility';\n\n/**\n * @internal\n * @param storage\n * @param key\n * @param expiredAt\n * @param expiredUnit\n */\nexport function WebStorage(\n storage: Storage | null,\n key?: string,\n expiredAt = 0,\n expiredUnit: ExpiredUnit = 'd',\n) {\n return (target: any, propertyName: string): void => {\n const storageKey = key ?? propertyName;\n let propertyValue: unknown | undefined = undefined;\n Object.defineProperty(target, propertyName, {\n get: () => {\n // check if the value is set\n if (propertyValue === undefined) {\n // if not check if the value is set in the storage\n if (StorageHas(storage, storageKey)) {\n return propertyValue = StorageGet(storage, storageKey);\n }\n }\n return propertyValue;\n },\n set: (value: unknown) => {\n // check if the value is set\n if (propertyValue === undefined) {\n // if not check if the value is set in the storage\n if (StorageHas(storage, storageKey)) {\n // if yes, get the value from the storage\n propertyValue = StorageGet(storage, storageKey);\n return;\n }\n }\n propertyValue = value;\n // check if the value is set\n if (propertyValue === undefined) {\n // check if the value is set in the storage\n if (StorageHas(storage, storageKey)) {\n // remove any value from the storage\n StorageRemove(storage, storageKey);\n }\n } else {\n // set the value in the storage\n StorageSet(storage, storageKey, value, expiredAt, expiredUnit);\n }\n },\n enumerable: true,\n configurable: true,\n });\n };\n}\n","import {\n ExpiredUnit,\n isBrowser,\n} from '../storage-utility';\nimport { WebStorage } from './web-storage';\n\n/**\n * `localStorage` Decorator\n *\n * @param [key] Storage key\n * @param [expiredAt=0] Expiration time, 0 means forever\n * @param [expiredUnit='t'] Expiration time unit (default: custom [unit: ms])\n */\nexport function LocalStorage(\n key?: string,\n expiredAt = 0,\n expiredUnit: ExpiredUnit = 't',\n) {\n return WebStorage(isBrowser ? localStorage : null, key, expiredAt, expiredUnit);\n}\n","import {\n ExpiredUnit,\n isBrowser,\n} from '../storage-utility';\nimport { WebStorage } from './web-storage';\n\n/**\n * `sessionStorage` Decorator\n *\n * @param [key] Storage key\n * @param [expiredAt=0] Expiration time, 0 means forever\n * @param [expiredUnit='t'] Expiration time unit (default: custom [unit: ms])\n */\nexport function SessionStorage(\n key?: string,\n expiredAt = 0,\n expiredUnit: ExpiredUnit = 't',\n) {\n return WebStorage(isBrowser ? sessionStorage : null, key, expiredAt, expiredUnit);\n}\n","import { Injectable } from '@angular/core';\nimport {\n ExpiredUnit,\n StorageGet,\n StorageHas,\n StorageKey,\n StorageRemove,\n StorageSet,\n} from './storage-utility';\n\n@Injectable()\nexport abstract class StorageService {\n protected constructor(private storage: Storage | null) {}\n\n has(key: string): boolean {\n return StorageHas(this.storage, key);\n }\n\n get(key: string): any {\n return StorageGet(this.storage, key);\n }\n\n set(key: string, value: any, expiredAt = 0, expiredUnit: ExpiredUnit = 'd'): void {\n return StorageSet(this.storage, key, value, expiredAt, expiredUnit);\n }\n\n /**\n * Removes the specified key, e.g.:\n * - `remove('key')` Remove `key` key\n * - `remove(/BMap_\\w+/)` Bulk delete all keys starting with BMap_\n * @param key key name or regular expression\n */\n remove(key: string | RegExp): void {\n if (typeof key === 'string') {\n StorageRemove(this.storage, key);\n return;\n }\n let index = 0;\n let next = StorageKey(this.storage, index);\n const ls: string[] = [];\n while (next) {\n if (key.test(next)) {\n ls.push(next);\n }\n next = StorageKey(this.storage, ++index);\n }\n ls.forEach((v) => StorageRemove(this.storage, v));\n }\n\n clear(): void {\n this.storage?.clear();\n }\n}\n\n","import { Injectable } from '@angular/core';\nimport { MockStorage } from './storage-utility';\nimport { StorageService } from './storage.service';\n\n@Injectable({ providedIn: 'root' })\nexport class EphemeralStorageService extends StorageService {\n\n constructor() {\n super(new MockStorage());\n }\n\n}\n","import { Injectable } from '@angular/core';\nimport { isBrowser } from './storage-utility';\nimport { StorageService } from './storage.service';\n\n@Injectable({ providedIn: 'root' })\nexport class LocalStorageService extends StorageService {\n constructor() {\n super(isBrowser ? localStorage : null);\n }\n}\n","import { Injectable } from '@angular/core';\nimport { isBrowser } from './storage-utility';\nimport { StorageService } from './storage.service';\n\n@Injectable({ providedIn: 'root' })\nexport class SessionStorageService extends StorageService {\n constructor() {\n super(isBrowser ? sessionStorage : null);\n }\n}\n","// region decorators\nexport * from './lib/decorators/local-storage';\nexport * from './lib/decorators/session-storage';\nexport * from './lib/decorators/web-storage';\n// endregion\n\n// region \nexport * from './lib/ephemeral-storage.service';\nexport * from './lib/local-storage.service';\nexport * from './lib/session-storage.service';\nexport * from './lib/storage-utility';\nexport * from './lib/storage.service';\n// endregion\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AAYA;;;;AAIG;AACI,MAAM,SAAS,GAAG,OAAO,QAAQ,KAAK,QAAQ,IAAI,CAAC,CAAC;AAE3C,SAAA,UAAU,CAAC,OAAuB,EAAE,GAAW,EAAA;AAC7D,IAAA,IAAI,OAAO,KAAK,IAAI,EAAE;AACpB,QAAA,OAAO,IAAI;;AAEb,IAAA,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,IAAI,IAAI;AAC3D,IAAA,IAAI,KAAK,KAAK,IAAI,EAAE;AAClB,QAAA,OAAO,IAAI;;IAEb,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,O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B,cADR,MAAM,EAAA,CAAA,CAAA;;4FACnB,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBADjC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;ACJlC;AAYA;;ACZA;;AAEG;;;;"}
1
+ {"version":3,"file":"rxap-ngx-memory.mjs","sources":["../../../../../packages/angular/memory/src/lib/storage-utility.ts","../../../../../packages/angular/memory/src/lib/decorators/web-storage.ts","../../../../../packages/angular/memory/src/lib/decorators/local-storage.ts","../../../../../packages/angular/memory/src/lib/decorators/session-storage.ts","../../../../../packages/angular/memory/src/lib/storage.service.ts","../../../../../packages/angular/memory/src/lib/ephemeral-storage.service.ts","../../../../../packages/angular/memory/src/lib/local-storage.service.ts","../../../../../packages/angular/memory/src/lib/session-storage.service.ts","../../../../../packages/angular/memory/src/index.ts","../../../../../packages/angular/memory/src/rxap-ngx-memory.ts"],"sourcesContent":["/**\n * Expiration time unit\n * s: seconds\n * m: minute\n * h: hour\n * d: day\n * w: week\n * y: year\n * t: Custom (millisecond)\n */\nexport type ExpiredUnit = 's' | 'm' | 'h' | 'd' | 'w' | 'y' | 't';\n\n/**\n * Determining if an Angular application is rendered in the browser\n * The Angular `PLATFORM_ID` identifier cannot be used directly by the `decorator`.\n * The advantage of this is that it also works well when the server populates the Document itself.\n */\nexport const isBrowser = typeof document === 'object' && !!document;\n\nexport function StorageGet(storage: Storage | null, key: string): unknown {\n if (storage === null) {\n return null;\n }\n const value = parse(storage.getItem(key) ?? 'null') ?? null;\n if (value === null) {\n return null;\n }\n if (typeof value === 'object' && typeof value._expired !== 'undefined' && value._expired !== 0 && +new Date() >\n value._expired) {\n StorageRemove(storage, key);\n return null;\n }\n\n return value._value ?? null;\n}\n\nexport function StorageHas(storage: Storage | null, key: string): boolean {\n if (storage === null) {\n return false;\n }\n return storage.getItem(key) !== null;\n}\n\nexport function StorageSet(\n storage: Storage | null, key: string, value: any, expiredAt = 0, expiredUnit: ExpiredUnit = 't'): void {\n if (storage === null) {\n return;\n }\n storage.setItem(\n key,\n stringify({\n _expired: getExpired(expiredAt, expiredUnit),\n _value: value,\n }),\n );\n}\n\nexport function StorageRemove(storage: Storage | null, key: string): void {\n if (storage === null) {\n return;\n }\n storage.removeItem(key);\n}\n\nexport function StorageKey(storage: Storage | null, index: number): string | null {\n if (storage === null) {\n return null;\n }\n return storage.key(index);\n}\n\nexport function getExpired(val: number, unit: ExpiredUnit): number {\n if (val <= 0) {\n return 0;\n }\n const now = +new Date();\n switch (unit) {\n case 's': // second\n return now + 1000 * val;\n case 'm': // minute\n return now + 1000 * 60 * val;\n case 'h': // hour\n return now + 1000 * 60 * 60 * val;\n case 'd': // day\n return now + 1000 * 60 * 60 * 24 * val;\n case 'w': // week\n return now + 1000 * 60 * 60 * 24 * 7 * val;\n case 'y': // year\n return now + 1000 * 60 * 60 * 24 * 365 * val;\n case 't': // customisation\n return now + val;\n default:\n throw new Error('Invalid expired unit');\n }\n return 0;\n}\n\nexport function stringify(value: any): string {\n return JSON.stringify(value);\n}\n\nfunction parse(text: string): any {\n try {\n return JSON.parse(text) ?? null;\n } catch (e) {\n return text;\n }\n}\n\nexport class MockStorage implements Storage {\n\n cache: Record<string, string> = {};\n\n get length(): number {\n return Object.keys(this.cache).length;\n }\n\n getItem(key: string): string | null {\n return this.cache[key] ?? null;\n }\n\n key(index: number): string | null {\n return Object.keys(this.cache)[index] ?? null;\n }\n\n removeItem(key: string): void {\n if (this.cache[key] !== undefined) {\n delete this.cache[key];\n }\n }\n\n setItem(key: string, value: string): void {\n this.cache[key] = value;\n }\n\n clear(): void {\n this.cache = {};\n }\n\n}\n","import {\n ExpiredUnit,\n StorageGet,\n StorageHas,\n StorageRemove,\n StorageSet,\n} from '../storage-utility';\n\n/**\n * @internal\n * @param storage\n * @param key\n * @param expiredAt\n * @param expiredUnit\n */\nexport function WebStorage(\n storage: Storage | null,\n key?: string,\n expiredAt = 0,\n expiredUnit: ExpiredUnit = 'd',\n) {\n return (target: any, propertyName: string): void => {\n const storageKey = key ?? propertyName;\n let propertyValue: unknown | undefined = undefined;\n Object.defineProperty(target, propertyName, {\n get: () => {\n // check if the value is set\n if (propertyValue === undefined) {\n // if not check if the value is set in the storage\n if (StorageHas(storage, storageKey)) {\n return propertyValue = StorageGet(storage, storageKey);\n }\n }\n return propertyValue;\n },\n set: (value: unknown) => {\n // check if the value is set\n if (propertyValue === undefined) {\n // if not check if the value is set in the storage\n if (StorageHas(storage, storageKey)) {\n // if yes, get the value from the storage\n propertyValue = StorageGet(storage, storageKey);\n return;\n }\n }\n propertyValue = value;\n // check if the value is set\n if (propertyValue === undefined) {\n // check if the value is set in the storage\n if (StorageHas(storage, storageKey)) {\n // remove any value from the storage\n StorageRemove(storage, storageKey);\n }\n } else {\n // set the value in the storage\n StorageSet(storage, storageKey, value, expiredAt, expiredUnit);\n }\n },\n enumerable: true,\n configurable: true,\n });\n };\n}\n","import {\n ExpiredUnit,\n isBrowser,\n} from '../storage-utility';\nimport { WebStorage } from './web-storage';\n\n/**\n * `localStorage` Decorator\n *\n * @param [key] Storage key\n * @param [expiredAt=0] Expiration time, 0 means forever\n * @param [expiredUnit='t'] Expiration time unit (default: custom [unit: ms])\n */\nexport function LocalStorage(\n key?: string,\n expiredAt = 0,\n expiredUnit: ExpiredUnit = 't',\n) {\n return WebStorage(isBrowser ? localStorage : null, key, expiredAt, expiredUnit);\n}\n","import {\n ExpiredUnit,\n isBrowser,\n} from '../storage-utility';\nimport { WebStorage } from './web-storage';\n\n/**\n * `sessionStorage` Decorator\n *\n * @param [key] Storage key\n * @param [expiredAt=0] Expiration time, 0 means forever\n * @param [expiredUnit='t'] Expiration time unit (default: custom [unit: ms])\n */\nexport function SessionStorage(\n key?: string,\n expiredAt = 0,\n expiredUnit: ExpiredUnit = 't',\n) {\n return WebStorage(isBrowser ? sessionStorage : null, key, expiredAt, expiredUnit);\n}\n","import { Injectable } from '@angular/core';\nimport {\n ExpiredUnit,\n StorageGet,\n StorageHas,\n StorageKey,\n StorageRemove,\n StorageSet,\n} from './storage-utility';\n\n@Injectable()\nexport abstract class StorageService {\n protected constructor(private storage: Storage | null) {}\n\n has(key: string): boolean {\n return StorageHas(this.storage, key);\n }\n\n get(key: string): any {\n return StorageGet(this.storage, key);\n }\n\n set(key: string, value: any, expiredAt = 0, expiredUnit: ExpiredUnit = 'd'): void {\n return StorageSet(this.storage, key, value, expiredAt, expiredUnit);\n }\n\n /**\n * Removes the specified key, e.g.:\n * - `remove('key')` Remove `key` key\n * - `remove(/BMap_\\w+/)` Bulk delete all keys starting with BMap_\n * @param key key name or regular expression\n */\n remove(key: string | RegExp): void {\n if (typeof key === 'string') {\n StorageRemove(this.storage, key);\n return;\n }\n let index = 0;\n let next = StorageKey(this.storage, index);\n const ls: string[] = [];\n while (next) {\n if (key.test(next)) {\n ls.push(next);\n }\n next = StorageKey(this.storage, ++index);\n }\n ls.forEach((v) => StorageRemove(this.storage, v));\n }\n\n clear(): void {\n this.storage?.clear();\n }\n}\n\n","import { Injectable } from '@angular/core';\nimport { MockStorage } from './storage-utility';\nimport { StorageService } from './storage.service';\n\n@Injectable({ providedIn: 'root' })\nexport class EphemeralStorageService extends StorageService {\n\n constructor() {\n super(new MockStorage());\n }\n\n}\n","import { Injectable } from '@angular/core';\nimport { isBrowser } from './storage-utility';\nimport { StorageService } from './storage.service';\n\n@Injectable({ providedIn: 'root' })\nexport class LocalStorageService extends StorageService {\n constructor() {\n super(isBrowser ? localStorage : null);\n }\n}\n","import { Injectable } from '@angular/core';\nimport { isBrowser } from './storage-utility';\nimport { StorageService } from './storage.service';\n\n@Injectable({ providedIn: 'root' })\nexport class SessionStorageService extends StorageService {\n constructor() {\n super(isBrowser ? sessionStorage : null);\n }\n}\n","// region decorators\nexport * from './lib/decorators/local-storage';\nexport * from './lib/decorators/session-storage';\nexport * from './lib/decorators/web-storage';\n// endregion\n\n// region \nexport * from './lib/ephemeral-storage.service';\nexport * from './lib/local-storage.service';\nexport * from './lib/session-storage.service';\nexport * from './lib/storage-utility';\nexport * from './lib/storage.service';\n// endregion\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AAYA;;;;AAIG;AACI,MAAM,SAAS,GAAG,OAAO,QAAQ,KAAK,QAAQ,IAAI,CAAC,CAAC;AAErD,SAAU,UAAU,CAAC,OAAuB,EAAE,GAAW,EAAA;AAC7D,IAAA,IAAI,OAAO,KAAK,IAAI,EAAE;AACpB,QAAA,OAAO,IAAI;IACb;AACA,IAAA,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,IAAI,IAAI;AAC3D,IAAA,IAAI,KAAK,KAAK,IAAI,EAAE;AAClB,QAAA,OAAO,IAAI;IACb;IACA,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,QAAQ,KAAK,WAAW,IAAI,KAAK,CAAC,QAAQ,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE;QACzG,KAAK,CAAC,QAAQ,EAAE;AAClB,QAAA,aAAa,CAAC,OAAO,EAAE,GAAG,CAAC;AAC3B,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,OAAO,KAAK,CAAC,MAAM,IAAI,IAAI;AAC7B;AAEM,SAAU,UAAU,CAAC,OAAuB,EAAE,GAAW,EAAA;AAC7D,IAAA,IAAI,OAAO,KAAK,IAAI,EAAE;AACpB,QAAA,OAAO,KAAK;IACd;IACA,OAAO,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI;AACtC;AAEM,SAAU,UAAU,CACxB,OAAuB,EAAE,GAAW,EAAE,KAAU,EAAE,SAAS,GAAG,CAAC,EAAE,cAA2B,GAAG,EAAA;AAC/F,IAAA,IAAI,OAAO,KAAK,IAAI,EAAE;QACpB;IACF;AACA,IAAA,OAAO,CAAC,OAAO,CACb,GAAG,EACH,SAAS,CAAC;AACR,QAAA,QAAQ,EAAE,UAAU,CAAC,SAAS,EAAE,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AAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,mBAAmB,cADN,MAAM,EAAA,CAAA,CAAA;;2FACnB,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAD/B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;ACC5B,MAAO,qBAAsB,SAAQ,cAAc,CAAA;AACvD,IAAA,WAAA,GAAA;QACE,KAAK,CAAC,SAAS,GAAG,cAAc,GAAG,IAAI,CAAC;IAC1C;8GAHW,qBAAqB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAArB,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qBAAqB,cADR,MAAM,EAAA,CAAA,CAAA;;2FACnB,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBADjC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;ACJlC;AAYA;;ACZA;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
- "version": "19.1.0",
2
+ "version": "21.0.1-dev.1",
3
3
  "name": "@rxap/ngx-memory",
4
4
  "description": "This package provides Angular services and decorators for interacting with web storage (localStorage and sessionStorage) and in-memory storage. It offers a simple way to manage data persistence with expiration options and provides decorators for binding class properties directly to storage values. The package includes services for local storage, session storage, and ephemeral (in-memory) storage.\n",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "dependencies": {
7
- "@nx/devkit": "20.5.0",
7
+ "@nx/devkit": "22.7.5",
8
8
  "tslib": "2.6.2"
9
9
  },
10
10
  "peerDependencies": {
11
- "@angular/core": "^19.2.1"
11
+ "@angular/core": "^21.2.9"
12
12
  },
13
13
  "author": {
14
14
  "name": "Merzough Münker",
@@ -31,9 +31,13 @@
31
31
  ],
32
32
  "nx-migrations": {
33
33
  "packageGroup": [
34
+ {
35
+ "package": "@angular/compiler",
36
+ "version": "21.2.9"
37
+ },
34
38
  {
35
39
  "package": "@angular/core",
36
- "version": "19.2.16"
40
+ "version": "21.2.9"
37
41
  }
38
42
  ]
39
43
  },
@@ -49,15 +53,16 @@
49
53
  "schematics": "./generators.json",
50
54
  "sideEffects": false,
51
55
  "module": "fesm2022/rxap-ngx-memory.mjs",
52
- "typings": "index.d.ts",
56
+ "typings": "types/rxap-ngx-memory.d.ts",
53
57
  "exports": {
54
58
  "./package.json": {
55
59
  "default": "./package.json"
56
60
  },
57
61
  ".": {
58
- "types": "./index.d.ts",
62
+ "types": "./types/rxap-ngx-memory.d.ts",
59
63
  "default": "./fesm2022/rxap-ngx-memory.mjs"
60
64
  },
61
65
  "./theme": "./theme.css"
62
- }
66
+ },
67
+ "type": "module"
63
68
  }
@@ -0,0 +1,101 @@
1
+ import * as i0 from '@angular/core';
2
+
3
+ /**
4
+ * Expiration time unit
5
+ * s: seconds
6
+ * m: minute
7
+ * h: hour
8
+ * d: day
9
+ * w: week
10
+ * y: year
11
+ * t: Custom (millisecond)
12
+ */
13
+ type ExpiredUnit = 's' | 'm' | 'h' | 'd' | 'w' | 'y' | 't';
14
+ /**
15
+ * Determining if an Angular application is rendered in the browser
16
+ * The Angular `PLATFORM_ID` identifier cannot be used directly by the `decorator`.
17
+ * The advantage of this is that it also works well when the server populates the Document itself.
18
+ */
19
+ declare const isBrowser: boolean;
20
+ declare function StorageGet(storage: Storage | null, key: string): unknown;
21
+ declare function StorageHas(storage: Storage | null, key: string): boolean;
22
+ declare function StorageSet(storage: Storage | null, key: string, value: any, expiredAt?: number, expiredUnit?: ExpiredUnit): void;
23
+ declare function StorageRemove(storage: Storage | null, key: string): void;
24
+ declare function StorageKey(storage: Storage | null, index: number): string | null;
25
+ declare function getExpired(val: number, unit: ExpiredUnit): number;
26
+ declare function stringify(value: any): string;
27
+ declare class MockStorage implements Storage {
28
+ cache: Record<string, string>;
29
+ get length(): number;
30
+ getItem(key: string): string | null;
31
+ key(index: number): string | null;
32
+ removeItem(key: string): void;
33
+ setItem(key: string, value: string): void;
34
+ clear(): void;
35
+ }
36
+
37
+ /**
38
+ * `localStorage` Decorator
39
+ *
40
+ * @param [key] Storage key
41
+ * @param [expiredAt=0] Expiration time, 0 means forever
42
+ * @param [expiredUnit='t'] Expiration time unit (default: custom [unit: ms])
43
+ */
44
+ declare function LocalStorage(key?: string, expiredAt?: number, expiredUnit?: ExpiredUnit): (target: any, propertyName: string) => void;
45
+
46
+ /**
47
+ * `sessionStorage` Decorator
48
+ *
49
+ * @param [key] Storage key
50
+ * @param [expiredAt=0] Expiration time, 0 means forever
51
+ * @param [expiredUnit='t'] Expiration time unit (default: custom [unit: ms])
52
+ */
53
+ declare function SessionStorage(key?: string, expiredAt?: number, expiredUnit?: ExpiredUnit): (target: any, propertyName: string) => void;
54
+
55
+ /**
56
+ * @internal
57
+ * @param storage
58
+ * @param key
59
+ * @param expiredAt
60
+ * @param expiredUnit
61
+ */
62
+ declare function WebStorage(storage: Storage | null, key?: string, expiredAt?: number, expiredUnit?: ExpiredUnit): (target: any, propertyName: string) => void;
63
+
64
+ declare abstract class StorageService {
65
+ private storage;
66
+ protected constructor(storage: Storage | null);
67
+ has(key: string): boolean;
68
+ get(key: string): any;
69
+ set(key: string, value: any, expiredAt?: number, expiredUnit?: ExpiredUnit): void;
70
+ /**
71
+ * Removes the specified key, e.g.:
72
+ * - `remove('key')` Remove `key` key
73
+ * - `remove(/BMap_\w+/)` Bulk delete all keys starting with BMap_
74
+ * @param key key name or regular expression
75
+ */
76
+ remove(key: string | RegExp): void;
77
+ clear(): void;
78
+ static ɵfac: i0.ɵɵFactoryDeclaration<StorageService, never>;
79
+ static ɵprov: i0.ɵɵInjectableDeclaration<StorageService>;
80
+ }
81
+
82
+ declare class EphemeralStorageService extends StorageService {
83
+ constructor();
84
+ static ɵfac: i0.ɵɵFactoryDeclaration<EphemeralStorageService, never>;
85
+ static ɵprov: i0.ɵɵInjectableDeclaration<EphemeralStorageService>;
86
+ }
87
+
88
+ declare class LocalStorageService extends StorageService {
89
+ constructor();
90
+ static ɵfac: i0.ɵɵFactoryDeclaration<LocalStorageService, never>;
91
+ static ɵprov: i0.ɵɵInjectableDeclaration<LocalStorageService>;
92
+ }
93
+
94
+ declare class SessionStorageService extends StorageService {
95
+ constructor();
96
+ static ɵfac: i0.ɵɵFactoryDeclaration<SessionStorageService, never>;
97
+ static ɵprov: i0.ɵɵInjectableDeclaration<SessionStorageService>;
98
+ }
99
+
100
+ export { EphemeralStorageService, LocalStorage, LocalStorageService, MockStorage, SessionStorage, SessionStorageService, StorageGet, StorageHas, StorageKey, StorageRemove, StorageService, StorageSet, WebStorage, getExpired, isBrowser, stringify };
101
+ export type { ExpiredUnit };
package/index.d.ts DELETED
@@ -1,8 +0,0 @@
1
- export * from './lib/decorators/local-storage';
2
- export * from './lib/decorators/session-storage';
3
- export * from './lib/decorators/web-storage';
4
- export * from './lib/ephemeral-storage.service';
5
- export * from './lib/local-storage.service';
6
- export * from './lib/session-storage.service';
7
- export * from './lib/storage-utility';
8
- export * from './lib/storage.service';
@@ -1,9 +0,0 @@
1
- import { ExpiredUnit } from '../storage-utility';
2
- /**
3
- * `localStorage` Decorator
4
- *
5
- * @param [key] Storage key
6
- * @param [expiredAt=0] Expiration time, 0 means forever
7
- * @param [expiredUnit='t'] Expiration time unit (default: custom [unit: ms])
8
- */
9
- export declare function LocalStorage(key?: string, expiredAt?: number, expiredUnit?: ExpiredUnit): (target: any, propertyName: string) => void;
@@ -1,9 +0,0 @@
1
- import { ExpiredUnit } from '../storage-utility';
2
- /**
3
- * `sessionStorage` Decorator
4
- *
5
- * @param [key] Storage key
6
- * @param [expiredAt=0] Expiration time, 0 means forever
7
- * @param [expiredUnit='t'] Expiration time unit (default: custom [unit: ms])
8
- */
9
- export declare function SessionStorage(key?: string, expiredAt?: number, expiredUnit?: ExpiredUnit): (target: any, propertyName: string) => void;
@@ -1,9 +0,0 @@
1
- import { ExpiredUnit } from '../storage-utility';
2
- /**
3
- * @internal
4
- * @param storage
5
- * @param key
6
- * @param expiredAt
7
- * @param expiredUnit
8
- */
9
- export declare function WebStorage(storage: Storage | null, key?: string, expiredAt?: number, expiredUnit?: ExpiredUnit): (target: any, propertyName: string) => void;
@@ -1,7 +0,0 @@
1
- import { StorageService } from './storage.service';
2
- import * as i0 from "@angular/core";
3
- export declare class EphemeralStorageService extends StorageService {
4
- constructor();
5
- static ɵfac: i0.ɵɵFactoryDeclaration<EphemeralStorageService, never>;
6
- static ɵprov: i0.ɵɵInjectableDeclaration<EphemeralStorageService>;
7
- }
@@ -1,7 +0,0 @@
1
- import { StorageService } from './storage.service';
2
- import * as i0 from "@angular/core";
3
- export declare class LocalStorageService extends StorageService {
4
- constructor();
5
- static ɵfac: i0.ɵɵFactoryDeclaration<LocalStorageService, never>;
6
- static ɵprov: i0.ɵɵInjectableDeclaration<LocalStorageService>;
7
- }
@@ -1,7 +0,0 @@
1
- import { StorageService } from './storage.service';
2
- import * as i0 from "@angular/core";
3
- export declare class SessionStorageService extends StorageService {
4
- constructor();
5
- static ɵfac: i0.ɵɵFactoryDeclaration<SessionStorageService, never>;
6
- static ɵprov: i0.ɵɵInjectableDeclaration<SessionStorageService>;
7
- }
@@ -1,33 +0,0 @@
1
- /**
2
- * Expiration time unit
3
- * s: seconds
4
- * m: minute
5
- * h: hour
6
- * d: day
7
- * w: week
8
- * y: year
9
- * t: Custom (millisecond)
10
- */
11
- export type ExpiredUnit = 's' | 'm' | 'h' | 'd' | 'w' | 'y' | 't';
12
- /**
13
- * Determining if an Angular application is rendered in the browser
14
- * The Angular `PLATFORM_ID` identifier cannot be used directly by the `decorator`.
15
- * The advantage of this is that it also works well when the server populates the Document itself.
16
- */
17
- export declare const isBrowser: boolean;
18
- export declare function StorageGet(storage: Storage | null, key: string): unknown;
19
- export declare function StorageHas(storage: Storage | null, key: string): boolean;
20
- export declare function StorageSet(storage: Storage | null, key: string, value: any, expiredAt?: number, expiredUnit?: ExpiredUnit): void;
21
- export declare function StorageRemove(storage: Storage | null, key: string): void;
22
- export declare function StorageKey(storage: Storage | null, index: number): string | null;
23
- export declare function getExpired(val: number, unit: ExpiredUnit): number;
24
- export declare function stringify(value: any): string;
25
- export declare class MockStorage implements Storage {
26
- cache: Record<string, string>;
27
- get length(): number;
28
- getItem(key: string): string | null;
29
- key(index: number): string | null;
30
- removeItem(key: string): void;
31
- setItem(key: string, value: string): void;
32
- clear(): void;
33
- }
@@ -1,19 +0,0 @@
1
- import { ExpiredUnit } from './storage-utility';
2
- import * as i0 from "@angular/core";
3
- export declare abstract class StorageService {
4
- private storage;
5
- protected constructor(storage: Storage | null);
6
- has(key: string): boolean;
7
- get(key: string): any;
8
- set(key: string, value: any, expiredAt?: number, expiredUnit?: ExpiredUnit): void;
9
- /**
10
- * Removes the specified key, e.g.:
11
- * - `remove('key')` Remove `key` key
12
- * - `remove(/BMap_\w+/)` Bulk delete all keys starting with BMap_
13
- * @param key key name or regular expression
14
- */
15
- remove(key: string | RegExp): void;
16
- clear(): void;
17
- static ɵfac: i0.ɵɵFactoryDeclaration<StorageService, never>;
18
- static ɵprov: i0.ɵɵInjectableDeclaration<StorageService>;
19
- }