@rt-tools/core 0.0.1 → 0.0.3

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.
@@ -1,8 +1,8 @@
1
- import { Subject } from 'rxjs';
1
+ import { Subject, Observable } from 'rxjs';
2
2
  import { filter, map } from 'rxjs/operators';
3
3
  import { isPlatformBrowser, DOCUMENT } from '@angular/common';
4
4
  import * as i0 from '@angular/core';
5
- import { inject, PLATFORM_ID, Injectable, InjectionToken } from '@angular/core';
5
+ import { inject, PLATFORM_ID, Injectable, InjectionToken, Input, Attribute, Optional, Directive, Pipe } from '@angular/core';
6
6
 
7
7
  function isNil(entity) {
8
8
  return entity === null || entity === undefined;
@@ -49,11 +49,636 @@ const WINDOW = new InjectionToken('An injection token for global window object',
49
49
  },
50
50
  });
51
51
 
52
+ const BEM_MODULE_CONFIG = {
53
+ separators: {
54
+ el: '__',
55
+ mod: '--',
56
+ val: '--',
57
+ },
58
+ ignoreValues: false,
59
+ modCase: 'kebab',
60
+ };
61
+
62
+ function modNameHandler(str) {
63
+ switch (BEM_MODULE_CONFIG.modCase) {
64
+ case 'kebab':
65
+ return str
66
+ ? str
67
+ .replace(/[A-Z]/g, function (s) {
68
+ return '-' + s.toLowerCase();
69
+ })
70
+ .replace(/$-/, '')
71
+ : '';
72
+ case 'snake':
73
+ return str
74
+ ? str
75
+ .replace(/[A-Z]/g, function (s) {
76
+ return '_' + s.toLowerCase();
77
+ })
78
+ .replace(/$-/, '')
79
+ : '';
80
+ default:
81
+ return str;
82
+ }
83
+ }
84
+ function generateClass(blockName, elemName, modName, modValue) {
85
+ if (BEM_MODULE_CONFIG.ignoreValues) {
86
+ modValue = !!modValue;
87
+ }
88
+ if (typeof modValue !== 'string' && typeof modValue !== 'boolean') {
89
+ modValue = !!modValue;
90
+ }
91
+ let cls = blockName;
92
+ if (elemName) {
93
+ cls += BEM_MODULE_CONFIG.separators.el + elemName;
94
+ }
95
+ if (modName) {
96
+ modName = modNameHandler(modName);
97
+ cls += BEM_MODULE_CONFIG.separators.mod + modName;
98
+ if (typeof modValue !== 'boolean' && modValue != null) {
99
+ cls += BEM_MODULE_CONFIG.separators.val + modValue;
100
+ }
101
+ }
102
+ return cls;
103
+ }
104
+ function parseMods(mods) {
105
+ if (typeof mods === 'string') {
106
+ mods = mods.split(/\s+/);
107
+ }
108
+ if (Array.isArray(mods)) {
109
+ const modsObj = {};
110
+ mods.forEach((key) => {
111
+ if (key) {
112
+ modsObj[key] = true;
113
+ }
114
+ });
115
+ mods = modsObj;
116
+ }
117
+ else if (typeof mods !== 'object') {
118
+ return {};
119
+ }
120
+ return mods;
121
+ }
122
+ function setMods(blockName, elemName, mods, oldMods, element, renderer) {
123
+ Object.keys(mods).forEach((key) => {
124
+ if (oldMods[key]) {
125
+ if (mods[key] === oldMods[key]) {
126
+ return;
127
+ }
128
+ renderer.removeClass(element.nativeElement, generateClass(blockName, elemName, key, oldMods[key]));
129
+ }
130
+ if (mods[key]) {
131
+ renderer.addClass(element.nativeElement, generateClass(blockName, elemName, key, mods[key]));
132
+ }
133
+ });
134
+ Object.keys(oldMods).forEach((key) => {
135
+ if (!(key in mods) && oldMods[key]) {
136
+ renderer.removeClass(element.nativeElement, generateClass(blockName, elemName, key, oldMods[key]));
137
+ }
138
+ });
139
+ }
140
+
141
+ class BlockDirective {
142
+ #mods = {};
143
+ #modSerialized = '';
144
+ constructor(element, renderer, name, elem) {
145
+ this.element = element;
146
+ this.renderer = renderer;
147
+ this.name = name;
148
+ this.elem = elem;
149
+ if (!elem && !(element.nativeElement instanceof Comment)) {
150
+ renderer.addClass(element.nativeElement, generateClass(name));
151
+ }
152
+ }
153
+ ngOnChanges() {
154
+ if (JSON.stringify(this.rtMod) !== this.#modSerialized && !this.elem) {
155
+ this.#modSerialized = JSON.stringify(this.rtMod);
156
+ let mods = this.rtMod;
157
+ const { renderer, element, name } = this;
158
+ mods = parseMods(mods);
159
+ if (!(element.nativeElement instanceof Comment)) {
160
+ setMods(name, '', mods, this.#mods || {}, element, renderer);
161
+ }
162
+ this.#mods = this.#mods === mods ? Object.assign({}, mods) : mods;
163
+ }
164
+ }
165
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.1", ngImport: i0, type: BlockDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: 'rtBlock', attribute: true }, { token: 'rtElem', attribute: true, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
166
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.0.1", type: BlockDirective, isStandalone: true, selector: "[rtBlock]", inputs: { rtMod: "rtMod" }, usesOnChanges: true, ngImport: i0 }); }
167
+ }
168
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.1", ngImport: i0, type: BlockDirective, decorators: [{
169
+ type: Directive,
170
+ args: [{
171
+ selector: '[rtBlock]',
172
+ }]
173
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: undefined, decorators: [{
174
+ type: Attribute,
175
+ args: ['rtBlock']
176
+ }] }, { type: undefined, decorators: [{
177
+ type: Optional
178
+ }, {
179
+ type: Attribute,
180
+ args: ['rtElem']
181
+ }] }], propDecorators: { rtMod: [{
182
+ type: Input
183
+ }] } });
184
+
185
+ class ConcatClassesPipe {
186
+ transform(classes) {
187
+ // eslint-disable-next-line
188
+ const validClassList = classes.flat().filter((className) => typeof className === 'string' && !!className.trim());
189
+ return validClassList.join(' ');
190
+ }
191
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.1", ngImport: i0, type: ConcatClassesPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
192
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.0.1", ngImport: i0, type: ConcatClassesPipe, isStandalone: true, name: "concatClasses" }); }
193
+ }
194
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.1", ngImport: i0, type: ConcatClassesPipe, decorators: [{
195
+ type: Pipe,
196
+ args: [{
197
+ name: 'concatClasses',
198
+ }]
199
+ }] });
200
+
201
+ class ElemDirective {
202
+ #mods = {};
203
+ #modSerialized = '';
204
+ constructor(element, renderer, name, rtBlock) {
205
+ this.element = element;
206
+ this.renderer = renderer;
207
+ this.name = name;
208
+ this.rtBlock = rtBlock;
209
+ this.blockName = rtBlock.name;
210
+ renderer.addClass(element.nativeElement, generateClass(rtBlock.name, name));
211
+ }
212
+ ngOnChanges() {
213
+ if (JSON.stringify(this.rtMod) !== this.#modSerialized) {
214
+ this.#modSerialized = JSON.stringify(this.rtMod);
215
+ let mods = this.rtMod;
216
+ const { renderer, element, blockName, name } = this;
217
+ mods = parseMods(mods);
218
+ setMods(blockName, name, mods, this.#mods || {}, element, renderer);
219
+ this.#mods = this.#mods === mods ? Object.assign({}, mods) : mods;
220
+ }
221
+ }
222
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.1", ngImport: i0, type: ElemDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: 'rtElem', attribute: true }, { token: BlockDirective }], target: i0.ɵɵFactoryTarget.Directive }); }
223
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.0.1", type: ElemDirective, isStandalone: true, selector: "[rtElem]", inputs: { rtMod: "rtMod" }, usesOnChanges: true, ngImport: i0 }); }
224
+ }
225
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.1", ngImport: i0, type: ElemDirective, decorators: [{
226
+ type: Directive,
227
+ args: [{
228
+ selector: '[rtElem]',
229
+ }]
230
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: undefined, decorators: [{
231
+ type: Attribute,
232
+ args: ['rtElem']
233
+ }] }, { type: BlockDirective }], propDecorators: { rtMod: [{
234
+ type: Input
235
+ }] } });
236
+
237
+ class ModDirective {
238
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.1", ngImport: i0, type: ModDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
239
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.0.1", type: ModDirective, isStandalone: true, selector: "[rtMod]", ngImport: i0 }); }
240
+ }
241
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.1", ngImport: i0, type: ModDirective, decorators: [{
242
+ type: Directive,
243
+ args: [{
244
+ selector: '[rtMod]',
245
+ }]
246
+ }] });
247
+
248
+ var STORAGE_TYPES_ENUM;
249
+ (function (STORAGE_TYPES_ENUM) {
250
+ STORAGE_TYPES_ENUM["LOCAL"] = "local";
251
+ STORAGE_TYPES_ENUM["SESSION"] = "session";
252
+ STORAGE_TYPES_ENUM["IN_MEMORY"] = "inMemory";
253
+ STORAGE_TYPES_ENUM["CUSTOM"] = "custom";
254
+ })(STORAGE_TYPES_ENUM || (STORAGE_TYPES_ENUM = {}));
255
+
256
+ /**
257
+ * A service that implements the `Storage` interface using an in-memory map.
258
+ * This service provides a fallback storage solution when `localStorage`
259
+ * or `sessionStorage` is not available, such as in server-side rendering (SSR) scenarios.
260
+ *
261
+ * @Injectable
262
+ */
263
+ class InMemoryStorageService {
264
+ /**
265
+ * Private in-memory storage map used to store key-value pairs.
266
+ * The keys are strings, the values are strings.
267
+ * The map is private and cannot be accessed directly.
268
+ * Instead, the public methods of the service should be used to interact with the storage.
269
+ * The map is initialized as an empty map.
270
+ *
271
+ * @type {Map<string, string>}
272
+ * @private
273
+ * @internal
274
+ * @readonly
275
+ */
276
+ #storage = new Map();
277
+ /**
278
+ * Returns the number of key-value pairs currently stored.
279
+ *
280
+ * @returns the number of items in storage
281
+ * @public
282
+ */
283
+ get length() {
284
+ return this.#storage.size;
285
+ }
286
+ /**
287
+ * Retrieves the value associated with the given key.
288
+ *
289
+ * @param key - The name of the key to retrieve the value for
290
+ * @returns the value associated with the key, or `null` if the key does not exist
291
+ * @public
292
+ * @returns string | null
293
+ */
294
+ getItem(key) {
295
+ return this.#storage.get(key) || null;
296
+ }
297
+ /**
298
+ * Adds or updates the key-value pair in the storage.
299
+ *
300
+ * @param key - The name of the key to create or update
301
+ * @param data - The value to associate with the key
302
+ * @public
303
+ * @returns void
304
+ */
305
+ setItem(key, data) {
306
+ this.#storage.set(key, data);
307
+ }
308
+ /**
309
+ * Retrieves the key at the specified index.
310
+ *
311
+ * @param index - The index of the key to retrieve
312
+ * @returns the key at the specified index, or `null` if the index is out of bounds
313
+ * @public
314
+ * @returns string | null
315
+ */
316
+ key(index) {
317
+ return Array.from(this.#storage.keys())[index] || null;
318
+ }
319
+ /**
320
+ * Removes the key-value pair associated with the given key.
321
+ *
322
+ * @param key - The name of the key to remove
323
+ * @public
324
+ * @returns void
325
+ */
326
+ removeItem(key) {
327
+ this.#storage.delete(key);
328
+ }
329
+ /**
330
+ * Clears all key-value pairs from the storage.
331
+ *
332
+ * @public
333
+ * @returns void
334
+ */
335
+ clear() {
336
+ this.#storage.clear();
337
+ }
338
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.1", ngImport: i0, type: InMemoryStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
339
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.1", ngImport: i0, type: InMemoryStorageService }); }
340
+ }
341
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.1", ngImport: i0, type: InMemoryStorageService, decorators: [{
342
+ type: Injectable
343
+ }] });
344
+
345
+ class JsonConverter {
346
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
347
+ convertTo(data) {
348
+ let parsedData;
349
+ try {
350
+ parsedData = JSON.stringify(data);
351
+ }
352
+ catch (e) {
353
+ // eslint-disable-next-line no-console
354
+ console.error(e);
355
+ parsedData = 'null';
356
+ }
357
+ return parsedData;
358
+ }
359
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
360
+ convertFrom(data) {
361
+ if (typeof data === 'string') {
362
+ try {
363
+ return JSON.parse(data);
364
+ }
365
+ catch (e) {
366
+ // eslint-disable-next-line no-console
367
+ console.error(e);
368
+ return null;
369
+ }
370
+ }
371
+ return null;
372
+ }
373
+ }
374
+
375
+ /**
376
+ * Factory for creating or returning `localStorage`.
377
+ * Returns `localStorage` global object if the application is running in a browser,
378
+ * otherwise returns null.
379
+ *
380
+ * @returns localStorage or null
381
+ */
382
+ function localStorageFactory() {
383
+ return inject(PlatformService).isPlatformBrowser ? localStorage : null;
384
+ }
385
+ /**
386
+ * Factory for creating or returning `sessionStorage`.
387
+ * Returns `sessionStorage` global object if the application is running in a browser,
388
+ * otherwise returns null.
389
+ *
390
+ * @returns sessionStorage or null
391
+ */
392
+ function sessionStorageFactory() {
393
+ return inject(PlatformService).isPlatformBrowser ? sessionStorage : null;
394
+ }
395
+ /**
396
+ * Factory for creating `InMemoryStorageService`.
397
+ * Returns a new instance of InMemoryStorageService.
398
+ *
399
+ * @returns a new instance of InMemoryStorageService
400
+ */
401
+ function inMemoryStorageFactory() {
402
+ return new InMemoryStorageService();
403
+ }
404
+
405
+ const CUSTOM_STORAGE = new InjectionToken('CUSTOM_STORAGE');
406
+
407
+ const IN_MEMORY_STORAGE = new InjectionToken('IN_MEMORY_STORAGE');
408
+
409
+ const LOCAL_STORAGE = new InjectionToken('LOCAL_STORAGE');
410
+
411
+ const SESSION_STORAGE = new InjectionToken('SESSION_STORAGE');
412
+
413
+ const defaultStorageConfig = {
414
+ ctx: STORAGE_TYPES_ENUM.LOCAL,
415
+ storageRef: null,
416
+ converter: new JsonConverter(),
417
+ };
418
+ /**
419
+ * A service for managing data storage across different storage types,
420
+ * including `localStorage`, `sessionStorage`, and an in-memory storage fallback.
421
+ * The service supports custom storage types and data conversion through configurable converters.
422
+ *
423
+ * @Injectable
424
+ */
425
+ class StorageService {
426
+ #platformService = inject(PlatformService);
427
+ #localStorageRef = inject(LOCAL_STORAGE);
428
+ #sessionStorageRef = inject(SESSION_STORAGE);
429
+ #inMemoryStorageRef = inject(IN_MEMORY_STORAGE);
430
+ #customStorageRef = inject(CUSTOM_STORAGE, { optional: true });
431
+ /**
432
+ * Retrieves an item from the specified storage context.
433
+ *
434
+ * @param key - The key of the item to retrieve.
435
+ * @param config - Optional configuration for the storage context and data conversion.
436
+ * @returns The retrieved item, converted from storage if a converter is provided, or `null` if the item does not exist.
437
+ */
438
+ getItem(key, config) {
439
+ const fullConfig = { ...defaultStorageConfig, ...config };
440
+ const item = this.#storage(fullConfig.ctx)?.getItem(key);
441
+ return fullConfig.converter?.convertFrom(item) ?? item ?? null;
442
+ }
443
+ /**
444
+ * Stores an item in the specified storage context.
445
+ *
446
+ * @param key - The key to associate with the stored item.
447
+ * @param data - The data to store, which will be converted if a converter is provided.
448
+ * @param config - Optional configuration for the storage context and data conversion.
449
+ */
450
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
451
+ setItem(key, data, config) {
452
+ const fullConfig = { ...defaultStorageConfig, ...config };
453
+ const parsedValue = fullConfig.converter?.convertTo(data) ?? data;
454
+ this.#storage(fullConfig.ctx)?.setItem(key, parsedValue);
455
+ }
456
+ /**
457
+ * Checks if a given key exists in the specified storage context.
458
+ *
459
+ * @param key - The key to check for.
460
+ * @param ctx - The storage context to search in (local, session, or in-memory).
461
+ * @returns `true` if the key exists, `false` otherwise.
462
+ */
463
+ hasKey(key, ctx = defaultStorageConfig.ctx) {
464
+ return Object.prototype.hasOwnProperty.call(this.#storage(ctx), key);
465
+ }
466
+ /**
467
+ * Executes callback functions based on whether a key exists in the specified storage context.
468
+ *
469
+ * @param key - The key to check for.
470
+ * @param onHas - The callback to execute if the key exists.
471
+ * @param onHasNot - The optional callback to execute if the key does not exist.
472
+ * @param config - Optional configuration for the storage context and data conversion.
473
+ */
474
+ onHasKey(key, onHas, onHasNot, config) {
475
+ const fullConfig = { ...defaultStorageConfig, ...config };
476
+ if (this.hasKey(key, fullConfig.ctx)) {
477
+ onHas(this.getItem(key, fullConfig));
478
+ }
479
+ else if (onHasNot !== void 0) {
480
+ onHasNot();
481
+ }
482
+ }
483
+ /**
484
+ * Removes an item from the specified storage context.
485
+ *
486
+ * @param key - The key of the item to remove.
487
+ * @param ctx - The storage context from which to remove the item.
488
+ */
489
+ removeItem(key, ctx = defaultStorageConfig.ctx) {
490
+ this.#storage(ctx)?.removeItem(key);
491
+ }
492
+ /**
493
+ * Clears all items from the specified storage context.
494
+ *
495
+ * @param ctx - The storage context to clear.
496
+ */
497
+ clear(ctx = defaultStorageConfig.ctx) {
498
+ this.#storage(ctx)?.clear();
499
+ }
500
+ /**
501
+ * Returns the appropriate storage reference based on the storage context and platform.
502
+ *
503
+ * @param ctx - The storage context to use (local, session, custom, or in-memory).
504
+ * @returns The corresponding `Storage` object, or `null` if not available.
505
+ */
506
+ #storage(ctx) {
507
+ if (this.#platformService.isPlatformBrowser) {
508
+ switch (ctx) {
509
+ case 'local':
510
+ return this.#localStorageRef;
511
+ case 'session':
512
+ return this.#sessionStorageRef;
513
+ case 'custom':
514
+ return this.#customStorageRef;
515
+ }
516
+ }
517
+ /**
518
+ * Fallback to in-memory storage when the platform is not a browser (e.g., SSR).
519
+ */
520
+ return this.#inMemoryStorageRef;
521
+ }
522
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.1", ngImport: i0, type: StorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
523
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.1", ngImport: i0, type: StorageService }); }
524
+ }
525
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.1", ngImport: i0, type: StorageService, decorators: [{
526
+ type: Injectable
527
+ }] });
528
+
529
+ /**
530
+ * Returns the set of dependency-injection providers
531
+ * required to setup storages in an application.
532
+ *
533
+ * @usageNotes
534
+ *
535
+ * This function sets up the essential storage services needed for
536
+ * working with `localStorage`, `sessionStorage`, and an in-memory storage solution.
537
+ * It includes providers for each type of storage, ensuring that the appropriate
538
+ * storage service is injected based on the platform or specific use case.
539
+ *
540
+ * The function is particularly useful in scenarios where the application may be
541
+ * running on the server-side (SSR). In such cases, instead of using `localStorage`
542
+ * and `sessionStorage`, which are only available in the browser, the `InMemoryStorageService`
543
+ * can be used as a fallback, ensuring that the application still functions correctly.
544
+ *
545
+ * ```typescript
546
+ * bootstrapApplication(RootComponent, {
547
+ * providers: [
548
+ * provideRtStorage()
549
+ * ]
550
+ * });
551
+ * ```
552
+ *
553
+ * @publicApi
554
+ */
555
+ function provideRtStorage() {
556
+ return [
557
+ InMemoryStorageService,
558
+ {
559
+ provide: LOCAL_STORAGE,
560
+ useFactory: localStorageFactory,
561
+ },
562
+ {
563
+ provide: SESSION_STORAGE,
564
+ useFactory: sessionStorageFactory,
565
+ },
566
+ {
567
+ provide: IN_MEMORY_STORAGE,
568
+ useFactory: inMemoryStorageFactory,
569
+ },
570
+ StorageService,
571
+ ];
572
+ }
573
+
574
+ class IDBStorageService {
575
+ #windowRef = inject(WINDOW);
576
+ #context;
577
+ constructor() {
578
+ this.#context = new Observable((observer) => {
579
+ if ('indexedDB' in this.#windowRef && 'open' in this.#windowRef.indexedDB) {
580
+ const openRequest = this.#windowRef.indexedDB.open('use-idb', 1);
581
+ openRequest.onerror = () => observer.error(openRequest.error);
582
+ openRequest.onsuccess = () => observer.next(openRequest.result);
583
+ openRequest.onupgradeneeded = () => openRequest.result.createObjectStore('idb');
584
+ }
585
+ else {
586
+ observer.error('IndexedDB not supported');
587
+ }
588
+ });
589
+ }
590
+ get(key) {
591
+ return new Observable((observer) => {
592
+ this.#context.subscribe((db) => {
593
+ const transaction = db.transaction('idb', 'readonly');
594
+ const store = transaction.objectStore('idb');
595
+ const request = store.get(key);
596
+ request.onsuccess = () => observer.next(request.result);
597
+ request.onerror = () => observer.error(request.error);
598
+ });
599
+ });
600
+ }
601
+ set(key, value) {
602
+ return new Observable((observer) => {
603
+ this.#context.subscribe((db) => {
604
+ const transaction = db.transaction('idb', 'readwrite');
605
+ const store = transaction.objectStore('idb');
606
+ const request = store.put(value, key);
607
+ request.onsuccess = () => observer.next();
608
+ request.onerror = () => observer.error(request.error);
609
+ });
610
+ });
611
+ }
612
+ remove(key) {
613
+ return new Observable((observer) => {
614
+ this.#context.subscribe((db) => {
615
+ const transaction = db.transaction('idb', 'readwrite');
616
+ const store = transaction.objectStore('idb');
617
+ const request = store.delete(key);
618
+ request.onsuccess = () => observer.next();
619
+ request.onerror = () => observer.error(request.error);
620
+ });
621
+ });
622
+ }
623
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.1", ngImport: i0, type: IDBStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
624
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.1", ngImport: i0, type: IDBStorageService }); }
625
+ }
626
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.1", ngImport: i0, type: IDBStorageService, decorators: [{
627
+ type: Injectable
628
+ }], ctorParameters: () => [] });
629
+
630
+ /**
631
+ * Factory for creating `IDBStorageService`.
632
+ * Returns a new instance of IDBStorageService.
633
+ *
634
+ * @returns a new instance of IDBStorageService
635
+ */
636
+ function iDBStorageFactory() {
637
+ return new IDBStorageService();
638
+ }
639
+
640
+ /**
641
+ * Injection token for IDBStorageService.
642
+ */
643
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
644
+ const IDB_STORAGE_SERVICE_TOKEN = new InjectionToken('IDB_STORAGE_SERVICE_TOKEN');
645
+
646
+ /**
647
+ * Returns the set of dependency-injection providers
648
+ * required to set up storages in an application.
649
+ *
650
+ * @usageNotes
651
+ *
652
+ * This function sets up the essential storage services needed for
653
+ * working with `idb storage` solution.
654
+ * It includes providers for each type of storage, ensuring that the appropriate
655
+ * storage service is injected based on the platform or specific use case.
656
+ *
657
+ * ```typescript
658
+ * bootstrapApplication(RootComponent, {
659
+ * providers: [
660
+ * provideRtIDBStorage()
661
+ * ]
662
+ * });
663
+ * ```
664
+ *
665
+ * @publicApi
666
+ */
667
+ function provideRtIDBStorage() {
668
+ return [
669
+ {
670
+ provide: IDB_STORAGE_SERVICE_TOKEN,
671
+ useFactory: iDBStorageFactory,
672
+ },
673
+ IDBStorageService,
674
+ ];
675
+ }
676
+
52
677
  // functions
53
678
 
54
679
  /**
55
680
  * Generated bundle index. Do not edit.
56
681
  */
57
682
 
58
- export { MessageBus, PlatformService, WINDOW, isNil };
683
+ export { BlockDirective, CUSTOM_STORAGE, ConcatClassesPipe, ElemDirective, IDBStorageService, IDB_STORAGE_SERVICE_TOKEN, IN_MEMORY_STORAGE, InMemoryStorageService, JsonConverter, LOCAL_STORAGE, MessageBus, ModDirective, PlatformService, SESSION_STORAGE, STORAGE_TYPES_ENUM, StorageService, WINDOW, iDBStorageFactory, inMemoryStorageFactory, isNil, localStorageFactory, provideRtIDBStorage, provideRtStorage, sessionStorageFactory };
59
684
  //# sourceMappingURL=rt-tools-core.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"rt-tools-core.mjs","sources":["../../../projects/core/src/lib/functions/is-nil.ts","../../../projects/core/src/lib/services/message-bus.ts","../../../projects/core/src/lib/services/platform.service.ts","../../../projects/core/src/lib/tokens/window.token.ts","../../../projects/core/src/index.ts","../../../projects/core/src/rt-tools-core.ts"],"sourcesContent":["export function isNil<T>(entity: T | null | undefined): entity is null | undefined {\n return entity === null || entity === undefined;\n}\n","import { Observable, Subject } from 'rxjs';\nimport { filter, map } from 'rxjs/operators';\n\nexport interface MessageBusEvent<T = string> {\n readonly type: T;\n}\n\nexport class MessageBus<M> {\n readonly #eventSource: Subject<MessageBusEvent<M>> = new Subject<MessageBusEvent<M>>();\n\n public emit(event: MessageBusEvent<M>): void {\n this.#eventSource.next(event);\n }\n\n public onEmit(): Observable<MessageBusEvent<M>> {\n return this.#eventSource.asObservable();\n }\n\n public ofType(eventType: M): Observable<MessageBusEvent<M>> {\n return this.onEmit().pipe(\n filter((event: MessageBusEvent<M>): event is MessageBusEvent<M> => event.type === eventType),\n map((event: MessageBusEvent<M>) => event)\n );\n }\n}\n","import { isPlatformBrowser } from '@angular/common';\nimport { Injectable, PLATFORM_ID, inject } from '@angular/core';\n\n/**\n * A service for detecting the platform on which the application is running.\n * This service is useful for checking if the application is running in a browser\n * environment or on the server-side.\n */\n@Injectable({ providedIn: 'root' })\nexport class PlatformService {\n readonly #platformId: object = inject(PLATFORM_ID);\n public readonly isPlatformBrowser: boolean;\n\n constructor() {\n this.isPlatformBrowser = isPlatformBrowser(this.#platformId);\n }\n}\n","import { DOCUMENT } from '@angular/common';\nimport { InjectionToken, inject } from '@angular/core';\n\nexport const WINDOW: InjectionToken<Window> = new InjectionToken<Window>('An injection token for global window object', {\n factory: (): Window => {\n const { defaultView }: Document = inject(DOCUMENT);\n\n if (!defaultView) {\n throw new Error('Window is not available');\n }\n\n return defaultView;\n },\n});\n","// functions\nexport * from './lib/functions';\n\n// services\nexport * from './lib/services';\n\n// tokens\nexport * from './lib/tokens';\n\n// types\nexport * from './lib/types';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAAM,SAAU,KAAK,CAAI,MAA4B,EAAA;AACjD,IAAA,OAAO,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS;AAClD;;MCKa,UAAU,CAAA;AACV,IAAA,YAAY,GAAgC,IAAI,OAAO,EAAsB;AAE/E,IAAA,IAAI,CAAC,KAAyB,EAAA;AACjC,QAAA,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC;IACjC;IAEO,MAAM,GAAA;AACT,QAAA,OAAO,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE;IAC3C;AAEO,IAAA,MAAM,CAAC,SAAY,EAAA;AACtB,QAAA,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CACrB,MAAM,CAAC,CAAC,KAAyB,KAAkC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,EAC5F,GAAG,CAAC,CAAC,KAAyB,KAAK,KAAK,CAAC,CAC5C;IACL;AACH;;ACrBD;;;;AAIG;MAEU,eAAe,CAAA;AACf,IAAA,WAAW,GAAW,MAAM,CAAC,WAAW,CAAC;AAGlD,IAAA,WAAA,GAAA;QACI,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC;IAChE;8GANS,eAAe,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAf,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,eAAe,cADF,MAAM,EAAA,CAAA,CAAA;;2FACnB,eAAe,EAAA,UAAA,EAAA,CAAA;kBAD3B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;MCLrB,MAAM,GAA2B,IAAI,cAAc,CAAS,6CAA6C,EAAE;IACpH,OAAO,EAAE,MAAa;QAClB,MAAM,EAAE,WAAW,EAAE,GAAa,MAAM,CAAC,QAAQ,CAAC;QAElD,IAAI,CAAC,WAAW,EAAE;AACd,YAAA,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC;QAC9C;AAEA,QAAA,OAAO,WAAW;IACtB,CAAC;AACJ,CAAA;;ACbD;;ACAA;;AAEG;;;;"}
1
+ {"version":3,"file":"rt-tools-core.mjs","sources":["../../../projects/core/src/lib/functions/is-nil.ts","../../../projects/core/src/lib/services/message-bus.ts","../../../projects/core/src/lib/services/platform.service.ts","../../../projects/core/src/lib/tokens/window.token.ts","../../../projects/core/src/lib/bem/bem.const.ts","../../../projects/core/src/lib/bem/bem.utils.ts","../../../projects/core/src/lib/bem/block.directive.ts","../../../projects/core/src/lib/bem/concat-classes.pipe.ts","../../../projects/core/src/lib/bem/elem.directive.ts","../../../projects/core/src/lib/bem/mod.directive.ts","../../../projects/core/src/lib/storage/enums/storage-types.enum.ts","../../../projects/core/src/lib/storage/in-memory-storage.service.ts","../../../projects/core/src/lib/storage/json-converter.ts","../../../projects/core/src/lib/storage/storage.factory.ts","../../../projects/core/src/lib/storage/tokens/custom-storage.token.ts","../../../projects/core/src/lib/storage/tokens/in-memory-storage.token.ts","../../../projects/core/src/lib/storage/tokens/local-storage.token.ts","../../../projects/core/src/lib/storage/tokens/session-storage.token.ts","../../../projects/core/src/lib/storage/storage.service.ts","../../../projects/core/src/lib/storage/providers.ts","../../../projects/core/src/lib/idb-storage/idb-storage-service.ts","../../../projects/core/src/lib/idb-storage/idb-storage.factory.ts","../../../projects/core/src/lib/idb-storage/token/idb-storage.token.ts","../../../projects/core/src/lib/idb-storage/providers.ts","../../../projects/core/src/index.ts","../../../projects/core/src/rt-tools-core.ts"],"sourcesContent":["export function isNil<T>(entity: T | null | undefined): entity is null | undefined {\n return entity === null || entity === undefined;\n}\n","import { Observable, Subject } from 'rxjs';\nimport { filter, map } from 'rxjs/operators';\n\nexport interface MessageBusEvent<T = string> {\n readonly type: T;\n}\n\nexport class MessageBus<M> {\n readonly #eventSource: Subject<MessageBusEvent<M>> = new Subject<MessageBusEvent<M>>();\n\n public emit(event: MessageBusEvent<M>): void {\n this.#eventSource.next(event);\n }\n\n public onEmit(): Observable<MessageBusEvent<M>> {\n return this.#eventSource.asObservable();\n }\n\n public ofType(eventType: M): Observable<MessageBusEvent<M>> {\n return this.onEmit().pipe(\n filter((event: MessageBusEvent<M>): event is MessageBusEvent<M> => event.type === eventType),\n map((event: MessageBusEvent<M>) => event)\n );\n }\n}\n","import { isPlatformBrowser } from '@angular/common';\nimport { Injectable, PLATFORM_ID, inject } from '@angular/core';\n\n/**\n * A service for detecting the platform on which the application is running.\n * This service is useful for checking if the application is running in a browser\n * environment or on the server-side.\n */\n@Injectable({ providedIn: 'root' })\nexport class PlatformService {\n readonly #platformId: object = inject(PLATFORM_ID);\n public readonly isPlatformBrowser: boolean;\n\n constructor() {\n this.isPlatformBrowser = isPlatformBrowser(this.#platformId);\n }\n}\n","import { DOCUMENT } from '@angular/common';\nimport { InjectionToken, inject } from '@angular/core';\n\nexport const WINDOW: InjectionToken<Window> = new InjectionToken<Window>('An injection token for global window object', {\n factory: (): Window => {\n const { defaultView }: Document = inject(DOCUMENT);\n\n if (!defaultView) {\n throw new Error('Window is not available');\n }\n\n return defaultView;\n },\n});\n","import { IBemConfig } from './bem.types';\n\nexport const BEM_MODULE_CONFIG: IBemConfig = {\n separators: {\n el: '__',\n mod: '--',\n val: '--',\n },\n ignoreValues: false,\n modCase: 'kebab',\n};\n","import { ElementRef, Renderer2 } from '@angular/core';\n\nimport { BEM_MODULE_CONFIG } from './bem.const';\nimport { IModsObject } from './bem.types';\n\nexport function modNameHandler(str: string): string {\n switch (BEM_MODULE_CONFIG.modCase) {\n case 'kebab':\n return str\n ? str\n .replace(/[A-Z]/g, function (s: string) {\n return '-' + s.toLowerCase();\n })\n .replace(/$-/, '')\n : '';\n case 'snake':\n return str\n ? str\n .replace(/[A-Z]/g, function (s: string) {\n return '_' + s.toLowerCase();\n })\n .replace(/$-/, '')\n : '';\n default:\n return str;\n }\n}\n\nexport function generateClass(blockName: string, elemName?: string, modName?: string, modValue?: unknown): string {\n if (BEM_MODULE_CONFIG.ignoreValues) {\n modValue = !!modValue;\n }\n\n if (typeof modValue !== 'string' && typeof modValue !== 'boolean') {\n modValue = !!modValue;\n }\n\n let cls: string = blockName;\n\n if (elemName) {\n cls += BEM_MODULE_CONFIG.separators.el + elemName;\n }\n\n if (modName) {\n modName = modNameHandler(modName);\n cls += BEM_MODULE_CONFIG.separators.mod + modName;\n if (typeof modValue !== 'boolean' && modValue != null) {\n cls += BEM_MODULE_CONFIG.separators.val + modValue;\n }\n }\n\n return cls;\n}\n\nexport function parseMods(mods?: string | string[] | (string | false)[] | IModsObject): IModsObject {\n if (typeof mods === 'string') {\n mods = mods.split(/\\s+/);\n }\n\n if (Array.isArray(mods)) {\n const modsObj: IModsObject = {};\n\n mods.forEach((key: string | false) => {\n if (key) {\n modsObj[key] = true;\n }\n });\n mods = modsObj;\n } else if (typeof mods !== 'object') {\n return {};\n }\n\n return mods;\n}\n\nexport function setMods(\n blockName: string,\n elemName: string,\n mods: IModsObject,\n oldMods: IModsObject,\n element: ElementRef,\n renderer: Renderer2\n): void {\n Object.keys(mods).forEach((key: string) => {\n if (oldMods[key]) {\n if (mods[key] === oldMods[key]) {\n return;\n }\n\n renderer.removeClass(element.nativeElement, generateClass(blockName, elemName, key, oldMods[key]));\n }\n\n if (mods[key]) {\n renderer.addClass(element.nativeElement, generateClass(blockName, elemName, key, mods[key]));\n }\n });\n\n Object.keys(oldMods).forEach((key: string) => {\n if (!(key in mods) && oldMods[key]) {\n renderer.removeClass(element.nativeElement, generateClass(blockName, elemName, key, oldMods[key]));\n }\n });\n}\n","import { Attribute, Directive, ElementRef, Input, OnChanges, Optional, Renderer2 } from '@angular/core';\n\nimport { IModsObject } from './bem.types';\nimport { generateClass, parseMods, setMods } from './bem.utils';\n\n@Directive({\n selector: '[rtBlock]',\n})\nexport class BlockDirective implements OnChanges {\n @Input() public rtMod?: string | string[] | (string | false)[] | IModsObject;\n #mods: IModsObject = {};\n #modSerialized: string = '';\n\n constructor(\n public readonly element: ElementRef,\n public readonly renderer: Renderer2,\n @Attribute('rtBlock') public readonly name: string,\n @Optional() @Attribute('rtElem') private readonly elem: string\n ) {\n if (!elem && !(element.nativeElement instanceof Comment)) {\n renderer.addClass(element.nativeElement, generateClass(name));\n }\n }\n\n public ngOnChanges(): void {\n if (JSON.stringify(this.rtMod) !== this.#modSerialized && !this.elem) {\n this.#modSerialized = JSON.stringify(this.rtMod);\n\n let mods: string | string[] | (string | false)[] | IModsObject | undefined = this.rtMod;\n\n const { renderer, element, name } = this;\n\n mods = parseMods(mods);\n\n if (!(element.nativeElement instanceof Comment)) {\n setMods(name, '', mods, this.#mods || {}, element, renderer);\n }\n\n this.#mods = this.#mods === mods ? Object.assign({}, mods) : mods;\n }\n }\n}\n","import { Pipe, PipeTransform } from '@angular/core';\n\n@Pipe({\n name: 'concatClasses',\n})\nexport class ConcatClassesPipe implements PipeTransform {\n public transform<C extends string | boolean | null | undefined>(classes: (C | C[])[]): string {\n // eslint-disable-next-line\n const validClassList = classes.flat().filter((className) => typeof className === 'string' && !!className.trim());\n return validClassList.join(' ');\n }\n}\n","import { Attribute, Directive, ElementRef, Input, OnChanges, Renderer2 } from '@angular/core';\n\nimport { IModsObject } from './bem.types';\nimport { generateClass, parseMods, setMods } from './bem.utils';\nimport { BlockDirective } from './block.directive';\n\n@Directive({\n selector: '[rtElem]',\n})\nexport class ElemDirective implements OnChanges {\n @Input() public rtMod?: string | string[] | (string | false)[] | IModsObject;\n public blockName: string;\n #mods: IModsObject = {};\n #modSerialized: string = '';\n\n constructor(\n public readonly element: ElementRef,\n public readonly renderer: Renderer2,\n @Attribute('rtElem') public readonly name: string,\n private readonly rtBlock: BlockDirective\n ) {\n this.blockName = rtBlock.name;\n\n renderer.addClass(element.nativeElement, generateClass(rtBlock.name, name));\n }\n\n public ngOnChanges(): void {\n if (JSON.stringify(this.rtMod) !== this.#modSerialized) {\n this.#modSerialized = JSON.stringify(this.rtMod);\n\n let mods: string | string[] | (string | false)[] | IModsObject | undefined = this.rtMod;\n\n const { renderer, element, blockName, name } = this;\n\n mods = parseMods(mods);\n\n setMods(blockName, name, mods, this.#mods || {}, element, renderer);\n\n this.#mods = this.#mods === mods ? Object.assign({}, mods) : mods;\n }\n }\n}\n","import { Directive } from '@angular/core';\n\n@Directive({\n selector: '[rtMod]',\n})\nexport class ModDirective {}\n","export enum STORAGE_TYPES_ENUM {\n LOCAL = 'local',\n SESSION = 'session',\n IN_MEMORY = 'inMemory',\n CUSTOM = 'custom',\n}\n\nexport type StorageType = STORAGE_TYPES_ENUM.LOCAL | STORAGE_TYPES_ENUM.SESSION | STORAGE_TYPES_ENUM.IN_MEMORY | STORAGE_TYPES_ENUM.CUSTOM;\n","import { Injectable } from '@angular/core';\n\n/**\n * A service that implements the `Storage` interface using an in-memory map.\n * This service provides a fallback storage solution when `localStorage`\n * or `sessionStorage` is not available, such as in server-side rendering (SSR) scenarios.\n *\n * @Injectable\n */\n@Injectable()\nexport class InMemoryStorageService implements Storage {\n /**\n * Private in-memory storage map used to store key-value pairs.\n * The keys are strings, the values are strings.\n * The map is private and cannot be accessed directly.\n * Instead, the public methods of the service should be used to interact with the storage.\n * The map is initialized as an empty map.\n *\n * @type {Map<string, string>}\n * @private\n * @internal\n * @readonly\n */\n readonly #storage: Map<string, string> = new Map<string, string>();\n\n /**\n * Returns the number of key-value pairs currently stored.\n *\n * @returns the number of items in storage\n * @public\n */\n public get length(): number {\n return this.#storage.size;\n }\n\n /**\n * Retrieves the value associated with the given key.\n *\n * @param key - The name of the key to retrieve the value for\n * @returns the value associated with the key, or `null` if the key does not exist\n * @public\n * @returns string | null\n */\n public getItem(key: string): string | null {\n return this.#storage.get(key) || null;\n }\n\n /**\n * Adds or updates the key-value pair in the storage.\n *\n * @param key - The name of the key to create or update\n * @param data - The value to associate with the key\n * @public\n * @returns void\n */\n public setItem(key: string, data: string): void {\n this.#storage.set(key, data);\n }\n\n /**\n * Retrieves the key at the specified index.\n *\n * @param index - The index of the key to retrieve\n * @returns the key at the specified index, or `null` if the index is out of bounds\n * @public\n * @returns string | null\n */\n public key(index: number): string | null {\n return Array.from(this.#storage.keys())[index] || null;\n }\n\n /**\n * Removes the key-value pair associated with the given key.\n *\n * @param key - The name of the key to remove\n * @public\n * @returns void\n */\n public removeItem(key: string): void {\n this.#storage.delete(key);\n }\n\n /**\n * Clears all key-value pairs from the storage.\n *\n * @public\n * @returns void\n */\n public clear(): void {\n this.#storage.clear();\n }\n}\n","import { Nullable } from '../types';\nimport { IStorageConverter } from './interfaces/storage-converter';\n\nexport class JsonConverter implements IStorageConverter {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public convertTo(data: Nullable<any>): string {\n let parsedData: string;\n\n try {\n parsedData = JSON.stringify(data);\n } catch (e: unknown) {\n // eslint-disable-next-line no-console\n console.error(e);\n parsedData = 'null';\n }\n\n return parsedData;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public convertFrom<T>(data: any): Nullable<T> {\n if (typeof data === 'string') {\n try {\n return JSON.parse(data) as T;\n } catch (e: unknown) {\n // eslint-disable-next-line no-console\n console.error(e);\n return null;\n }\n }\n\n return null;\n }\n}\n","import { inject } from '@angular/core';\n\nimport { PlatformService } from '../services';\nimport { Nullable } from '../types';\nimport { InMemoryStorageService } from './in-memory-storage.service';\n\n/**\n * Factory for creating or returning `localStorage`.\n * Returns `localStorage` global object if the application is running in a browser,\n * otherwise returns null.\n *\n * @returns localStorage or null\n */\nexport function localStorageFactory(): Nullable<Storage> {\n return inject(PlatformService).isPlatformBrowser ? localStorage : null;\n}\n\n/**\n * Factory for creating or returning `sessionStorage`.\n * Returns `sessionStorage` global object if the application is running in a browser,\n * otherwise returns null.\n *\n * @returns sessionStorage or null\n */\nexport function sessionStorageFactory(): Nullable<Storage> {\n return inject(PlatformService).isPlatformBrowser ? sessionStorage : null;\n}\n\n/**\n * Factory for creating `InMemoryStorageService`.\n * Returns a new instance of InMemoryStorageService.\n *\n * @returns a new instance of InMemoryStorageService\n */\nexport function inMemoryStorageFactory(): Storage {\n return new InMemoryStorageService();\n}\n","import { InjectionToken } from '@angular/core';\n\nexport const CUSTOM_STORAGE: InjectionToken<Storage> = new InjectionToken<Storage>('CUSTOM_STORAGE');\n","import { InjectionToken } from '@angular/core';\n\nexport const IN_MEMORY_STORAGE: InjectionToken<Storage> = new InjectionToken<Storage>('IN_MEMORY_STORAGE');\n","import { InjectionToken } from '@angular/core';\n\nexport const LOCAL_STORAGE: InjectionToken<Storage> = new InjectionToken<Storage>('LOCAL_STORAGE');\n","import { InjectionToken } from '@angular/core';\n\nexport const SESSION_STORAGE: InjectionToken<Storage> = new InjectionToken<Storage>('SESSION_STORAGE');\n","import { inject, Injectable } from '@angular/core';\n\nimport { PlatformService } from '../services';\nimport { Nullable } from '../types';\nimport { STORAGE_TYPES_ENUM, StorageType } from './enums/storage-types.enum';\nimport { IStorageConfig } from './interfaces/storage-config';\nimport { JsonConverter } from './json-converter';\nimport { CUSTOM_STORAGE } from './tokens/custom-storage.token';\nimport { IN_MEMORY_STORAGE } from './tokens/in-memory-storage.token';\nimport { LOCAL_STORAGE } from './tokens/local-storage.token';\nimport { SESSION_STORAGE } from './tokens/session-storage.token';\n\nconst defaultStorageConfig: IStorageConfig = {\n ctx: STORAGE_TYPES_ENUM.LOCAL,\n storageRef: null,\n converter: new JsonConverter(),\n};\n\n/**\n * A service for managing data storage across different storage types,\n * including `localStorage`, `sessionStorage`, and an in-memory storage fallback.\n * The service supports custom storage types and data conversion through configurable converters.\n *\n * @Injectable\n */\n@Injectable()\nexport class StorageService {\n readonly #platformService: PlatformService = inject(PlatformService);\n readonly #localStorageRef: Storage = inject(LOCAL_STORAGE);\n readonly #sessionStorageRef: Storage = inject(SESSION_STORAGE);\n readonly #inMemoryStorageRef: Storage = inject(IN_MEMORY_STORAGE);\n readonly #customStorageRef: Nullable<Storage> = inject(CUSTOM_STORAGE, { optional: true });\n\n /**\n * Retrieves an item from the specified storage context.\n *\n * @param key - The key of the item to retrieve.\n * @param config - Optional configuration for the storage context and data conversion.\n * @returns The retrieved item, converted from storage if a converter is provided, or `null` if the item does not exist.\n */\n public getItem<T>(key: string, config?: Partial<IStorageConfig>): Nullable<T> {\n const fullConfig: IStorageConfig = { ...defaultStorageConfig, ...config };\n const item: Nullable<T> = this.#storage(fullConfig.ctx)?.getItem(key) as T;\n return fullConfig.converter?.convertFrom(item) ?? item ?? null;\n }\n\n /**\n * Stores an item in the specified storage context.\n *\n * @param key - The key to associate with the stored item.\n * @param data - The data to store, which will be converted if a converter is provided.\n * @param config - Optional configuration for the storage context and data conversion.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public setItem(key: string, data: any, config?: Partial<IStorageConfig>): void {\n const fullConfig: IStorageConfig = { ...defaultStorageConfig, ...config };\n const parsedValue: string = fullConfig.converter?.convertTo(data) ?? data;\n this.#storage(fullConfig.ctx)?.setItem(key, parsedValue);\n }\n\n /**\n * Checks if a given key exists in the specified storage context.\n *\n * @param key - The key to check for.\n * @param ctx - The storage context to search in (local, session, or in-memory).\n * @returns `true` if the key exists, `false` otherwise.\n */\n public hasKey(key: string, ctx: Nullable<StorageType> = defaultStorageConfig.ctx): boolean {\n return Object.prototype.hasOwnProperty.call(this.#storage(ctx), key);\n }\n\n /**\n * Executes callback functions based on whether a key exists in the specified storage context.\n *\n * @param key - The key to check for.\n * @param onHas - The callback to execute if the key exists.\n * @param onHasNot - The optional callback to execute if the key does not exist.\n * @param config - Optional configuration for the storage context and data conversion.\n */\n public onHasKey<T>(key: string, onHas: (value: Nullable<T>) => void, onHasNot?: () => void, config?: Partial<IStorageConfig>): void {\n const fullConfig: IStorageConfig = { ...defaultStorageConfig, ...config };\n\n if (this.hasKey(key, fullConfig.ctx)) {\n onHas(this.getItem<T>(key, fullConfig));\n } else if (onHasNot !== void 0) {\n onHasNot();\n }\n }\n\n /**\n * Removes an item from the specified storage context.\n *\n * @param key - The key of the item to remove.\n * @param ctx - The storage context from which to remove the item.\n */\n public removeItem(key: string, ctx: Nullable<StorageType> = defaultStorageConfig.ctx): void {\n this.#storage(ctx)?.removeItem(key);\n }\n\n /**\n * Clears all items from the specified storage context.\n *\n * @param ctx - The storage context to clear.\n */\n public clear(ctx: Nullable<StorageType> = defaultStorageConfig.ctx): void {\n this.#storage(ctx)?.clear();\n }\n\n /**\n * Returns the appropriate storage reference based on the storage context and platform.\n *\n * @param ctx - The storage context to use (local, session, custom, or in-memory).\n * @returns The corresponding `Storage` object, or `null` if not available.\n */\n #storage(ctx: Nullable<StorageType>): Nullable<Storage> {\n if (this.#platformService.isPlatformBrowser) {\n switch (ctx) {\n case 'local':\n return this.#localStorageRef;\n\n case 'session':\n return this.#sessionStorageRef;\n\n case 'custom':\n return this.#customStorageRef;\n }\n }\n\n /**\n * Fallback to in-memory storage when the platform is not a browser (e.g., SSR).\n */\n return this.#inMemoryStorageRef;\n }\n}\n","import { Provider } from '@angular/core';\n\nimport { InMemoryStorageService } from './in-memory-storage.service';\nimport { inMemoryStorageFactory, localStorageFactory, sessionStorageFactory } from './storage.factory';\nimport { StorageService } from './storage.service';\nimport { IN_MEMORY_STORAGE } from './tokens/in-memory-storage.token';\nimport { LOCAL_STORAGE } from './tokens/local-storage.token';\nimport { SESSION_STORAGE } from './tokens/session-storage.token';\n\n/**\n * Returns the set of dependency-injection providers\n * required to setup storages in an application.\n *\n * @usageNotes\n *\n * This function sets up the essential storage services needed for\n * working with `localStorage`, `sessionStorage`, and an in-memory storage solution.\n * It includes providers for each type of storage, ensuring that the appropriate\n * storage service is injected based on the platform or specific use case.\n *\n * The function is particularly useful in scenarios where the application may be\n * running on the server-side (SSR). In such cases, instead of using `localStorage`\n * and `sessionStorage`, which are only available in the browser, the `InMemoryStorageService`\n * can be used as a fallback, ensuring that the application still functions correctly.\n *\n * ```typescript\n * bootstrapApplication(RootComponent, {\n * providers: [\n * provideRtStorage()\n * ]\n * });\n * ```\n *\n * @publicApi\n */\nexport function provideRtStorage(): Provider[] {\n return [\n InMemoryStorageService,\n {\n provide: LOCAL_STORAGE,\n useFactory: localStorageFactory,\n },\n {\n provide: SESSION_STORAGE,\n useFactory: sessionStorageFactory,\n },\n {\n provide: IN_MEMORY_STORAGE,\n useFactory: inMemoryStorageFactory,\n },\n StorageService,\n ];\n}\n","import { inject, Injectable } from '@angular/core';\nimport { Observable, Observer, Subscriber } from 'rxjs';\n\nimport { WINDOW } from '../tokens';\nimport { IIDBStorageServiceInterface } from './interfaces/idb-storage-service.interface';\n\n@Injectable()\nexport class IDBStorageService<ENTITY_TYPE> implements IIDBStorageServiceInterface<ENTITY_TYPE> {\n readonly #windowRef: Window = inject(WINDOW);\n\n #context: Observable<IDBDatabase>;\n\n constructor() {\n this.#context = new Observable<IDBDatabase>((observer: Observer<IDBDatabase>) => {\n if ('indexedDB' in this.#windowRef && 'open' in this.#windowRef.indexedDB) {\n const openRequest: IDBOpenDBRequest = this.#windowRef.indexedDB.open('use-idb', 1);\n openRequest.onerror = (): void => observer.error(openRequest.error);\n openRequest.onsuccess = (): void => observer.next(openRequest.result);\n openRequest.onupgradeneeded = (): IDBObjectStore => openRequest.result.createObjectStore('idb');\n } else {\n observer.error('IndexedDB not supported');\n }\n });\n }\n\n public get(key: string): Observable<ENTITY_TYPE | undefined> {\n return new Observable<ENTITY_TYPE | undefined>((observer: Subscriber<ENTITY_TYPE | undefined>) => {\n this.#context.subscribe((db: IDBDatabase) => {\n const transaction: IDBTransaction = db.transaction('idb', 'readonly');\n const store: IDBObjectStore = transaction.objectStore('idb');\n const request: IDBRequest<ENTITY_TYPE> = store.get(key);\n\n request.onsuccess = (): void => observer.next(request.result);\n request.onerror = (): void => observer.error(request.error);\n });\n });\n }\n\n public set(key: string, value: ENTITY_TYPE): Observable<void> {\n return new Observable<void>((observer: Subscriber<void>) => {\n this.#context.subscribe((db: IDBDatabase) => {\n const transaction: IDBTransaction = db.transaction('idb', 'readwrite');\n const store: IDBObjectStore = transaction.objectStore('idb');\n const request: IDBRequest<IDBValidKey> = store.put(value, key);\n\n request.onsuccess = (): void => observer.next();\n request.onerror = (): void => observer.error(request.error);\n });\n });\n }\n\n public remove(key: string): Observable<void> {\n return new Observable<void>((observer: Subscriber<void>) => {\n this.#context.subscribe((db: IDBDatabase) => {\n const transaction: IDBTransaction = db.transaction('idb', 'readwrite');\n const store: IDBObjectStore = transaction.objectStore('idb');\n const request: IDBRequest<undefined> = store.delete(key);\n\n request.onsuccess = (): void => observer.next();\n request.onerror = (): void => observer.error(request.error);\n });\n });\n }\n}\n","import { IDBStorageService } from './idb-storage-service';\n\n/**\n * Factory for creating `IDBStorageService`.\n * Returns a new instance of IDBStorageService.\n *\n * @returns a new instance of IDBStorageService\n */\nexport function iDBStorageFactory(): IDBStorageService<Record<string, unknown>> {\n return new IDBStorageService();\n}\n","import { InjectionToken } from '@angular/core';\n\nimport { IDBStorageService } from '../idb-storage-service';\n\n/**\n * Injection token for IDBStorageService.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const IDB_STORAGE_SERVICE_TOKEN: InjectionToken<IDBStorageService<any>> = new InjectionToken<IDBStorageService<any>>(\n 'IDB_STORAGE_SERVICE_TOKEN'\n);\n","import { Provider } from '@angular/core';\n\nimport { iDBStorageFactory } from './idb-storage.factory';\nimport { IDBStorageService } from './idb-storage-service';\nimport { IDB_STORAGE_SERVICE_TOKEN } from './token/idb-storage.token';\n\n/**\n * Returns the set of dependency-injection providers\n * required to set up storages in an application.\n *\n * @usageNotes\n *\n * This function sets up the essential storage services needed for\n * working with `idb storage` solution.\n * It includes providers for each type of storage, ensuring that the appropriate\n * storage service is injected based on the platform or specific use case.\n *\n * ```typescript\n * bootstrapApplication(RootComponent, {\n * providers: [\n * provideRtIDBStorage()\n * ]\n * });\n * ```\n *\n * @publicApi\n */\nexport function provideRtIDBStorage(): Provider[] {\n return [\n {\n provide: IDB_STORAGE_SERVICE_TOKEN,\n useFactory: iDBStorageFactory,\n },\n IDBStorageService,\n ];\n}\n","// functions\nexport * from './lib/functions';\n\n// services\nexport * from './lib/services';\n\n// tokens\nexport * from './lib/tokens';\n\n// types\nexport * from './lib/types';\n\n// bem\nexport * from './lib/bem';\n\n// storage\nexport * from './lib/storage';\n\n// idb-storage\nexport * from './lib/idb-storage';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1.BlockDirective"],"mappings":";;;;;;AAAM,SAAU,KAAK,CAAI,MAA4B,EAAA;AACjD,IAAA,OAAO,MAAM,KAAK,IAAI,IA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,CAAA;kHAAjB,iBAAiB,EAAA,CAAA,CAAA;;2FAAjB,iBAAiB,EAAA,UAAA,EAAA,CAAA;kBAD7B;;;ACJD;;;;;AAKG;SACa,iBAAiB,GAAA;IAC7B,OAAO,IAAI,iBAAiB,EAAE;AAClC;;ACNA;;AAEG;AACH;MACa,yBAAyB,GAA2C,IAAI,cAAc,CAC/F,2BAA2B;;ACH/B;;;;;;;;;;;;;;;;;;;;AAoBG;SACa,mBAAmB,GAAA;IAC/B,OAAO;AACH,QAAA;AACI,YAAA,OAAO,EAAE,yBAAyB;AAClC,YAAA,UAAU,EAAE,iBAAiB;AAChC,SAAA;QACD,iBAAiB;KACpB;AACL;;ACnCA;;ACAA;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rt-tools/core",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Core utilities for Angular applications - MessageBus, PlatformService, WINDOW token, and helper functions",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Yauheni Krumin",
Binary file
@@ -1,6 +1,6 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import * as i0 from '@angular/core';
3
- import { InjectionToken } from '@angular/core';
3
+ import { InjectionToken, OnChanges, ElementRef, Renderer2, PipeTransform, Provider } from '@angular/core';
4
4
 
5
5
  declare function isNil<T>(entity: T | null | undefined): entity is null | undefined;
6
6
 
@@ -37,5 +37,331 @@ type Nullable<T> = T | undefined | null;
37
37
 
38
38
  type Primitive = string | number | bigint | boolean | symbol | null | undefined;
39
39
 
40
- export { MessageBus, PlatformService, WINDOW, isNil };
41
- export type { IDictionary, MessageBusEvent, Nullable, Primitive };
40
+ type IModsObject = Record<string, unknown>;
41
+ interface IBemConfig {
42
+ separators: {
43
+ el: string;
44
+ mod: string;
45
+ val: string;
46
+ };
47
+ ignoreValues?: boolean;
48
+ modCase?: string;
49
+ }
50
+
51
+ declare class BlockDirective implements OnChanges {
52
+ #private;
53
+ readonly element: ElementRef;
54
+ readonly renderer: Renderer2;
55
+ readonly name: string;
56
+ private readonly elem;
57
+ rtMod?: string | string[] | (string | false)[] | IModsObject;
58
+ constructor(element: ElementRef, renderer: Renderer2, name: string, elem: string);
59
+ ngOnChanges(): void;
60
+ static ɵfac: i0.ɵɵFactoryDeclaration<BlockDirective, [null, null, { attribute: "rtBlock"; }, { attribute: "rtElem"; optional: true; }]>;
61
+ static ɵdir: i0.ɵɵDirectiveDeclaration<BlockDirective, "[rtBlock]", never, { "rtMod": { "alias": "rtMod"; "required": false; }; }, {}, never, never, true, never>;
62
+ }
63
+
64
+ declare class ConcatClassesPipe implements PipeTransform {
65
+ transform<C extends string | boolean | null | undefined>(classes: (C | C[])[]): string;
66
+ static ɵfac: i0.ɵɵFactoryDeclaration<ConcatClassesPipe, never>;
67
+ static ɵpipe: i0.ɵɵPipeDeclaration<ConcatClassesPipe, "concatClasses", true>;
68
+ }
69
+
70
+ declare class ElemDirective implements OnChanges {
71
+ #private;
72
+ readonly element: ElementRef;
73
+ readonly renderer: Renderer2;
74
+ readonly name: string;
75
+ private readonly rtBlock;
76
+ rtMod?: string | string[] | (string | false)[] | IModsObject;
77
+ blockName: string;
78
+ constructor(element: ElementRef, renderer: Renderer2, name: string, rtBlock: BlockDirective);
79
+ ngOnChanges(): void;
80
+ static ɵfac: i0.ɵɵFactoryDeclaration<ElemDirective, [null, null, { attribute: "rtElem"; }, null]>;
81
+ static ɵdir: i0.ɵɵDirectiveDeclaration<ElemDirective, "[rtElem]", never, { "rtMod": { "alias": "rtMod"; "required": false; }; }, {}, never, never, true, never>;
82
+ }
83
+
84
+ declare class ModDirective {
85
+ static ɵfac: i0.ɵɵFactoryDeclaration<ModDirective, never>;
86
+ static ɵdir: i0.ɵɵDirectiveDeclaration<ModDirective, "[rtMod]", never, {}, {}, never, never, true, never>;
87
+ }
88
+
89
+ declare enum STORAGE_TYPES_ENUM {
90
+ LOCAL = "local",
91
+ SESSION = "session",
92
+ IN_MEMORY = "inMemory",
93
+ CUSTOM = "custom"
94
+ }
95
+ type StorageType = STORAGE_TYPES_ENUM.LOCAL | STORAGE_TYPES_ENUM.SESSION | STORAGE_TYPES_ENUM.IN_MEMORY | STORAGE_TYPES_ENUM.CUSTOM;
96
+
97
+ /**
98
+ * A service that implements the `Storage` interface using an in-memory map.
99
+ * This service provides a fallback storage solution when `localStorage`
100
+ * or `sessionStorage` is not available, such as in server-side rendering (SSR) scenarios.
101
+ *
102
+ * @Injectable
103
+ */
104
+ declare class InMemoryStorageService implements Storage {
105
+ #private;
106
+ /**
107
+ * Returns the number of key-value pairs currently stored.
108
+ *
109
+ * @returns the number of items in storage
110
+ * @public
111
+ */
112
+ get length(): number;
113
+ /**
114
+ * Retrieves the value associated with the given key.
115
+ *
116
+ * @param key - The name of the key to retrieve the value for
117
+ * @returns the value associated with the key, or `null` if the key does not exist
118
+ * @public
119
+ * @returns string | null
120
+ */
121
+ getItem(key: string): string | null;
122
+ /**
123
+ * Adds or updates the key-value pair in the storage.
124
+ *
125
+ * @param key - The name of the key to create or update
126
+ * @param data - The value to associate with the key
127
+ * @public
128
+ * @returns void
129
+ */
130
+ setItem(key: string, data: string): void;
131
+ /**
132
+ * Retrieves the key at the specified index.
133
+ *
134
+ * @param index - The index of the key to retrieve
135
+ * @returns the key at the specified index, or `null` if the index is out of bounds
136
+ * @public
137
+ * @returns string | null
138
+ */
139
+ key(index: number): string | null;
140
+ /**
141
+ * Removes the key-value pair associated with the given key.
142
+ *
143
+ * @param key - The name of the key to remove
144
+ * @public
145
+ * @returns void
146
+ */
147
+ removeItem(key: string): void;
148
+ /**
149
+ * Clears all key-value pairs from the storage.
150
+ *
151
+ * @public
152
+ * @returns void
153
+ */
154
+ clear(): void;
155
+ static ɵfac: i0.ɵɵFactoryDeclaration<InMemoryStorageService, never>;
156
+ static ɵprov: i0.ɵɵInjectableDeclaration<InMemoryStorageService>;
157
+ }
158
+
159
+ interface IStorageConverter {
160
+ convertTo(data: any): string;
161
+ convertFrom<T>(data: any): Nullable<T>;
162
+ }
163
+
164
+ interface IStorageConfig {
165
+ ctx: Nullable<StorageType>;
166
+ storageRef: Nullable<Storage>;
167
+ converter: Nullable<IStorageConverter>;
168
+ }
169
+
170
+ declare class JsonConverter implements IStorageConverter {
171
+ convertTo(data: Nullable<any>): string;
172
+ convertFrom<T>(data: any): Nullable<T>;
173
+ }
174
+
175
+ /**
176
+ * Returns the set of dependency-injection providers
177
+ * required to setup storages in an application.
178
+ *
179
+ * @usageNotes
180
+ *
181
+ * This function sets up the essential storage services needed for
182
+ * working with `localStorage`, `sessionStorage`, and an in-memory storage solution.
183
+ * It includes providers for each type of storage, ensuring that the appropriate
184
+ * storage service is injected based on the platform or specific use case.
185
+ *
186
+ * The function is particularly useful in scenarios where the application may be
187
+ * running on the server-side (SSR). In such cases, instead of using `localStorage`
188
+ * and `sessionStorage`, which are only available in the browser, the `InMemoryStorageService`
189
+ * can be used as a fallback, ensuring that the application still functions correctly.
190
+ *
191
+ * ```typescript
192
+ * bootstrapApplication(RootComponent, {
193
+ * providers: [
194
+ * provideRtStorage()
195
+ * ]
196
+ * });
197
+ * ```
198
+ *
199
+ * @publicApi
200
+ */
201
+ declare function provideRtStorage(): Provider[];
202
+
203
+ /**
204
+ * Factory for creating or returning `localStorage`.
205
+ * Returns `localStorage` global object if the application is running in a browser,
206
+ * otherwise returns null.
207
+ *
208
+ * @returns localStorage or null
209
+ */
210
+ declare function localStorageFactory(): Nullable<Storage>;
211
+ /**
212
+ * Factory for creating or returning `sessionStorage`.
213
+ * Returns `sessionStorage` global object if the application is running in a browser,
214
+ * otherwise returns null.
215
+ *
216
+ * @returns sessionStorage or null
217
+ */
218
+ declare function sessionStorageFactory(): Nullable<Storage>;
219
+ /**
220
+ * Factory for creating `InMemoryStorageService`.
221
+ * Returns a new instance of InMemoryStorageService.
222
+ *
223
+ * @returns a new instance of InMemoryStorageService
224
+ */
225
+ declare function inMemoryStorageFactory(): Storage;
226
+
227
+ /**
228
+ * A service for managing data storage across different storage types,
229
+ * including `localStorage`, `sessionStorage`, and an in-memory storage fallback.
230
+ * The service supports custom storage types and data conversion through configurable converters.
231
+ *
232
+ * @Injectable
233
+ */
234
+ declare class StorageService {
235
+ #private;
236
+ /**
237
+ * Retrieves an item from the specified storage context.
238
+ *
239
+ * @param key - The key of the item to retrieve.
240
+ * @param config - Optional configuration for the storage context and data conversion.
241
+ * @returns The retrieved item, converted from storage if a converter is provided, or `null` if the item does not exist.
242
+ */
243
+ getItem<T>(key: string, config?: Partial<IStorageConfig>): Nullable<T>;
244
+ /**
245
+ * Stores an item in the specified storage context.
246
+ *
247
+ * @param key - The key to associate with the stored item.
248
+ * @param data - The data to store, which will be converted if a converter is provided.
249
+ * @param config - Optional configuration for the storage context and data conversion.
250
+ */
251
+ setItem(key: string, data: any, config?: Partial<IStorageConfig>): void;
252
+ /**
253
+ * Checks if a given key exists in the specified storage context.
254
+ *
255
+ * @param key - The key to check for.
256
+ * @param ctx - The storage context to search in (local, session, or in-memory).
257
+ * @returns `true` if the key exists, `false` otherwise.
258
+ */
259
+ hasKey(key: string, ctx?: Nullable<StorageType>): boolean;
260
+ /**
261
+ * Executes callback functions based on whether a key exists in the specified storage context.
262
+ *
263
+ * @param key - The key to check for.
264
+ * @param onHas - The callback to execute if the key exists.
265
+ * @param onHasNot - The optional callback to execute if the key does not exist.
266
+ * @param config - Optional configuration for the storage context and data conversion.
267
+ */
268
+ onHasKey<T>(key: string, onHas: (value: Nullable<T>) => void, onHasNot?: () => void, config?: Partial<IStorageConfig>): void;
269
+ /**
270
+ * Removes an item from the specified storage context.
271
+ *
272
+ * @param key - The key of the item to remove.
273
+ * @param ctx - The storage context from which to remove the item.
274
+ */
275
+ removeItem(key: string, ctx?: Nullable<StorageType>): void;
276
+ /**
277
+ * Clears all items from the specified storage context.
278
+ *
279
+ * @param ctx - The storage context to clear.
280
+ */
281
+ clear(ctx?: Nullable<StorageType>): void;
282
+ static ɵfac: i0.ɵɵFactoryDeclaration<StorageService, never>;
283
+ static ɵprov: i0.ɵɵInjectableDeclaration<StorageService>;
284
+ }
285
+
286
+ declare const CUSTOM_STORAGE: InjectionToken<Storage>;
287
+
288
+ declare const IN_MEMORY_STORAGE: InjectionToken<Storage>;
289
+
290
+ declare const LOCAL_STORAGE: InjectionToken<Storage>;
291
+
292
+ declare const SESSION_STORAGE: InjectionToken<Storage>;
293
+
294
+ /**
295
+ * Abstract StorageService class for interacting with a storage system.
296
+ * Uses Observable to handle asynchronous operations.
297
+ */
298
+ interface IIDBStorageServiceInterface<T> {
299
+ /**
300
+ * Retrieves a value from storage by the given key.
301
+ * @param key - The key to retrieve the value.
302
+ * @returns An Observable that emits the value of type T or undefined if the key does not exist.
303
+ */
304
+ get(key: string): Observable<T | undefined>;
305
+ /**
306
+ * Saves a value in storage under the specified key.
307
+ * @param key - The key to store the value under.
308
+ * @param value - The value to be stored.
309
+ * @returns An Observable that completes once the value is successfully saved.
310
+ */
311
+ set(key: string, value: T): Observable<void>;
312
+ /**
313
+ * Removes a value from storage by the specified key.
314
+ * @param key - The key to remove the value from.
315
+ * @returns An Observable that completes once the value is successfully removed.
316
+ */
317
+ remove(key: string): Observable<void>;
318
+ }
319
+
320
+ declare class IDBStorageService<ENTITY_TYPE> implements IIDBStorageServiceInterface<ENTITY_TYPE> {
321
+ #private;
322
+ constructor();
323
+ get(key: string): Observable<ENTITY_TYPE | undefined>;
324
+ set(key: string, value: ENTITY_TYPE): Observable<void>;
325
+ remove(key: string): Observable<void>;
326
+ static ɵfac: i0.ɵɵFactoryDeclaration<IDBStorageService<any>, never>;
327
+ static ɵprov: i0.ɵɵInjectableDeclaration<IDBStorageService<any>>;
328
+ }
329
+
330
+ /**
331
+ * Factory for creating `IDBStorageService`.
332
+ * Returns a new instance of IDBStorageService.
333
+ *
334
+ * @returns a new instance of IDBStorageService
335
+ */
336
+ declare function iDBStorageFactory(): IDBStorageService<Record<string, unknown>>;
337
+
338
+ /**
339
+ * Returns the set of dependency-injection providers
340
+ * required to set up storages in an application.
341
+ *
342
+ * @usageNotes
343
+ *
344
+ * This function sets up the essential storage services needed for
345
+ * working with `idb storage` solution.
346
+ * It includes providers for each type of storage, ensuring that the appropriate
347
+ * storage service is injected based on the platform or specific use case.
348
+ *
349
+ * ```typescript
350
+ * bootstrapApplication(RootComponent, {
351
+ * providers: [
352
+ * provideRtIDBStorage()
353
+ * ]
354
+ * });
355
+ * ```
356
+ *
357
+ * @publicApi
358
+ */
359
+ declare function provideRtIDBStorage(): Provider[];
360
+
361
+ /**
362
+ * Injection token for IDBStorageService.
363
+ */
364
+ declare const IDB_STORAGE_SERVICE_TOKEN: InjectionToken<IDBStorageService<any>>;
365
+
366
+ export { BlockDirective, CUSTOM_STORAGE, ConcatClassesPipe, ElemDirective, IDBStorageService, IDB_STORAGE_SERVICE_TOKEN, IN_MEMORY_STORAGE, InMemoryStorageService, JsonConverter, LOCAL_STORAGE, MessageBus, ModDirective, PlatformService, SESSION_STORAGE, STORAGE_TYPES_ENUM, StorageService, WINDOW, iDBStorageFactory, inMemoryStorageFactory, isNil, localStorageFactory, provideRtIDBStorage, provideRtStorage, sessionStorageFactory };
367
+ export type { IBemConfig, IDictionary, IIDBStorageServiceInterface, IModsObject, IStorageConfig, IStorageConverter, MessageBusEvent, Nullable, Primitive, StorageType };