@rxap/ngx-memory 21.0.1-dev.1 → 22.0.0-dev.0

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 (67) 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 +101 -157
  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 -8
  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 -15
  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 -14
  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 +260 -258
  65. package/fesm2022/rxap-ngx-memory.mjs.map +1 -1
  66. package/package.json +5 -5
  67. package/types/rxap-ngx-memory.d.ts +53 -61
@@ -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;AAErD,SAAU,UAAU,CAAC,OAAuB,EAAE,GAAW,EAAA;AAC7D,IAAA,IAAI,OAAO,KAAK,IAAI,EAAE;AACpB,QAAA,OAAO,IAAI;IACb;AACA,IAAA,MAAM,KAAK,GA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,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;;;;"}
1
+ {"version":3,"file":"rxap-ngx-memory.mjs","names":[],"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"],"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"],"mappings":";;AAiBA,MAAa,YAAY,OAAO,aAAa,YAAY,CAAC,CAAC;AAE3D,SAAgB,WAAW,SAAyB,KAAW;CAC7D,IAAI,YAAY,MACd,OAAO;CAET,MAAM,QAAQ,MAAM,QAAQ,QAAQ,GAAG,KAAK,MAAM,KAAK;CACvD,IAAI,UAAU,MACZ,OAAO;CAET,IAAI,OAAO,UAAU,YAAY,OAAO,MAAM,aAAa,eAAe,MAAM,aAAa,KAAK,iBAAC,IAAI,KAAI,IACvG,MAAM,UAAU;EAClB,cAAc,SAAS,GAAG;EAC1B,OAAO;CACT;CAEA,OAAO,MAAM,UAAU;AACzB;AAEA,SAAgB,WAAW,SAAyB,KAAW;CAC7D,IAAI,YAAY,MACd,OAAO;CAET,OAAO,QAAQ,QAAQ,GAAG,MAAM;AAClC;AAEA,SAAgB,WACd,SAAyB,KAAa,OAAY,YAAY,GAAG,cAA2B,KAAG;CAC/F,IAAI,YAAY,MACd;CAEF,QAAQ,QACN,KACA,UAAU;EACR,UAAU,WAAW,WAAW,WAAW;EAC3C,QAAQ;CACT,CAAA,CAAC;AAEN;AAEA,SAAgB,cAAc,SAAyB,KAAW;CAChE,IAAI,YAAY,MACd;CAEF,QAAQ,WAAW,GAAG;AACxB;AAEA,SAAgB,WAAW,SAAyB,OAAa;CAC/D,IAAI,YAAY,MACd,OAAO;CAET,OAAO,QAAQ,IAAI,KAAK;AAC1B;AAEA,SAAgB,WAAW,KAAa,MAAiB;CACvD,IAAI,OAAO,GACT,OAAO;CAET,MAAM,MAAM,iBAAC,IAAI,KAAI;CACrB,QAAQ,MAAR;EACE,KAAK,KACH,OAAO,MAAM,MAAO;EACtB,KAAK,KACH,OAAO,MAAM,MAAY;EAC3B,KAAK,KACH,OAAO,MAAM,OAAiB;EAChC,KAAK,KACH,OAAO,MAAM,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,CAAE;;;;ACClC,IAAa,wBAAb,MAAa,8BAA8B,eAAc;CACvD,cAAA;EACE,MAAM,YAAY,iBAAiB,IAAI;CACzC;CAHW;EAAA,KAAA,OAAA,GAAA,mBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAqB,MAAA,CAAA;GAAA,QAAA,GAAA,gBAAA;EAAA,CAAA;CAAA;CAArB;EAAA,KAAA,QAAA,GAAA,sBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAqB,YADR;EAAM,CAAA;CAAA;;AACnB,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAqB,YAAA,CAAA;EADjC,MAAA;EAAW,MAAA,CAAA,EAAE,YAAY,OAAM,CAAE"}
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
- "version": "21.0.1-dev.1",
2
+ "version": "22.0.0-dev.0",
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": "22.7.5",
7
+ "@nx/devkit": "24.0.6",
8
8
  "tslib": "2.6.2"
9
9
  },
10
10
  "peerDependencies": {
11
- "@angular/core": "^21.2.9"
11
+ "@angular/core": "^22.3.0"
12
12
  },
13
13
  "author": {
14
14
  "name": "Merzough Münker",
@@ -33,11 +33,11 @@
33
33
  "packageGroup": [
34
34
  {
35
35
  "package": "@angular/compiler",
36
- "version": "21.2.9"
36
+ "version": "22.3.0"
37
37
  },
38
38
  {
39
39
  "package": "@angular/core",
40
- "version": "21.2.9"
40
+ "version": "22.3.0"
41
41
  }
42
42
  ]
43
43
  },
@@ -1,5 +1,7 @@
1
- import * as i0 from '@angular/core';
2
-
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ import * as i0 from "@angular/core";
3
5
  /**
4
6
  * Expiration time unit
5
7
  * s: seconds
@@ -10,30 +12,29 @@ import * as i0 from '@angular/core';
10
12
  * y: year
11
13
  * t: Custom (millisecond)
12
14
  */
13
- type ExpiredUnit = 's' | 'm' | 'h' | 'd' | 'w' | 'y' | 't';
15
+ export type ExpiredUnit = 's' | 'm' | 'h' | 'd' | 'w' | 'y' | 't';
14
16
  /**
15
17
  * Determining if an Angular application is rendered in the browser
16
18
  * The Angular `PLATFORM_ID` identifier cannot be used directly by the `decorator`.
17
19
  * The advantage of this is that it also works well when the server populates the Document itself.
18
20
  */
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;
21
+ export declare const isBrowser: boolean;
22
+ export declare function StorageGet(storage: Storage | null, key: string): unknown;
23
+ export declare function StorageHas(storage: Storage | null, key: string): boolean;
24
+ export declare function StorageSet(storage: Storage | null, key: string, value: any, expiredAt?: number, expiredUnit?: ExpiredUnit): void;
25
+ export declare function StorageRemove(storage: Storage | null, key: string): void;
26
+ export declare function StorageKey(storage: Storage | null, index: number): string | null;
27
+ export declare function getExpired(val: number, unit: ExpiredUnit): number;
28
+ export declare function stringify(value: any): string;
29
+ export declare class MockStorage implements Storage {
30
+ cache: Record<string, string>;
31
+ get length(): number;
32
+ getItem(key: string): string | null;
33
+ key(index: number): string | null;
34
+ removeItem(key: string): void;
35
+ setItem(key: string, value: string): void;
36
+ clear(): void;
35
37
  }
36
-
37
38
  /**
38
39
  * `localStorage` Decorator
39
40
  *
@@ -41,8 +42,7 @@ declare class MockStorage implements Storage {
41
42
  * @param [expiredAt=0] Expiration time, 0 means forever
42
43
  * @param [expiredUnit='t'] Expiration time unit (default: custom [unit: ms])
43
44
  */
44
- declare function LocalStorage(key?: string, expiredAt?: number, expiredUnit?: ExpiredUnit): (target: any, propertyName: string) => void;
45
-
45
+ export declare function LocalStorage(key?: string, expiredAt?: number, expiredUnit?: ExpiredUnit): (target: any, propertyName: string) => void;
46
46
  /**
47
47
  * `sessionStorage` Decorator
48
48
  *
@@ -50,8 +50,7 @@ declare function LocalStorage(key?: string, expiredAt?: number, expiredUnit?: Ex
50
50
  * @param [expiredAt=0] Expiration time, 0 means forever
51
51
  * @param [expiredUnit='t'] Expiration time unit (default: custom [unit: ms])
52
52
  */
53
- declare function SessionStorage(key?: string, expiredAt?: number, expiredUnit?: ExpiredUnit): (target: any, propertyName: string) => void;
54
-
53
+ export declare function SessionStorage(key?: string, expiredAt?: number, expiredUnit?: ExpiredUnit): (target: any, propertyName: string) => void;
55
54
  /**
56
55
  * @internal
57
56
  * @param storage
@@ -59,43 +58,36 @@ declare function SessionStorage(key?: string, expiredAt?: number, expiredUnit?:
59
58
  * @param expiredAt
60
59
  * @param expiredUnit
61
60
  */
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>;
61
+ export declare function WebStorage(storage: Storage | null, key?: string, expiredAt?: number, expiredUnit?: ExpiredUnit): (target: any, propertyName: string) => void;
62
+ export declare abstract class StorageService {
63
+ private storage;
64
+ protected constructor(storage: Storage | null);
65
+ has(key: string): boolean;
66
+ get(key: string): any;
67
+ set(key: string, value: any, expiredAt?: number, expiredUnit?: ExpiredUnit): void;
68
+ /**
69
+ * Removes the specified key, e.g.:
70
+ * - `remove('key')` Remove `key` key
71
+ * - `remove(/BMap_\w+/)` Bulk delete all keys starting with BMap_
72
+ * @param key key name or regular expression
73
+ */
74
+ remove(key: string | RegExp): void;
75
+ clear(): void;
76
+ static ɵfac: i0.ɵɵFactoryDeclaration<StorageService, never>;
77
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
86
78
  }
87
-
88
- declare class LocalStorageService extends StorageService {
89
- constructor();
90
- static ɵfac: i0.ɵɵFactoryDeclaration<LocalStorageService, never>;
91
- static ɵprov: i0.ɵɵInjectableDeclaration<LocalStorageService>;
79
+ export declare class EphemeralStorageService extends StorageService {
80
+ constructor();
81
+ static ɵfac: i0.ɵɵFactoryDeclaration<EphemeralStorageService, never>;
82
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
92
83
  }
93
-
94
- declare class SessionStorageService extends StorageService {
95
- constructor();
96
- static ɵfac: i0.ɵɵFactoryDeclaration<SessionStorageService, never>;
97
- static ɵprov: i0.ɵɵInjectableDeclaration<SessionStorageService>;
84
+ export declare class LocalStorageService extends StorageService {
85
+ constructor();
86
+ static ɵfac: i0.ɵɵFactoryDeclaration<LocalStorageService, never>;
87
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
98
88
  }
99
-
100
- export { EphemeralStorageService, LocalStorage, LocalStorageService, MockStorage, SessionStorage, SessionStorageService, StorageGet, StorageHas, StorageKey, StorageRemove, StorageService, StorageSet, WebStorage, getExpired, isBrowser, stringify };
101
- export type { ExpiredUnit };
89
+ export declare class SessionStorageService extends StorageService {
90
+ constructor();
91
+ static ɵfac: i0.ɵɵFactoryDeclaration<SessionStorageService, never>;
92
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
93
+ }