@esfaenza/preferences 16.2.29 → 17.3.15
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/esm2022/esfaenza-preferences.mjs +4 -4
- package/esm2022/lib/models/PreferencesModuleConfig.mjs +25 -25
- package/esm2022/lib/persistor/base/CachePersistor.mjs +31 -31
- package/esm2022/lib/persistor/base/IBasePersistor.mjs +1 -1
- package/esm2022/lib/persistor/base/PreferencesPersistor.mjs +33 -33
- package/esm2022/lib/persistor/implementation/LocalStorageCachePersistor.mjs +51 -51
- package/esm2022/lib/persistor/implementation/LocalStoragePreferencesPersistor.mjs +51 -51
- package/esm2022/lib/preferences.module.mjs +33 -33
- package/esm2022/lib/services/base/IBaseStorage.mjs +1 -1
- package/esm2022/lib/services/base/base.service.mjs +140 -140
- package/esm2022/lib/services/cache.service.mjs +24 -24
- package/esm2022/lib/services/preferences.service.mjs +24 -24
- package/esm2022/lib/session/base/BaseSessionRetriever.mjs +5 -5
- package/esm2022/lib/session/implementation/DefaultSessionRetriever.mjs +27 -27
- package/esm2022/lib/tokens.mjs +9 -9
- package/esm2022/public-api.mjs +10 -10
- package/fesm2022/esfaenza-preferences.mjs +392 -392
- package/fesm2022/esfaenza-preferences.mjs.map +1 -1
- package/index.d.ts +5 -5
- package/lib/models/PreferencesModuleConfig.d.ts +29 -29
- package/lib/persistor/base/CachePersistor.d.ts +57 -57
- package/lib/persistor/base/IBasePersistor.d.ts +17 -17
- package/lib/persistor/base/PreferencesPersistor.d.ts +59 -59
- package/lib/persistor/implementation/LocalStorageCachePersistor.d.ts +22 -22
- package/lib/persistor/implementation/LocalStoragePreferencesPersistor.d.ts +22 -22
- package/lib/preferences.module.d.ts +9 -9
- package/lib/services/base/IBaseStorage.d.ts +9 -9
- package/lib/services/base/base.service.d.ts +80 -80
- package/lib/services/cache.service.d.ts +10 -10
- package/lib/services/preferences.service.d.ts +10 -10
- package/lib/session/base/BaseSessionRetriever.d.ts +11 -11
- package/lib/session/implementation/DefaultSessionRetriever.d.ts +21 -21
- package/lib/tokens.d.ts +9 -9
- package/package.json +3 -3
- package/public-api.d.ts +10 -10
|
@@ -4,417 +4,417 @@ import { __decorate, __param } from 'tslib';
|
|
|
4
4
|
import { of, forkJoin } from 'rxjs';
|
|
5
5
|
import { take, tap, switchMap, map, first } from 'rxjs/operators';
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Indica se recuperare autonomamente tutte le configurazioni salvate al bootstrap della libreria o se aspettare le richieste specifiche.
|
|
9
|
-
*
|
|
10
|
-
* Utile se non vengono salvate tante cose, potrebbe creare un momento di irresponsività se le info da recuperare sono molte
|
|
11
|
-
*/
|
|
12
|
-
const PREF_FULL_RETRIEVE_AT_START = new InjectionToken('PREF_FULL_RETRIEVE_AT_START');
|
|
13
|
-
/** Modalità di Debug */
|
|
7
|
+
/**
|
|
8
|
+
* Indica se recuperare autonomamente tutte le configurazioni salvate al bootstrap della libreria o se aspettare le richieste specifiche.
|
|
9
|
+
*
|
|
10
|
+
* Utile se non vengono salvate tante cose, potrebbe creare un momento di irresponsività se le info da recuperare sono molte
|
|
11
|
+
*/
|
|
12
|
+
const PREF_FULL_RETRIEVE_AT_START = new InjectionToken('PREF_FULL_RETRIEVE_AT_START');
|
|
13
|
+
/** Modalità di Debug */
|
|
14
14
|
const PREF_DEBUG_MODE = new InjectionToken('PREF_DEBUG_MODE');
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* Service che si occupa di salvare e recuperare le preferenze utente rispetto alle chiavi salvate
|
|
18
|
-
*/
|
|
19
|
-
let BaseService = class BaseService {
|
|
20
|
-
persistor;
|
|
21
|
-
PREF_FULL_RETRIEVE_AT_START;
|
|
22
|
-
/** Store in memoria delle preferenze locali che sarà persistito per mezzo della classe che fa le veci del **BasePreferencesPersistor** */
|
|
23
|
-
LocalStore = {};
|
|
24
|
-
/** Indica se ho già effettuato il retrieve di tutta la roba salvata */
|
|
25
|
-
AllRetrieved = false;
|
|
26
|
-
/**
|
|
27
|
-
* Costruttore
|
|
28
|
-
*
|
|
29
|
-
* @ignore
|
|
30
|
-
*/
|
|
31
|
-
constructor(persistor, PREF_FULL_RETRIEVE_AT_START) {
|
|
32
|
-
this.persistor = persistor;
|
|
33
|
-
this.PREF_FULL_RETRIEVE_AT_START = PREF_FULL_RETRIEVE_AT_START;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Salva un oggetto sia nella cache locale che nel persistor
|
|
37
|
-
*
|
|
38
|
-
* @param {string} key Chiave di persistenza
|
|
39
|
-
* @param {T} item Oggetto da salvare
|
|
40
|
-
*/
|
|
41
|
-
setItem(key, item) {
|
|
42
|
-
let detatched = JSON.parse(JSON.stringify(item));
|
|
43
|
-
if (detatched) {
|
|
44
|
-
if (detatched.selfsearch)
|
|
45
|
-
detatched.selfsearch = false;
|
|
46
|
-
if (detatched.page && detatched.items && detatched.items.length > 0)
|
|
47
|
-
detatched.items = [];
|
|
48
|
-
}
|
|
49
|
-
this.setLocalItem(key, detatched);
|
|
50
|
-
return this.persist(key, detatched);
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Salva un oggetto solo nella cache locale. Dovrà essere persistito manualmente o andrà perso al riavvio dell'applicazione
|
|
54
|
-
*
|
|
55
|
-
* @param {string} key Chiave di persistenza
|
|
56
|
-
* @param {T} item Oggetto da salvare
|
|
57
|
-
*/
|
|
58
|
-
setLocalItem(key, item) {
|
|
59
|
-
this.LocalStore[key] = item;
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Salva, per una sessione, una chiave con un valore, viene chiamato automaticamente dal metodo **store** ma dev'essere chiamato manualmente
|
|
64
|
-
* nel caso si utilizzi il metodo **storeLocal**
|
|
65
|
-
*
|
|
66
|
-
* @param {string} key Chiave da storicizzare
|
|
67
|
-
*/
|
|
68
|
-
persist(key, item) {
|
|
69
|
-
return this.persistor.persist(key, item);
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Recupera un oggetto in base a una chiave. Permette di accedere alla copia locale o alla copia persistita.
|
|
73
|
-
*
|
|
74
|
-
* @param {string} key Chiave del valore da recuperare
|
|
75
|
-
* @param {boolean} cacheBust Indica se ignorare il valore della cache locale e recuperare l'oggetto dallo store persistito,
|
|
76
|
-
* in caso fosse stato modificato fuori sistema o da un altro sistema
|
|
77
|
-
*
|
|
78
|
-
* @returns {Observable<T>} Oggetto richiesto
|
|
79
|
-
*/
|
|
80
|
-
getItem(key, cacheBust = false) {
|
|
81
|
-
if (this.PREF_FULL_RETRIEVE_AT_START && !this.AllRetrieved) {
|
|
82
|
-
let retrieveObservable = this.persistor.recoverAll().pipe(take(1), tap(t => {
|
|
83
|
-
this.AllRetrieved = true;
|
|
84
|
-
for (let cProp in t)
|
|
85
|
-
this.LocalStore[cProp] = t[cProp];
|
|
86
|
-
}));
|
|
87
|
-
return retrieveObservable.pipe(switchMap(r => this.doGetItem(key, cacheBust)));
|
|
88
|
-
}
|
|
89
|
-
return this.doGetItem(key, cacheBust);
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Funzione interna che effettivamente recupera le cache
|
|
93
|
-
*
|
|
94
|
-
* @param key Chiave da recuperare
|
|
95
|
-
* @param cacheBust Indica se raccogliere dagli elementi locali o se prendere una copia nuova dell'oggetto dalla cache persistita
|
|
96
|
-
*
|
|
97
|
-
* @returns Observable che alla sottoscrizione restituisce l'oggetto richiesto
|
|
98
|
-
*/
|
|
99
|
-
doGetItem(key, cacheBust = false) {
|
|
100
|
-
if (this.LocalStore[key] && !cacheBust)
|
|
101
|
-
return of(this.LocalStore[key]);
|
|
102
|
-
else {
|
|
103
|
-
var obj = this.persistor.recover(key);
|
|
104
|
-
if (!obj)
|
|
105
|
-
return of(null);
|
|
106
|
-
obj.pipe(tap(item => { this.LocalStore[key] = item; }));
|
|
107
|
-
return obj;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Recupera un oggetto in base a una chiave. Permette di accedere solo alla copia locale
|
|
112
|
-
*
|
|
113
|
-
* @param {string} key Chiave del valore da recuperare
|
|
114
|
-
*
|
|
115
|
-
* @returns {T} Oggetto richiesto
|
|
116
|
-
*/
|
|
117
|
-
getLocalItem(key) {
|
|
118
|
-
if (this.LocalStore[key])
|
|
119
|
-
return this.LocalStore[key];
|
|
120
|
-
else
|
|
121
|
-
return null;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Elimina un oggetto dalla cache sia locale che persistita
|
|
125
|
-
*
|
|
126
|
-
* @param {string} key Chiave da rimuovere
|
|
127
|
-
*/
|
|
128
|
-
removeItem(key) {
|
|
129
|
-
if (this.LocalStore[key])
|
|
130
|
-
delete this.LocalStore[key];
|
|
131
|
-
return this.persistor.remove(key);
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Ripulisce le impostazioni locali e le impostazioni salvate dal persistor
|
|
135
|
-
*/
|
|
136
|
-
clear() {
|
|
137
|
-
// Pulisco la cache locale
|
|
138
|
-
this.LocalStore = {};
|
|
139
|
-
// "Committo" le modifiche
|
|
140
|
-
return this.persistor.clear();
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
BaseService = __decorate([
|
|
144
|
-
__param(1, Optional()),
|
|
145
|
-
__param(1, Inject(PREF_FULL_RETRIEVE_AT_START))
|
|
16
|
+
/**
|
|
17
|
+
* Service che si occupa di salvare e recuperare le preferenze utente rispetto alle chiavi salvate
|
|
18
|
+
*/
|
|
19
|
+
let BaseService = class BaseService {
|
|
20
|
+
persistor;
|
|
21
|
+
PREF_FULL_RETRIEVE_AT_START;
|
|
22
|
+
/** Store in memoria delle preferenze locali che sarà persistito per mezzo della classe che fa le veci del **BasePreferencesPersistor** */
|
|
23
|
+
LocalStore = {};
|
|
24
|
+
/** Indica se ho già effettuato il retrieve di tutta la roba salvata */
|
|
25
|
+
AllRetrieved = false;
|
|
26
|
+
/**
|
|
27
|
+
* Costruttore
|
|
28
|
+
*
|
|
29
|
+
* @ignore
|
|
30
|
+
*/
|
|
31
|
+
constructor(persistor, PREF_FULL_RETRIEVE_AT_START) {
|
|
32
|
+
this.persistor = persistor;
|
|
33
|
+
this.PREF_FULL_RETRIEVE_AT_START = PREF_FULL_RETRIEVE_AT_START;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Salva un oggetto sia nella cache locale che nel persistor
|
|
37
|
+
*
|
|
38
|
+
* @param {string} key Chiave di persistenza
|
|
39
|
+
* @param {T} item Oggetto da salvare
|
|
40
|
+
*/
|
|
41
|
+
setItem(key, item) {
|
|
42
|
+
let detatched = JSON.parse(JSON.stringify(item));
|
|
43
|
+
if (detatched) {
|
|
44
|
+
if (detatched.selfsearch)
|
|
45
|
+
detatched.selfsearch = false;
|
|
46
|
+
if (detatched.page && detatched.items && detatched.items.length > 0)
|
|
47
|
+
detatched.items = [];
|
|
48
|
+
}
|
|
49
|
+
this.setLocalItem(key, detatched);
|
|
50
|
+
return this.persist(key, detatched);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Salva un oggetto solo nella cache locale. Dovrà essere persistito manualmente o andrà perso al riavvio dell'applicazione
|
|
54
|
+
*
|
|
55
|
+
* @param {string} key Chiave di persistenza
|
|
56
|
+
* @param {T} item Oggetto da salvare
|
|
57
|
+
*/
|
|
58
|
+
setLocalItem(key, item) {
|
|
59
|
+
this.LocalStore[key] = item;
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Salva, per una sessione, una chiave con un valore, viene chiamato automaticamente dal metodo **store** ma dev'essere chiamato manualmente
|
|
64
|
+
* nel caso si utilizzi il metodo **storeLocal**
|
|
65
|
+
*
|
|
66
|
+
* @param {string} key Chiave da storicizzare
|
|
67
|
+
*/
|
|
68
|
+
persist(key, item) {
|
|
69
|
+
return this.persistor.persist(key, item);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Recupera un oggetto in base a una chiave. Permette di accedere alla copia locale o alla copia persistita.
|
|
73
|
+
*
|
|
74
|
+
* @param {string} key Chiave del valore da recuperare
|
|
75
|
+
* @param {boolean} cacheBust Indica se ignorare il valore della cache locale e recuperare l'oggetto dallo store persistito,
|
|
76
|
+
* in caso fosse stato modificato fuori sistema o da un altro sistema
|
|
77
|
+
*
|
|
78
|
+
* @returns {Observable<T>} Oggetto richiesto
|
|
79
|
+
*/
|
|
80
|
+
getItem(key, cacheBust = false) {
|
|
81
|
+
if (this.PREF_FULL_RETRIEVE_AT_START && !this.AllRetrieved) {
|
|
82
|
+
let retrieveObservable = this.persistor.recoverAll().pipe(take(1), tap(t => {
|
|
83
|
+
this.AllRetrieved = true;
|
|
84
|
+
for (let cProp in t)
|
|
85
|
+
this.LocalStore[cProp] = t[cProp];
|
|
86
|
+
}));
|
|
87
|
+
return retrieveObservable.pipe(switchMap(r => this.doGetItem(key, cacheBust)));
|
|
88
|
+
}
|
|
89
|
+
return this.doGetItem(key, cacheBust);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Funzione interna che effettivamente recupera le cache
|
|
93
|
+
*
|
|
94
|
+
* @param key Chiave da recuperare
|
|
95
|
+
* @param cacheBust Indica se raccogliere dagli elementi locali o se prendere una copia nuova dell'oggetto dalla cache persistita
|
|
96
|
+
*
|
|
97
|
+
* @returns Observable che alla sottoscrizione restituisce l'oggetto richiesto
|
|
98
|
+
*/
|
|
99
|
+
doGetItem(key, cacheBust = false) {
|
|
100
|
+
if (this.LocalStore[key] && !cacheBust)
|
|
101
|
+
return of(this.LocalStore[key]);
|
|
102
|
+
else {
|
|
103
|
+
var obj = this.persistor.recover(key);
|
|
104
|
+
if (!obj)
|
|
105
|
+
return of(null);
|
|
106
|
+
obj.pipe(tap(item => { this.LocalStore[key] = item; }));
|
|
107
|
+
return obj;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Recupera un oggetto in base a una chiave. Permette di accedere solo alla copia locale
|
|
112
|
+
*
|
|
113
|
+
* @param {string} key Chiave del valore da recuperare
|
|
114
|
+
*
|
|
115
|
+
* @returns {T} Oggetto richiesto
|
|
116
|
+
*/
|
|
117
|
+
getLocalItem(key) {
|
|
118
|
+
if (this.LocalStore[key])
|
|
119
|
+
return this.LocalStore[key];
|
|
120
|
+
else
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Elimina un oggetto dalla cache sia locale che persistita
|
|
125
|
+
*
|
|
126
|
+
* @param {string} key Chiave da rimuovere
|
|
127
|
+
*/
|
|
128
|
+
removeItem(key) {
|
|
129
|
+
if (this.LocalStore[key])
|
|
130
|
+
delete this.LocalStore[key];
|
|
131
|
+
return this.persistor.remove(key);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Ripulisce le impostazioni locali e le impostazioni salvate dal persistor
|
|
135
|
+
*/
|
|
136
|
+
clear() {
|
|
137
|
+
// Pulisco la cache locale
|
|
138
|
+
this.LocalStore = {};
|
|
139
|
+
// "Committo" le modifiche
|
|
140
|
+
return this.persistor.clear();
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
BaseService = __decorate([
|
|
144
|
+
__param(1, Optional()),
|
|
145
|
+
__param(1, Inject(PREF_FULL_RETRIEVE_AT_START))
|
|
146
146
|
], BaseService);
|
|
147
147
|
|
|
148
|
-
/** Classe astratta che rappresenta lo stato di persistenza fra la libreria e uno storage */
|
|
149
|
-
class CachePersistor {
|
|
150
|
-
session;
|
|
151
|
-
/** @ignore Costruttore */
|
|
152
|
-
constructor(session) {
|
|
153
|
-
this.session = session;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Effettua il **persist** massivo di una lista di Chiave - Valore
|
|
157
|
-
*
|
|
158
|
-
* @param {{ [key: string]: string }} dictionary Dizionario (lista di Chiave - Valore) da persistere
|
|
159
|
-
*/
|
|
160
|
-
persistAll(dictionary) {
|
|
161
|
-
let observables = [];
|
|
162
|
-
for (let key in dictionary)
|
|
163
|
-
observables.push(this.persist(key, dictionary[key]));
|
|
164
|
-
return forkJoin(observables).pipe(map(res => res.reduce((acc, val) => acc && val, true)));
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Ottiene la chiave "Reale" da utilizzare per la persistenza di una chiave generica
|
|
168
|
-
*
|
|
169
|
-
* @param {string} key Chiave da storicizzare
|
|
170
|
-
*
|
|
171
|
-
* @returns {string} Unione fra l'identificativo della sessione e la chiave specificata
|
|
172
|
-
*/
|
|
173
|
-
getKey(key) {
|
|
174
|
-
return this.session.getSessionKey() + "§" + key + "§";
|
|
175
|
-
}
|
|
148
|
+
/** Classe astratta che rappresenta lo stato di persistenza fra la libreria e uno storage */
|
|
149
|
+
class CachePersistor {
|
|
150
|
+
session;
|
|
151
|
+
/** @ignore Costruttore */
|
|
152
|
+
constructor(session) {
|
|
153
|
+
this.session = session;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Effettua il **persist** massivo di una lista di Chiave - Valore
|
|
157
|
+
*
|
|
158
|
+
* @param {{ [key: string]: string }} dictionary Dizionario (lista di Chiave - Valore) da persistere
|
|
159
|
+
*/
|
|
160
|
+
persistAll(dictionary) {
|
|
161
|
+
let observables = [];
|
|
162
|
+
for (let key in dictionary)
|
|
163
|
+
observables.push(this.persist(key, dictionary[key]));
|
|
164
|
+
return forkJoin(observables).pipe(map(res => res.reduce((acc, val) => acc && val, true)));
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Ottiene la chiave "Reale" da utilizzare per la persistenza di una chiave generica
|
|
168
|
+
*
|
|
169
|
+
* @param {string} key Chiave da storicizzare
|
|
170
|
+
*
|
|
171
|
+
* @returns {string} Unione fra l'identificativo della sessione e la chiave specificata
|
|
172
|
+
*/
|
|
173
|
+
getKey(key) {
|
|
174
|
+
return this.session.getSessionKey() + "§" + key + "§";
|
|
175
|
+
}
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
// Angular
|
|
179
|
-
/** Service che si occupa di salvare e recuperare le preferenze utente rispetto alle chiavi salvate */
|
|
180
|
-
class CacheService extends BaseService {
|
|
181
|
-
/** @ignore Costruttore */
|
|
182
|
-
constructor(persistor, PREF_FULL_RETRIEVE_AT_START) {
|
|
183
|
-
super(persistor, PREF_FULL_RETRIEVE_AT_START);
|
|
184
|
-
}
|
|
185
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
186
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
187
|
-
}
|
|
188
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
189
|
-
type: Injectable
|
|
190
|
-
}], ctorParameters:
|
|
191
|
-
type: Optional
|
|
192
|
-
}, {
|
|
193
|
-
type: Inject,
|
|
194
|
-
args: [PREF_FULL_RETRIEVE_AT_START]
|
|
195
|
-
}] }]
|
|
178
|
+
// Angular
|
|
179
|
+
/** Service che si occupa di salvare e recuperare le preferenze utente rispetto alle chiavi salvate */
|
|
180
|
+
class CacheService extends BaseService {
|
|
181
|
+
/** @ignore Costruttore */
|
|
182
|
+
constructor(persistor, PREF_FULL_RETRIEVE_AT_START) {
|
|
183
|
+
super(persistor, PREF_FULL_RETRIEVE_AT_START);
|
|
184
|
+
}
|
|
185
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CacheService, deps: [{ token: CachePersistor }, { token: PREF_FULL_RETRIEVE_AT_START, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
186
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CacheService });
|
|
187
|
+
}
|
|
188
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CacheService, decorators: [{
|
|
189
|
+
type: Injectable
|
|
190
|
+
}], ctorParameters: () => [{ type: CachePersistor }, { type: undefined, decorators: [{
|
|
191
|
+
type: Optional
|
|
192
|
+
}, {
|
|
193
|
+
type: Inject,
|
|
194
|
+
args: [PREF_FULL_RETRIEVE_AT_START]
|
|
195
|
+
}] }] });
|
|
196
196
|
|
|
197
|
-
/**
|
|
198
|
-
* Classe astratta che rappresenta lo stato di persistenza fra la libreria e uno storage
|
|
199
|
-
*/
|
|
200
|
-
class PreferencesPersistor {
|
|
201
|
-
session;
|
|
202
|
-
/** @ignore Costruttore */
|
|
203
|
-
constructor(session) {
|
|
204
|
-
this.session = session;
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Effettua il **persist** massivo di una lista di Chiave - Valore
|
|
208
|
-
*
|
|
209
|
-
* @param {{ [key: string]: string }} dictionary Dizionario (lista di Chiave - Valore) da persistere
|
|
210
|
-
*/
|
|
211
|
-
persistAll(dictionary) {
|
|
212
|
-
let observables = [];
|
|
213
|
-
for (let key in dictionary)
|
|
214
|
-
observables.push(this.persist(key, dictionary[key]));
|
|
215
|
-
return forkJoin(observables).pipe(map(res => res.reduce((acc, val) => acc && val, true)));
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Ottiene la chiave "Reale" da utilizzare per la persistenza di una chiave generica
|
|
219
|
-
*
|
|
220
|
-
* @param {string} key Chiave da storicizzare
|
|
221
|
-
*
|
|
222
|
-
* @returns {string} Unione fra l'identificativo della sessione e la chiave specificata
|
|
223
|
-
*/
|
|
224
|
-
getKey(key) {
|
|
225
|
-
return this.session.getSessionKey() + "§" + key + "§";
|
|
226
|
-
}
|
|
197
|
+
/**
|
|
198
|
+
* Classe astratta che rappresenta lo stato di persistenza fra la libreria e uno storage
|
|
199
|
+
*/
|
|
200
|
+
class PreferencesPersistor {
|
|
201
|
+
session;
|
|
202
|
+
/** @ignore Costruttore */
|
|
203
|
+
constructor(session) {
|
|
204
|
+
this.session = session;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Effettua il **persist** massivo di una lista di Chiave - Valore
|
|
208
|
+
*
|
|
209
|
+
* @param {{ [key: string]: string }} dictionary Dizionario (lista di Chiave - Valore) da persistere
|
|
210
|
+
*/
|
|
211
|
+
persistAll(dictionary) {
|
|
212
|
+
let observables = [];
|
|
213
|
+
for (let key in dictionary)
|
|
214
|
+
observables.push(this.persist(key, dictionary[key]));
|
|
215
|
+
return forkJoin(observables).pipe(map(res => res.reduce((acc, val) => acc && val, true)));
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Ottiene la chiave "Reale" da utilizzare per la persistenza di una chiave generica
|
|
219
|
+
*
|
|
220
|
+
* @param {string} key Chiave da storicizzare
|
|
221
|
+
*
|
|
222
|
+
* @returns {string} Unione fra l'identificativo della sessione e la chiave specificata
|
|
223
|
+
*/
|
|
224
|
+
getKey(key) {
|
|
225
|
+
return this.session.getSessionKey() + "§" + key + "§";
|
|
226
|
+
}
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
// Angular
|
|
230
|
-
/** Service che si occupa di salvare e recuperare le preferenze utente rispetto alle chiavi salvate */
|
|
231
|
-
class PreferencesService extends BaseService {
|
|
232
|
-
/** @ignore Costruttore */
|
|
233
|
-
constructor(persistor, PREF_FULL_RETRIEVE_AT_START) {
|
|
234
|
-
super(persistor, PREF_FULL_RETRIEVE_AT_START);
|
|
235
|
-
}
|
|
236
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
237
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
238
|
-
}
|
|
239
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
240
|
-
type: Injectable
|
|
241
|
-
}], ctorParameters:
|
|
242
|
-
type: Optional
|
|
243
|
-
}, {
|
|
244
|
-
type: Inject,
|
|
245
|
-
args: [PREF_FULL_RETRIEVE_AT_START]
|
|
246
|
-
}] }]
|
|
229
|
+
// Angular
|
|
230
|
+
/** Service che si occupa di salvare e recuperare le preferenze utente rispetto alle chiavi salvate */
|
|
231
|
+
class PreferencesService extends BaseService {
|
|
232
|
+
/** @ignore Costruttore */
|
|
233
|
+
constructor(persistor, PREF_FULL_RETRIEVE_AT_START) {
|
|
234
|
+
super(persistor, PREF_FULL_RETRIEVE_AT_START);
|
|
235
|
+
}
|
|
236
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PreferencesService, deps: [{ token: PreferencesPersistor }, { token: PREF_FULL_RETRIEVE_AT_START, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
237
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PreferencesService });
|
|
238
|
+
}
|
|
239
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PreferencesService, decorators: [{
|
|
240
|
+
type: Injectable
|
|
241
|
+
}], ctorParameters: () => [{ type: PreferencesPersistor }, { type: undefined, decorators: [{
|
|
242
|
+
type: Optional
|
|
243
|
+
}, {
|
|
244
|
+
type: Inject,
|
|
245
|
+
args: [PREF_FULL_RETRIEVE_AT_START]
|
|
246
|
+
}] }] });
|
|
247
247
|
|
|
248
|
-
/**
|
|
249
|
-
* Classe di Configurazione per la libreria
|
|
250
|
-
*/
|
|
251
|
-
class PreferencesModuleConfig {
|
|
252
|
-
/**
|
|
253
|
-
* Indica se recuperare autonomamente tutte le configurazioni salvate al bootstrap della libreria o se aspettare le richieste specifiche.
|
|
254
|
-
*
|
|
255
|
-
* Utile se non vengono salvate tante cose, potrebbe creare un momento di irresponsività se le info da recuperare sono molte
|
|
256
|
-
*/
|
|
257
|
-
retrieveAllAtStart;
|
|
258
|
-
/**
|
|
259
|
-
* Classe che si deve occupare dello store "Definitivo" delle preferenze. Di default viene proposto uno store lato localStorage ma si può facilmente
|
|
260
|
-
* fornire uno storage che porta le informazioni lato Database
|
|
261
|
-
*/
|
|
262
|
-
preferencePersistor;
|
|
263
|
-
/**
|
|
264
|
-
* Classe che si deve occupare dello store "Definitivo" delle cache. Di default viene proposto uno store lato localStorage ma si può facilmente
|
|
265
|
-
* fornire uno storage che porta le informazioni lato Database
|
|
266
|
-
*/
|
|
267
|
-
cachePersistor;
|
|
268
|
-
/** Classe che si deve occupare per generare un ID univoco di sessione in base al quale verranno salvate le preferenze */
|
|
269
|
-
sessionRetriever;
|
|
270
|
-
/** Attiva la modalità di debug per l'esposizione di messaggi significativi */
|
|
271
|
-
debugMode;
|
|
248
|
+
/**
|
|
249
|
+
* Classe di Configurazione per la libreria
|
|
250
|
+
*/
|
|
251
|
+
class PreferencesModuleConfig {
|
|
252
|
+
/**
|
|
253
|
+
* Indica se recuperare autonomamente tutte le configurazioni salvate al bootstrap della libreria o se aspettare le richieste specifiche.
|
|
254
|
+
*
|
|
255
|
+
* Utile se non vengono salvate tante cose, potrebbe creare un momento di irresponsività se le info da recuperare sono molte
|
|
256
|
+
*/
|
|
257
|
+
retrieveAllAtStart;
|
|
258
|
+
/**
|
|
259
|
+
* Classe che si deve occupare dello store "Definitivo" delle preferenze. Di default viene proposto uno store lato localStorage ma si può facilmente
|
|
260
|
+
* fornire uno storage che porta le informazioni lato Database
|
|
261
|
+
*/
|
|
262
|
+
preferencePersistor;
|
|
263
|
+
/**
|
|
264
|
+
* Classe che si deve occupare dello store "Definitivo" delle cache. Di default viene proposto uno store lato localStorage ma si può facilmente
|
|
265
|
+
* fornire uno storage che porta le informazioni lato Database
|
|
266
|
+
*/
|
|
267
|
+
cachePersistor;
|
|
268
|
+
/** Classe che si deve occupare per generare un ID univoco di sessione in base al quale verranno salvate le preferenze */
|
|
269
|
+
sessionRetriever;
|
|
270
|
+
/** Attiva la modalità di debug per l'esposizione di messaggi significativi */
|
|
271
|
+
debugMode;
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
-
/**
|
|
275
|
-
* Classe astratta che si occupa di recuperare l'Id sessione univoco per applicazione ed utente collegato
|
|
276
|
-
*/
|
|
277
|
-
class BaseSessionRetriever {
|
|
274
|
+
/**
|
|
275
|
+
* Classe astratta che si occupa di recuperare l'Id sessione univoco per applicazione ed utente collegato
|
|
276
|
+
*/
|
|
277
|
+
class BaseSessionRetriever {
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
-
/**
|
|
281
|
-
* Implementazione di default per la classe **BaseSessionRetriever**
|
|
282
|
-
*/
|
|
283
|
-
class DefaultSessionRetriever extends BaseSessionRetriever {
|
|
284
|
-
/**
|
|
285
|
-
* Costruttore
|
|
286
|
-
*
|
|
287
|
-
* @ignore
|
|
288
|
-
*/
|
|
289
|
-
constructor() { super(); }
|
|
290
|
-
/**
|
|
291
|
-
* Ottiene un ID sessione
|
|
292
|
-
*
|
|
293
|
-
* @returns {string} ID sessione
|
|
294
|
-
*/
|
|
295
|
-
getSessionKey() {
|
|
296
|
-
return "DUMMY_SESSION";
|
|
297
|
-
}
|
|
298
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
299
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
300
|
-
}
|
|
301
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
302
|
-
type: Injectable
|
|
303
|
-
}], ctorParameters:
|
|
280
|
+
/**
|
|
281
|
+
* Implementazione di default per la classe **BaseSessionRetriever**
|
|
282
|
+
*/
|
|
283
|
+
class DefaultSessionRetriever extends BaseSessionRetriever {
|
|
284
|
+
/**
|
|
285
|
+
* Costruttore
|
|
286
|
+
*
|
|
287
|
+
* @ignore
|
|
288
|
+
*/
|
|
289
|
+
constructor() { super(); }
|
|
290
|
+
/**
|
|
291
|
+
* Ottiene un ID sessione
|
|
292
|
+
*
|
|
293
|
+
* @returns {string} ID sessione
|
|
294
|
+
*/
|
|
295
|
+
getSessionKey() {
|
|
296
|
+
return "DUMMY_SESSION";
|
|
297
|
+
}
|
|
298
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: DefaultSessionRetriever, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
299
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: DefaultSessionRetriever });
|
|
300
|
+
}
|
|
301
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: DefaultSessionRetriever, decorators: [{
|
|
302
|
+
type: Injectable
|
|
303
|
+
}], ctorParameters: () => [] });
|
|
304
304
|
|
|
305
|
-
// Angular
|
|
306
|
-
class LocalStorageCachePersistor extends CachePersistor {
|
|
307
|
-
constructor(session) {
|
|
308
|
-
super(session);
|
|
309
|
-
}
|
|
310
|
-
/** @ignore Vedi classe base */
|
|
311
|
-
persist(key, item) {
|
|
312
|
-
localStorage.setItem(this.getKey(key), JSON.stringify(item));
|
|
313
|
-
return of(true).pipe(first());
|
|
314
|
-
}
|
|
315
|
-
/** @ignore Vedi classe base */
|
|
316
|
-
recover(key) {
|
|
317
|
-
var ret = JSON.parse(localStorage.getItem(this.getKey(key)));
|
|
318
|
-
return of(ret).pipe(first());
|
|
319
|
-
}
|
|
320
|
-
/** @ignore Vedi classe base */
|
|
321
|
-
remove(key) {
|
|
322
|
-
var ret = localStorage.removeItem(this.getKey(key));
|
|
323
|
-
return of(true).pipe(first());
|
|
324
|
-
}
|
|
325
|
-
/** @ignore Vedi classe base */
|
|
326
|
-
recoverAll() {
|
|
327
|
-
var ret = {};
|
|
328
|
-
for (var k in localStorage) {
|
|
329
|
-
if (k.includes("§") && k.startsWith(this.session.getSessionKey()))
|
|
330
|
-
ret[k.match(/§(.*)§/)[1]] = JSON.parse(localStorage.getItem(k));
|
|
331
|
-
}
|
|
332
|
-
return of(ret).pipe(first());
|
|
333
|
-
}
|
|
334
|
-
/** @ignore Vedi classe base */
|
|
335
|
-
clear() {
|
|
336
|
-
for (var k in localStorage) {
|
|
337
|
-
if (k.includes("§") && k.startsWith(this.session.getSessionKey()))
|
|
338
|
-
localStorage.removeItem(k);
|
|
339
|
-
}
|
|
340
|
-
return of(true).pipe(first());
|
|
341
|
-
}
|
|
342
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
343
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
344
|
-
}
|
|
345
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
346
|
-
type: Injectable
|
|
347
|
-
}], ctorParameters:
|
|
305
|
+
// Angular
|
|
306
|
+
class LocalStorageCachePersistor extends CachePersistor {
|
|
307
|
+
constructor(session) {
|
|
308
|
+
super(session);
|
|
309
|
+
}
|
|
310
|
+
/** @ignore Vedi classe base */
|
|
311
|
+
persist(key, item) {
|
|
312
|
+
localStorage.setItem(this.getKey(key), JSON.stringify(item));
|
|
313
|
+
return of(true).pipe(first());
|
|
314
|
+
}
|
|
315
|
+
/** @ignore Vedi classe base */
|
|
316
|
+
recover(key) {
|
|
317
|
+
var ret = JSON.parse(localStorage.getItem(this.getKey(key)));
|
|
318
|
+
return of(ret).pipe(first());
|
|
319
|
+
}
|
|
320
|
+
/** @ignore Vedi classe base */
|
|
321
|
+
remove(key) {
|
|
322
|
+
var ret = localStorage.removeItem(this.getKey(key));
|
|
323
|
+
return of(true).pipe(first());
|
|
324
|
+
}
|
|
325
|
+
/** @ignore Vedi classe base */
|
|
326
|
+
recoverAll() {
|
|
327
|
+
var ret = {};
|
|
328
|
+
for (var k in localStorage) {
|
|
329
|
+
if (k.includes("§") && k.startsWith(this.session.getSessionKey()))
|
|
330
|
+
ret[k.match(/§(.*)§/)[1]] = JSON.parse(localStorage.getItem(k));
|
|
331
|
+
}
|
|
332
|
+
return of(ret).pipe(first());
|
|
333
|
+
}
|
|
334
|
+
/** @ignore Vedi classe base */
|
|
335
|
+
clear() {
|
|
336
|
+
for (var k in localStorage) {
|
|
337
|
+
if (k.includes("§") && k.startsWith(this.session.getSessionKey()))
|
|
338
|
+
localStorage.removeItem(k);
|
|
339
|
+
}
|
|
340
|
+
return of(true).pipe(first());
|
|
341
|
+
}
|
|
342
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: LocalStorageCachePersistor, deps: [{ token: BaseSessionRetriever }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
343
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: LocalStorageCachePersistor });
|
|
344
|
+
}
|
|
345
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: LocalStorageCachePersistor, decorators: [{
|
|
346
|
+
type: Injectable
|
|
347
|
+
}], ctorParameters: () => [{ type: BaseSessionRetriever }] });
|
|
348
348
|
|
|
349
|
-
// Angular
|
|
350
|
-
class LocalStoragePreferencesPersistor extends PreferencesPersistor {
|
|
351
|
-
constructor(session) {
|
|
352
|
-
super(session);
|
|
353
|
-
}
|
|
354
|
-
/** @ignore Vedi classe base */
|
|
355
|
-
persist(key, item) {
|
|
356
|
-
localStorage.setItem(this.getKey(key), JSON.stringify(item));
|
|
357
|
-
return of(true).pipe(first());
|
|
358
|
-
}
|
|
359
|
-
/** @ignore Vedi classe base */
|
|
360
|
-
recover(key) {
|
|
361
|
-
var ret = JSON.parse(localStorage.getItem(this.getKey(key)));
|
|
362
|
-
return of(ret).pipe(first());
|
|
363
|
-
}
|
|
364
|
-
/** @ignore Vedi classe base */
|
|
365
|
-
remove(key) {
|
|
366
|
-
var ret = localStorage.removeItem(this.getKey(key));
|
|
367
|
-
return of(true).pipe(first());
|
|
368
|
-
}
|
|
369
|
-
/** @ignore Vedi classe base */
|
|
370
|
-
recoverAll() {
|
|
371
|
-
var ret = {};
|
|
372
|
-
for (var k in localStorage) {
|
|
373
|
-
if (k.includes("§") && k.startsWith(this.session.getSessionKey()))
|
|
374
|
-
ret[k.match(/§(.*)§/)[1]] = JSON.parse(localStorage.getItem(k));
|
|
375
|
-
}
|
|
376
|
-
return of(ret).pipe(first());
|
|
377
|
-
}
|
|
378
|
-
/** @ignore Vedi classe base */
|
|
379
|
-
clear() {
|
|
380
|
-
for (var k in localStorage) {
|
|
381
|
-
if (k.includes("§") && k.startsWith(this.session.getSessionKey()))
|
|
382
|
-
localStorage.removeItem(k);
|
|
383
|
-
}
|
|
384
|
-
return of(true).pipe(first());
|
|
385
|
-
}
|
|
386
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
387
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
388
|
-
}
|
|
389
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
390
|
-
type: Injectable
|
|
391
|
-
}], ctorParameters:
|
|
349
|
+
// Angular
|
|
350
|
+
class LocalStoragePreferencesPersistor extends PreferencesPersistor {
|
|
351
|
+
constructor(session) {
|
|
352
|
+
super(session);
|
|
353
|
+
}
|
|
354
|
+
/** @ignore Vedi classe base */
|
|
355
|
+
persist(key, item) {
|
|
356
|
+
localStorage.setItem(this.getKey(key), JSON.stringify(item));
|
|
357
|
+
return of(true).pipe(first());
|
|
358
|
+
}
|
|
359
|
+
/** @ignore Vedi classe base */
|
|
360
|
+
recover(key) {
|
|
361
|
+
var ret = JSON.parse(localStorage.getItem(this.getKey(key)));
|
|
362
|
+
return of(ret).pipe(first());
|
|
363
|
+
}
|
|
364
|
+
/** @ignore Vedi classe base */
|
|
365
|
+
remove(key) {
|
|
366
|
+
var ret = localStorage.removeItem(this.getKey(key));
|
|
367
|
+
return of(true).pipe(first());
|
|
368
|
+
}
|
|
369
|
+
/** @ignore Vedi classe base */
|
|
370
|
+
recoverAll() {
|
|
371
|
+
var ret = {};
|
|
372
|
+
for (var k in localStorage) {
|
|
373
|
+
if (k.includes("§") && k.startsWith(this.session.getSessionKey()))
|
|
374
|
+
ret[k.match(/§(.*)§/)[1]] = JSON.parse(localStorage.getItem(k));
|
|
375
|
+
}
|
|
376
|
+
return of(ret).pipe(first());
|
|
377
|
+
}
|
|
378
|
+
/** @ignore Vedi classe base */
|
|
379
|
+
clear() {
|
|
380
|
+
for (var k in localStorage) {
|
|
381
|
+
if (k.includes("§") && k.startsWith(this.session.getSessionKey()))
|
|
382
|
+
localStorage.removeItem(k);
|
|
383
|
+
}
|
|
384
|
+
return of(true).pipe(first());
|
|
385
|
+
}
|
|
386
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: LocalStoragePreferencesPersistor, deps: [{ token: BaseSessionRetriever }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
387
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: LocalStoragePreferencesPersistor });
|
|
388
|
+
}
|
|
389
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: LocalStoragePreferencesPersistor, decorators: [{
|
|
390
|
+
type: Injectable
|
|
391
|
+
}], ctorParameters: () => [{ type: BaseSessionRetriever }] });
|
|
392
392
|
|
|
393
|
-
class PreferencesModule {
|
|
394
|
-
static forRoot(config) {
|
|
395
|
-
return {
|
|
396
|
-
ngModule: PreferencesModule,
|
|
397
|
-
providers: [
|
|
398
|
-
CacheService,
|
|
399
|
-
PreferencesService,
|
|
400
|
-
{ provide: PreferencesPersistor, useClass: config?.preferencePersistor || LocalStoragePreferencesPersistor },
|
|
401
|
-
{ provide: CachePersistor, useClass: config?.cachePersistor || LocalStorageCachePersistor },
|
|
402
|
-
{ provide: BaseSessionRetriever, useClass: config?.sessionRetriever || DefaultSessionRetriever },
|
|
403
|
-
{ provide: PREF_FULL_RETRIEVE_AT_START, useValue: config?.retrieveAllAtStart || true },
|
|
404
|
-
{ provide: PREF_DEBUG_MODE, useValue: config?.debugMode || false },
|
|
405
|
-
]
|
|
406
|
-
};
|
|
407
|
-
}
|
|
408
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
409
|
-
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
410
|
-
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
411
|
-
}
|
|
412
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
413
|
-
type: NgModule
|
|
393
|
+
class PreferencesModule {
|
|
394
|
+
static forRoot(config) {
|
|
395
|
+
return {
|
|
396
|
+
ngModule: PreferencesModule,
|
|
397
|
+
providers: [
|
|
398
|
+
CacheService,
|
|
399
|
+
PreferencesService,
|
|
400
|
+
{ provide: PreferencesPersistor, useClass: config?.preferencePersistor || LocalStoragePreferencesPersistor },
|
|
401
|
+
{ provide: CachePersistor, useClass: config?.cachePersistor || LocalStorageCachePersistor },
|
|
402
|
+
{ provide: BaseSessionRetriever, useClass: config?.sessionRetriever || DefaultSessionRetriever },
|
|
403
|
+
{ provide: PREF_FULL_RETRIEVE_AT_START, useValue: config?.retrieveAllAtStart || true },
|
|
404
|
+
{ provide: PREF_DEBUG_MODE, useValue: config?.debugMode || false },
|
|
405
|
+
]
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PreferencesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
409
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: PreferencesModule });
|
|
410
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PreferencesModule });
|
|
411
|
+
}
|
|
412
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PreferencesModule, decorators: [{
|
|
413
|
+
type: NgModule
|
|
414
414
|
}] });
|
|
415
415
|
|
|
416
|
-
/**
|
|
417
|
-
* Generated bundle index. Do not edit.
|
|
416
|
+
/**
|
|
417
|
+
* Generated bundle index. Do not edit.
|
|
418
418
|
*/
|
|
419
419
|
|
|
420
420
|
export { BaseSessionRetriever, CachePersistor, CacheService, LocalStorageCachePersistor, LocalStoragePreferencesPersistor, PREF_DEBUG_MODE, PREF_FULL_RETRIEVE_AT_START, PreferencesModule, PreferencesModuleConfig, PreferencesPersistor, PreferencesService };
|