@ngx-pwa/local-storage 13.0.5 → 14.0.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.
- package/LICENSE +1 -1
- package/esm2020/lib/databases/indexeddb-database.mjs +18 -40
- package/esm2020/lib/databases/local-database.mjs +9 -21
- package/esm2020/lib/databases/localstorage-database.mjs +9 -12
- package/esm2020/lib/databases/memory-database.mjs +4 -4
- package/esm2020/lib/providers.mjs +81 -0
- package/esm2020/lib/storage.module.mjs +4 -4
- package/esm2020/lib/storages/local-storage.service.mjs +8 -11
- package/esm2020/lib/storages/storage-map.service.mjs +13 -10
- package/esm2020/lib/tokens.mjs +1 -1
- package/esm2020/lib/validation/json-validator.mjs +3 -3
- package/esm2020/public-api.mjs +2 -1
- package/fesm2015/ngx-pwa-local-storage.mjs +138 -96
- package/fesm2015/ngx-pwa-local-storage.mjs.map +1 -1
- package/fesm2020/ngx-pwa-local-storage.mjs +138 -94
- package/fesm2020/ngx-pwa-local-storage.mjs.map +1 -1
- package/{ngx-pwa-local-storage.d.ts → index.d.ts} +0 -0
- package/lib/databases/indexeddb-database.d.ts +1 -8
- package/lib/databases/local-database.d.ts +1 -5
- package/lib/databases/localstorage-database.d.ts +0 -4
- package/lib/providers.d.ts +71 -0
- package/lib/storages/storage-map.service.d.ts +1 -1
- package/lib/tokens.d.ts +4 -14
- package/package.json +6 -6
- package/public-api.d.ts +1 -0
- package/schematics/migration.json +5 -0
- package/schematics/ng-add/index.js +9 -4
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-update/index.d.ts +1 -0
- package/schematics/ng-update/index.js +15 -1
- package/schematics/ng-update/index.js.map +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, InjectionToken, Inject, PLATFORM_ID, NgModule } from '@angular/core';
|
|
2
|
+
import { Injectable, InjectionToken, inject, Inject, PLATFORM_ID, NgModule, makeEnvironmentProviders } from '@angular/core';
|
|
3
3
|
import { isPlatformBrowser } from '@angular/common';
|
|
4
4
|
import { ReplaySubject, fromEvent, race, throwError, of, Observable, asyncScheduler, from } from 'rxjs';
|
|
5
|
-
import { mergeMap, map, first,
|
|
5
|
+
import { mergeMap, map, first, takeWhile, tap, observeOn, catchError } from 'rxjs/operators';
|
|
6
6
|
|
|
7
7
|
class JSONValidator {
|
|
8
8
|
/**
|
|
@@ -236,9 +236,9 @@ class JSONValidator {
|
|
|
236
236
|
return (schema.enum.includes(data));
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
-
JSONValidator.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
240
|
-
JSONValidator.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
241
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
239
|
+
JSONValidator.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: JSONValidator, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
240
|
+
JSONValidator.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: JSONValidator, providedIn: 'root' });
|
|
241
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: JSONValidator, decorators: [{
|
|
242
242
|
type: Injectable,
|
|
243
243
|
args: [{
|
|
244
244
|
providedIn: 'root'
|
|
@@ -332,14 +332,7 @@ class SerializationError extends Error {
|
|
|
332
332
|
}
|
|
333
333
|
|
|
334
334
|
class IndexedDBDatabase {
|
|
335
|
-
|
|
336
|
-
* Constructor params are provided by Angular (but can also be passed manually in tests)
|
|
337
|
-
* @param dbName `indexedDB` database name
|
|
338
|
-
* @param storeName `indexedDB` store name
|
|
339
|
-
* @param dbVersion `indexedDB` database version
|
|
340
|
-
* @param noWrap Flag to not wrap `indexedDB` values for interoperability or to wrap for backward compatibility
|
|
341
|
-
*/
|
|
342
|
-
constructor(dbName = DEFAULT_IDB_DB_NAME, storeName = DEFAULT_IDB_STORE_NAME, dbVersion = DEFAULT_IDB_DB_VERSION, noWrap = DEFAULT_IDB_NO_WRAP) {
|
|
335
|
+
constructor() {
|
|
343
336
|
/**
|
|
344
337
|
* `indexedDB` database connection, wrapped in a RxJS `ReplaySubject` to be able to access the connection
|
|
345
338
|
* even after the connection success event happened
|
|
@@ -349,10 +342,10 @@ class IndexedDBDatabase {
|
|
|
349
342
|
* Index used when wrapping value. *For backward compatibility only.*
|
|
350
343
|
*/
|
|
351
344
|
this.wrapIndex = 'value';
|
|
352
|
-
this.dbName =
|
|
353
|
-
this.storeName =
|
|
354
|
-
this.dbVersion =
|
|
355
|
-
this.noWrap =
|
|
345
|
+
this.dbName = inject(IDB_DB_NAME);
|
|
346
|
+
this.storeName = inject(IDB_STORE_NAME);
|
|
347
|
+
this.dbVersion = inject(IDB_DB_VERSION);
|
|
348
|
+
this.noWrap = inject(IDB_NO_WRAP);
|
|
356
349
|
/* Connect to `indexedDB`, with prefix if provided by the user */
|
|
357
350
|
this.connect();
|
|
358
351
|
}
|
|
@@ -434,8 +427,7 @@ class IndexedDBDatabase {
|
|
|
434
427
|
/* Add if the item is not existing yet, or update otherwise */
|
|
435
428
|
store.put(dataToStore, key);
|
|
436
429
|
/* Listen to events and return `undefined` as no value is expected */
|
|
437
|
-
|
|
438
|
-
return events.pipe(mapTo(undefined));
|
|
430
|
+
return events.pipe(map(() => undefined));
|
|
439
431
|
}),
|
|
440
432
|
/* The observable will complete after the first value */
|
|
441
433
|
first());
|
|
@@ -452,8 +444,7 @@ class IndexedDBDatabase {
|
|
|
452
444
|
/* Delete the item in store */
|
|
453
445
|
store.delete(key);
|
|
454
446
|
/* Listen to events and return `undefined` as no data is expected here */
|
|
455
|
-
|
|
456
|
-
return events.pipe(mapTo(undefined));
|
|
447
|
+
return events.pipe(map(() => undefined));
|
|
457
448
|
}),
|
|
458
449
|
/* The observable will complete after the first value */
|
|
459
450
|
first());
|
|
@@ -469,8 +460,7 @@ class IndexedDBDatabase {
|
|
|
469
460
|
/* Delete all items in object store */
|
|
470
461
|
store.clear();
|
|
471
462
|
/* Listen to events and return `undefined` as no data is expected here */
|
|
472
|
-
|
|
473
|
-
return events.pipe(mapTo(undefined));
|
|
463
|
+
return events.pipe(map(() => undefined));
|
|
474
464
|
}),
|
|
475
465
|
/* The observable will complete */
|
|
476
466
|
first());
|
|
@@ -595,7 +585,7 @@ class IndexedDBDatabase {
|
|
|
595
585
|
}
|
|
596
586
|
catch (error) {
|
|
597
587
|
/* The store could have been deleted from outside */
|
|
598
|
-
return throwError(error);
|
|
588
|
+
return throwError(() => error);
|
|
599
589
|
}
|
|
600
590
|
/* Get the store from the transaction */
|
|
601
591
|
const store = transaction.objectStore(this.storeName);
|
|
@@ -614,7 +604,7 @@ class IndexedDBDatabase {
|
|
|
614
604
|
/* Throw on error to be able to catch errors in RxJS way.
|
|
615
605
|
* Here `event.target` must be used, as `transactionOrRequest.error` will be `null`
|
|
616
606
|
* if we are on the request and the error is only triggered later by the transaction */
|
|
617
|
-
mergeMap((event) => throwError(event.target.error)));
|
|
607
|
+
mergeMap((event) => throwError(() => event.target.error)));
|
|
618
608
|
}
|
|
619
609
|
/**
|
|
620
610
|
* Listen transaction `complete` and `error` events
|
|
@@ -630,32 +620,17 @@ class IndexedDBDatabase {
|
|
|
630
620
|
return race([complete$, error$]);
|
|
631
621
|
}
|
|
632
622
|
}
|
|
633
|
-
IndexedDBDatabase.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
634
|
-
IndexedDBDatabase.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
635
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
623
|
+
IndexedDBDatabase.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: IndexedDBDatabase, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
624
|
+
IndexedDBDatabase.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: IndexedDBDatabase, providedIn: 'root' });
|
|
625
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: IndexedDBDatabase, decorators: [{
|
|
636
626
|
type: Injectable,
|
|
637
627
|
args: [{
|
|
638
628
|
providedIn: 'root'
|
|
639
629
|
}]
|
|
640
|
-
}], ctorParameters: function () { return [
|
|
641
|
-
type: Inject,
|
|
642
|
-
args: [IDB_DB_NAME]
|
|
643
|
-
}] }, { type: undefined, decorators: [{
|
|
644
|
-
type: Inject,
|
|
645
|
-
args: [IDB_STORE_NAME]
|
|
646
|
-
}] }, { type: undefined, decorators: [{
|
|
647
|
-
type: Inject,
|
|
648
|
-
args: [IDB_DB_VERSION]
|
|
649
|
-
}] }, { type: undefined, decorators: [{
|
|
650
|
-
type: Inject,
|
|
651
|
-
args: [IDB_NO_WRAP]
|
|
652
|
-
}] }]; } });
|
|
630
|
+
}], ctorParameters: function () { return []; } });
|
|
653
631
|
|
|
654
632
|
class LocalStorageDatabase {
|
|
655
|
-
|
|
656
|
-
* Constructor params are provided by Angular (but can also be passed manually in tests)
|
|
657
|
-
* @param prefix Prefix option to avoid collision for multiple apps on the same subdomain or for interoperability
|
|
658
|
-
*/
|
|
633
|
+
// `inject()` cannot be used here, as `LocalStorageDatabase` is instanciated at runtime in some scenarios
|
|
659
634
|
constructor(prefix = '') {
|
|
660
635
|
/* Prefix if asked, or no prefix otherwise */
|
|
661
636
|
this.prefix = prefix || '';
|
|
@@ -683,7 +658,7 @@ class LocalStorageDatabase {
|
|
|
683
658
|
parsedData = JSON.parse(unparsedData);
|
|
684
659
|
}
|
|
685
660
|
catch (error) {
|
|
686
|
-
return throwError(error);
|
|
661
|
+
return throwError(() => error);
|
|
687
662
|
}
|
|
688
663
|
}
|
|
689
664
|
/* Wrap in a RxJS `Observable` to be consistent with other storages */
|
|
@@ -701,21 +676,21 @@ class LocalStorageDatabase {
|
|
|
701
676
|
const dataPrototype = Object.getPrototypeOf(data);
|
|
702
677
|
if ((typeof data === 'object') && (data !== null) && !Array.isArray(data) &&
|
|
703
678
|
!((dataPrototype === Object.prototype) || (dataPrototype === null))) {
|
|
704
|
-
return throwError(new SerializationError());
|
|
679
|
+
return throwError(() => new SerializationError());
|
|
705
680
|
}
|
|
706
681
|
/* Try to stringify (can fail on circular references) */
|
|
707
682
|
try {
|
|
708
683
|
serializedData = JSON.stringify(data);
|
|
709
684
|
}
|
|
710
685
|
catch (error) {
|
|
711
|
-
return throwError(error);
|
|
686
|
+
return throwError(() => error);
|
|
712
687
|
}
|
|
713
688
|
/* Can fail if storage quota is exceeded */
|
|
714
689
|
try {
|
|
715
690
|
localStorage.setItem(this.prefixKey(key), serializedData);
|
|
716
691
|
}
|
|
717
692
|
catch (error) {
|
|
718
|
-
return throwError(error);
|
|
693
|
+
return throwError(() => error);
|
|
719
694
|
}
|
|
720
695
|
/* Wrap in a RxJS `Observable` to be consistent with other storages */
|
|
721
696
|
return of(undefined);
|
|
@@ -796,9 +771,9 @@ class LocalStorageDatabase {
|
|
|
796
771
|
return `${this.prefix}${key}`;
|
|
797
772
|
}
|
|
798
773
|
}
|
|
799
|
-
LocalStorageDatabase.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
800
|
-
LocalStorageDatabase.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
801
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
774
|
+
LocalStorageDatabase.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: LocalStorageDatabase, deps: [{ token: LS_PREFIX }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
775
|
+
LocalStorageDatabase.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: LocalStorageDatabase, providedIn: 'root' });
|
|
776
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: LocalStorageDatabase, decorators: [{
|
|
802
777
|
type: Injectable,
|
|
803
778
|
args: [{
|
|
804
779
|
providedIn: 'root'
|
|
@@ -879,9 +854,9 @@ class MemoryDatabase {
|
|
|
879
854
|
return of(this.memoryStorage.has(key));
|
|
880
855
|
}
|
|
881
856
|
}
|
|
882
|
-
MemoryDatabase.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
883
|
-
MemoryDatabase.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
884
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
857
|
+
MemoryDatabase.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: MemoryDatabase, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
858
|
+
MemoryDatabase.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: MemoryDatabase, providedIn: 'root' });
|
|
859
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: MemoryDatabase, decorators: [{
|
|
885
860
|
type: Injectable,
|
|
886
861
|
args: [{
|
|
887
862
|
providedIn: 'root'
|
|
@@ -890,13 +865,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImpor
|
|
|
890
865
|
|
|
891
866
|
/**
|
|
892
867
|
* Factory to create a storage according to browser support
|
|
893
|
-
* @param platformId Context about the platform (`browser`, `server`...)
|
|
894
|
-
* @param LSPrefix Prefix for `localStorage` keys to avoid collision for multiple apps on the same subdomain
|
|
895
|
-
* @param IDBDBName `indexedDB` database name
|
|
896
|
-
* @param IDBstoreName `indexedDB` storeName name
|
|
897
868
|
* @see {@link https://github.com/cyrilletuzi/angular-async-local-storage/blob/main/docs/BROWSERS_SUPPORT.md}
|
|
898
869
|
*/
|
|
899
|
-
function localDatabaseFactory(
|
|
870
|
+
function localDatabaseFactory() {
|
|
871
|
+
const platformId = inject(PLATFORM_ID);
|
|
900
872
|
/* When storage is fully disabled in browser (via the "Block all cookies" option),
|
|
901
873
|
* just trying to check `indexedDB` or `localStorage` variables causes a security exception.
|
|
902
874
|
* Prevents https://github.com/cyrilletuzi/angular-async-local-storage/issues/118
|
|
@@ -911,7 +883,7 @@ function localDatabaseFactory(platformId, LSPrefix, IDBDBName, IDBStoreName, IDB
|
|
|
911
883
|
* Will be the case for:
|
|
912
884
|
* - All other browsers in normal mode
|
|
913
885
|
* - Chromium / Safari private mode, but in this case, data will be swiped when the user leaves the app */
|
|
914
|
-
return new IndexedDBDatabase(
|
|
886
|
+
return new IndexedDBDatabase();
|
|
915
887
|
}
|
|
916
888
|
else if (isPlatformBrowser(platformId)
|
|
917
889
|
&& (localStorage !== undefined) && (localStorage !== null) && ('getItem' in localStorage)) {
|
|
@@ -926,7 +898,7 @@ function localDatabaseFactory(platformId, LSPrefix, IDBDBName, IDBStoreName, IDB
|
|
|
926
898
|
* For Firefox, can only be detected later in `IndexedDBDatabase.connect()`
|
|
927
899
|
* @see {@link https://bugzilla.mozilla.org/show_bug.cgi?id=781982}
|
|
928
900
|
*/
|
|
929
|
-
return new LocalStorageDatabase(
|
|
901
|
+
return new LocalStorageDatabase();
|
|
930
902
|
}
|
|
931
903
|
}
|
|
932
904
|
catch {
|
|
@@ -941,21 +913,13 @@ function localDatabaseFactory(platformId, LSPrefix, IDBDBName, IDBStoreName, IDB
|
|
|
941
913
|
}
|
|
942
914
|
class LocalDatabase {
|
|
943
915
|
}
|
|
944
|
-
LocalDatabase.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
945
|
-
LocalDatabase.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
946
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
916
|
+
LocalDatabase.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: LocalDatabase, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
917
|
+
LocalDatabase.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: LocalDatabase, providedIn: 'root', useFactory: localDatabaseFactory });
|
|
918
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: LocalDatabase, decorators: [{
|
|
947
919
|
type: Injectable,
|
|
948
920
|
args: [{
|
|
949
921
|
providedIn: 'root',
|
|
950
922
|
useFactory: localDatabaseFactory,
|
|
951
|
-
deps: [
|
|
952
|
-
PLATFORM_ID,
|
|
953
|
-
LS_PREFIX,
|
|
954
|
-
IDB_DB_NAME,
|
|
955
|
-
IDB_STORE_NAME,
|
|
956
|
-
IDB_DB_VERSION,
|
|
957
|
-
IDB_NO_WRAP,
|
|
958
|
-
]
|
|
959
923
|
}]
|
|
960
924
|
}] });
|
|
961
925
|
|
|
@@ -981,7 +945,9 @@ class StorageMap {
|
|
|
981
945
|
* @param jsonValidator Validator service
|
|
982
946
|
* @param LSPrefix Prefix for `localStorage` keys to avoid collision for multiple apps on the same subdomain or for interoperability
|
|
983
947
|
*/
|
|
984
|
-
constructor(database, jsonValidator = new JSONValidator(),
|
|
948
|
+
constructor(database, jsonValidator = new JSONValidator(),
|
|
949
|
+
// `inject()` cannot be used here, as `StorageMap` needs other manual params
|
|
950
|
+
LSPrefix = '') {
|
|
985
951
|
this.database = database;
|
|
986
952
|
this.jsonValidator = jsonValidator;
|
|
987
953
|
this.LSPrefix = LSPrefix;
|
|
@@ -1076,7 +1042,7 @@ class StorageMap {
|
|
|
1076
1042
|
else if (schema) {
|
|
1077
1043
|
/* Validate data against a JSON schema if provided */
|
|
1078
1044
|
if (!this.jsonValidator.validate(data, schema)) {
|
|
1079
|
-
return throwError(new ValidationError());
|
|
1045
|
+
return throwError(() => new ValidationError());
|
|
1080
1046
|
}
|
|
1081
1047
|
/* Data have been checked, so it's OK to cast */
|
|
1082
1048
|
return of(data);
|
|
@@ -1104,7 +1070,7 @@ class StorageMap {
|
|
|
1104
1070
|
}
|
|
1105
1071
|
/* Validate data against a JSON schema if provided */
|
|
1106
1072
|
if (schema && !this.jsonValidator.validate(data, schema)) {
|
|
1107
|
-
return throwError(new ValidationError());
|
|
1073
|
+
return throwError(() => new ValidationError());
|
|
1108
1074
|
}
|
|
1109
1075
|
return this.database.set(key, data).pipe(
|
|
1110
1076
|
/* Catch if `indexedDb` is broken */
|
|
@@ -1240,14 +1206,15 @@ class StorageMap {
|
|
|
1240
1206
|
}
|
|
1241
1207
|
else {
|
|
1242
1208
|
/* Otherwise, rethrow the error */
|
|
1243
|
-
return
|
|
1209
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
1210
|
+
return throwError(() => error);
|
|
1244
1211
|
}
|
|
1245
1212
|
});
|
|
1246
1213
|
}
|
|
1247
1214
|
}
|
|
1248
|
-
StorageMap.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1249
|
-
StorageMap.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
1250
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1215
|
+
StorageMap.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: StorageMap, deps: [{ token: LocalDatabase }, { token: JSONValidator }, { token: LS_PREFIX }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1216
|
+
StorageMap.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: StorageMap, providedIn: 'root' });
|
|
1217
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: StorageMap, decorators: [{
|
|
1251
1218
|
type: Injectable,
|
|
1252
1219
|
args: [{
|
|
1253
1220
|
providedIn: 'root'
|
|
@@ -1296,8 +1263,7 @@ class LocalStorage {
|
|
|
1296
1263
|
setItem(key, data, schema) {
|
|
1297
1264
|
return this.storageMap.set(key, data, schema).pipe(
|
|
1298
1265
|
/* Transform `undefined` into `true` for backward compatibility with v7 */
|
|
1299
|
-
|
|
1300
|
-
mapTo(true));
|
|
1266
|
+
map(() => true));
|
|
1301
1267
|
}
|
|
1302
1268
|
/**
|
|
1303
1269
|
* Delete an item in storage
|
|
@@ -1310,8 +1276,7 @@ class LocalStorage {
|
|
|
1310
1276
|
removeItem(key) {
|
|
1311
1277
|
return this.storageMap.delete(key).pipe(
|
|
1312
1278
|
/* Transform `undefined` into `true` for backward compatibility with v7 */
|
|
1313
|
-
|
|
1314
|
-
mapTo(true));
|
|
1279
|
+
map(() => true));
|
|
1315
1280
|
}
|
|
1316
1281
|
/**
|
|
1317
1282
|
* Delete all items in storage
|
|
@@ -1323,13 +1288,12 @@ class LocalStorage {
|
|
|
1323
1288
|
clear() {
|
|
1324
1289
|
return this.storageMap.clear().pipe(
|
|
1325
1290
|
/* Transform `undefined` into `true` for backward compatibility with v7 */
|
|
1326
|
-
|
|
1327
|
-
mapTo(true));
|
|
1291
|
+
map(() => true));
|
|
1328
1292
|
}
|
|
1329
1293
|
}
|
|
1330
|
-
LocalStorage.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1331
|
-
LocalStorage.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
1332
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1294
|
+
LocalStorage.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: LocalStorage, deps: [{ token: StorageMap }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1295
|
+
LocalStorage.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: LocalStorage, providedIn: 'root' });
|
|
1296
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: LocalStorage, decorators: [{
|
|
1333
1297
|
type: Injectable,
|
|
1334
1298
|
args: [{
|
|
1335
1299
|
providedIn: 'root'
|
|
@@ -1365,13 +1329,92 @@ class StorageModule {
|
|
|
1365
1329
|
};
|
|
1366
1330
|
}
|
|
1367
1331
|
}
|
|
1368
|
-
StorageModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1369
|
-
StorageModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "
|
|
1370
|
-
StorageModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
1371
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1332
|
+
StorageModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: StorageModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1333
|
+
StorageModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.0.4", ngImport: i0, type: StorageModule });
|
|
1334
|
+
StorageModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: StorageModule });
|
|
1335
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: StorageModule, decorators: [{
|
|
1372
1336
|
type: NgModule
|
|
1373
1337
|
}] });
|
|
1374
1338
|
|
|
1339
|
+
/**
|
|
1340
|
+
* Allows to add a prefix before `localStorage` keys.
|
|
1341
|
+
* *Use only* for interoperability with other APIs or to avoid collision for multiple apps on the same subdomain.
|
|
1342
|
+
* **WARNING: do not change this option in an app already deployed in production, as previously stored data would be lost.**
|
|
1343
|
+
*
|
|
1344
|
+
* @example
|
|
1345
|
+
* bootstrapApplication(AppComponent, {
|
|
1346
|
+
* providers: [provideLocalStoragePrefix('custom_')]
|
|
1347
|
+
* });
|
|
1348
|
+
*
|
|
1349
|
+
* @example
|
|
1350
|
+
* NgModule({
|
|
1351
|
+
* providers: [provideLocalStoragePrefix('custom_')]
|
|
1352
|
+
* })
|
|
1353
|
+
* export class AppModule
|
|
1354
|
+
*/
|
|
1355
|
+
function provideLocalStoragePrefix(prefix) {
|
|
1356
|
+
return makeEnvironmentProviders([{ provide: LS_PREFIX, useValue: prefix }]);
|
|
1357
|
+
}
|
|
1358
|
+
/**
|
|
1359
|
+
* Allows to change the name used for `indexedDB` database.
|
|
1360
|
+
* *Use only* for interoperability with other APIs or to avoid collision for multiple apps on the same subdomain.
|
|
1361
|
+
* **WARNING: do not change this option in an app already deployed in production, as previously stored data would be lost.**
|
|
1362
|
+
*
|
|
1363
|
+
* @example
|
|
1364
|
+
* bootstrapApplication(AppComponent, {
|
|
1365
|
+
* providers: [provideIndexedDBDataBaseName('custom')]
|
|
1366
|
+
* });
|
|
1367
|
+
*
|
|
1368
|
+
* @example
|
|
1369
|
+
* NgModule({
|
|
1370
|
+
* providers: [provideIndexedDBDataBaseName('custom')]
|
|
1371
|
+
* })
|
|
1372
|
+
* export class AppModule
|
|
1373
|
+
*/
|
|
1374
|
+
function provideIndexedDBDataBaseName(name) {
|
|
1375
|
+
return makeEnvironmentProviders([{ provide: IDB_DB_NAME, useValue: name }]);
|
|
1376
|
+
}
|
|
1377
|
+
/**
|
|
1378
|
+
* Allows to change the database version used for `indexedDB` database.
|
|
1379
|
+
* Must be an unsigned **integer**.
|
|
1380
|
+
* **Use with caution as the creation of the store depends on the version.**
|
|
1381
|
+
* *Use only* for interoperability with other APIs or to avoid collision for multiple apps on the same subdomain.
|
|
1382
|
+
* **WARNING: do not change this option in an app already deployed in production, as previously stored data would be lost.**
|
|
1383
|
+
*
|
|
1384
|
+
* @example
|
|
1385
|
+
* bootstrapApplication(AppComponent, {
|
|
1386
|
+
* providers: [provideIndexedDBDataBaseVersion(2)]
|
|
1387
|
+
* });
|
|
1388
|
+
*
|
|
1389
|
+
* @example
|
|
1390
|
+
* NgModule({
|
|
1391
|
+
* providers: [provideIndexedDBDataBaseVersion(2)]
|
|
1392
|
+
* })
|
|
1393
|
+
* export class AppModule
|
|
1394
|
+
*/
|
|
1395
|
+
function provideIndexedDBDataBaseVersion(version) {
|
|
1396
|
+
return makeEnvironmentProviders([{ provide: IDB_DB_VERSION, useValue: version }]);
|
|
1397
|
+
}
|
|
1398
|
+
/**
|
|
1399
|
+
* Allows to change the name used for `indexedDB` object store.
|
|
1400
|
+
* *Use only* for interoperability with other APIs.
|
|
1401
|
+
* **WARNING: do not change this option in an app already deployed in production, as previously stored data would be lost.**
|
|
1402
|
+
*
|
|
1403
|
+
* @example
|
|
1404
|
+
* bootstrapApplication(AppComponent, {
|
|
1405
|
+
* providers: [provideIndexedDBStoreName('custom')]
|
|
1406
|
+
* });
|
|
1407
|
+
*
|
|
1408
|
+
* @example
|
|
1409
|
+
* NgModule({
|
|
1410
|
+
* providers: [provideIndexedDBStoreName('custom')]
|
|
1411
|
+
* })
|
|
1412
|
+
* export class AppModule
|
|
1413
|
+
*/
|
|
1414
|
+
function provideIndexedDBStoreName(name) {
|
|
1415
|
+
return makeEnvironmentProviders([{ provide: IDB_STORE_NAME, useValue: name }]);
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1375
1418
|
/*
|
|
1376
1419
|
* Public API Surface of local-storage
|
|
1377
1420
|
*/
|
|
@@ -1380,5 +1423,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImpor
|
|
|
1380
1423
|
* Generated bundle index. Do not edit.
|
|
1381
1424
|
*/
|
|
1382
1425
|
|
|
1383
|
-
export { JSONValidator, LocalDatabase, LocalStorage, SERIALIZATION_ERROR, SerializationError, StorageMap, StorageModule, VALIDATION_ERROR, ValidationError };
|
|
1426
|
+
export { JSONValidator, LocalDatabase, LocalStorage, SERIALIZATION_ERROR, SerializationError, StorageMap, StorageModule, VALIDATION_ERROR, ValidationError, provideIndexedDBDataBaseName, provideIndexedDBDataBaseVersion, provideIndexedDBStoreName, provideLocalStoragePrefix };
|
|
1427
|
+
//# sourceMappingURL=ngx-pwa-local-storage.mjs.map
|
|
1384
1428
|
//# sourceMappingURL=ngx-pwa-local-storage.mjs.map
|